From 7b1b17574bf1466ddd7e6657b6122244dc5a73ce Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Tue, 12 Sep 2023 01:07:04 +0000 Subject: [PATCH] fix bugs with effects fallback --- compiler/rustc_monomorphize/src/collector.rs | 6 ------ compiler/rustc_passes/src/lang_items.rs | 12 ++++++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 118b3862887..67e821dcf5a 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -815,12 +815,6 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Loc mir::AssertKind::BoundsCheck { .. } => LangItem::PanicBoundsCheck, _ => LangItem::Panic, }; - let def_id = tcx.require_lang_item(lang_item, Some(source)); - let instance = if has_host_effect { - Instance::new(def_id, tcx.mk_args(&[tcx.consts.true_.into()])) - } else { - Instance::mono(tcx, def_id) - }; push_mono_lang_item(self, lang_item); } mir::TerminatorKind::UnwindTerminate(reason) => { diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs index 476394f30cc..7e837243918 100644 --- a/compiler/rustc_passes/src/lang_items.rs +++ b/compiler/rustc_passes/src/lang_items.rs @@ -20,7 +20,8 @@ use rustc_hir::{LangItem, LanguageItems, Target}; use rustc_middle::ty::TyCtxt; use rustc_session::cstore::ExternCrate; -use rustc_span::{symbol::kw::Empty, Span}; +use rustc_span::symbol::kw::Empty; +use rustc_span::{sym, Span}; use rustc_middle::query::Providers; @@ -157,7 +158,14 @@ fn collect_item_extended(&mut self, lang_item: LangItem, item_def_id: LocalDefId self.tcx.hir().get_by_def_id(item_def_id) { let (actual_num, generics_span) = match kind.generics() { - Some(generics) => (generics.params.len(), generics.span), + Some(generics) => ( + generics + .params + .iter() + .filter(|p| !self.tcx.has_attr(p.def_id, sym::rustc_host)) + .count(), + generics.span, + ), None => (0, *item_span), };