Revert to only using opportunistic_resolve_vars for existing places
This commit is contained in:
parent
61157b341e
commit
fb6cec440a
12 changed files with 47 additions and 94 deletions
|
@ -322,7 +322,22 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ReVar(_) => self.canonicalize_region_mode.canonicalize_free_region(self, r),
|
ty::ReVar(vid) => {
|
||||||
|
let resolved_vid = self
|
||||||
|
.infcx
|
||||||
|
.unwrap()
|
||||||
|
.inner
|
||||||
|
.borrow_mut()
|
||||||
|
.unwrap_region_constraints()
|
||||||
|
.opportunistic_resolve_var(vid);
|
||||||
|
debug!(
|
||||||
|
"canonical: region var found with vid {:?}, \
|
||||||
|
opportunistically resolved to {:?}",
|
||||||
|
vid, r
|
||||||
|
);
|
||||||
|
let r = self.tcx.reuse_or_mk_region(r, ty::ReVar(resolved_vid));
|
||||||
|
self.canonicalize_region_mode.canonicalize_free_region(self, r)
|
||||||
|
}
|
||||||
|
|
||||||
ty::ReStatic
|
ty::ReStatic
|
||||||
| ty::ReEarlyBound(..)
|
| ty::ReEarlyBound(..)
|
||||||
|
|
|
@ -623,6 +623,10 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn opportunistic_resolve_var(&mut self, rid: ty::RegionVid) -> ty::RegionVid {
|
||||||
|
self.unification_table().find(rid).vid
|
||||||
|
}
|
||||||
|
|
||||||
pub fn opportunistic_resolve_region(
|
pub fn opportunistic_resolve_region(
|
||||||
&mut self,
|
&mut self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
@ -692,8 +696,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
||||||
&self,
|
&self,
|
||||||
value_count: usize,
|
value_count: usize,
|
||||||
) -> (Range<RegionVid>, Vec<RegionVariableOrigin>) {
|
) -> (Range<RegionVid>, Vec<RegionVariableOrigin>) {
|
||||||
let range = RegionVid::from(value_count as u32)
|
let range = RegionVid::from(value_count)..RegionVid::from(self.unification_table.len());
|
||||||
..RegionVid::from(self.unification_table.len() as u32);
|
|
||||||
(
|
(
|
||||||
range.clone(),
|
range.clone(),
|
||||||
(range.start.index()..range.end.index())
|
(range.start.index()..range.end.index())
|
||||||
|
|
|
@ -84,12 +84,18 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
|
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
|
||||||
let tcx = self.tcx();
|
match *r {
|
||||||
self.infcx
|
ty::ReVar(rid) => {
|
||||||
|
let resolved = self
|
||||||
|
.infcx
|
||||||
.inner
|
.inner
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.unwrap_region_constraints()
|
.unwrap_region_constraints()
|
||||||
.opportunistic_resolve_region(tcx, r)
|
.opportunistic_resolve_var(rid);
|
||||||
|
self.tcx().reuse_or_mk_region(r, ty::ReVar(resolved))
|
||||||
|
}
|
||||||
|
_ => r,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
||||||
|
|
|
@ -102,8 +102,6 @@ pub fn call_tuple_two() {
|
||||||
tuple_two::<Tuple>();
|
tuple_two::<Tuple>();
|
||||||
//~^ ERROR implementation of `TheTrait` is not general enough
|
//~^ ERROR implementation of `TheTrait` is not general enough
|
||||||
//~| ERROR implementation of `TheTrait` is not general enough
|
//~| ERROR implementation of `TheTrait` is not general enough
|
||||||
//~| ERROR mismatched types
|
|
||||||
//~| ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn call_tuple_three() {
|
pub fn call_tuple_three() {
|
||||||
|
|
|
@ -46,34 +46,6 @@ LL | tuple_one::<Tuple>();
|
||||||
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
|
||||||
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/associated-types-eq-hr.rs:102:5
|
|
||||||
|
|
|
||||||
LL | tuple_two::<Tuple>();
|
|
||||||
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
|
||||||
|
|
|
||||||
= note: expected reference `&'x isize`
|
|
||||||
found reference `&'y isize`
|
|
||||||
note: the lifetime requirement is introduced here
|
|
||||||
--> $DIR/associated-types-eq-hr.rs:66:53
|
|
||||||
|
|
|
||||||
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/associated-types-eq-hr.rs:102:5
|
|
||||||
|
|
|
||||||
LL | tuple_two::<Tuple>();
|
|
||||||
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
|
||||||
|
|
|
||||||
= note: expected reference `&'x isize`
|
|
||||||
found reference `&'y isize`
|
|
||||||
note: the lifetime requirement is introduced here
|
|
||||||
--> $DIR/associated-types-eq-hr.rs:66:53
|
|
||||||
|
|
|
||||||
LL | T: for<'x, 'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>,
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: implementation of `TheTrait` is not general enough
|
error: implementation of `TheTrait` is not general enough
|
||||||
--> $DIR/associated-types-eq-hr.rs:102:5
|
--> $DIR/associated-types-eq-hr.rs:102:5
|
||||||
|
|
|
|
||||||
|
@ -93,7 +65,7 @@ LL | tuple_two::<Tuple>();
|
||||||
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
||||||
|
|
||||||
error: implementation of `TheTrait` is not general enough
|
error: implementation of `TheTrait` is not general enough
|
||||||
--> $DIR/associated-types-eq-hr.rs:114:5
|
--> $DIR/associated-types-eq-hr.rs:112:5
|
||||||
|
|
|
|
||||||
LL | tuple_four::<Tuple>();
|
LL | tuple_four::<Tuple>();
|
||||||
| ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
| ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
||||||
|
@ -101,7 +73,6 @@ LL | tuple_four::<Tuple>();
|
||||||
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
|
= note: `Tuple` must implement `TheTrait<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`...
|
||||||
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0271, E0308.
|
For more information about this error, try `rustc --explain E0271`.
|
||||||
For more information about an error, try `rustc --explain E0271`.
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ LL | let v = Unit2.m(
|
||||||
= help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4`
|
= help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4`
|
||||||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
|
|
||||||
error[E0271]: type mismatch resolving `<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as FnOnce<((&'r u8,),)>>::Output == Unit3`
|
error[E0271]: type mismatch resolving `<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as FnOnce<((&u8,),)>>::Output == Unit3`
|
||||||
--> $DIR/issue-62203-hrtb-ice.rs:38:19
|
--> $DIR/issue-62203-hrtb-ice.rs:38:19
|
||||||
|
|
|
|
||||||
LL | let v = Unit2.m(
|
LL | let v = Unit2.m(
|
||||||
|
|
|
@ -23,10 +23,6 @@ static SOME_STRUCT: &SomeStruct = &SomeStruct {
|
||||||
bar: &Bar { bools: &[true, true] },
|
bar: &Bar { bools: &[true, true] },
|
||||||
f: &id,
|
f: &id,
|
||||||
//~^ ERROR implementation of `FnOnce` is not general enough
|
//~^ ERROR implementation of `FnOnce` is not general enough
|
||||||
//~^^ mismatched types
|
|
||||||
//~^^^ mismatched types
|
|
||||||
//~^^^^ mismatched types
|
|
||||||
//~^^^^^ mismatched types
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// very simple test for a 'static static with default lifetime
|
// very simple test for a 'static static with default lifetime
|
||||||
|
|
|
@ -1,39 +1,3 @@
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/rfc1623.rs:24:8
|
|
||||||
|
|
|
||||||
LL | f: &id,
|
|
||||||
| ^^^ one type is more general than the other
|
|
||||||
|
|
|
||||||
= note: expected reference `&'a Foo<'b>`
|
|
||||||
found reference `&'a Foo<'b>`
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/rfc1623.rs:24:8
|
|
||||||
|
|
|
||||||
LL | f: &id,
|
|
||||||
| ^^^ one type is more general than the other
|
|
||||||
|
|
|
||||||
= note: expected reference `&'a Foo<'b>`
|
|
||||||
found reference `&'a Foo<'b>`
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/rfc1623.rs:24:8
|
|
||||||
|
|
|
||||||
LL | f: &id,
|
|
||||||
| ^^^ one type is more general than the other
|
|
||||||
|
|
|
||||||
= note: expected reference `&'a Foo<'b>`
|
|
||||||
found reference `&'a Foo<'b>`
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/rfc1623.rs:24:8
|
|
||||||
|
|
|
||||||
LL | f: &id,
|
|
||||||
| ^^^ one type is more general than the other
|
|
||||||
|
|
|
||||||
= note: expected reference `&'a Foo<'b>`
|
|
||||||
found reference `&'a Foo<'b>`
|
|
||||||
|
|
||||||
error: implementation of `FnOnce` is not general enough
|
error: implementation of `FnOnce` is not general enough
|
||||||
--> $DIR/rfc1623.rs:24:8
|
--> $DIR/rfc1623.rs:24:8
|
||||||
|
|
|
|
||||||
|
@ -43,6 +7,5 @@ LL | f: &id,
|
||||||
= note: `fn(&'2 Foo<'_>) -> &'2 Foo<'_> {id::<&'2 Foo<'_>>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any lifetime `'1`...
|
= note: `fn(&'2 Foo<'_>) -> &'2 Foo<'_> {id::<&'2 Foo<'_>>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any lifetime `'1`...
|
||||||
= note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2`
|
= note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2`
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0308`.
|
|
||||||
|
|
|
@ -26,4 +26,6 @@ fn main() {
|
||||||
// Should only be a few notes.
|
// Should only be a few notes.
|
||||||
is_send::<X<C<'static>>>();
|
is_send::<X<C<'static>>>();
|
||||||
//~^ ERROR overflow evaluating
|
//~^ ERROR overflow evaluating
|
||||||
|
//~| 2 redundant requirements hidden
|
||||||
|
//~| required because of
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0275]: overflow evaluating the requirement `Box<X<C<'static>>>: NotAuto`
|
error[E0275]: overflow evaluating the requirement `Box<X<C<'_>>>: NotAuto`
|
||||||
--> $DIR/lifetime.rs:27:5
|
--> $DIR/lifetime.rs:27:5
|
||||||
|
|
|
|
||||||
LL | fn is_send<S: NotAuto>() {}
|
LL | fn is_send<S: NotAuto>() {}
|
||||||
|
@ -7,11 +7,13 @@ LL | fn is_send<S: NotAuto>() {}
|
||||||
LL | is_send::<X<C<'static>>>();
|
LL | is_send::<X<C<'static>>>();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: required because of the requirements on the impl of `NotAuto` for `X<C<'static>>`
|
note: required because of the requirements on the impl of `NotAuto` for `X<C<'_>>`
|
||||||
--> $DIR/lifetime.rs:19:12
|
--> $DIR/lifetime.rs:19:12
|
||||||
|
|
|
|
||||||
LL | impl<T: Y> NotAuto for X<T> where T::P: NotAuto {}
|
LL | impl<T: Y> NotAuto for X<T> where T::P: NotAuto {}
|
||||||
| ^^^^^^^ ^^^^
|
| ^^^^^^^ ^^^^
|
||||||
|
= note: 2 redundant requirements hidden
|
||||||
|
= note: required because of the requirements on the impl of `NotAuto` for `X<C<'static>>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ trait Bug {
|
||||||
impl Bug for &() {
|
impl Bug for &() {
|
||||||
type Item = impl Bug; //~ ERROR `impl Trait` in type aliases is unstable
|
type Item = impl Bug; //~ ERROR `impl Trait` in type aliases is unstable
|
||||||
//~^ ERROR the trait bound `(): Bug` is not satisfied
|
//~^ ERROR the trait bound `(): Bug` is not satisfied
|
||||||
//~^^ ERROR the trait bound
|
//~^^ ERROR could not find defining uses
|
||||||
|
|
||||||
const FUN: fn() -> Self::Item = || ();
|
const FUN: fn() -> Self::Item = || ();
|
||||||
//~^ ERROR type alias impl trait is not permitted here
|
//~^ ERROR type alias impl trait is not permitted here
|
||||||
|
|
|
@ -25,14 +25,11 @@ LL | type Item = impl Bug;
|
||||||
= help: the following implementations were found:
|
= help: the following implementations were found:
|
||||||
<&() as Bug>
|
<&() as Bug>
|
||||||
|
|
||||||
error[E0277]: the trait bound `(): Bug` is not satisfied
|
error: could not find defining uses
|
||||||
--> $DIR/issue-60371.rs:10:17
|
--> $DIR/issue-60371.rs:10:17
|
||||||
|
|
|
|
||||||
LL | type Item = impl Bug;
|
LL | type Item = impl Bug;
|
||||||
| ^^^^^^^^ the trait `Bug` is not implemented for `()`
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
= help: the following implementations were found:
|
|
||||||
<&() as Bug>
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue