Navigation Menu

Skip to content

Commit

Permalink
Fix NLL compare mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Oct 6, 2020
1 parent c9eeb60 commit 69fc6d8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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`...

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

For more information about this error, try `rustc --explain E0308`.
Some errors have detailed explanations: E0308, E0310.
For more information about an error, try `rustc --explain E0308`.
@@ -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`.

0 comments on commit 69fc6d8

Please sign in to comment.