about summary refs log tree commit diff
path: root/src/test/ui/suggestions/lifetimes
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-520/+0
2022-10-25Name impl trait in region bound suggestionMichael Goulet-3/+3
2022-09-26Merge remote-tracking branch 'origin/master' into ↵Matthew Kelly-10/+12
mpk/add-long-error-message-for-E0311
2022-09-05suggest introducing an explicit lifetime if it does not existTakayuki Maeda-10/+12
2022-08-19fix updated stderr outputsMatthew Kelly-1/+2
2022-07-26Use real opaque type instead of just saying impl TraitMichael Goulet-2/+2
2022-07-07Shorten span for closures.Camille GILLOT-1/+1
2022-06-03Fully stabilize NLLJack Huey-296/+34
2022-05-22Use revisions for NLL in suggestionsJack Huey-64/+111
2022-04-30Bless nll tests.Camille GILLOT-17/+25
2022-04-30Bless tests.Camille GILLOT-11/+19
2022-04-28Revert diagnostic duplication and accidental stabilizationOli Scherer-159/+29
2022-04-25Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLLmarmeladema-2/+20
2022-04-24Bless testsmarmeladema-3/+54
2022-04-17Bless nll test.Camille GILLOT-0/+106
2022-04-17Bless tests.Camille GILLOT-14/+246
2022-04-04diagnostics: use correct span for const genericsMichael Howell-0/+35
Fixes #95616
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-36/+16
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-16/+36
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2021-12-10Tweak wordingEsteban Kuber-4/+4
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-1/+6
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-10-15simplify constrain_opaque_typesNiko Matsakis-10/+16
2021-10-13Remove textual span from diagnostic stringOli Scherer-2/+2
2021-10-03Don't suggest replacing region with 'static in NLLAaron Hill-3/+0
Fixes #73159 This is similar to #69350 - if the user didn't initially write out a 'static lifetime, adding 'static in response to a lifetime error is usually the wrong thing to do.
2021-08-11Modify structured suggestion outputEsteban Küber-8/+8
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-07-20Get back the more precise suggestion spans of old regionckOli Scherer-2/+2
2021-03-29Suggest box/pin/arc ing receiver on method callsEsteban Küber-11/+0
2021-03-25Bless nll testJack Huey-84/+3
2021-03-24resolve late lifetimes by itemJack Huey-110/+4
This reverts commit 22ae20733515d710c1134600bc1e29cdd76f6b9b.
2021-02-21Add indication of anonymous lifetime position0yoyoyo-49/+34
2021-02-12Add nll test0yoyoyo-0/+17
2021-02-12Fix suggestion to introduce explicit lifetime0yoyoyo-0/+47
2020-09-28pretty.rs: Update Closure and Generator printAman Arora-4/+4
Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com> Co-authored-by: Logan Mosier <logmosier@gmail.com>
2020-08-22Use smaller def span for functionsAaron Hill-34/+9
Currently, the def span of a funtion encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); }``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. * The 'unconditional recursion' lint uses the full span to show additional context for the recursive call. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-07-22Further tweak wording of E0759 and introduce E0767Esteban Küber-10/+10
2020-06-19Account for multiple impl/dyn Trait in return type when suggesting `'_`Esteban Küber-0/+216
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-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-7/+1
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(); } } ```