From 3a1847b07d552fff62be4ebf11e74f90b6a43fce Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Wed, 28 Nov 2018 15:05:36 -0600 Subject: [PATCH 1/5] implement outlive suggestions --- src/librustc_errors/diagnostic.rs | 16 +- src/librustc_mir/borrow_check/mod.rs | 2 +- .../nll/region_infer/error_reporting/mod.rs | 25 +- .../error_reporting/outlives_suggestion.rs | 315 ++++++++++++++++++ .../borrow_check/nll/region_infer/mod.rs | 12 + .../propagate-approximated-ref.stderr | 4 + ...oximated-shorter-to-static-no-bound.stderr | 4 + ...mated-shorter-to-static-wrong-bound.stderr | 4 + .../propagate-approximated-val.stderr | 4 + ...n-lbr-named-does-not-outlive-static.stderr | 4 + .../region-lbr1-does-not-outlive-ebr2.stderr | 4 + src/test/ui/nll/issue-52113.stderr | 4 + src/test/ui/nll/issue-58299.stderr | 8 + src/test/ui/nll/mir_check_cast_closure.stderr | 4 + src/test/ui/nll/mir_check_cast_reify.stderr | 4 + .../ui/nll/mir_check_cast_unsafe_fn.stderr | 4 + src/test/ui/nll/mir_check_cast_unsize.stderr | 4 + src/test/ui/nll/outlives-suggestion-simple.rs | 77 +++++ .../ui/nll/outlives-suggestion-simple.stderr | 118 +++++++ .../projection-one-region-closure.stderr | 8 + ...tion-one-region-trait-bound-closure.stderr | 8 + ...tion-two-region-trait-bound-closure.stderr | 4 + .../ui/nll/ty-outlives/wf-unreachable.stderr | 32 ++ .../nll/type-check-pointer-coercions.stderr | 28 ++ .../nll/type-check-pointer-comparisons.stderr | 12 + .../user-annotations/closure-substs.stderr | 8 + .../inherent-associated-constants.stderr | 4 + .../nll/user-annotations/issue-54124.stderr | 4 + ...-55748-pat-types-constrain-bindings.stderr | 12 + .../issue-57731-ascibed-coupled-types.stderr | 16 + .../ui/nll/user-annotations/patterns.stderr | 16 + .../nll/user-annotations/wf-self-type.stderr | 4 + .../ui/nll/where_clauses_in_functions.stderr | 4 + .../ui/nll/where_clauses_in_structs.stderr | 4 + ...n-supertrait-outlives-container.nll.stderr | 4 + ...ons-free-region-ordering-caller.nll.stderr | 12 + ...lives-projection-container-hrtb.nll.stderr | 8 + ...utlives-projection-container-wc.nll.stderr | 4 + .../regions/regions-static-bound.nll.stderr | 4 + 39 files changed, 807 insertions(+), 6 deletions(-) create mode 100644 src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs create mode 100644 src/test/ui/nll/outlives-suggestion-simple.rs create mode 100644 src/test/ui/nll/outlives-suggestion-simple.stderr diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 1781f2e165033..3c4539b597ba9 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -6,7 +6,7 @@ use crate::Applicability; use crate::Level; use crate::snippet::Style; use std::fmt; -use syntax_pos::{MultiSpan, Span}; +use syntax_pos::{MultiSpan, Span, DUMMY_SP}; #[must_use] #[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] @@ -17,6 +17,11 @@ pub struct Diagnostic { pub span: MultiSpan, pub children: Vec, pub suggestions: Vec, + + /// This is not used for highlighting or rendering any error message. Rather, it can be used + /// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of + /// `span` if there is one. Otherwise, it is `DUMMY_SP`. + pub sort_span: Span, } #[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] @@ -87,6 +92,7 @@ impl Diagnostic { span: MultiSpan::new(), children: vec![], suggestions: vec![], + sort_span: DUMMY_SP, } } @@ -118,6 +124,11 @@ impl Diagnostic { self.level == Level::Cancelled } + /// Set the sorting span. + pub fn set_sort_span(&mut self, sp: Span) { + self.sort_span = sp; + } + /// Adds a span/label to be included in the resulting snippet. /// This label will be shown together with the original span/label used when creating the /// diagnostic, *not* a span added by one of the `span_*` methods. @@ -457,6 +468,9 @@ impl Diagnostic { pub fn set_span>(&mut self, sp: S) -> &mut Self { self.span = sp.into(); + if let Some(span) = self.span.primary_span() { + self.sort_span = span; + } self } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index c3369e872151a..4bfd0844f8436 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -367,7 +367,7 @@ fn do_mir_borrowck<'a, 'tcx>( } if !mbcx.errors_buffer.is_empty() { - mbcx.errors_buffer.sort_by_key(|diag| diag.span.primary_span()); + mbcx.errors_buffer.sort_by_key(|diag| diag.sort_span); for diag in mbcx.errors_buffer.drain(..) { mbcx.infcx.tcx.sess.diagnostic().emit_diagnostic(&diag); diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index 7362ae9c638b1..26b288cb4b24e 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -18,6 +18,10 @@ use syntax::errors::Applicability; use syntax::symbol::kw; use syntax_pos::Span; +use self::outlives_suggestion::OutlivesSuggestionBuilder; + +pub mod outlives_suggestion; + mod region_name; mod var_name; @@ -56,7 +60,6 @@ enum Trace { /// Various pieces of state used when reporting borrow checker errors. pub struct ErrorReportingCtx<'a, 'b, 'tcx> { /// The region inference context used for borrow chekcing this MIR body. - #[allow(dead_code)] // FIXME(mark-i-m): used by outlives suggestions region_infcx: &'b RegionInferenceContext<'tcx>, /// The inference context used for type checking. @@ -370,6 +373,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { fr: RegionVid, fr_origin: NLLRegionVariableOrigin, outlived_fr: RegionVid, + outlives_suggestion: &mut OutlivesSuggestionBuilder, renctx: &mut RegionErrorNamingCtx, ) -> DiagnosticBuilder<'a> { debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr); @@ -415,9 +419,22 @@ impl<'tcx> RegionInferenceContext<'tcx> { self.report_fnmut_error(&errctx, &errci, renctx) } (ConstraintCategory::Assignment, true, false) - | (ConstraintCategory::CallArgument, true, false) => - self.report_escaping_data_error(&errctx, &errci, renctx), - _ => self.report_general_error(&errctx, &errci, renctx), + | (ConstraintCategory::CallArgument, true, false) => { + let mut db = self.report_escaping_data_error(&errctx, &errci, renctx); + + outlives_suggestion.intermediate_suggestion(&errctx, &errci, renctx, &mut db); + outlives_suggestion.collect_constraint(fr, outlived_fr); + + db + } + _ => { + let mut db = self.report_general_error(&errctx, &errci, renctx); + + outlives_suggestion.intermediate_suggestion(&errctx, &errci, renctx, &mut db); + outlives_suggestion.collect_constraint(fr, outlived_fr); + + db + } } } diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs new file mode 100644 index 0000000000000..a55a3a406044b --- /dev/null +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs @@ -0,0 +1,315 @@ +//! Contains utilities for generating suggestions for borrowck errors related to unsatisified +//! outlives constraints. + +use std::collections::BTreeMap; + +use log::debug; +use rustc::{hir::def_id::DefId, infer::InferCtxt, mir::Body, ty::RegionVid}; +use rustc_data_structures::fx::FxHashSet; +use rustc_errors::{Diagnostic, DiagnosticBuilder, Level}; + +use smallvec::SmallVec; + +use crate::borrow_check::nll::region_infer::{ + error_reporting::{ + region_name::{RegionName, RegionNameSource}, + ErrorConstraintInfo, ErrorReportingCtx, RegionErrorNamingCtx, + }, + RegionInferenceContext, +}; + +/// The different things we could suggest. +enum SuggestedConstraint { + /// Outlives(a, [b, c, d, ...]) => 'a: 'b + 'c + 'd + ... + Outlives(RegionName, SmallVec<[RegionName; 2]>), + + /// 'a = 'b + Equal(RegionName, RegionName), + + /// 'a: 'static i.e. 'a = 'static and the user should just use 'static + Static(RegionName), +} + +/// Collects information about outlives constraints that needed to be added for a given MIR node +/// corresponding to a function definition. +/// +/// Adds a help note suggesting adding a where clause with the needed constraints. +pub struct OutlivesSuggestionBuilder { + /// The MIR DefId of the fn with the lifetime error. + mir_def_id: DefId, + + /// The list of outlives constraints that need to be added. Specifically, we map each free + /// region to all other regions that it must outlive. I will use the shorthand `fr: + /// outlived_frs`. Not all of these regions will already have names necessarily. Some could be + /// implicit free regions that we inferred. These will need to be given names in the final + /// suggestion message. + constraints_to_add: BTreeMap>, +} + +impl OutlivesSuggestionBuilder { + /// Create a new builder for the given MIR node representing a fn definition. + crate fn new(mir_def_id: DefId) -> Self { + OutlivesSuggestionBuilder { mir_def_id, constraints_to_add: BTreeMap::default() } + } + + /// Returns `true` iff the `RegionNameSource` is a valid source for an outlives + /// suggestion. + // + // FIXME: Currently, we only report suggestions if the `RegionNameSource` is an early-bound + // region or a named region, avoiding using regions with synthetic names altogether. This + // allows us to avoid giving impossible suggestions (e.g. adding bounds to closure args). + // We can probably be less conservative, since some inferred free regions are namable (e.g. + // the user can explicitly name them. To do this, we would allow some regions whose names + // come from `MatchedAdtAndSegment`, being careful to filter out bad suggestions, such as + // naming the `'self` lifetime in methods, etc. + fn region_name_is_suggestable(name: &RegionName) -> bool { + match name.source { + RegionNameSource::NamedEarlyBoundRegion(..) + | RegionNameSource::NamedFreeRegion(..) + | RegionNameSource::Static => { + debug!("Region {:?} is suggestable", name); + true + } + + // Don't give suggestions for upvars, closure return types, or other unnamable + // regions. + RegionNameSource::SynthesizedFreeEnvRegion(..) + | RegionNameSource::CannotMatchHirTy(..) + | RegionNameSource::MatchedHirTy(..) + | RegionNameSource::MatchedAdtAndSegment(..) + | RegionNameSource::AnonRegionFromUpvar(..) + | RegionNameSource::AnonRegionFromOutput(..) + | RegionNameSource::AnonRegionFromYieldTy(..) => { + debug!("Region {:?} is NOT suggestable", name); + false + } + } + } + + /// Returns a name for the region if it is suggestable. See `region_name_is_suggestable`. + fn region_vid_to_name( + &self, + errctx: &ErrorReportingCtx<'_, '_, '_>, + renctx: &mut RegionErrorNamingCtx, + region: RegionVid, + ) -> Option { + errctx + .region_infcx + .give_region_a_name(errctx, renctx, region) + .filter(Self::region_name_is_suggestable) + } + + /// Compiles a list of all suggestions to be printed in the final big suggestion. + fn compile_all_suggestions<'tcx>( + &self, + body: &Body<'tcx>, + region_infcx: &RegionInferenceContext<'tcx>, + infcx: &InferCtxt<'_, 'tcx>, + renctx: &mut RegionErrorNamingCtx, + ) -> SmallVec<[SuggestedConstraint; 2]> { + let mut suggested = SmallVec::new(); + + // Keep track of variables that we have already suggested unifying so that we don't print + // out silly duplicate messages. + let mut unified_already = FxHashSet::default(); + + let errctx = ErrorReportingCtx { + region_infcx, + infcx, + body, + mir_def_id: self.mir_def_id, + + // We should not be suggesting naming upvars, so we pass in a dummy set of upvars that + // should never be used. + upvars: &[], + }; + + for (fr, outlived) in &self.constraints_to_add { + let fr_name = if let Some(fr_name) = self.region_vid_to_name(&errctx, renctx, *fr) { + fr_name + } else { + continue; + }; + + let outlived = outlived + .iter() + // if there is a `None`, we will just omit that constraint + .filter_map(|fr| { + self.region_vid_to_name(&errctx, renctx, *fr).map(|rname| (fr, rname)) + }) + .collect::>(); + + // No suggestable outlived lifetimes. + if outlived.is_empty() { + continue; + } + + // There are three types of suggestions we can make: + // 1) Suggest a bound: 'a: 'b + // 2) Suggest replacing 'a with 'static. If any of `outlived` is `'static`, then we + // should just replace 'a with 'static. + // 3) Suggest unifying 'a with 'b if we have both 'a: 'b and 'b: 'a + + if outlived.iter().any(|(_, outlived_name)| { + if let RegionNameSource::Static = outlived_name.source { + true + } else { + false + } + }) { + suggested.push(SuggestedConstraint::Static(fr_name)); + } else { + // We want to isolate out all lifetimes that should be unified and print out + // separate messages for them. + + let (unified, other): (Vec<_>, Vec<_>) = outlived.into_iter().partition( + // Do we have both 'fr: 'r and 'r: 'fr? + |(r, _)| { + self.constraints_to_add + .get(r) + .map(|r_outlived| r_outlived.as_slice().contains(fr)) + .unwrap_or(false) + }, + ); + + for (r, bound) in unified.into_iter() { + if !unified_already.contains(fr) { + suggested.push(SuggestedConstraint::Equal(fr_name.clone(), bound)); + unified_already.insert(r); + } + } + + if !other.is_empty() { + let other = + other.iter().map(|(_, rname)| rname.clone()).collect::>(); + suggested.push(SuggestedConstraint::Outlives(fr_name, other)) + } + } + } + + suggested + } + + /// Add the outlives constraint `fr: outlived_fr` to the set of constraints we need to suggest. + crate fn collect_constraint(&mut self, fr: RegionVid, outlived_fr: RegionVid) { + debug!("Collected {:?}: {:?}", fr, outlived_fr); + + // Add to set of constraints for final help note. + self.constraints_to_add.entry(fr).or_insert(Vec::new()).push(outlived_fr); + } + + /// Emit an intermediate note on the given `Diagnostic` if the involved regions are + /// suggestable. + crate fn intermediate_suggestion( + &mut self, + errctx: &ErrorReportingCtx<'_, '_, '_>, + errci: &ErrorConstraintInfo, + renctx: &mut RegionErrorNamingCtx, + diag: &mut DiagnosticBuilder<'_>, + ) { + // Emit an intermediate note. + let fr_name = self.region_vid_to_name(errctx, renctx, errci.fr); + let outlived_fr_name = self.region_vid_to_name(errctx, renctx, errci.outlived_fr); + + if let (Some(fr_name), Some(outlived_fr_name)) = (fr_name, outlived_fr_name) { + if let RegionNameSource::Static = outlived_fr_name.source { + diag.help(&format!("consider replacing `{}` with `'static`", fr_name)); + } else { + diag.help(&format!( + "consider adding the following bound: `{}: {}`", + fr_name, outlived_fr_name + )); + } + } + } + + /// If there is a suggestion to emit, add a diagnostic to the buffer. This is the final + /// suggestion including all collected constraints. + crate fn add_suggestion<'tcx>( + &self, + body: &Body<'tcx>, + region_infcx: &RegionInferenceContext<'tcx>, + infcx: &InferCtxt<'_, 'tcx>, + errors_buffer: &mut Vec, + renctx: &mut RegionErrorNamingCtx, + ) { + // No constraints to add? Done. + if self.constraints_to_add.is_empty() { + debug!("No constraints to suggest."); + return; + } + + // If there is only one constraint to suggest, then we already suggested it in the + // intermediate suggestion above. + if self.constraints_to_add.len() == 1 { + debug!("Only 1 suggestion. Skipping."); + return; + } + + // Get all suggestable constraints. + let suggested = self.compile_all_suggestions(body, region_infcx, infcx, renctx); + + // If there are no suggestable constraints... + if suggested.is_empty() { + debug!("Only 1 suggestable constraint. Skipping."); + return; + } + + // If there is exactly one suggestable constraints, then just suggest it. Otherwise, emit a + // list of diagnostics. + let mut diag = if suggested.len() == 1 { + DiagnosticBuilder::new( + infcx.tcx.sess.diagnostic(), + Level::Help, + &match suggested.last().unwrap() { + SuggestedConstraint::Outlives(a, bs) => { + let bs: SmallVec<[String; 2]> = + bs.iter().map(|r| format!("{}", r)).collect(); + format!("add bound `{}: {}`", a, bs.join(" + ")) + } + + SuggestedConstraint::Equal(a, b) => { + format!("`{}` and `{}` must be the same: replace one with the other", a, b) + } + SuggestedConstraint::Static(a) => format!("replace `{}` with `'static`", a), + }, + ) + } else { + // Create a new diagnostic. + let mut diag = DiagnosticBuilder::new( + infcx.tcx.sess.diagnostic(), + Level::Help, + "the following changes may resolve your lifetime errors", + ); + + // Add suggestions. + for constraint in suggested { + match constraint { + SuggestedConstraint::Outlives(a, bs) => { + let bs: SmallVec<[String; 2]> = + bs.iter().map(|r| format!("{}", r)).collect(); + diag.help(&format!("add bound `{}: {}`", a, bs.join(" + "))); + } + SuggestedConstraint::Equal(a, b) => { + diag.help(&format!( + "`{}` and `{}` must be the same: replace one with the other", + a, b + )); + } + SuggestedConstraint::Static(a) => { + diag.help(&format!("replace `{}` with `'static`", a)); + } + } + } + + diag + }; + + // We want this message to appear after other messages on the mir def. + let mir_span = infcx.tcx.def_span(self.mir_def_id); + diag.sort_span = mir_span.shrink_to_hi(); + + // Buffer the diagnostic + diag.buffer(errors_buffer); + } +} diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index dbb810db555b4..4de8200e6a0c7 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -11,6 +11,7 @@ use crate::borrow_check::nll::{ region_infer::values::{ PlaceholderIndices, RegionElement, ToElementIndex }, + region_infer::error_reporting::outlives_suggestion::OutlivesSuggestionBuilder, type_check::{free_region_relations::UniversalRegionRelations, Locations}, }; use crate::borrow_check::Upvar; @@ -1326,6 +1327,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { errors_buffer: &mut Vec, region_naming: &mut RegionErrorNamingCtx, ) { + let mut outlives_suggestion = OutlivesSuggestionBuilder::new(mir_def_id); + for (fr, fr_definition) in self.definitions.iter_enumerated() { match fr_definition.origin { NLLRegionVariableOrigin::FreeRegion => { @@ -1339,6 +1342,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { mir_def_id, fr, &mut propagated_outlives_requirements, + &mut outlives_suggestion, errors_buffer, region_naming, ); @@ -1353,6 +1357,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { } } } + + // Emit outlives suggestions + outlives_suggestion.add_suggestion(body, self, infcx, errors_buffer, region_naming); } /// Checks the final value for the free region `fr` to see if it @@ -1371,6 +1378,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { mir_def_id: DefId, longer_fr: RegionVid, propagated_outlives_requirements: &mut Option<&mut Vec>>, + outlives_suggestion: &mut OutlivesSuggestionBuilder, errors_buffer: &mut Vec, region_naming: &mut RegionErrorNamingCtx, ) { @@ -1399,6 +1407,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { upvars, mir_def_id, propagated_outlives_requirements, + outlives_suggestion, errors_buffer, region_naming, ); @@ -1416,6 +1425,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { upvars, mir_def_id, propagated_outlives_requirements, + outlives_suggestion, errors_buffer, region_naming, ) { @@ -1438,6 +1448,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { upvars: &[Upvar], mir_def_id: DefId, propagated_outlives_requirements: &mut Option<&mut Vec>>, + outlives_suggestion: &mut OutlivesSuggestionBuilder, errors_buffer: &mut Vec, region_naming: &mut RegionErrorNamingCtx, ) -> Option { @@ -1497,6 +1508,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { longer_fr, NLLRegionVariableOrigin::FreeRegion, shorter_fr, + outlives_suggestion, region_naming, ); diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr index fa8384311ea57..61f20d1dc9ad0 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -43,5 +43,9 @@ LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index 601b3577e0eec..e34884e9f9a36 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -46,5 +46,9 @@ LL | | demand_y(x, y, x.get()) LL | | }); | |______^ `cell_a` escapes the function body here +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 5b5440e7a9641..40917135c59d3 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -46,5 +46,9 @@ LL | | demand_y(x, y, x.get()) LL | | }); | |______^ `cell_a` escapes the function body here +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr index a08cde2c9c635..f227e9eb413e5 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -43,5 +43,9 @@ LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { LL | demand_y(outlives1, outlives2, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr b/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr index d0a24a267fd4f..5e8d9fa7882f1 100644 --- a/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr +++ b/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr @@ -6,5 +6,9 @@ LL | fn foo<'a>(x: &'a u32) -> &'static u32 { LL | &*x | ^^^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr b/src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr index 6dc98a944086f..d3edbfdae88fd 100644 --- a/src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr +++ b/src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr @@ -8,5 +8,9 @@ LL | fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 { LL | &*x | ^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: aborting due to previous error diff --git a/src/test/ui/nll/issue-52113.stderr b/src/test/ui/nll/issue-52113.stderr index 590963ded78bc..109c7e9565911 100644 --- a/src/test/ui/nll/issue-52113.stderr +++ b/src/test/ui/nll/issue-52113.stderr @@ -9,5 +9,9 @@ LL | fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> i LL | x | ^ returning this value requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: aborting due to previous error diff --git a/src/test/ui/nll/issue-58299.stderr b/src/test/ui/nll/issue-58299.stderr index aba07542d026e..906a7bff00d4e 100644 --- a/src/test/ui/nll/issue-58299.stderr +++ b/src/test/ui/nll/issue-58299.stderr @@ -7,6 +7,10 @@ LL | fn foo<'a>(x: i32) { LL | A::<'a>::X..=A::<'static>::X => (), | ^^^^^^^^^^ requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/issue-58299.rs:24:27 | @@ -16,5 +20,9 @@ LL | fn bar<'a>(x: i32) { LL | A::<'static>::X..=A::<'a>::X => (), | ^^^^^^^^^^ requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/mir_check_cast_closure.stderr b/src/test/ui/nll/mir_check_cast_closure.stderr index e14cb074c81f8..40ce9e850ea43 100644 --- a/src/test/ui/nll/mir_check_cast_closure.stderr +++ b/src/test/ui/nll/mir_check_cast_closure.stderr @@ -9,5 +9,9 @@ LL | let g: fn(_, _) -> _ = |_x, y| y; LL | g | ^ returning this value requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + error: aborting due to previous error diff --git a/src/test/ui/nll/mir_check_cast_reify.stderr b/src/test/ui/nll/mir_check_cast_reify.stderr index 4e8eec330a579..f091161b22407 100644 --- a/src/test/ui/nll/mir_check_cast_reify.stderr +++ b/src/test/ui/nll/mir_check_cast_reify.stderr @@ -7,5 +7,9 @@ LL | fn bar<'a>(x: &'a u32) -> &'static u32 { LL | f(x) | ^^^^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to previous error diff --git a/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr b/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr index 52959850a3332..2f76758f259a5 100644 --- a/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr +++ b/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr @@ -7,5 +7,9 @@ LL | fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 { LL | unsafe { g(input) } | ^^^^^^^^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to previous error diff --git a/src/test/ui/nll/mir_check_cast_unsize.stderr b/src/test/ui/nll/mir_check_cast_unsize.stderr index 364d6c17ea7f6..4a76fa8158e5a 100644 --- a/src/test/ui/nll/mir_check_cast_unsize.stderr +++ b/src/test/ui/nll/mir_check_cast_unsize.stderr @@ -6,5 +6,9 @@ LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug { LL | x | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + 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 new file mode 100644 index 0000000000000..91a7a1d71e80c --- /dev/null +++ b/src/test/ui/nll/outlives-suggestion-simple.rs @@ -0,0 +1,77 @@ +// Test the simplest of outlives suggestions. + +#![feature(nll)] + +fn foo1<'a, 'b>(x: &'a usize) -> &'b usize { + x //~ERROR lifetime may not live long enough +} + +fn foo2<'a>(x: &'a usize) -> &'static usize { + x //~ERROR lifetime may not live long enough +} + +fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) { + (x, y) //~ERROR lifetime may not live long enough + //~^ERROR lifetime may not live long enough +} + +fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) { + // FIXME: ideally, we suggest 'a: 'b + 'c, but as of today (may 04, 2019), the null error + // reporting stops after the first error in a MIR def so as not to produce too many errors, so + // currently we only report 'a: 'b. The user would then re-run and get another error. + (x, x) //~ERROR lifetime may not live long enough +} + +struct Foo<'a> { + x: &'a usize, +} + +impl Foo<'static> { + pub fn foo<'a>(x: &'a usize) -> Self { + Foo { x } //~ERROR lifetime may not live long enough + } +} + +struct Bar<'a> { + x: &'a usize, +} + +impl<'a> Bar<'a> { + pub fn get<'b>(&self) -> &'b usize { + self.x //~ERROR lifetime may not live long enough + } +} + +// source: https://stackoverflow.com/questions/41417057/why-do-i-get-a-lifetime-error-when-i-use-a-mutable-reference-in-a-struct-instead +struct Baz<'a> { + x: &'a mut i32, +} + +impl<'a> Baz<'a> { + fn get<'b>(&'b self) -> &'a i32 { + self.x //~ERROR lifetime may not live long enough + } +} + +// source: https://stackoverflow.com/questions/41204134/rust-lifetime-error +struct Bar2<'a> { + bar: &'a str, +} +impl<'a> Bar2<'a> { + fn new(foo: &'a Foo2<'a>) -> Bar2<'a> { + Bar2 { bar: foo.raw } + } +} + +pub struct Foo2<'a> { + raw: &'a str, + cell: std::cell::Cell<&'a str>, +} +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 + } +} + +fn main() {} diff --git a/src/test/ui/nll/outlives-suggestion-simple.stderr b/src/test/ui/nll/outlives-suggestion-simple.stderr new file mode 100644 index 0000000000000..90c6bf2f5b8d9 --- /dev/null +++ b/src/test/ui/nll/outlives-suggestion-simple.stderr @@ -0,0 +1,118 @@ +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-simple.rs:6:5 + | +LL | fn foo1<'a, 'b>(x: &'a usize) -> &'b usize { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | x + | ^ returning this value requires that `'a` must outlive `'b` + +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-simple.rs:10:5 + | +LL | fn foo2<'a>(x: &'a usize) -> &'static usize { + | -- lifetime `'a` defined here +LL | x + | ^ returning this value requires that `'a` must outlive `'static` + +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-simple.rs:14:5 + | +LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | (x, y) + | ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-simple.rs:14:5 + | +LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | (x, y) + | ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + +help: the following changes may resolve your lifetime errors + | + = help: `'a` and `'b` must be the same; replace one with the other + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-simple.rs:22:5 + | +LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | (x, x) + | ^^^^^^ returning this value requires that `'a` must outlive `'b` + +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-simple.rs:31:9 + | +LL | pub fn foo<'a>(x: &'a usize) -> Self { + | -- lifetime `'a` defined here +LL | Foo { x } + | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-simple.rs:41:9 + | +LL | impl<'a> Bar<'a> { + | -- lifetime `'a` defined here +LL | pub fn get<'b>(&self) -> &'b usize { + | -- lifetime `'b` defined here +LL | self.x + | ^^^^^^ returning this value requires that `'a` must outlive `'b` + +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-simple.rs:52:9 + | +LL | impl<'a> Baz<'a> { + | -- lifetime `'a` defined here +LL | fn get<'b>(&'b self) -> &'a i32 { + | -- lifetime `'b` defined here +LL | self.x + | ^^^^^^ returning this value requires that `'b` must outlive `'a` + +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + +error[E0521]: borrowed data escapes outside of function + --> $DIR/outlives-suggestion-simple.rs:73:9 + | +LL | fn get_bar(&self) -> Bar2 { + | ----- + | | + | `self` is declared here, outside of the function body + | `self` is a reference that is only valid in the function body +LL | Bar2::new(&self) + | ^^^^^^^^^^^^^^^^ `self` escapes the function body here + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index 10b2bd1af4702..be45c23ed8318 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -51,6 +51,10 @@ LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + note: External requirements --> $DIR/projection-one-region-closure.rs:56:29 | @@ -105,6 +109,10 @@ LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + note: External requirements --> $DIR/projection-one-region-closure.rs:70:29 | diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index b4b74bfc1284f..39f9e78f88964 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -42,6 +42,10 @@ LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + note: External requirements --> $DIR/projection-one-region-trait-bound-closure.rs:47:29 | @@ -87,6 +91,10 @@ LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + note: External requirements --> $DIR/projection-one-region-trait-bound-closure.rs:60:29 | diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index a48766cd7340b..15e921bdec16c 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -237,6 +237,10 @@ LL | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + note: External requirements --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | diff --git a/src/test/ui/nll/ty-outlives/wf-unreachable.stderr b/src/test/ui/nll/ty-outlives/wf-unreachable.stderr index 9128fd1647959..e4fa647e6cb1a 100644 --- a/src/test/ui/nll/ty-outlives/wf-unreachable.stderr +++ b/src/test/ui/nll/ty-outlives/wf-unreachable.stderr @@ -7,6 +7,10 @@ LL | return; LL | let x: &'static &'a (); | ^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:13:12 | @@ -16,6 +20,10 @@ LL | return; LL | let x: &'static &'a () = &&(); | ^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:17:12 | @@ -24,6 +32,10 @@ LL | fn uninit_infer<'a>() { LL | let x: &'static &'a _; | ^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:23:12 | @@ -33,6 +45,10 @@ LL | return; LL | let x: &'static &'a _ = &&(); | ^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:28:12 | @@ -42,6 +58,10 @@ LL | return; LL | let _: &'static &'a (); | ^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:33:12 | @@ -51,6 +71,10 @@ LL | return; LL | let _: &'static &'a () = &&(); | ^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:38:12 | @@ -60,6 +84,10 @@ LL | return; LL | let _: &'static &'a _ = &&(); | ^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:51:12 | @@ -69,5 +97,9 @@ LL | return; LL | let _: C<'static, 'a, _> = C((), &(), &()); | ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to 8 previous errors diff --git a/src/test/ui/nll/type-check-pointer-coercions.stderr b/src/test/ui/nll/type-check-pointer-coercions.stderr index 9aa78dfbd4acd..9c7601c3a6026 100644 --- a/src/test/ui/nll/type-check-pointer-coercions.stderr +++ b/src/test/ui/nll/type-check-pointer-coercions.stderr @@ -8,6 +8,10 @@ LL | fn shared_to_const<'a, 'b>(x: &&'a i32) -> *const &'b i32 { LL | x | ^ returning this value requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:8:5 | @@ -18,6 +22,10 @@ LL | fn unique_to_const<'a, 'b>(x: &mut &'a i32) -> *const &'b i32 { LL | x | ^ returning this value requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:13:5 | @@ -40,6 +48,10 @@ LL | // Two errors because *mut is invariant LL | x | ^ returning this value requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: `'b` and `'a` must be the same; replace one with the other + error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:18:5 | @@ -50,6 +62,10 @@ LL | fn mut_to_const<'a, 'b>(x: *mut &'a i32) -> *const &'b i32 { LL | x | ^ returning this value requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:24:5 | @@ -61,6 +77,10 @@ LL | fn array_elem<'a, 'b>(x: &'a i32) -> *const &'b i32 { LL | y | ^ returning this value requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:30:5 | @@ -72,6 +92,10 @@ LL | fn array_coerce<'a, 'b>(x: &'a i32) -> *const [&'b i32; 3] { LL | y | ^ returning this value requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:36:5 | @@ -83,5 +107,9 @@ LL | fn nested_array<'a, 'b>(x: &'a i32) -> *const [&'b i32; 2] { LL | y | ^ returning this value requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: aborting due to 8 previous errors diff --git a/src/test/ui/nll/type-check-pointer-comparisons.stderr b/src/test/ui/nll/type-check-pointer-comparisons.stderr index c0a994cfb6381..5293f48116e8f 100644 --- a/src/test/ui/nll/type-check-pointer-comparisons.stderr +++ b/src/test/ui/nll/type-check-pointer-comparisons.stderr @@ -18,6 +18,10 @@ LL | fn compare_const<'a, 'b>(x: *const &mut &'a i32, y: *const &mut &'b i32) { LL | x == y; | ^ requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: `'b` and `'a` must be the same; replace one with the other + error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:12:5 | @@ -38,6 +42,10 @@ LL | fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) { LL | x == y; | ^ requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: `'a` and `'b` must be the same; replace one with the other + error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:18:5 | @@ -58,5 +66,9 @@ LL | fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32 LL | f == g; | ^ requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: `'a` and `'b` must be the same; replace one with the other + error: aborting due to 6 previous errors diff --git a/src/test/ui/nll/user-annotations/closure-substs.stderr b/src/test/ui/nll/user-annotations/closure-substs.stderr index 384d53f0e4b0a..ff0cda9114a1a 100644 --- a/src/test/ui/nll/user-annotations/closure-substs.stderr +++ b/src/test/ui/nll/user-annotations/closure-substs.stderr @@ -7,6 +7,10 @@ LL | fn foo<'a>() { LL | return x; | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/closure-substs.rs:15:16 | @@ -24,6 +28,10 @@ LL | fn bar<'a>() { LL | b(x); | ^^^^ argument requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error[E0521]: borrowed data escapes outside of closure --> $DIR/closure-substs.rs:29:9 | diff --git a/src/test/ui/nll/user-annotations/inherent-associated-constants.stderr b/src/test/ui/nll/user-annotations/inherent-associated-constants.stderr index 768454698987e..48d56fc1c02fe 100644 --- a/src/test/ui/nll/user-annotations/inherent-associated-constants.stderr +++ b/src/test/ui/nll/user-annotations/inherent-associated-constants.stderr @@ -6,5 +6,9 @@ LL | fn non_wf_associated_const<'a>(x: i32) { LL | A::<'a>::IC; | ^^^^^^^^^^^ requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/issue-54124.stderr b/src/test/ui/nll/user-annotations/issue-54124.stderr index 6cfccf7cb69ce..64df1264d27ea 100644 --- a/src/test/ui/nll/user-annotations/issue-54124.stderr +++ b/src/test/ui/nll/user-annotations/issue-54124.stderr @@ -16,5 +16,9 @@ LL | fn test<'a>() { LL | let _:fn(&()) = |_:&'a ()| {}; | ^ requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr b/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr index 5929707e41e10..a629cc267635d 100644 --- a/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr +++ b/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr @@ -7,6 +7,10 @@ LL | fn coupled_regions_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/issue-55748-pat-types-constrain-bindings.rs:49:5 | @@ -16,6 +20,10 @@ LL | fn coupled_types_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/issue-55748-pat-types-constrain-bindings.rs:62:5 | @@ -25,5 +33,9 @@ LL | fn coupled_wilds_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to 3 previous errors diff --git a/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr b/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr index c99f53c5aa4c5..937db3775738d 100644 --- a/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr +++ b/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr @@ -7,6 +7,10 @@ LL | let ((y, _z),) = ((s, _x),): (PairCoupledTypes<_>,); LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/issue-57731-ascibed-coupled-types.rs:22:5 | @@ -16,6 +20,10 @@ LL | let ((y, _z),) = ((s, _x),): (PairCoupledRegions<_>,); LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/issue-57731-ascibed-coupled-types.rs:32:5 | @@ -25,6 +33,10 @@ LL | let ((y, _z),) = ((s, _x),) as (PairCoupledTypes<_>,); LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/issue-57731-ascibed-coupled-types.rs:37:5 | @@ -34,5 +46,9 @@ LL | let ((y, _z),) = ((s, _x),) as (PairCoupledRegions<_>,); LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to 4 previous errors diff --git a/src/test/ui/nll/user-annotations/patterns.stderr b/src/test/ui/nll/user-annotations/patterns.stderr index 7ebd0ae227a80..981e59c08c520 100644 --- a/src/test/ui/nll/user-annotations/patterns.stderr +++ b/src/test/ui/nll/user-annotations/patterns.stderr @@ -157,6 +157,10 @@ LL | fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 { LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/patterns.rs:125:5 | @@ -166,6 +170,10 @@ LL | fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 { LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/patterns.rs:130:5 | @@ -175,6 +183,10 @@ LL | let Single { value: y }: Single<&'a u32> = Single { value: &22 }; LL | y | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: lifetime may not live long enough --> $DIR/patterns.rs:134:18 | @@ -183,6 +195,10 @@ LL | fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 { LL | let (y, _z): (&'static u32, u32) = (x, 44); | ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error: aborting due to 19 previous errors Some errors have detailed explanations: E0597, E0716. diff --git a/src/test/ui/nll/user-annotations/wf-self-type.stderr b/src/test/ui/nll/user-annotations/wf-self-type.stderr index 8f8e1bc28f6fa..c3b32865b0147 100644 --- a/src/test/ui/nll/user-annotations/wf-self-type.stderr +++ b/src/test/ui/nll/user-annotations/wf-self-type.stderr @@ -8,5 +8,9 @@ LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { LL | Foo::xmute(u) | ^^^^^^^^^^^^^ returning this value requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + error: aborting due to previous error diff --git a/src/test/ui/nll/where_clauses_in_functions.stderr b/src/test/ui/nll/where_clauses_in_functions.stderr index f3b65ec31ac7d..c01101cf1f6d0 100644 --- a/src/test/ui/nll/where_clauses_in_functions.stderr +++ b/src/test/ui/nll/where_clauses_in_functions.stderr @@ -8,5 +8,9 @@ LL | fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { LL | foo(x, y) | ^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: aborting due to previous error diff --git a/src/test/ui/nll/where_clauses_in_structs.stderr b/src/test/ui/nll/where_clauses_in_structs.stderr index e0feb40273f6b..aa15aa4ddcae2 100644 --- a/src/test/ui/nll/where_clauses_in_structs.stderr +++ b/src/test/ui/nll/where_clauses_in_structs.stderr @@ -8,5 +8,9 @@ LL | fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) { LL | Foo { x, y }; | ^ requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: aborting due to previous error diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr index 4944f2649b738..79ea4caa34333 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr @@ -9,5 +9,9 @@ LL | fn with_assoc<'a,'b>() { LL | let _: &'a WithAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + error: aborting due to previous error diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr index 16eda2844c64c..594ea755e3d43 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr @@ -8,6 +8,10 @@ LL | fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { LL | let z: Option<&'b &'a usize> = None; | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: lifetime may not live long enough --> $DIR/regions-free-region-ordering-caller.rs:17:12 | @@ -19,6 +23,10 @@ LL | let y: Paramd<'a> = Paramd { x: a }; LL | let z: Option<&'b Paramd<'a>> = None; | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'b` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'b` + error: lifetime may not live long enough --> $DIR/regions-free-region-ordering-caller.rs:22:12 | @@ -29,5 +37,9 @@ LL | fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { LL | let z: Option<&'a &'b usize> = None; | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr index eed9934be121d..fb836d32a2bff 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr @@ -9,6 +9,10 @@ LL | fn with_assoc<'a,'b>() { LL | let _: &'a WithHrAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + error: lifetime may not live long enough --> $DIR/regions-outlives-projection-container-hrtb.rs:50:12 | @@ -20,5 +24,9 @@ LL | fn with_assoc_sub<'a,'b>() { LL | let _: &'a WithHrAssocSub> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr index 8c54d8da0a063..3f5088c12d64a 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr @@ -9,5 +9,9 @@ LL | fn with_assoc<'a,'b>() { LL | let _: &'a WithAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` +help: the following changes may resolve your lifetime errors + | + = help: add bound `'b: 'a` + error: aborting due to previous error diff --git a/src/test/ui/regions/regions-static-bound.nll.stderr b/src/test/ui/regions/regions-static-bound.nll.stderr index b5f3e6cfaba09..281683ac1da2b 100644 --- a/src/test/ui/regions/regions-static-bound.nll.stderr +++ b/src/test/ui/regions/regions-static-bound.nll.stderr @@ -6,6 +6,10 @@ LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { LL | t | ^ returning this value requires that `'a` must outlive `'static` +help: the following changes may resolve your lifetime errors + | + = help: replace `'a` with `'static` + error[E0621]: explicit lifetime required in the type of `u` --> $DIR/regions-static-bound.rs:14:5 | From 89a184a39921f10782f986c9e5bcd8b92ef60818 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Tue, 17 Sep 2019 11:57:16 -0500 Subject: [PATCH 2/5] add test for complex suggestions --- src/test/ui/nll/outlives-suggestion-more.rs | 28 +++++ .../ui/nll/outlives-suggestion-more.stderr | 100 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 src/test/ui/nll/outlives-suggestion-more.rs create mode 100644 src/test/ui/nll/outlives-suggestion-more.stderr diff --git a/src/test/ui/nll/outlives-suggestion-more.rs b/src/test/ui/nll/outlives-suggestion-more.rs new file mode 100644 index 0000000000000..4d80b78ac6575 --- /dev/null +++ b/src/test/ui/nll/outlives-suggestion-more.rs @@ -0,0 +1,28 @@ +// Test the more elaborate outlives suggestions. + +#![feature(nll)] + +// Should suggest: 'a: 'c, 'b: 'd +fn foo1<'a, 'b, 'c, 'd>(x: &'a usize, y: &'b usize) -> (&'c usize, &'d usize) { + (x, y) //~ERROR lifetime may not live long enough + //~^ERROR lifetime may not live long enough +} + +// Should suggest: 'a: 'c and use 'static instead of 'b +fn foo2<'a, 'b, 'c>(x: &'a usize, y: &'b usize) -> (&'c usize, &'static usize) { + (x, y) //~ERROR lifetime may not live long enough + //~^ERROR lifetime may not live long enough +} + +// Should suggest: 'a and 'b are the same and use 'static instead of 'c +fn foo3<'a, 'b, 'c, 'd, 'e>( + x: &'a usize, + y: &'b usize, + z: &'c usize, +) -> (&'b usize, &'a usize, &'static usize) { + (x, y, z) //~ERROR lifetime may not live long enough + //~^ERROR lifetime may not live long enough + //~^^ERROR lifetime may not live long enough +} + +fn main() {} diff --git a/src/test/ui/nll/outlives-suggestion-more.stderr b/src/test/ui/nll/outlives-suggestion-more.stderr new file mode 100644 index 0000000000000..2ebcbf5cbafda --- /dev/null +++ b/src/test/ui/nll/outlives-suggestion-more.stderr @@ -0,0 +1,100 @@ +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-more.rs:7:5 + | +LL | fn foo1<'a, 'b, 'c, 'd>(x: &'a usize, y: &'b usize) -> (&'c usize, &'d usize) { + | -- -- lifetime `'c` defined here + | | + | lifetime `'a` defined here +LL | (x, y) + | ^^^^^^ returning this value requires that `'a` must outlive `'c` + | + = help: consider adding the following bound: `'a: 'c` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-more.rs:7:5 + | +LL | fn foo1<'a, 'b, 'c, 'd>(x: &'a usize, y: &'b usize) -> (&'c usize, &'d usize) { + | -- -- lifetime `'d` defined here + | | + | lifetime `'b` defined here +LL | (x, y) + | ^^^^^^ returning this value requires that `'b` must outlive `'d` + | + = help: consider adding the following bound: `'b: 'd` + +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'c` + = help: add bound `'b: 'd` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-more.rs:13:5 + | +LL | fn foo2<'a, 'b, 'c>(x: &'a usize, y: &'b usize) -> (&'c usize, &'static usize) { + | -- -- lifetime `'c` defined here + | | + | lifetime `'a` defined here +LL | (x, y) + | ^^^^^^ returning this value requires that `'a` must outlive `'c` + | + = help: consider adding the following bound: `'a: 'c` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-more.rs:13:5 + | +LL | fn foo2<'a, 'b, 'c>(x: &'a usize, y: &'b usize) -> (&'c usize, &'static usize) { + | -- lifetime `'b` defined here +LL | (x, y) + | ^^^^^^ returning this value requires that `'b` must outlive `'static` + | + = help: consider replacing `'b` with `'static` + +help: the following changes may resolve your lifetime errors + | + = help: add bound `'a: 'c` + = help: replace `'b` with `'static` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-more.rs:23:5 + | +LL | fn foo3<'a, 'b, 'c, 'd, 'e>( + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | (x, y, z) + | ^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-more.rs:23:5 + | +LL | fn foo3<'a, 'b, 'c, 'd, 'e>( + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | (x, y, z) + | ^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + +error: lifetime may not live long enough + --> $DIR/outlives-suggestion-more.rs:23:5 + | +LL | fn foo3<'a, 'b, 'c, 'd, 'e>( + | -- lifetime `'c` defined here +... +LL | (x, y, z) + | ^^^^^^^^^ returning this value requires that `'c` must outlive `'static` + | + = help: consider replacing `'c` with `'static` + +help: the following changes may resolve your lifetime errors + | + = help: `'a` and `'b` must be the same: replace one with the other + = help: replace `'c` with `'static` + +error: aborting due to 7 previous errors + From 19122ab98190053ad19e8baf153870c56c266f29 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 3 Oct 2019 18:14:25 -0500 Subject: [PATCH 3/5] add and use struct_help --- src/librustc_errors/lib.rs | 5 +++ .../error_reporting/outlives_suggestion.rs | 37 ++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 63df052a22504..705c802d90acb 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -619,6 +619,11 @@ impl Handler { DiagnosticBuilder::new(self, Level::Fatal, msg) } + /// Construct a builder at the `Help` level with the `msg`. + pub fn struct_help(&self, msg: &str) -> DiagnosticBuilder<'_> { + DiagnosticBuilder::new(self, Level::Help, msg) + } + pub fn span_fatal(&self, span: impl Into, msg: &str) -> FatalError { self.emit_diag_at_span(Diagnostic::new(Fatal, msg), span); FatalError diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs index a55a3a406044b..57f844f292437 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs @@ -6,7 +6,7 @@ use std::collections::BTreeMap; use log::debug; use rustc::{hir::def_id::DefId, infer::InferCtxt, mir::Body, ty::RegionVid}; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{Diagnostic, DiagnosticBuilder, Level}; +use rustc_errors::{Diagnostic, DiagnosticBuilder}; use smallvec::SmallVec; @@ -258,29 +258,24 @@ impl OutlivesSuggestionBuilder { // If there is exactly one suggestable constraints, then just suggest it. Otherwise, emit a // list of diagnostics. let mut diag = if suggested.len() == 1 { - DiagnosticBuilder::new( - infcx.tcx.sess.diagnostic(), - Level::Help, - &match suggested.last().unwrap() { - SuggestedConstraint::Outlives(a, bs) => { - let bs: SmallVec<[String; 2]> = - bs.iter().map(|r| format!("{}", r)).collect(); - format!("add bound `{}: {}`", a, bs.join(" + ")) - } + infcx.tcx.sess.diagnostic().struct_help(&match suggested.last().unwrap() { + SuggestedConstraint::Outlives(a, bs) => { + let bs: SmallVec<[String; 2]> = bs.iter().map(|r| format!("{}", r)).collect(); + format!("add bound `{}: {}`", a, bs.join(" + ")) + } - SuggestedConstraint::Equal(a, b) => { - format!("`{}` and `{}` must be the same: replace one with the other", a, b) - } - SuggestedConstraint::Static(a) => format!("replace `{}` with `'static`", a), - }, - ) + SuggestedConstraint::Equal(a, b) => { + format!("`{}` and `{}` must be the same: replace one with the other", a, b) + } + SuggestedConstraint::Static(a) => format!("replace `{}` with `'static`", a), + }) } else { // Create a new diagnostic. - let mut diag = DiagnosticBuilder::new( - infcx.tcx.sess.diagnostic(), - Level::Help, - "the following changes may resolve your lifetime errors", - ); + let mut diag = infcx + .tcx + .sess + .diagnostic() + .struct_help("the following changes may resolve your lifetime errors"); // Add suggestions. for constraint in suggested { From 0026e3ec3f7945aa99b5c1ba7c1bed1a5d6bacf3 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Wed, 9 Oct 2019 18:49:40 -0500 Subject: [PATCH 4/5] hack around '_ named regions --- .../error_reporting/outlives_suggestion.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs index 57f844f292437..62142efe505b2 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/outlives_suggestion.rs @@ -67,8 +67,15 @@ impl OutlivesSuggestionBuilder { RegionNameSource::NamedEarlyBoundRegion(..) | RegionNameSource::NamedFreeRegion(..) | RegionNameSource::Static => { - debug!("Region {:?} is suggestable", name); - true + // FIXME: This is a bit hacky. We should ideally have a semantic way for checking + // if the name is `'_`... + if name.name().with(|name| name != "'_") { + debug!("Region {:?} is suggestable", name); + true + } else { + debug!("Region {:?} is NOT suggestable", name); + false + } } // Don't give suggestions for upvars, closure return types, or other unnamable From cba0761e5f3677b90390fe7aee1eeda684296658 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Sun, 27 Oct 2019 09:39:14 -0500 Subject: [PATCH 5/5] update tests --- .../implied-region-constraints.nll.stderr | 4 +++ ...es-project-from-hrtb-in-fn-body.nll.stderr | 6 ++++ .../associated-types-subtyping-1.nll.stderr | 4 +++ ...fn-ret-contravariant.krisskross.nll.stderr | 6 ++++ ...-fn-ret-contravariant.transmute.nll.stderr | 2 ++ ...ect-fn-ret-invariant.krisskross.nll.stderr | 6 ++++ ...project-fn-ret-invariant.oneuse.nll.stderr | 6 ++++ ...ject-fn-ret-invariant.transmute.nll.stderr | 2 ++ .../ret-impl-trait-one.nll.stderr | 2 ++ ...orrow-from-shorter-lived-andmut.nll.stderr | 2 ++ .../expect-region-supply-region.nll.stderr | 2 ++ ...ubtype.free_inv_x_vs_free_inv_y.nll.stderr | 4 +++ .../hr-subtype.free_x_vs_free_y.nll.stderr | 2 ++ .../hrtb/hrtb-perfect-forwarding.nll.stderr | 2 ++ .../dyn-trait.nll.stderr | 2 ++ .../multiple-lifetimes/error-handling.stderr | 1 + ...t_outlive_least_region_or_bound.nll.stderr | 4 +++ .../static-return-lifetime-infered.nll.stderr | 1 + .../in-band-lifetimes/mismatched.nll.stderr | 2 ++ src/test/ui/issues/issue-10291.nll.stderr | 2 ++ src/test/ui/issues/issue-26217.nll.stderr | 2 ++ src/test/ui/issues/issue-28848.nll.stderr | 2 ++ src/test/ui/issues/issue-52213.nll.stderr | 2 ++ src/test/ui/issues/issue-54943.nll.stderr | 2 ++ src/test/ui/issues/issue-55796.nll.stderr | 4 +++ ...etime-bound-will-change-warning.nll.stderr | 4 +++ .../ex2c-push-inference-variable.nll.stderr | 2 ++ .../ex2d-push-inference-variable-2.nll.stderr | 2 ++ .../ex2e-push-inference-variable-3.nll.stderr | 2 ++ ...-are-structs-earlybound-regions.nll.stderr | 2 ++ ...h-are-structs-latebound-regions.nll.stderr | 2 ++ ...-anon-regions-latebound-regions.nll.stderr | 2 ++ src/test/ui/lub-if.nll.stderr | 4 +++ src/test/ui/lub-match.nll.stderr | 4 +++ .../match/match-ref-mut-invariance.nll.stderr | 2 ++ .../match-ref-mut-let-invariance.nll.stderr | 2 ++ .../propagate-approximated-ref.stderr | 4 +-- ...oximated-shorter-to-static-no-bound.stderr | 4 +-- ...mated-shorter-to-static-wrong-bound.stderr | 4 +-- .../propagate-approximated-val.stderr | 4 +-- ...n-lbr-named-does-not-outlive-static.stderr | 4 +-- .../region-lbr1-does-not-outlive-ebr2.stderr | 4 +-- src/test/ui/nll/issue-50716.nll.stderr | 2 ++ src/test/ui/nll/issue-52113.stderr | 4 +-- src/test/ui/nll/issue-55401.nll.stderr | 2 ++ src/test/ui/nll/issue-58299.stderr | 8 ++--- src/test/ui/nll/mir_check_cast_closure.stderr | 4 +-- src/test/ui/nll/mir_check_cast_reify.stderr | 4 +-- .../ui/nll/mir_check_cast_unsafe_fn.stderr | 4 +-- src/test/ui/nll/mir_check_cast_unsize.stderr | 4 +-- .../ui/nll/outlives-suggestion-simple.stderr | 32 +++++++------------ .../projection-one-region-closure.stderr | 8 ++--- ...tion-one-region-trait-bound-closure.stderr | 8 ++--- ...tion-two-region-trait-bound-closure.stderr | 4 +-- .../ui/nll/ty-outlives/wf-unreachable.stderr | 32 +++++-------------- .../nll/type-check-pointer-coercions.stderr | 32 +++++++------------ .../nll/type-check-pointer-comparisons.stderr | 24 ++++++++------ .../user-annotations/closure-substs.stderr | 8 ++--- .../constant-in-expr-inherent-1.nll.stderr | 2 ++ .../constant-in-expr-normalize.nll.stderr | 2 ++ .../constant-in-expr-trait-item-1.nll.stderr | 2 ++ .../constant-in-expr-trait-item-2.nll.stderr | 2 ++ .../constant-in-expr-trait-item-3.nll.stderr | 2 ++ .../inherent-associated-constants.stderr | 4 +-- .../nll/user-annotations/issue-54124.stderr | 4 +-- ...-55748-pat-types-constrain-bindings.stderr | 12 ++----- .../issue-57731-ascibed-coupled-types.stderr | 16 +++------- .../ui/nll/user-annotations/patterns.stderr | 16 +++------- .../nll/user-annotations/wf-self-type.stderr | 4 +-- .../ui/nll/where_clauses_in_functions.stderr | 4 +-- .../ui/nll/where_clauses_in_structs.stderr | 4 +-- ...object-lifetime-default-elision.nll.stderr | 2 ++ ...ime-default-from-rptr-box-error.nll.stderr | 2 ++ ...-default-from-rptr-struct-error.nll.stderr | 2 ++ .../object-lifetime-default-mybox.nll.stderr | 4 +++ ...nvariant-static-error-reporting.nll.stderr | 2 ++ .../region-object-lifetime-2.nll.stderr | 2 ++ .../region-object-lifetime-4.nll.stderr | 2 ++ ...ion-object-lifetime-in-coercion.nll.stderr | 2 ++ ...rait-outlives-container.migrate.nll.stderr | 2 ++ ...n-supertrait-outlives-container.nll.stderr | 4 +-- ...unded-by-trait-requiring-static.nll.stderr | 12 +++++++ ...hod-type-parameters-cross-crate.nll.stderr | 2 ++ ...hod-type-parameters-trait-bound.nll.stderr | 2 ++ ...-bounded-method-type-parameters.nll.stderr | 2 ++ src/test/ui/regions/regions-bounds.nll.stderr | 4 +++ ...ions-close-object-into-object-2.nll.stderr | 2 ++ ...ions-close-object-into-object-4.nll.stderr | 2 ++ ...se-over-type-parameter-multiple.nll.stderr | 2 ++ .../regions-creating-enums3.nll.stderr | 2 ++ .../regions-creating-enums4.nll.stderr | 2 ++ ...egions-early-bound-error-method.nll.stderr | 2 ++ .../regions-early-bound-error.nll.stderr | 2 ++ ...ons-free-region-ordering-callee.nll.stderr | 4 +++ ...-region-ordering-caller.migrate.nll.stderr | 6 ++++ ...ons-free-region-ordering-caller.nll.stderr | 12 ++----- ...-free-region-ordering-incorrect.nll.stderr | 2 ++ ...nfer-contravariance-due-to-decl.nll.stderr | 2 ++ ...ns-infer-covariance-due-to-decl.nll.stderr | 2 ++ ...ns-infer-invariance-due-to-decl.nll.stderr | 2 ++ ...-invariance-due-to-mutability-3.nll.stderr | 2 ++ ...-invariance-due-to-mutability-4.nll.stderr | 2 ++ .../regions-infer-not-param.nll.stderr | 8 +++++ .../ui/regions/regions-nested-fns.nll.stderr | 2 ++ ...ojection-container-hrtb.migrate.nll.stderr | 4 +++ ...lives-projection-container-hrtb.nll.stderr | 8 ++--- ...projection-container-wc.migrate.nll.stderr | 2 ++ ...utlives-projection-container-wc.nll.stderr | 4 +-- ...s-outlives-projection-container.nll.stderr | 8 +++++ ...ow-from-shorter-mut-ref-mut-ref.nll.stderr | 2 ++ ...s-reborrow-from-shorter-mut-ref.nll.stderr | 2 ++ .../regions-static-bound.migrate.nll.stderr | 2 ++ .../regions/regions-static-bound.nll.stderr | 4 +-- .../regions-trait-object-subtyping.nll.stderr | 4 +++ ...se-covariant-in-second-position.nll.stderr | 2 ++ ...nce-contravariant-use-covariant.nll.stderr | 2 ++ ...nce-covariant-use-contravariant.nll.stderr | 2 ++ ...nce-invariant-use-contravariant.nll.stderr | 2 ++ ...ariance-invariant-use-covariant.nll.stderr | 2 ++ .../variance-btree-invariant-types.nll.stderr | 24 ++++++++++++++ .../variance-cell-is-invariant.nll.stderr | 2 ++ ...riance-contravariant-arg-object.nll.stderr | 4 +++ ...e-contravariant-arg-trait-match.nll.stderr | 4 +++ ...-contravariant-self-trait-match.nll.stderr | 4 +++ .../variance-covariant-arg-object.nll.stderr | 4 +++ ...iance-covariant-arg-trait-match.nll.stderr | 4 +++ ...ance-covariant-self-trait-match.nll.stderr | 4 +++ .../variance-invariant-arg-object.nll.stderr | 4 +++ ...iance-invariant-arg-trait-match.nll.stderr | 4 +++ ...ance-invariant-self-trait-match.nll.stderr | 4 +++ ...ance-use-contravariant-struct-1.nll.stderr | 2 ++ ...variance-use-covariant-struct-1.nll.stderr | 2 ++ ...variance-use-invariant-struct-1.nll.stderr | 4 +++ src/test/ui/wf/wf-static-method.nll.stderr | 12 +++++++ 134 files changed, 409 insertions(+), 207 deletions(-) diff --git a/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr b/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr index 32d099fce759e..b8c54b13d8b4d 100644 --- a/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr +++ b/src/test/ui/associated-type-bounds/implied-region-constraints.nll.stderr @@ -8,6 +8,8 @@ LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>) ... LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0; | ^^^^^ type annotation requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/implied-region-constraints.rs:40:64 @@ -19,6 +21,8 @@ LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>) ... LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x; | ^^^^^ type annotation requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr index ca99304f9b4a0..e12d42e5ed0cc 100644 --- a/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr +++ b/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr @@ -8,6 +8,8 @@ LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( ... LL | let z: I::A = if cond { x } else { y }; | ^ assignment requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40 @@ -19,6 +21,10 @@ LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( ... LL | let z: I::A = if cond { x } else { y }; | ^ assignment requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` + +help: `'a` and `'b` must be the same: replace one with the other error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr b/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr index d8506b9c8c81c..11d3cfe5b4669 100644 --- a/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr +++ b/src/test/ui/associated-types/associated-types-subtyping-1.nll.stderr @@ -8,6 +8,8 @@ LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T) ... LL | let a: >::Type = make_any(); | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/associated-types-subtyping-1.rs:35:13 @@ -19,6 +21,8 @@ LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T) ... LL | let _c: >::Type = b; | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr index 779e6dac92e25..a5b6d64039147 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr @@ -8,6 +8,8 @@ LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { ... LL | (a, b) | ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/project-fn-ret-contravariant.rs:45:4 @@ -19,6 +21,10 @@ LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { ... LL | (a, b) | ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + +help: `'a` and `'b` must be the same: replace one with the other error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr index f532c96ed2cc7..558f394ef8644 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr @@ -5,6 +5,8 @@ LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here LL | bar(foo, x) | ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr index c45082fb0538f..71a533a36f418 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr @@ -8,6 +8,8 @@ LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { ... LL | (a, b) | ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/project-fn-ret-invariant.rs:55:4 @@ -19,6 +21,10 @@ LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { ... LL | (a, b) | ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + +help: `'a` and `'b` must be the same: replace one with the other error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr index 2c11e7ffe930d..c39030fbed1e1 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr @@ -8,6 +8,8 @@ LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { LL | let f = foo; // <-- No consistent type can be inferred for `f` here. LL | let a = bar(f, x); | ^^^^^^^^^ argument requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/project-fn-ret-invariant.rs:39:12 @@ -19,6 +21,10 @@ LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { ... LL | let b = bar(f, y); | ^^^^^^^^^ argument requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` + +help: `'a` and `'b` must be the same: replace one with the other error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr index 8be0ad6e88f3a..f74d4ba73bf4e 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr @@ -6,6 +6,8 @@ LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> { ... LL | bar(foo, x) | ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr index b4d5d3ec051e2..53b0dd691b891 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr @@ -10,6 +10,8 @@ LL | | LL | | (a, b) LL | | } | |_^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr index e6d0f88e3ea8b..f28c42ce2d58f 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr @@ -7,6 +7,8 @@ LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { | lifetime `'a` defined here LL | S { pointer: &mut *p.pointer } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr index bbf75302d564a..f816f27a89236 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr @@ -37,6 +37,8 @@ LL | fn expect_bound_supply_named<'x>() { ... LL | closure_expecting_bound(|x: &'x u32| { | ^ requires that `'x` must outlive `'static` + | + = help: consider replacing `'x` with `'static` error: aborting due to 4 previous errors diff --git a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr index 070fe12a2849f..9b0c987c0545d 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr @@ -11,6 +11,8 @@ LL | gimme::<$t2>(None::<$t1>); LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), LL | | fn(Inv<'y>)) } | |__________________________________________________- in this macro invocation + | + = help: consider adding the following bound: `'x: 'y` error: lifetime may not live long enough --> $DIR/hr-subtype.rs:39:13 @@ -25,6 +27,8 @@ LL | gimme::<$t1>(None::<$t2>); LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), LL | | fn(Inv<'y>)) } | |__________________________________________________- in this macro invocation + | + = help: consider adding the following bound: `'x: 'y` error: aborting due to 2 previous errors diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr index e140eaadd48a5..48558fad0051e 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr @@ -11,6 +11,8 @@ LL | gimme::<$t1>(None::<$t2>); LL | / check! { free_x_vs_free_y: (fn(&'x u32), LL | | fn(&'y u32)) } | |__________________________________________- in this macro invocation + | + = help: consider adding the following bound: `'x: 'y` error: aborting due to previous error diff --git a/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr b/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr index 6d1ef24b2dccd..f1647d3d2e43b 100644 --- a/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr +++ b/src/test/ui/hrtb/hrtb-perfect-forwarding.nll.stderr @@ -58,6 +58,8 @@ LL | fn foo_hrtb_bar_not<'b,T>(mut t: T) ... LL | foo_hrtb_bar_not(&mut t); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` + | + = help: consider replacing `'b` with `'static` warning: function cannot return without recursing --> $DIR/hrtb-perfect-forwarding.rs:49:1 diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr index da30997a23111..8e660d6814c43 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr @@ -5,6 +5,8 @@ LL | fn with_dyn_debug_static<'a>(x: Box) { | - `x` is a reference that is only valid in the function body LL | static_val(x); | ^^^^^^^^^^^^^ `x` escapes the function body here + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr index 82e280b9fb2e1..45c5142d93f28 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr +++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr @@ -4,6 +4,7 @@ error: lifetime may not live long enough LL | fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { | -- lifetime `'a` defined here ^^^^^^^^^ opaque type requires that `'a` must outlive `'static` | + = help: consider replacing `'a` with `'static` help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a constraint | LL | type E<'a, 'b> = impl Sized; + 'a diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr index 097f003575eab..bb5a85aba9709 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr @@ -19,6 +19,7 @@ LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } | | | lifetime `'a` defined here | + = help: consider replacing `'a` with `'static` help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a constraint | LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } @@ -31,6 +32,7 @@ LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` | = help: consider replacing `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/must_outlive_least_region_or_bound.rs:17:61 @@ -39,6 +41,8 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | -- -- lifetime `'b` defined here ^^^^^^^^^^^^^^^^ opaque type requires that `'b` must outlive `'a` | | | lifetime `'a` defined here + | + = help: consider adding the following bound: `'b: 'a` error[E0310]: the parameter type `T` may not live long enough --> $DIR/must_outlive_least_region_or_bound.rs:22:51 diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr index 423cfcc498980..22f081b79f157 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr @@ -19,6 +19,7 @@ LL | fn iter_values<'a>(&'a self) -> impl Iterator { | | | lifetime `'a` defined here | + = help: consider replacing `'a` with `'static` help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a constraint | LL | fn iter_values<'a>(&'a self) -> impl Iterator + 'a { diff --git a/src/test/ui/in-band-lifetimes/mismatched.nll.stderr b/src/test/ui/in-band-lifetimes/mismatched.nll.stderr index f5aee2d2d7e5c..db028e63a8244 100644 --- a/src/test/ui/in-band-lifetimes/mismatched.nll.stderr +++ b/src/test/ui/in-band-lifetimes/mismatched.nll.stderr @@ -14,6 +14,8 @@ LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } | | | | | lifetime `'b` defined here | lifetime `'a` defined here + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-10291.nll.stderr b/src/test/ui/issues/issue-10291.nll.stderr index a7b827d27a87b..1ebb0c6cf1e7b 100644 --- a/src/test/ui/issues/issue-10291.nll.stderr +++ b/src/test/ui/issues/issue-10291.nll.stderr @@ -6,6 +6,8 @@ LL | fn test<'x>(x: &'x isize) { LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { LL | x | ^ returning this value requires that `'x` must outlive `'static` + | + = help: consider replacing `'x` with `'static` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-26217.nll.stderr b/src/test/ui/issues/issue-26217.nll.stderr index c7601caacdca3..83f10c67d43a5 100644 --- a/src/test/ui/issues/issue-26217.nll.stderr +++ b/src/test/ui/issues/issue-26217.nll.stderr @@ -5,6 +5,8 @@ LL | fn bar<'a>() { | -- lifetime `'a` defined here LL | foo::<&'a i32>(); | ^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-28848.nll.stderr b/src/test/ui/issues/issue-28848.nll.stderr index 5cf9856e4dc7e..a29dac4c9c87c 100644 --- a/src/test/ui/issues/issue-28848.nll.stderr +++ b/src/test/ui/issues/issue-28848.nll.stderr @@ -7,6 +7,8 @@ LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { | lifetime `'a` defined here LL | Foo::<'a, 'b>::xmute(u) | ^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-52213.nll.stderr b/src/test/ui/issues/issue-52213.nll.stderr index eba875de2152b..359f91309d4f3 100644 --- a/src/test/ui/issues/issue-52213.nll.stderr +++ b/src/test/ui/issues/issue-52213.nll.stderr @@ -8,6 +8,8 @@ LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { LL | match (&t,) { LL | ((u,),) => u, | ^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-54943.nll.stderr b/src/test/ui/issues/issue-54943.nll.stderr index 59be0f983b907..5bf6d3382d2eb 100644 --- a/src/test/ui/issues/issue-54943.nll.stderr +++ b/src/test/ui/issues/issue-54943.nll.stderr @@ -6,6 +6,8 @@ LL | fn boo<'a>() { ... LL | let x = foo::<&'a u32>(); | ^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-55796.nll.stderr b/src/test/ui/issues/issue-55796.nll.stderr index 5809a56cd4b6b..baa0e6c29bfc4 100644 --- a/src/test/ui/issues/issue-55796.nll.stderr +++ b/src/test/ui/issues/issue-55796.nll.stderr @@ -6,6 +6,8 @@ LL | pub trait Graph<'a> { ... LL | Box::new(self.out_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/issue-55796.rs:21:9 @@ -15,6 +17,8 @@ LL | pub trait Graph<'a> { ... LL | Box::new(self.in_edges(u).map(|e| e.target())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr index f2cf19abdac31..60420973e1ee0 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr @@ -6,6 +6,8 @@ LL | fn test2<'a>(x: &'a Box) { LL | // but ref_obj will not, so warn. LL | ref_obj(x) | ^^^^^^^^^^ `x` escapes the function body here + | + = help: consider replacing `'a` with `'static` error[E0521]: borrowed data escapes outside of function --> $DIR/lifetime-bound-will-change-warning.rs:39:5 @@ -15,6 +17,8 @@ LL | fn test2cc<'a>(x: &'a Box) { LL | // same as test2, but cross crate LL | lib::ref_obj(x) | ^^^^^^^^^^^^^^^ `x` escapes the function body here + | + = help: consider replacing `'a` with `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr index fbefa1f5667c7..99fab4631a216 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr @@ -8,6 +8,8 @@ LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { LL | let z = Ref { data: y.data }; LL | x.push(z); | ^^^^^^^^^ argument requires that `'c` must outlive `'b` + | + = help: consider adding the following bound: `'c: 'b` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr index d889eb4afdbe5..52c5752f6ea1e 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr @@ -8,6 +8,8 @@ LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { ... LL | a.push(b); | ^^^^^^^^^ argument requires that `'c` must outlive `'b` + | + = help: consider adding the following bound: `'c: 'b` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr index 39eb4079352c3..e90c81ee3e1af 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr @@ -8,6 +8,8 @@ LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { ... LL | Vec::push(a, b); | ^^^^^^^^^^^^^^^ argument requires that `'c` must outlive `'b` + | + = help: consider adding the following bound: `'c: 'b` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr index a39bb165806f2..b3d0bc2b882f9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr @@ -8,6 +8,8 @@ LL | fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) ... LL | x.push(y); | ^^^^^^^^^ argument requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr index 48ce5301adef3..fbe98a4263ec1 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr @@ -7,6 +7,8 @@ LL | fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) { | lifetime `'a` defined here LL | x.push(y); | ^^^^^^^^^ argument requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr index 0996068398009..1e24032fc1ce2 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr @@ -7,6 +7,8 @@ LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { | lifetime `'a` defined here LL | x.push(y); | ^^^^^^^^^ argument requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/lub-if.nll.stderr b/src/test/ui/lub-if.nll.stderr index 832688f5162b3..1ef479fcd4bc0 100644 --- a/src/test/ui/lub-if.nll.stderr +++ b/src/test/ui/lub-if.nll.stderr @@ -6,6 +6,8 @@ LL | pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { ... LL | s | ^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/lub-if.rs:35:9 @@ -15,6 +17,8 @@ LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { ... LL | s | ^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/lub-match.nll.stderr b/src/test/ui/lub-match.nll.stderr index 3a344a77d2c2d..ed551da54f55e 100644 --- a/src/test/ui/lub-match.nll.stderr +++ b/src/test/ui/lub-match.nll.stderr @@ -6,6 +6,8 @@ LL | pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { ... LL | s | ^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/lub-match.rs:39:13 @@ -15,6 +17,8 @@ LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { ... LL | s | ^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/match/match-ref-mut-invariance.nll.stderr b/src/test/ui/match/match-ref-mut-invariance.nll.stderr index 505b8db6a3332..1658efa28bf30 100644 --- a/src/test/ui/match/match-ref-mut-invariance.nll.stderr +++ b/src/test/ui/match/match-ref-mut-invariance.nll.stderr @@ -7,6 +7,8 @@ LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { | -- lifetime `'a` defined here LL | match self.0 { ref mut x => x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr b/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr index ab5f43d022281..dc227a36566e6 100644 --- a/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr +++ b/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr @@ -8,6 +8,8 @@ LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { LL | let ref mut x = self.0; LL | x | ^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr index 61f20d1dc9ad0..d383dcca9c127 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -42,10 +42,8 @@ LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { ... LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index e34884e9f9a36..20b9144341c2e 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -45,10 +45,8 @@ LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) LL | | }); | |______^ `cell_a` escapes the function body here - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 40917135c59d3..7fe00271fc4d2 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -45,10 +45,8 @@ LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) LL | | }); | |______^ `cell_a` escapes the function body here - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr index f227e9eb413e5..7678f24381ec4 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -42,10 +42,8 @@ LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { ... LL | demand_y(outlives1, outlives2, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr b/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr index 5e8d9fa7882f1..1fa3d01017af5 100644 --- a/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr +++ b/src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr @@ -5,10 +5,8 @@ LL | fn foo<'a>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here LL | &*x | ^^^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr b/src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr index d3edbfdae88fd..d0ba539253248 100644 --- a/src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr +++ b/src/test/ui/nll/closure-requirements/region-lbr1-does-not-outlive-ebr2.stderr @@ -7,10 +7,8 @@ LL | fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 { | lifetime `'a` defined here LL | &*x | ^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/nll/issue-50716.nll.stderr b/src/test/ui/nll/issue-50716.nll.stderr index 38dd1b5f6fe73..7b83e4beaf387 100644 --- a/src/test/ui/nll/issue-50716.nll.stderr +++ b/src/test/ui/nll/issue-50716.nll.stderr @@ -6,6 +6,8 @@ LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>) ... LL | let _x = *s; | ^^ proving this value is `Sized` requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/issue-52113.stderr b/src/test/ui/nll/issue-52113.stderr index 109c7e9565911..dcf0338673483 100644 --- a/src/test/ui/nll/issue-52113.stderr +++ b/src/test/ui/nll/issue-52113.stderr @@ -8,10 +8,8 @@ LL | fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> i ... LL | x | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/nll/issue-55401.nll.stderr b/src/test/ui/nll/issue-55401.nll.stderr index 4f797f26a1a7c..df320aa0844ad 100644 --- a/src/test/ui/nll/issue-55401.nll.stderr +++ b/src/test/ui/nll/issue-55401.nll.stderr @@ -6,6 +6,8 @@ LL | fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'static u LL | let (ref y, _z): (&'a u32, u32) = (&22, 44); LL | *y | ^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/issue-58299.stderr b/src/test/ui/nll/issue-58299.stderr index 906a7bff00d4e..5be4e56171c52 100644 --- a/src/test/ui/nll/issue-58299.stderr +++ b/src/test/ui/nll/issue-58299.stderr @@ -6,10 +6,8 @@ LL | fn foo<'a>(x: i32) { ... LL | A::<'a>::X..=A::<'static>::X => (), | ^^^^^^^^^^ requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/issue-58299.rs:24:27 @@ -19,10 +17,8 @@ LL | fn bar<'a>(x: i32) { ... LL | A::<'static>::X..=A::<'a>::X => (), | ^^^^^^^^^^ requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/mir_check_cast_closure.stderr b/src/test/ui/nll/mir_check_cast_closure.stderr index 40ce9e850ea43..113e220e5137e 100644 --- a/src/test/ui/nll/mir_check_cast_closure.stderr +++ b/src/test/ui/nll/mir_check_cast_closure.stderr @@ -8,10 +8,8 @@ LL | fn bar<'a, 'b>() -> fn(&'a u32, &'b u32) -> &'a u32 { LL | let g: fn(_, _) -> _ = |_x, y| y; LL | g | ^ returning this value requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/nll/mir_check_cast_reify.stderr b/src/test/ui/nll/mir_check_cast_reify.stderr index f091161b22407..1722da8f343de 100644 --- a/src/test/ui/nll/mir_check_cast_reify.stderr +++ b/src/test/ui/nll/mir_check_cast_reify.stderr @@ -6,10 +6,8 @@ LL | fn bar<'a>(x: &'a u32) -> &'static u32 { ... LL | f(x) | ^^^^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr b/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr index 2f76758f259a5..c87425ecfc0fa 100644 --- a/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr +++ b/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr @@ -6,10 +6,8 @@ LL | fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 { ... LL | unsafe { g(input) } | ^^^^^^^^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/mir_check_cast_unsize.stderr b/src/test/ui/nll/mir_check_cast_unsize.stderr index 4a76fa8158e5a..cb7328d117984 100644 --- a/src/test/ui/nll/mir_check_cast_unsize.stderr +++ b/src/test/ui/nll/mir_check_cast_unsize.stderr @@ -5,10 +5,8 @@ LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug { | -- lifetime `'a` defined here LL | x | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/outlives-suggestion-simple.stderr b/src/test/ui/nll/outlives-suggestion-simple.stderr index 90c6bf2f5b8d9..f7603e29d488c 100644 --- a/src/test/ui/nll/outlives-suggestion-simple.stderr +++ b/src/test/ui/nll/outlives-suggestion-simple.stderr @@ -7,10 +7,8 @@ LL | fn foo1<'a, 'b>(x: &'a usize) -> &'b usize { | lifetime `'a` defined here LL | x | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/outlives-suggestion-simple.rs:10:5 @@ -19,10 +17,8 @@ LL | fn foo2<'a>(x: &'a usize) -> &'static usize { | -- lifetime `'a` defined here LL | x | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/outlives-suggestion-simple.rs:14:5 @@ -33,6 +29,8 @@ LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) { | lifetime `'a` defined here LL | (x, y) | ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/outlives-suggestion-simple.rs:14:5 @@ -43,10 +41,10 @@ LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) { | lifetime `'a` defined here LL | (x, y) | ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - -help: the following changes may resolve your lifetime errors | - = help: `'a` and `'b` must be the same; replace one with the other + = help: consider adding the following bound: `'b: 'a` + +help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/outlives-suggestion-simple.rs:22:5 @@ -58,10 +56,8 @@ LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) { ... LL | (x, x) | ^^^^^^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/outlives-suggestion-simple.rs:31:9 @@ -70,10 +66,8 @@ LL | pub fn foo<'a>(x: &'a usize) -> Self { | -- lifetime `'a` defined here LL | Foo { x } | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/outlives-suggestion-simple.rs:41:9 @@ -84,10 +78,8 @@ LL | pub fn get<'b>(&self) -> &'b usize { | -- lifetime `'b` defined here LL | self.x | ^^^^^^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/outlives-suggestion-simple.rs:52:9 @@ -98,10 +90,8 @@ LL | fn get<'b>(&'b self) -> &'a i32 { | -- lifetime `'b` defined here LL | self.x | ^^^^^^ returning this value requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` error[E0521]: borrowed data escapes outside of function --> $DIR/outlives-suggestion-simple.rs:73:9 diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index be45c23ed8318..7c5a6eecea1ea 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -50,10 +50,8 @@ LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) ... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` note: External requirements --> $DIR/projection-one-region-closure.rs:56:29 @@ -108,10 +106,8 @@ LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) ... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` note: External requirements --> $DIR/projection-one-region-closure.rs:70:29 diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 39f9e78f88964..a2ba2e36edf42 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -41,10 +41,8 @@ LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) ... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` note: External requirements --> $DIR/projection-one-region-trait-bound-closure.rs:47:29 @@ -90,10 +88,8 @@ LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) ... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` note: External requirements --> $DIR/projection-one-region-trait-bound-closure.rs:60:29 diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 15e921bdec16c..109edfec43c0e 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -236,10 +236,8 @@ LL | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) ... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` note: External requirements --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 diff --git a/src/test/ui/nll/ty-outlives/wf-unreachable.stderr b/src/test/ui/nll/ty-outlives/wf-unreachable.stderr index e4fa647e6cb1a..f15c2ffd0d7eb 100644 --- a/src/test/ui/nll/ty-outlives/wf-unreachable.stderr +++ b/src/test/ui/nll/ty-outlives/wf-unreachable.stderr @@ -6,10 +6,8 @@ LL | fn uninit<'a>() { LL | return; LL | let x: &'static &'a (); | ^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:13:12 @@ -19,10 +17,8 @@ LL | fn var_type<'a>() { LL | return; LL | let x: &'static &'a () = &&(); | ^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:17:12 @@ -31,10 +27,8 @@ LL | fn uninit_infer<'a>() { | -- lifetime `'a` defined here LL | let x: &'static &'a _; | ^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:23:12 @@ -44,10 +38,8 @@ LL | fn infer<'a>() { LL | return; LL | let x: &'static &'a _ = &&(); | ^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:28:12 @@ -57,10 +49,8 @@ LL | fn uninit_no_var<'a>() { LL | return; LL | let _: &'static &'a (); | ^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:33:12 @@ -70,10 +60,8 @@ LL | fn no_var<'a>() { LL | return; LL | let _: &'static &'a () = &&(); | ^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:38:12 @@ -83,10 +71,8 @@ LL | fn infer_no_var<'a>() { LL | return; LL | let _: &'static &'a _ = &&(); | ^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/wf-unreachable.rs:51:12 @@ -96,10 +82,8 @@ LL | fn required_substs<'a>() { LL | return; LL | let _: C<'static, 'a, _> = C((), &(), &()); | ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to 8 previous errors diff --git a/src/test/ui/nll/type-check-pointer-coercions.stderr b/src/test/ui/nll/type-check-pointer-coercions.stderr index 9c7601c3a6026..39fd98f7151a0 100644 --- a/src/test/ui/nll/type-check-pointer-coercions.stderr +++ b/src/test/ui/nll/type-check-pointer-coercions.stderr @@ -7,10 +7,8 @@ LL | fn shared_to_const<'a, 'b>(x: &&'a i32) -> *const &'b i32 { | lifetime `'a` defined here LL | x | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:8:5 @@ -21,10 +19,8 @@ LL | fn unique_to_const<'a, 'b>(x: &mut &'a i32) -> *const &'b i32 { | lifetime `'a` defined here LL | x | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:13:5 @@ -36,6 +32,8 @@ LL | fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 { LL | // Two errors because *mut is invariant LL | x | ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:13:5 @@ -47,10 +45,10 @@ LL | fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 { LL | // Two errors because *mut is invariant LL | x | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: `'b` and `'a` must be the same; replace one with the other + = help: consider adding the following bound: `'a: 'b` + +help: `'b` and `'a` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:18:5 @@ -61,10 +59,8 @@ LL | fn mut_to_const<'a, 'b>(x: *mut &'a i32) -> *const &'b i32 { | lifetime `'a` defined here LL | x | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:24:5 @@ -76,10 +72,8 @@ LL | fn array_elem<'a, 'b>(x: &'a i32) -> *const &'b i32 { ... LL | y | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:30:5 @@ -91,10 +85,8 @@ LL | fn array_coerce<'a, 'b>(x: &'a i32) -> *const [&'b i32; 3] { ... LL | y | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:36:5 @@ -106,10 +98,8 @@ LL | fn nested_array<'a, 'b>(x: &'a i32) -> *const [&'b i32; 2] { ... LL | y | ^ returning this value requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: aborting due to 8 previous errors diff --git a/src/test/ui/nll/type-check-pointer-comparisons.stderr b/src/test/ui/nll/type-check-pointer-comparisons.stderr index 5293f48116e8f..f350b861eb6d2 100644 --- a/src/test/ui/nll/type-check-pointer-comparisons.stderr +++ b/src/test/ui/nll/type-check-pointer-comparisons.stderr @@ -7,6 +7,8 @@ LL | fn compare_const<'a, 'b>(x: *const &mut &'a i32, y: *const &mut &'b i32) { | lifetime `'a` defined here LL | x == y; | ^ requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:6:10 @@ -17,10 +19,10 @@ LL | fn compare_const<'a, 'b>(x: *const &mut &'a i32, y: *const &mut &'b i32) { | lifetime `'a` defined here LL | x == y; | ^ requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: `'b` and `'a` must be the same; replace one with the other + = help: consider adding the following bound: `'b: 'a` + +help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:12:5 @@ -31,6 +33,8 @@ LL | fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) { | lifetime `'a` defined here LL | x == y; | ^ requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:12:10 @@ -41,10 +45,10 @@ LL | fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) { | lifetime `'a` defined here LL | x == y; | ^ requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: `'a` and `'b` must be the same; replace one with the other + = help: consider adding the following bound: `'b: 'a` + +help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:18:5 @@ -55,6 +59,8 @@ LL | fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32 | lifetime `'a` defined here LL | f == g; | ^ requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:18:10 @@ -65,10 +71,10 @@ LL | fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32 | lifetime `'a` defined here LL | f == g; | ^ requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: `'a` and `'b` must be the same; replace one with the other + = help: consider adding the following bound: `'b: 'a` + +help: `'a` and `'b` must be the same: replace one with the other error: aborting due to 6 previous errors diff --git a/src/test/ui/nll/user-annotations/closure-substs.stderr b/src/test/ui/nll/user-annotations/closure-substs.stderr index ff0cda9114a1a..e3e294106d168 100644 --- a/src/test/ui/nll/user-annotations/closure-substs.stderr +++ b/src/test/ui/nll/user-annotations/closure-substs.stderr @@ -6,10 +6,8 @@ LL | fn foo<'a>() { ... LL | return x; | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/closure-substs.rs:15:16 @@ -27,10 +25,8 @@ LL | fn bar<'a>() { ... LL | b(x); | ^^^^ argument requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error[E0521]: borrowed data escapes outside of closure --> $DIR/closure-substs.rs:29:9 diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.nll.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.nll.stderr index c39301588acfa..e9a0b8173ceaa 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.nll.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.nll.stderr @@ -5,6 +5,8 @@ LL | fn foo<'a>(_: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here LL | >::C | ^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-normalize.nll.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-normalize.nll.stderr index 541a2cfaf299a..52ec36ef542cc 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-normalize.nll.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-normalize.nll.stderr @@ -5,6 +5,8 @@ LL | fn foo<'a>(_: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here LL | <() as Foo<'a>>::C | ^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.nll.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.nll.stderr index ea0fcb6d634cd..5f3212eb9aa34 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.nll.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.nll.stderr @@ -5,6 +5,8 @@ LL | fn foo<'a>(_: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here LL | <() as Foo<'a>>::C | ^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.nll.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.nll.stderr index ff549f1d88bd4..490030d30f317 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.nll.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.nll.stderr @@ -5,6 +5,8 @@ LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 { | -- lifetime `'a` defined here LL | >::C | ^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.nll.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.nll.stderr index 7f160d8e398b9..5e687805c6fc3 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.nll.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.nll.stderr @@ -5,6 +5,8 @@ LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 { | -- lifetime `'a` defined here LL | T::C | ^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/inherent-associated-constants.stderr b/src/test/ui/nll/user-annotations/inherent-associated-constants.stderr index 48d56fc1c02fe..7b5646de775ab 100644 --- a/src/test/ui/nll/user-annotations/inherent-associated-constants.stderr +++ b/src/test/ui/nll/user-annotations/inherent-associated-constants.stderr @@ -5,10 +5,8 @@ LL | fn non_wf_associated_const<'a>(x: i32) { | -- lifetime `'a` defined here LL | A::<'a>::IC; | ^^^^^^^^^^^ requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/nll/user-annotations/issue-54124.stderr b/src/test/ui/nll/user-annotations/issue-54124.stderr index 64df1264d27ea..97653b8c199c8 100644 --- a/src/test/ui/nll/user-annotations/issue-54124.stderr +++ b/src/test/ui/nll/user-annotations/issue-54124.stderr @@ -15,10 +15,8 @@ LL | fn test<'a>() { | -- lifetime `'a` defined here LL | let _:fn(&()) = |_:&'a ()| {}; | ^ requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr b/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr index a629cc267635d..f23ea9fdb5c31 100644 --- a/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr +++ b/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr @@ -6,10 +6,8 @@ LL | fn coupled_regions_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { ... LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/issue-55748-pat-types-constrain-bindings.rs:49:5 @@ -19,10 +17,8 @@ LL | fn coupled_types_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { ... LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/issue-55748-pat-types-constrain-bindings.rs:62:5 @@ -32,10 +28,8 @@ LL | fn coupled_wilds_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { ... LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to 3 previous errors diff --git a/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr b/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr index 937db3775738d..426c57ef9c4e7 100644 --- a/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr +++ b/src/test/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.stderr @@ -6,10 +6,8 @@ LL | fn coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { LL | let ((y, _z),) = ((s, _x),): (PairCoupledTypes<_>,); LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/issue-57731-ascibed-coupled-types.rs:22:5 @@ -19,10 +17,8 @@ LL | fn coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { LL | let ((y, _z),) = ((s, _x),): (PairCoupledRegions<_>,); LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/issue-57731-ascibed-coupled-types.rs:32:5 @@ -32,10 +28,8 @@ LL | fn cast_coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 LL | let ((y, _z),) = ((s, _x),) as (PairCoupledTypes<_>,); LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/issue-57731-ascibed-coupled-types.rs:37:5 @@ -45,10 +39,8 @@ LL | fn cast_coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u LL | let ((y, _z),) = ((s, _x),) as (PairCoupledRegions<_>,); LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to 4 previous errors diff --git a/src/test/ui/nll/user-annotations/patterns.stderr b/src/test/ui/nll/user-annotations/patterns.stderr index 981e59c08c520..c2786f0e8cca2 100644 --- a/src/test/ui/nll/user-annotations/patterns.stderr +++ b/src/test/ui/nll/user-annotations/patterns.stderr @@ -156,10 +156,8 @@ LL | fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 { ... LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/patterns.rs:125:5 @@ -169,10 +167,8 @@ LL | fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 { ... LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/patterns.rs:130:5 @@ -182,10 +178,8 @@ LL | fn static_to_a_to_static_through_struct<'a>(_x: &'a u32) -> &'static u32 { LL | let Single { value: y }: Single<&'a u32> = Single { value: &22 }; LL | y | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/patterns.rs:134:18 @@ -194,10 +188,8 @@ LL | fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here LL | let (y, _z): (&'static u32, u32) = (x, 44); | ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error: aborting due to 19 previous errors diff --git a/src/test/ui/nll/user-annotations/wf-self-type.stderr b/src/test/ui/nll/user-annotations/wf-self-type.stderr index c3b32865b0147..33bb1c519b16e 100644 --- a/src/test/ui/nll/user-annotations/wf-self-type.stderr +++ b/src/test/ui/nll/user-annotations/wf-self-type.stderr @@ -7,10 +7,8 @@ LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { | lifetime `'a` defined here LL | Foo::xmute(u) | ^^^^^^^^^^^^^ returning this value requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/nll/where_clauses_in_functions.stderr b/src/test/ui/nll/where_clauses_in_functions.stderr index c01101cf1f6d0..1badb7d753b6e 100644 --- a/src/test/ui/nll/where_clauses_in_functions.stderr +++ b/src/test/ui/nll/where_clauses_in_functions.stderr @@ -7,10 +7,8 @@ LL | fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { | lifetime `'a` defined here LL | foo(x, y) | ^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/nll/where_clauses_in_structs.stderr b/src/test/ui/nll/where_clauses_in_structs.stderr index aa15aa4ddcae2..2e990131e61de 100644 --- a/src/test/ui/nll/where_clauses_in_structs.stderr +++ b/src/test/ui/nll/where_clauses_in_structs.stderr @@ -7,10 +7,8 @@ LL | fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) { | lifetime `'a` defined here LL | Foo { x, y }; | ^ requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr index e94f2a92125cd..900cdfca24438 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr @@ -8,6 +8,8 @@ LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { ... LL | ss | ^^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr index 7d6f9f39d13ed..defffe2b84b0d 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr @@ -5,6 +5,8 @@ LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here LL | ss.t = t; | ^^^^^^^^ assignment requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr index 6df54638ce004..8c28a7a011aba 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr @@ -5,6 +5,8 @@ LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here LL | ss.t = t; | ^^^^^^^^ assignment requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr index cdfbf0fc878cf..d871eb5327d22 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr @@ -8,6 +8,8 @@ LL | fn load1<'a,'b>(a: &'a MyBox, ... LL | a | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error[E0521]: borrowed data escapes outside of function --> $DIR/object-lifetime-default-mybox.rs:31:5 @@ -16,6 +18,8 @@ LL | fn load2<'a>(ss: &MyBox) -> MyBox { | -- `ss` is a reference that is only valid in the function body LL | load0(ss) | ^^^^^^^^^ `ss` escapes the function body here + | + = help: consider replacing `'a` with `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr b/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr index 76129b4d188d3..d941030d82474 100644 --- a/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr +++ b/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr @@ -6,6 +6,8 @@ LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { LL | let bad = if x.is_some() { LL | x.unwrap() | ^^^^^^^^^^ `x` escapes the function body here + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/regions/region-object-lifetime-2.nll.stderr b/src/test/ui/regions/region-object-lifetime-2.nll.stderr index 60084773466a6..db45a03ad18fb 100644 --- a/src/test/ui/regions/region-object-lifetime-2.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-2.nll.stderr @@ -7,6 +7,8 @@ LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | lifetime `'a` defined here LL | x.borrowed() | ^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/regions/region-object-lifetime-4.nll.stderr b/src/test/ui/regions/region-object-lifetime-4.nll.stderr index 75b049dae21f8..fda66a2412ccb 100644 --- a/src/test/ui/regions/region-object-lifetime-4.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-4.nll.stderr @@ -7,6 +7,8 @@ LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &' | lifetime `'a` defined here LL | x.borrowed() | ^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr index 43acbfd412d91..767853d81480e 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr @@ -32,6 +32,8 @@ LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | lifetime `'a` defined here LL | Box::new(v) | ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to 4 previous errors diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.nll.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.nll.stderr index 4944f2649b738..9bb385b0dcdc8 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.nll.stderr +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.nll.stderr @@ -8,6 +8,8 @@ LL | fn with_assoc<'a,'b>() { ... LL | let _: &'a WithAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr index 79ea4caa34333..9bb385b0dcdc8 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr @@ -8,10 +8,8 @@ LL | fn with_assoc<'a,'b>() { ... LL | let _: &'a WithAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr index 86bd100538d70..ca153b9d9b1d7 100644 --- a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr +++ b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr @@ -5,6 +5,8 @@ LL | fn param_not_ok<'a>(x: &'a isize) { | -- lifetime `'a` defined here LL | assert_send::<&'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 @@ -13,6 +15,8 @@ LL | fn param_not_ok1<'a>(_: &'a isize) { | -- lifetime `'a` defined here LL | assert_send::<&'a str>(); | ^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/regions-bounded-by-trait-requiring-static.rs:30:5 @@ -21,6 +25,8 @@ LL | fn param_not_ok2<'a>(_: &'a isize) { | -- lifetime `'a` defined here LL | assert_send::<&'a [isize]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/regions-bounded-by-trait-requiring-static.rs:44:5 @@ -29,6 +35,8 @@ LL | fn box_with_region_not_ok<'a>() { | -- lifetime `'a` defined here LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/regions-bounded-by-trait-requiring-static.rs:55:5 @@ -37,6 +45,8 @@ LL | fn unsafe_ok2<'a>(_: &'a isize) { | -- lifetime `'a` defined here LL | assert_send::<*const &'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: lifetime may not live long enough --> $DIR/regions-bounded-by-trait-requiring-static.rs:59:5 @@ -45,6 +55,8 @@ LL | fn unsafe_ok3<'a>(_: &'a isize) { | -- lifetime `'a` defined here LL | assert_send::<*mut &'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to 6 previous errors diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr index a8ab92d75c06d..47796e50a888f 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr @@ -8,6 +8,8 @@ LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { LL | // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. LL | a.bigger_region(b) | ^^^^^^^^^^^^^^^^^^ argument requires that `'y` must outlive `'x` + | + = help: consider adding the following bound: `'y: 'x` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr index 52ad2d9daeb1d..d352d119a70e8 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr @@ -8,6 +8,8 @@ LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { LL | // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. LL | f.method(b); | ^^^^^^^^^^^ `b` escapes the function body here + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr index b6d7b8aac5f19..2076772b59df4 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr @@ -5,6 +5,8 @@ LL | fn caller<'a>(x: &isize) { | -- lifetime `'a` defined here LL | Foo.some_method::<&'a isize>(); | ^^^^^^^^^^^ requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-bounds.nll.stderr b/src/test/ui/regions/regions-bounds.nll.stderr index 3345946bfddff..dd702755c7e7b 100644 --- a/src/test/ui/regions/regions-bounds.nll.stderr +++ b/src/test/ui/regions/regions-bounds.nll.stderr @@ -7,6 +7,8 @@ LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { | lifetime `'a` defined here LL | return e; | ^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/regions-bounds.rs:13:12 @@ -17,6 +19,8 @@ LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { | lifetime `'a` defined here LL | return e; | ^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr index 806a3ca82425b..882faf4ece316 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr @@ -5,6 +5,8 @@ LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { | -- lifetime `'a` defined here LL | box B(&*v) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error[E0515]: cannot return value referencing local data `*v` --> $DIR/regions-close-object-into-object-2.rs:10:5 diff --git a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr index 1e57023bc2320..93ac17810dae2 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr @@ -13,6 +13,8 @@ LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | -- lifetime `'a` defined here LL | box B(&*v) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error[E0515]: cannot return value referencing local data `*v` --> $DIR/regions-close-object-into-object-4.rs:10:5 diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr index 88d6abd1428aa..2fb9dcc4e9ec7 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr @@ -8,6 +8,8 @@ LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'c` + | + = help: consider adding the following bound: `'a: 'c` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-creating-enums3.nll.stderr b/src/test/ui/regions/regions-creating-enums3.nll.stderr index e35a878fce177..41d609b56d233 100644 --- a/src/test/ui/regions/regions-creating-enums3.nll.stderr +++ b/src/test/ui/regions/regions-creating-enums3.nll.stderr @@ -7,6 +7,8 @@ LL | fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> { | lifetime `'a` defined here LL | Ast::Add(x, y) | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-creating-enums4.nll.stderr b/src/test/ui/regions/regions-creating-enums4.nll.stderr index 4eac457feda2c..dda374c90d937 100644 --- a/src/test/ui/regions/regions-creating-enums4.nll.stderr +++ b/src/test/ui/regions/regions-creating-enums4.nll.stderr @@ -7,6 +7,8 @@ LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { | lifetime `'a` defined here LL | Ast::Add(x, y) | ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-early-bound-error-method.nll.stderr b/src/test/ui/regions/regions-early-bound-error-method.nll.stderr index 1540a7bacd7b2..4957bcf3f7371 100644 --- a/src/test/ui/regions/regions-early-bound-error-method.nll.stderr +++ b/src/test/ui/regions/regions-early-bound-error-method.nll.stderr @@ -7,6 +7,8 @@ LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { | -- lifetime `'b` defined here LL | g2.get() | ^^^^^^^^ returning this value requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-early-bound-error.nll.stderr b/src/test/ui/regions/regions-early-bound-error.nll.stderr index 7836291a7caab..eb4cd5ca72ea1 100644 --- a/src/test/ui/regions/regions-early-bound-error.nll.stderr +++ b/src/test/ui/regions/regions-early-bound-error.nll.stderr @@ -7,6 +7,8 @@ LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { | lifetime `'a` defined here LL | g1.get() | ^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr index 9ae484eaf4558..f61f068a4861b 100644 --- a/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr @@ -8,6 +8,8 @@ LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { LL | // However, it is not safe to assume that 'b <= 'a LL | &*y | ^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/regions-free-region-ordering-callee.rs:18:12 @@ -19,6 +21,8 @@ LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { LL | // Do not infer an ordering from the return value. LL | let z: &'b usize = &*x; | ^^^^^^^^^ type annotation requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.migrate.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-caller.migrate.nll.stderr index 16eda2844c64c..0d4694a64d087 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller.migrate.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-caller.migrate.nll.stderr @@ -7,6 +7,8 @@ LL | fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { | lifetime `'a` defined here LL | let z: Option<&'b &'a usize> = None; | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/regions-free-region-ordering-caller.rs:17:12 @@ -18,6 +20,8 @@ LL | fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { LL | let y: Paramd<'a> = Paramd { x: a }; LL | let z: Option<&'b Paramd<'a>> = None; | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/regions-free-region-ordering-caller.rs:22:12 @@ -28,6 +32,8 @@ LL | fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { | lifetime `'a` defined here LL | let z: Option<&'a &'b usize> = None; | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr index 594ea755e3d43..0d4694a64d087 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr @@ -7,10 +7,8 @@ LL | fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { | lifetime `'a` defined here LL | let z: Option<&'b &'a usize> = None; | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/regions-free-region-ordering-caller.rs:17:12 @@ -22,10 +20,8 @@ LL | fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { LL | let y: Paramd<'a> = Paramd { x: a }; LL | let z: Option<&'b Paramd<'a>> = None; | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'b` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'a: 'b` + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/regions-free-region-ordering-caller.rs:22:12 @@ -36,10 +32,8 @@ LL | fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { | lifetime `'a` defined here LL | let z: Option<&'a &'b usize> = None; | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr index 480a81d33f64c..106d3df274435 100644 --- a/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr @@ -10,6 +10,8 @@ LL | | Some(ref next) => next.get(), LL | | None => &self.val LL | | } | |_________^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr index cefeecf16e2d4..94b80852d0124 100644 --- a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr @@ -8,6 +8,8 @@ LL | fn use_<'short,'long>(c: Contravariant<'short>, ... LL | let _: Contravariant<'long> = c; | ^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'short` must outlive `'long` + | + = help: consider adding the following bound: `'short: 'long` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr index 1bddecba50a72..f44a0fad59b2e 100644 --- a/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr @@ -8,6 +8,8 @@ LL | fn use_<'short,'long>(c: Covariant<'long>, ... LL | let _: Covariant<'short> = c; | ^^^^^^^^^^^^^^^^^ type annotation requires that `'short` must outlive `'long` + | + = help: consider adding the following bound: `'short: 'long` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr index 0c1e3989b234a..3256e3c0dd381 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr @@ -5,6 +5,8 @@ LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here LL | b_isize | ^^^^^^^ returning this value requires that `'r` must outlive `'static` + | + = help: consider replacing `'r` with `'static` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr index 0edeb2723998f..991f9a287b9bf 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr @@ -5,6 +5,8 @@ LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here LL | b_isize | ^^^^^^^ returning this value requires that `'r` must outlive `'static` + | + = help: consider replacing `'r` with `'static` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr index 724dd7e3f6d3f..2d62fb85b81eb 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr @@ -5,6 +5,8 @@ LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here LL | b_isize | ^^^^^^^ returning this value requires that `'r` must outlive `'static` + | + = help: consider replacing `'r` with `'static` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-not-param.nll.stderr b/src/test/ui/regions/regions-infer-not-param.nll.stderr index 2064b060ec419..fcc2ec31f3e02 100644 --- a/src/test/ui/regions/regions-infer-not-param.nll.stderr +++ b/src/test/ui/regions/regions-infer-not-param.nll.stderr @@ -5,6 +5,8 @@ LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } | -- -- lifetime `'b` defined here ^ returning this value requires that `'a` must outlive `'b` | | | lifetime `'a` defined here + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/regions-infer-not-param.rs:19:63 @@ -13,6 +15,8 @@ LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` | | | lifetime `'a` defined here + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/regions-infer-not-param.rs:19:63 @@ -21,6 +25,10 @@ LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | -- -- lifetime `'b` defined here ^ returning this value requires that `'a` must outlive `'b` | | | lifetime `'a` defined here + | + = help: consider adding the following bound: `'a: 'b` + +help: `'b` and `'a` must be the same: replace one with the other error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-nested-fns.nll.stderr b/src/test/ui/regions/regions-nested-fns.nll.stderr index 97650636cb67f..305a76815aca9 100644 --- a/src/test/ui/regions/regions-nested-fns.nll.stderr +++ b/src/test/ui/regions/regions-nested-fns.nll.stderr @@ -45,6 +45,8 @@ LL | fn nested<'x>(x: &'x isize) { ... LL | if false { return x; } | ^ returning this value requires that `'x` must outlive `'static` + | + = help: consider replacing `'x` with `'static` error: aborting due to 4 previous errors diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.migrate.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.migrate.nll.stderr index eed9934be121d..29e92f33ec914 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-hrtb.migrate.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container-hrtb.migrate.nll.stderr @@ -8,6 +8,8 @@ LL | fn with_assoc<'a,'b>() { ... LL | let _: &'a WithHrAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/regions-outlives-projection-container-hrtb.rs:50:12 @@ -19,6 +21,8 @@ LL | fn with_assoc_sub<'a,'b>() { ... LL | let _: &'a WithHrAssocSub> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr index fb836d32a2bff..29e92f33ec914 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr @@ -8,10 +8,8 @@ LL | fn with_assoc<'a,'b>() { ... LL | let _: &'a WithHrAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/regions-outlives-projection-container-hrtb.rs:50:12 @@ -23,10 +21,8 @@ LL | fn with_assoc_sub<'a,'b>() { ... LL | let _: &'a WithHrAssocSub> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.migrate.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.migrate.nll.stderr index 8c54d8da0a063..7035144302479 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-wc.migrate.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container-wc.migrate.nll.stderr @@ -8,6 +8,8 @@ LL | fn with_assoc<'a,'b>() { ... LL | let _: &'a WithAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr index 3f5088c12d64a..7035144302479 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr @@ -8,10 +8,8 @@ LL | fn with_assoc<'a,'b>() { ... LL | let _: &'a WithAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` - -help: the following changes may resolve your lifetime errors | - = help: add bound `'b: 'a` + = help: consider adding the following bound: `'b: 'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-outlives-projection-container.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container.nll.stderr index 2cf6e245d19f6..073a31900227e 100644 --- a/src/test/ui/regions/regions-outlives-projection-container.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container.nll.stderr @@ -8,6 +8,8 @@ LL | fn with_assoc<'a,'b>() { ... LL | let _x: &'a WithAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/regions-outlives-projection-container.rs:54:13 @@ -19,6 +21,8 @@ LL | fn without_assoc<'a,'b>() { ... LL | let _x: &'a WithoutAssoc> = loop { }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/regions-outlives-projection-container.rs:63:5 @@ -30,6 +34,8 @@ LL | fn call_with_assoc<'a,'b>() { ... LL | call::<&'a WithAssoc>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/regions-outlives-projection-container.rs:70:5 @@ -41,6 +47,8 @@ LL | fn call_without_assoc<'a,'b>() { ... LL | call::<&'a WithoutAssoc>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to 4 previous errors diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr index c8582f8bfe7f0..dc905d076bb7d 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr @@ -7,6 +7,8 @@ LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b m | lifetime `'a` defined here LL | &mut ***p | ^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr index 5946e7bf84950..c98ec477417bd 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr @@ -7,6 +7,8 @@ LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { | lifetime `'a` defined here LL | &mut **p | ^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | + = help: consider adding the following bound: `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-static-bound.migrate.nll.stderr b/src/test/ui/regions/regions-static-bound.migrate.nll.stderr index b5f3e6cfaba09..6f2c75d2ebad8 100644 --- a/src/test/ui/regions/regions-static-bound.migrate.nll.stderr +++ b/src/test/ui/regions/regions-static-bound.migrate.nll.stderr @@ -5,6 +5,8 @@ LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { | -- lifetime `'a` defined here LL | t | ^ returning this value requires that `'a` must outlive `'static` + | + = help: consider replacing `'a` with `'static` error[E0621]: explicit lifetime required in the type of `u` --> $DIR/regions-static-bound.rs:14:5 diff --git a/src/test/ui/regions/regions-static-bound.nll.stderr b/src/test/ui/regions/regions-static-bound.nll.stderr index 281683ac1da2b..6f2c75d2ebad8 100644 --- a/src/test/ui/regions/regions-static-bound.nll.stderr +++ b/src/test/ui/regions/regions-static-bound.nll.stderr @@ -5,10 +5,8 @@ LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { | -- lifetime `'a` defined here LL | t | ^ returning this value requires that `'a` must outlive `'static` - -help: the following changes may resolve your lifetime errors | - = help: replace `'a` with `'static` + = help: consider replacing `'a` with `'static` error[E0621]: explicit lifetime required in the type of `u` --> $DIR/regions-static-bound.rs:14:5 diff --git a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr index f4b1a89db9a73..f92923a112584 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr +++ b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr @@ -8,6 +8,8 @@ LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { LL | // Without knowing 'a:'b, we can't coerce LL | x | ^ returning this value requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough --> $DIR/regions-trait-object-subtyping.rs:22:5 @@ -19,6 +21,8 @@ LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dum LL | // We can't coerce because it is packed in `Wrapper` LL | x | ^ returning this value requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr index f5b96f314c578..5352be430fbc5 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr @@ -8,6 +8,8 @@ LL | fn use_<'short,'long>(c: S<'long, 'short>, ... LL | let _: S<'long, 'long> = c; | ^^^^^^^^^^^^^^^ type annotation requires that `'short` must outlive `'long` + | + = help: consider adding the following bound: `'short: 'long` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr index 372510a2f7e28..22c9b915bb9ee 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr @@ -8,6 +8,8 @@ LL | fn use_<'short,'long>(c: Contravariant<'short>, ... LL | let _: Contravariant<'long> = c; | ^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'short` must outlive `'long` + | + = help: consider adding the following bound: `'short: 'long` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr b/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr index e87e914727c5f..a07181ad553e6 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr @@ -8,6 +8,8 @@ LL | fn use_<'short,'long>(c: Covariant<'long>, ... LL | let _: Covariant<'short> = c; | ^^^^^^^^^^^^^^^^^ type annotation requires that `'short` must outlive `'long` + | + = help: consider adding the following bound: `'short: 'long` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr b/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr index adee33bfc7e83..d51db99f81f7b 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr @@ -8,6 +8,8 @@ LL | fn use_<'short,'long>(c: Invariant<'long>, ... LL | let _: Invariant<'short> = c; | ^^^^^^^^^^^^^^^^^ type annotation requires that `'short` must outlive `'long` + | + = help: consider adding the following bound: `'short: 'long` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr b/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr index 15853e6ca5d69..90388a1c51b1f 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr @@ -6,6 +6,8 @@ LL | fn use_<'b>(c: Invariant<'b>) { ... LL | let _: Invariant<'static> = c; | ^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'static` + | + = help: consider replacing `'b` with `'static` error: aborting due to previous error diff --git a/src/test/ui/variance/variance-btree-invariant-types.nll.stderr b/src/test/ui/variance/variance-btree-invariant-types.nll.stderr index 344437f74e495..be18737b5f131 100644 --- a/src/test/ui/variance/variance-btree-invariant-types.nll.stderr +++ b/src/test/ui/variance/variance-btree-invariant-types.nll.stderr @@ -5,6 +5,8 @@ LL | fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, & | ---- lifetime `'new` defined here LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:7:5 @@ -13,6 +15,8 @@ LL | fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, ( | ---- lifetime `'new` defined here LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:10:5 @@ -21,6 +25,8 @@ LL | fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, & | ---- lifetime `'new` defined here LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:13:5 @@ -29,6 +35,8 @@ LL | fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, ( | ---- lifetime `'new` defined here LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:18:5 @@ -38,6 +46,8 @@ LL | fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>) LL | -> OccupiedEntry<'a, &'new (), ()> { LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:22:5 @@ -47,6 +57,8 @@ LL | fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>) LL | -> OccupiedEntry<'a, (), &'new ()> { LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:26:5 @@ -56,6 +68,8 @@ LL | fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>) LL | -> OccupiedEntry<'a, &'static (), ()> { LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:30:5 @@ -65,6 +79,8 @@ LL | fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>) LL | -> OccupiedEntry<'a, (), &'static ()> { LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:35:5 @@ -74,6 +90,8 @@ LL | fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>) LL | -> VacantEntry<'a, &'new (), ()> { LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:39:5 @@ -83,6 +101,8 @@ LL | fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>) LL | -> VacantEntry<'a, (), &'new ()> { LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:43:5 @@ -92,6 +112,8 @@ LL | fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>) LL | -> VacantEntry<'a, &'static (), ()> { LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: lifetime may not live long enough --> $DIR/variance-btree-invariant-types.rs:47:5 @@ -101,6 +123,8 @@ LL | fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>) LL | -> VacantEntry<'a, (), &'static ()> { LL | v | ^ returning this value requires that `'new` must outlive `'static` + | + = help: consider replacing `'new` with `'static` error: aborting due to 12 previous errors diff --git a/src/test/ui/variance/variance-cell-is-invariant.nll.stderr b/src/test/ui/variance/variance-cell-is-invariant.nll.stderr index a3ae5320c90d4..1fcdfc4b5bbb2 100644 --- a/src/test/ui/variance/variance-cell-is-invariant.nll.stderr +++ b/src/test/ui/variance/variance-cell-is-invariant.nll.stderr @@ -8,6 +8,8 @@ LL | fn use_<'short,'long>(c: Foo<'short>, ... LL | let _: Foo<'long> = c; | ^^^^^^^^^^ type annotation requires that `'short` must outlive `'long` + | + = help: consider adding the following bound: `'short: 'long` error: aborting due to previous error diff --git a/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr b/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr index 69818aedd154c..91d4fd2e971fa 100644 --- a/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max>(v: Box>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-contravariant-arg-object.rs:22:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>(v: Box>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-contravariant-arg-trait-match.nll.stderr b/src/test/ui/variance/variance-contravariant-arg-trait-match.nll.stderr index dbd75cb52fa83..6f136750ee13d 100644 --- a/src/test/ui/variance/variance-contravariant-arg-trait-match.nll.stderr +++ b/src/test/ui/variance/variance-contravariant-arg-trait-match.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max, G>() ... LL | impls_get::() | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-contravariant-arg-trait-match.rs:21:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>() ... LL | impls_get::() | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-contravariant-self-trait-match.nll.stderr b/src/test/ui/variance/variance-contravariant-self-trait-match.nll.stderr index 9212cf24be3bf..fe08ce0b84d21 100644 --- a/src/test/ui/variance/variance-contravariant-self-trait-match.nll.stderr +++ b/src/test/ui/variance/variance-contravariant-self-trait-match.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max, G>() ... LL | impls_get::<&'min G>(); | ^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-contravariant-self-trait-match.rs:22:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>() ... LL | impls_get::<&'max G>(); | ^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-covariant-arg-object.nll.stderr b/src/test/ui/variance/variance-covariant-arg-object.nll.stderr index 63ab7fe96512d..37fdea960be7c 100644 --- a/src/test/ui/variance/variance-covariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-covariant-arg-object.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max>(v: Box>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-covariant-arg-object.rs:22:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>(v: Box>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-covariant-arg-trait-match.nll.stderr b/src/test/ui/variance/variance-covariant-arg-trait-match.nll.stderr index 33589121c4b83..a982a29d499c4 100644 --- a/src/test/ui/variance/variance-covariant-arg-trait-match.nll.stderr +++ b/src/test/ui/variance/variance-covariant-arg-trait-match.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max, G>() ... LL | impls_get::() | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-covariant-arg-trait-match.rs:20:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>() ... LL | impls_get::() | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-covariant-self-trait-match.nll.stderr b/src/test/ui/variance/variance-covariant-self-trait-match.nll.stderr index 6b2413d68be29..81b25e38ec6d8 100644 --- a/src/test/ui/variance/variance-covariant-self-trait-match.nll.stderr +++ b/src/test/ui/variance/variance-covariant-self-trait-match.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max, G>() ... LL | impls_get::<&'min G>(); | ^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-covariant-self-trait-match.rs:20:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>() ... LL | impls_get::<&'max G>(); | ^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-invariant-arg-object.nll.stderr b/src/test/ui/variance/variance-invariant-arg-object.nll.stderr index fe2f35b63b57d..f6265980af7da 100644 --- a/src/test/ui/variance/variance-invariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-invariant-arg-object.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max>(v: Box>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-invariant-arg-object.rs:18:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>(v: Box>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-invariant-arg-trait-match.nll.stderr b/src/test/ui/variance/variance-invariant-arg-trait-match.nll.stderr index 2ab44c54c7216..2909e81fcbf76 100644 --- a/src/test/ui/variance/variance-invariant-arg-trait-match.nll.stderr +++ b/src/test/ui/variance/variance-invariant-arg-trait-match.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max, G>() ... LL | impls_get::() | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-invariant-arg-trait-match.rs:16:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>() ... LL | impls_get::() | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-invariant-self-trait-match.nll.stderr b/src/test/ui/variance/variance-invariant-self-trait-match.nll.stderr index 7b7c42fea8da8..01b2c8803ae72 100644 --- a/src/test/ui/variance/variance-invariant-self-trait-match.nll.stderr +++ b/src/test/ui/variance/variance-invariant-self-trait-match.nll.stderr @@ -8,6 +8,8 @@ LL | fn get_min_from_max<'min, 'max, G>() ... LL | impls_get::<&'min G>(); | ^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-invariant-self-trait-match.rs:16:5 @@ -19,6 +21,8 @@ LL | fn get_max_from_min<'min, 'max, G>() ... LL | impls_get::<&'max G>(); | ^^^^^^^^^^^^^^^^^^^^ requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-use-contravariant-struct-1.nll.stderr b/src/test/ui/variance/variance-use-contravariant-struct-1.nll.stderr index 8468448b27bd2..eddd4b217c088 100644 --- a/src/test/ui/variance/variance-use-contravariant-struct-1.nll.stderr +++ b/src/test/ui/variance/variance-use-contravariant-struct-1.nll.stderr @@ -8,6 +8,8 @@ LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to previous error diff --git a/src/test/ui/variance/variance-use-covariant-struct-1.nll.stderr b/src/test/ui/variance/variance-use-covariant-struct-1.nll.stderr index 19a22f064beb0..a86c1b93a73b8 100644 --- a/src/test/ui/variance/variance-use-covariant-struct-1.nll.stderr +++ b/src/test/ui/variance/variance-use-covariant-struct-1.nll.stderr @@ -8,6 +8,8 @@ LL | fn foo<'min,'max>(v: SomeStruct<&'min ()>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to previous error diff --git a/src/test/ui/variance/variance-use-invariant-struct-1.nll.stderr b/src/test/ui/variance/variance-use-invariant-struct-1.nll.stderr index 61f80fe77e63d..385d83adaf830 100644 --- a/src/test/ui/variance/variance-use-invariant-struct-1.nll.stderr +++ b/src/test/ui/variance/variance-use-invariant-struct-1.nll.stderr @@ -8,6 +8,8 @@ LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: lifetime may not live long enough --> $DIR/variance-use-invariant-struct-1.rs:19:5 @@ -19,6 +21,8 @@ LL | fn bar<'min,'max>(v: SomeStruct<&'min ()>) ... LL | v | ^ returning this value requires that `'min` must outlive `'max` + | + = help: consider adding the following bound: `'min: 'max` error: aborting due to 2 previous errors diff --git a/src/test/ui/wf/wf-static-method.nll.stderr b/src/test/ui/wf/wf-static-method.nll.stderr index 338de6db18006..d031a68a51d9c 100644 --- a/src/test/ui/wf/wf-static-method.nll.stderr +++ b/src/test/ui/wf/wf-static-method.nll.stderr @@ -8,6 +8,8 @@ LL | impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { ... LL | u | ^ returning this value requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/wf-static-method.rs:26:18 @@ -19,6 +21,8 @@ LL | impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { ... LL | let me = Self::make_me(); | ^^^^^^^^^^^^^ requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/wf-static-method.rs:33:9 @@ -30,6 +34,8 @@ LL | impl<'a, 'b> Evil<'a, 'b> { LL | fn inherent_evil(u: &'b u32) -> &'a u32 { LL | u | ^ returning this value requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/wf-static-method.rs:41:5 @@ -40,6 +46,8 @@ LL | fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { | lifetime `'a` defined here LL | <()>::static_evil(b) | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/wf-static-method.rs:45:5 @@ -50,6 +58,8 @@ LL | fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 { | lifetime `'a` defined here LL | ::static_evil(b) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough --> $DIR/wf-static-method.rs:50:5 @@ -60,6 +70,8 @@ LL | fn inherent_evil<'a, 'b>(b: &'b u32) -> &'a u32 { | lifetime `'a` defined here LL | ::inherent_evil(b) // bug? shouldn't this be an error | ^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` error: aborting due to 6 previous errors