about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
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 feature gate for inherent associate types.Olivier FAURE-18/+71
2021-02-25Update test/pretty output for edition preludes.Mara Bos-6/+6
2021-02-25Update test output for edition preludes.Mara Bos-11/+11
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>
2021-02-24Properly account for non-shorthand pattern field in unused variable lintEsteban Küber-0/+46
Fix #82488
2021-02-25Fix testsAmanieu d'Antras-4/+12
2021-02-25Address review commentsAmanieu d'Antras-0/+3
2021-02-24Account for associated consts in the "unstable assoc item name colission" lintEsteban Küber-7/+28
Fix #81663.
2021-02-24Auto merge of #82159 - BoxyUwU:uwu, r=varkorbors-0/+47
Use correct param_env in conservative_is_privately_uninhabited cc `@lcnr` r? `@varkor` since this is your FIXME that was removed ^^
2021-02-24Substitute erased lifetimes on bad placeholder typeEsteban Küber-2/+32
Fix #82455.
2021-02-24Auto merge of #80914 - GuillaumeGomez:remove-is_spotlight, r=jyn514bors-0/+24
Remove is_spotlight field from `Trait` Small PR, only the last commit is relevant here. The rest is coming from #80883 because I need the `TyCtxt` stored inside `Cache`. The point is to make ItemKind looks as close as possible to the compiler type so that it makes the switch simpler (which is why I make all these "small" PRs). r? `@jyn514`
2021-02-24Auto merge of #80475 - simonvandel:fix-77355, r=oli-obkbors-355/+482
New mir-opt pass to simplify gotos with const values (reopening #77486) Reopening PR #77486 Fixes #77355 This pass optimizes the following sequence ```rust bb2: { _2 = const true; goto -> bb3; } bb3: { switchInt(_2) -> [false: bb4, otherwise: bb5]; } ``` into ```rust bb2: { _2 = const true; goto -> bb5; } ```
2021-02-24Add suggestion for iterators in iteratorsKevin Per-0/+32
2021-02-24Properly reject non-const argumentsAmanieu d'Antras-0/+36
2021-02-24TODO -> FIXMEAmanieu d'Antras-1/+1
2021-02-23yeetEllen-0/+47
2021-02-23* Fix some typoGuillaume Gomez-0/+24
* Improve documentation * Add a test to ensure that spotlighted traits from dependencies are taken into account as expected
2021-02-23Do not consider using a semicolon inside of a different-crate macroMichael Howell-0/+71
Fixes #81943
2021-02-23Move tests to subdirectoryAmanieu d'Antras-0/+0
2021-02-23Add #[rustc_legacy_const_generics]Amanieu d'Antras-0/+125
2021-02-23Rollup merge of #82362 - osa1:issue81918, r=oli-obkDylan DPC-0/+11
Fix mir-cfg dumps Fixes #81918 Fixes #82326 (duplicate) Fixes #82325 --- r? ``@oli-obk``
2021-02-23Rollup merge of #82311 - aDotInTheVoid:jsondocck-improvements, r=jyn514Dylan DPC-10/+14
Jsondocck improvements Adds 2 new commands, ```@is``` and ```@set`.`` ```@is``` works like ```@has`,`` except instead of checking if any value matches, it checks that there is exactly one value, and it matches. This allows more precise testing. ```@set``` gets a value, and saves it to be used later. This makes it possible to check that an item appears in the correct module. Once this lands, the rest of the test suite can be upgraded to use these. cc ``@CraftSpider`` ``@rustbot`` modify labels: +T-rustdoc +A-rustdoc-json +A-testsuite
2021-02-23Rollup merge of #82308 - estebank:issue-82290, r=lcnrDylan DPC-0/+27
Lower condition of `if` expression before it's "then" block Fix #82290, fix #82250.
2021-02-23Rollup merge of #82297 - tmiasko:write-only, r=oli-obkDylan DPC-1/+68
Consider auto derefs before warning about write only fields Changes from #81473 extended the dead code lint with an ability to detect fields that are written to but never read from. The implementation skips over fields on the left hand side of an assignment, without marking them as live. A field access might involve an automatic dereference and de-facto read the field. Conservatively mark expressions with deref adjustments as live to avoid generating false positive warnings. Closes #81626.
2021-02-23Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakisDylan DPC-24/+170
Support `pub` on `macro_rules` This rebases and updates `since` version of #78166 from ``@petrochenkov`` r? ``@nikomatsakis``
2021-02-23Rollup merge of #82113 - m-ou-se:panic-format-lint, r=estebankDylan DPC-4/+76
Improve non_fmt_panic lint. This change: - fixes the span used by this lint in the case the panic argument is a single macro expansion (e.g. `panic!(a!())`); - adds a suggestion for `panic!(format!(..))` to remove `format!()` instead of adding `"{}", ` or using `panic_any` like it does now; and - fixes the incorrect suggestion to replace `panic![123]` by `panic_any(123]`. Fixes #82109. Fixes #82110. Fixes #82111. Example output: ``` warning: panic message is not a string literal --> src/main.rs:8:12 | 8 | panic!(format!("error: {}", "oh no")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(non_fmt_panic)]` on by default = note: this is no longer accepted in Rust 2021 = note: the panic!() macro supports formatting, so there's no need for the format!() macro here help: remove the `format!(..)` macro call | 8 | panic!("error: {}", "oh no"); | -- -- ``` r? `@estebank`
2021-02-23Rollup merge of #81629 - 1000teslas:issue-81365-fix, r=Aaron1011Dylan DPC-0/+520
Point out implicit deref coercions in borrow Fixes #81365 `@Aaron1011` I'm not sure why my code shows the note even in an implicit `Deref` call. See the output for `issue-81365-8.rs`.
2021-02-23Skip emitting closure diagnostic when closure_kind_origins has no entryAaron Hill-0/+40
Fixes #82438 This map is not guarnateed to have an entry for a closure.
2021-02-23Add full test for rustdoc map fileGuillaume Gomez-0/+67
2021-02-23Add tests for --generate-redirect-map optionGuillaume Gomez-0/+29
2021-02-23Auto merge of #82102 - nagisa:nagisa/fix-dwo-name, r=davidtwcobors-0/+12
Set path of the compile unit to the source directory As part of the effort to implement split dwarf debug info, we ended up setting the compile unit location to the output directory rather than the source directory. Furthermore, it seems like we failed to remap the prefixes for this as well! The desired behaviour is to instead set the `DW_AT_GNU_dwo_name` to a path relative to compiler's working directory. This still allows debuggers to find the split dwarf files, while not changing the behaviour of the code that is compiling with regular debug info, and not changing the compiler's behaviour with regards to reproducibility. Fixes #82074 cc `@alexcrichton` `@davidtwco`
2021-02-23Improve error msgs when found type is deref of expectedÖmer Sinan Ağacan-0/+96
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