Auto merge of #85090 - Aaron1011:type-outlives-global, r=matthewjasper,jackh726
Return `EvaluatedToOk` when type in outlives predicate is global A global type doesn't reference any local regions or types, so it's guaranteed to outlive any region.
This commit is contained in:
commit
d34a3a401b
3 changed files with 24 additions and 16 deletions
|
@ -492,7 +492,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
None => Ok(EvaluatedToAmbig),
|
None => Ok(EvaluatedToAmbig),
|
||||||
},
|
},
|
||||||
|
|
||||||
ty::PredicateKind::TypeOutlives(..) | ty::PredicateKind::RegionOutlives(..) => {
|
ty::PredicateKind::TypeOutlives(pred) => {
|
||||||
|
if pred.0.is_global() {
|
||||||
|
Ok(EvaluatedToOk)
|
||||||
|
} else {
|
||||||
|
Ok(EvaluatedToOkModuloRegions)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ty::PredicateKind::RegionOutlives(..) => {
|
||||||
// We do not consider region relationships when evaluating trait matches.
|
// We do not consider region relationships when evaluating trait matches.
|
||||||
Ok(EvaluatedToOkModuloRegions)
|
Ok(EvaluatedToOkModuloRegions)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ pub struct Second {
|
||||||
d: Vec<First>,
|
d: Vec<First>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Third<f> {
|
struct Third<'a, f> {
|
||||||
g: Vec<f>,
|
g: Vec<(f, &'a f)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Ty {
|
enum Ty {
|
||||||
|
@ -38,29 +38,29 @@ struct Sixth {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_evaluate_where_clauses]
|
#[rustc_evaluate_where_clauses]
|
||||||
fn forward()
|
fn forward<'a>()
|
||||||
where
|
where
|
||||||
Vec<First>: Unpin,
|
Vec<First>: Unpin,
|
||||||
Third<Ty>: Unpin,
|
Third<'a, Ty>: Unpin,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustc_evaluate_where_clauses]
|
#[rustc_evaluate_where_clauses]
|
||||||
fn reverse()
|
fn reverse<'a>()
|
||||||
where
|
where
|
||||||
Third<Ty>: Unpin,
|
Third<'a, Ty>: Unpin,
|
||||||
Vec<First>: Unpin,
|
Vec<First>: Unpin,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Key is that Vec<First> is "ok" and Third<Ty> is "ok modulo regions":
|
// Key is that Vec<First> is "ok" and Third<'_, Ty> is "ok modulo regions":
|
||||||
|
|
||||||
forward();
|
forward();
|
||||||
//~^ ERROR evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>), [])) = Ok(EvaluatedToOk)
|
//~^ ERROR evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>), [])) = Ok(EvaluatedToOk)
|
||||||
//~| ERROR evaluate(Binder(TraitPredicate(<Third<Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
|
//~| ERROR evaluate(Binder(TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
|
||||||
|
|
||||||
reverse();
|
reverse();
|
||||||
//~^ ERROR evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>), [])) = Ok(EvaluatedToOk)
|
//~^ ERROR evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>), [])) = Ok(EvaluatedToOk)
|
||||||
//~| ERROR evaluate(Binder(TraitPredicate(<Third<Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
|
//~| ERROR evaluate(Binder(TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,20 @@ LL | Vec<First>: Unpin,
|
||||||
LL | forward();
|
LL | forward();
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: evaluate(Binder(TraitPredicate(<Third<Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
|
error: evaluate(Binder(TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
|
||||||
--> $DIR/issue-83538-tainted-cache-after-cycle.rs:59:5
|
--> $DIR/issue-83538-tainted-cache-after-cycle.rs:59:5
|
||||||
|
|
|
|
||||||
LL | Third<Ty>: Unpin,
|
LL | Third<'a, Ty>: Unpin,
|
||||||
| ----- predicate
|
| ----- predicate
|
||||||
...
|
...
|
||||||
LL | forward();
|
LL | forward();
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: evaluate(Binder(TraitPredicate(<Third<Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
|
error: evaluate(Binder(TraitPredicate(<Third<'_, Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
|
||||||
--> $DIR/issue-83538-tainted-cache-after-cycle.rs:63:5
|
--> $DIR/issue-83538-tainted-cache-after-cycle.rs:63:5
|
||||||
|
|
|
|
||||||
LL | Third<Ty>: Unpin,
|
LL | Third<'a, Ty>: Unpin,
|
||||||
| ----- predicate
|
| ----- predicate
|
||||||
...
|
...
|
||||||
LL | reverse();
|
LL | reverse();
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
Loading…
Add table
Reference in a new issue