From 052d77ea5669380fafbc210b517e51f7c7281c68 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 10 Jun 2021 12:06:47 +0900 Subject: Account for bad placeholder errors on consts/statics with trait objects --- compiler/rustc_typeck/src/collect.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler') diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index ee3ac3b62d9..89bfb77b855 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -808,6 +808,14 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) { match it.kind { hir::ItemKind::Fn(..) => tcx.ensure().fn_sig(def_id), hir::ItemKind::OpaqueTy(..) => tcx.ensure().item_bounds(def_id), + hir::ItemKind::Const(ty, ..) | hir::ItemKind::Static(ty, ..) => { + // (#75889): Account for `const C: dyn Fn() -> _ = "";` + if let hir::TyKind::TraitObject(..) = ty.kind { + let mut visitor = PlaceholderHirTyCollector::default(); + visitor.visit_item(it); + placeholder_type_error(tcx, None, &[], visitor.0, false, None); + } + } _ => (), } } -- cgit 1.4.1-3-g733a5