Skip to content

Commit 60892e8

Browse files
committed
Visit opaque types during type collection too.
1 parent 3075f03 commit 60892e8

23 files changed

+120
-342
lines changed

compiler/rustc_hir_analysis/src/collect.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -644,40 +644,39 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
644644
}
645645
}
646646

647-
// Desugared from `impl Trait`, so visited by the function's return type.
648-
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
649-
origin: hir::OpaqueTyOrigin::FnReturn(..) | hir::OpaqueTyOrigin::AsyncFn(..),
650-
..
651-
}) => {}
652-
653647
// Don't call `type_of` on opaque types, since that depends on type
654648
// checking function bodies. `check_item_type` ensures that it's called
655649
// instead.
656650
hir::ItemKind::OpaqueTy(..) => {
657651
tcx.ensure().generics_of(def_id);
658652
tcx.ensure().predicates_of(def_id);
659653
tcx.ensure().explicit_item_bounds(def_id);
654+
tcx.ensure().item_bounds(def_id);
660655
}
661-
hir::ItemKind::TyAlias(..)
662-
| hir::ItemKind::Static(..)
663-
| hir::ItemKind::Const(..)
664-
| hir::ItemKind::Fn(..) => {
656+
657+
hir::ItemKind::TyAlias(..) => {
665658
tcx.ensure().generics_of(def_id);
666659
tcx.ensure().type_of(def_id);
667660
tcx.ensure().predicates_of(def_id);
668-
match it.kind {
669-
hir::ItemKind::Fn(..) => tcx.ensure().fn_sig(def_id),
670-
hir::ItemKind::OpaqueTy(..) => tcx.ensure().item_bounds(def_id),
671-
hir::ItemKind::Const(ty, ..) | hir::ItemKind::Static(ty, ..) => {
672-
if !is_suggestable_infer_ty(ty) {
673-
let mut visitor = HirPlaceholderCollector::default();
674-
visitor.visit_item(it);
675-
placeholder_type_error(tcx, None, visitor.0, false, None, it.kind.descr());
676-
}
677-
}
678-
_ => (),
661+
}
662+
663+
hir::ItemKind::Static(ty, ..) | hir::ItemKind::Const(ty, ..) => {
664+
tcx.ensure().generics_of(def_id);
665+
tcx.ensure().type_of(def_id);
666+
tcx.ensure().predicates_of(def_id);
667+
if !is_suggestable_infer_ty(ty) {
668+
let mut visitor = HirPlaceholderCollector::default();
669+
visitor.visit_item(it);
670+
placeholder_type_error(tcx, None, visitor.0, false, None, it.kind.descr());
679671
}
680672
}
673+
674+
hir::ItemKind::Fn(..) => {
675+
tcx.ensure().generics_of(def_id);
676+
tcx.ensure().type_of(def_id);
677+
tcx.ensure().predicates_of(def_id);
678+
tcx.ensure().fn_sig(def_id);
679+
}
681680
}
682681
}
683682

src/test/ui/associated-type-bounds/duplicate.rs

+3
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ where
132132
}
133133

134134
fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> {
135+
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
135136
iter::empty()
136137
}
137138
fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> {
139+
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
138140
iter::empty()
139141
}
140142
fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> {
143+
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
141144
iter::empty()
142145
}
143146
fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {}

0 commit comments

Comments
 (0)