Remove some noise from opaque type errors around associated types
This commit is contained in:
parent
f8402169aa
commit
689a868a1f
3 changed files with 17 additions and 57 deletions
|
@ -551,6 +551,20 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
||||||
let predicate = predicate.subst(tcx, substs);
|
let predicate = predicate.subst(tcx, substs);
|
||||||
debug!(?predicate);
|
debug!(?predicate);
|
||||||
|
|
||||||
|
// Replace all other mentions of the same opaque type with the hidden type,
|
||||||
|
// as the bounds must hold on the hidden type after all.
|
||||||
|
let predicate = predicate.fold_with(&mut BottomUpFolder {
|
||||||
|
tcx,
|
||||||
|
ty_op: |ty| match *ty.kind() {
|
||||||
|
ty::Opaque(def_id2, substs2) if def_id == def_id2 && substs == substs2 => {
|
||||||
|
ty_var
|
||||||
|
}
|
||||||
|
_ => ty,
|
||||||
|
},
|
||||||
|
lt_op: |lt| lt,
|
||||||
|
ct_op: |ct| ct,
|
||||||
|
});
|
||||||
|
|
||||||
// We can't normalize associated types from `rustc_infer`, but we can eagerly register inference variables for them.
|
// We can't normalize associated types from `rustc_infer`, but we can eagerly register inference variables for them.
|
||||||
let predicate = predicate.fold_with(&mut BottomUpFolder {
|
let predicate = predicate.fold_with(&mut BottomUpFolder {
|
||||||
tcx,
|
tcx,
|
||||||
|
|
|
@ -15,9 +15,5 @@ impl<W> Trait<W> for () {}
|
||||||
|
|
||||||
fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
|
fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
|
||||||
//~^ ERROR non-defining opaque type use in defining scope
|
//~^ ERROR non-defining opaque type use in defining scope
|
||||||
//~| ERROR non-defining opaque type use in defining scope
|
|
||||||
//~| ERROR non-defining opaque type use in defining scope
|
|
||||||
//~| ERROR `T` is part of concrete type but not used in parameter list
|
|
||||||
//~| ERROR `T` is part of concrete type but not used in parameter list
|
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,8 @@
|
||||||
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
|
|
||||||
--> $DIR/bound_reduction2.rs:16:60
|
|
||||||
|
|
|
||||||
LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
|
|
||||||
| ____________________________________________________________^
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | | ()
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
|
|
||||||
--> $DIR/bound_reduction2.rs:16:60
|
|
||||||
|
|
|
||||||
LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
|
|
||||||
| ____________________________________________________________^
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | | ()
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: non-defining opaque type use in defining scope
|
error: non-defining opaque type use in defining scope
|
||||||
--> $DIR/bound_reduction2.rs:16:1
|
--> $DIR/bound_reduction2.rs:16:46
|
||||||
|
|
|
|
||||||
LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
|
LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: used non-generic type `<T as TraitWithAssoc>::Assoc` for generic parameter
|
note: used non-generic type `<T as TraitWithAssoc>::Assoc` for generic parameter
|
||||||
--> $DIR/bound_reduction2.rs:9:10
|
--> $DIR/bound_reduction2.rs:9:10
|
||||||
|
@ -36,35 +10,11 @@ note: used non-generic type `<T as TraitWithAssoc>::Assoc` for generic parameter
|
||||||
LL | type Foo<V> = impl Trait<V>;
|
LL | type Foo<V> = impl Trait<V>;
|
||||||
| ^
|
| ^
|
||||||
|
|
||||||
error: non-defining opaque type use in defining scope
|
|
||||||
--> $DIR/bound_reduction2.rs:16:1
|
|
||||||
|
|
|
||||||
LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: used non-generic type `_` for generic parameter
|
|
||||||
--> $DIR/bound_reduction2.rs:9:10
|
|
||||||
|
|
|
||||||
LL | type Foo<V> = impl Trait<V>;
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: non-defining opaque type use in defining scope
|
|
||||||
--> $DIR/bound_reduction2.rs:16:1
|
|
||||||
|
|
|
||||||
LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: used non-generic type `_` for generic parameter
|
|
||||||
--> $DIR/bound_reduction2.rs:9:10
|
|
||||||
|
|
|
||||||
LL | type Foo<V> = impl Trait<V>;
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: could not find defining uses
|
error: could not find defining uses
|
||||||
--> $DIR/bound_reduction2.rs:9:15
|
--> $DIR/bound_reduction2.rs:9:15
|
||||||
|
|
|
|
||||||
LL | type Foo<V> = impl Trait<V>;
|
LL | type Foo<V> = impl Trait<V>;
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue