diff --git a/compiler/rustc_typeck/src/hir_wf_check.rs b/compiler/rustc_typeck/src/hir_wf_check.rs index fa9c44bb89191..a8ec7b79e571f 100644 --- a/compiler/rustc_typeck/src/hir_wf_check.rs +++ b/compiler/rustc_typeck/src/hir_wf_check.rs @@ -121,7 +121,11 @@ fn diagnostic_hir_wf_check<'tcx>( let ty = match tcx.hir().get(hir_id) { hir::Node::ImplItem(item) => match item.kind { - hir::ImplItemKind::TyAlias(ref ty) => Some(ty), + hir::ImplItemKind::TyAlias(ty) => Some(ty), + _ => None, + }, + hir::Node::TraitItem(item) => match item.kind { + hir::TraitItemKind::Type(_, ty) => ty, _ => None, }, _ => None, diff --git a/src/test/ui/associated-types/defaults-wf.stderr b/src/test/ui/associated-types/defaults-wf.stderr index d4fa5be742ff3..73ef567ffae6d 100644 --- a/src/test/ui/associated-types/defaults-wf.stderr +++ b/src/test/ui/associated-types/defaults-wf.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/defaults-wf.rs:7:5 + --> $DIR/defaults-wf.rs:7:15 | LL | type Ty = Vec<[u8]>; - | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^ doesn't have a size known at compile-time | ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | diff --git a/src/test/ui/wf/wf-trait-associated-type-trait.rs b/src/test/ui/wf/wf-trait-associated-type-trait.rs index ddc0b323a11a1..d67e110edeeee 100644 --- a/src/test/ui/wf/wf-trait-associated-type-trait.rs +++ b/src/test/ui/wf/wf-trait-associated-type-trait.rs @@ -8,7 +8,7 @@ struct IsCopy { x: T } trait SomeTrait { type Type1; - type Type2 = IsCopy; + type Type2 = (IsCopy, bool); //~^ ERROR E0277 } diff --git a/src/test/ui/wf/wf-trait-associated-type-trait.stderr b/src/test/ui/wf/wf-trait-associated-type-trait.stderr index a139186ebb673..d1c2c65043d21 100644 --- a/src/test/ui/wf/wf-trait-associated-type-trait.stderr +++ b/src/test/ui/wf/wf-trait-associated-type-trait.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `::Type1: Copy` is not satisfied - --> $DIR/wf-trait-associated-type-trait.rs:11:5 + --> $DIR/wf-trait-associated-type-trait.rs:11:19 | LL | struct IsCopy { x: T } | ---- required by this bound in `IsCopy` ... -LL | type Type2 = IsCopy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `::Type1` +LL | type Type2 = (IsCopy, bool); + | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `::Type1` | help: consider further restricting the associated type |