about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-03-02Rollup merge of #82662 - GuillaumeGomez:doc-attr-check, r=jyn514Guillaume Gomez-0/+38
Warn about unknown doc attributes Fixes #82652. For the text error, I decided to go for "invalid" instead of "unknown". What do you think? r? `@jyn514`
2021-03-02Rollup merge of #82655 - SkiFire13:fix-issue-81314, r=estebankGuillaume Gomez-16/+61
Highlight identifier span instead of whole pattern span in `unused` lint Fixes #81314 This pretty much just changes the span highlighted in the lint from `pat_sp` to `ident.span`. There's however an exception, which is in patterns with shorthands like `Point { y, ref mut x }`, where a suggestion to change just `x` would be invalid; in those cases I had to keep the pattern span. Another option would be suggesting something like `Point { y, x: ref mut _x }`. I also added a new test since there weren't any test that checked the `unused` lint with optional patterns.
2021-03-02Rollup merge of #82598 - GuillaumeGomez:rustdoc-rustc-pass, r=jyn514Guillaume Gomez-0/+15
Check stability and feature attributes in rustdoc Fixes #82588. cc `@Nemo157` `@camelid` r? `@jyn514`
2021-03-02Rollup merge of #82018 - jyn514:no-dummy-cache, r=camelid,GuillaumeGomezGuillaume Gomez-1/+3
Remove the dummy cache in `DocContext`; delete RenderInfo The same information is available everywhere; the only reason the dummy cache was needed is because it was previously stored in three different places. This consolidates the info a bit so the cache in `DocContext` is used throughout. As a bonus, it also completely removes `RenderInfo`. - Return a `Cache` from `run_global_ctxt`, not `RenderInfo` - Remove the unused `render_info` from `run_renderer` - Remove RenderInfo altogether Helps with https://github.com/rust-lang/rust/pull/82014. The next step is to move the `populate()` call before the `collect_intra_doc_links` pass, which currently breaks because a) lots of the cache is populated in early passes, and b) intra_doc_links itself sets some info with `register_res`. I'm working on separate PR for that to avoid making too many big changes at once. r? `@GuillaumeGomez`
2021-03-02Rollup merge of #81932 - jyn514:rustdoc-logging, r=Mark-SimulacrumGuillaume Gomez-1/+1
Always compile rustdoc with debug logging enabled when `download-rustc` is set Previously, logging at DEBUG or below would always be silenced, because rustc compiles tracing with the `static_max_level_info` feature. That makes sense for release artifacts, but not for developing rustdoc. Instead, this compiles two different versions of tracing: one in the release artifacts, distributed in the sysroot, and a new version compiled by rustdoc. Since `rustc_driver` is always linked to the version of sysroot, this copy/pastes `init_env_logging` into rustdoc. To avoid compiling an unnecessary version of tracing when `download-rustc` isn't set, this adds a new `using-ci-artifacts` feature for rustdoc and passes that feature in bootstrap. Addresses https://github.com/rust-lang/rust/issues/81930. This builds on https://github.com/rust-lang/rust/pull/79540. r? `@Mark-Simulacrum`
2021-03-02Rollup merge of #80734 - abonander:ab/issue-66693, r=oli-obkGuillaume Gomez-4/+92
check that first arg to `panic!()` in const is `&str` closes #66693 ~~TODO: regression test~~ cc `@RalfJung` for error message wording
2021-03-01Auto merge of #82663 - jyn514:rollup-xh3cb0c, r=jyn514bors-0/+37
Rollup of 8 pull requests Successful merges: - #81210 (BTreeMap: correct node size test case for choices of B) - #82360 (config.toml parsing error improvements) - #82428 (Update mdbook) - #82480 (Remove `ENABLE_DOWNLOAD_RUSTC` constant) - #82578 (Add some diagnostic items for Clippy) - #82620 (Apply lint restrictions from renamed lints) - #82635 (Fix typos in rustc_infer::infer::nll_relate) - #82645 (Clarify that SyncOnceCell::set blocks.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-03-01Add tests for doc attribute checkGuillaume Gomez-0/+38
2021-03-01Auto merge of #82587 - taiki-e:unaligned_references, r=oli-obkbors-0/+68
Enable report_in_external_macro in unaligned_references Fixes an issue where `unaligned_references` is not triggered in external macros, unlike `safe_packed_borrows`. Also, given that this lint is planned to eventually change to hard error (#82525), it would make sense for this lint to be triggered for external macros as well. See https://github.com/taiki-e/pin-project-lite/pull/55#issuecomment-787038676 and https://github.com/taiki-e/pin-project-lite/pull/55#issuecomment-787052874 for more. r? `@RalfJung`
2021-03-01check that first arg to `panic!()` in const is `&str`Austin Bonander-4/+92
2021-03-01Rollup merge of #82620 - jyn514:apply-renamed-lints, r=ManishearthJoshua Nelson-0/+37
Apply lint restrictions from renamed lints Previously, if you denied the old name of a renamed lint, it would warn about using the new name, but otherwise do nothing. Now, it will behave the same as if you'd used the new name. Fixes https://github.com/rust-lang/rust/issues/82615. r? `@ehuss`
2021-03-01Auto merge of #78360 - tmiasko:storage-markers, r=wesleywiser,oli-obkbors-3/+127
Remove storage markers if they won't be used during code generation The storage markers constitute a substantial portion of all MIR statements. At the same time, for builds without any optimizations, the storage markers have no further use during and after MIR optimization phase. If storage markers are not necessary for code generation, remove them.
2021-03-01Add regression testGiacomo Stevanato-0/+45
2021-03-01Rollup merge of #82643 - Aaron1011:test-macro-attrs, r=petrochenkovYuki Okushi-371/+2249
Add more proc-macro attribute tests r? `@petrochenkov`
2021-03-01Rollup merge of #82531 - GuillaumeGomez:gui-tests-start, r=jyn514Yuki Okushi-0/+37
Add GUI tests The start of a lot more of GUI tests! \o/ One test is to ensure that the search input can always be selected in all rustdoc "modes" (mobile, tablet mostly) whereas the second checks the shortcuts. r? `@jyn514`
2021-03-01Remove `krate.version`; fix `crate_version` in JSONJoshua Nelson-1/+3
Previously, `JsonRenderer::after_krate` called `krate.version.clone()`. The problem was it did that after the version was already moved into the cache, so it would always be None. The fix was to get the version from the cache instead.
2021-02-28Add more proc-macro attribute testsAaron Hill-371/+2249
2021-02-28Remove deleted pass from rustdoc test suiteJoshua Nelson-1/+1
`src/test/rustdoc-ui/deprecated-attrs.rs` tells rustdoc to run the `collapse-docs` pass, which no longer exists (it was removed in https://github.com/rust-lang/rust/pull/80261). Rustdoc doesn't actually give a proper diagnostic here; instead it prints an `error!` log. Now that tracing is compiled unconditionally, the log is now being emitted by default, because it's at the error level. rustdoc shouldn't be using `error!` logging for diagnostics in the first place, but in the meantime this change gets the testsuite to pass.
2021-02-28Bless some testsGiacomo Stevanato-16/+16
2021-02-28Add GUI testsGuillaume Gomez-0/+37
2021-02-28Apply lint restrictions from renamed lintsJoshua Nelson-0/+37
Previously, if you denied the old name of a renamed lint, it would warn about using the new name, but otherwise do nothing. Now, it will behave the same as if you'd used the new name.
2021-02-28Use -O in try_identity test that requires storage markersTomasz Miąsko-1/+1
2021-02-28Remove storage markers if they won't be used during code generationTomasz Miąsko-2/+126
The storage markers constitute a substantial portion of all MIR statements. At the same time, for builds without any optimizations, the storage markers have no further use during and after MIR optimization phase. If storage markers are not necessary for code generation, remove them.
2021-02-28Update rustdoc test to make it work with newly added rustc passesGuillaume Gomez-0/+2
2021-02-28Add test for rustdoc new check passGuillaume Gomez-0/+13
2021-02-27Rollup merge of #82563 - lucas-deangelis:issue-82209-fix, r=jyn514Dylan DPC-0/+11
Fix intra-doc handling of `Self` in enum Fixes #82209
2021-02-27Rollup merge of #81856 - Smittyvb:utf16-warn, r=matthewjasperDylan DPC-0/+0
Suggest character encoding is incorrect when encountering random null bytes This adds a note whenever null bytes are seen at the start of a token unexpectedly, since those tend to come from UTF-16 encoded files without a [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) (if a UTF-16 BOM appears it won't be valid UTF-8, but if there is no BOM it be both valid UTF-16 and valid but garbled UTF-8). This approach was suggested in https://github.com/rust-lang/rust/issues/73979#issuecomment-653976451. Closes #73979.
2021-02-27Enable report_in_external_macro in unaligned_referencesTaiki Endo-0/+68
2021-02-27Rollup merge of #82494 - estebank:issue-82455, r=petrochenkovDylan DPC-2/+32
Substitute erased lifetimes on bad placeholder type Fix #82455.
2021-02-27Rollup merge of #82442 - Aaron1011:fix/closure-mut-crash, r=matthewjasperDylan DPC-0/+40
Skip emitting closure diagnostic when closure_kind_origins has no entry Fixes #82438 This map is not guarnateed to have an entry for a closure.
2021-02-27Rollup merge of #82419 - petrochenkov:inertord, r=Aaron1011Dylan DPC-38/+112
expand: Preserve order of inert attributes during expansion Fixes https://github.com/rust-lang/rust/issues/67839 Fixes https://github.com/rust-lang/rust/issues/81871 r? `````@Aaron1011`````
2021-02-27Rollup merge of #82404 - nagisa:nagisa/hexagon-enums-llvm-comps, r=petrochenkovDylan DPC-5/+6
Test hexagon-enum only when llvm target is present See https://github.com/rust-lang/rust/pull/82379#issuecomment-783439754 r? ``````@petrochenkov`````` ``````@bors`````` rollup
2021-02-27Rollup merge of #82370 - ↵Dylan DPC-103/+88
0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank Improve anonymous lifetime note to indicate the target span Improvement for #81650 Cc #81995 Message after this improvement: (Improve note in the middle) ``` error[E0311]: the parameter type `T` may not live long enough --> src/main.rs:25:11 | 24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) { | -- help: consider adding an explicit lifetime bound...: `T: 'a +` 25 | scope.spawn(move |_| { | ^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 24:40... --> src/main.rs:24:40 | 24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) { | ^^^^^ note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds --> src/main.rs:25:11 | 25 | scope.spawn(move |_| { | ^^^^^ ``` r? ``````@estebank``````
2021-02-27Move test file, add test of generated linkLucas De Angelis-0/+3
2021-02-26Fix intra-doc handling of `Self` in enumLucas De Angelis-0/+8
Fixes #82209
2021-02-26Auto merge of #82552 - GuillaumeGomez:rollup-8dn1ztn, r=GuillaumeGomezbors-20/+84
Rollup of 8 pull requests Successful merges: - #81940 (Stabilize str_split_once) - #82165 (Reword labels on E0308 involving async fn return type) - #82456 (Replaced some unwrap_or and map_or with lazy variants) - #82491 (Consider inexpensive inlining criteria first) - #82506 (Properly account for non-shorthand pattern field in unused variable lint) - #82535 (Set codegen thread names) - #82545 (rustdoc: add optional woff2 versions of FiraSans.) - #82549 (Revert "Update normalize.css to 8.0.1") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-02-26Rollup merge of #82506 - estebank:unused_variable_lint, r=lcnrGuillaume Gomez-0/+46
Properly account for non-shorthand pattern field in unused variable lint Fix #82488
2021-02-26Rollup merge of #82165 - nellshamrell:nell/fix-80658-B, r=estebankGuillaume Gomez-20/+38
Reword labels on E0308 involving async fn return type Fix for #80658. When someone writes code like this: ```rust fn foo() -> u8 { async fn async_fn() -> () {} async_fn() } ``` And they try to compile it, they will see an error that looks like this: ```bash error[E0308]: mismatched types --> test.rs:4:5 | 1 | fn foo() -> u8 { | -- expected `u8` because of return type 2 | async fn async_fn() -> () {} | -- checked the `Output` of this `async fn`, found opaque type 3 | 4 | async_fn() | ^^^^^^^^^^ expected `u8`, found opaque type | = note: while checking the return type of this `async fn` = note: expected type `u8` found opaque type `impl Future` ```
2021-02-26Auto merge of #81458 - estebank:match-stmt-remove-semi, r=oli-obkbors-0/+81
Detect match statement intended to be tail expression CC #24157
2021-02-25Rollup merge of #82431 - Aaron1011:fix/bug-env, r=jyn514Aaron Hill-2/+4
Set RUST_BACKTRACE=0 when running `treat-err-as-bug` tests These ensure that these tests pass regardless of what RUST_BACKTRACE is set to in the user's shell.
2021-02-25Auto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obkbors-0/+185
Add #[rustc_legacy_const_generics] This is the first step towards removing `#[rustc_args_required_const]`: a new attribute is added which rewrites function calls of the form `func(a, b, c)` to `func::<{b}>(a, c)`. This allows previously stabilized functions in `stdarch` which use `rustc_args_required_const` to use const generics instead. This new attribute is not intended to ever be stabilized, it is only intended for use in `stdarch` as a replacement for `#[rustc_args_required_const]`. ```rust #[rustc_legacy_const_generics(1)] pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] { [x, Y, z] } fn main() { assert_eq!(foo(0 + 0, 1 + 1, 2 + 2), [0, 2, 4]); assert_eq!(foo::<{1 + 1}>(0 + 0, 2 + 2), [0, 2, 4]); } ``` r? `@oli-obk`
2021-02-25Detect match statement intended to be tail expressionEsteban Küber-0/+81
CC #24157
2021-02-25Rollup merge of #82364 - osa1:issue82361, r=estebankDylan DPC-0/+96
Improve error msgs when found type is deref of expected This improves help messages in two cases: - When expected type is `T` and found type is `&T`, we now look through blocks and suggest dereferencing the expression of the block, rather than the whole block. - In the above case, if the expression is an `&`, we not suggest removing the `&` instead of adding `*`. Both of these are demonstrated in the regression test. Before this patch the first error in the test would be: error[E0308]: `if` and `else` have incompatible types --> test.rs:8:9 | 5 | / if true { 6 | | a | | - expected because of this 7 | | } else { 8 | | b | | ^ expected `usize`, found `&usize` 9 | | }; | |_____- `if` and `else` have incompatible types | help: consider dereferencing the borrow | 7 | } else *{ 8 | b 9 | }; | Now: error[E0308]: `if` and `else` have incompatible types --> test.rs:8:9 | 5 | / if true { 6 | | a | | - expected because of this 7 | | } else { 8 | | b | | ^ | | | | | expected `usize`, found `&usize` | | help: consider dereferencing the borrow: `*b` 9 | | }; | |_____- `if` and `else` have incompatible types The second error: error[E0308]: `if` and `else` have incompatible types --> test.rs:14:9 | 11 | / if true { 12 | | 1 | | - expected because of this 13 | | } else { 14 | | &1 | | ^^ expected integer, found `&{integer}` 15 | | }; | |_____- `if` and `else` have incompatible types | help: consider dereferencing the borrow | 13 | } else *{ 14 | &1 15 | }; | now: error[E0308]: `if` and `else` have incompatible types --> test.rs:14:9 | 11 | / if true { 12 | | 1 | | - expected because of this 13 | | } else { 14 | | &1 | | ^- | | || | | |help: consider removing the `&`: `1` | | expected integer, found `&{integer}` 15 | | }; | |_____- `if` and `else` have incompatible types Fixes #82361 --- r? ````@estebank````
2021-02-25Rollup merge of #82220 - henryboisdequin:fixes-80853, r=varkorDylan DPC-7/+46
fix the false 'defined here' messages Closes #80853. Take this code: ```rust struct S; fn repro_ref(thing: S) { thing(); } ``` Previously, the error message would be this: ``` error[E0618]: expected function, found `S` --> src/lib.rs:4:5 | 3 | fn repro_ref(thing: S) { | ----- `S` defined here 4 | thing(); | ^^^^^-- | | | call expression requires function error: aborting due to previous error ``` This is incorrect as `S` is not defined in the function arguments, `thing` is defined there. With this change, the following is emitted: ``` error[E0618]: expected function, found `S` --> $DIR/80853.rs:4:5 | LL | fn repro_ref(thing: S) { | ----- is of type `S` LL | thing(); | ^^^^^-- | | | call expression requires function | = note: local variable `S` is not a function error: aborting due to previous error ``` As you can see, this error message points out that `thing` is of type `S` and later in a note, that `S` is not a function. This change does seem like a downside for some error messages. Take this example: ``` LL | struct Empty2; | -------------- is of type `Empty2` ``` As you can see, the error message shows that the definition of `Empty2` is of type `Empty2`. Although this isn't wrong, it would be more helpful if it would say something like this (which was there previously): ``` LL | struct Empty2; | -------------- `Empty2` defined here ``` If there is a better way of doing this, where the `Empty2` example would stay the same as without this change, please inform me. **Update: This is now fixed** CC `@camelid`
2021-02-25Rollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebankDylan DPC-0/+71
Do not consider using a semicolon inside of a different-crate macro Fixes #81943
2021-02-25Rollup merge of #82087 - estebank:abolish-ice, r=oli-obkDylan DPC-0/+25
Fix ICE caused by suggestion with no code substitutions Change suggestion logic to filter and checking _before_ creating specific resolution suggestion. Assert earlier that suggestions contain code substitions to make it easier in the future to debug invalid uses. If we find this becomes too noisy in the wild, we can always make the emitter resilient to these cases and remove the assertions. Fix #78651.
2021-02-25Rollup merge of #81713 - estebank:unstable-assoc-item-lint, r=oli-obkDylan DPC-7/+28
Account for associated consts in the "unstable assoc item name colission" lint Fix #81663.
2021-02-25add helpful error notes and fix the false 'defined here' messagesHenry Boisdequin-7/+46
2021-02-25Improve checking for attributeAmanieu d'Antras-16/+29
2021-02-24clarifies error when finding mismatched returned types for async functionsNell Shamrell-20/+38
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>