Revert to only using opportunistic_resolve_vars for existing places

This commit is contained in:
Jack Huey 2021-05-15 12:10:56 -04:00
parent 61157b341e
commit fb6cec440a
12 changed files with 47 additions and 94 deletions

View file

@ -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::ReEarlyBound(..)

View file

@ -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(
&mut self,
tcx: TyCtxt<'tcx>,
@ -692,8 +696,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
&self,
value_count: usize,
) -> (Range<RegionVid>, Vec<RegionVariableOrigin>) {
let range = RegionVid::from(value_count as u32)
..RegionVid::from(self.unification_table.len() as u32);
let range = RegionVid::from(value_count)..RegionVid::from(self.unification_table.len());
(
range.clone(),
(range.start.index()..range.end.index())

View file

@ -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> {
let tcx = self.tcx();
self.infcx
.inner
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_region(tcx, r)
match *r {
ty::ReVar(rid) => {
let resolved = self
.infcx
.inner
.borrow_mut()
.unwrap_region_constraints()
.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> {

View file

@ -102,8 +102,6 @@ pub fn call_tuple_two() {
tuple_two::<Tuple>();
//~^ 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() {

View file

@ -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: ...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
--> $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`
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>();
| ^^^^^^^^^^^^^^^^^^^ 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: ...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 an error, try `rustc --explain E0271`.
For more information about this error, try `rustc --explain E0271`.

View file

@ -9,7 +9,7 @@ LL | let v = Unit2.m(
= 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
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
|
LL | let v = Unit2.m(

View file

@ -23,10 +23,6 @@ static SOME_STRUCT: &SomeStruct = &SomeStruct {
bar: &Bar { bools: &[true, true] },
f: &id,
//~^ 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

View file

@ -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
--> $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: ...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`.

View file

@ -26,4 +26,6 @@ fn main() {
// Should only be a few notes.
is_send::<X<C<'static>>>();
//~^ ERROR overflow evaluating
//~| 2 redundant requirements hidden
//~| required because of
}

View file

@ -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
|
LL | fn is_send<S: NotAuto>() {}
@ -7,11 +7,13 @@ LL | fn is_send<S: NotAuto>() {}
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
|
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

View file

@ -9,7 +9,7 @@ trait Bug {
impl Bug for &() {
type Item = impl Bug; //~ ERROR `impl Trait` in type aliases is unstable
//~^ ERROR the trait bound `(): Bug` is not satisfied
//~^^ ERROR the trait bound
//~^^ ERROR could not find defining uses
const FUN: fn() -> Self::Item = || ();
//~^ ERROR type alias impl trait is not permitted here

View file

@ -25,14 +25,11 @@ LL | type Item = impl Bug;
= help: the following implementations were found:
<&() as Bug>
error[E0277]: the trait bound `(): Bug` is not satisfied
error: could not find defining uses
--> $DIR/issue-60371.rs:10:17
|
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