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 a6fcbdea959c..30ce17b6c6a6 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -430,7 +430,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { None }; - self.check_type_tests(infcx, mir, outlives_requirements.as_mut()); + self.check_type_tests(infcx, mir, mir_def_id, outlives_requirements.as_mut()); self.check_universal_regions(infcx, mir, mir_def_id, outlives_requirements.as_mut()); @@ -504,6 +504,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { &self, infcx: &InferCtxt<'_, 'gcx, 'tcx>, mir: &Mir<'tcx>, + mir_def_id: DefId, mut propagated_outlives_requirements: Option<&mut Vec>>, ) { let tcx = infcx.tcx; @@ -522,14 +523,56 @@ impl<'tcx> RegionInferenceContext<'tcx> { } // Oh the humanity. Obviously we will do better than this error eventually. - tcx.sess.span_err( - type_test.span, - &format!( - "`{}` does not outlive `{:?}`", + let lower_bound_region = self.to_error_region(type_test.lower_bound); + if let Some(lower_bound_region) = lower_bound_region { + let region_scope_tree = &tcx.region_scope_tree(mir_def_id); + infcx.report_generic_bound_failure( + region_scope_tree, + type_test.span, + None, type_test.generic_kind, - type_test.lower_bound, - ), - ); + lower_bound_region, + ); + } else { + // FIXME. We should handle this case better. It + // indicates that we have e.g. some region variable + // whose value is like `'a+'b` where `'a` and `'b` are + // distinct unrelated univesal regions that are not + // known to outlive one another. It'd be nice to have + // some examples where this arises to decide how best + // to report it; we could probably handle it by + // iterating over the universal regions and reporting + // an error that multiple bounds are required. + tcx.sess.span_err( + type_test.span, + &format!( + "`{}` does not live long enough", + type_test.generic_kind, + ), + ); + } + } + } + + /// Converts a region inference variable into a `ty::Region` that + /// we can use for error reporting. If `r` is universally bound, + /// then we use the name that we have on record for it. If `r` is + /// existentially bound, then we check its inferred value and try + /// to find a good name from that. Returns `None` if we can't find + /// one (e.g., this is just some random part of the CFG). + fn to_error_region(&self, r: RegionVid) -> Option> { + if self.universal_regions.is_universal_region(r) { + return self.definitions[r].external_name; + } else { + let inferred_values = self.inferred_values + .as_ref() + .expect("region values not yet inferred"); + let upper_bound = self.universal_upper_bound(r); + if inferred_values.contains(r, upper_bound) { + self.to_error_region(upper_bound) + } else { + None + } } } @@ -663,20 +706,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// encoding `T` as part of `try_promote_type_test_subject` (see /// that fn for details). /// - /// Since `r` is (potentially) an existential region, it has some - /// value which may include (a) any number of points in the CFG - /// and (b) any number of `end('x)` elements of universally - /// quantified regions. To convert this into a single universal - /// region we do as follows: - /// - /// - Ignore the CFG points in `'r`. All universally quantified regions - /// include the CFG anyhow. - /// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding - /// a result `'y`. - /// - Finally, we take the non-local upper bound of `'y`. - /// - This uses `UniversalRegions::non_local_upper_bound`, which - /// is similar to this method but only works on universal - /// regions). + /// This is based on the result `'y` of `universal_upper_bound`, + /// except that it converts further takes the non-local upper + /// bound of `'y`, so that the final result is non-local. fn non_local_universal_upper_bound(&self, r: RegionVid) -> RegionVid { let inferred_values = self.inferred_values.as_ref().unwrap(); @@ -686,14 +718,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { inferred_values.region_value_str(r) ); - // Find the smallest universal region that contains all other - // universal regions within `region`. - let mut lub = self.universal_regions.fr_fn_body; - for ur in inferred_values.universal_regions_outlived_by(r) { - lub = self.universal_regions.postdom_upper_bound(lub, ur); - } - - debug!("non_local_universal_upper_bound: lub={:?}", lub); + let lub = self.universal_upper_bound(r); // Grow further to get smallest universal region known to // creator. @@ -707,6 +732,41 @@ impl<'tcx> RegionInferenceContext<'tcx> { non_local_lub } + /// Returns a universally quantified region that outlives the + /// value of `r` (`r` may be existentially or universally + /// quantified). + /// + /// Since `r` is (potentially) an existential region, it has some + /// value which may include (a) any number of points in the CFG + /// and (b) any number of `end('x)` elements of universally + /// quantified regions. To convert this into a single universal + /// region we do as follows: + /// + /// - Ignore the CFG points in `'r`. All universally quantified regions + /// include the CFG anyhow. + /// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding + /// a result `'y`. + fn universal_upper_bound(&self, r: RegionVid) -> RegionVid { + let inferred_values = self.inferred_values.as_ref().unwrap(); + + debug!( + "universal_upper_bound(r={:?}={})", + r, + inferred_values.region_value_str(r) + ); + + // Find the smallest universal region that contains all other + // universal regions within `region`. + let mut lub = self.universal_regions.fr_fn_body; + for ur in inferred_values.universal_regions_outlived_by(r) { + lub = self.universal_regions.postdom_upper_bound(lub, ur); + } + + debug!("universal_upper_bound: r={:?} lub={:?}", r, lub); + + lub + } + /// Test if `test` is true when applied to `lower_bound` at /// `point`, and returns true or false. fn eval_region_test( @@ -924,8 +984,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { ) { // Obviously uncool error reporting. - let fr_name = self.definitions[fr].external_name; - let outlived_fr_name = self.definitions[outlived_fr].external_name; + let fr_name = self.to_error_region(fr); + let outlived_fr_name = self.to_error_region(outlived_fr); if let (Some(f), Some(o)) = (fr_name, outlived_fr_name) { let tables = infcx.tcx.typeck_tables_of(mir_def_id); diff --git a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs index 604c81da49db..91796355752a 100644 --- a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs +++ b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs @@ -40,7 +40,7 @@ where T: Trait<'a>, { establish_relationships(value, |value| { - //~^ ERROR `T` does not outlive + //~^ ERROR the parameter type `T` may not live long enough // This function call requires that // diff --git a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr index efac55f2beea..aefa160fcbc9 100644 --- a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -9,7 +9,7 @@ note: External requirements | 42 | establish_relationships(value, |value| { | ____________________________________^ -43 | | //~^ ERROR `T` does not outlive +43 | | //~^ ERROR the parameter type `T` may not live long enough 44 | | 45 | | // This function call requires that ... | @@ -26,18 +26,20 @@ note: External requirements = note: number of external vids: 2 = note: where T: '_#1r -error: `T` does not outlive `'_#3r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/propagate-from-trait-match.rs:42:36 | 42 | establish_relationships(value, |value| { | ____________________________________^ -43 | | //~^ ERROR `T` does not outlive +43 | | //~^ ERROR the parameter type `T` may not live long enough 44 | | 45 | | // This function call requires that ... | 56 | | //~^ WARNING not reporting region error due to -Znll 57 | | }); | |_____^ + | + = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... note: No external requirements --> $DIR/propagate-from-trait-match.rs:38:1 diff --git a/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs b/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs index c03ec839808b..135805a73394 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs +++ b/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs @@ -21,7 +21,7 @@ where T: Debug, { x - //~^ ERROR `T` does not outlive + //~^ ERROR the parameter type `T` may not live long enough [E0309] } fn correct_region<'a, T>(x: Box) -> impl Debug + 'a @@ -37,7 +37,7 @@ where T: 'b + Debug, { x - //~^ ERROR `T` does not outlive + //~^ ERROR the parameter type `T` may not live long enough [E0309] } fn outlives_region<'a, 'b, T>(x: Box) -> impl Debug + 'a diff --git a/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr b/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr index 4ebd2c7fc434..5916d0060a02 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr +++ b/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr @@ -10,17 +10,21 @@ warning: not reporting region error due to -Znll 34 | fn wrong_region<'a, 'b, T>(x: Box) -> impl Debug + 'a | ^^^^^^^^^^^^^^^ -error: `T` does not outlive `'_#1r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/impl-trait-outlives.rs:23:5 | 23 | x | ^ + | + = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... -error: `T` does not outlive `'_#1r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/impl-trait-outlives.rs:39:5 | 39 | x | ^ + | + = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs b/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs index 9a7c2838cde2..0ec6d7b74ad5 100644 --- a/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs +++ b/src/test/ui/nll/ty-outlives/projection-implied-bounds.rs @@ -44,7 +44,7 @@ where fn generic2(value: T) { twice(value, |value_ref, item| invoke2(value_ref, item)); //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| ERROR the parameter type `T` may not live long enough } fn invoke2<'a, T, U>(a: &T, b: Cell<&'a Option>) diff --git a/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr b/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr index 6cdf1b6f0a21..a49bdbbf09ed 100644 --- a/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr +++ b/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr @@ -4,11 +4,13 @@ warning: not reporting region error due to -Znll 45 | twice(value, |value_ref, item| invoke2(value_ref, item)); | ^^^^^^^ -error: `T` does not outlive `'_#0r` +error[E0310]: the parameter type `T` may not live long enough --> $DIR/projection-implied-bounds.rs:45:18 | 45 | twice(value, |value_ref, item| invoke2(value_ref, item)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs index 9451163ace99..0493bd1ea0d9 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs @@ -35,7 +35,7 @@ where { with_signature(x, |mut y| Box::new(y.next())) //~^ WARNING not reporting region error due to -Znll - //~| ERROR `::Item` does not outlive + //~| ERROR the associated type `::Item` may not live long enough } #[rustc_regions] @@ -53,7 +53,7 @@ where { with_signature(x, |mut y| Box::new(y.next())) //~^ WARNING not reporting region error due to -Znll - //~| ERROR `::Item` does not outlive + //~| ERROR the associated type `::Item` may not live long enough } #[rustc_regions] diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr index 9afd5d41182f..b2e98b7c2f6a 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -72,11 +72,13 @@ note: External requirements = note: number of external vids: 4 = note: where ::Item: '_#3r -error: `::Item` does not outlive `'_#4r` +error[E0309]: the associated type `::Item` may not live long enough --> $DIR/projection-no-regions-closure.rs:36:23 | 36 | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: ReEarlyBound(0, 'a)`... note: No external requirements --> $DIR/projection-no-regions-closure.rs:32:1 @@ -86,7 +88,7 @@ note: No external requirements 34 | | T: Iterator, 35 | | { ... | -38 | | //~| ERROR `::Item` does not outlive +38 | | //~| ERROR the associated type `::Item` may not live long enough 39 | | } | |_^ | @@ -111,11 +113,13 @@ note: No external requirements T ] -error: `::Item` does not outlive `'_#6r` +error[E0309]: the associated type `::Item` may not live long enough --> $DIR/projection-no-regions-closure.rs:54:23 | 54 | with_signature(x, |mut y| Box::new(y.next())) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: ReEarlyBound(0, 'a)`... note: No external requirements --> $DIR/projection-no-regions-closure.rs:50:1 @@ -125,7 +129,7 @@ note: No external requirements 52 | | T: 'b + Iterator, 53 | | { ... | -56 | | //~| ERROR `::Item` does not outlive +56 | | //~| ERROR the associated type `::Item` may not live long enough 57 | | } | |_^ | diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-fn.rs b/src/test/ui/nll/ty-outlives/projection-no-regions-fn.rs index c815fdc1a0c5..5f2e84e247a3 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-fn.rs +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-fn.rs @@ -23,7 +23,7 @@ where { Box::new(x.next()) //~^ WARNING not reporting region error due to -Znll - //~| ERROR `::Item` does not outlive + //~| the associated type `::Item` may not live long enough } fn correct_region<'a, T>(mut x: T) -> Box @@ -39,7 +39,7 @@ where { Box::new(x.next()) //~^ WARNING not reporting region error due to -Znll - //~| ERROR `::Item` does not outlive + //~| the associated type `::Item` may not live long enough } fn outlives_region<'a, 'b, T>(mut x: T) -> Box diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-fn.stderr b/src/test/ui/nll/ty-outlives/projection-no-regions-fn.stderr index 4d13972641c1..d309bf2ce6ca 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-fn.stderr +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-fn.stderr @@ -10,17 +10,21 @@ warning: not reporting region error due to -Znll 40 | Box::new(x.next()) | ^^^^^^^^^^^^^^^^^^ -error: `::Item` does not outlive `'_#4r` +error[E0309]: the associated type `::Item` may not live long enough --> $DIR/projection-no-regions-fn.rs:24:5 | 24 | Box::new(x.next()) | ^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: ReEarlyBound(0, 'a)`... -error: `::Item` does not outlive `'_#5r` +error[E0309]: the associated type `::Item` may not live long enough --> $DIR/projection-no-regions-fn.rs:40:5 | 40 | Box::new(x.next()) | ^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: ReEarlyBound(0, 'a)`... error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs b/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs index 5d68cc6a7a9f..9a5e04deddfc 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs @@ -55,7 +55,7 @@ where { with_signature(cell, t, |cell, t| require(cell, t)); //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| ERROR the parameter type `T` may not live long enough //~| ERROR does not outlive free region } @@ -67,7 +67,7 @@ where { with_signature(cell, t, |cell, t| require(cell, t)); //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| ERROR the parameter type `T` may not live long enough //~| ERROR does not outlive free region } @@ -89,7 +89,7 @@ where with_signature(cell, t, |cell, t| require(cell, t)); //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| ERROR the parameter type `T` may not live long enough //~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)` } 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 73cfa0d18fa4..e57a39a9de96 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 @@ -83,11 +83,13 @@ note: External requirements = note: where T: '_#3r = note: where '_#2r: '_#3r -error: `T` does not outlive `'_#5r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:56:29 | 56 | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: ReFree(DefId(0/0:8 ~ projection_one_region_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:17), 'a))`... error: free region `ReEarlyBound(0, 'b)` does not outlive free region `ReFree(DefId(0/0:8 ~ projection_one_region_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:17), 'a))` --> $DIR/projection-one-region-closure.rs:56:20 @@ -112,11 +114,13 @@ note: No external requirements T ] -error: `T` does not outlive `'_#6r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:68:29 | 68 | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... error: free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)` --> $DIR/projection-one-region-closure.rs:68:20 @@ -142,11 +146,13 @@ note: No external requirements T ] -error: `T` does not outlive `'_#6r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:90:29 | 90 | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... error: free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)` --> $DIR/projection-one-region-closure.rs:90:20 diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs index e129ac146fcf..e3cee00ed4eb 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs @@ -48,7 +48,7 @@ where { with_signature(cell, t, |cell, t| require(cell, t)); //~^ WARNING not reporting region error due to -Znll - //~| ERROR `>::AssocType` does not outlive `'_#7r` + //~| ERROR associated type `>::AssocType` may not live long enough } #[rustc_regions] @@ -59,7 +59,7 @@ where { with_signature(cell, t, |cell, t| require(cell, t)); //~^ WARNING not reporting region error due to -Znll - //~| ERROR `>::AssocType` does not outlive `'_#8r` + //~| ERROR associated type `>::AssocType` may not live long enough } #[rustc_regions] @@ -80,7 +80,7 @@ where with_signature(cell, t, |cell, t| require(cell, t)); //~^ WARNING not reporting region error due to -Znll - //~| ERROR `>::AssocType` does not outlive `'_#8r` + //~| ERROR associated type `>::AssocType` may not live long enough } #[rustc_regions] 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 b26cf2ca4cb2..414ae38080f6 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 @@ -152,11 +152,13 @@ note: External requirements = note: number of external vids: 3 = note: where >::AssocType: '_#2r -error: `>::AssocType` does not outlive `'_#7r` +error[E0309]: the associated type `>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:49:29 | 49 | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `>::AssocType: ReFree(DefId(0/0:8 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:19), 'a))`... note: No external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:45:1 @@ -166,7 +168,7 @@ note: No external requirements 47 | | T: Anything<'b, 'c>, 48 | | { ... | -51 | | //~| ERROR `>::AssocType` does not outlive `'_#7r` +51 | | //~| ERROR associated type `>::AssocType` may not live long enough 52 | | } | |_^ | @@ -176,11 +178,13 @@ note: No external requirements T ] -error: `>::AssocType` does not outlive `'_#8r` +error[E0309]: the associated type `>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:60:29 | 60 | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `>::AssocType: ReEarlyBound(0, 'a)`... note: No external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:55:1 @@ -190,7 +194,7 @@ note: No external requirements 57 | | T: Anything<'b, 'c>, 58 | | 'a: 'a, ... | -62 | | //~| ERROR `>::AssocType` does not outlive `'_#8r` +62 | | //~| ERROR associated type `>::AssocType` may not live long enough 63 | | } | |_^ | @@ -201,11 +205,13 @@ note: No external requirements T ] -error: `>::AssocType` does not outlive `'_#8r` +error[E0309]: the associated type `>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:81:29 | 81 | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `>::AssocType: ReEarlyBound(0, 'a)`... note: No external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:66:1 @@ -215,7 +221,7 @@ note: No external requirements 68 | | T: Anything<'b, 'c>, 69 | | T::AssocType: 'a, ... | -83 | | //~| ERROR `>::AssocType` does not outlive `'_#8r` +83 | | //~| ERROR associated type `>::AssocType` may not live long enough 84 | | } | |_^ | diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs index d632bc8d0f60..423747a6bd6c 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs @@ -43,7 +43,7 @@ fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { twice(cell, value, |a, b| invoke(a, b)); //~^ WARNING not reporting region error //~| WARNING not reporting region error - //~| ERROR `T` does not outlive + //~| ERROR the parameter type `T` may not live long enough } fn invoke<'a, 'x, T>(x: Option>, y: &T) diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index f6ca614ea38d..ef564377e506 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -60,11 +60,13 @@ note: No external requirements T ] -error: `T` does not outlive `'_#3r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-approximate-lower-bound.rs:43:24 | 43 | twice(cell, value, |a, b| invoke(a, b)); | ^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: ReFree(DefId(0/0:6 ~ ty_param_closure_approximate_lower_bound[317d]::generic_fail[0]), BrNamed(crate0:DefIndex(1:16), 'a))`... note: No external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:42:1 @@ -73,7 +75,7 @@ note: No external requirements 43 | | twice(cell, value, |a, b| invoke(a, b)); 44 | | //~^ WARNING not reporting region error 45 | | //~| WARNING not reporting region error -46 | | //~| ERROR `T` does not outlive +46 | | //~| ERROR the parameter type `T` may not live long enough 47 | | } | |_^ | diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs index 14e2eb26976a..95a483b3c355 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs @@ -36,7 +36,7 @@ where with_signature(x, |y| y) //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| ERROR the parameter type `T` may not live long enough } fn correct_region<'a, T>(x: Box) -> Box @@ -52,7 +52,7 @@ where { x //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| ERROR the parameter type `T` may not live long enough } fn outlives_region<'a, 'b, T>(x: Box) -> Box diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index 37ebc38da4da..b7120017a2c0 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -25,11 +25,13 @@ note: External requirements = note: number of external vids: 3 = note: where T: '_#2r -error: `T` does not outlive `'_#4r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-return-type.rs:37:23 | 37 | with_signature(x, |y| y) | ^^^^^ + | + = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... note: No external requirements --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:1 @@ -39,7 +41,7 @@ note: No external requirements 28 | | T: Debug, 29 | | { ... | -39 | | //~| ERROR `T` does not outlive +39 | | //~| ERROR the parameter type `T` may not live long enough 40 | | } | |_^ | @@ -48,11 +50,13 @@ note: No external requirements T ] -error: `T` does not outlive `'_#4r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-return-type.rs:53:5 | 53 | x | ^ + | + = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs index beed1a740eac..1149f250a46e 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs @@ -36,7 +36,7 @@ where #[rustc_regions] fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { with_signature(a, b, |x, y| { - //~^ ERROR `T` does not outlive + //~^ ERROR the parameter type `T` may not live long enough // // See `correct_region`, which explains the point of this // test. The only difference is that, in the case of this @@ -74,7 +74,7 @@ where T: 'b, { with_signature(a, b, |x, y| { - //~^ ERROR `T` does not outlive + //~^ ERROR the parameter type `T` may not live long enough // See `correct_region` require(&x, &y) //~^ WARNING not reporting region error due to -Znll diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index 78445eb47c32..d47f506cd204 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -15,7 +15,7 @@ note: External requirements | 38 | with_signature(a, b, |x, y| { | __________________________^ -39 | | //~^ ERROR `T` does not outlive +39 | | //~^ ERROR the parameter type `T` may not live long enough 40 | | // 41 | | // See `correct_region`, which explains the point of this ... | @@ -58,7 +58,7 @@ note: External requirements | 76 | with_signature(a, b, |x, y| { | __________________________^ -77 | | //~^ ERROR `T` does not outlive +77 | | //~^ ERROR the parameter type `T` may not live long enough 78 | | // See `correct_region` 79 | | require(&x, &y) 80 | | //~^ WARNING not reporting region error due to -Znll @@ -94,25 +94,27 @@ note: External requirements = note: number of external vids: 4 = note: where T: '_#3r -error: `T` does not outlive `'_#3r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:38:26 | 38 | with_signature(a, b, |x, y| { | __________________________^ -39 | | //~^ ERROR `T` does not outlive +39 | | //~^ ERROR the parameter type `T` may not live long enough 40 | | // 41 | | // See `correct_region`, which explains the point of this ... | 46 | | //~^ WARNING not reporting region error due to -Znll 47 | | }) | |_____^ + | + = help: consider adding an explicit lifetime bound `T: ReFree(DefId(0/0:6 ~ ty_param_closure_outlives_from_where_clause[317d]::no_region[0]), BrNamed(crate0:DefIndex(1:15), 'a))`... note: No external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:37:1 | 37 | / fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { 38 | | with_signature(a, b, |x, y| { -39 | | //~^ ERROR `T` does not outlive +39 | | //~^ ERROR the parameter type `T` may not live long enough 40 | | // ... | 47 | | }) @@ -140,17 +142,19 @@ note: No external requirements T ] -error: `T` does not outlive `'_#5r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:76:26 | 76 | with_signature(a, b, |x, y| { | __________________________^ -77 | | //~^ ERROR `T` does not outlive +77 | | //~^ ERROR the parameter type `T` may not live long enough 78 | | // See `correct_region` 79 | | require(&x, &y) 80 | | //~^ WARNING not reporting region error due to -Znll 81 | | }) | |_____^ + | + = help: consider adding an explicit lifetime bound `T: ReFree(DefId(0/0:8 ~ ty_param_closure_outlives_from_where_clause[317d]::wrong_region[0]), BrNamed(crate0:DefIndex(1:21), 'a))`... note: No external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:72:1 diff --git a/src/test/ui/nll/ty-outlives/ty-param-fn-body.rs b/src/test/ui/nll/ty-outlives/ty-param-fn-body.rs index a1e636cbc444..e66c1853b64b 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-fn-body.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-fn-body.rs @@ -29,7 +29,7 @@ fn region_within_body(t: T) { fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) { outlives(cell, t) //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| ERROR the parameter type `T` may not live long enough } fn outlives<'a, T>(x: Cell<&'a usize>, y: T) diff --git a/src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr b/src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr index bbe55c52b6ed..3334f4ecc7c8 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr @@ -4,11 +4,13 @@ warning: not reporting region error due to -Znll 30 | outlives(cell, t) | ^^^^^^^^ -error: `T` does not outlive `'_#4r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn-body.rs:30:5 | 30 | outlives(cell, t) | ^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'a`... error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/ty-param-fn.rs b/src/test/ui/nll/ty-outlives/ty-param-fn.rs index 76783af4ceb0..aa3a03afa35c 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-fn.rs +++ b/src/test/ui/nll/ty-outlives/ty-param-fn.rs @@ -21,7 +21,7 @@ where { x //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| the parameter type `T` may not live long enough } fn correct_region<'a, T>(x: Box) -> Box @@ -37,7 +37,7 @@ where { x //~^ WARNING not reporting region error due to -Znll - //~| ERROR `T` does not outlive + //~| the parameter type `T` may not live long enough } fn outlives_region<'a, 'b, T>(x: Box) -> Box diff --git a/src/test/ui/nll/ty-outlives/ty-param-fn.stderr b/src/test/ui/nll/ty-outlives/ty-param-fn.stderr index 02c4ebbd5aca..1e659e2e9f07 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-fn.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-fn.stderr @@ -10,17 +10,21 @@ warning: not reporting region error due to -Znll 38 | x | ^ -error: `T` does not outlive `'_#3r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn.rs:22:5 | 22 | x | ^ + | + = help: consider adding an explicit lifetime bound `T: 'a`... -error: `T` does not outlive `'_#4r` +error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn.rs:38:5 | 38 | x | ^ + | + = help: consider adding an explicit lifetime bound `T: 'a`... error: aborting due to 2 previous errors