Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
2261154
core: add Peekable::next_if_map
kennytm Jul 10, 2025
bbf08d8
add a test with incorrect `if let`-`super let` drop order
dianne Aug 13, 2025
8fc3938
fix scope of `super let` bindings within `if let`
dianne Aug 13, 2025
52063ae
stabilize path_add_extension
hanna-kruppe Aug 10, 2025
8dbdb17
On binding not present in all patterns, suggest potential typo
estebank Aug 24, 2025
bcfc9b5
inline at the callsite & warn when target features mismatch
Jamesbarford Aug 21, 2025
fc7de99
Ensure we emit an allocator shim when only some crate types need one
bjorn3 Aug 28, 2025
1d30900
Fix typo in comment
bjorn3 Aug 28, 2025
f4888c2
Correctly handle different crate types disagreeing if the allocator s…
bjorn3 Aug 28, 2025
bd0ea61
Add test for typo in or-pattern binding
estebank Aug 29, 2025
cb9cd8f
On binding not present in all patterns, look at consts and unit struc…
estebank Aug 30, 2025
00f6fe1
On unused binding in pattern, suggest unit struct/variant with simila…
estebank Aug 30, 2025
3355f4b
Suggest constant on unused binding in a pattern
estebank Aug 30, 2025
86085b4
Avoid unnecessary suggestion in or-pattern
estebank Aug 30, 2025
a44b180
add `#[must_use]` to `array::repeat`
joboet Aug 31, 2025
0711bba
Ignore test when dylibs are not supported
bjorn3 Aug 31, 2025
5e9b655
Correct typo in `rustc_errors` comment
smoelius Sep 2, 2025
5b43244
Add LSX accelerated implementation for source file analysis
heiher Aug 28, 2025
a8537ab
Remove special implementation of `PartialEq` for `InvisibleOrigin` ou…
Kobzol Sep 1, 2025
5d9f8fc
llvm: nvptx: Layout update to match LLVM
maurer Sep 2, 2025
5a9e2e4
docs(std): add missing closing code block fences in doc comments
AudaciousAxiom Sep 2, 2025
43873db
test(rustdoc): show the wrong `--emit` precedence
weihanglo Sep 2, 2025
af0d6f1
compiletest: cygwin follows windows in using PATH for dynamic libraries
jeremyd2019 Sep 2, 2025
d9dc20c
raw_vec.rs: Remove superfluous fn alloc_guard
btj Aug 22, 2025
0fa93a3
Disallow frontmatter in `--cfg` and `--check-cfg` arguments
Urgau Sep 2, 2025
c5dd32e
fix(rustdoc): match rustc `--emit` precedence
weihanglo Sep 2, 2025
df5896a
Rename `ToolRustc` to `ToolRustcPrivate`
Kobzol Sep 2, 2025
f19c33e
Split distcheck logic into functions
Kobzol Sep 2, 2025
df2caed
refactor tests to use TestCtx
Shourya742 Sep 3, 2025
c4a5408
Make test parallel
Shourya742 Sep 3, 2025
9f3fe40
remove thread option from self-test invocation
Shourya742 Sep 3, 2025
5c4b61b
don't uppercase error messages
scrabsha Sep 1, 2025
fe90610
Check `rustc-dev` in `distcheck`
Kobzol Sep 2, 2025
a5f52a9
Uncomment code to add scraped rustdoc examples in loaded paths
GuillaumeGomez Sep 3, 2025
e7674cb
rustdoc-search: add test case for indexing every item type
notriddle Sep 2, 2025
fcc413f
htmldocck: fix a bug in relative paths / globs
notriddle Sep 2, 2025
c914c47
Add `read_buf` equivalents for positioned reads
niklasf Apr 29, 2025
fea27a6
triagebot: configure some pings when certain attributes are used
RalfJung Sep 3, 2025
2d20ee7
support keyword-based mentions in tidy
RalfJung Sep 3, 2025
f073f64
Rollup merge of #140459 - niklasf:feature/read-buf-at, r=tgross35
Zalathar Sep 4, 2025
732802c
Rollup merge of #143725 - kennytm:peekable_next_if_map, r=jhpratt
Zalathar Sep 4, 2025
98f6887
Rollup merge of #145209 - hanna-kruppe:path_add_extension, r=tgross35
Zalathar Sep 4, 2025
cd59ee7
Rollup merge of #145342 - dianne:if-let-super-let, r=nnethercote
Zalathar Sep 4, 2025
d71a9b6
Rollup merge of #145750 - btj:drop-alloc-guard, r=tgross35
Zalathar Sep 4, 2025
3a6ae11
Rollup merge of #145827 - estebank:issue-51976, r=jackh726
Zalathar Sep 4, 2025
f90cc35
Rollup merge of #145932 - JamieCunliffe:target-feature-inlining, r=ja…
Zalathar Sep 4, 2025
6c77c4c
Rollup merge of #145962 - bjorn3:linkage_fixes, r=WaffleLapkin
Zalathar Sep 4, 2025
2952b99
Rollup merge of #145963 - heiher:src-analysis-lsx, r=lqd
Zalathar Sep 4, 2025
c7a11f4
Rollup merge of #146054 - joboet:array-repeat-must_use, r=ibraheemdev
Zalathar Sep 4, 2025
57e8a53
Rollup merge of #146090 - Kobzol:invisible-origin-eq, r=petrochenkov
Zalathar Sep 4, 2025
6f490f7
Rollup merge of #146112 - scrabsha:push-utkysktvulto, r=WaffleLapkin
Zalathar Sep 4, 2025
5848328
Rollup merge of #146120 - smoelius:patch-3, r=lqd
Zalathar Sep 4, 2025
1456b67
Rollup merge of #146124 - Kobzol:distcheck-ext, r=jieyouxu
Zalathar Sep 4, 2025
9867486
Rollup merge of #146127 - Kobzol:rename-tool-rustc, r=jieyouxu
Zalathar Sep 4, 2025
3b365d8
Rollup merge of #146131 - notriddle:rustdoc-search-load-itemtype-test…
Zalathar Sep 4, 2025
a1469aa
Rollup merge of #146134 - maurer:nvptx-sync, r=durin42
Zalathar Sep 4, 2025
b27c94a
Rollup merge of #146136 - AudaciousAxiom:docs/missing-closing-code-bl…
Zalathar Sep 4, 2025
10cbfe6
Rollup merge of #146137 - Urgau:cfg-disallow-frontmatter, r=fmease
Zalathar Sep 4, 2025
9214b18
Rollup merge of #146140 - jeremyd2019:patch-1, r=jieyouxu
Zalathar Sep 4, 2025
8fc568e
Rollup merge of #146150 - weihanglo:rustdoc-emit, r=aDotInTheVoid
Zalathar Sep 4, 2025
8b2a64f
Rollup merge of #146155 - Shourya742:2025-09-03-make-test-run-paralle…
Zalathar Sep 4, 2025
c81fffa
Rollup merge of #146161 - GuillaumeGomez:loaded-paths-scraped-example…
Zalathar Sep 4, 2025
11ea573
Rollup merge of #146172 - RalfJung:triagebot-keyword-mentions, r=Urgau
Zalathar Sep 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ pub enum CommentKind {
Block,
}

// This type must not implement `Hash` due to the unusual `PartialEq` impl below.
#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable_Generic)]
#[derive(Copy, Clone, PartialEq, Debug, Encodable, Decodable, HashStable_Generic)]
pub enum InvisibleOrigin {
// From the expansion of a metavariable in a declarative macro.
MetaVar(MetaVarKind),
Expand All @@ -45,20 +44,6 @@ impl InvisibleOrigin {
}
}

impl PartialEq for InvisibleOrigin {
#[inline]
fn eq(&self, _other: &InvisibleOrigin) -> bool {
// When we had AST-based nonterminals we couldn't compare them, and the
// old `Nonterminal` type had an `eq` that always returned false,
// resulting in this restriction:
// https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment
// This `eq` emulates that behaviour. We could consider lifting this
// restriction now but there are still cases involving invisible
// delimiters that make it harder than it first appears.
false
}
}

/// Annoyingly similar to `NonterminalKind`, but the slight differences are important.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)]
pub enum MetaVarKind {
Expand Down Expand Up @@ -142,7 +127,8 @@ impl Delimiter {
}
}

// This exists because `InvisibleOrigin`s should be compared. It is only used for assertions.
// This exists because `InvisibleOrigin`s should not be compared. It is only used for
// assertions.
pub fn eq_ignoring_invisible_origin(&self, other: &Delimiter) -> bool {
match (self, other) {
(Delimiter::Parenthesis, Delimiter::Parenthesis) => true,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ attr_parsing_unrecognized_repr_hint =
attr_parsing_unstable_cfg_target_compact =
compact `cfg(target(..))` is experimental and subject to change

attr_parsing_unstable_feature_bound_incompatible_stability = Item annotated with `#[unstable_feature_bound]` should not be stable
attr_parsing_unstable_feature_bound_incompatible_stability = item annotated with `#[unstable_feature_bound]` should not be stable
.help = If this item is meant to be stable, do not use any functions annotated with `#[unstable_feature_bound]`. Otherwise, mark this item as unstable with `#[unstable]`

attr_parsing_unsupported_literal_cfg_boolean =
Expand Down
31 changes: 21 additions & 10 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ pub(crate) fn apply_to_callsite(callsite: &Value, idx: AttributePlace, attrs: &[
}

/// Get LLVM attribute for the provided inline heuristic.
#[inline]
fn inline_attr<'ll>(cx: &CodegenCx<'ll, '_>, inline: InlineAttr) -> Option<&'ll Attribute> {
pub(crate) fn inline_attr<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
instance: ty::Instance<'tcx>,
) -> Option<&'ll Attribute> {
// `optnone` requires `noinline`
let codegen_fn_attrs = cx.tcx.codegen_fn_attrs(instance.def_id());
let inline = match (codegen_fn_attrs.inline, &codegen_fn_attrs.optimize) {
(_, OptimizeAttr::DoNotOptimize) => InlineAttr::Never,
(InlineAttr::None, _) if instance.def.requires_inline(cx.tcx) => InlineAttr::Hint,
(inline, _) => inline,
};

if !cx.tcx.sess.opts.unstable_opts.inline_llvm {
// disable LLVM inlining
return Some(AttributeKind::NoInline.create_attr(cx.llcx));
Expand Down Expand Up @@ -346,14 +356,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
OptimizeAttr::Speed => {}
}

// `optnone` requires `noinline`
let inline = match (codegen_fn_attrs.inline, &codegen_fn_attrs.optimize) {
(_, OptimizeAttr::DoNotOptimize) => InlineAttr::Never,
(InlineAttr::None, _) if instance.def.requires_inline(cx.tcx) => InlineAttr::Hint,
(inline, _) => inline,
};
to_add.extend(inline_attr(cx, inline));

if cx.sess().must_emit_unwind_tables() {
to_add.push(uwtable_attr(cx.llcx, cx.sess().opts.unstable_opts.use_sync_unwind));
}
Expand Down Expand Up @@ -488,6 +490,14 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
let function_features =
codegen_fn_attrs.target_features.iter().map(|f| f.name.as_str()).collect::<Vec<&str>>();

// Apply function attributes as per usual if there are no user defined
// target features otherwise this will get applied at the callsite.
if function_features.is_empty() {
if let Some(inline_attr) = inline_attr(cx, instance) {
to_add.push(inline_attr);
}
}

let function_features = function_features
.iter()
// Convert to LLVMFeatures and filter out unavailable ones
Expand Down Expand Up @@ -517,6 +527,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
let function_features = function_features.iter().map(|s| s.as_str());
let target_features: String =
global_features.chain(function_features).intersperse(",").collect();

if !target_features.is_empty() {
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features));
}
Expand Down
29 changes: 26 additions & 3 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
fn call(
&mut self,
llty: &'ll Type,
fn_attrs: Option<&CodegenFnAttrs>,
fn_call_attrs: Option<&CodegenFnAttrs>,
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
llfn: &'ll Value,
args: &[&'ll Value],
Expand All @@ -1409,10 +1409,10 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}

// Emit CFI pointer type membership test
self.cfi_type_test(fn_attrs, fn_abi, instance, llfn);
self.cfi_type_test(fn_call_attrs, fn_abi, instance, llfn);

// Emit KCFI operand bundle
let kcfi_bundle = self.kcfi_operand_bundle(fn_attrs, fn_abi, instance, llfn);
let kcfi_bundle = self.kcfi_operand_bundle(fn_call_attrs, fn_abi, instance, llfn);
if let Some(kcfi_bundle) = kcfi_bundle.as_ref().map(|b| b.as_ref()) {
bundles.push(kcfi_bundle);
}
Expand All @@ -1429,6 +1429,29 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
c"".as_ptr(),
)
};

if let Some(instance) = instance {
// Attributes on the function definition being called
let fn_defn_attrs = self.cx.tcx.codegen_fn_attrs(instance.def_id());
if let Some(fn_call_attrs) = fn_call_attrs
&& !fn_call_attrs.target_features.is_empty()
// If there is an inline attribute and a target feature that matches
// we will add the attribute to the callsite otherwise we'll omit
// this and not add the attribute to prevent soundness issues.
&& let Some(inlining_rule) = attributes::inline_attr(&self.cx, instance)
&& self.cx.tcx.is_target_feature_call_safe(
&fn_call_attrs.target_features,
&fn_defn_attrs.target_features,
)
{
attributes::apply_to_callsite(
call,
llvm::AttributePlace::Function,
&[inlining_rule],
);
}
}

if let Some(fn_abi) = fn_abi {
fn_abi.apply_attrs_callsite(self, call);
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ pub(crate) unsafe fn create_module<'ll>(
// LLVM 22.0 updated the default layout on avr: https://github.com/llvm/llvm-project/pull/153010
target_data_layout = target_data_layout.replace("n8:16", "n8")
}
if sess.target.arch == "nvptx64" {
// LLVM 22 updated the NVPTX layout to indicate 256-bit vector load/store: https://github.com/llvm/llvm-project/pull/155198
target_data_layout = target_data_layout.replace("-i256:256", "");
}
}

// Ensure the data-layout values hardcoded remain the defaults.
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ codegen_ssa_dynamic_linking_with_lto =
.note = only 'staticlib', 'bin', and 'cdylib' outputs are supported with LTO

codegen_ssa_error_calling_dlltool =
Error calling dlltool '{$dlltool_path}': {$error}
error calling dlltool '{$dlltool_path}': {$error}

codegen_ssa_error_creating_import_library =
Error creating import library for {$lib_name}: {$error}
error creating import library for {$lib_name}: {$error}

codegen_ssa_error_creating_remark_dir = failed to create remark directory: {$error}

codegen_ssa_error_writing_def_file =
Error writing .DEF file: {$error}
error writing .DEF file: {$error}

codegen_ssa_expected_name_value_pair = expected name value pair

Expand Down Expand Up @@ -264,9 +264,9 @@ codegen_ssa_shuffle_indices_evaluation = could not evaluate shuffle_indices at c

codegen_ssa_specify_libraries_to_link = use the `-l` flag to specify native libraries to link

codegen_ssa_static_library_native_artifacts = Link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.
codegen_ssa_static_library_native_artifacts = link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms.

codegen_ssa_static_library_native_artifacts_to_file = Native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms.
codegen_ssa_static_library_native_artifacts_to_file = native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms.

codegen_ssa_stripping_debug_info_failed = stripping debug info with `{$util}` failed: {$status}
.note = {$output}
Expand Down Expand Up @@ -364,13 +364,13 @@ codegen_ssa_unable_to_run = unable to run `{$util}`: {$error}

codegen_ssa_unable_to_run_dsymutil = unable to run `dsymutil`: {$error}

codegen_ssa_unable_to_write_debugger_visualizer = Unable to write debugger visualizer file `{$path}`: {$error}
codegen_ssa_unable_to_write_debugger_visualizer = unable to write debugger visualizer file `{$path}`: {$error}

codegen_ssa_unexpected_parameter_name = unexpected parameter name
.label = expected `{$prefix_nops}` or `{$entry_nops}`

codegen_ssa_unknown_archive_kind =
Don't know how to build archive of type: {$kind}
don't know how to build archive of type: {$kind}

codegen_ssa_unknown_ctarget_feature =
unknown and unstable feature specified for `-Ctarget-feature`: `{$feature}`
Expand Down
17 changes: 13 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use super::linker::{self, Linker};
use super::metadata::{MetadataPosition, create_wrapper_file};
use super::rpath::{self, RPathConfig};
use super::{apple, versioned_llvm_target};
use crate::base::needs_allocator_shim_for_linking;
use crate::{
CodegenResults, CompiledModule, CrateInfo, NativeLib, errors, looks_like_rust_object_file,
};
Expand Down Expand Up @@ -2080,9 +2081,17 @@ fn add_local_crate_regular_objects(cmd: &mut dyn Linker, codegen_results: &Codeg
}

/// Add object files for allocator code linked once for the whole crate tree.
fn add_local_crate_allocator_objects(cmd: &mut dyn Linker, codegen_results: &CodegenResults) {
if let Some(obj) = codegen_results.allocator_module.as_ref().and_then(|m| m.object.as_ref()) {
cmd.add_object(obj);
fn add_local_crate_allocator_objects(
cmd: &mut dyn Linker,
codegen_results: &CodegenResults,
crate_type: CrateType,
) {
if needs_allocator_shim_for_linking(&codegen_results.crate_info.dependency_formats, crate_type)
{
if let Some(obj) = codegen_results.allocator_module.as_ref().and_then(|m| m.object.as_ref())
{
cmd.add_object(obj);
}
}
}

Expand Down Expand Up @@ -2281,7 +2290,7 @@ fn linker_with_args(
codegen_results,
metadata,
);
add_local_crate_allocator_objects(cmd, codegen_results);
add_local_crate_allocator_objects(cmd, codegen_results, crate_type);

// Avoid linking to dynamic libraries unless they satisfy some undefined symbols
// at the point at which they are specified on the command line.
Expand Down
17 changes: 14 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use rustc_metadata::{
};
use rustc_middle::bug;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols;
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, SymbolExportKind};
use rustc_middle::middle::exported_symbols::{
self, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
};
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
Expand All @@ -22,6 +23,8 @@ use tracing::{debug, warn};

use super::command::Command;
use super::symbol_export;
use crate::back::symbol_export::allocator_shim_symbols;
use crate::base::needs_allocator_shim_for_linking;
use crate::errors;

#[cfg(test)]
Expand Down Expand Up @@ -1827,7 +1830,7 @@ fn exported_symbols_for_non_proc_macro(
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
// Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins
// from any cdylib. The latter doesn't work anyway as we use hidden visibility for
// from any dylib. The latter doesn't work anyway as we use hidden visibility for
// compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) {
symbols.push((
Expand All @@ -1838,6 +1841,14 @@ fn exported_symbols_for_non_proc_macro(
}
});

// Mark allocator shim symbols as exported only if they were generated.
if export_threshold == SymbolExportLevel::Rust
&& needs_allocator_shim_for_linking(tcx.dependency_formats(()), crate_type)
&& tcx.allocator_kind(()).is_some()
{
symbols.extend(allocator_shim_symbols(tcx));
}

symbols
}

Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::config::{CrateType, Lto};
use tracing::info;

use crate::back::symbol_export::{self, symbol_name_for_instance_in_crate};
use crate::back::symbol_export::{self, allocator_shim_symbols, symbol_name_for_instance_in_crate};
use crate::back::write::CodegenContext;
use crate::base::allocator_kind_for_codegen;
use crate::errors::{DynamicLinkingWithLTO, LtoDisallowed, LtoDylib, LtoProcMacro};
use crate::traits::*;

Expand Down Expand Up @@ -115,6 +116,11 @@ pub(super) fn exported_symbols_for_lto(
}
}

// Mark allocator shim symbols as exported only if they were generated.
if export_threshold == SymbolExportLevel::Rust && allocator_kind_for_codegen(tcx).is_some() {
symbols_below_threshold.extend(allocator_shim_symbols(tcx).map(|(name, _kind)| name));
}

symbols_below_threshold
}

Expand Down
52 changes: 26 additions & 26 deletions compiler/rustc_codegen_ssa/src/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_symbol_mangling::mangle_internal_symbol;
use rustc_target::spec::TlsModel;
use tracing::debug;

use crate::base::allocator_kind_for_codegen;
use crate::back::symbol_export;

fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
crates_export_threshold(tcx.crate_types())
Expand Down Expand Up @@ -217,31 +217,6 @@ fn exported_non_generic_symbols_provider_local<'tcx>(
));
}

// Mark allocator shim symbols as exported only if they were generated.
if allocator_kind_for_codegen(tcx).is_some() {
for symbol_name in ALLOCATOR_METHODS
.iter()
.map(|method| mangle_internal_symbol(tcx, global_fn_name(method.name).as_str()))
.chain([
mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
])
{
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));

symbols.push((
exported_symbol,
SymbolExportInfo {
level: SymbolExportLevel::Rust,
kind: SymbolExportKind::Text,
used: false,
rustc_std_internal_symbol: true,
},
));
}
}

// Sort so we get a stable incr. comp. hash.
symbols.sort_by_cached_key(|s| s.0.symbol_name_for_local_instance(tcx));

Expand Down Expand Up @@ -516,6 +491,31 @@ pub(crate) fn provide(providers: &mut Providers) {
upstream_monomorphizations_for_provider;
}

pub(crate) fn allocator_shim_symbols(
tcx: TyCtxt<'_>,
) -> impl Iterator<Item = (String, SymbolExportKind)> {
ALLOCATOR_METHODS
.iter()
.map(move |method| mangle_internal_symbol(tcx, global_fn_name(method.name).as_str()))
.chain([
mangle_internal_symbol(tcx, "__rust_alloc_error_handler"),
mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
])
.map(move |symbol_name| {
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));

(
symbol_export::exporting_symbol_name_for_instance_in_crate(
tcx,
exported_symbol,
LOCAL_CRATE,
),
SymbolExportKind::Text,
)
})
}

fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel {
// We export anything that's not mangled at the "C" layer as it probably has
// to do with ABI concerns. We do not, however, apply such treatment to
Expand Down
Loading
Loading