mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
Consider param-env candidates, too
This commit is contained in:
parent
184d5ef107
commit
e425d85518
@ -3,6 +3,8 @@ use rustc_data_structures::graph::WithSuccessors;
|
||||
use rustc_index::bit_set::{HybridBitSet, SparseBitMatrix};
|
||||
use rustc_index::interval::IntervalSet;
|
||||
use rustc_infer::infer::canonical::QueryRegionConstraints;
|
||||
use rustc_infer::infer::outlives::test_type_match;
|
||||
use rustc_infer::infer::region_constraints::VerifyIfEq;
|
||||
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
|
||||
use rustc_middle::traits::query::DropckOutlivesResult;
|
||||
use rustc_middle::ty::{
|
||||
@ -622,6 +624,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
|
||||
bug!();
|
||||
};
|
||||
let tcx = self.typeck.infcx.tcx;
|
||||
let param_env = self.typeck.param_env;
|
||||
let mut outlives_bounds = tcx
|
||||
.item_bounds(alias_ty.def_id)
|
||||
.iter_instantiated(tcx, alias_ty.args)
|
||||
@ -633,7 +636,24 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
})
|
||||
.chain(param_env.caller_bounds().iter().filter_map(|clause| {
|
||||
let outlives = clause.as_type_outlives_clause()?;
|
||||
if let Some(outlives) = outlives.no_bound_vars()
|
||||
&& outlives.0 == t
|
||||
{
|
||||
Some(outlives.1)
|
||||
} else {
|
||||
test_type_match::extract_verify_if_eq(
|
||||
tcx,
|
||||
param_env,
|
||||
&outlives.map_bound(|ty::OutlivesPredicate(ty, bound)| {
|
||||
VerifyIfEq { ty, bound }
|
||||
}),
|
||||
t,
|
||||
)
|
||||
}
|
||||
}));
|
||||
if let Some(r) = outlives_bounds.next()
|
||||
&& !r.is_late_bound()
|
||||
&& outlives_bounds.all(|other_r| {
|
||||
|
20
tests/ui/borrowck/alias-liveness/gat-static.rs
Normal file
20
tests/ui/borrowck/alias-liveness/gat-static.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// check-pass
|
||||
|
||||
trait Foo {
|
||||
type Assoc<'a>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn assoc(&mut self) -> Self::Assoc<'_>;
|
||||
}
|
||||
|
||||
fn test<T>(mut t: T)
|
||||
where
|
||||
T: Foo,
|
||||
for<'a> T::Assoc<'a>: 'static,
|
||||
{
|
||||
let a = t.assoc();
|
||||
let b = t.assoc();
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user