Make missing lifetime suggestion verbose · rust-lang/rust@250b5d2 (original) (raw)

File tree

27 files changed

lines changed

27 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -3122,15 +3122,10 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
3122 3122 &mut err,
3123 3123 Some(lifetime_ref.ident.name.as_str()),
3124 3124 |err, _, span, message, suggestion, span_suggs
3125 - err.multipart_suggestion_with_style(
3125 + err.multipart_suggestion_verbose(
3126 3126 message,
3127 3127 std::iter::once((span, suggestion)).chain(span_suggs.clone()).collect(),
3128 3128 Applicability::MaybeIncorrect,
3129 -if span_suggs.is_empty() {
3130 -SuggestionStyle::ShowCode
3131 -} else {
3132 -SuggestionStyle::ShowAlways
3133 -},
3134 3129 );
3135 3130 true
3136 3131 },

| Original file line number | Diff line number | Diff line change | | | ----------------------------------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------- | | | @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'d` | | | | | 2 | 2 | --> $DIR/issue-109299.rs:6:12 | | | 3 | 3 | | | | | 4 | 4 | LL | impl Lexer<'d> { | | | 5 | | - | - ^^ undeclared lifetime | | | 6 | | - | | | | 7 | | - | help: consider introducing lifetime `'d` here: `<'d>` | | | | 5 | + | ^^ undeclared lifetime | | | | | 6 | + | | | | | | 7 | +help: consider introducing lifetime `'d` here | | | | | 8 | + | | | | | | 9 | +LL | impl<'d> Lexer<'d> { | | | | | 10 | + | ++++ | | | | 8 | 11 | | | | 9 | 12 | error: aborting due to 1 previous error | | | 10 | 13 | | |

| Original file line number | Diff line number | Diff line change | | | ----------------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- | | | @@ -7,19 +7,24 @@ LL | struct DataWrapper<'static> { | | | | | 7 | 7 | error[E0261]: use of undeclared lifetime name `'a` | | | 8 | 8 | --> $DIR/generic_const_early_param.rs:6:12 | | | 9 | 9 | | | | | 10 | | -LL | struct DataWrapper<'static> { | | | 11 | | - | - help: consider introducing lifetime `'a` here: `'a,` | | | 12 | | -LL | | | | 13 | 10 | LL | data: &'a [u8; Self::SIZE], | | | 14 | 11 | | ^^ undeclared lifetime | | | | 12 | + | | | | | | 13 | +help: consider introducing lifetime `'a` here | | | | | 14 | + | | | | | | 15 | +LL | struct DataWrapper<'a, 'static> { | | | | | 16 | + | +++ | | | | 15 | 17 | | | | 16 | 18 | error[E0261]: use of undeclared lifetime name `'a` | | | 17 | 19 | --> $DIR/generic_const_early_param.rs:10:18 | | | 18 | 20 | | | | | 19 | 21 | LL | impl DataWrapper<'a> { | | | 20 | | - | - ^^ undeclared lifetime | | | 21 | | - | | | | 22 | | - | help: consider introducing lifetime `'a` here: `<'a>` | | | | 22 | + | ^^ undeclared lifetime | | | | | 23 | + | | | | | | 24 | +help: consider introducing lifetime `'a` here | | | | | 25 | + | | | | | | 26 | +LL | impl<'a> DataWrapper<'a> { | | | | | 27 | + | ++++ | | | | 23 | 28 | | | | 24 | 29 | warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes | | | 25 | 30 | --> $DIR/generic_const_early_param.rs:1:12 | |

| Original file line number | Diff line number | Diff line change | | | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | | | @@ -2,27 +2,34 @@ error[E0261]: use of undeclared lifetime name `'unpinned` | | | | | 2 | 2 | --> $DIR/ice-cast-type-with-error-124848.rs:7:32 | | | 3 | 3 | | | | | 4 | 4 | LL | struct MyType<'a>(Cell<Option<&'unpinned mut MyType<'a>>>, Pin); | | | 5 | | - | - ^^^^^^^^^ undeclared lifetime | | | 6 | | - | | | | 7 | | - | help: consider introducing lifetime `'unpinned` here: `'unpinned,` | | | | 5 | + | ^^^^^^^^^ undeclared lifetime | | | | | 6 | + | | | | | | 7 | +help: consider introducing lifetime `'unpinned` here | | | | | 8 | + | | | | | | 9 | +LL | struct MyType<'unpinned, 'a>(Cell<Option<&'unpinned mut MyType<'a>>>, Pin); | | | | | 10 | + | ++++++++++ | | | | 8 | 11 | | | | 9 | 12 | error[E0261]: use of undeclared lifetime name `'a` | | | 10 | 13 | --> $DIR/ice-cast-type-with-error-124848.rs:14:53 | | | 11 | 14 | | | | | 12 | | -LL | fn main() { | | | 13 | | - | - help: consider introducing lifetime `'a` here: `<'a>` | | | 14 | | -... | | | 15 | 15 | LL | let bad_addr = &unpinned as *const Cell<Option<&'a mut MyType<'a>>> as usize; | | | 16 | 16 | | ^^ undeclared lifetime | | | | 17 | + | | | | | | 18 | +help: consider introducing lifetime `'a` here | | | | | 19 | + | | | | | | 20 | +LL | fn main<'a>() { | | | | | 21 | + | ++++ | | | | 17 | 22 | | | | 18 | 23 | error[E0261]: use of undeclared lifetime name `'a` | | | 19 | 24 | --> $DIR/ice-cast-type-with-error-124848.rs:14:67 | | | 20 | 25 | | | | | 21 | | -LL | fn main() { | | | 22 | | - | - help: consider introducing lifetime `'a` here: `<'a>` | | | 23 | | -... | | | 24 | 26 | LL | let bad_addr = &unpinned as *const Cell<Option<&'a mut MyType<'a>>> as usize; | | | 25 | 27 | | ^^ undeclared lifetime | | | | 28 | + | | | | | | 29 | +help: consider introducing lifetime `'a` here | | | | | 30 | + | | | | | | 31 | +LL | fn main<'a>() { | | | | | 32 | + | ++++ | | | | 26 | 33 | | | | 27 | 34 | error[E0412]: cannot find type `Pin` in this scope | | | 28 | 35 | --> $DIR/ice-cast-type-with-error-124848.rs:7:60 | |

Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
1 1 error[E0261]: use of undeclared lifetime name `'a`
2 2 --> $DIR/unresolved_lifetimes_error.rs:5:13
3 3 |
4 -LL | fn foo() -> [(); {
5 - | - help: consider introducing lifetime `'a` here: `<'a>`
6 4 LL | let a: &'a ();
7 5 | ^^ undeclared lifetime
6 + |
7 +help: consider introducing lifetime `'a` here
8 + |
9 +LL | fn foo<'a>() -> [(); {
10 + | ++++
8 11
9 12 error: aborting due to 1 previous error
10 13

| Original file line number | Diff line number | Diff line change | | | ------------------------------------------------------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------- | | | @@ -17,9 +17,12 @@ error[E0261]: use of undeclared lifetime name `'a` | | | | | 17 | 17 | --> $DIR/ice-unexpected-inference-var-122549.rs:11:34 | | | 18 | 18 | | | | | 19 | 19 | LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {} | | | 20 | | - | - ^^ undeclared lifetime | | | 21 | | - | | | | 22 | | - | help: consider introducing lifetime `'a` here: `'a,` | | | | 20 | + | ^^ undeclared lifetime | | | | | 21 | + | | | | | | 22 | +help: consider introducing lifetime `'a` here | | | | | 23 | + | | | | | | 24 | +LL | struct ConstChunksExact<'a, 'rem, T: 'a, const N: usize> {} | | | | | 25 | + | +++ | | | | 23 | 26 | | | | 24 | 27 | error[E0046]: not all trait items implemented, missing: `const_chunks_exact` | | | 25 | 28 | --> $DIR/ice-unexpected-inference-var-122549.rs:9:1 | |

| Original file line number | Diff line number | Diff line change | | | ----------------------------------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------- | | | @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'a` | | | | | 2 | 2 | --> $DIR/ice-type-mismatch-when-copying-112824.rs:5:21 | | | 3 | 3 | | | | | 4 | 4 | LL | pub struct Opcode2(&'a S); | | | 5 | | - | - ^^ undeclared lifetime | | | 6 | | - | | | | 7 | | - | help: consider introducing lifetime `'a` here: `<'a>` | | | | 5 | + | ^^ undeclared lifetime | | | | | 6 | + | | | | | | 7 | +help: consider introducing lifetime `'a` here | | | | | 8 | + | | | | | | 9 | +LL | pub struct Opcode2<'a>(&'a S); | | | | | 10 | + | ++++ | | | | 8 | 11 | | | | 9 | 12 | error[E0412]: cannot find type `S` in this scope | | | 10 | 13 | --> $DIR/ice-type-mismatch-when-copying-112824.rs:5:24 | |

| Original file line number | Diff line number | Diff line change | | | --------------------------------------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------- | | | @@ -139,9 +139,12 @@ error[E0261]: use of undeclared lifetime name `'a` | | | | | 139 | 139 | --> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:96:12 | | | 140 | 140 | | | | | 141 | 141 | LL | fn bar(_: &'a Trait) {} | | | 142 | | - | - ^^ undeclared lifetime | | | 143 | | - | | | | 144 | | - | help: consider introducing lifetime `'a` here: `<'a>` | | | | 142 | + | ^^ undeclared lifetime | | | | | 143 | + | | | | | | 144 | +help: consider introducing lifetime `'a` here | | | | | 145 | + | | | | | | 146 | +LL | fn bar<'a>(_: &'a Trait) {} | | | | | 147 | + | ++++ | | | | 145 | 148 | | | | 146 | 149 | error[E0106]: missing lifetime specifier | | | 147 | 150 | --> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:110:13 | | | @@ -171,9 +174,12 @@ error[E0261]: use of undeclared lifetime name `'a` | | | | | 171 | 174 | --> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:122:17 | | | 172 | 175 | | | | | 173 | 176 | LL | fn kitten() -> &'a Trait { | | | 174 | | - | - ^^ undeclared lifetime | | | 175 | | - | | | | 176 | | - | help: consider introducing lifetime `'a` here: `<'a>` | | | | 177 | + | ^^ undeclared lifetime | | | | | 178 | + | | | | | | 179 | +help: consider introducing lifetime `'a` here | | | | | 180 | + | | | | | | 181 | +LL | fn kitten<'a>() -> &'a Trait { | | | | | 182 | + | ++++ | | | | 177 | 183 | | | | 178 | 184 | error[E0106]: missing lifetime specifier | | | 179 | 185 | --> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:133:16 | |

| Original file line number | Diff line number | Diff line change | | | ------------------------------------------------------------------------ | ------------------------------------------------ | ----------------------------------------------------------------- | | | @@ -2,17 +2,23 @@ error[E0261]: use of undeclared lifetime name `'a` | | | | | 2 | 2 | --> $DIR/E0261.rs:1:12 | | | 3 | 3 | | | | | 4 | 4 | LL | fn foo(x: &'a str) { } | | | 5 | | - | - ^^ undeclared lifetime | | | 6 | | - | | | | 7 | | - | help: consider introducing lifetime `'a` here: `<'a>` | | | | 5 | + | ^^ undeclared lifetime | | | | | 6 | + | | | | | | 7 | +help: consider introducing lifetime `'a` here | | | | | 8 | + | | | | | | 9 | +LL | fn foo<'a>(x: &'a str) { } | | | | | 10 | + | ++++ | | | | 8 | 11 | | | | 9 | 12 | error[E0261]: use of undeclared lifetime name `'a` | | | 10 | 13 | --> $DIR/E0261.rs:5:9 | | | 11 | 14 | | | | | 12 | | -LL | struct Foo { | | | 13 | | - | - help: consider introducing lifetime `'a` here: `<'a>` | | | 14 | 15 | LL | x: &'a str, | | | 15 | 16 | | ^^ undeclared lifetime | | | | 17 | + | | | | | | 18 | +help: consider introducing lifetime `'a` here | | | | | 19 | + | | | | | | 20 | +LL | struct Foo<'a> { | | | | | 21 | + | ++++ | | | | 16 | 22 | | | | 17 | 23 | error: aborting due to 2 previous errors | | | 18 | 24 | | |

| Original file line number | Diff line number | Diff line change | | | ----------------------------------------------------------------------- | ---------------------------------------------------- | -------------------------------------------------------------- | | | @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'a` | | | | | 2 | 2 | --> $DIR/generic-extern-lifetime.rs:6:26 | | | 3 | 3 | | | | | 4 | 4 | LL | pub fn life2<'b>(x: &'a i32, y: &'b i32); | | | 5 | | - | - ^^ undeclared lifetime | | | 6 | | - | | | | 7 | | - | help: consider introducing lifetime `'a` here: `'a,` | | | | 5 | + | ^^ undeclared lifetime | | | | | 6 | + | | | | | | 7 | +help: consider introducing lifetime `'a` here | | | | | 8 | + | | | | | | 9 | +LL | pub fn life2<'a, 'b>(x: &'a i32, y: &'b i32); | | | | | 10 | + | +++ | | | | 8 | 11 | | | | 9 | 12 | error[E0261]: use of undeclared lifetime name `'a` | | | 10 | 13 | --> $DIR/generic-extern-lifetime.rs:8:37 | |