Skip to content

Commit 546ce21

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

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 3 additions & 1 deletion
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

Lines changed: 10 additions & 2 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 6 additions & 0 deletions
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)

tests/codegen/debug-vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
// CHECK: @vtable.3 = private constant <{
1616
// CHECK: @vtable.4 = private constant <{
1717

18+
// NONMSVC: ![[PTR:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "*const ()"
1819
// NONMSVC: ![[USIZE:[0-9]+]] = !DIBasicType(name: "usize"
1920
// MSVC: ![[USIZE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_typedef, name: "usize"
20-
// NONMSVC: ![[PTR:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "*const ()"
2121
// MSVC: ![[PTR:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "ptr_const$<tuple$<> >"
2222

2323
// NONMSVC: !DIGlobalVariable(name: "<debug_vtable::Foo as debug_vtable::SomeTrait>::{vtable}"

0 commit comments

Comments
 (0)