about summary refs log tree commit diff
path: root/src/test/ui/suggestions
AgeCommit message (Collapse)AuthorLines
2020-07-22Increase accuracy of lifetime bound on trait object impl suggestionEsteban Küber-35/+123
2020-07-22Detect when `'static` obligation might come from an `impl`Esteban Küber-0/+135
Address #71341.
2020-07-14Rollup merge of #74228 - estebank:unsized-param, r=davidtwcoManish Goregaokar-21/+7
Provide structured suggestion on unsized fields and fn params * Suggest borrowing or boxing unsized fields * Suggest borrowing fn parameters * Remove some verbosity of unsized errors * Remove `on_unimplemented` note from `trait Sized` Fix #23286, fix #28653. r? @davidtwco
2020-07-14Remove redundant explanatory `note` for type parametersEsteban Küber-11/+0
2020-07-14Suggest borrowing in more unsized fn param casesEsteban Küber-1/+4
2020-07-14Remove `Sized` `on_unimplemented` noteEsteban Küber-7/+1
2020-07-14Suggest boxing or borrowing unsized fieldsEsteban Küber-2/+2
2020-07-14Suggest struct pat on incorrect unit or tuple patEsteban Küber-5/+11
When encountering a unit or tuple pattern for a struct-like item, suggest using the correct pattern. Use `insert_field_names_local` when evaluating variants and store field names even when the list is empty in order to produce accurate structured suggestions.
2020-07-09Rollup merge of #74188 - estebank:tweak-ascription-typo-heuristic, ↵Manish Goregaokar-3/+0
r=petrochenkov Tweak `::` -> `:` typo heuristic and reduce verbosity Do not trigger on correct type ascription expressions with trailing operators and _do_ trigger on likely path typos where a turbofish is used. On likely path typos, remove note explaining type ascription. Clean up indentation. r? @petrochenkov
2020-07-09Tweak `::` -> `:` typo heuristic and reduce verbosityEsteban Küber-3/+0
Do not trigger on correct type ascription expressions with trailing operators and _do_ trigger on likely path typos where a turbofish is used. On likely path typos, remove note explaining type ascription.
2020-07-06Rollup merge of #73953 - JohnTitor:audit-hidden-sugg, r=estebankManish Goregaokar-17/+72
Audit hidden/short code suggestions Should fix #73641. Audit uses of `span_suggestion_short` and `tool_only_span_suggestion` (`span_suggestion_hidden` is already tested with `run-rustfix`). Leave some FIXMEs for futher improvements/fixes. r? @estebank
2020-07-02resolve: disallow label use through closure/asyncDavid Wood-15/+15
This commit modifies resolve to disallow `break`/`continue` to labels through closures or async blocks. This doesn't make sense and should have been prohibited anyway. Signed-off-by: David Wood <david@davidtw.co>
2020-07-02Audit uses of `span_suggestion_short`Yuki Okushi-17/+72
2020-06-27Rollup merge of #73672 - nellshamrell:async-fix, r=estebankManish Goregaokar-4/+6
Adds a clearer message for when the async keyword is missing from a f… …unction This is a somewhat simple fix for #66731. Under the current version of Rust, if a user has a rust file that looks like this: ```rust fn boo (){} async fn foo() { boo().await; } fn main() { } ``` And they attempt to run it, they will receive an error message that looks like this: ```bash error: incorrect use of `await` --> test.rs:4:14 | 4 | boo.await(); | ^^ help: `await` is not a method call, remove the parentheses error[E0277]: the trait bound `fn() {boo}: std::future::Future` is not satisfied --> test.rs:4:5 | 4 | boo.await(); | ^^^^^^^^^ the trait `std::future::Future` is not implemented for `fn() {boo}` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. ``` This is not very clear. With the changes made in this PR, when a user compiles and runs that same rust code, they will receive an error message that looks like this: ```bash error[E0277]: `()` is not a future. --> test.rs:4:5 | 4 | boo().await; | ^^^^^^^^^^^ `()` is not a future | = help: the trait `std::future::Future` is not implemented for `()` = note: required by `std::future::Future::poll` ``` In the future, I think we should make this error message even clearer, perhaps through a solution like the one described in [this comment](https://github.com/rust-lang/rust/issues/66731#issuecomment-644394287). However, as that potentially involves a major change proposal, I would rather get this change in now and make the error message a little clearer while an MCP is drafted and discussed. Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
2020-06-26Show the values and computation that would overflow a const evaluation or ↵Oliver Scherer-2/+2
propagation
2020-06-25Rollup merge of #73674 - estebank:op-trait-bound-suggestion, r=davidtwcoManish Goregaokar-0/+50
Tweak binop errors * Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
2020-06-25Adds a clearer message for when the async keyword is missing from a functionNell Shamrell-4/+6
Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
2020-06-24Suggest type param trait bound for binop only when appropriateEsteban Küber-26/+33
Verify that the binop trait *is* implemented for the types *if* all the involved type parameters are replaced with fresh inferred types. When this is the case, it means that the type parameter was indeed missing a trait bound. If this is not the case, provide a generic `note` refering to the type that doesn't implement the expected trait.
2020-06-23Tweak binop errorsEsteban Küber-0/+43
* Suggest potentially missing binop trait bound (fix #73416) * Use structured suggestion for dereference in binop
2020-06-23Rollup merge of #73496 - estebank:opaque-missing-lts-in-fn-3, r=nikomatsakisManish Goregaokar-0/+216
Account for multiple impl/dyn Trait in return type when suggesting `'_` Make `impl` and `dyn` Trait lifetime suggestions a bit more resilient. Follow up to #72804. r? @nikomatsakis
2020-06-23Rollup merge of #72271 - rakshith-ravi:master, r=varkorManish Goregaokar-0/+2
Improve compiler error message for wrong generic parameter order - Added optional "help" parameter that shows a help message on the compiler error if required. - Added a simple ordered parameter as a sample help. @varkor will make more changes as required. Let me know if I'm heading in the right direction. Fixes #68437 r? @varkor
2020-06-20Squashed all commitsRakshith Ravi-0/+2
2020-06-19Account for multiple impl/dyn Trait in return type when suggesting `'_`Esteban Küber-0/+216
2020-06-19Rollup merge of #73261 - estebank:generics-sized, r=nikomatsakisManish Goregaokar-0/+135
Suggest `?Sized` when applicable for ADTs Address #71790, fix #27964.
2020-06-18Rollup merge of #73320 - estebank:type-param-sugg-more, r=davidtwcoManish Goregaokar-0/+26
Make new type param suggestion more targetted Do not suggest new type param when encountering a missing type in an ADT field with generic parameters. Fix #72640.
2020-06-16Suggest new type param on single char identEsteban Küber-6/+18
Suggest new type parameter on single char uppercase ident even if it doesn't appear in a field's type parameter. Address comment in #72641.
2020-06-16Provide `help` when `T: ?Sized` can't be suggestedEsteban Küber-1/+60
2020-06-15Suggest `?Sized` when applicable for ADTsEsteban Küber-0/+76
Fix #71790.
2020-06-15Change E0758 to E0759 to avoid conflict with #72912Esteban Küber-2/+2
2020-06-15Register new eror codeEsteban Küber-1/+1
2020-06-15Use note for requirement source spanEsteban Küber-4/+7
2020-06-15review comments: wordingEsteban Küber-2/+2
2020-06-15Tweak wording and add error codeEsteban Küber-4/+4
2020-06-15Reduce verbosity of suggestion message and mention lifetime in labelEsteban Küber-2/+2
2020-06-13Make new type param suggestion more targettedEsteban Küber-0/+14
Do not suggest new type param when encountering a missing type in an ADT field with generic parameters. Fix #72640.
2020-06-13Prefer the associated consts for pattern matching errorLzu Tao-2/+2
2020-06-03Rollup merge of #72848 - camelid:fix-72815, r=varkorDylan DPC-2/+2
Correct generic parameter ordering in error note for E0747 Fixes #72815. r? @varkor
2020-06-02Rollup merge of #72775 - JohnTitor:await-sugg, r=estebankYuki Okushi-0/+35
Return early to avoid ICE Fixes #72766
2020-05-31Correct generic parameter ordering in error notecamelid-2/+2
2020-05-30Rollup merge of #72668 - ↵Ralf Jung-0/+68
awoimbee:give-fn-parenthetical-notation-parentheses, r=estebank Fix missing parentheses Fn notation error Fixes #72611 Well, fixes the error output, I think E0658 is the right error to throw in this case so I didn't change that
2020-05-30Tweak wording and spans of `'static` `dyn Trait`/`impl Trait` requirementsEsteban Küber-14/+5
2020-05-30Account for enclosing item when suggesting new lifetime nameEsteban Küber-10/+63
2020-05-30Tweak type parameter errors to reduce verbosityEsteban Küber-14/+2
2020-05-30review comment: tweak wording and account for span overlapEsteban Küber-3/+3
2020-05-30Account for returned `dyn Trait` evaluating to `'static` lifetimeEsteban Küber-3/+3
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-30Fix NLL outputEsteban Küber-0/+98
2020-05-30Improve output of argument anonymous borrow missing annotation involving ↵Esteban Küber-39/+8
opaque return type Go from ``` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> file8.rs:22:5 | 22 | / move || { 23 | | *dest = g.get(); 24 | | } | |_____^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 18:1... --> file8.rs:18:1 | 18 | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a 19 | | where 20 | | G: Get<T> 21 | | { ... | 24 | | } 25 | | } | |_^ note: ...so that the types are compatible --> file8.rs:22:5 | 22 | / move || { //~ ERROR cannot infer an appropriate lifetime 23 | | *dest = g.get(); 24 | | } | |_____^ = note: expected `&mut T` found `&mut T` note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 18:8... --> file8.rs:18:8 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^ note: ...so that return value is valid for the call --> file8.rs:18:45 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^^^^^^^^^^^^^^^^^^^^^^ ``` to ``` error[E0621]: explicit lifetime required in the type of `dest` --> file8.rs:18:45 | 18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required | | | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` ```
2020-05-30Account for missing lifetime in opaque return typeEsteban Küber-0/+246
When encountering an opaque closure return type that needs to bound a lifetime to the function's arguments, including borrows and type params, provide appropriate suggestions that lead to working code. Get the user from ```rust fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() where G: Get<T> { move || { *dest = g.get(); } } ``` to ```rust fn foo<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() +'a where G: Get<T> { move || { *dest = g.get(); } } ```
2020-05-30Test ui suggestion fn trait notationArthur Woimbée-0/+68
2020-05-30Return early to avoid ICEYuki Okushi-0/+35