about summary refs log tree commit diff
path: root/src/test/ui/suggestions
AgeCommit message (Collapse)AuthorLines
2021-06-05Rollup merge of #85939 - m-ou-se:fix-remove-ref-macro-invocation, r=estebankYuki Okushi-1/+25
Fix suggestion for removing &mut from &mut macro!(). Fixes #85933 Before: (Note the suggestions.) ``` error[E0308]: mismatched types --> src/main.rs:2:21 | 2 | let _: String = &mut format!(""); | ------ ^^^^^^^^^^^^^^^^ | | | | | expected struct `String`, found `&mut String` | | help: consider removing the borrow: `mut format!("")` | expected due to this error[E0308]: mismatched types --> src/main.rs:3:21 | 3 | let _: String = &mut (format!("")); | ------ ^^^^^^^^^^^^^^^^^^ | | | | | expected struct `String`, found `&mut String` | | help: consider removing the borrow: `mut (format!(""))` | expected due to this ``` After: ``` error[E0308]: mismatched types --> src/main.rs:2:21 | 2 | let _: String = &mut format!(""); | ------ ^^^^^^^^^^^^^^^^ | | | | | expected struct `String`, found `&mut String` | | help: consider removing the borrow: `format!("")` | expected due to this error[E0308]: mismatched types --> src/main.rs:3:21 | 3 | let _: String = &mut (format!("")); | ------ ^^^^^^^^^^^^^^^^^^ | | | | | expected struct `String`, found `&mut String` | | help: consider removing the borrow: `format!("")` | expected due to this ```
2021-06-04Rollup merge of #85937 - m-ou-se:macro-ref-suggestions, r=estebankYuki Okushi-0/+81
Fix bad suggestions for code from proc_macro Fixes #85932 This disables these suggestions for spans from external macros, while keeping them for macros defined locally: Before: ``` 3 | #[hello] | ^^^^^^^^ | | | expected `&mut i32`, found integer | help: consider mutably borrowing here: `&mut #[hello]` ``` After: ``` 3 | #[hello] | ^^^^^^^^ expected `&mut i32`, found integer ``` Unchanged: ``` 26 | macro_rules! bla { () => { x(123); } } | ^^^ | | | expected `&mut i32`, found integer | help: consider mutably borrowing here: `&mut 123` ... 29 | bla!(); | ------- in this macro invocation ```
2021-06-03don't suggest unsized indirection in where-clausesTaylor Yu-0/+29
Skip where-clauses when suggesting using indirection in combination with `?Sized` bounds on type parameters.
2021-06-02Add test for removing &mut for &mut format!().Mara Bos-1/+25
2021-06-02Add test for ref suggestions in macros.Mara Bos-0/+81
2021-05-21Auto merge of #85511 - Mark-Simulacrum:eq-not-sup, r=nikomatsakisbors-16/+2
Adjust self-type check to require equality When we encounter `SomeType::<X>::foo`, `self_ty` is `SomeType<X>` and the method is defined in an impl on `SomeType<A>`. Previously, we required simply that `self_ty <: impl_ty`, but this is too lax: we should require equality in order to use the method. This was found as part of unrelated work on never type stabilization, but also fixes one of the wf test cases.
2021-05-21Adjust self-type to require equalityMark Rousskov-16/+2
2021-05-20Rollup merge of #85375 - SkiFire13:fix-85347, r=jackh726Guillaume Gomez-0/+29
Fix missing lifetimes diagnostics after #83759 In #83759 while rebasing I didn't realize there was a new function for suggesting to add lifetime arguments. It relied on some invariants, namely that if a generic type/trait has angle brackets then it must have some generic argument, which is now no longer true. This PR updates that function to handle the new invariants. This also adds a new regression test but I'm not sure if that's the correct place for it. Fixes #85347
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-1/+1
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-18Fix use placement for suggestions near main.Eric Huss-0/+101
2021-05-17Implement jackh726's suggestionsFabian Wolff-2/+131
2021-05-16Add regression testGiacomo Stevanato-0/+29
2021-05-16Suggest borrowing if a trait implementation is found for &/&mut <type>Fabian Wolff-4/+80
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-4/+4
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-05-11Auto merge of #82272 - b-naber:gat_diag, r=estebank,jackh726bors-39/+39
Improve diagnostics for GATs Fixes https://github.com/rust-lang/rust/issues/81801 Fixes https://github.com/rust-lang/rust/issues/81961 Fixes https://github.com/rust-lang/rust/issues/81862 r? `@estebank`
2021-05-11improve diagnosts for GATsb-naber-39/+39
2021-05-11Auto merge of #85100 - HKalbasi:issue-68049-fix, r=Aaron1011bors-0/+67
Fix invalid suggestion of changing impl trait signature Fix #68049
2021-05-11Fix CI problemshamidreza kalbasi-3/+3
2021-05-10More minor fixes suggested by @jackh726Fabian Wolff-0/+235
2021-05-09Implement @jackh726's suggestionsFabian Wolff-0/+34
2021-05-09Try to fix issue 68049hamidreza kalbasi-0/+67
2021-05-07Fix suggestions for missing return type lifetime parametersFabian Wolff-0/+4
2021-05-07Rollup merge of #84728 - camelid:sized-param-sugg-test, r=Mark-SimulacrumDylan DPC-0/+88
Add test for suggestion to borrow unsized function parameters Closes #82820. This is a regression test for #82820. This test case is included in more general tests, but I think the error regressed because there were a bunch of other diagnostic changes in the test that obscured this regression. Hopefully, having a test specific to the suggestion, and running rustfix for the test, will prevent this error from regressing in the future.
2021-05-06Add test for suggestion to borrow unsized function parametersCamelid-0/+88
This is a regression test for #82820. This test case is included in more general tests, but I think the error regressed because there were a bunch of other diagnostic changes in the test that obscured this regression. Hopefully, having a test specific to the suggestion, and running rustfix for the test, will prevent this error from regressing in the future.
2021-05-06Better rustc_on_unimplemented, and UI test fixesScott McMurray-1/+1
2021-05-05Rollup merge of #84808 - estebank:issue-84769, r=petrochenkovRalf Jung-2/+25
Account for unsatisfied bounds in E0599 Fix #84769, follow up to #84499, #83667.
2021-05-04Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakisbors-2/+9
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021 This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition. r? `@estebank`
2021-05-02add suggestion for unit enum variant when matched with a paternAliénore Bouttefeux-0/+47
2021-05-01Account for unsatisfied bounds in E0599Esteban Küber-2/+25
Fix #84769, follow up to #84499, #83667.
2021-04-23Tweak suggestion outputEsteban Küber-12/+1
2021-04-23Recover trait import suggestionEsteban Küber-0/+5
2021-04-23Add regression testEsteban Küber-0/+35
2021-04-20Auto merge of #84353 - estebank:as-ref-mir, r=davidtwcobors-59/+103
Suggest `.as_ref()` on borrow error involving `Option`/`Result` When encountering a E0382 borrow error involving an `Option` or `Result` provide a suggestion to use `.as_ref()` on the prior move location to avoid the move. Fix #84165.
2021-04-19Suggest `.as_ref()` on borrow error involving `Option`/`Result`Esteban Küber-59/+103
When encountering a E0382 borrow error involving an `Option` or `Result` provide a suggestion to use `.as_ref()` on the prior move location to avoid the move. Fix #84165.
2021-04-19fix suggestion for unsized function parameterslcnr-2/+2
2021-04-16Fix testsRyan Levick-2/+9
2021-04-09Auto merge of #83956 - estebank:issue-83892, r=varkorbors-0/+36
Use a more appropriate span for `;` suggestion Fix #83892.
2021-04-06Use a more appropriate span for `;` suggestionEsteban Küber-0/+36
Fix #83892.
2021-04-06Account for `ExprKind::Block` when suggesting .into() and derefEsteban Küber-4/+40
Fix #83943.
2021-03-31give full path of constraint in suggest_constraining_type_paramhi-rustin-13/+13
revert file bless with nll mode
2021-03-29Suggest box/pin/arc ing receiver on method callsEsteban Küber-11/+0
2021-03-26fix rustc_on_implemented `_Self` pathslcnr-2/+5
2021-03-25Bless nll testJack Huey-84/+3
2021-03-24resolve late lifetimes by itemJack Huey-134/+28
This reverts commit 22ae20733515d710c1134600bc1e29cdd76f6b9b.
2021-03-15More precise spans for HIR pathsVadim Petrochenkov-3/+3
2021-03-13Avoid sorting predicates by `DefId`Aaron Hill-2/+2
Fixes issue #82920 Even if an item does not change between compilation sessions, it may end up with a different `DefId`, since inserting/deleting an item affects the `DefId`s of all subsequent items. Therefore, we use a `DefPathHash` in the incremental compilation system, which is stable in the face of changes to unrelated items. In particular, the query system will consider the inputs to a query to be unchanged if any `DefId`s in the inputs have their `DefPathHash`es unchanged. Queries are pure functions, so the query result should be unchanged if the query inputs are unchanged. Unfortunately, it's possible to inadvertantly make a query result incorrectly change across compilations, by relying on the specific value of a `DefId`. Specifically, if the query result is a slice that gets sorted by `DefId`, the precise order will depend on how the `DefId`s got assigned in a particular compilation session. If some definitions end up with different `DefId`s (but the same `DefPathHash`es) in a subsequent compilation session, we will end up re-computing a *different* value for the query, even though the query system expects the result to unchanged due to the unchanged inputs. It turns out that we have been sorting the predicates computed during `astconv` by their `DefId`. These predicates make their way into the `super_predicates_that_define_assoc_type`, which ends up getting used to compute the vtables of trait objects. This, re-ordering these predicates between compilation sessions can lead to undefined behavior at runtime - the query system will re-use code built with a *differently ordered* vtable, resulting in the wrong method being invoked at runtime. This PR avoids sorting by `DefId` in `astconv`, fixing the miscompilation. However, it's possible that other instances of this issue exist - they could also be easily introduced in the future. To fully fix this issue, we should 1. Turn on `-Z incremental-verify-ich` by default. This will cause the compiler to ICE whenver an 'unchanged' query result changes between compilation sessions, instead of causing a miscompilation. 2. Remove the `Ord` impls for `CrateNum` and `DefId`. This will make it difficult to introduce ICEs in the first place.
2021-03-02Rollup merge of #82579 - osa1:issue82566, r=estebankYuki Okushi-0/+122
Fix turbofish recovery with multiple generic args This consists of two commits, each can be individually reviewed. - First commit fixes the issue in [this comment](https://github.com/rust-lang/rust/issues/82566#issuecomment-786924466). - Second commit fixes #82566 --- r? ````@estebank````
2021-02-27Recover from X<Y,Z> when parsing const exprÖmer Sinan Ağacan-3/+69
This adds recovery when in array type syntax user writes [X; Y<Z, ...>] instead of [X; Y::<Z, ...>] Fixes #82566 Note that whenever we parse an expression and know that the next token cannot be `,`, we should be calling check_mistyped_turbofish_with_multiple_type_params for this recovery. Previously we only did this for statement parsing (e.g. `let x = f<a, b>;`). We now also do it when parsing the length field in array type syntax.
2021-02-27Fix turbofish recovery with multiple generic argsÖmer Sinan Ağacan-0/+56
check_mistyped_turbofish_with_multiple_type_params was previously expecting type arguments between angle brackets, which is not right, as we can also see const expressions. We now use generic argument parser instead of type parser. Test with one, two, and three generic arguments added to check consistentcy between 1. check_no_chained_comparison: Called after parsing a nested binop application like `x < A > ...` where angle brackets are interpreted as binary operators and `A` is an expression. 2. check_mistyped_turbofish_with_multiple_type_params: called by `parse_full_stmt` when we expect to see a semicolon after parsing an expression but don't see it. (In `T2<1, 2>::C;`, the expression is `T2 < 1`)
2021-02-27Rollup merge of #82370 - ↵Dylan DPC-49/+34
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``````