Skip to content

Commit 69fc6d8

Browse files
committed
Fix NLL compare mode tests
1 parent c9eeb60 commit 69fc6d8

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed

compiler/rustc_mir/src/borrow_check/diagnostics/region_errors.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_infer::infer::{
66
error_reporting::unexpected_hidden_region_diagnostic, NLLRegionVariableOrigin,
77
};
88
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
9+
use rustc_middle::ty::subst::Subst;
910
use rustc_middle::ty::{self, RegionVid, Ty};
1011
use rustc_span::symbol::{kw, sym};
1112
use rustc_span::Span;
@@ -585,14 +586,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
585586
//
586587
// eg. check for `impl Trait + 'static` instead of `impl Trait`.
587588
let has_static_predicate = {
588-
let predicates_of = self.infcx.tcx.predicates_of(did);
589-
let bounds = predicates_of.instantiate(self.infcx.tcx, substs);
589+
let bounds = self.infcx.tcx.explicit_item_bounds(did);
590590

591591
let mut found = false;
592-
for predicate in bounds.predicates {
592+
for (bound, _) in bounds {
593593
if let ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(_, r)) =
594-
predicate.skip_binders()
594+
bound.skip_binders()
595595
{
596+
let r = r.subst(self.infcx.tcx, substs);
596597
if let ty::RegionKind::ReStatic = r {
597598
found = true;
598599
break;

src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr

+20-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ LL | type WrongGeneric<T> = impl 'static;
1818
= note: expected type `i32`
1919
found opaque type `impl Sized`
2020

21-
error: aborting due to 2 previous errors
21+
error[E0310]: the parameter type `T` may not live long enough
22+
--> $DIR/generic_type_does_not_live_long_enough.rs:14:30
23+
|
24+
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
25+
| ^^^^^^^^^^^^^^^
26+
|
27+
= help: consider adding an explicit lifetime bound `T: 'static`...
28+
29+
error[E0310]: the parameter type `T` may not live long enough
30+
--> $DIR/generic_type_does_not_live_long_enough.rs:9:24
31+
|
32+
LL | type WrongGeneric<T> = impl 'static;
33+
| ^^^^^^^^^^^^
34+
|
35+
= help: consider adding an explicit lifetime bound `T: 'static`...
36+
= note: ...so that the type `T` will meet its required lifetime bounds
37+
38+
error: aborting due to 4 previous errors
2239

23-
For more information about this error, try `rustc --explain E0308`.
40+
Some errors have detailed explanations: E0308, E0310.
41+
For more information about an error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
error: higher-ranked subtype error
2-
--> $DIR/issue-57611-trait-alias.rs:21:9
2+
--> $DIR/issue-57611-trait-alias.rs:25:9
33
|
44
LL | |x| x
55
| ^^^^^
66

77
error: higher-ranked subtype error
8-
--> $DIR/issue-57611-trait-alias.rs:21:9
8+
--> $DIR/issue-57611-trait-alias.rs:25:9
99
|
1010
LL | |x| x
1111
| ^^^^^
1212

13-
error: aborting due to 2 previous errors
13+
error[E0308]: mismatched types
14+
--> $DIR/issue-57611-trait-alias.rs:17:16
15+
|
16+
LL | type Bar = impl Baz<Self, Self>;
17+
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
18+
|
19+
= note: expected type `for<'r> Fn<(&'r X,)>`
20+
found type `Fn<(&'static X,)>`
21+
22+
error[E0308]: mismatched types
23+
--> $DIR/issue-57611-trait-alias.rs:17:16
24+
|
25+
LL | type Bar = impl Baz<Self, Self>;
26+
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
27+
|
28+
= note: expected type `FnOnce<(&X,)>`
29+
found type `FnOnce<(&'static X,)>`
30+
31+
error: aborting due to 4 previous errors
1432

33+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)