Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
eb7cb89
implement our own `ulps` check to test `f16`
folkertdev Apr 12, 2026
f40da91
disable `f16` tests when not `target_has_reliable_f16_math`
folkertdev Apr 16, 2026
c4f3110
Fix pointer API to match what was stabilized
calebzulawski May 8, 2026
94a3ba2
Merge pull request #526 from rust-lang/update-pointer-api
calebzulawski May 9, 2026
beafe83
Optimize `swizzle_dyn` for AArch64 with N > 16
Kmeakin May 28, 2026
be090a7
Merge pull request #528 from Kmeakin/km/aarch64-dyn-swizzle
calebzulawski May 30, 2026
b16ee62
Provide `From` impls for AArch64 ACLE tuple types.
Kmeakin May 31, 2026
61ae55e
Use `impl` restrictions over hand-sealed traits
jhpratt May 30, 2026
ae33abe
Add `Mask::last_set` method
Kmeakin Jun 19, 2026
a27ae1d
Merge pull request #532 from Kmeakin/km/simd-last-set
calebzulawski Jun 20, 2026
8e3bfb0
Merge pull request #530 from Kmeakin/km/aarch64-tuple-from-impls
calebzulawski Jun 20, 2026
d7a525f
Merge pull request #529 from jhpratt/master
calebzulawski Jun 20, 2026
30bdfe3
Optimize `swizzle_dyn` for LoongArch64 with N is 16 or 32
heiher Jun 19, 2026
44a03e6
Merge pull request #533 from heiher/swizzle-dyn-loong64
calebzulawski Jun 23, 2026
5b7c840
Merge pull request #518 from folkertdev/test-float-f16
programmerjake Jul 3, 2026
7d497cc
Merge of rust-lang/portable-simd#520: disable `f16` tests for the cra…
workingjubilee Jul 3, 2026
0a63dc6
rustdoc-json: add paths for linked associated items
qaijuang May 11, 2026
08fb51a
address suggested nits
qaijuang Jun 15, 2026
c78d0a7
test with IDs as suggested
qaijuang Jul 16, 2026
da5e0cf
Add splat mangling bug tests (flaky?)
teor2345 Jul 1, 2026
cbb2169
Implement v0 symbol mangling for splat
teor2345 Jul 7, 2026
553dbd7
Doc splat mangling in the reference
teor2345 Jul 14, 2026
a34aad0
Fix typo in symbol-mangling/v0.md
teor2345 Jul 14, 2026
b010737
Merge commit '7d497cca160ae6062acc1a2db838667f83c0b58e' into sync-fro…
folkertdev Jul 19, 2026
e09b887
fix feature gate
folkertdev Jul 20, 2026
b045903
remove now-dead `Sealed` trait
folkertdev Jul 20, 2026
7629861
fix simd tests that use `without_provenance{_mut}`
folkertdev Jul 20, 2026
f32f69b
disable `portable_simd` miri test that needs additional intrinsic sup…
folkertdev Jul 20, 2026
002c50a
Bring runtime symbols `static`s on par with foreign functions
Urgau Jul 18, 2026
7c5c34f
Remove the `static` items specific diagnostic for runtime symbols lints
Urgau Jul 18, 2026
f50b20d
Merge checking for static and foreign functions
Urgau Jul 18, 2026
778a9df
Check only foreign statics with `#[linkage = "..."]`
Urgau Jul 18, 2026
b663a94
Remove `early_exit` closures
nnethercote Jul 21, 2026
a235d0d
Use two local variables
nnethercote Jul 21, 2026
8ae35e2
Remove the `cfg(not(no_global_oom_handling))` from `Drop` impl
maxdexh Jul 21, 2026
e547ba4
relax `f16` `LOG_APPROX` when running tests under Miri
folkertdev Jul 21, 2026
3feb78f
define a `Simd` type in `minicore`
folkertdev Jul 21, 2026
602c462
Remove the blanket `#![cfg_attr(test, allow(unused))]` from bootstrap
Zalathar Jul 21, 2026
0b0c55f
Add layout cycle hang regression test
chenyukang Jul 21, 2026
7f2417b
Refactor is_opsem_inhabited
camsteffen Jul 20, 2026
72814a6
Rollup merge of #159582 - folkertdev:sync-from-portable-simd-2026-07-…
JonathanBrouwer Jul 21, 2026
b659bdb
Rollup merge of #158890 - teor2345:splat-mangling-clash, r=wesleywiser
JonathanBrouwer Jul 21, 2026
89c8e23
Rollup merge of #159647 - nnethercote:rm-early_exit-closures, r=bjorn3
JonathanBrouwer Jul 21, 2026
03e0ba6
Rollup merge of #159656 - folkertdev:minicore-simd, r=jieyouxu
JonathanBrouwer Jul 21, 2026
fde6b5e
Rollup merge of #156474 - qaijuang:rustdoc-json-link-paths, r=aDotInT…
JonathanBrouwer Jul 21, 2026
5b7c131
Rollup merge of #159527 - Urgau:runtime-symbols-static-cleanup, r=Gui…
JonathanBrouwer Jul 21, 2026
f66896f
Rollup merge of #159625 - camsteffen:opsem-inhabited-refactor, r=Ralf…
JonathanBrouwer Jul 21, 2026
63002e1
Rollup merge of #159652 - maxdexh:bugfix/unique-arc-uninit-drop-oom, …
JonathanBrouwer Jul 21, 2026
d361a94
Rollup merge of #159657 - Zalathar:allow-unused, r=jieyouxu
JonathanBrouwer Jul 21, 2026
cace6fe
Rollup merge of #159663 - chenyukang:yukang-fix-153205-layout-cycle-h…
JonathanBrouwer Jul 21, 2026
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
40 changes: 14 additions & 26 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,28 +231,21 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
let sess = &compiler.sess;
let codegen_backend = &*compiler.codegen_backend;

// This is used for early exits unrelated to errors. E.g. when just
// printing some information without compiling, or exiting immediately
// after parsing, etc.
let early_exit = || {
sess.dcx().abort_if_errors();
};

// This implements `-Whelp`. It should be handled very early, like
// `--help`/`-Zhelp`/`-Chelp`. This is the earliest it can run, because
// it must happen after lints are registered, during session creation.
if sess.opts.describe_lints {
describe_lints(sess, registered_lints);
return early_exit();
return;
}

// We have now handled all help options, exit
if help_only {
return early_exit();
return;
}

if print_crate_info(codegen_backend, sess, has_input) == Compilation::Stop {
return early_exit();
return;
}

if !has_input {
Expand All @@ -261,12 +254,12 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))

if !sess.opts.unstable_opts.ls.is_empty() {
list_metadata(sess, &*codegen_backend.metadata_loader());
return early_exit();
return;
}

if sess.opts.unstable_opts.link_only {
process_rlink(sess, compiler);
return early_exit();
return;
}

// Parse the crate root source code (doesn't parse submodules yet)
Expand All @@ -285,28 +278,23 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
pretty::print(sess, pp_mode, pretty::PrintExtra::AfterParsing { krate: &krate });
}
trace!("finished pretty-printing");
return early_exit();
return;
}

if callbacks.after_crate_root_parsing(compiler, &mut krate) == Compilation::Stop {
return early_exit();
return;
}

if sess.opts.unstable_opts.parse_crate_root_only {
return early_exit();
return;
}

let linker = create_and_enter_global_ctxt(compiler, krate, |tcx| {
let early_exit = || {
sess.dcx().abort_if_errors();
None
};

// Make sure name resolution and macro expansion is run.
let _ = tcx.resolver_for_lowering();

if callbacks.after_expansion(compiler, tcx) == Compilation::Stop {
return early_exit();
return None;
}

passes::write_dep_info(tcx);
Expand All @@ -316,11 +304,11 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
if sess.opts.output_types.contains_key(&OutputType::DepInfo)
&& sess.opts.output_types.len() == 1
{
return early_exit();
return None;
}

if sess.opts.unstable_opts.no_analysis {
return early_exit();
return None;
}

tcx.ensure_ok().analysis(());
Expand All @@ -330,16 +318,16 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
}

if callbacks.after_analysis(compiler, tcx) == Compilation::Stop {
return early_exit();
return None;
}

if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
if sess.opts.output_types.contains_key(&OutputType::Mir) {
if let Err(error) = pretty::emit_mir(tcx) {
tcx.dcx().emit_fatal(CantEmitMIR { error });
}
}

let linker = Linker::codegen_and_build_linker(tcx, &*compiler.codegen_backend);
let linker = Linker::codegen_and_build_linker(tcx, codegen_backend);

tcx.report_unused_features();

Expand Down
15 changes: 2 additions & 13 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ pub(crate) enum RedefiningRuntimeSymbolsDiag<'tcx> {
#[help(
"either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = \"{$symbol_name}\")]`, or `#[link_name = \"{$symbol_name}\"]`"
)]
FnDefInvalid { symbol_name: String, expected_fn_sig: Ty<'tcx>, found_fn_sig: Ty<'tcx> },
Invalid { symbol_name: String, expected_fn_sig: Ty<'tcx>, found_fn_sig: Ty<'tcx> },
#[diag(
"suspicious definition of the runtime `{$symbol_name}` symbol used by the standard library"
)]
Expand All @@ -858,18 +858,7 @@ pub(crate) enum RedefiningRuntimeSymbolsDiag<'tcx> {
"either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = \"{$symbol_name}\")]`, or `#[link_name = \"{$symbol_name}\"]`"
)]
#[help("allow this lint if the signature is compatible")]
FnDefSuspicious { symbol_name: String, expected_fn_sig: Ty<'tcx>, found_fn_sig: Ty<'tcx> },
#[diag(
"invalid definition of the runtime `{$symbol_name}` symbol used by the standard library"
)]
#[note(
"expected `{$expected_fn_sig}`
found `static {$symbol_name}: {$static_ty}`"
)]
#[help(
"either fix the signature or remove any attributes `#[unsafe(no_mangle)]` or `#[unsafe(export_name = \"{$symbol_name}\")]`"
)]
Static { symbol_name: String, static_ty: Ty<'tcx>, expected_fn_sig: Ty<'tcx> },
Suspicious { symbol_name: String, expected_fn_sig: Ty<'tcx>, found_fn_sig: Ty<'tcx> },
}

// drop_forget_useless.rs
Expand Down
120 changes: 70 additions & 50 deletions compiler/rustc_lint/src/runtime_symbols.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_hir::def_id::LocalDefId;
use rustc_hir::{self as hir, CanonicalSymbol, FnSig, ForeignItemKind};
use rustc_infer::infer::DefineOpaqueTypes;
use rustc_middle::ty::{self, Instance, Ty};
use rustc_middle::ty::{self, Instance, PolyFnSig, Ty};
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::{Span, Symbol};
use rustc_trait_selection::infer::TyCtxtInferExt;
Expand Down Expand Up @@ -125,7 +125,10 @@ impl<'tcx> LateLintPass<'tcx> for RuntimeSymbols {
check_fn(cx, &symbol_name.name, fn_sig, did);
}
ForeignItemKind::Static(..) => {
check_static(cx, &symbol_name.name, did, item.span);
// We only check static with #[linkage = "..."] attribute (see std weak! macro)
if cx.tcx.codegen_fn_attrs(did).import_linkage.is_some() {
check_static(cx, &symbol_name.name, did, item.span);
}
}
ForeignItemKind::Type => return,
}
Expand Down Expand Up @@ -154,13 +157,72 @@ fn check_fn(cx: &LateContext<'_>, symbol_name: &str, sig: FnSig<'_>, did: LocalD
.tcx
.normalize_erasing_regions(cx.typing_env(), cx.tcx.fn_sig(did).instantiate_identity());

check(cx, symbol_name, did, sig.span, lang_sig, user_sig);
}

fn check_static<'tcx>(cx: &LateContext<'tcx>, symbol_name: &str, did: LocalDefId, sp: Span) {
let s = Symbol::intern(symbol_name);
let Some(CanonicalSymbol { symbol: _, def_id: expected_def_id }) =
cx.tcx.all_canonical_symbols(()).iter().find(|cs| cs.symbol == s)
else {
// The symbol name does not correspond to a runtime symbols, bail out
return;
};

// Get the expected symbol function signature
let lang_sig = cx.tcx.normalize_erasing_regions(
cx.typing_env(),
cx.tcx.fn_sig(expected_def_id).instantiate_identity(),
);

// Get the static type
let outer_user_sig = cx.tcx.type_of(did).instantiate_identity().skip_norm_wip();

// Peel Option<...> and get the inner type (see std weak! macro with #[linkage = "extern_weak"])
let user_sig: Ty<'_> = match outer_user_sig.kind() {
ty::Adt(def, args) if Some(def.did()) == cx.tcx.lang_items().option_type() => {
args.type_at(0)
}
_ => outer_user_sig,
};

let user_sig = if let ty::FnPtr(sig_tys, hdr) = user_sig.kind() {
sig_tys.with(*hdr)
} else {
// not a function pointer, report an error

let lang_sig = Ty::new_fn_ptr(cx.tcx, lang_sig);
cx.emit_span_lint(
INVALID_RUNTIME_SYMBOL_DEFINITIONS,
sp,
RedefiningRuntimeSymbolsDiag::Invalid {
symbol_name: symbol_name.to_string(),
found_fn_sig: user_sig,
expected_fn_sig: lang_sig,
},
);
return;
};

// Compare the signatures and report a warning/error depending on the mismatch
check(cx, symbol_name, did, sp, lang_sig, user_sig);
}

fn check<'tcx>(
cx: &LateContext<'tcx>,
symbol_name: &str,
did: LocalDefId,
sp: Span,
lang_sig: PolyFnSig<'tcx>,
user_sig: PolyFnSig<'tcx>,
) {
// Compare the two signatures with an inference context
let infcx = cx.tcx.infer_ctxt().build(cx.typing_mode());
let cause = rustc_middle::traits::ObligationCause::misc(sig.span, did);
let cause = rustc_middle::traits::ObligationCause::misc(sp, did);
let result = infcx.at(&cause, cx.param_env).eq(DefineOpaqueTypes::No, lang_sig, user_sig);

// If they don't match, emit our own mismatch signatures
if let Err(_terr) = result {
if result.is_err() {
// Create fn pointers for diagnostics purpose
let expected = Ty::new_fn_ptr(cx.tcx, lang_sig);
let actual = Ty::new_fn_ptr(cx.tcx, user_sig);
Expand All @@ -173,8 +235,8 @@ fn check_fn(cx: &LateContext<'_>, symbol_name: &str, sig: FnSig<'_>, did: LocalD
{
cx.emit_span_lint(
INVALID_RUNTIME_SYMBOL_DEFINITIONS,
sig.span,
RedefiningRuntimeSymbolsDiag::FnDefInvalid {
sp,
RedefiningRuntimeSymbolsDiag::Invalid {
symbol_name: symbol_name.to_string(),
found_fn_sig: actual,
expected_fn_sig: expected,
Expand All @@ -183,8 +245,8 @@ fn check_fn(cx: &LateContext<'_>, symbol_name: &str, sig: FnSig<'_>, did: LocalD
} else {
cx.emit_span_lint(
SUSPICIOUS_RUNTIME_SYMBOL_DEFINITIONS,
sig.span,
RedefiningRuntimeSymbolsDiag::FnDefSuspicious {
sp,
RedefiningRuntimeSymbolsDiag::Suspicious {
symbol_name: symbol_name.to_string(),
found_fn_sig: actual,
expected_fn_sig: expected,
Expand All @@ -193,45 +255,3 @@ fn check_fn(cx: &LateContext<'_>, symbol_name: &str, sig: FnSig<'_>, did: LocalD
};
}
}

fn check_static<'tcx>(cx: &LateContext<'tcx>, symbol_name: &str, did: LocalDefId, sp: Span) {
let s = Symbol::intern(symbol_name);
let Some(CanonicalSymbol { symbol: _, def_id: expected_def_id }) =
cx.tcx.all_canonical_symbols(()).iter().find(|cs| cs.symbol == s)
else {
// The symbol name does not correspond to a runtime symbols, bail out
return;
};

// Get the static type
let static_ty = cx.tcx.type_of(did).instantiate_identity().skip_norm_wip();

// Peel Option<...> and get the inner type (see std weak! macro with #[linkage = "extern_weak"])
let inner_static_ty: Ty<'_> = match static_ty.kind() {
ty::Adt(def, args) if Some(def.did()) == cx.tcx.lang_items().option_type() => {
args.type_at(0)
}
_ => static_ty,
};

// Get the expected symbol function signature
let lang_sig = cx.tcx.normalize_erasing_regions(
cx.typing_env(),
cx.tcx.fn_sig(expected_def_id).instantiate_identity(),
);

let expected = Ty::new_fn_ptr(cx.tcx, lang_sig);

// Compare the expected function signature with the static type, report an error if they don't match
if expected != inner_static_ty {
cx.emit_span_lint(
INVALID_RUNTIME_SYMBOL_DEFINITIONS,
sp,
RedefiningRuntimeSymbolsDiag::Static {
static_ty,
symbol_name: symbol_name.to_string(),
expected_fn_sig: expected,
},
);
}
}
Loading
Loading