about summary refs log tree commit diff
path: root/tests/ui/lifetimes
AgeCommit message (Collapse)AuthorLines
2023-12-12Rollup merge of #117914 - estebank:issue-85843, r=wesleywiserMatthias Krüger-5/+40
On borrow return type, suggest borrowing from arg or owned return type When we encounter a function with a return type that has an anonymous lifetime with no argument to borrow from, besides suggesting the `'static` lifetime we now also suggest changing the arguments to be borrows or changing the return type to be an owned type. ``` error[E0106]: missing lifetime specifier --> $DIR/variadic-ffi-6.rs:7:6 | LL | ) -> &usize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | ) -> &'static usize { | +++++++ help: instead, you are more likely to want to change one of the arguments to be borrowed... | LL | x: &usize, | + help: ...or alternatively, to want to return an owned value | LL - ) -> &usize { LL + ) -> usize { | ``` Fix #85843.
2023-12-07recurse into refs when comparing tys for diagnosticsjyn-4/+4
2023-12-05Add print_trait_sugaredMichael Goulet-14/+14
2023-11-30generic_const_exprs: suggest to add the feature, not use itRalf Jung-1/+1
2023-11-24Show number in error message even for one errorNilstrieb-47/+47
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-20Fix incorrect lifetime suggestionEsteban Küber-19/+2
2023-11-20Tweak wordingEsteban Küber-5/+5
2023-11-20On borrow return type, suggest borrowing from arg or owned return typeEsteban Küber-7/+59
When we encounter a function with a return type that has an anonymous lifetime with no argument to borrow from, besides suggesting the `'static` lifetime we now also suggest changing the arguments to be borrows or changing the return type to be an owned type. ``` error[E0106]: missing lifetime specifier --> $DIR/variadic-ffi-6.rs:7:6 | LL | ) -> &usize { | ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static` | LL | ) -> &'static usize { | +++++++ help: instead, you are more likely to want to change one of the arguments to be borrowed... | LL | x: &usize, | + help: ...or alternatively, to want to return an owned value | LL - ) -> &usize { LL + ) -> usize { | ``` Fix #85843.
2023-11-02Pretty print Fn traits in rustc_on_unimplementedMichael Goulet-12/+12
2023-10-26Quietly fail if an error has already occurredOli Scherer-0/+70
2023-10-24Rollup merge of #116841 - chenyukang:yukang-suggest-unwrap-expect, r=b-naberMatthias Krüger-0/+4
Suggest unwrap/expect for let binding type mismatch Found it when investigating https://github.com/rust-lang/rust/issues/116738 I'm not sure whether it's a good style to suggest `unwrap`, seems it's may helpful for newcomers. #116738 needs another fix to improve it.
2023-10-25suggest unwrap/expect for let binding type mismatchyukang-0/+4
2023-10-21Rollup merge of #116990 - estebank:issue-68445, r=cjgillotMatthias Krüger-0/+4
Mention `into_iter` on borrow errors suggestions when appropriate If we encounter a borrow error on `vec![1, 2, 3].iter()`, suggest `into_iter`. Fix #68445.
2023-10-20s/generator/coroutine/Oli Scherer-1/+1
2023-10-20Mention `into_iter` on borrow errors suggestions when appropriateEsteban Küber-0/+4
If we encounter a borrow error on `vec![1, 2, 3].iter()`, suggest `into_iter`. Fix #68445.
2023-10-08remove trailing dotsAli MJ Al-Nasrawy-8/+8
2023-10-08always show and explain sub regionAli MJ Al-Nasrawy-18/+26
2023-10-08improve the suggestion of generic_bound_failureAli MJ Al-Nasrawy-10/+12
2023-10-05Add a note to duplicate diagnosticsAlex Macleod-0/+1
2023-09-28make adt_const_params feature suggestion more consistent with others and ↵asquared31415-2/+2
only suggest it when the type can probably work
2023-09-14Properly consider binder vars in HasTypeFlagsVisitorMichael Goulet-0/+27
2023-09-11Rollup merge of #115743 - compiler-errors:no-impls, r=davidtwcoMatthias Krüger-0/+6
Point out if a local trait has no implementations Slightly helps with #115741
2023-09-10Point out if a local trait has no implementationsMichael Goulet-0/+6
2023-09-08Improve "associated type not found" diagnosticsLieselotte-1/+1
2023-08-08fix: not insert missing lifetime for `ConstParamTy`bohan-5/+0
2023-07-28Account for macros when suggesting a new let bindingEsteban Küber-1/+5
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-23/+23
2023-05-21Tweak the post-order for multi-successor blocksScott McMurray-1/+1
2023-05-05improve diagnostics and bless testsBoxy-12/+11
2023-04-29Do not force anonymous lifetimes in consts to be static.Camille GILLOT-0/+20
2023-04-21Auto merge of #110370 - c410-f3r:dqewdas, r=petrochenkovbors-0/+13
Move test files r? `@petrochenkov`
2023-04-20Move test filesCaio-0/+13
2023-04-19Extend and use `hir::Node::body_id`Maybe Waffle-0/+2
2023-04-14use param instead of tyAlex Chi-70/+46
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2023-04-14better suggestion based on hirAlex Chi-1/+148
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2023-04-14suggest lifetime for closure parameter type when mismatchAlex Chi-0/+8
2023-04-05Add regression test for #93911Yuki Okushi-0/+18
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-03-17Do not ICE for unexpected lifetime with ConstGeneric ribyukang-2/+24
2023-03-10feat: implement better error for manual impl of `Fn*` traitsEzra Shaw-0/+6
2023-03-03Label opaque type for 'captures lifetime' error messageMichael Goulet-3/+10
2023-02-26Don't trigger ICE for ReError when the other region is empty.Lenko Donchev-0/+40
2023-02-22diagnostics: update test cases to refer to assoc fn with `self` as methodMichael Howell-4/+4
2023-02-10Auto merge of #107652 - estebank:re_error, r=oli-obkbors-4/+74
Introduce `ReError` CC #69314 r? `@nagisa`
2023-02-09Rollup merge of #107648 - matthiaskrgr:unused_lifetime_104432_fix, r=cjgillotDylan DPC-0/+12
unused-lifetimes: don't warn about lifetimes originating from expanded code previously, we would warn like this: ```` warning: lifetime parameter `'s` never used --> /tmp/unusedlif/code.rs:6:62 | 5 | #[derive(Clone)] | - help: elide the unused lifetime 6 | struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As)); | ^^ | = note: requested on the command line with `-W unused-lifetimes` ```` Fixes #104432
2023-02-09Introduce `ReError`Esteban Küber-4/+74
CC #69314
2023-02-04Recover from default value for a lifetime in generic parameters.Lenko Donchev-0/+14
2023-02-03unused-lifetimes: don't warn about lifetimes originating from expanded codeMatthias Krüger-0/+12
previously, we would warn like this: ```` warning: lifetime parameter `'s` never used --> /tmp/unusedlif/code.rs:6:62 | 5 | #[derive(Clone)] | - help: elide the unused lifetime 6 | struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As)); | ^^ | = note: requested on the command line with `-W unused-lifetimes` ```` Fixes #104432
2023-01-30Modify primary span label for E0308Esteban Küber-3/+3
The previous output was unintuitive to users.
2023-01-25Rollup merge of #106897 - estebank:issue-99430, r=davidtwcoMatthias Krüger-0/+2
Tweak E0597 CC #99430
2023-01-23Add hint for missing lifetime bound on trait object when type alias is usedyanchen4791-0/+105