mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 17:53:56 +00:00
Rollup merge of #68438 - Aaron1011:fix/tait-non-defining, r=estebank
Account for non-types in substs for opaque type error messages Fixes #68368 Previously, I assumed that the substs contained only types, which caused the computed index number to be wrong.
This commit is contained in:
commit
143059deaf
@ -1673,8 +1673,15 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
||||
ty::Param(_) => true,
|
||||
_ => false,
|
||||
};
|
||||
let bad_substs: Vec<_> =
|
||||
substs.types().enumerate().filter(|(_, ty)| !is_param(ty)).collect();
|
||||
let bad_substs: Vec<_> = substs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, k)| {
|
||||
if let GenericArgKind::Type(ty) = k.unpack() { Some((i, ty)) } else { None }
|
||||
})
|
||||
.filter(|(_, ty)| !is_param(ty))
|
||||
.collect();
|
||||
|
||||
if !bad_substs.is_empty() {
|
||||
let identity_substs = InternalSubsts::identity_for_item(self.tcx, self.def_id);
|
||||
for (i, bad_subst) in bad_substs {
|
||||
|
@ -0,0 +1,13 @@
|
||||
// Regression test for issue #68368
|
||||
// Ensures that we don't ICE when emitting an error
|
||||
// for a non-defining use when lifetimes are involved
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
trait Trait<T> {}
|
||||
type Alias<'a, U> = impl Trait<U>; //~ ERROR could not find defining uses
|
||||
fn f<'a>() -> Alias<'a, ()> {}
|
||||
//~^ ERROR defining opaque type use does not fully define opaque type: generic parameter `U`
|
||||
|
||||
fn main() {}
|
||||
|
||||
impl Trait<()> for () {}
|
@ -0,0 +1,14 @@
|
||||
error: defining opaque type use does not fully define opaque type: generic parameter `U` is specified as concrete type `()`
|
||||
--> $DIR/issue-68368-non-defining-use.rs:8:1
|
||||
|
|
||||
LL | fn f<'a>() -> Alias<'a, ()> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: could not find defining uses
|
||||
--> $DIR/issue-68368-non-defining-use.rs:7:1
|
||||
|
|
||||
LL | type Alias<'a, U> = impl Trait<U>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user