fix the new unsoundness
This commit is contained in:
parent
eea560494c
commit
bfd35016e4
@ -642,7 +642,14 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
||||
) -> ty::Region<'tcx> {
|
||||
let mut ut = self.unification_table_mut(); // FIXME(rust-lang/ena#42): unnecessary mut
|
||||
let root_vid = ut.find(vid).vid;
|
||||
ut.probe_value(root_vid).0.unwrap_or_else(|| tcx.mk_re_var(root_vid))
|
||||
let resolved = ut.probe_value(root_vid).0.unwrap_or_else(|| tcx.mk_re_var(root_vid));
|
||||
|
||||
// Don't resolve a variable to a region that it cannot name.
|
||||
if self.var_universe(vid).can_name(self.universe(resolved)) {
|
||||
resolved
|
||||
} else {
|
||||
tcx.mk_re_var(vid)
|
||||
}
|
||||
}
|
||||
|
||||
fn combine_map(&mut self, t: CombineMapType) -> &mut CombineMap<'tcx> {
|
||||
|
@ -2,9 +2,6 @@
|
||||
//
|
||||
// In particular, we test this pattern in trait solving, where it is not connected
|
||||
// to any part of the source code.
|
||||
//
|
||||
// check-pass
|
||||
// Oops!
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
@ -28,5 +25,5 @@ fn main() {
|
||||
// yielding `fn(&!b u32)`, in a fresh universe U1
|
||||
// - So we get `?a = !b` but the universe U0 assigned to `?a` cannot name `!b`.
|
||||
|
||||
foo::<()>();
|
||||
foo::<()>(); //~ ERROR implementation of `Trait` is not general enough
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
error: implementation of `Trait` is not general enough
|
||||
--> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5
|
||||
|
|
||||
LL | foo::<()>();
|
||||
| ^^^^^^^^^^^ implementation of `Trait` is not general enough
|
||||
|
|
||||
= note: `()` must implement `Trait<for<'b> fn(Cell<&'b u32>)>`
|
||||
= note: ...but it actually implements `Trait<fn(Cell<&'0 u32>)>`, for some specific lifetime `'0`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -14,6 +14,12 @@ LL | fn give_some<'a>() {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | want_hrtb::<&'a u32>()
|
||||
| ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
|
||||
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
|
||||
--> $DIR/hrtb-just-for-static.rs:9:15
|
||||
|
|
||||
LL | where T : for<'a> Foo<&'a isize>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: implementation of `Foo` is not general enough
|
||||
--> $DIR/hrtb-just-for-static.rs:30:5
|
||||
|
Loading…
x
Reference in New Issue
Block a user