replace parent substs of associated types with inference vars in borrow check
This commit is contained in:
parent
8d1e3d3b74
commit
f30ee6508d
6 changed files with 44 additions and 48 deletions
|
@ -235,6 +235,7 @@ struct UniversalRegionRelationsBuilder<'this, 'tcx> {
|
|||
|
||||
impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
|
||||
crate fn create(mut self) -> CreateResult<'tcx> {
|
||||
let tcx = self.infcx.tcx;
|
||||
let unnormalized_input_output_tys = self
|
||||
.universal_regions
|
||||
.unnormalized_input_tys
|
||||
|
@ -266,6 +267,9 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
|
|||
.delay_span_bug(DUMMY_SP, &format!("failed to normalize {:?}", ty));
|
||||
(self.infcx.tcx.ty_error(), None)
|
||||
});
|
||||
// We need to replace bound regions in the substs of associated types (parent substs, not GATs)
|
||||
// with inference vars, see issue #78450
|
||||
let ty = self.universal_regions.indices.fold_to_region_vids(tcx, ty);
|
||||
let constraints2 = self.add_implied_bounds(ty);
|
||||
normalized_inputs_and_output.push(ty);
|
||||
constraints1.into_iter().chain(constraints2)
|
||||
|
|
|
@ -30,7 +30,7 @@ use crate::borrow_check::nll::ToRegionVid;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct UniversalRegions<'tcx> {
|
||||
indices: UniversalRegionIndices<'tcx>,
|
||||
pub(crate) indices: UniversalRegionIndices<'tcx>,
|
||||
|
||||
/// The vid assigned to `'static`
|
||||
pub fr_static: RegionVid,
|
||||
|
@ -162,7 +162,7 @@ impl<'tcx> DefiningTy<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct UniversalRegionIndices<'tcx> {
|
||||
pub(crate) struct UniversalRegionIndices<'tcx> {
|
||||
/// For those regions that may appear in the parameter environment
|
||||
/// ('static and early-bound regions), we maintain a map from the
|
||||
/// `ty::Region` to the internal `RegionVid` we are using. This is
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
// failure-status: 101
|
||||
// rustc-env:RUST_BACKTRACE=0
|
||||
// normalize-stderr-test "note: .*\n\n" -> ""
|
||||
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
|
||||
|
||||
// compile-flags: --crate-type=rlib
|
||||
|
||||
// Regression test for https://github.com/rust-lang/rust/issues/78450
|
||||
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![no_std]
|
||||
|
||||
pub trait AssociatedImpl {
|
||||
type ImplTrait;
|
||||
|
||||
fn f() -> Self::ImplTrait;
|
||||
}
|
||||
|
||||
struct S<T>(T);
|
||||
|
||||
trait Associated {
|
||||
type A;
|
||||
}
|
||||
|
||||
// ICE
|
||||
impl<'a, T: Associated<A = &'a ()>> AssociatedImpl for S<T> {
|
||||
type ImplTrait = impl core::fmt::Debug;
|
||||
|
||||
fn f() -> Self::ImplTrait {
|
||||
//~^ ERROR unexpected concrete region in borrowck: ReEarlyBound(0, 'a)
|
||||
()
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
error: internal compiler error: unexpected concrete region in borrowck: ReEarlyBound(0, 'a)
|
||||
--> $DIR/associated-type-lifetime-ice.rs:29:5
|
||||
|
|
||||
LL | / fn f() -> Self::ImplTrait {
|
||||
LL | |
|
||||
LL | | ()
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= error: internal compiler error: unexpected panic
|
||||
|
||||
query stack during panic:
|
||||
end of query stack
|
27
src/test/ui/type-alias-impl-trait/issue-78450.rs
Normal file
27
src/test/ui/type-alias-impl-trait/issue-78450.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
//~^ WARNING: the feature `type_alias_impl_trait` is incomplete
|
||||
|
||||
pub trait AssociatedImpl {
|
||||
type ImplTrait;
|
||||
|
||||
fn f() -> Self::ImplTrait;
|
||||
}
|
||||
|
||||
struct S<T>(T);
|
||||
|
||||
trait Associated {
|
||||
type A;
|
||||
}
|
||||
|
||||
impl<'a, T: Associated<A = &'a ()>> AssociatedImpl for S<T> {
|
||||
type ImplTrait = impl core::fmt::Debug;
|
||||
|
||||
fn f() -> Self::ImplTrait {
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
11
src/test/ui/type-alias-impl-trait/issue-78450.stderr
Normal file
11
src/test/ui/type-alias-impl-trait/issue-78450.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-78450.rs:4:12
|
||||
|
|
||||
LL | #![feature(type_alias_impl_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
Loading…
Reference in a new issue