Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 207308f

Browse files
committedApr 18, 2025
make linkage be external more often
1 parent b5a0367 commit 207308f

File tree

20 files changed

+179
-119
lines changed

20 files changed

+179
-119
lines changed
 

‎compiler/rustc_error_codes/src/error_codes/E0264.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#### this error code is no longer emitted by the compiler.
2+
13
An unknown external lang item was used.
24

35
Erroneous code example:

‎compiler/rustc_hir/src/lang_items.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ language_item_table! {
296296
PanicMisalignedPointerDereference, sym::panic_misaligned_pointer_dereference, panic_misaligned_pointer_dereference_fn, Target::Fn, GenericRequirement::Exact(0);
297297
PanicInfo, sym::panic_info, panic_info, Target::Struct, GenericRequirement::None;
298298
PanicLocation, sym::panic_location, panic_location, Target::Struct, GenericRequirement::None;
299+
/// Note: used to mark an extern item but now marks an externally implementable item. This means
300+
/// that the PanicImpl used to be marked to be specially treated in the compiler, while it now
301+
/// is only marked so we can check if it exists. There's no other reason for this lang item
302+
/// anymore.
299303
PanicImpl, sym::panic_impl, panic_impl, Target::Fn, GenericRequirement::None;
300304
PanicCannotUnwind, sym::panic_cannot_unwind, panic_cannot_unwind, Target::Fn, GenericRequirement::Exact(0);
301305
PanicInCleanup, sym::panic_in_cleanup, panic_in_cleanup, Target::Fn, GenericRequirement::Exact(0);

‎compiler/rustc_middle/src/middle/eii.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable};
77
pub struct EiiMapping {
88
pub extern_item: DefId,
99
pub chosen_impl: DefId,
10+
pub weak_linkage: bool,
1011
}
1112

1213
pub type EiiMap = FxIndexMap<LocalDefId, EiiMapping>;

‎compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ mod size_asserts {
16721672
// tidy-alphabetical-start
16731673
static_assert_size!(BasicBlockData<'_>, 128);
16741674
static_assert_size!(LocalDecl<'_>, 40);
1675-
static_assert_size!(SourceScopeData<'_>, 64);
1675+
static_assert_size!(SourceScopeData<'_>, 72);
16761676
static_assert_size!(Statement<'_>, 32);
16771677
static_assert_size!(Terminator<'_>, 96);
16781678
static_assert_size!(VarDebugInfo<'_>, 88);

‎compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ pub struct MonoItemData {
383383
/// Specifies the linkage type for a `MonoItem`.
384384
///
385385
/// See <https://llvm.org/docs/LangRef.html#linkage-types> for more details about these variants.
386-
#[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)]
386+
#[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable, Eq, Hash)]
387387
pub enum Linkage {
388388
External,
389389
AvailableExternally,

‎compiler/rustc_middle/src/mir/terminator.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ impl<O> AssertKind<O> {
215215
}
216216
}
217217

218+
/// Generally do not use this and use `panic_function` instead.
219+
/// Gives the lang item that is required to exist for this assertion
220+
/// to be emitted. This sometimes causes the assertion not to be emitted
221+
/// if a lang item isn't there.
222+
pub fn required_lang_item(&self) {}
223+
218224
/// Format the message arguments for the `assert(cond, msg..)` terminator in MIR printing.
219225
///
220226
/// Needs to be kept in sync with the run-time behavior (which is defined by

‎compiler/rustc_middle/src/mir/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ macro_rules! make_mir_visitor {
355355
}
356356
| ty::InstanceKind::AsyncDropGlueCtorShim(_def_id, None)
357357
| ty::InstanceKind::DropGlue(_def_id, None)
358-
| ty::InstanceKind::EiiShim { def_id: _def_id, extern_item: _, chosen_impl: _ } => {}
358+
| ty::InstanceKind::EiiShim { def_id: _def_id, extern_item: _, chosen_impl: _, weak_linkage: _ } => {}
359359

360360
ty::InstanceKind::FnPtrShim(_def_id, ty)
361361
| ty::InstanceKind::DropGlue(_def_id, Some(ty))

‎compiler/rustc_middle/src/ty/instance.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub enum InstanceKind<'tcx> {
178178
/// Generated by externally implementable items. This function adds indirection so we can choose
179179
/// in the final crate whether to call an explicit implementation or, if none are given, call the
180180
/// default.
181-
EiiShim { def_id: DefId, extern_item: DefId, chosen_impl: DefId },
181+
EiiShim { def_id: DefId, extern_item: DefId, chosen_impl: DefId, weak_linkage: bool },
182182
}
183183

184184
impl<'tcx> Instance<'tcx> {
@@ -416,7 +416,10 @@ pub fn fmt_instance(
416416
InstanceKind::FnPtrAddrShim(_, ty) => write!(f, " - shim({ty})"),
417417
InstanceKind::AsyncDropGlueCtorShim(_, None) => write!(f, " - shim(None)"),
418418
InstanceKind::AsyncDropGlueCtorShim(_, Some(ty)) => write!(f, " - shim(Some({ty}))"),
419-
InstanceKind::EiiShim { def_id: _, extern_item, chosen_impl } => {
419+
InstanceKind::EiiShim { def_id: _, extern_item, chosen_impl, weak_linkage: true } => {
420+
write!(f, " - shim(eii: {extern_item:?} -> {chosen_impl:?} [weak]")
421+
}
422+
InstanceKind::EiiShim { def_id: _, extern_item, chosen_impl, weak_linkage: false } => {
420423
write!(f, " - shim(eii: {extern_item:?} -> {chosen_impl:?})")
421424
}
422425
}

‎compiler/rustc_mir_transform/src/shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceKind<'tcx>) -> Body<
7878
receiver_by_ref,
7979
} => build_construct_coroutine_by_move_shim(tcx, coroutine_closure_def_id, receiver_by_ref),
8080

81-
e @ ty::InstanceKind::EiiShim { def_id: _, extern_item, chosen_impl } => {
81+
e @ ty::InstanceKind::EiiShim { def_id: _, extern_item, chosen_impl, weak_linkage: _ } => {
8282
let source = MirSource::from_instance(e);
8383

8484
// get the signature for the new function this shim is creating

‎compiler/rustc_monomorphize/src/collector.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ impl<'v> RootCollector<'_, 'v> {
15941594
/// For each externally implementable item, we should generate an alias MonoItem that
15951595
/// determines what implementation is called. This could be a default implementation.
15961596
fn push_extra_eii_roots(&mut self) {
1597-
for (shim_did, &EiiMapping { extern_item, chosen_impl, .. }) in
1597+
for (shim_did, &EiiMapping { extern_item, chosen_impl, weak_linkage, .. }) in
15981598
self.tcx.get_externally_implementable_item_impls(())
15991599
{
16001600
self.output.push(create_fn_mono_item(
@@ -1604,6 +1604,7 @@ impl<'v> RootCollector<'_, 'v> {
16041604
def_id: (*shim_did).into(),
16051605
extern_item,
16061606
chosen_impl,
1607+
weak_linkage,
16071608
},
16081609
args: ty::GenericArgs::empty(),
16091610
},

‎compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,12 @@ fn characteristic_def_id_of_mono_item<'tcx>(
634634
ty::InstanceKind::Item(def) => def,
635635
// EII shims have a characteristic defid.
636636
// But it's not their own, its the one of the extern item it is implementing.
637-
ty::InstanceKind::EiiShim { def_id: _, extern_item, chosen_impl: _ } => extern_item,
637+
ty::InstanceKind::EiiShim {
638+
def_id: _,
639+
extern_item,
640+
chosen_impl: _,
641+
weak_linkage: _,
642+
} => extern_item,
638643
ty::InstanceKind::VTableShim(..)
639644
| ty::InstanceKind::ReifyShim(..)
640645
| ty::InstanceKind::FnPtrShim(..)
@@ -767,8 +772,10 @@ fn mono_item_linkage_and_visibility<'tcx>(
767772
// together anyway. LLVM ensures the last one is the one that's chosen
768773
// TODO: this isn't the problem if they both decided to choose either the default or the
769774
// same explicit impl but if their view on it differs it is a problem!
770-
if let MonoItem::Fn(Instance { def: InstanceKind::EiiShim { .. }, .. }) = mono_item {
771-
(Linkage::WeakAny, vis)
775+
if let MonoItem::Fn(Instance { def: InstanceKind::EiiShim { weak_linkage, .. }, .. }) =
776+
mono_item
777+
{
778+
if *weak_linkage { (Linkage::WeakAny, vis) } else { (Linkage::External, vis) }
772779
} else {
773780
(Linkage::External, vis)
774781
}

‎compiler/rustc_passes/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,9 @@ passes_trait_impl_const_stable =
761761
passes_transparent_incompatible =
762762
transparent {$target} cannot have other repr hints
763763
764+
passes_undefined_naked_function_abi =
765+
Rust ABI is unsupported in naked functions
766+
764767
passes_unknown_external_lang_item =
765768
unknown external lang item: `{$lang_item}`
766769

‎compiler/rustc_passes/src/eii.rs

Lines changed: 133 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_attr_parsing::{EIIDecl, EIIImpl};
66
use rustc_data_structures::fx::FxIndexMap;
77
use rustc_hir::def::DefKind;
88
use rustc_hir::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, LocalDefId};
9+
use rustc_middle::bug;
910
use rustc_middle::middle::eii::EiiMapping;
1011
use rustc_middle::ty::TyCtxt;
1112
use rustc_session::config::CrateType;
@@ -21,39 +22,52 @@ pub(crate) fn get_externally_implementable_item_impls<'tcx>(
2122
tcx: TyCtxt<'tcx>,
2223
(): (),
2324
) -> &'tcx FxIndexMap<LocalDefId, EiiMapping> {
24-
// We only need to check whether there are duplicate or missing EIIs if we're
25-
// emitting something that's not an rlib.
26-
let needs_check = tcx.crate_types().iter().any(|kind| match *kind {
27-
// Executables are leafs of the crate graph and need all EIIs to be satisfied,
28-
// either with defaults or explicit implementations. So they check their crate
29-
// graph to make sure this is the case.
30-
CrateType::Executable => true,
31-
// Proc macros are leafs of their crate graph and will be run,
32-
// and so need to check the EIIs of their dependencies.
33-
CrateType::ProcMacro => true,
34-
35-
// These are a litte difficult. We don't know whether things depending on these
36-
// will perform checks to see if EIIs are implemented, or duplicated, or any other
37-
// of the checks performed in this function. So we must do the checks. However,
38-
// this can later lead to duplicate symbols when linking them together.
39-
// For this reason, we later mark EII symbols as "globally shared" and "may conflict".
40-
// In other words, if two shared libraries both provide an implementation for an EII,
41-
// that's fine! Just choose one... And because their mangled symbol names are the same
42-
// (that's exactly the conflict we're having) we hopefully have the same exact implementation.
43-
CrateType::Dylib | CrateType::Cdylib | CrateType::Staticlib => true,
44-
45-
// Rlibs are just a step in the crate graph.
46-
// Later on we'll link it together into an executable and over there we can check for EIIs
47-
CrateType::Rlib => false,
48-
});
49-
if !needs_check {
50-
// In this case we could only have called it when checking,
51-
// and not when we were actually codegenning functions so we don't need to return any real data
52-
return &*tcx.arena.alloc(FxIndexMap::default());
25+
#[derive(Copy, Clone)]
26+
enum Case {
27+
/// We need to generate all EII shims because we are generating some final target like an
28+
/// executable or library (not rlib)
29+
AlwaysEmit,
30+
/// We need to generate all EII shims because one of our crate types is a final target like
31+
/// an executable. However, we're also generating an rlib. So. If we see explicit
32+
/// definitions of EIIs we can generate them with external linkage. However, if we find
33+
/// defaults, they must also be emitted because some of our crate types are final targets.
34+
/// And unfortunately the rlib will also contain these definitions. However, because rlibs
35+
/// will later be used in final targets, which will use `AlwaysEmit`, these symbols that were
36+
/// spuriously generated in rlibs will be redefined and then flagged by the linker as
37+
/// duplicate definitions. So, we have to emit EII shims which are default impls (not
38+
/// explicit ones) as weak symbols.
39+
EmitMaybeWeak,
40+
/// We don't always need to emit EIIs because we're generating an Rlib. However, if we see
41+
/// an explicit implementation, we can! Because it cannot be overwritten anymore.
42+
EmitExternalIfExplicit,
5343
}
5444

55-
let mut eiis =
56-
FxIndexMap::<DefId, (EIIDecl, CrateNum, FxIndexMap<DefId, (EIIImpl, CrateNum)>)>::default();
45+
let has_rlib = tcx.crate_types().iter().any(|i| matches!(i, CrateType::Rlib));
46+
let has_target = tcx.crate_types().iter().any(|i| !matches!(i, CrateType::Rlib));
47+
48+
let case = match (has_rlib, has_target) {
49+
(true, true) => Case::EmitMaybeWeak,
50+
(true, false) => Case::EmitExternalIfExplicit,
51+
(false, true) => Case::AlwaysEmit,
52+
(false, false) => {
53+
bug!("no targets but somehow we are running the compiler")
54+
}
55+
};
56+
57+
#[derive(Debug)]
58+
struct FoundImpl {
59+
imp: EIIImpl,
60+
impl_crate: CrateNum,
61+
}
62+
63+
#[derive(Debug)]
64+
struct FoundEii {
65+
decl: EIIDecl,
66+
decl_crate: CrateNum,
67+
impls: FxIndexMap<DefId, FoundImpl>,
68+
}
69+
70+
let mut eiis = FxIndexMap::<DefId, FoundEii>::default();
5771

5872
// println!("current crate: {}", tcx.crate_name(LOCAL_CRATE));
5973

@@ -66,28 +80,36 @@ pub(crate) fn get_externally_implementable_item_impls<'tcx>(
6680
// update or insert the corresponding entries
6781
for (did, (decl, impls)) in crate_eiis {
6882
eiis.entry(*did)
69-
.or_insert_with(|| (*decl, cnum, Default::default()))
70-
.2
71-
.extend(impls.into_iter().map(|(did, i)| (*did, (*i, cnum))));
83+
.or_insert_with(|| FoundEii {
84+
decl: *decl,
85+
decl_crate: cnum,
86+
impls: Default::default(),
87+
})
88+
.impls
89+
.extend(
90+
impls
91+
.into_iter()
92+
.map(|(did, i)| (*did, FoundImpl { imp: *i, impl_crate: cnum })),
93+
);
7294
}
7395
}
7496

7597
let mut final_impls = FxIndexMap::default();
7698

7799
// now we have all eiis! For each of them, choose one we want to actually generate.
78100

79-
for (decl_did, (decl, decl_crate, impls)) in eiis {
101+
for (decl_did, FoundEii { decl, decl_crate, impls }) in eiis {
80102
// println!("for decl: {decl_did:?}: {decl:?}");
81103
let mut default_impls = Vec::new();
82104
let mut explicit_impls = Vec::new();
83105

84-
for (impl_did, (impl_metadata, cnum)) in impls {
85-
if impl_metadata.is_default {
106+
for (impl_did, FoundImpl { imp, impl_crate }) in impls {
107+
if imp.is_default {
86108
// println!("found default impl in {}", tcx.crate_name(cnum));
87-
default_impls.push((impl_did, cnum));
109+
default_impls.push((impl_did, impl_crate));
88110
} else {
89111
// println!("found impl in {}", tcx.crate_name(cnum));
90-
explicit_impls.push((impl_did, cnum));
112+
explicit_impls.push((impl_did, impl_crate));
91113
}
92114
}
93115

@@ -115,43 +137,78 @@ pub(crate) fn get_externally_implementable_item_impls<'tcx>(
115137
panic!("multiple not supported right now, but this is easily possible");
116138
}
117139

118-
// println!("impls: {explicit_impls:?}");
119-
// println!("default impls: {default_impls:?}");
120-
121-
if let Some((chosen_impl, _)) = explicit_impls.first().or(default_impls.first()) {
122-
let feed = tcx.create_def(
123-
CRATE_DEF_ID,
124-
Some(Symbol::intern(&format!("EII shim for {decl_did:?}"))),
125-
DefKind::Fn,
126-
);
127-
128-
let extern_item_did = decl.eii_extern_item;
129-
130-
feed.generics_of(tcx.generics_of(extern_item_did).clone());
131-
feed.type_of(tcx.type_of(extern_item_did).clone());
132-
feed.def_span(tcx.def_span(chosen_impl));
133-
feed.visibility(tcx.visibility(chosen_impl));
134-
feed.feed_hir();
135-
136-
// println!("generating {extern_item_did:?} for impl {chosen_impl:?} in crate {} with did {decl_did:?}", tcx.crate_name(LOCAL_CRATE));
137-
138-
let shim_did = feed.def_id();
139-
140-
// println!("shim: {shim_did:?}");
141-
142-
final_impls.insert(
143-
shim_did,
144-
EiiMapping { extern_item: extern_item_did, chosen_impl: *chosen_impl },
145-
);
146-
} else {
147-
tcx.dcx().emit_err(EiiWithoutImpl {
148-
current_crate_name: tcx.crate_name(LOCAL_CRATE),
149-
decl_crate_name: tcx.crate_name(decl_crate),
150-
name: tcx.item_name(decl_did),
151-
span: decl.span,
152-
help: (),
153-
});
154-
}
140+
let (chosen_impl, weak_linkage) =
141+
match (case, explicit_impls.first(), default_impls.first()) {
142+
(Case::EmitExternalIfExplicit, Some((explicit, impl_crate)), _) => {
143+
if impl_crate != &LOCAL_CRATE {
144+
continue;
145+
}
146+
(explicit, false)
147+
}
148+
// we don't care in this case if we find no implementation yet. Another can come
149+
// downstream.
150+
(Case::EmitExternalIfExplicit, None, _) => {
151+
continue;
152+
}
153+
154+
(Case::AlwaysEmit, Some((explicit, impl_crate)), _) => {
155+
if impl_crate != &LOCAL_CRATE {
156+
continue;
157+
}
158+
159+
(explicit, false)
160+
}
161+
(Case::AlwaysEmit, _, Some((deflt, _))) => (deflt, false),
162+
163+
(Case::EmitMaybeWeak, Some((explicit, impl_crate)), _) => {
164+
if impl_crate != &LOCAL_CRATE {
165+
continue;
166+
}
167+
168+
(explicit, false)
169+
}
170+
// IMPORTANT! weak linkage because the symbol will also end up in the rlib and may need
171+
// to be overwritten :(
172+
(Case::EmitMaybeWeak, _, Some((deflt, _))) => (deflt, true),
173+
174+
// We have a target to generate, but no impl to put in it. error!
175+
(Case::EmitMaybeWeak | Case::AlwaysEmit, None, None) => {
176+
tcx.dcx().emit_err(EiiWithoutImpl {
177+
current_crate_name: tcx.crate_name(LOCAL_CRATE),
178+
decl_crate_name: tcx.crate_name(decl_crate),
179+
name: tcx.item_name(decl_did),
180+
span: decl.span,
181+
help: (),
182+
});
183+
184+
continue;
185+
}
186+
};
187+
188+
let feed = tcx.create_def(
189+
CRATE_DEF_ID,
190+
Some(Symbol::intern(&format!("EII shim for {decl_did:?}"))),
191+
DefKind::Fn,
192+
);
193+
194+
let extern_item_did = decl.eii_extern_item;
195+
196+
feed.generics_of(tcx.generics_of(extern_item_did).clone());
197+
feed.type_of(tcx.type_of(extern_item_did).clone());
198+
feed.def_span(tcx.def_span(chosen_impl));
199+
feed.visibility(tcx.visibility(chosen_impl));
200+
feed.feed_hir();
201+
202+
// println!("generating {extern_item_did:?} for impl {chosen_impl:?} in crate {} with did {decl_did:?}", tcx.crate_name(LOCAL_CRATE));
203+
204+
let shim_did = feed.def_id();
205+
206+
// println!("shim: {shim_did:?}");
207+
208+
final_impls.insert(
209+
shim_did,
210+
EiiMapping { extern_item: extern_item_did, chosen_impl: *chosen_impl, weak_linkage },
211+
);
155212
}
156213

157214
tcx.arena.alloc(final_impls)

‎compiler/rustc_passes/src/errors.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -854,14 +854,6 @@ pub(crate) struct DeprecatedAnnotationHasNoEffect {
854854
pub span: Span,
855855
}
856856

857-
#[derive(Diagnostic)]
858-
#[diag(passes_unknown_external_lang_item, code = E0264)]
859-
pub(crate) struct UnknownExternLangItem {
860-
#[primary_span]
861-
pub span: Span,
862-
pub lang_item: Symbol,
863-
}
864-
865857
#[derive(Diagnostic)]
866858
#[diag(passes_panic_unwind_without_std)]
867859
#[help]

‎compiler/rustc_passes/src/lang_items.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ impl<'ast, 'tcx> LanguageItemCollector<'ast, 'tcx> {
7474
actual_target,
7575
);
7676
}
77+
// Exception: for EIIs the macro gets copied to both a generated macro *and* the
78+
// generated extern item. We need to ignore one of these, and it must be the
79+
// macrodef.
80+
Some(LangItem::PanicImpl) if actual_target == Target::MacroDef => return,
7781
// Known lang item with attribute on incorrect target.
7882
Some(lang_item) => {
7983
self.tcx.dcx().emit_err(LangItemOnIncorrectTarget {

‎compiler/rustc_passes/src/weak_lang_items.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::middle::lang_items::required;
99
use rustc_middle::ty::TyCtxt;
1010
use rustc_session::config::CrateType;
1111

12-
use crate::errors::{MissingLangItem, PanicUnwindWithoutStd, UnknownExternLangItem};
12+
use crate::errors::{MissingLangItem, PanicUnwindWithoutStd};
1313

1414
/// Checks the crate for usage of weak lang items, returning a vector of all the
1515
/// lang items required by this crate, but not defined yet.
@@ -31,17 +31,16 @@ pub(crate) fn check_crate(
3131
items.missing.push(LangItem::EhCatchTypeinfo);
3232
}
3333

34-
visit::Visitor::visit_crate(&mut WeakLangItemVisitor { tcx, items }, krate);
34+
visit::Visitor::visit_crate(&mut WeakLangItemVisitor { items }, krate);
3535

3636
verify(tcx, items);
3737
}
3838

39-
struct WeakLangItemVisitor<'a, 'tcx> {
40-
tcx: TyCtxt<'tcx>,
39+
struct WeakLangItemVisitor<'a> {
4140
items: &'a mut lang_items::LanguageItems,
4241
}
4342

44-
impl<'ast> visit::Visitor<'ast> for WeakLangItemVisitor<'_, '_> {
43+
impl<'ast> visit::Visitor<'ast> for WeakLangItemVisitor<'_> {
4544
fn visit_foreign_item(&mut self, i: &'ast ast::ForeignItem) {
4645
if let Some((lang_item, _)) = lang_items::extract(&i.attrs) {
4746
if let Some(item) = LangItem::from_name(lang_item)
@@ -50,8 +49,6 @@ impl<'ast> visit::Visitor<'ast> for WeakLangItemVisitor<'_, '_> {
5049
if self.items.get(item).is_none() {
5150
self.items.missing.push(item);
5251
}
53-
} else {
54-
self.tcx.dcx().emit_err(UnknownExternLangItem { span: i.span, lang_item });
5552
}
5653
}
5754
}

‎library/core/src/panic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::any::Any;
2121
#[stable(feature = "panic_hooks", since = "1.10.0")]
2222
#[cfg(not(bootstrap))]
2323
#[eii(panic_handler)]
24+
#[lang = "panic_impl"]
2425
pub(crate) fn panic_impl(info: &PanicInfo<'_>) -> !;
2526

2627
#[doc(hidden)]

‎tests/run-make/bin-emit-no-symbols/rmake.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use run_make_support::{llvm_readobj, rustc};
1010
fn main() {
1111
rustc().emit("obj").input("app.rs").run();
1212
let out = llvm_readobj().input("app.o").arg("--symbols").run();
13-
out.assert_stdout_contains("rust_begin_unwind");
1413
out.assert_stdout_contains("rust_eh_personality");
1514
out.assert_stdout_contains("__rg_oom");
1615
}

‎tests/ui/error-codes/E0264.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎tests/ui/error-codes/E0264.stderr

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.