Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dbb21b3

Browse files
committedDec 20, 2017
use report_generic_bound_failure when we can in the compiler
1 parent 5274e29 commit dbb21b3

25 files changed

+189
-85
lines changed
 

‎src/librustc_mir/borrow_check/nll/region_infer/mod.rs

+87-27
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
430430
None
431431
};
432432

433-
self.check_type_tests(infcx, mir, outlives_requirements.as_mut());
433+
self.check_type_tests(infcx, mir, mir_def_id, outlives_requirements.as_mut());
434434

435435
self.check_universal_regions(infcx, mir, mir_def_id, outlives_requirements.as_mut());
436436

@@ -504,6 +504,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
504504
&self,
505505
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
506506
mir: &Mir<'tcx>,
507+
mir_def_id: DefId,
507508
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
508509
) {
509510
let tcx = infcx.tcx;
@@ -522,14 +523,56 @@ impl<'tcx> RegionInferenceContext<'tcx> {
522523
}
523524

524525
// Oh the humanity. Obviously we will do better than this error eventually.
525-
tcx.sess.span_err(
526-
type_test.span,
527-
&format!(
528-
"`{}` does not outlive `{:?}`",
526+
let lower_bound_region = self.to_error_region(type_test.lower_bound);
527+
if let Some(lower_bound_region) = lower_bound_region {
528+
let region_scope_tree = &tcx.region_scope_tree(mir_def_id);
529+
infcx.report_generic_bound_failure(
530+
region_scope_tree,
531+
type_test.span,
532+
None,
529533
type_test.generic_kind,
530-
type_test.lower_bound,
531-
),
532-
);
534+
lower_bound_region,
535+
);
536+
} else {
537+
// FIXME. We should handle this case better. It
538+
// indicates that we have e.g. some region variable
539+
// whose value is like `'a+'b` where `'a` and `'b` are
540+
// distinct unrelated univesal regions that are not
541+
// known to outlive one another. It'd be nice to have
542+
// some examples where this arises to decide how best
543+
// to report it; we could probably handle it by
544+
// iterating over the universal regions and reporting
545+
// an error that multiple bounds are required.
546+
tcx.sess.span_err(
547+
type_test.span,
548+
&format!(
549+
"`{}` does not live long enough",
550+
type_test.generic_kind,
551+
),
552+
);
553+
}
554+
}
555+
}
556+
557+
/// Converts a region inference variable into a `ty::Region` that
558+
/// we can use for error reporting. If `r` is universally bound,
559+
/// then we use the name that we have on record for it. If `r` is
560+
/// existentially bound, then we check its inferred value and try
561+
/// to find a good name from that. Returns `None` if we can't find
562+
/// one (e.g., this is just some random part of the CFG).
563+
fn to_error_region(&self, r: RegionVid) -> Option<ty::Region<'tcx>> {
564+
if self.universal_regions.is_universal_region(r) {
565+
return self.definitions[r].external_name;
566+
} else {
567+
let inferred_values = self.inferred_values
568+
.as_ref()
569+
.expect("region values not yet inferred");
570+
let upper_bound = self.universal_upper_bound(r);
571+
if inferred_values.contains(r, upper_bound) {
572+
self.to_error_region(upper_bound)
573+
} else {
574+
None
575+
}
533576
}
534577
}
535578

@@ -663,6 +706,36 @@ impl<'tcx> RegionInferenceContext<'tcx> {
663706
/// encoding `T` as part of `try_promote_type_test_subject` (see
664707
/// that fn for details).
665708
///
709+
/// This is based on the result `'y` of `universal_upper_bound`,
710+
/// except that it converts further takes the non-local upper
711+
/// bound of `'y`, so that the final result is non-local.
712+
fn non_local_universal_upper_bound(&self, r: RegionVid) -> RegionVid {
713+
let inferred_values = self.inferred_values.as_ref().unwrap();
714+
715+
debug!(
716+
"non_local_universal_upper_bound(r={:?}={})",
717+
r,
718+
inferred_values.region_value_str(r)
719+
);
720+
721+
let lub = self.universal_upper_bound(r);
722+
723+
// Grow further to get smallest universal region known to
724+
// creator.
725+
let non_local_lub = self.universal_regions.non_local_upper_bound(lub);
726+
727+
debug!(
728+
"non_local_universal_upper_bound: non_local_lub={:?}",
729+
non_local_lub
730+
);
731+
732+
non_local_lub
733+
}
734+
735+
/// Returns a universally quantified region that outlives the
736+
/// value of `r` (`r` may be existentially or universally
737+
/// quantified).
738+
///
666739
/// Since `r` is (potentially) an existential region, it has some
667740
/// value which may include (a) any number of points in the CFG
668741
/// and (b) any number of `end('x)` elements of universally
@@ -673,15 +746,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
673746
/// include the CFG anyhow.
674747
/// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding
675748
/// a result `'y`.
676-
/// - Finally, we take the non-local upper bound of `'y`.
677-
/// - This uses `UniversalRegions::non_local_upper_bound`, which
678-
/// is similar to this method but only works on universal
679-
/// regions).
680-
fn non_local_universal_upper_bound(&self, r: RegionVid) -> RegionVid {
749+
fn universal_upper_bound(&self, r: RegionVid) -> RegionVid {
681750
let inferred_values = self.inferred_values.as_ref().unwrap();
682751

683752
debug!(
684-
"non_local_universal_upper_bound(r={:?}={})",
753+
"universal_upper_bound(r={:?}={})",
685754
r,
686755
inferred_values.region_value_str(r)
687756
);
@@ -693,18 +762,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
693762
lub = self.universal_regions.postdom_upper_bound(lub, ur);
694763
}
695764

696-
debug!("non_local_universal_upper_bound: lub={:?}", lub);
697-
698-
// Grow further to get smallest universal region known to
699-
// creator.
700-
let non_local_lub = self.universal_regions.non_local_upper_bound(lub);
765+
debug!("universal_upper_bound: r={:?} lub={:?}", r, lub);
701766

702-
debug!(
703-
"non_local_universal_upper_bound: non_local_lub={:?}",
704-
non_local_lub
705-
);
706-
707-
non_local_lub
767+
lub
708768
}
709769

710770
/// Test if `test` is true when applied to `lower_bound` at
@@ -924,8 +984,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
924984
) {
925985
// Obviously uncool error reporting.
926986

927-
let fr_name = self.definitions[fr].external_name;
928-
let outlived_fr_name = self.definitions[outlived_fr].external_name;
987+
let fr_name = self.to_error_region(fr);
988+
let outlived_fr_name = self.to_error_region(outlived_fr);
929989

930990
if let (Some(f), Some(o)) = (fr_name, outlived_fr_name) {
931991
let tables = infcx.tcx.typeck_tables_of(mir_def_id);

‎src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ where
4040
T: Trait<'a>,
4141
{
4242
establish_relationships(value, |value| {
43-
//~^ ERROR `T` does not outlive
43+
//~^ ERROR the parameter type `T` may not live long enough
4444

4545
// This function call requires that
4646
//

‎src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ note: External requirements
99
|
1010
42 | establish_relationships(value, |value| {
1111
| ____________________________________^
12-
43 | | //~^ ERROR `T` does not outlive
12+
43 | | //~^ ERROR the parameter type `T` may not live long enough
1313
44 | |
1414
45 | | // This function call requires that
1515
... |
@@ -26,18 +26,20 @@ note: External requirements
2626
= note: number of external vids: 2
2727
= note: where T: '_#1r
2828

29-
error: `T` does not outlive `'_#3r`
29+
error[E0309]: the parameter type `T` may not live long enough
3030
--> $DIR/propagate-from-trait-match.rs:42:36
3131
|
3232
42 | establish_relationships(value, |value| {
3333
| ____________________________________^
34-
43 | | //~^ ERROR `T` does not outlive
34+
43 | | //~^ ERROR the parameter type `T` may not live long enough
3535
44 | |
3636
45 | | // This function call requires that
3737
... |
3838
56 | | //~^ WARNING not reporting region error due to -Znll
3939
57 | | });
4040
| |_____^
41+
|
42+
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
4143

4244
note: No external requirements
4345
--> $DIR/propagate-from-trait-match.rs:38:1

‎src/test/ui/nll/ty-outlives/impl-trait-outlives.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
T: Debug,
2222
{
2323
x
24-
//~^ ERROR `T` does not outlive
24+
//~^ ERROR the parameter type `T` may not live long enough [E0309]
2525
}
2626

2727
fn correct_region<'a, T>(x: Box<T>) -> impl Debug + 'a
@@ -37,7 +37,7 @@ where
3737
T: 'b + Debug,
3838
{
3939
x
40-
//~^ ERROR `T` does not outlive
40+
//~^ ERROR the parameter type `T` may not live long enough [E0309]
4141
}
4242

4343
fn outlives_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a

‎src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ warning: not reporting region error due to -Znll
1010
34 | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a
1111
| ^^^^^^^^^^^^^^^
1212

13-
error: `T` does not outlive `'_#1r`
13+
error[E0309]: the parameter type `T` may not live long enough
1414
--> $DIR/impl-trait-outlives.rs:23:5
1515
|
1616
23 | x
1717
| ^
18+
|
19+
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
1820

19-
error: `T` does not outlive `'_#1r`
21+
error[E0309]: the parameter type `T` may not live long enough
2022
--> $DIR/impl-trait-outlives.rs:39:5
2123
|
2224
39 | x
2325
| ^
26+
|
27+
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
2428

2529
error: aborting due to 2 previous errors
2630

‎src/test/ui/nll/ty-outlives/projection-implied-bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ where
4444
fn generic2<T: Iterator>(value: T) {
4545
twice(value, |value_ref, item| invoke2(value_ref, item));
4646
//~^ WARNING not reporting region error due to -Znll
47-
//~| ERROR `T` does not outlive
47+
//~| ERROR the parameter type `T` may not live long enough
4848
}
4949

5050
fn invoke2<'a, T, U>(a: &T, b: Cell<&'a Option<U>>)

‎src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ warning: not reporting region error due to -Znll
44
45 | twice(value, |value_ref, item| invoke2(value_ref, item));
55
| ^^^^^^^
66

7-
error: `T` does not outlive `'_#0r`
7+
error[E0310]: the parameter type `T` may not live long enough
88
--> $DIR/projection-implied-bounds.rs:45:18
99
|
1010
45 | twice(value, |value_ref, item| invoke2(value_ref, item));
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
|
13+
= help: consider adding an explicit lifetime bound `T: 'static`...
1214

1315
error: aborting due to previous error
1416

‎src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ where
3535
{
3636
with_signature(x, |mut y| Box::new(y.next()))
3737
//~^ WARNING not reporting region error due to -Znll
38-
//~| ERROR `<T as std::iter::Iterator>::Item` does not outlive
38+
//~| ERROR the associated type `<T as std::iter::Iterator>::Item` may not live long enough
3939
}
4040

4141
#[rustc_regions]
@@ -53,7 +53,7 @@ where
5353
{
5454
with_signature(x, |mut y| Box::new(y.next()))
5555
//~^ WARNING not reporting region error due to -Znll
56-
//~| ERROR `<T as std::iter::Iterator>::Item` does not outlive
56+
//~| ERROR the associated type `<T as std::iter::Iterator>::Item` may not live long enough
5757
}
5858

5959
#[rustc_regions]

‎src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr

+8-4
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ note: External requirements
7272
= note: number of external vids: 4
7373
= note: where <T as std::iter::Iterator>::Item: '_#3r
7474

75-
error: `<T as std::iter::Iterator>::Item` does not outlive `'_#4r`
75+
error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
7676
--> $DIR/projection-no-regions-closure.rs:36:23
7777
|
7878
36 | with_signature(x, |mut y| Box::new(y.next()))
7979
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
80+
|
81+
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...
8082

8183
note: No external requirements
8284
--> $DIR/projection-no-regions-closure.rs:32:1
@@ -86,7 +88,7 @@ note: No external requirements
8688
34 | | T: Iterator,
8789
35 | | {
8890
... |
89-
38 | | //~| ERROR `<T as std::iter::Iterator>::Item` does not outlive
91+
38 | | //~| ERROR the associated type `<T as std::iter::Iterator>::Item` may not live long enough
9092
39 | | }
9193
| |_^
9294
|
@@ -111,11 +113,13 @@ note: No external requirements
111113
T
112114
]
113115

114-
error: `<T as std::iter::Iterator>::Item` does not outlive `'_#6r`
116+
error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
115117
--> $DIR/projection-no-regions-closure.rs:54:23
116118
|
117119
54 | with_signature(x, |mut y| Box::new(y.next()))
118120
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
121+
|
122+
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...
119123

120124
note: No external requirements
121125
--> $DIR/projection-no-regions-closure.rs:50:1
@@ -125,7 +129,7 @@ note: No external requirements
125129
52 | | T: 'b + Iterator,
126130
53 | | {
127131
... |
128-
56 | | //~| ERROR `<T as std::iter::Iterator>::Item` does not outlive
132+
56 | | //~| ERROR the associated type `<T as std::iter::Iterator>::Item` may not live long enough
129133
57 | | }
130134
| |_^
131135
|

‎src/test/ui/nll/ty-outlives/projection-no-regions-fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ where
2323
{
2424
Box::new(x.next())
2525
//~^ WARNING not reporting region error due to -Znll
26-
//~| ERROR `<T as std::iter::Iterator>::Item` does not outlive
26+
//~| the associated type `<T as std::iter::Iterator>::Item` may not live long enough
2727
}
2828

2929
fn correct_region<'a, T>(mut x: T) -> Box<dyn Anything + 'a>
@@ -39,7 +39,7 @@ where
3939
{
4040
Box::new(x.next())
4141
//~^ WARNING not reporting region error due to -Znll
42-
//~| ERROR `<T as std::iter::Iterator>::Item` does not outlive
42+
//~| the associated type `<T as std::iter::Iterator>::Item` may not live long enough
4343
}
4444

4545
fn outlives_region<'a, 'b, T>(mut x: T) -> Box<dyn Anything + 'a>

‎src/test/ui/nll/ty-outlives/projection-no-regions-fn.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ warning: not reporting region error due to -Znll
1010
40 | Box::new(x.next())
1111
| ^^^^^^^^^^^^^^^^^^
1212

13-
error: `<T as std::iter::Iterator>::Item` does not outlive `'_#4r`
13+
error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
1414
--> $DIR/projection-no-regions-fn.rs:24:5
1515
|
1616
24 | Box::new(x.next())
1717
| ^^^^^^^^^^^^^^^^^^
18+
|
19+
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...
1820

19-
error: `<T as std::iter::Iterator>::Item` does not outlive `'_#5r`
21+
error[E0309]: the associated type `<T as std::iter::Iterator>::Item` may not live long enough
2022
--> $DIR/projection-no-regions-fn.rs:40:5
2123
|
2224
40 | Box::new(x.next())
2325
| ^^^^^^^^^^^^^^^^^^
26+
|
27+
= help: consider adding an explicit lifetime bound `<T as std::iter::Iterator>::Item: ReEarlyBound(0, 'a)`...
2428

2529
error: aborting due to 2 previous errors
2630

‎src/test/ui/nll/ty-outlives/projection-one-region-closure.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ where
5555
{
5656
with_signature(cell, t, |cell, t| require(cell, t));
5757
//~^ WARNING not reporting region error due to -Znll
58-
//~| ERROR `T` does not outlive
58+
//~| ERROR the parameter type `T` may not live long enough
5959
//~| ERROR does not outlive free region
6060
}
6161

@@ -67,7 +67,7 @@ where
6767
{
6868
with_signature(cell, t, |cell, t| require(cell, t));
6969
//~^ WARNING not reporting region error due to -Znll
70-
//~| ERROR `T` does not outlive
70+
//~| ERROR the parameter type `T` may not live long enough
7171
//~| ERROR does not outlive free region
7272
}
7373

@@ -89,7 +89,7 @@ where
8989

9090
with_signature(cell, t, |cell, t| require(cell, t));
9191
//~^ WARNING not reporting region error due to -Znll
92-
//~| ERROR `T` does not outlive
92+
//~| ERROR the parameter type `T` may not live long enough
9393
//~| ERROR free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
9494
}
9595

‎src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr

+9-3
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ note: External requirements
8383
= note: where T: '_#3r
8484
= note: where '_#2r: '_#3r
8585

86-
error: `T` does not outlive `'_#5r`
86+
error[E0309]: the parameter type `T` may not live long enough
8787
--> $DIR/projection-one-region-closure.rs:56:29
8888
|
8989
56 | with_signature(cell, t, |cell, t| require(cell, t));
9090
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
91+
|
92+
= 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))`...
9193

9294
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))`
9395
--> $DIR/projection-one-region-closure.rs:56:20
@@ -112,11 +114,13 @@ note: No external requirements
112114
T
113115
]
114116

115-
error: `T` does not outlive `'_#6r`
117+
error[E0309]: the parameter type `T` may not live long enough
116118
--> $DIR/projection-one-region-closure.rs:68:29
117119
|
118120
68 | with_signature(cell, t, |cell, t| require(cell, t));
119121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
122+
|
123+
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
120124

121125
error: free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
122126
--> $DIR/projection-one-region-closure.rs:68:20
@@ -142,11 +146,13 @@ note: No external requirements
142146
T
143147
]
144148

145-
error: `T` does not outlive `'_#6r`
149+
error[E0309]: the parameter type `T` may not live long enough
146150
--> $DIR/projection-one-region-closure.rs:90:29
147151
|
148152
90 | with_signature(cell, t, |cell, t| require(cell, t));
149153
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
154+
|
155+
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
150156

151157
error: free region `ReEarlyBound(1, 'b)` does not outlive free region `ReEarlyBound(0, 'a)`
152158
--> $DIR/projection-one-region-closure.rs:90:20

‎src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ where
4848
{
4949
with_signature(cell, t, |cell, t| require(cell, t));
5050
//~^ WARNING not reporting region error due to -Znll
51-
//~| ERROR `<T as Anything<'_#5r, '_#6r>>::AssocType` does not outlive `'_#7r`
51+
//~| ERROR associated type `<T as Anything<'_#5r, '_#6r>>::AssocType` may not live long enough
5252
}
5353

5454
#[rustc_regions]
@@ -59,7 +59,7 @@ where
5959
{
6060
with_signature(cell, t, |cell, t| require(cell, t));
6161
//~^ WARNING not reporting region error due to -Znll
62-
//~| ERROR `<T as Anything<'_#6r, '_#7r>>::AssocType` does not outlive `'_#8r`
62+
//~| ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
6363
}
6464

6565
#[rustc_regions]
@@ -80,7 +80,7 @@ where
8080

8181
with_signature(cell, t, |cell, t| require(cell, t));
8282
//~^ WARNING not reporting region error due to -Znll
83-
//~| ERROR `<T as Anything<'_#6r, '_#7r>>::AssocType` does not outlive `'_#8r`
83+
//~| ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
8484
}
8585

8686
#[rustc_regions]

‎src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr

+12-6
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ note: External requirements
152152
= note: number of external vids: 3
153153
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r
154154

155-
error: `<T as Anything<'_#5r, '_#6r>>::AssocType` does not outlive `'_#7r`
155+
error[E0309]: the associated type `<T as Anything<'_#5r, '_#6r>>::AssocType` may not live long enough
156156
--> $DIR/projection-two-region-trait-bound-closure.rs:49:29
157157
|
158158
49 | with_signature(cell, t, |cell, t| require(cell, t));
159159
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
160+
|
161+
= help: consider adding an explicit lifetime bound `<T as Anything<'_#5r, '_#6r>>::AssocType: ReFree(DefId(0/0:8 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:19), 'a))`...
160162

161163
note: No external requirements
162164
--> $DIR/projection-two-region-trait-bound-closure.rs:45:1
@@ -166,7 +168,7 @@ note: No external requirements
166168
47 | | T: Anything<'b, 'c>,
167169
48 | | {
168170
... |
169-
51 | | //~| ERROR `<T as Anything<'_#5r, '_#6r>>::AssocType` does not outlive `'_#7r`
171+
51 | | //~| ERROR associated type `<T as Anything<'_#5r, '_#6r>>::AssocType` may not live long enough
170172
52 | | }
171173
| |_^
172174
|
@@ -176,11 +178,13 @@ note: No external requirements
176178
T
177179
]
178180

179-
error: `<T as Anything<'_#6r, '_#7r>>::AssocType` does not outlive `'_#8r`
181+
error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
180182
--> $DIR/projection-two-region-trait-bound-closure.rs:60:29
181183
|
182184
60 | with_signature(cell, t, |cell, t| require(cell, t));
183185
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
186+
|
187+
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`...
184188

185189
note: No external requirements
186190
--> $DIR/projection-two-region-trait-bound-closure.rs:55:1
@@ -190,7 +194,7 @@ note: No external requirements
190194
57 | | T: Anything<'b, 'c>,
191195
58 | | 'a: 'a,
192196
... |
193-
62 | | //~| ERROR `<T as Anything<'_#6r, '_#7r>>::AssocType` does not outlive `'_#8r`
197+
62 | | //~| ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
194198
63 | | }
195199
| |_^
196200
|
@@ -201,11 +205,13 @@ note: No external requirements
201205
T
202206
]
203207

204-
error: `<T as Anything<'_#6r, '_#7r>>::AssocType` does not outlive `'_#8r`
208+
error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
205209
--> $DIR/projection-two-region-trait-bound-closure.rs:81:29
206210
|
207211
81 | with_signature(cell, t, |cell, t| require(cell, t));
208212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
213+
|
214+
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`...
209215

210216
note: No external requirements
211217
--> $DIR/projection-two-region-trait-bound-closure.rs:66:1
@@ -215,7 +221,7 @@ note: No external requirements
215221
68 | | T: Anything<'b, 'c>,
216222
69 | | T::AssocType: 'a,
217223
... |
218-
83 | | //~| ERROR `<T as Anything<'_#6r, '_#7r>>::AssocType` does not outlive `'_#8r`
224+
83 | | //~| ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
219225
84 | | }
220226
| |_^
221227
|

‎src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) {
4343
twice(cell, value, |a, b| invoke(a, b));
4444
//~^ WARNING not reporting region error
4545
//~| WARNING not reporting region error
46-
//~| ERROR `T` does not outlive
46+
//~| ERROR the parameter type `T` may not live long enough
4747
}
4848

4949
fn invoke<'a, 'x, T>(x: Option<Cell<&'x &'a ()>>, y: &T)

‎src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ note: No external requirements
6060
T
6161
]
6262

63-
error: `T` does not outlive `'_#3r`
63+
error[E0309]: the parameter type `T` may not live long enough
6464
--> $DIR/ty-param-closure-approximate-lower-bound.rs:43:24
6565
|
6666
43 | twice(cell, value, |a, b| invoke(a, b));
6767
| ^^^^^^^^^^^^^^^^^^^
68+
|
69+
= 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))`...
6870

6971
note: No external requirements
7072
--> $DIR/ty-param-closure-approximate-lower-bound.rs:42:1
@@ -73,7 +75,7 @@ note: No external requirements
7375
43 | | twice(cell, value, |a, b| invoke(a, b));
7476
44 | | //~^ WARNING not reporting region error
7577
45 | | //~| WARNING not reporting region error
76-
46 | | //~| ERROR `T` does not outlive
78+
46 | | //~| ERROR the parameter type `T` may not live long enough
7779
47 | | }
7880
| |_^
7981
|

‎src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ where
3636

3737
with_signature(x, |y| y)
3838
//~^ WARNING not reporting region error due to -Znll
39-
//~| ERROR `T` does not outlive
39+
//~| ERROR the parameter type `T` may not live long enough
4040
}
4141

4242
fn correct_region<'a, T>(x: Box<T>) -> Box<Debug + 'a>
@@ -52,7 +52,7 @@ where
5252
{
5353
x
5454
//~^ WARNING not reporting region error due to -Znll
55-
//~| ERROR `T` does not outlive
55+
//~| ERROR the parameter type `T` may not live long enough
5656
}
5757

5858
fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>

‎src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr

+7-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ note: External requirements
2525
= note: number of external vids: 3
2626
= note: where T: '_#2r
2727

28-
error: `T` does not outlive `'_#4r`
28+
error[E0309]: the parameter type `T` may not live long enough
2929
--> $DIR/ty-param-closure-outlives-from-return-type.rs:37:23
3030
|
3131
37 | with_signature(x, |y| y)
3232
| ^^^^^
33+
|
34+
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
3335

3436
note: No external requirements
3537
--> $DIR/ty-param-closure-outlives-from-return-type.rs:26:1
@@ -39,7 +41,7 @@ note: No external requirements
3941
28 | | T: Debug,
4042
29 | | {
4143
... |
42-
39 | | //~| ERROR `T` does not outlive
44+
39 | | //~| ERROR the parameter type `T` may not live long enough
4345
40 | | }
4446
| |_^
4547
|
@@ -48,11 +50,13 @@ note: No external requirements
4850
T
4951
]
5052

51-
error: `T` does not outlive `'_#4r`
53+
error[E0309]: the parameter type `T` may not live long enough
5254
--> $DIR/ty-param-closure-outlives-from-return-type.rs:53:5
5355
|
5456
53 | x
5557
| ^
58+
|
59+
= help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...
5660

5761
error: aborting due to 2 previous errors
5862

‎src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ where
3636
#[rustc_regions]
3737
fn no_region<'a, T>(a: Cell<&'a ()>, b: T) {
3838
with_signature(a, b, |x, y| {
39-
//~^ ERROR `T` does not outlive
39+
//~^ ERROR the parameter type `T` may not live long enough
4040
//
4141
// See `correct_region`, which explains the point of this
4242
// test. The only difference is that, in the case of this
@@ -74,7 +74,7 @@ where
7474
T: 'b,
7575
{
7676
with_signature(a, b, |x, y| {
77-
//~^ ERROR `T` does not outlive
77+
//~^ ERROR the parameter type `T` may not live long enough
7878
// See `correct_region`
7979
require(&x, &y)
8080
//~^ WARNING not reporting region error due to -Znll

‎src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr

+11-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ note: External requirements
1515
|
1616
38 | with_signature(a, b, |x, y| {
1717
| __________________________^
18-
39 | | //~^ ERROR `T` does not outlive
18+
39 | | //~^ ERROR the parameter type `T` may not live long enough
1919
40 | | //
2020
41 | | // See `correct_region`, which explains the point of this
2121
... |
@@ -58,7 +58,7 @@ note: External requirements
5858
|
5959
76 | with_signature(a, b, |x, y| {
6060
| __________________________^
61-
77 | | //~^ ERROR `T` does not outlive
61+
77 | | //~^ ERROR the parameter type `T` may not live long enough
6262
78 | | // See `correct_region`
6363
79 | | require(&x, &y)
6464
80 | | //~^ WARNING not reporting region error due to -Znll
@@ -94,25 +94,27 @@ note: External requirements
9494
= note: number of external vids: 4
9595
= note: where T: '_#3r
9696

97-
error: `T` does not outlive `'_#3r`
97+
error[E0309]: the parameter type `T` may not live long enough
9898
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:38:26
9999
|
100100
38 | with_signature(a, b, |x, y| {
101101
| __________________________^
102-
39 | | //~^ ERROR `T` does not outlive
102+
39 | | //~^ ERROR the parameter type `T` may not live long enough
103103
40 | | //
104104
41 | | // See `correct_region`, which explains the point of this
105105
... |
106106
46 | | //~^ WARNING not reporting region error due to -Znll
107107
47 | | })
108108
| |_____^
109+
|
110+
= 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))`...
109111

110112
note: No external requirements
111113
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:37:1
112114
|
113115
37 | / fn no_region<'a, T>(a: Cell<&'a ()>, b: T) {
114116
38 | | with_signature(a, b, |x, y| {
115-
39 | | //~^ ERROR `T` does not outlive
117+
39 | | //~^ ERROR the parameter type `T` may not live long enough
116118
40 | | //
117119
... |
118120
47 | | })
@@ -140,17 +142,19 @@ note: No external requirements
140142
T
141143
]
142144

143-
error: `T` does not outlive `'_#5r`
145+
error[E0309]: the parameter type `T` may not live long enough
144146
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:76:26
145147
|
146148
76 | with_signature(a, b, |x, y| {
147149
| __________________________^
148-
77 | | //~^ ERROR `T` does not outlive
150+
77 | | //~^ ERROR the parameter type `T` may not live long enough
149151
78 | | // See `correct_region`
150152
79 | | require(&x, &y)
151153
80 | | //~^ WARNING not reporting region error due to -Znll
152154
81 | | })
153155
| |_____^
156+
|
157+
= 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))`...
154158

155159
note: No external requirements
156160
--> $DIR/ty-param-closure-outlives-from-where-clause.rs:72:1

‎src/test/ui/nll/ty-outlives/ty-param-fn-body.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn region_within_body<T>(t: T) {
2929
fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) {
3030
outlives(cell, t)
3131
//~^ WARNING not reporting region error due to -Znll
32-
//~| ERROR `T` does not outlive
32+
//~| ERROR the parameter type `T` may not live long enough
3333
}
3434

3535
fn outlives<'a, T>(x: Cell<&'a usize>, y: T)

‎src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ warning: not reporting region error due to -Znll
44
30 | outlives(cell, t)
55
| ^^^^^^^^
66

7-
error: `T` does not outlive `'_#4r`
7+
error[E0309]: the parameter type `T` may not live long enough
88
--> $DIR/ty-param-fn-body.rs:30:5
99
|
1010
30 | outlives(cell, t)
1111
| ^^^^^^^^^^^^^^^^^
12+
|
13+
= help: consider adding an explicit lifetime bound `T: 'a`...
1214

1315
error: aborting due to previous error
1416

‎src/test/ui/nll/ty-outlives/ty-param-fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
{
2222
x
2323
//~^ WARNING not reporting region error due to -Znll
24-
//~| ERROR `T` does not outlive
24+
//~| the parameter type `T` may not live long enough
2525
}
2626

2727
fn correct_region<'a, T>(x: Box<T>) -> Box<Debug + 'a>
@@ -37,7 +37,7 @@ where
3737
{
3838
x
3939
//~^ WARNING not reporting region error due to -Znll
40-
//~| ERROR `T` does not outlive
40+
//~| the parameter type `T` may not live long enough
4141
}
4242

4343
fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>

‎src/test/ui/nll/ty-outlives/ty-param-fn.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ warning: not reporting region error due to -Znll
1010
38 | x
1111
| ^
1212

13-
error: `T` does not outlive `'_#3r`
13+
error[E0309]: the parameter type `T` may not live long enough
1414
--> $DIR/ty-param-fn.rs:22:5
1515
|
1616
22 | x
1717
| ^
18+
|
19+
= help: consider adding an explicit lifetime bound `T: 'a`...
1820

19-
error: `T` does not outlive `'_#4r`
21+
error[E0309]: the parameter type `T` may not live long enough
2022
--> $DIR/ty-param-fn.rs:38:5
2123
|
2224
38 | x
2325
| ^
26+
|
27+
= help: consider adding an explicit lifetime bound `T: 'a`...
2428

2529
error: aborting due to 2 previous errors
2630

0 commit comments

Comments
 (0)
Please sign in to comment.