diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 61a177f291ba0..b33667501cd02 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -374,7 +374,6 @@ E0633: include_str!("./error_codes/E0633.md"), E0634: include_str!("./error_codes/E0634.md"), E0635: include_str!("./error_codes/E0635.md"), E0636: include_str!("./error_codes/E0636.md"), -E0637: include_str!("./error_codes/E0637.md"), E0638: include_str!("./error_codes/E0638.md"), E0639: include_str!("./error_codes/E0639.md"), E0641: include_str!("./error_codes/E0641.md"), @@ -632,6 +631,7 @@ E0787: include_str!("./error_codes/E0787.md"), // E0629, // missing 'feature' (rustc_const_unstable) // E0630, // rustc_const_unstable attribute must be paired with stable/unstable // attribute +// E0637, // merged into E0106 E0640, // infer outlives requirements // E0645, // trait aliases not finished // E0694, // an unknown tool name found in scoped attributes diff --git a/compiler/rustc_error_codes/src/error_codes/E0637.md b/compiler/rustc_error_codes/src/error_codes/E0637.md index 62d5565df2798..d5ed38c2939f9 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0637.md +++ b/compiler/rustc_error_codes/src/error_codes/E0637.md @@ -1,9 +1,11 @@ +#### Note: this error code is no longer emitted by the compiler. + `'_` lifetime name or `&T` without an explicit lifetime name has been used on illegal place. Erroneous code example: -```compile_fail,E0106,E0637 +```compile_fail,E0106 fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str { //^^ `'_` is a reserved lifetime name if str1.len() > str2.len() { diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 723e66e9ef618..4f27ff7f4aa67 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -224,11 +224,6 @@ enum LifetimeRibKind { /// For **Deprecated** cases, report an error. AnonymousCreateParameter(NodeId), - /// Give a hard error when either `&` or `'_` is written. Used to - /// rule out things like `where T: Foo<'_>`. Does not imply an - /// error on default object bounds (e.g., `Box`). - AnonymousReportError, - /// Pass responsibility to `resolve_lifetime` code for all cases. AnonymousPassThrough(NodeId), } @@ -881,40 +876,38 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { debug!("visit_where_predicate {:?}", p); let previous_value = replace(&mut self.diagnostic_metadata.current_where_predicate, Some(p)); - self.with_lifetime_rib(LifetimeRibKind::AnonymousReportError, |this| { - if let WherePredicate::BoundPredicate(WhereBoundPredicate { - ref bounded_ty, - ref bounds, - ref bound_generic_params, - span: predicate_span, - .. - }) = p - { - let span = if bound_generic_params.is_empty() { - predicate_span.shrink_to_lo() - } else { - *predicate_span - }; - this.with_generic_param_rib( - &bound_generic_params, - NormalRibKind, - LifetimeRibKind::Generics { - parent: bounded_ty.id, - kind: LifetimeBinderKind::WhereBound, - span, - }, - |this| { - this.visit_generic_param_vec(&bound_generic_params, false); - this.visit_ty(bounded_ty); - for bound in bounds { - this.visit_param_bound(bound, BoundKind::Bound) - } - }, - ); + if let WherePredicate::BoundPredicate(WhereBoundPredicate { + ref bounded_ty, + ref bounds, + ref bound_generic_params, + span: predicate_span, + .. + }) = p + { + let span = if bound_generic_params.is_empty() { + predicate_span.shrink_to_lo() } else { - visit::walk_where_predicate(this, p); - } - }); + *predicate_span + }; + self.with_generic_param_rib( + &bound_generic_params, + NormalRibKind, + LifetimeRibKind::Generics { + parent: bounded_ty.id, + kind: LifetimeBinderKind::WhereBound, + span, + }, + |this| { + this.visit_generic_param_vec(&bound_generic_params, false); + this.visit_ty(bounded_ty); + for bound in bounds { + this.visit_param_bound(bound, BoundKind::Bound) + } + }, + ); + } else { + visit::walk_where_predicate(self, p); + } self.diagnostic_metadata.current_where_predicate = previous_value; } @@ -1093,62 +1086,56 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { forward_ty_ban_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), Res::Err); } - self.with_lifetime_rib(LifetimeRibKind::AnonymousReportError, |this| { - for param in params { - match param.kind { - GenericParamKind::Lifetime => { - for bound in ¶m.bounds { - this.visit_param_bound(bound, BoundKind::Bound); - } + for param in params { + match param.kind { + GenericParamKind::Lifetime => { + for bound in ¶m.bounds { + self.visit_param_bound(bound, BoundKind::Bound); + } + } + GenericParamKind::Type { ref default } => { + for bound in ¶m.bounds { + self.visit_param_bound(bound, BoundKind::Bound); } - GenericParamKind::Type { ref default } => { - for bound in ¶m.bounds { - this.visit_param_bound(bound, BoundKind::Bound); - } - - if let Some(ref ty) = default { - this.ribs[TypeNS].push(forward_ty_ban_rib); - this.ribs[ValueNS].push(forward_const_ban_rib); - this.visit_ty(ty); - forward_const_ban_rib = this.ribs[ValueNS].pop().unwrap(); - forward_ty_ban_rib = this.ribs[TypeNS].pop().unwrap(); - } - // Allow all following defaults to refer to this type parameter. - forward_ty_ban_rib - .bindings - .remove(&Ident::with_dummy_span(param.ident.name)); + if let Some(ref ty) = default { + self.ribs[TypeNS].push(forward_ty_ban_rib); + self.ribs[ValueNS].push(forward_const_ban_rib); + self.visit_ty(ty); + forward_const_ban_rib = self.ribs[ValueNS].pop().unwrap(); + forward_ty_ban_rib = self.ribs[TypeNS].pop().unwrap(); } - GenericParamKind::Const { ref ty, kw_span: _, ref default } => { - // Const parameters can't have param bounds. - assert!(param.bounds.is_empty()); - - this.ribs[TypeNS].push(Rib::new(ConstParamTyRibKind)); - this.ribs[ValueNS].push(Rib::new(ConstParamTyRibKind)); - this.with_lifetime_rib(LifetimeRibKind::ConstGeneric, |this| { - this.visit_ty(ty) - }); - this.ribs[TypeNS].pop().unwrap(); - this.ribs[ValueNS].pop().unwrap(); - - if let Some(ref expr) = default { - this.ribs[TypeNS].push(forward_ty_ban_rib); - this.ribs[ValueNS].push(forward_const_ban_rib); - this.with_lifetime_rib(LifetimeRibKind::ConstGeneric, |this| { - this.resolve_anon_const(expr, IsRepeatExpr::No) - }); - forward_const_ban_rib = this.ribs[ValueNS].pop().unwrap(); - forward_ty_ban_rib = this.ribs[TypeNS].pop().unwrap(); - } - // Allow all following defaults to refer to this const parameter. - forward_const_ban_rib - .bindings - .remove(&Ident::with_dummy_span(param.ident.name)); + // Allow all following defaults to refer to this type parameter. + forward_ty_ban_rib.bindings.remove(&Ident::with_dummy_span(param.ident.name)); + } + GenericParamKind::Const { ref ty, kw_span: _, ref default } => { + // Const parameters can't have param bounds. + assert!(param.bounds.is_empty()); + + self.ribs[TypeNS].push(Rib::new(ConstParamTyRibKind)); + self.ribs[ValueNS].push(Rib::new(ConstParamTyRibKind)); + self.with_lifetime_rib(LifetimeRibKind::ConstGeneric, |this| this.visit_ty(ty)); + self.ribs[TypeNS].pop().unwrap(); + self.ribs[ValueNS].pop().unwrap(); + + if let Some(ref expr) = default { + self.ribs[TypeNS].push(forward_ty_ban_rib); + self.ribs[ValueNS].push(forward_const_ban_rib); + self.with_lifetime_rib(LifetimeRibKind::ConstGeneric, |this| { + this.resolve_anon_const(expr, IsRepeatExpr::No) + }); + forward_const_ban_rib = self.ribs[ValueNS].pop().unwrap(); + forward_ty_ban_rib = self.ribs[TypeNS].pop().unwrap(); } + + // Allow all following defaults to refer to this const parameter. + forward_const_ban_rib + .bindings + .remove(&Ident::with_dummy_span(param.ident.name)); } } - }) + } } #[tracing::instrument(level = "debug", skip(self, work))] @@ -1226,28 +1213,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { self.create_fresh_lifetime(lifetime.id, lifetime.ident, item_node_id); return; } - LifetimeRibKind::AnonymousReportError => { - let (msg, note) = if elided { - ( - "`&` without an explicit lifetime name cannot be used here", - "explicit lifetime name needed here", - ) - } else { - ("`'_` cannot be used here", "`'_` is a reserved lifetime name") - }; - rustc_errors::struct_span_err!( - self.r.session, - lifetime.ident.span, - E0637, - "{}", - msg, - ) - .span_label(lifetime.ident.span, note) - .emit(); - - self.record_lifetime_res(lifetime.id, LifetimeRes::Error); - return; - } LifetimeRibKind::AnonymousPassThrough(node_id) => { self.record_lifetime_res( lifetime.id, @@ -1372,7 +1337,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { res = LifetimeRes::Anonymous { binder, elided: true }; break; } - LifetimeRibKind::AnonymousReportError | LifetimeRibKind::Item => { + LifetimeRibKind::Item => { // FIXME(cjgillot) This resolution is wrong, but this does not matter // since these cases are erroneous anyway. Lifetime resolution should // emit a "missing lifetime specifier" diagnostic. @@ -2028,28 +1993,28 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { self.with_generic_param_rib(&generics.params, ItemRibKind(HasGenericParams::Yes), LifetimeRibKind::Generics { span: generics.span, parent: item_id, kind: LifetimeBinderKind::ImplBlock }, |this| { // Dummy self type for better errors if `Self` is used in the trait path. this.with_self_rib(Res::SelfTy { trait_: None, alias_to: None }, |this| { - this.with_lifetime_rib(LifetimeRibKind::AnonymousCreateParameter(item_id), |this| { - // Resolve the trait reference, if necessary. - this.with_optional_trait_ref(opt_trait_reference.as_ref(), |this, trait_id| { - let item_def_id = this.r.local_def_id(item_id); - - // Register the trait definitions from here. - if let Some(trait_id) = trait_id { - this.r.trait_impls.entry(trait_id).or_default().push(item_def_id); - } + // Resolve the trait reference, if necessary. + this.with_optional_trait_ref(opt_trait_reference.as_ref(), |this, trait_id| { + let item_def_id = this.r.local_def_id(item_id); + + // Register the trait definitions from here. + if let Some(trait_id) = trait_id { + this.r.trait_impls.entry(trait_id).or_default().push(item_def_id); + } - let item_def_id = item_def_id.to_def_id(); - let res = - Res::SelfTy { trait_: trait_id, alias_to: Some((item_def_id, false)) }; - this.with_self_rib(res, |this| { + let item_def_id = item_def_id.to_def_id(); + let res = + Res::SelfTy { trait_: trait_id, alias_to: Some((item_def_id, false)) }; + this.with_self_rib(res, |this| { + // Resolve the generic parameters. + this.visit_generics(generics); + this.with_lifetime_rib(LifetimeRibKind::AnonymousCreateParameter(item_id), |this| { if let Some(trait_ref) = opt_trait_reference.as_ref() { // Resolve type arguments in the trait path. visit::walk_trait_ref(this, trait_ref); } // Resolve the self type. this.visit_ty(self_type); - // Resolve the generic parameters. - this.visit_generics(generics); // Resolve the items within the impl. this.with_lifetime_rib(LifetimeRibKind::AnonymousPassThrough(item_id), diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr b/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr index d6753a74f8574..2ff6a36b282b7 100644 --- a/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr +++ b/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr @@ -1,33 +1,58 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/const-param-elided-lifetime.rs:9:19 | LL | struct A; - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | struct A<'a, const N: &'a u8>; + | +++ ++ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/const-param-elided-lifetime.rs:14:15 | LL | impl A { - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | impl<'a, const N: &'a u8> A { + | +++ ++ -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:17:21 +error[E0106]: missing lifetime specifier + --> $DIR/const-param-elided-lifetime.rs:16:21 | LL | fn foo(&self) {} - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a, const M: &'a u8>(&self) {} + | +++ ++ -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:22:15 +error[E0106]: missing lifetime specifier + --> $DIR/const-param-elided-lifetime.rs:20:15 | LL | impl B for A {} - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | impl<'a, const N: &'a u8> B for A {} + | +++ ++ -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:26:17 +error[E0106]: missing lifetime specifier + --> $DIR/const-param-elided-lifetime.rs:23:17 | LL | fn bar() {} - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | fn bar<'a, const N: &'a u8>() {} + | +++ ++ error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr b/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr index 48d85e7ff64ec..2ff6a36b282b7 100644 --- a/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr +++ b/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr @@ -1,78 +1,58 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/const-param-elided-lifetime.rs:9:19 | LL | struct A; - | ^ explicit lifetime name needed here - -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:14:15 - | -LL | impl A { - | ^ explicit lifetime name needed here - -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:17:21 - | -LL | fn foo(&self) {} - | ^ explicit lifetime name needed here - -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:22:15 - | -LL | impl B for A {} - | ^ explicit lifetime name needed here - -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:26:17 - | -LL | fn bar() {} - | ^ explicit lifetime name needed here - -error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:9:19 + | ^ expected named lifetime parameter | -LL | struct A; - | ^^^ +help: consider introducing a named lifetime parameter | - = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` +LL | struct A<'a, const N: &'a u8>; + | +++ ++ -error: `&'static u8` is forbidden as the type of a const generic parameter +error[E0106]: missing lifetime specifier --> $DIR/const-param-elided-lifetime.rs:14:15 | LL | impl A { - | ^^^ + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter | - = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` +LL | impl<'a, const N: &'a u8> A { + | +++ ++ -error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:17:21 +error[E0106]: missing lifetime specifier + --> $DIR/const-param-elided-lifetime.rs:16:21 | LL | fn foo(&self) {} - | ^^^ + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter | - = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` +LL | fn foo<'a, const M: &'a u8>(&self) {} + | +++ ++ -error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:22:15 +error[E0106]: missing lifetime specifier + --> $DIR/const-param-elided-lifetime.rs:20:15 | LL | impl B for A {} - | ^^^ + | ^ expected named lifetime parameter | - = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` +help: consider introducing a named lifetime parameter + | +LL | impl<'a, const N: &'a u8> B for A {} + | +++ ++ -error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:26:17 +error[E0106]: missing lifetime specifier + --> $DIR/const-param-elided-lifetime.rs:23:17 | LL | fn bar() {} - | ^^^ + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter | - = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` +LL | fn bar<'a, const N: &'a u8>() {} + | +++ ++ -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.rs b/src/test/ui/const-generics/const-param-elided-lifetime.rs index 487b82dbf4ac4..1685eca426bdc 100644 --- a/src/test/ui/const-generics/const-param-elided-lifetime.rs +++ b/src/test/ui/const-generics/const-param-elided-lifetime.rs @@ -7,24 +7,20 @@ #![cfg_attr(full, allow(incomplete_features))] struct A; -//~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&'static u8` is forbidden +//~^ ERROR missing lifetime specifier [E0106] + trait B {} impl A { -//~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&'static u8` is forbidden +//~^ ERROR missing lifetime specifier [E0106] fn foo(&self) {} - //~^ ERROR `&` without an explicit lifetime name cannot be used here - //[min]~^^ ERROR `&'static u8` is forbidden + //~^ ERROR missing lifetime specifier [E0106] } impl B for A {} -//~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&'static u8` is forbidden +//~^ ERROR missing lifetime specifier [E0106] fn bar() {} -//~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&'static u8` is forbidden +//~^ ERROR missing lifetime specifier [E0106] fn main() {} diff --git a/src/test/ui/error-codes/E0637.rs b/src/test/ui/error-codes/E0637.rs deleted file mode 100644 index 382ce3ed01f34..0000000000000 --- a/src/test/ui/error-codes/E0637.rs +++ /dev/null @@ -1,17 +0,0 @@ -fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str { - //~^ ERROR: `'_` cannot be used here [E0637] - //~| ERROR: missing lifetime specifier - if str1.len() > str2.len() { - str1 - } else { - str2 - } -} - -fn and_without_explicit_lifetime() -where - T: Into<&u32>, //~ ERROR: `&` without an explicit lifetime name cannot be used here [E0637] -{ -} - -fn main() {} diff --git a/src/test/ui/error-codes/E0637.stderr b/src/test/ui/error-codes/E0637.stderr deleted file mode 100644 index 87aaba65a73ad..0000000000000 --- a/src/test/ui/error-codes/E0637.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0637]: `'_` cannot be used here - --> $DIR/E0637.rs:1:24 - | -LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str { - | ^^ `'_` is a reserved lifetime name - -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/E0637.rs:13:13 - | -LL | T: Into<&u32>, - | ^ explicit lifetime name needed here - -error[E0106]: missing lifetime specifier - --> $DIR/E0637.rs:1:62 - | -LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str { - | ------- ------- ^^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `str1` or `str2` -help: consider introducing a named lifetime parameter - | -LL | fn underscore_lifetime<'a, '_>(str1: &'a str, str2: &'a str) -> &'a str { - | +++ ~~ ~~ ~~ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0106, E0637. -For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr b/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr index 26bdf460f5e4d..3a0df04e40ff3 100644 --- a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr +++ b/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr @@ -1,3 +1,9 @@ +error[E0412]: cannot find type `T` in this scope + --> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5 + | +LL | T: Copy, + | ^ not found in this scope + error[E0412]: cannot find type `T` in this scope --> $DIR/fn-help-with-err-generic-is-not-function.rs:2:13 | @@ -6,12 +12,6 @@ LL | impl Struct | | | help: you might be missing a type parameter: `` -error[E0412]: cannot find type `T` in this scope - --> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5 - | -LL | T: Copy, - | ^ not found in this scope - error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs index 54b483f53d4cb..1d1696fb20dcd 100644 --- a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs +++ b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.rs @@ -3,7 +3,7 @@ struct Nested(K); fn should_error() where T : Into<&u32> {} -//~^ ERROR `&` without an explicit lifetime name cannot be used here [E0637] +//~^ ERROR missing lifetime specifier [E0106] trait X<'a, K: 'a> { fn foo<'b, L: X<&'b Nested>>(); diff --git a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr index 270d6b8e18e22..7ff45025b6b57 100644 --- a/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr +++ b/src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr @@ -1,8 +1,13 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:5:37 | LL | fn should_error() where T : Into<&u32> {} - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | fn should_error<'a, T>() where T : Into<&'a u32> {} + | +++ ++ error[E0106]: missing lifetime specifier --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:13:17 @@ -35,5 +40,4 @@ LL | fn foo<'b, L: X<'lifetime, &'b Nested>>(); error: aborting due to 3 previous errors -Some errors have detailed explanations: E0106, E0637. -For more information about an error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/impl-header-lifetime-elision/trait-elided.rs b/src/test/ui/impl-header-lifetime-elision/trait-elided.rs index c3e76d9cb5a03..a5c25917b7b29 100644 --- a/src/test/ui/impl-header-lifetime-elision/trait-elided.rs +++ b/src/test/ui/impl-header-lifetime-elision/trait-elided.rs @@ -3,6 +3,6 @@ trait MyTrait<'a> {} impl MyTrait for u32 {} -//~^ ERROR implicit elided lifetime not allowed here +//~^ ERROR missing lifetime specifier [E0106] fn main() {} diff --git a/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr b/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr index 412bba6be7167..219a892102f59 100644 --- a/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr +++ b/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr @@ -1,15 +1,14 @@ -error[E0726]: implicit elided lifetime not allowed here +error[E0106]: missing lifetime specifier --> $DIR/trait-elided.rs:5:6 | LL | impl MyTrait for u32 {} - | ^^^^^^^ expected lifetime parameter + | ^^^^^^^ expected named lifetime parameter | - = note: assuming a `'static` lifetime... -help: indicate the anonymous lifetime +help: consider introducing a named lifetime parameter | -LL | impl MyTrait<'_> for u32 {} - | ++++ +LL | impl<'a> MyTrait<'a> for u32 {} + | ++++ ~~~~~~~~~~~ error: aborting due to previous error -For more information about this error, try `rustc --explain E0726`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/issues/issue-10412.rs b/src/test/ui/issues/issue-10412.rs index 0de170161b514..682975abbae88 100644 --- a/src/test/ui/issues/issue-10412.rs +++ b/src/test/ui/issues/issue-10412.rs @@ -7,8 +7,7 @@ trait Serializable<'self, T> { impl<'self> Serializable for &'self str { //~^ ERROR lifetimes cannot use keyword names //~| ERROR lifetimes cannot use keyword names - //~| ERROR implicit elided lifetime not allowed here - //~| ERROR the size for values of type `str` cannot be known at compilation time [E0277] + //~| ERROR missing lifetime specifier [E0106] fn serialize(val: &'self str) -> Vec { //~^ ERROR lifetimes cannot use keyword names vec![1] diff --git a/src/test/ui/issues/issue-10412.stderr b/src/test/ui/issues/issue-10412.stderr index 46b9fd541adfa..16a344ae4b093 100644 --- a/src/test/ui/issues/issue-10412.stderr +++ b/src/test/ui/issues/issue-10412.stderr @@ -29,47 +29,28 @@ LL | impl<'self> Serializable for &'self str { | ^^^^^ error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:12:24 + --> $DIR/issue-10412.rs:11:24 | LL | fn serialize(val: &'self str) -> Vec { | ^^^^^ error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:16:37 + --> $DIR/issue-10412.rs:15:37 | LL | fn deserialize(repr: &[u8]) -> &'self str { | ^^^^^ -error[E0726]: implicit elided lifetime not allowed here - --> $DIR/issue-10412.rs:7:13 +error[E0106]: missing lifetime specifier + --> $DIR/issue-10412.rs:7:26 | LL | impl<'self> Serializable for &'self str { - | ^^^^^^^^^^^^^^^^^ expected lifetime parameter + | ^ expected named lifetime parameter | - = note: assuming a `'static` lifetime... -help: indicate the anonymous lifetime +help: consider using the `'self` lifetime | -LL | impl<'self> Serializable<'_, str> for &'self str { - | +++ +LL | impl<'self> Serializable<'self, str> for &'self str { + | ++++++ -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/issue-10412.rs:7:13 - | -LL | impl<'self> Serializable for &'self str { - | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `Serializable` - --> $DIR/issue-10412.rs:1:27 - | -LL | trait Serializable<'self, T> { - | ^ required by this bound in `Serializable` -help: consider relaxing the implicit `Sized` restriction - | -LL | trait Serializable<'self, T: ?Sized> { - | ++++++++ - -error: aborting due to 9 previous errors +error: aborting due to 8 previous errors -Some errors have detailed explanations: E0277, E0726. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/in-binder.stderr b/src/test/ui/underscore-lifetime/in-binder.stderr index fcd7eddb57605..1b936dd9aec2f 100644 --- a/src/test/ui/underscore-lifetime/in-binder.stderr +++ b/src/test/ui/underscore-lifetime/in-binder.stderr @@ -36,4 +36,3 @@ LL | fn foo<'_>() { error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0637`. diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr index 22bf1fdba326f..6628e0ca7566d 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr @@ -47,5 +47,4 @@ LL | fn foo2<'a>(_: &'a u8, y: &'a u8) -> &'a u8 { y } error: aborting due to 5 previous errors -Some errors have detailed explanations: E0106, E0637. -For more information about an error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/underscore-outlives-bounds.rs b/src/test/ui/underscore-lifetime/underscore-outlives-bounds.rs index 567cc7a3f5fa3..1c158e839a2b8 100644 --- a/src/test/ui/underscore-lifetime/underscore-outlives-bounds.rs +++ b/src/test/ui/underscore-lifetime/underscore-outlives-bounds.rs @@ -4,5 +4,5 @@ // #54902 trait Foo<'a> {} -impl<'b: '_> Foo<'b> for i32 {} //~ ERROR `'_` cannot be used here +impl<'b: '_> Foo<'b> for i32 {} //~ ERROR missing lifetime specifier [E0106] fn main() { } diff --git a/src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr b/src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr index 4b38a26f957f9..eab8826677736 100644 --- a/src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr +++ b/src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr @@ -1,9 +1,14 @@ -error[E0637]: `'_` cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/underscore-outlives-bounds.rs:7:10 | LL | impl<'b: '_> Foo<'b> for i32 {} - | ^^ `'_` is a reserved lifetime name + | ^^ expected named lifetime parameter + | +help: consider using the `'b` lifetime + | +LL | impl<'b: 'b> Foo<'b> for i32 {} + | ~~ error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs index 43de30944cacb..ac18823187939 100644 --- a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs +++ b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs @@ -11,8 +11,7 @@ struct Foo { impl Foo where T: WithType<&u32> -//[rust2015]~^ ERROR `&` without an explicit lifetime name cannot be used here -//[rust2018]~^^ ERROR `&` without an explicit lifetime name cannot be used here +//[rust2015,rust2018]~^ ERROR missing lifetime specifier [E0106] { } fn main() {} diff --git a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr index fe726cb49c737..0fd55fe9d5731 100644 --- a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr @@ -1,9 +1,16 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clause-inherent-impl-ampersand.rs:13:17 | LL | T: WithType<&u32> - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ impl<'a, T> Foo +LL | where +LL ~ T: WithType<&'a u32> + | error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr index fe726cb49c737..0fd55fe9d5731 100644 --- a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr @@ -1,9 +1,16 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clause-inherent-impl-ampersand.rs:13:17 | LL | T: WithType<&u32> - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ impl<'a, T> Foo +LL | where +LL ~ T: WithType<&'a u32> + | error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rs b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rs index 38189816da849..091a3c265a1a4 100644 --- a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rs +++ b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rs @@ -11,7 +11,7 @@ struct Foo { impl Foo where T: WithRegion<'_> -//[rust2015,rust2018]~^ ERROR `'_` cannot be used here +//[rust2015,rust2018]~^ ERROR missing lifetime specifier [E0106] { } fn main() {} diff --git a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr index 95939fd6b7e03..12dd418a81fc9 100644 --- a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr @@ -1,9 +1,16 @@ -error[E0637]: `'_` cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clause-inherent-impl-underscore.rs:13:19 | LL | T: WithRegion<'_> - | ^^ `'_` is a reserved lifetime name + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ impl<'a, T> Foo +LL | where +LL ~ T: WithRegion<'a> + | error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr index 95939fd6b7e03..12dd418a81fc9 100644 --- a/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr @@ -1,9 +1,16 @@ -error[E0637]: `'_` cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clause-inherent-impl-underscore.rs:13:19 | LL | T: WithRegion<'_> - | ^^ `'_` is a reserved lifetime name + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ impl<'a, T> Foo +LL | where +LL ~ T: WithRegion<'a> + | error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rs b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rs index 09e5bbd846d6c..3d231ec8d83db 100644 --- a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rs +++ b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rs @@ -9,7 +9,7 @@ trait Foo { } impl Foo for Vec where T: WithType<&u32> -//[rust2015,rust2018]~^ ERROR `&` without an explicit lifetime name cannot be used here +//[rust2015,rust2018]~^ ERROR missing lifetime specifier [E0106] { } fn main() {} diff --git a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr index fbd14de21078b..bcc86f306555c 100644 --- a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr @@ -1,9 +1,16 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clause-trait-impl-region.rs:11:17 | LL | T: WithType<&u32> - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ impl<'a, T> Foo for Vec +LL | where +LL ~ T: WithType<&'a u32> + | error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr index fbd14de21078b..bcc86f306555c 100644 --- a/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr @@ -1,9 +1,16 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clause-trait-impl-region.rs:11:17 | LL | T: WithType<&u32> - | ^ explicit lifetime name needed here + | ^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ impl<'a, T> Foo for Vec +LL | where +LL ~ T: WithType<&'a u32> + | error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rs b/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rs index 371d2e4ba43ac..87adbcdfdd810 100644 --- a/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rs +++ b/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rs @@ -9,7 +9,7 @@ trait Foo { } impl Foo for Vec where T: WithRegion<'_> -//[rust2015,rust2018]~^ ERROR `'_` cannot be used here +//[rust2015,rust2018]~^ ERROR missing lifetime specifier [E0106] { } fn main() {} diff --git a/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr b/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr index 92caff0dcde99..9a0f3bf6f0064 100644 --- a/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr @@ -1,9 +1,16 @@ -error[E0637]: `'_` cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clause-trait-impl-underscore.rs:11:19 | LL | T: WithRegion<'_> - | ^^ `'_` is a reserved lifetime name + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ impl<'a, T> Foo for Vec +LL | where +LL ~ T: WithRegion<'a> + | error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr b/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr index 92caff0dcde99..9a0f3bf6f0064 100644 --- a/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr +++ b/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr @@ -1,9 +1,16 @@ -error[E0637]: `'_` cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clause-trait-impl-underscore.rs:11:19 | LL | T: WithRegion<'_> - | ^^ `'_` is a reserved lifetime name + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL ~ impl<'a, T> Foo for Vec +LL | where +LL ~ T: WithRegion<'a> + | error: aborting due to previous error -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/underscore-lifetime/where-clauses.rs b/src/test/ui/underscore-lifetime/where-clauses.rs index ee6823b804782..648e4ff794c5e 100644 --- a/src/test/ui/underscore-lifetime/where-clauses.rs +++ b/src/test/ui/underscore-lifetime/where-clauses.rs @@ -1,7 +1,7 @@ trait Foo<'a> {} -impl<'b: '_> Foo<'b> for i32 {} //~ ERROR `'_` cannot be used here +impl<'b: '_> Foo<'b> for i32 {} //~ ERROR missing lifetime specifier [E0106] -impl Foo<'static> for Vec {} //~ ERROR `'_` cannot be used here +impl Foo<'static> for Vec {} //~ ERROR missing lifetime specifier [E0106] fn main() { } diff --git a/src/test/ui/underscore-lifetime/where-clauses.stderr b/src/test/ui/underscore-lifetime/where-clauses.stderr index 1a3ea4af7e12e..e54735d4840be 100644 --- a/src/test/ui/underscore-lifetime/where-clauses.stderr +++ b/src/test/ui/underscore-lifetime/where-clauses.stderr @@ -1,15 +1,25 @@ -error[E0637]: `'_` cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clauses.rs:3:10 | LL | impl<'b: '_> Foo<'b> for i32 {} - | ^^ `'_` is a reserved lifetime name + | ^^ expected named lifetime parameter + | +help: consider using the `'b` lifetime + | +LL | impl<'b: 'b> Foo<'b> for i32 {} + | ~~ -error[E0637]: `'_` cannot be used here +error[E0106]: missing lifetime specifier --> $DIR/where-clauses.rs:5:9 | LL | impl Foo<'static> for Vec {} - | ^^ `'_` is a reserved lifetime name + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | impl<'a, T: 'a> Foo<'static> for Vec {} + | +++ ~~ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0637`. +For more information about this error, try `rustc --explain E0106`.