From 7f7709e3d4c10e1b71461496bf6747c3cea63b75 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Mon, 30 Dec 2019 19:46:30 -0600 Subject: [PATCH 1/9] Generalized article_and_description --- src/librustc/ty/context.rs | 16 ++++++++- src/librustc/ty/sty.rs | 35 +++++++++++++++++++ .../diagnostics/conflict_errors.rs | 7 ++-- .../borrow_check/diagnostics/region_errors.rs | 16 ++++----- .../borrow_check/universal_regions.rs | 23 ++++++++++++ 5 files changed, 83 insertions(+), 14 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index e59738d888608..fd2f58d24f8dd 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -209,7 +209,7 @@ fn validate_hir_id_for_typeck_tables( ty::tls::with(|tcx| { bug!( "node {} with HirId::owner {:?} cannot be placed in \ - TypeckTables with local_id_root {:?}", + TypeckTables with local_id_root {:?}", tcx.hir().node_to_string(hir_id), DefId::local(hir_id.owner), local_id_root @@ -1512,6 +1512,20 @@ impl<'tcx> TyCtxt<'tcx> { .subst(*self, self.mk_substs([self.lifetimes.re_static.into()].iter())), ) } + + /// Returns a displayable description and article for the given `def_id` (e.g. `("a", "closure")`). + pub fn article_and_description( + &self, + def_id: crate::hir::def_id::DefId, + ) -> (&'static str, &'static str) { + self.def_kind(def_id).map_or_else( + || { + // TODO: is it a problem to try to use the ty here? + self.type_of(def_id).kind.article_and_description() + }, + |def_kind| (def_kind.article(), def_kind.descr(def_id)), + ) + } } impl<'tcx> GlobalCtxt<'tcx> { diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index c3698f402a9d1..a54bf4d7eff38 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -254,6 +254,41 @@ pub enum TyKind<'tcx> { Error, } +impl<'tcx> TyKind<'tcx> { + pub fn article_and_description(&self) -> (&'static str, &'static str) { + match *self { + Bool => ("a", "boolean value"), + Char => ("a", "character"), + Int(..) => ("a", "signed interger"), + Uint(..) => ("an", "unsigned integer"), + Float(..) => ("a", "floating point number"), + Adt(..) => ("an", "abstract data type"), + Foreign(..) => ("a", "foreign type"), + Str => ("a", "string slice"), + Array(..) => ("an", "array"), + Slice(..) => ("a", "slice"), + RawPtr(..) => ("a", "raw pointer"), + Ref(..) => ("a", "reference"), + FnDef(..) => ("a", "function"), + FnPtr(..) => ("a", "function pointer"), + Dynamic(..) => ("a", "trait object"), + Closure(..) => ("a", "closure"), + Generator(..) => ("a", "generator"), + GeneratorWitness(..) => ("a", "generator witness"), + Never => ("a", "never"), + Tuple(..) => ("a", "tuple"), + Projection(..) => ("a", "projection"), + UnnormalizedProjection(..) => ("an", "unnormalized projection"), + Opaque(..) => ("an", "opaque type"), + Param(..) => ("a", "type parameter"), + Bound(..) => ("a", "bound type variable"), + Placeholder(..) => ("a", "universally quantified higher-ranked type"), + Infer(..) => ("an", "inference variable"), + Error => ("a", "type error"), + } + } +} + // `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(target_arch = "x86_64")] static_assert_size!(TyKind<'_>, 24); diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 0ed7dd03f3ab7..41a99d1125b5d 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -1257,7 +1257,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } _ => bug!( "report_escaping_closure_capture called with unexpected constraint \ - category: `{:?}`", + category: `{:?}`", category ), }; @@ -1279,8 +1279,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let tables = tcx.typeck_tables_of(self.mir_def_id); let mir_hir_id = tcx.hir().def_index_to_hir_id(self.mir_def_id.index); match tables.node_type(mir_hir_id).kind { - ty::Closure(..) => "closure", - ty::Generator(..) => "generator", + ref kind @ ty::Closure(..) | ref kind @ ty::Generator(..) => { + kind.article_and_description().1 + } _ => bug!("Closure body doesn't have a closure or generator type"), } } else { diff --git a/src/librustc_mir/borrow_check/diagnostics/region_errors.rs b/src/librustc_mir/borrow_check/diagnostics/region_errors.rs index a3e0e51c5b64d..0f0fd64844a8d 100644 --- a/src/librustc_mir/borrow_check/diagnostics/region_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/region_errors.rs @@ -427,18 +427,15 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { errci.outlived_fr, ); - let escapes_from = match self.regioncx.universal_regions().defining_ty { - DefiningTy::Closure(..) => "closure", - DefiningTy::Generator(..) => "generator", - DefiningTy::FnDef(..) => "function", - DefiningTy::Const(..) => "const", - }; + let (_, escapes_from) = + self.infcx.tcx.article_and_description(self.universal_regions.defining_ty.def_id()); // Revert to the normal error in these cases. // Assignments aren't "escapes" in function items. if (fr_name_and_span.is_none() && outlived_fr_name_and_span.is_none()) - || (*category == ConstraintCategory::Assignment && escapes_from == "function") - || escapes_from == "const" + || (*category == ConstraintCategory::Assignment + && self.universal_regions.defining_ty.is_fn_def()) + || self.universal_regions.defining_ty.is_closure() { return self.report_general_error(&ErrorConstraintInfo { fr_is_local: true, @@ -504,8 +501,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let mut diag = self.infcx.tcx.sess.struct_span_err(*span, "lifetime may not live long enough"); - let mir_def_name = - if self.infcx.tcx.is_closure(self.mir_def_id) { "closure" } else { "function" }; + let (_, mir_def_name) = self.infcx.tcx.article_and_description(self.mir_def_id); let fr_name = self.give_region_a_name(*fr).unwrap(); fr_name.highlight_region_name(&mut diag); diff --git a/src/librustc_mir/borrow_check/universal_regions.rs b/src/librustc_mir/borrow_check/universal_regions.rs index 0913de63e8ef1..777eea22eb639 100644 --- a/src/librustc_mir/borrow_check/universal_regions.rs +++ b/src/librustc_mir/borrow_check/universal_regions.rs @@ -131,6 +131,29 @@ impl<'tcx> DefiningTy<'tcx> { DefiningTy::FnDef(..) | DefiningTy::Const(..) => 0, } } + + pub fn is_closure(&self) -> bool { + match *self { + DefiningTy::Closure(..) => true, + _ => false, + } + } + + pub fn is_fn_def(&self) -> bool { + match *self { + DefiningTy::FnDef(..) => true, + _ => false, + } + } + + pub fn def_id(&self) -> DefId { + match *self { + DefiningTy::Closure(def_id, ..) => def_id, + DefiningTy::Generator(def_id, ..) => def_id, + DefiningTy::FnDef(def_id, ..) => def_id, + DefiningTy::Const(def_id, ..) => def_id, + } + } } #[derive(Debug)] From 4d22e757cd97d1a69ed8ddda7d346355ce466255 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Fri, 24 Jan 2020 12:02:33 -0600 Subject: [PATCH 2/9] minor cleanup --- src/librustc_mir/borrow_check/universal_regions.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/borrow_check/universal_regions.rs b/src/librustc_mir/borrow_check/universal_regions.rs index 777eea22eb639..6d79b7228f22d 100644 --- a/src/librustc_mir/borrow_check/universal_regions.rs +++ b/src/librustc_mir/borrow_check/universal_regions.rs @@ -148,10 +148,10 @@ impl<'tcx> DefiningTy<'tcx> { pub fn def_id(&self) -> DefId { match *self { - DefiningTy::Closure(def_id, ..) => def_id, - DefiningTy::Generator(def_id, ..) => def_id, - DefiningTy::FnDef(def_id, ..) => def_id, - DefiningTy::Const(def_id, ..) => def_id, + DefiningTy::Closure(def_id, ..) + | DefiningTy::Generator(def_id, ..) + | DefiningTy::FnDef(def_id, ..) + | DefiningTy::Const(def_id, ..) => def_id, } } } From 245062cdcd9907bd7f71822f958219dc8ce994d2 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Fri, 24 Jan 2020 12:13:45 -0600 Subject: [PATCH 3/9] some fixes --- src/librustc/ty/context.rs | 11 ++++------- .../borrow_check/diagnostics/conflict_errors.rs | 13 +------------ .../borrow_check/diagnostics/region_errors.rs | 2 +- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index fd2f58d24f8dd..07c7ccfd16da2 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1518,13 +1518,10 @@ impl<'tcx> TyCtxt<'tcx> { &self, def_id: crate::hir::def_id::DefId, ) -> (&'static str, &'static str) { - self.def_kind(def_id).map_or_else( - || { - // TODO: is it a problem to try to use the ty here? - self.type_of(def_id).kind.article_and_description() - }, - |def_kind| (def_kind.article(), def_kind.descr(def_id)), - ) + match self.def_kind(def_id) { + Some(def_kind) => (def_kind.article(), def_kind.descr(def_id)), + None => self.type_of(def_id).kind.article_and_description(), + } } } diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 41a99d1125b5d..83669a53eb4ac 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -1275,18 +1275,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ) -> DiagnosticBuilder<'cx> { let tcx = self.infcx.tcx; - let escapes_from = if tcx.is_closure(self.mir_def_id) { - let tables = tcx.typeck_tables_of(self.mir_def_id); - let mir_hir_id = tcx.hir().def_index_to_hir_id(self.mir_def_id.index); - match tables.node_type(mir_hir_id).kind { - ref kind @ ty::Closure(..) | ref kind @ ty::Generator(..) => { - kind.article_and_description().1 - } - _ => bug!("Closure body doesn't have a closure or generator type"), - } - } else { - "function" - }; + let (_, escapes_from) = tcx.article_and_description(self.mir_def_id); let mut err = borrowck_errors::borrowed_data_escapes_closure(tcx, escape_span, escapes_from); diff --git a/src/librustc_mir/borrow_check/diagnostics/region_errors.rs b/src/librustc_mir/borrow_check/diagnostics/region_errors.rs index 0f0fd64844a8d..f4089b2686084 100644 --- a/src/librustc_mir/borrow_check/diagnostics/region_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/region_errors.rs @@ -435,7 +435,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if (fr_name_and_span.is_none() && outlived_fr_name_and_span.is_none()) || (*category == ConstraintCategory::Assignment && self.universal_regions.defining_ty.is_fn_def()) - || self.universal_regions.defining_ty.is_closure() + || self.universal_regions.defining_ty.is_const() { return self.report_general_error(&ErrorConstraintInfo { fr_is_local: true, From 66500effea474498052ecd0cd26274be5602a63a Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Sat, 25 Jan 2020 19:09:23 -0600 Subject: [PATCH 4/9] add generator_kind query --- src/librustc/query/mod.rs | 3 +++ src/librustc/ty/context.rs | 22 +++++++++++-------- src/librustc_metadata/rmeta/decoder.rs | 19 +++++++++++----- .../rmeta/decoder/cstore_impl.rs | 1 + src/librustc_metadata/rmeta/encoder.rs | 16 ++++---------- src/librustc_metadata/rmeta/mod.rs | 6 ++--- .../borrow_check/diagnostics/region_errors.rs | 10 +++++---- .../borrow_check/universal_regions.rs | 8 +++---- src/librustc_typeck/collect.rs | 15 +++++++++++-- 9 files changed, 60 insertions(+), 40 deletions(-) diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 02c51a2ebb0e9..3a6961660fd69 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -308,6 +308,9 @@ rustc_queries! { /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item. query static_mutability(_: DefId) -> Option {} + /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator. + query generator_kind(_: DefId) -> Option {} + /// Gets a map with the variance of every item; use `item_variance` instead. query crate_variances(_: CrateNum) -> &'tcx ty::CrateVariancesMap<'tcx> { desc { "computing the variances for items in this crate" } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 07c7ccfd16da2..2d8601f9556a3 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -5,7 +5,7 @@ use crate::dep_graph::DepGraph; use crate::dep_graph::{self, DepConstructor}; use crate::hir::exports::Export; use crate::hir::map as hir_map; -use crate::hir::map::DefPathHash; +use crate::hir::map::{DefPathData, DefPathHash}; use crate::ich::{NodeIdHashingMode, StableHashingContext}; use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; use crate::lint::{struct_lint_level, LintSource}; @@ -1513,14 +1513,18 @@ impl<'tcx> TyCtxt<'tcx> { ) } - /// Returns a displayable description and article for the given `def_id` (e.g. `("a", "closure")`). - pub fn article_and_description( - &self, - def_id: crate::hir::def_id::DefId, - ) -> (&'static str, &'static str) { - match self.def_kind(def_id) { - Some(def_kind) => (def_kind.article(), def_kind.descr(def_id)), - None => self.type_of(def_id).kind.article_and_description(), + /// Returns a displayable description and article for the given `def_id` (e.g. `("a", "struct")`). + pub fn article_and_description(&self, def_id: DefId) -> (&'static str, &'static str) { + match self.def_key(def_id).disambiguated_data.data { + DefPathData::TypeNs(..) | DefPathData::ValueNs(..) | DefPathData::MacroNs(..) => { + let kind = self.def_kind(def_id).unwrap(); + (kind.article(), kind.descr(def_id)) + } + DefPathData::ClosureExpr => { + // TODO + todo!(); + } + _ => bug!("article_and_description called on def_id {:?}", def_id), } } } diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index 01fd637b20e66..d09e68e34a6c3 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -500,7 +500,7 @@ impl MetadataBlob { } } -impl<'tcx> EntryKind<'tcx> { +impl EntryKind { fn def_kind(&self) -> Option { Some(match *self { EntryKind::Const(..) => DefKind::Const, @@ -614,11 +614,11 @@ impl<'a, 'tcx> CrateMetadata { self.root.proc_macro_data.and_then(|data| data.decode(self).find(|x| *x == id)).is_some() } - fn maybe_kind(&self, item_id: DefIndex) -> Option> { + fn maybe_kind(&self, item_id: DefIndex) -> Option { self.root.per_def.kind.get(self, item_id).map(|k| k.decode(self)) } - fn kind(&self, item_id: DefIndex) -> EntryKind<'tcx> { + fn kind(&self, item_id: DefIndex) -> EntryKind { assert!(!self.is_proc_macro(item_id)); self.maybe_kind(item_id).unwrap_or_else(|| { bug!( @@ -723,7 +723,7 @@ impl<'a, 'tcx> CrateMetadata { fn get_variant( &self, tcx: TyCtxt<'tcx>, - kind: &EntryKind<'_>, + kind: &EntryKind, index: DefIndex, parent_did: DefId, ) -> ty::VariantDef { @@ -1390,6 +1390,13 @@ impl<'a, 'tcx> CrateMetadata { } } + fn generator_kind(&self, id: DefIndex) -> Option { + match self.kind(id) { + EntryKind::Generator(data) => Some(data.decode(self)), + _ => None, + } + } + fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> { self.root.per_def.fn_sig.get(self, id).unwrap().decode((self, tcx)) } @@ -1499,8 +1506,8 @@ impl<'a, 'tcx> CrateMetadata { ); debug!( "CrateMetaData::imported_source_files alloc \ - source_file {:?} original (start_pos {:?} end_pos {:?}) \ - translated (start_pos {:?} end_pos {:?})", + source_file {:?} original (start_pos {:?} end_pos {:?}) \ + translated (start_pos {:?} end_pos {:?})", local_version.name, start_pos, end_pos, diff --git a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs index fb7e5541e266e..e6270e903295c 100644 --- a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs +++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs @@ -134,6 +134,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, asyncness => { cdata.asyncness(def_id.index) } is_foreign_item => { cdata.is_foreign_item(def_id.index) } static_mutability => { cdata.static_mutability(def_id.index) } + generator_kind => { cdata.generator_kind(def_id.index) } def_kind => { cdata.def_kind(def_id.index) } def_span => { cdata.get_span(def_id.index, &tcx.sess) } lookup_stability => { diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 41fc5ed843fd3..e985ec5fcdfda 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -306,7 +306,7 @@ impl<'tcx> EncodeContext<'tcx> { assert!( last_min_end <= lazy.position, "make sure that the calls to `lazy*` \ - are in the same order as the metadata fields", + are in the same order as the metadata fields", ); lazy.position.get() - last_min_end.get() } @@ -1248,12 +1248,7 @@ impl EncodeContext<'tcx> { self.encode_deprecation(def_id); } - fn encode_info_for_generic_param( - &mut self, - def_id: DefId, - kind: EntryKind<'tcx>, - encode_type: bool, - ) { + fn encode_info_for_generic_param(&mut self, def_id: DefId, kind: EntryKind, encode_type: bool) { record!(self.per_def.kind[def_id] <- kind); record!(self.per_def.visibility[def_id] <- ty::Visibility::Public); record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id)); @@ -1271,11 +1266,8 @@ impl EncodeContext<'tcx> { let ty = self.tcx.typeck_tables_of(def_id).node_type(hir_id); record!(self.per_def.kind[def_id] <- match ty.kind { - ty::Generator(def_id, ..) => { - let layout = self.tcx.generator_layout(def_id); - let data = GeneratorData { - layout: layout.clone(), - }; + ty::Generator(..) => { + let data = self.tcx.generator_kind(def_id).unwrap(); EntryKind::Generator(self.lazy(data)) } diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs index 77ec3eb4555e3..a3e3165f31edf 100644 --- a/src/librustc_metadata/rmeta/mod.rs +++ b/src/librustc_metadata/rmeta/mod.rs @@ -252,7 +252,7 @@ macro_rules! define_per_def_tables { } define_per_def_tables! { - kind: Table)>, + kind: Table>, visibility: Table>, span: Table>, attributes: Table>, @@ -279,7 +279,7 @@ define_per_def_tables! { } #[derive(Copy, Clone, RustcEncodable, RustcDecodable)] -enum EntryKind<'tcx> { +enum EntryKind { Const(mir::ConstQualifs, Lazy), ImmStatic, MutStatic, @@ -302,7 +302,7 @@ enum EntryKind<'tcx> { Mod(Lazy), MacroDef(Lazy), Closure, - Generator(Lazy!(GeneratorData<'tcx>)), + Generator(Lazy), Trait(Lazy), Impl(Lazy), Method(Lazy), diff --git a/src/librustc_mir/borrow_check/diagnostics/region_errors.rs b/src/librustc_mir/borrow_check/diagnostics/region_errors.rs index f4089b2686084..8d991927d5437 100644 --- a/src/librustc_mir/borrow_check/diagnostics/region_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/region_errors.rs @@ -427,15 +427,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { errci.outlived_fr, ); - let (_, escapes_from) = - self.infcx.tcx.article_and_description(self.universal_regions.defining_ty.def_id()); + let (_, escapes_from) = self + .infcx + .tcx + .article_and_description(self.regioncx.universal_regions().defining_ty.def_id()); // Revert to the normal error in these cases. // Assignments aren't "escapes" in function items. if (fr_name_and_span.is_none() && outlived_fr_name_and_span.is_none()) || (*category == ConstraintCategory::Assignment - && self.universal_regions.defining_ty.is_fn_def()) - || self.universal_regions.defining_ty.is_const() + && self.regioncx.universal_regions().defining_ty.is_fn_def()) + || self.regioncx.universal_regions().defining_ty.is_const() { return self.report_general_error(&ErrorConstraintInfo { fr_is_local: true, diff --git a/src/librustc_mir/borrow_check/universal_regions.rs b/src/librustc_mir/borrow_check/universal_regions.rs index 6d79b7228f22d..af4ea759f4f8b 100644 --- a/src/librustc_mir/borrow_check/universal_regions.rs +++ b/src/librustc_mir/borrow_check/universal_regions.rs @@ -132,16 +132,16 @@ impl<'tcx> DefiningTy<'tcx> { } } - pub fn is_closure(&self) -> bool { + pub fn is_fn_def(&self) -> bool { match *self { - DefiningTy::Closure(..) => true, + DefiningTy::FnDef(..) => true, _ => false, } } - pub fn is_fn_def(&self) -> bool { + pub fn is_const(&self) -> bool { match *self { - DefiningTy::FnDef(..) => true, + DefiningTy::Const(..) => true, _ => false, } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 70586be0d0433..2b85cba900394 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -76,6 +76,7 @@ pub fn provide(providers: &mut Providers<'_>) { impl_polarity, is_foreign_item, static_mutability, + generator_kind, codegen_fn_attrs, collect_mod_item_types, ..*providers @@ -1006,7 +1007,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TraitDef { .struct_span_err( item.span, "the `#[rustc_paren_sugar]` attribute is a temporary means of controlling \ - which traits can use parenthetical notation", + which traits can use parenthetical notation", ) .help("add `#![feature(unboxed_closures)]` to the crate attributes to use it") .emit(); @@ -2106,7 +2107,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( ast_ty.span, &format!( "use of SIMD type `{}` in FFI is highly experimental and \ - may result in invalid code", + may result in invalid code", tcx.hir().hir_to_pretty_string(ast_ty.hir_id) ), ) @@ -2145,6 +2146,16 @@ fn static_mutability(tcx: TyCtxt<'_>, def_id: DefId) -> Option } } +fn generator_kind(tcx: TyCtxt<'_>, def_id: DefId) -> Option { + match tcx.hir().get_if_local(def_id) { + Some(Node::Item(&hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. })) => { + tcx.hir().body(body_id).generator_kind() + } + Some(_) => None, + _ => bug!("generator_kind applied to non-local def-id {:?}", def_id), + } +} + fn from_target_feature( tcx: TyCtxt<'_>, id: DefId, From c6781037eb5864b532094ade1fdbeea336af1836 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Sat, 25 Jan 2020 19:31:38 -0600 Subject: [PATCH 5/9] article and descr for closures --- src/librustc/ty/context.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 2d8601f9556a3..4db20817e641c 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1520,10 +1520,11 @@ impl<'tcx> TyCtxt<'tcx> { let kind = self.def_kind(def_id).unwrap(); (kind.article(), kind.descr(def_id)) } - DefPathData::ClosureExpr => { - // TODO - todo!(); - } + DefPathData::ClosureExpr => match self.generator_kind(def_id) { + None => ("a", "closure"), + Some(rustc_hir::GeneratorKind::Async(..)) => ("an", "async closure"), + Some(rustc_hir::GeneratorKind::Gen) => ("a", "generator"), + }, _ => bug!("article_and_description called on def_id {:?}", def_id), } } From 74360571e9850840c093bdba2310fa7b8f898a0f Mon Sep 17 00:00:00 2001 From: mark Date: Sat, 8 Feb 2020 16:33:50 -0600 Subject: [PATCH 6/9] address some review comments/bugs --- src/librustc/ty/context.rs | 2 ++ src/librustc_typeck/collect.rs | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 4db20817e641c..7237b50d8f39a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1525,6 +1525,8 @@ impl<'tcx> TyCtxt<'tcx> { Some(rustc_hir::GeneratorKind::Async(..)) => ("an", "async closure"), Some(rustc_hir::GeneratorKind::Gen) => ("a", "generator"), }, + DefPathData::LifetimeNs(..) => ("a", "lifetime"), + DefPathData::Impl => ("an", "implementation"), _ => bug!("article_and_description called on def_id {:?}", def_id), } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 2b85cba900394..869a1dcbcc7a6 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2148,9 +2148,10 @@ fn static_mutability(tcx: TyCtxt<'_>, def_id: DefId) -> Option fn generator_kind(tcx: TyCtxt<'_>, def_id: DefId) -> Option { match tcx.hir().get_if_local(def_id) { - Some(Node::Item(&hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. })) => { - tcx.hir().body(body_id).generator_kind() - } + Some(Node::Expr(&rustc_hir::Expr { + kind: rustc_hir::ExprKind::Closure(_, _, body_id, _, _), + .. + })) => tcx.hir().body(body_id).generator_kind(), Some(_) => None, _ => bug!("generator_kind applied to non-local def-id {:?}", def_id), } From 9207a13bfc48ebc8582555abd922748a69d2488c Mon Sep 17 00:00:00 2001 From: mark Date: Sat, 22 Feb 2020 13:05:32 -0600 Subject: [PATCH 7/9] get rid of lazy --- src/librustc_metadata/rmeta/decoder.rs | 2 +- src/librustc_metadata/rmeta/encoder.rs | 2 +- src/librustc_metadata/rmeta/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index d09e68e34a6c3..2576514735bae 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -1392,7 +1392,7 @@ impl<'a, 'tcx> CrateMetadata { fn generator_kind(&self, id: DefIndex) -> Option { match self.kind(id) { - EntryKind::Generator(data) => Some(data.decode(self)), + EntryKind::Generator(data) => Some(data), _ => None, } } diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index e985ec5fcdfda..ee54f40ece5c8 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -1268,7 +1268,7 @@ impl EncodeContext<'tcx> { record!(self.per_def.kind[def_id] <- match ty.kind { ty::Generator(..) => { let data = self.tcx.generator_kind(def_id).unwrap(); - EntryKind::Generator(self.lazy(data)) + EntryKind::Generator(data) } ty::Closure(..) => EntryKind::Closure, diff --git a/src/librustc_metadata/rmeta/mod.rs b/src/librustc_metadata/rmeta/mod.rs index a3e3165f31edf..01a3f6c560f1b 100644 --- a/src/librustc_metadata/rmeta/mod.rs +++ b/src/librustc_metadata/rmeta/mod.rs @@ -302,7 +302,7 @@ enum EntryKind { Mod(Lazy), MacroDef(Lazy), Closure, - Generator(Lazy), + Generator(hir::GeneratorKind), Trait(Lazy), Impl(Lazy), Method(Lazy), From 7a6361f4655fe26f6f25efc551242115953ae335 Mon Sep 17 00:00:00 2001 From: mark Date: Sat, 22 Feb 2020 13:09:54 -0600 Subject: [PATCH 8/9] remove unneeded fn --- src/librustc/ty/sty.rs | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index a54bf4d7eff38..c3698f402a9d1 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -254,41 +254,6 @@ pub enum TyKind<'tcx> { Error, } -impl<'tcx> TyKind<'tcx> { - pub fn article_and_description(&self) -> (&'static str, &'static str) { - match *self { - Bool => ("a", "boolean value"), - Char => ("a", "character"), - Int(..) => ("a", "signed interger"), - Uint(..) => ("an", "unsigned integer"), - Float(..) => ("a", "floating point number"), - Adt(..) => ("an", "abstract data type"), - Foreign(..) => ("a", "foreign type"), - Str => ("a", "string slice"), - Array(..) => ("an", "array"), - Slice(..) => ("a", "slice"), - RawPtr(..) => ("a", "raw pointer"), - Ref(..) => ("a", "reference"), - FnDef(..) => ("a", "function"), - FnPtr(..) => ("a", "function pointer"), - Dynamic(..) => ("a", "trait object"), - Closure(..) => ("a", "closure"), - Generator(..) => ("a", "generator"), - GeneratorWitness(..) => ("a", "generator witness"), - Never => ("a", "never"), - Tuple(..) => ("a", "tuple"), - Projection(..) => ("a", "projection"), - UnnormalizedProjection(..) => ("an", "unnormalized projection"), - Opaque(..) => ("an", "opaque type"), - Param(..) => ("a", "type parameter"), - Bound(..) => ("a", "bound type variable"), - Placeholder(..) => ("a", "universally quantified higher-ranked type"), - Infer(..) => ("an", "inference variable"), - Error => ("a", "type error"), - } - } -} - // `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(target_arch = "x86_64")] static_assert_size!(TyKind<'_>, 24); From 9434d6b67fb0817e7db5217e6355cbf4c7e402f6 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Sat, 22 Feb 2020 16:14:14 -0600 Subject: [PATCH 9/9] update some tests --- .../ui/async-await/issues/issue-62097.nll.stderr | 6 +++--- .../ui/async-await/issues/issue-63388-1.nll.stderr | 2 +- src/test/ui/issues/issue-16683.nll.stderr | 6 +++--- src/test/ui/issues/issue-17758.nll.stderr | 6 +++--- ...one-existing-name-if-else-using-impl.nll.stderr | 2 +- ...ne-existing-name-return-type-is-anon.nll.stderr | 2 +- ...eturn-one-existing-name-self-is-anon.nll.stderr | 2 +- ...oth-anon-regions-return-type-is-anon.nll.stderr | 2 +- .../ex3-both-anon-regions-self-is-anon.nll.stderr | 2 +- src/test/ui/nll/outlives-suggestion-simple.rs | 2 +- src/test/ui/nll/outlives-suggestion-simple.stderr | 8 ++++---- ...lf_types_pin_lifetime_mismatch-async.nll.stderr | 6 +++--- ...ary_self_types_pin_lifetime_mismatch.nll.stderr | 6 +++--- .../ui/self/elision/lt-ref-self-async.nll.stderr | 12 ++++++------ src/test/ui/self/elision/lt-ref-self.nll.stderr | 12 ++++++------ .../ui/self/elision/ref-mut-self-async.nll.stderr | 12 ++++++------ src/test/ui/self/elision/ref-mut-self.nll.stderr | 12 ++++++------ .../self/elision/ref-mut-struct-async.nll.stderr | 10 +++++----- src/test/ui/self/elision/ref-mut-struct.nll.stderr | 10 +++++----- src/test/ui/self/elision/ref-self.nll.stderr | 14 +++++++------- .../ui/self/elision/ref-struct-async.nll.stderr | 10 +++++----- src/test/ui/self/elision/ref-struct.nll.stderr | 10 +++++----- 22 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/test/ui/async-await/issues/issue-62097.nll.stderr b/src/test/ui/async-await/issues/issue-62097.nll.stderr index 0c64f90cb9fae..f72c645bf8dbf 100644 --- a/src/test/ui/async-await/issues/issue-62097.nll.stderr +++ b/src/test/ui/async-await/issues/issue-62097.nll.stderr @@ -16,13 +16,13 @@ help: to force the closure to take ownership of `self` (and any other referenced LL | foo(move || self.bar()).await; | ^^^^^^^ -error[E0521]: borrowed data escapes outside of function +error[E0521]: borrowed data escapes outside of method --> $DIR/issue-62097.rs:13:9 | LL | pub async fn run_dummy_fn(&self) { - | ----- `self` is a reference that is only valid in the function body + | ----- `self` is a reference that is only valid in the method body LL | foo(|| self.bar()).await; - | ^^^^^^^^^^^^^^^^^^ `self` escapes the function body here + | ^^^^^^^^^^^^^^^^^^ `self` escapes the method body here error: aborting due to 2 previous errors diff --git a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr index 8e0e1ce3dc34d..696f79ec40f36 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.nll.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.nll.stderr @@ -9,7 +9,7 @@ LL | ) -> &dyn Foo LL | / { LL | | foo LL | | } - | |_____^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` + | |_____^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-16683.nll.stderr b/src/test/ui/issues/issue-16683.nll.stderr index ea6b69d1a76c6..f76e7a4e44fd7 100644 --- a/src/test/ui/issues/issue-16683.nll.stderr +++ b/src/test/ui/issues/issue-16683.nll.stderr @@ -1,10 +1,10 @@ -error[E0521]: borrowed data escapes outside of function +error[E0521]: borrowed data escapes outside of method --> $DIR/issue-16683.rs:4:9 | LL | fn b(&self) { - | ----- `self` is a reference that is only valid in the function body + | ----- `self` is a reference that is only valid in the method body LL | self.a(); - | ^^^^^^^^ `self` escapes the function body here + | ^^^^^^^^ `self` escapes the method body here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-17758.nll.stderr b/src/test/ui/issues/issue-17758.nll.stderr index b9dc9da3683d6..92e21f4dc1769 100644 --- a/src/test/ui/issues/issue-17758.nll.stderr +++ b/src/test/ui/issues/issue-17758.nll.stderr @@ -1,10 +1,10 @@ -error[E0521]: borrowed data escapes outside of function +error[E0521]: borrowed data escapes outside of method --> $DIR/issue-17758.rs:7:9 | LL | fn bar(&self) { - | ----- `self` is a reference that is only valid in the function body + | ----- `self` is a reference that is only valid in the method body LL | self.foo(); - | ^^^^^^^^^^ `self` escapes the function body here + | ^^^^^^^^^^ `self` escapes the method body here error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr index fc9093bb2e4b8..291edc505cd1e 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr @@ -7,7 +7,7 @@ LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { | lifetime `'a` defined here LL | LL | if x > y { x } else { y } - | ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr index 3384c24da8fbe..15ee58574ecaa 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr @@ -7,7 +7,7 @@ LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { | lifetime `'a` defined here LL | LL | x - | ^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` + | ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr index 5ef29076e07bf..a27a91e38f1e4 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr @@ -7,7 +7,7 @@ LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { | lifetime `'a` defined here LL | LL | if true { x } else { self } - | ^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` + | ^^^^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr index 1c258ad98ba10..5f922d8560b2a 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr @@ -6,7 +6,7 @@ LL | fn foo<'a>(&self, x: &i32) -> &i32 { | | | let's call the lifetime of this reference `'2` LL | x - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr index ffe39fdd8c9f5..91d7597c87fea 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr @@ -6,7 +6,7 @@ LL | fn foo<'a>(&self, x: &Foo) -> &Foo { | | | let's call the lifetime of this reference `'2` LL | if true { x } else { self } - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to previous error diff --git a/src/test/ui/nll/outlives-suggestion-simple.rs b/src/test/ui/nll/outlives-suggestion-simple.rs index 91a7a1d71e80c..ee5a80ae6483f 100644 --- a/src/test/ui/nll/outlives-suggestion-simple.rs +++ b/src/test/ui/nll/outlives-suggestion-simple.rs @@ -70,7 +70,7 @@ pub struct Foo2<'a> { impl<'a> Foo2<'a> { // should not produce outlives suggestions to name 'self fn get_bar(&self) -> Bar2 { - Bar2::new(&self) //~ERROR borrowed data escapes outside of function + Bar2::new(&self) //~ERROR borrowed data escapes outside of method } } diff --git a/src/test/ui/nll/outlives-suggestion-simple.stderr b/src/test/ui/nll/outlives-suggestion-simple.stderr index db7f57ceccf13..cf55603cd71f5 100644 --- a/src/test/ui/nll/outlives-suggestion-simple.stderr +++ b/src/test/ui/nll/outlives-suggestion-simple.stderr @@ -93,16 +93,16 @@ LL | self.x | = help: consider adding the following bound: `'b: 'a` -error[E0521]: borrowed data escapes outside of function +error[E0521]: borrowed data escapes outside of method --> $DIR/outlives-suggestion-simple.rs:73:9 | LL | fn get_bar(&self) -> Bar2 { | ----- | | - | `self` declared here, outside of the function body - | `self` is a reference that is only valid in the function body + | `self` declared here, outside of the method body + | `self` is a reference that is only valid in the method body LL | Bar2::new(&self) - | ^^^^^^^^^^^^^^^^ `self` escapes the function body here + | ^^^^^^^^^^^^^^^^ `self` escapes the method body here error: aborting due to 9 previous errors diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr index 61f6680d5a423..6afcf24cd3e1e 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr @@ -2,7 +2,7 @@ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52 | LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | - - ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | - - ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` @@ -11,7 +11,7 @@ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:75 | LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | - - ^^^^^^^^^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | - - ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` @@ -20,7 +20,7 @@ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64 | LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } - | -- - ^^^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` + | -- - ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` | | | | | let's call the lifetime of this reference `'1` | lifetime `'a` defined here diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr index 1a0904fcbba6e..a659e4487856c 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr @@ -2,7 +2,7 @@ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:6:46 | LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | - - ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | - - ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` @@ -11,7 +11,7 @@ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:8:69 | LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | - - ^^^^^^^^^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | - - ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` @@ -20,7 +20,7 @@ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:13:58 | LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } - | -- ---- has type `std::pin::Pin<&'1 Foo>` ^^^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` + | -- ---- has type `std::pin::Pin<&'1 Foo>` ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` | | | lifetime `'a` defined here diff --git a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr index e66711076e893..57d0929c50a79 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.nll.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.nll.stderr @@ -6,7 +6,7 @@ LL | async fn ref_self(&self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:19:9 @@ -16,7 +16,7 @@ LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:23:9 @@ -26,7 +26,7 @@ LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:27:9 @@ -36,7 +36,7 @@ LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:31:9 @@ -46,7 +46,7 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self-async.rs:35:9 @@ -56,7 +56,7 @@ LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/lt-ref-self.nll.stderr b/src/test/ui/self/elision/lt-ref-self.nll.stderr index a0c56f2221850..b51b5a0ba38f2 100644 --- a/src/test/ui/self/elision/lt-ref-self.nll.stderr +++ b/src/test/ui/self/elision/lt-ref-self.nll.stderr @@ -6,7 +6,7 @@ LL | fn ref_self(&self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:17:9 @@ -16,7 +16,7 @@ LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:21:9 @@ -26,7 +26,7 @@ LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:25:9 @@ -36,7 +36,7 @@ LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:29:9 @@ -46,7 +46,7 @@ LL | fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:33:9 @@ -56,7 +56,7 @@ LL | fn box_pin_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr index 82098cd4f077e..46e828390b0fc 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.nll.stderr @@ -6,7 +6,7 @@ LL | async fn ref_self(&mut self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:19:9 @@ -16,7 +16,7 @@ LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:23:9 @@ -26,7 +26,7 @@ LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:27:9 @@ -36,7 +36,7 @@ LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:31:9 @@ -46,7 +46,7 @@ LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self-async.rs:35:9 @@ -56,7 +56,7 @@ LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-self.nll.stderr b/src/test/ui/self/elision/ref-mut-self.nll.stderr index 4e7d7f521d256..6c8c030e5fffa 100644 --- a/src/test/ui/self/elision/ref-mut-self.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-self.nll.stderr @@ -6,7 +6,7 @@ LL | fn ref_self(&mut self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:17:9 @@ -16,7 +16,7 @@ LL | fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:21:9 @@ -26,7 +26,7 @@ LL | fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:25:9 @@ -36,7 +36,7 @@ LL | fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:29:9 @@ -46,7 +46,7 @@ LL | fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:33:9 @@ -56,7 +56,7 @@ LL | fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr index 736cebae4bccf..99340800790ec 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.nll.stderr @@ -6,7 +6,7 @@ LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:17:9 @@ -16,7 +16,7 @@ LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:21:9 @@ -26,7 +26,7 @@ LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:25:9 @@ -36,7 +36,7 @@ LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-struct-async.rs:29:9 @@ -46,7 +46,7 @@ LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-mut-struct.nll.stderr b/src/test/ui/self/elision/ref-mut-struct.nll.stderr index cec7034cd9f9d..e3886444db2ad 100644 --- a/src/test/ui/self/elision/ref-mut-struct.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-struct.nll.stderr @@ -6,7 +6,7 @@ LL | fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:15:9 @@ -16,7 +16,7 @@ LL | fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:19:9 @@ -26,7 +26,7 @@ LL | fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:23:9 @@ -36,7 +36,7 @@ LL | fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:27:9 @@ -46,7 +46,7 @@ LL | fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-self.nll.stderr b/src/test/ui/self/elision/ref-self.nll.stderr index 20045be0527a4..ecac1ce3378d6 100644 --- a/src/test/ui/self/elision/ref-self.nll.stderr +++ b/src/test/ui/self/elision/ref-self.nll.stderr @@ -6,7 +6,7 @@ LL | fn ref_self(&self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-self.rs:27:9 @@ -16,7 +16,7 @@ LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-self.rs:31:9 @@ -26,7 +26,7 @@ LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-self.rs:35:9 @@ -36,7 +36,7 @@ LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-self.rs:39:9 @@ -46,7 +46,7 @@ LL | fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-self.rs:43:9 @@ -56,7 +56,7 @@ LL | fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-self.rs:47:9 @@ -66,7 +66,7 @@ LL | fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 7 previous errors diff --git a/src/test/ui/self/elision/ref-struct-async.nll.stderr b/src/test/ui/self/elision/ref-struct-async.nll.stderr index 5d7dd76827a96..bcbf79bc039fd 100644 --- a/src/test/ui/self/elision/ref-struct-async.nll.stderr +++ b/src/test/ui/self/elision/ref-struct-async.nll.stderr @@ -6,7 +6,7 @@ LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:17:9 @@ -16,7 +16,7 @@ LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:21:9 @@ -26,7 +26,7 @@ LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:25:9 @@ -36,7 +36,7 @@ LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-struct-async.rs:29:9 @@ -46,7 +46,7 @@ LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-struct.nll.stderr b/src/test/ui/self/elision/ref-struct.nll.stderr index 31bb9f49a6c4d..39e7631f31e7b 100644 --- a/src/test/ui/self/elision/ref-struct.nll.stderr +++ b/src/test/ui/self/elision/ref-struct.nll.stderr @@ -6,7 +6,7 @@ LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-struct.rs:15:9 @@ -16,7 +16,7 @@ LL | fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-struct.rs:19:9 @@ -26,7 +26,7 @@ LL | fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-struct.rs:23:9 @@ -36,7 +36,7 @@ LL | fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: lifetime may not live long enough --> $DIR/ref-struct.rs:27:9 @@ -46,7 +46,7 @@ LL | fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { | | | let's call the lifetime of this reference `'2` LL | f - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` error: aborting due to 5 previous errors