Fix NLL compare mode tests

This commit is contained in:
Matthew Jasper 2020-10-06 08:39:49 +01:00
parent c9eeb60b63
commit 69fc6d8c5c
3 changed files with 47 additions and 9 deletions

View File

@ -6,6 +6,7 @@ use rustc_infer::infer::{
error_reporting::unexpected_hidden_region_diagnostic, NLLRegionVariableOrigin,
};
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{self, RegionVid, Ty};
use rustc_span::symbol::{kw, sym};
use rustc_span::Span;
@ -585,14 +586,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
//
// eg. check for `impl Trait + 'static` instead of `impl Trait`.
let has_static_predicate = {
let predicates_of = self.infcx.tcx.predicates_of(did);
let bounds = predicates_of.instantiate(self.infcx.tcx, substs);
let bounds = self.infcx.tcx.explicit_item_bounds(did);
let mut found = false;
for predicate in bounds.predicates {
for (bound, _) in bounds {
if let ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(_, r)) =
predicate.skip_binders()
bound.skip_binders()
{
let r = r.subst(self.infcx.tcx, substs);
if let ty::RegionKind::ReStatic = r {
found = true;
break;

View File

@ -18,6 +18,24 @@ LL | type WrongGeneric<T> = impl 'static;
= note: expected type `i32`
found opaque type `impl Sized`
error: aborting due to 2 previous errors
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/generic_type_does_not_live_long_enough.rs:14:30
|
LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
| ^^^^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `T: 'static`...
For more information about this error, try `rustc --explain E0308`.
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/generic_type_does_not_live_long_enough.rs:9:24
|
LL | type WrongGeneric<T> = impl 'static;
| ^^^^^^^^^^^^
|
= help: consider adding an explicit lifetime bound `T: 'static`...
= note: ...so that the type `T` will meet its required lifetime bounds
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0308, E0310.
For more information about an error, try `rustc --explain E0308`.

View File

@ -1,14 +1,33 @@
error: higher-ranked subtype error
--> $DIR/issue-57611-trait-alias.rs:21:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^
error: higher-ranked subtype error
--> $DIR/issue-57611-trait-alias.rs:21:9
--> $DIR/issue-57611-trait-alias.rs:25:9
|
LL | |x| x
| ^^^^^
error: aborting due to 2 previous errors
error[E0308]: mismatched types
--> $DIR/issue-57611-trait-alias.rs:17:16
|
LL | type Bar = impl Baz<Self, Self>;
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `for<'r> Fn<(&'r X,)>`
found type `Fn<(&'static X,)>`
error[E0308]: mismatched types
--> $DIR/issue-57611-trait-alias.rs:17:16
|
LL | type Bar = impl Baz<Self, Self>;
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected type `FnOnce<(&X,)>`
found type `FnOnce<(&'static X,)>`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.