Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1fc55c7
comment about empty run_passes
jdonszelmann Jun 25, 2026
e54776f
Honor field-level lint attributes in non_snake_case
chenyukang Jul 15, 2026
d2b2602
Improve error messages for disagreeing *target-modifiers*
kulst Jan 10, 2026
078858d
Treat `-Ctarget-cpu` as a target-modifier when targeting AVR, AMDGCN …
kulst Jan 6, 2026
b727274
make debug builders with closures impl with cell
connortsui20 Jul 14, 2026
9c81f66
point at method call chain when a return-position `impl Trait` assoc …
Albab-Hasan Jul 16, 2026
e215910
Update global_asm tests for LLVM 23
nikic Jul 13, 2026
d4a24cd
Adjust codegen test for LLVM 23
nikic Jul 13, 2026
283a60b
Update simd mask test for LLVM 23
nikic Jul 13, 2026
61d9ba2
Disable slice is_ascii() test on LLVM 23
nikic Jul 13, 2026
df6afdf
Adjust PGO tests for LLVM 23
nikic Jul 14, 2026
810a7aa
tests: gate `tests/deubinfo/function-call.rs` on min GDB 15.1
jieyouxu Jul 16, 2026
05bebcd
Update books
rustbot Jul 16, 2026
cbd88d9
Fix safety doc in intrinsics::simd
yilin0518 Jul 16, 2026
14713e5
[aarch64][win] Pass oversized c-variadic args indirectly on Arm64EC
dpaoliello Jul 16, 2026
5245634
add a fallback for `fmuladdf*`
folkertdev Jul 16, 2026
71321f5
Manually implement Clone for GrowableBitSet
DaniPopes Jul 16, 2026
403637b
rustdoc: remove old `--emit` types
notriddle Jul 16, 2026
07069b3
Fix ICE in `write_interface` when the interface file can't be written
cezarbbb Jul 6, 2026
50fd1f1
rustdoc: rename the doc parts metadata params
notriddle Jul 17, 2026
b53cbe1
Update Enzyme to handle LLVM23
ZuseZ4 Jul 14, 2026
e176864
fix grammar
RalfJung Jul 17, 2026
353c194
remove unused check_struct_def
chenyukang Jul 17, 2026
cedf49e
Rollup merge of #150732 - kulst:cpu_is_target_modifier, r=bjorn3
JonathanBrouwer Jul 17, 2026
abe777f
Rollup merge of #159301 - ZuseZ4:enzyme-llvm23, r=nikic
JonathanBrouwer Jul 17, 2026
af6d04b
Rollup merge of #159365 - Albab-Hasan:point-at-chain-in-return-positi…
JonathanBrouwer Jul 17, 2026
4c301c1
Rollup merge of #159402 - yilin0518:fix_simd_2, r=programmerjake
JonathanBrouwer Jul 17, 2026
46b2dd0
Rollup merge of #159410 - notriddle:remove-deprecated-emit-types, r=G…
JonathanBrouwer Jul 17, 2026
916b7dd
Rollup merge of #158398 - jdonszelmann:empty_passes, r=RalfJung
JonathanBrouwer Jul 17, 2026
603330e
Rollup merge of #158843 - cezarbbb:fix-143981-sdylib-write-interface-…
JonathanBrouwer Jul 17, 2026
63736e7
Rollup merge of #159302 - connortsui20:dyn-debug-helpers, r=hanna-kruppe
JonathanBrouwer Jul 17, 2026
f3485c6
Rollup merge of #159332 - chenyukang:yukang-fix-159323-field-lint-exp…
JonathanBrouwer Jul 17, 2026
fe71856
Rollup merge of #159386 - folkertdev:fmuladd-fallback, r=RalfJung
JonathanBrouwer Jul 17, 2026
4cc2813
Rollup merge of #159391 - nikic:llvm23-test-updates, r=cuviper
JonathanBrouwer Jul 17, 2026
e23182a
Rollup merge of #159400 - rustbot:docs-update, r=ehuss
JonathanBrouwer Jul 17, 2026
4692e88
Rollup merge of #159401 - jieyouxu:jieyouxu/test/function-call, r=wor…
JonathanBrouwer Jul 17, 2026
ef7f6fa
Rollup merge of #159404 - dpaoliello:varargarm64ec, r=folkertdev
JonathanBrouwer Jul 17, 2026
238ef89
Rollup merge of #159405 - DaniPopes:bitset-clone-from, r=workingjubilee
JonathanBrouwer Jul 17, 2026
a97a4d9
Rollup merge of #159415 - notriddle:rename-parts-to-dep-meta, r=Guill…
JonathanBrouwer Jul 17, 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
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use rustc_codegen_ssa::{CompiledModules, CrateInfo, TargetConfig, back};
use rustc_log::tracing::info;
use rustc_middle::dep_graph::WorkProductMap;
use rustc_session::Session;
use rustc_session::config::OutputFilenames;
use rustc_session::config::{NATIVE_CPU, OutputFilenames};
use rustc_span::{Symbol, sym};
use rustc_target::spec::{Arch, CfgAbi, Env, Os};

Expand Down Expand Up @@ -341,7 +341,7 @@ fn build_isa(sess: &Session, jit: bool) -> Arc<dyn TargetIsa + 'static> {
let flags = settings::Flags::new(flags_builder);

let isa_builder = match sess.opts.cg.target_cpu.as_deref() {
Some("native") => cranelift_native::builder_with_options(true).unwrap(),
Some(NATIVE_CPU) => cranelift_native::builder_with_options(true).unwrap(),
Some(value) => {
let mut builder =
cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_gcc/src/gcc_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use gccjit::Context;
use rustc_codegen_ssa::target_features;
use rustc_data_structures::smallvec::{SmallVec, smallvec};
use rustc_session::Session;
use rustc_session::config::NATIVE_CPU;
use rustc_target::spec::Arch;

fn gcc_features_by_flags(sess: &Session, features: &mut Vec<String>) {
Expand Down Expand Up @@ -115,7 +116,7 @@ fn arch_to_gcc(name: &str) -> &str {
}

fn handle_native(name: &str) -> &str {
if name != "native" {
if name != NATIVE_CPU {
return arch_to_gcc(name);
}

Expand Down
12 changes: 7 additions & 5 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
use rustc_fs_util::path_to_c_string;
use rustc_middle::bug;
use rustc_session::Session;
use rustc_session::config::{PrintKind, PrintRequest};
use rustc_session::config::{NATIVE_CPU, PrintKind, PrintRequest};
use rustc_target::spec::{
Arch, CfgAbi, Env, MergeFunctions, Os, PanicStrategy, SmallDataThresholdSupport,
};
Expand Down Expand Up @@ -514,10 +514,12 @@ fn print_target_cpus(sess: &Session, tm: &llvm::TargetMachine, out: &mut String)

// Only print the "native" entry when host and target are the same arch,
// since otherwise it could be wrong or misleading.
if sess.host.arch == sess.target.arch {
// Also do not print it if `requires_consistent_cpu` is set, because in this case
// "native" would be rejected.
if sess.host.arch == sess.target.arch && !sess.target.requires_consistent_cpu {
let host = get_host_cpu_name();
cpus.push_front(Cpu {
cpu_name: "native",
cpu_name: NATIVE_CPU,
remark: format!(" - Select the CPU of the current host (currently {host})."),
});
}
Expand Down Expand Up @@ -612,7 +614,7 @@ fn get_host_cpu_name() -> &'static str {
/// LLVM. Otherwise, the string is returned as-is.
fn handle_native(cpu_name: &str) -> &str {
match cpu_name {
"native" => get_host_cpu_name(),
NATIVE_CPU => get_host_cpu_name(),
_ => cpu_name,
}
}
Expand Down Expand Up @@ -666,7 +668,7 @@ pub(crate) fn global_llvm_features(sess: &Session, only_base_features: bool) ->

// -Ctarget-cpu=native
match sess.opts.cg.target_cpu {
Some(ref s) if s == "native" => {
Some(ref s) if s == NATIVE_CPU => {
// We have already figured out the actual CPU name with `LLVMRustGetHostCPUName` and set
// that for LLVM, so the features implied by that CPU name will be available everywhere.
// However, that is not sufficient: e.g. `skylake` alone is not sufficient to tell if
Expand Down
13 changes: 12 additions & 1 deletion compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,11 +1287,22 @@ impl<'a, T: Idx> Iterator for MixedBitIter<'a, T> {
///
/// All operations that involve an element will panic if the element is equal
/// to or greater than the domain size.
#[derive(Clone, Debug, PartialEq)]
#[derive(Debug, PartialEq)]
pub struct GrowableBitSet<T: Idx> {
bit_set: DenseBitSet<T>,
}

// Manually implemented to forward `clone_from`, and to avoid the `T: Clone` bound.
impl<T: Idx> Clone for GrowableBitSet<T> {
fn clone(&self) -> Self {
Self { bit_set: self.bit_set.clone() }
}

fn clone_from(&mut self, source: &Self) {
self.bit_set.clone_from(&source.bit_set);
}
}

impl<T: Idx> Default for GrowableBitSet<T> {
fn default() -> Self {
GrowableBitSet::new_empty()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub(crate) struct TempsDirError;
pub(crate) struct OutDirError;

#[derive(Diagnostic)]
#[diag("failed to write file {$path}: {$error}\"")]
#[diag("failed to write file {$path}: {$error}")]
pub(crate) struct FailedWritingFile<'a> {
pub path: &'a Path,
pub error: io::Error,
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,9 +881,11 @@ pub fn write_interface<'tcx>(tcx: TyCtxt<'tcx>) {
&tcx.sess.psess.attr_id_generator,
);
let export_output = tcx.output_filenames(()).interface_path();
let mut file = fs::File::create_buffered(export_output).unwrap();
if let Err(err) = write!(file, "{}", krate) {
tcx.dcx().fatal(format!("error writing interface file: {}", err));
let mut file = fs::File::create_buffered(&export_output).unwrap_or_else(|error| {
tcx.dcx().emit_fatal(diagnostics::FailedWritingFile { path: &export_output, error })
});
if let Err(error) = write!(file, "{}", krate) {
tcx.dcx().emit_fatal(diagnostics::FailedWritingFile { path: &export_output, error });
}
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_lint/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
}

fn visit_variant_data(&mut self, s: &'tcx hir::VariantData<'tcx>) {
lint_callback!(self, check_struct_def, s);
hir_visit::walk_struct_def(self, s);
}

Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_lint/src/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl EarlyLintPass for NonCamelCaseTypes {

declare_lint! {
/// The `non_snake_case` lint detects variables, methods, functions,
/// lifetime parameters and modules that don't have snake case names.
/// lifetime parameters, named fields and modules that don't have snake case names.
///
/// ### Example
///
Expand Down Expand Up @@ -452,10 +452,8 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
}
}

fn check_struct_def(&mut self, cx: &LateContext<'_>, s: &hir::VariantData<'_>) {
for sf in s.fields() {
self.check_snake_case(cx, "structure field", &sf.ident);
}
fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) {
self.check_snake_case(cx, "structure field", &field.ident);
}
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_lint/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ macro_rules! late_lint_methods {
fn check_trait_item(a: &'tcx rustc_hir::TraitItem<'tcx>);
fn check_impl_item(a: &'tcx rustc_hir::ImplItem<'tcx>);
fn check_impl_item_post(a: &'tcx rustc_hir::ImplItem<'tcx>);
fn check_struct_def(a: &'tcx rustc_hir::VariantData<'tcx>);
fn check_field_def(a: &'tcx rustc_hir::FieldDef<'tcx>);
fn check_variant(a: &'tcx rustc_hir::Variant<'tcx>);
fn check_path(a: &rustc_hir::Path<'tcx>, b: rustc_hir::HirId);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ impl CStore {
flag_name,
flag_name_prefixed,
extern_value: extern_value.to_string(),
has_extern_value: !extern_value.is_empty(),
})
}
(Some(local_value), None) => {
Expand All @@ -390,6 +391,7 @@ impl CStore {
flag_name,
flag_name_prefixed,
local_value: local_value.to_string(),
has_local_value: !local_value.is_empty(),
})
}
(None, None) => panic!("Incorrect target modifiers report_diff(None, None)"),
Expand Down
22 changes: 18 additions & 4 deletions compiler/rustc_metadata/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,16 @@ pub(crate) struct IncompatibleTargetModifiers {
"the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely"
)]
#[note(
"unset `{$flag_name_prefixed}` in this crate is incompatible with `{$flag_name_prefixed}={$extern_value}` in dependency `{$extern_crate}`"
"`{$flag_name_prefixed}` is unset in this crate which is incompatible with {$has_extern_value ->
[false] `{$flag_name_prefixed}` being set
*[other] `{$flag_name_prefixed}={$extern_value}`
} in dependency `{$extern_crate}`"
)]
#[help(
"set `{$flag_name_prefixed}={$extern_value}` in this crate or unset `{$flag_name_prefixed}` in `{$extern_crate}`"
"set {$has_extern_value ->
[false] `{$flag_name_prefixed}`
*[other] `{$flag_name_prefixed}={$extern_value}`
} in this crate or unset `{$flag_name_prefixed}` in `{$extern_crate}`"
)]
#[help(
"if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error"
Expand All @@ -622,6 +628,7 @@ pub(crate) struct IncompatibleTargetModifiersLMissed {
pub flag_name: String,
pub flag_name_prefixed: String,
pub extern_value: String,
pub has_extern_value: bool,
}

#[derive(Diagnostic)]
Expand All @@ -630,10 +637,16 @@ pub(crate) struct IncompatibleTargetModifiersLMissed {
"the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely"
)]
#[note(
"`{$flag_name_prefixed}={$local_value}` in this crate is incompatible with unset `{$flag_name_prefixed}` in dependency `{$extern_crate}`"
"{$has_local_value ->
[false] `{$flag_name_prefixed}` being set
*[other] `{$flag_name_prefixed}={$local_value}`
} in this crate is incompatible with `{$flag_name_prefixed}` being unset in dependency `{$extern_crate}`"
)]
#[help(
"unset `{$flag_name_prefixed}` in this crate or set `{$flag_name_prefixed}={$local_value}` in `{$extern_crate}`"
"unset `{$flag_name_prefixed}` in this crate or set {$has_local_value ->
[false] `{$flag_name_prefixed}`
*[other] `{$flag_name_prefixed}={$local_value}`
} in `{$extern_crate}`"
)]
#[help(
"if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error"
Expand All @@ -646,6 +659,7 @@ pub(crate) struct IncompatibleTargetModifiersRMissed {
pub flag_name: String,
pub flag_name_prefixed: String,
pub local_value: String,
pub has_local_value: bool,
}

#[derive(Diagnostic)]
Expand Down
20 changes: 19 additions & 1 deletion compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ impl MetadataBlob {
"lang_items".to_owned(),
"features".to_owned(),
"items".to_owned(),
"target_modifiers".to_owned(),
];
let ls_kinds = if ls_kinds.contains(&"all".to_owned()) { &all_ls_kinds } else { ls_kinds };

Expand Down Expand Up @@ -919,11 +920,28 @@ impl MetadataBlob {

write!(out, "\n")?;
}
"target_modifiers" => {
writeln!(out, "=Target modifiers=")?;

for modifier in root.decode_target_modifiers(self) {
let extended = modifier.extend();

writeln!(
out,
"-{}{}={} [{}]",
extended.prefix,
extended.name,
modifier.value_name,
extended.tech_value,
)?;
}
}

_ => {
writeln!(
out,
"unknown -Zls kind. allowed values are: all, root, lang_items, features, items"
"unknown -Zls kind. allowed values are: all, root, lang_items, features, items, \
target_modifiers"
)?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) struct DropCheckOverflow<'tcx> {
}

#[derive(Diagnostic)]
#[diag("failed to write file {$path}: {$error}\"")]
#[diag("failed to write file {$path}: {$error}")]
pub(crate) struct FailedWritingFile<'a> {
pub path: &'a Path,
pub error: io::Error,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_mir_transform/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,8 @@ pub(super) fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
// so this would otherwise not get filled).
body.set_mentioned_items(Vec::new());

// We don't pass any passes here, we just force a phase change to `Optimized`.
// Otherwise this bit of MIR will trigger assertions trying to detect MIR with an invalid phase.
pm::run_passes_no_validate(
tcx,
&mut body,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ mod native_libs;
mod print_request;
pub mod sigpipe;

/// Special CPU name requesting the CPU of the current host.
pub const NATIVE_CPU: &str = "native";

/// The different settings that the `-C strip` flag can have.
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
pub enum Strip {
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_session/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,17 @@ pub(crate) struct ThinLtoNotSupportedByBackend;
#[derive(Diagnostic)]
#[diag("`-Zpacked-stack` is only supported on s390x")]
pub(crate) struct UnsupportedPackedStack;

#[derive(Diagnostic)]
#[diag("`-Ctarget-cpu=native` is not allowed for target `{$target_triple}`")]
#[note("this target requires consistent `-Ctarget-cpu` values across all crates")]
#[help(
"specify the target CPU explicitly {$need_explicit_cpu ->
[false] or leave it blank to use the default
*[other] {\"\"}
}"
)]
pub(crate) struct NativeTargetCpuNotAllowed<'a> {
pub(crate) target_triple: &'a TargetTuple,
pub(crate) need_explicit_cpu: bool,
}
30 changes: 28 additions & 2 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,28 @@ mod target_modifier_consistency_check {
}
true
}
pub(super) fn target_cpu(
sess: &Session,
l: &TargetModifier,
r: Option<&TargetModifier>,
) -> bool {
if !sess.target.requires_consistent_cpu {
return true;
}
let l_tech_value = l.extend().tech_value;
let r_tech_value = match r {
Some(r) => r.extend().tech_value,
// If only one of the two compared crates specifies the CPU
// explicitly we compare against the target's default CPU.
None => {
// We reuse the same parsing logic.
CodegenOptionsTargetModifiers::TargetCpu
.reparse(sess.target.cpu.as_ref())
.tech_value
}
};
l_tech_value == r_tech_value
}
}

impl TargetModifier {
Expand All @@ -152,7 +174,11 @@ impl TargetModifier {
}
_ => {}
},
_ => {}
OptionsTargetModifiers::CodegenOptions(codegen) => match codegen {
CodegenOptionsTargetModifiers::TargetCpu => {
return target_modifier_consistency_check::target_cpu(sess, self, other);
}
},
};
match other {
Some(other) => self.extend().tech_value == other.extend().tech_value,
Expand Down Expand Up @@ -2273,7 +2299,7 @@ options! {
symbol_mangling_version: Option<SymbolManglingVersion> = (None,
parse_symbol_mangling_version, [TRACKED],
"which mangling version to use for symbol names ('legacy', 'v0' (default), or 'hashed')"),
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED] { TARGET_MODIFIER: TargetCpu },
"select target processor (`rustc --print target-cpus` for details)"),
target_feature: String = (String::new(), parse_target_feature, [TRACKED],
"target specific attributes. (`rustc --print target-features` for details). \
Expand Down
13 changes: 11 additions & 2 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ use crate::code_stats::CodeStats;
pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
use crate::config::{
self, Cfg, CheckCfg, CoverageLevel, CoverageOptions, CrateType, DebugInfo, ErrorOutputType,
FunctionReturn, Input, InstrumentCoverage, InstrumentMcount, OptLevel, OutFileName, OutputType,
PointerAuthOption, SwitchWithOptPath,
FunctionReturn, Input, InstrumentCoverage, InstrumentMcount, NATIVE_CPU, OptLevel, OutFileName,
OutputType, PointerAuthOption, SwitchWithOptPath,
};
use crate::filesearch::FileSearch;
use crate::lint::LintId;
Expand Down Expand Up @@ -1695,6 +1695,15 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
sess.dcx().emit_err(diagnostics::UnsupportedPackedStack);
}
}

if let Some(ref cpu_name) = sess.opts.cg.target_cpu {
if cpu_name == NATIVE_CPU && sess.target.requires_consistent_cpu {
sess.dcx().emit_fatal(diagnostics::NativeTargetCpuNotAllowed {
target_triple: &sess.opts.target_triple,
need_explicit_cpu: sess.target.need_explicit_cpu,
});
}
}
}

/// Holds data on the current incremental compilation session, if there is one.
Expand Down
Loading
Loading