Skip to content

Commit d90c700

Browse files
committed
fix bugs with effects fallback
1 parent 22e53f4 commit d90c700

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

compiler/rustc_monomorphize/src/collector.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
846846
} else {
847847
Instance::mono(tcx, def_id)
848848
};
849-
push_mono_lang_item(self, lang_item);
849+
if should_codegen_locally(tcx, &instance) {
850+
self.output.push(create_fn_mono_item(tcx, instance, source));
851+
}
850852
}
851853
mir::TerminatorKind::UnwindTerminate(reason) => {
852854
push_mono_lang_item(self, reason.lang_item());

compiler/rustc_passes/src/lang_items.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use rustc_hir::lang_items::{extract, GenericRequirement};
2020
use rustc_hir::{LangItem, LanguageItems, Target};
2121
use rustc_middle::ty::TyCtxt;
2222
use rustc_session::cstore::ExternCrate;
23-
use rustc_span::{symbol::kw::Empty, Span};
23+
use rustc_span::symbol::kw::Empty;
24+
use rustc_span::{sym, Span};
2425

2526
use rustc_middle::query::Providers;
2627

@@ -157,7 +158,14 @@ impl<'tcx> LanguageItemCollector<'tcx> {
157158
self.tcx.hir().get_by_def_id(item_def_id)
158159
{
159160
let (actual_num, generics_span) = match kind.generics() {
160-
Some(generics) => (generics.params.len(), generics.span),
161+
Some(generics) => (
162+
generics
163+
.params
164+
.iter()
165+
.filter(|p| !self.tcx.has_attr(p.def_id, sym::rustc_host))
166+
.count(),
167+
generics.span,
168+
),
161169
None => (0, *item_span),
162170
};
163171

compiler/rustc_trait_selection/src/solve/canonicalize.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
365365
// FIXME: we should fold this ty eventually
366366
CanonicalVarKind::Const(ui, c.ty())
367367
}
368-
ty::ConstKind::Infer(ty::InferConst::EffectVar(_)) => {
369-
bug!("effect var has no universe")
370-
}
368+
ty::ConstKind::Infer(ty::InferConst::EffectVar(_)) => CanonicalVarKind::Effect,
371369
ty::ConstKind::Infer(ty::InferConst::Fresh(_)) => {
372370
bug!("fresh var during canonicalization: {c:?}")
373371
}

compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs

+6
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EagerResolver<'_, 'tcx> {
382382
}
383383
}
384384
}
385+
ty::ConstKind::Infer(ty::InferConst::EffectVar(vid)) => {
386+
match self.infcx.probe_effect_var(vid) {
387+
Some(val) => val.as_const(self.infcx.tcx).fold_with(self),
388+
None => self.infcx.tcx.consts.true_,
389+
}
390+
}
385391
_ => {
386392
if c.has_infer() {
387393
c.super_fold_with(self)

0 commit comments

Comments
 (0)