Skip to content

Commit

Permalink
fix bugs with effects fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Sep 12, 2023
1 parent 22e53f4 commit 546ce21
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
} else {
Instance::mono(tcx, def_id)
};
push_mono_lang_item(self, lang_item);
if should_codegen_locally(tcx, &instance) {
self.output.push(create_fn_mono_item(tcx, instance, source));
}
}
mir::TerminatorKind::UnwindTerminate(reason) => {
push_mono_lang_item(self, reason.lang_item());
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_passes/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use rustc_hir::lang_items::{extract, GenericRequirement};
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;

Expand Down Expand Up @@ -157,7 +158,14 @@ impl<'tcx> LanguageItemCollector<'tcx> {
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),
};

Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_trait_selection/src/solve/canonicalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
// FIXME: we should fold this ty eventually
CanonicalVarKind::Const(ui, c.ty())
}
ty::ConstKind::Infer(ty::InferConst::EffectVar(_)) => {
bug!("effect var has no universe")
}
ty::ConstKind::Infer(ty::InferConst::EffectVar(_)) => CanonicalVarKind::Effect,
ty::ConstKind::Infer(ty::InferConst::Fresh(_)) => {
bug!("fresh var during canonicalization: {c:?}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EagerResolver<'_, 'tcx> {
}
}
}
ty::ConstKind::Infer(ty::InferConst::EffectVar(vid)) => {
match self.infcx.probe_effect_var(vid) {
Some(val) => val.as_const(self.infcx.tcx).fold_with(self),
None => self.infcx.tcx.consts.true_,
}
}
_ => {
if c.has_infer() {
c.super_fold_with(self)
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/debug-vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// CHECK: @vtable.3 = private constant <{
// CHECK: @vtable.4 = private constant <{

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

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

0 comments on commit 546ce21

Please sign in to comment.