From 673090eefe975517f76b7669b29e735e02b998a1 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 16 May 2022 19:35:42 +0200 Subject: [PATCH 1/2] Separate `AnonymousCreateParameter` and `ReportElidedInPath`. --- compiler/rustc_resolve/src/late.rs | 202 ++++++++++++++++------------- 1 file changed, 115 insertions(+), 87 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index f05090d046f3..470ea996a9d7 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -222,15 +222,12 @@ enum LifetimeRibKind { /// `body_id` is an anonymous constant and `lifetime_ref` is non-static. AnonConst, - /// For **Modern** cases, create a new anonymous region parameter - /// and reference that. - /// - /// For **Dyn Bound** cases, pass responsibility to - /// `resolve_lifetime` code. - /// - /// For **Deprecated** cases, report an error. + /// Create a new anonymous region parameter and reference that. AnonymousCreateParameter(NodeId), + /// Give a hard error when generic lifetime arguments are elided. + ReportElidedInPath, + /// 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`). @@ -746,8 +743,10 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { this.with_lifetime_rib( LifetimeRibKind::AnonymousCreateParameter(fn_id), |this| { - // Add each argument to the rib. - this.resolve_params(&declaration.inputs) + this.with_lifetime_rib(LifetimeRibKind::ReportElidedInPath, |this| { + // Add each argument to the rib. + this.resolve_params(&declaration.inputs) + }); }, ); @@ -1301,7 +1300,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { let rib = &mut self.lifetime_ribs[i]; match rib.kind { LifetimeRibKind::AnonymousCreateParameter(item_node_id) => { - self.create_fresh_lifetime(lifetime.id, lifetime.ident, item_node_id); + let region = + self.create_fresh_lifetime(lifetime.id, lifetime.ident, item_node_id); + self.record_lifetime_res(lifetime.id, region); return; } LifetimeRibKind::AnonymousReportError => { @@ -1358,7 +1359,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { } #[tracing::instrument(level = "debug", skip(self))] - fn create_fresh_lifetime(&mut self, id: NodeId, ident: Ident, item_node_id: NodeId) { + fn create_fresh_lifetime( + &mut self, + id: NodeId, + ident: Ident, + item_node_id: NodeId, + ) -> LifetimeRes { debug_assert_eq!(ident.name, kw::UnderscoreLifetime); debug!(?ident.span); let item_def_id = self.r.local_def_id(item_node_id); @@ -1373,12 +1379,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { debug!(?def_id); let region = LifetimeRes::Fresh { param: def_id, binder: item_node_id }; - self.record_lifetime_res(id, region); self.r.extra_lifetime_params_map.entry(item_node_id).or_insert_with(Vec::new).push(( ident, def_node_id, region, )); + region } #[tracing::instrument(level = "debug", skip(self))] @@ -1391,7 +1397,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { path_span: Span, ) { let proj_start = path.len() - partial_res.unresolved_segments(); - for (i, segment) in path.iter().enumerate() { + 'segment: for (i, segment) in path.iter().enumerate() { if segment.has_lifetime_args { continue; } @@ -1428,16 +1434,69 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { | PathSource::Struct | PathSource::TupleStruct(..) => false, }; - let mut res = LifetimeRes::Error; + + let node_ids = self.r.next_node_ids(expected_lifetimes); + self.record_lifetime_res( + segment_id, + LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end }, + ); + + if !missing { + for i in 0..expected_lifetimes { + let id = node_ids.start.plus(i); + self.record_lifetime_res( + id, + LifetimeRes::Anonymous { binder: DUMMY_NODE_ID, elided: true }, + ); + } + continue; + } + + let elided_lifetime_span = if segment.has_generic_args { + // If there are brackets, but not generic arguments, then use the opening bracket + segment.args_span.with_hi(segment.args_span.lo() + BytePos(1)) + } else { + // If there are no brackets, use the identifier span. + // HACK: we use find_ancestor_inside to properly suggest elided spans in paths + // originating from macros, since the segment's span might be from a macro arg. + segment.ident.span.find_ancestor_inside(path_span).unwrap_or(path_span) + }; + for rib in self.lifetime_ribs.iter().rev() { match rib.kind { - // In create-parameter mode we error here because we don't want to support - // deprecated impl elision in new features like impl elision and `async fn`, - // both of which work using the `CreateParameter` mode: - // - // impl Foo for std::cell::Ref // note lack of '_ - // async fn foo(_: std::cell::Ref) { ... } - LifetimeRibKind::AnonymousCreateParameter(_) => { + // We error here because we don't want to support deprecated impl elision in + // new features like impl elision and `async fn`, + LifetimeRibKind::ReportElidedInPath => { + let sess = self.r.session; + let mut err = rustc_errors::struct_span_err!( + sess, + path_span, + E0726, + "implicit elided lifetime not allowed here" + ); + rustc_errors::add_elided_lifetime_in_path_suggestion( + sess.source_map(), + &mut err, + expected_lifetimes, + path_span, + !segment.has_generic_args, + elided_lifetime_span, + ); + err.note("assuming a `'static` lifetime..."); + err.emit(); + for i in 0..expected_lifetimes { + let id = node_ids.start.plus(i); + self.record_lifetime_res(id, LifetimeRes::Error); + } + continue 'segment; + } + LifetimeRibKind::AnonymousCreateParameter(binder) => { + let ident = Ident::new(kw::UnderscoreLifetime, elided_lifetime_span); + for i in 0..expected_lifetimes { + let id = node_ids.start.plus(i); + let res = self.create_fresh_lifetime(id, ident, binder); + self.record_lifetime_res(id, res); + } break; } // `PassThrough` is the normal case. @@ -1447,75 +1506,40 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { // lifetime. Instead, we simply create an implicit lifetime, which will be checked // later, at which point a suitable error will be emitted. LifetimeRibKind::AnonymousPassThrough(binder, _) => { - res = LifetimeRes::Anonymous { binder, elided: true }; + let res = LifetimeRes::Anonymous { binder, elided: true }; + for i in 0..expected_lifetimes { + let id = node_ids.start.plus(i); + self.record_lifetime_res(id, res); + } break; } LifetimeRibKind::AnonymousReportError | 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. - res = LifetimeRes::Anonymous { binder: DUMMY_NODE_ID, elided: true }; + let res = LifetimeRes::Anonymous { binder: DUMMY_NODE_ID, elided: true }; + for i in 0..expected_lifetimes { + let id = node_ids.start.plus(i); + self.record_lifetime_res(id, res); + } break; } _ => {} } } - let node_ids = self.r.next_node_ids(expected_lifetimes); - self.record_lifetime_res( + self.r.lint_buffer.buffer_lint_with_diagnostic( + lint::builtin::ELIDED_LIFETIMES_IN_PATHS, segment_id, - LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end }, - ); - for i in 0..expected_lifetimes { - let id = node_ids.start.plus(i); - self.record_lifetime_res(id, res); - } - - if !missing { - continue; - } - - let elided_lifetime_span = if segment.has_generic_args { - // If there are brackets, but not generic arguments, then use the opening bracket - segment.args_span.with_hi(segment.args_span.lo() + BytePos(1)) - } else { - // If there are no brackets, use the identifier span. - // HACK: we use find_ancestor_inside to properly suggest elided spans in paths - // originating from macros, since the segment's span might be from a macro arg. - segment.ident.span.find_ancestor_inside(path_span).unwrap_or(path_span) - }; - if let LifetimeRes::Error = res { - let sess = self.r.session; - let mut err = rustc_errors::struct_span_err!( - sess, - path_span, - E0726, - "implicit elided lifetime not allowed here" - ); - rustc_errors::add_elided_lifetime_in_path_suggestion( - sess.source_map(), - &mut err, + elided_lifetime_span, + "hidden lifetime parameters in types are deprecated", + lint::BuiltinLintDiagnostics::ElidedLifetimesInPaths( expected_lifetimes, path_span, !segment.has_generic_args, elided_lifetime_span, - ); - err.note("assuming a `'static` lifetime..."); - err.emit(); - } else { - self.r.lint_buffer.buffer_lint_with_diagnostic( - lint::builtin::ELIDED_LIFETIMES_IN_PATHS, - segment_id, - elided_lifetime_span, - "hidden lifetime parameters in types are deprecated", - lint::BuiltinLintDiagnostics::ElidedLifetimesInPaths( - expected_lifetimes, - path_span, - !segment.has_generic_args, - elided_lifetime_span, - ), - ); - } + ), + ); } } @@ -2072,12 +2096,14 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { let mut new_id = None; if let Some(trait_ref) = opt_trait_ref { let path: Vec<_> = Segment::from_path(&trait_ref.path); - let res = self.smart_resolve_path_fragment( - None, - &path, - PathSource::Trait(AliasPossibility::No), - Finalize::new(trait_ref.ref_id, trait_ref.path.span), - ); + let res = self.with_lifetime_rib(LifetimeRibKind::ReportElidedInPath, |this| { + this.smart_resolve_path_fragment( + None, + &path, + PathSource::Trait(AliasPossibility::No), + Finalize::new(trait_ref.ref_id, trait_ref.path.span), + ) + }); if let Some(def_id) = res.base_res().opt_def_id() { new_id = Some(def_id); new_val = Some((self.r.expect_module(def_id), trait_ref.clone())); @@ -2130,14 +2156,16 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { let res = Res::SelfTy { trait_: trait_id, alias_to: Some((item_def_id, false)) }; this.with_self_rib(res, |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); + this.with_lifetime_rib(LifetimeRibKind::ReportElidedInPath, |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,false), From 0968c188cb861889dad55e911ad7ab33c4a1bdb9 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 11 May 2022 23:10:01 +0200 Subject: [PATCH 2/2] Stop errorring for elided lifetimes in path. --- .../src/error_codes/E0726.md | 4 +- compiler/rustc_resolve/src/late.rs | 69 +++++-------------- .../ui/async-await/async-fn-path-elision.rs | 5 +- .../async-await/async-fn-path-elision.stderr | 24 +++++-- .../path-elided.rs | 4 +- .../path-elided.stderr | 9 ++- .../trait-elided.rs | 4 +- .../trait-elided.stderr | 9 ++- src/test/ui/issues/issue-10412.rs | 1 - src/test/ui/issues/issue-10412.stderr | 21 ++---- .../wf/wf-in-foreign-fn-decls-issue-80468.rs | 5 +- .../wf-in-foreign-fn-decls-issue-80468.stderr | 37 ---------- 12 files changed, 65 insertions(+), 127 deletions(-) delete mode 100644 src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.stderr diff --git a/compiler/rustc_error_codes/src/error_codes/E0726.md b/compiler/rustc_error_codes/src/error_codes/E0726.md index e3794327f2d4..ae7355a47502 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0726.md +++ b/compiler/rustc_error_codes/src/error_codes/E0726.md @@ -1,3 +1,5 @@ +#### Note: this error code is no longer emitted by the compiler. + An argument lifetime was elided in an async function. Erroneous code example: @@ -7,7 +9,7 @@ the Rust compiler to know, on usage, the lifespan of the type. When the lifetime is not explicitly mentioned and the Rust Compiler cannot determine the lifetime of your type, the following error occurs. -```compile_fail,E0726 +```compile_fail use futures::executor::block_on; struct Content<'a> { title: &'a str, diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 470ea996a9d7..ad2979effb8f 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -225,9 +225,6 @@ enum LifetimeRibKind { /// Create a new anonymous region parameter and reference that. AnonymousCreateParameter(NodeId), - /// Give a hard error when generic lifetime arguments are elided. - ReportElidedInPath, - /// 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`). @@ -743,10 +740,8 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { this.with_lifetime_rib( LifetimeRibKind::AnonymousCreateParameter(fn_id), |this| { - this.with_lifetime_rib(LifetimeRibKind::ReportElidedInPath, |this| { - // Add each argument to the rib. - this.resolve_params(&declaration.inputs) - }); + // Add each argument to the rib. + this.resolve_params(&declaration.inputs) }, ); @@ -1397,7 +1392,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { path_span: Span, ) { let proj_start = path.len() - partial_res.unresolved_segments(); - 'segment: for (i, segment) in path.iter().enumerate() { + for (i, segment) in path.iter().enumerate() { if segment.has_lifetime_args { continue; } @@ -1464,32 +1459,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { for rib in self.lifetime_ribs.iter().rev() { match rib.kind { - // We error here because we don't want to support deprecated impl elision in - // new features like impl elision and `async fn`, - LifetimeRibKind::ReportElidedInPath => { - let sess = self.r.session; - let mut err = rustc_errors::struct_span_err!( - sess, - path_span, - E0726, - "implicit elided lifetime not allowed here" - ); - rustc_errors::add_elided_lifetime_in_path_suggestion( - sess.source_map(), - &mut err, - expected_lifetimes, - path_span, - !segment.has_generic_args, - elided_lifetime_span, - ); - err.note("assuming a `'static` lifetime..."); - err.emit(); - for i in 0..expected_lifetimes { - let id = node_ids.start.plus(i); - self.record_lifetime_res(id, LifetimeRes::Error); - } - continue 'segment; - } LifetimeRibKind::AnonymousCreateParameter(binder) => { let ident = Ident::new(kw::UnderscoreLifetime, elided_lifetime_span); for i in 0..expected_lifetimes { @@ -2096,14 +2065,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { let mut new_id = None; if let Some(trait_ref) = opt_trait_ref { let path: Vec<_> = Segment::from_path(&trait_ref.path); - let res = self.with_lifetime_rib(LifetimeRibKind::ReportElidedInPath, |this| { - this.smart_resolve_path_fragment( - None, - &path, - PathSource::Trait(AliasPossibility::No), - Finalize::new(trait_ref.ref_id, trait_ref.path.span), - ) - }); + let res = self.smart_resolve_path_fragment( + None, + &path, + PathSource::Trait(AliasPossibility::No), + Finalize::new(trait_ref.ref_id, trait_ref.path.span), + ); if let Some(def_id) = res.base_res().opt_def_id() { new_id = Some(def_id); new_val = Some((self.r.expect_module(def_id), trait_ref.clone())); @@ -2156,16 +2123,14 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { let res = Res::SelfTy { trait_: trait_id, alias_to: Some((item_def_id, false)) }; this.with_self_rib(res, |this| { - this.with_lifetime_rib(LifetimeRibKind::ReportElidedInPath, |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); - }); + 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,false), diff --git a/src/test/ui/async-await/async-fn-path-elision.rs b/src/test/ui/async-await/async-fn-path-elision.rs index 3f1f51c20ca0..307de367ae6f 100644 --- a/src/test/ui/async-await/async-fn-path-elision.rs +++ b/src/test/ui/async-await/async-fn-path-elision.rs @@ -1,12 +1,13 @@ // edition:2018 +#![deny(elided_lifetimes_in_paths)] struct HasLifetime<'a>(&'a bool); -async fn error(lt: HasLifetime) { //~ ERROR implicit elided lifetime not allowed here +async fn error(lt: HasLifetime) { //~ ERROR hidden lifetime parameters in types are deprecated if *lt.0 {} } -fn no_error(lt: HasLifetime) { +fn also_error(lt: HasLifetime) { //~ ERROR hidden lifetime parameters in types are deprecated if *lt.0 {} } diff --git a/src/test/ui/async-await/async-fn-path-elision.stderr b/src/test/ui/async-await/async-fn-path-elision.stderr index 5e0c8c299891..03c6cdb7ee55 100644 --- a/src/test/ui/async-await/async-fn-path-elision.stderr +++ b/src/test/ui/async-await/async-fn-path-elision.stderr @@ -1,15 +1,29 @@ -error[E0726]: implicit elided lifetime not allowed here - --> $DIR/async-fn-path-elision.rs:5:20 +error: hidden lifetime parameters in types are deprecated + --> $DIR/async-fn-path-elision.rs:6:20 | LL | async fn error(lt: HasLifetime) { | ^^^^^^^^^^^ expected lifetime parameter | - = note: assuming a `'static` lifetime... +note: the lint level is defined here + --> $DIR/async-fn-path-elision.rs:2:9 + | +LL | #![deny(elided_lifetimes_in_paths)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime | LL | async fn error(lt: HasLifetime<'_>) { | ++++ -error: aborting due to previous error +error: hidden lifetime parameters in types are deprecated + --> $DIR/async-fn-path-elision.rs:10:19 + | +LL | fn also_error(lt: HasLifetime) { + | ^^^^^^^^^^^ expected lifetime parameter + | +help: indicate the anonymous lifetime + | +LL | fn also_error(lt: HasLifetime<'_>) { + | ++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0726`. diff --git a/src/test/ui/impl-header-lifetime-elision/path-elided.rs b/src/test/ui/impl-header-lifetime-elision/path-elided.rs index 40a52efc7f9f..8a97c14dad2b 100644 --- a/src/test/ui/impl-header-lifetime-elision/path-elided.rs +++ b/src/test/ui/impl-header-lifetime-elision/path-elided.rs @@ -1,11 +1,11 @@ -#![allow(warnings)] +#![deny(elided_lifetimes_in_paths)] trait MyTrait { } struct Foo<'a> { x: &'a u32 } impl MyTrait for Foo { - //~^ ERROR implicit elided lifetime not allowed here + //~^ ERROR hidden lifetime parameters in types are deprecated [elided_lifetimes_in_paths] } fn main() {} diff --git a/src/test/ui/impl-header-lifetime-elision/path-elided.stderr b/src/test/ui/impl-header-lifetime-elision/path-elided.stderr index 0b7d3f1e851e..16996f8f1e52 100644 --- a/src/test/ui/impl-header-lifetime-elision/path-elided.stderr +++ b/src/test/ui/impl-header-lifetime-elision/path-elided.stderr @@ -1,10 +1,14 @@ -error[E0726]: implicit elided lifetime not allowed here +error: hidden lifetime parameters in types are deprecated --> $DIR/path-elided.rs:7:18 | LL | impl MyTrait for Foo { | ^^^ expected lifetime parameter | - = note: assuming a `'static` lifetime... +note: the lint level is defined here + --> $DIR/path-elided.rs:1:9 + | +LL | #![deny(elided_lifetimes_in_paths)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime | LL | impl MyTrait for Foo<'_> { @@ -12,4 +16,3 @@ LL | impl MyTrait for Foo<'_> { error: aborting due to previous error -For more information about this error, try `rustc --explain E0726`. 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 c3e76d9cb5a0..4216418eced5 100644 --- a/src/test/ui/impl-header-lifetime-elision/trait-elided.rs +++ b/src/test/ui/impl-header-lifetime-elision/trait-elided.rs @@ -1,8 +1,8 @@ -#![allow(warnings)] +#![deny(elided_lifetimes_in_paths)] trait MyTrait<'a> {} impl MyTrait for u32 {} -//~^ ERROR implicit elided lifetime not allowed here +//~^ ERROR hidden lifetime parameters in types are deprecated [elided_lifetimes_in_paths] 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 412bba6be716..10e9bae76bac 100644 --- a/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr +++ b/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr @@ -1,10 +1,14 @@ -error[E0726]: implicit elided lifetime not allowed here +error: hidden lifetime parameters in types are deprecated --> $DIR/trait-elided.rs:5:6 | LL | impl MyTrait for u32 {} | ^^^^^^^ expected lifetime parameter | - = note: assuming a `'static` lifetime... +note: the lint level is defined here + --> $DIR/trait-elided.rs:1:9 + | +LL | #![deny(elided_lifetimes_in_paths)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime | LL | impl MyTrait<'_> for u32 {} @@ -12,4 +16,3 @@ LL | impl MyTrait<'_> for u32 {} error: aborting due to previous error -For more information about this error, try `rustc --explain E0726`. diff --git a/src/test/ui/issues/issue-10412.rs b/src/test/ui/issues/issue-10412.rs index 0de170161b51..0603e1edab29 100644 --- a/src/test/ui/issues/issue-10412.rs +++ b/src/test/ui/issues/issue-10412.rs @@ -7,7 +7,6 @@ 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] fn serialize(val: &'self str) -> Vec { //~^ ERROR lifetimes cannot use keyword names diff --git a/src/test/ui/issues/issue-10412.stderr b/src/test/ui/issues/issue-10412.stderr index 46b9fd541adf..3cd08c22efbf 100644 --- a/src/test/ui/issues/issue-10412.stderr +++ b/src/test/ui/issues/issue-10412.stderr @@ -29,29 +29,17 @@ 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 - | -LL | impl<'self> Serializable for &'self str { - | ^^^^^^^^^^^^^^^^^ expected lifetime parameter - | - = note: assuming a `'static` lifetime... -help: indicate the anonymous lifetime - | -LL | impl<'self> Serializable<'_, 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 | @@ -69,7 +57,6 @@ 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 E0277`. diff --git a/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs index 4fcf8f403bbb..2357f586a65c 100644 --- a/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs +++ b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.rs @@ -1,3 +1,4 @@ +// check-pass // Regression test for #80468. #![crate_type = "lib"] @@ -10,8 +11,8 @@ pub struct Wrapper(T); #[repr(transparent)] pub struct Ref<'a>(&'a u8); -impl Trait for Ref {} //~ ERROR: implicit elided lifetime not allowed here +impl Trait for Ref {} extern "C" { - pub fn repro(_: Wrapper); //~ ERROR: incompatible lifetime on type + pub fn repro(_: Wrapper); } diff --git a/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.stderr b/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.stderr deleted file mode 100644 index 16d198725523..000000000000 --- a/src/test/ui/wf/wf-in-foreign-fn-decls-issue-80468.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0726]: implicit elided lifetime not allowed here - --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:13:16 - | -LL | impl Trait for Ref {} - | ^^^ expected lifetime parameter - | - = note: assuming a `'static` lifetime... -help: indicate the anonymous lifetime - | -LL | impl Trait for Ref<'_> {} - | ++++ - -error: incompatible lifetime on type - --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:21 - | -LL | pub fn repro(_: Wrapper); - | ^^^^^^^^^^^^ - | -note: because this has an unmet lifetime requirement - --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:8:23 - | -LL | pub struct Wrapper(T); - | ^^^^^ introduces a `'static` lifetime requirement -note: the anonymous lifetime #1 defined here... - --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:5 - | -LL | pub fn repro(_: Wrapper); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...does not necessarily outlive the static lifetime introduced by the compatible `impl` - --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:13:1 - | -LL | impl Trait for Ref {} - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0726`.