Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7936070
cleaned up some tests
Kivooeo Jun 8, 2025
1c9f795
Check CoerceUnsized impl validity before coercing
compiler-errors Jun 24, 2025
066ae4c
submodule update
KMJ-007 Jun 25, 2025
7b1c89f
added PrintTAFn flag for autodiff
KMJ-007 Jun 25, 2025
35deb5b
compiler: Trim the misleading C from ExternAbi::CCmse*
workingjubilee Jun 7, 2025
4bdf1c5
compiler: remove misleading 'c' from `abi_c_cmse_nonsecure_call` feature
workingjubilee Jun 24, 2025
383d761
compiler: Trim the misleading C of C-cmse from errors
workingjubilee Jun 7, 2025
1400e2d
tests: s/C-cmse/cmse/
workingjubilee Jun 7, 2025
02a00df
tests: bless s/C-cmse/cmse/
workingjubilee Jun 9, 2025
9cfee73
move unstable book page and account for it
workingjubilee Jun 24, 2025
3beed38
unstable-book: Update cmse feature descriptions
workingjubilee Jun 7, 2025
586a9d1
tests: split out unsupported-in-impls.rs
workingjubilee Jun 24, 2025
12d05d8
tests: migrate unsupported-abi-transmute.rs to extern "rust-invalid"
workingjubilee Jun 24, 2025
78652b7
tests: specify why extern "rust-invalid" cannot be used in varargs test
workingjubilee Jun 24, 2025
087dabf
Sprinkle breadcrumbs around to lead people to the rust-invalid ABI
workingjubilee Jun 25, 2025
c24914e
compiler: fussily sort the huge AbiMap match
workingjubilee Jun 25, 2025
09295af
Add Sub, Mul, Div, Rem as const_traits
SciMind2460 Jun 25, 2025
d2d17c6
Add runtime check to avoid overwrite arg easily in diag and store and…
xizheyin Jun 21, 2025
8825997
Rollup merge of #142146 - workingjubilee:doubt-that-cmse-nonsecure-ab…
jdonszelmann Jun 25, 2025
131a2e4
Rollup merge of #142200 - Kivooeo:tf8, r=jieyouxu
jdonszelmann Jun 25, 2025
63c5a84
Rollup merge of #142724 - xizheyin:avoid_overwrite_args, r=oli-obk
jdonszelmann Jun 25, 2025
69b11c6
Rollup merge of #142809 - KMJ-007:ad-type-analysis-flag, r=ZuseZ4
jdonszelmann Jun 25, 2025
da42289
Rollup merge of #142976 - compiler-errors:coerce-ice, r=fee1-dead
jdonszelmann Jun 25, 2025
20e47aa
Rollup merge of #142992 - workingjubilee:dont-validate-naughty-abis, …
jdonszelmann Jun 25, 2025
c001128
Rollup merge of #143000 - SciMind2460:master, r=jhpratt
jdonszelmann Jun 25, 2025
File filter

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_abi/src/canon_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ impl fmt::Display for CanonAbi {
CanonAbi::Custom => ExternAbi::Custom,
CanonAbi::Arm(arm_call) => match arm_call {
ArmCall::Aapcs => ExternAbi::Aapcs { unwind: false },
ArmCall::CCmseNonSecureCall => ExternAbi::CCmseNonSecureCall,
ArmCall::CCmseNonSecureEntry => ExternAbi::CCmseNonSecureEntry,
ArmCall::CCmseNonSecureCall => ExternAbi::CmseNonSecureCall,
ArmCall::CCmseNonSecureEntry => ExternAbi::CmseNonSecureEntry,
},
CanonAbi::GpuKernel => ExternAbi::GpuKernel,
CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_abi/src/extern_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ pub enum ExternAbi {
unwind: bool,
},
/// extremely constrained barely-C ABI for TrustZone
CCmseNonSecureCall,
CmseNonSecureCall,
/// extremely constrained barely-C ABI for TrustZone
CCmseNonSecureEntry,
CmseNonSecureEntry,

/* gpu */
/// An entry-point function called by the GPU's host
Expand Down Expand Up @@ -140,8 +140,6 @@ macro_rules! abi_impls {
abi_impls! {
ExternAbi = {
C { unwind: false } =><= "C",
CCmseNonSecureCall =><= "C-cmse-nonsecure-call",
CCmseNonSecureEntry =><= "C-cmse-nonsecure-entry",
C { unwind: true } =><= "C-unwind",
Rust =><= "Rust",
Aapcs { unwind: false } =><= "aapcs",
Expand All @@ -150,6 +148,8 @@ abi_impls! {
AvrNonBlockingInterrupt =><= "avr-non-blocking-interrupt",
Cdecl { unwind: false } =><= "cdecl",
Cdecl { unwind: true } =><= "cdecl-unwind",
CmseNonSecureCall =><= "cmse-nonsecure-call",
CmseNonSecureEntry =><= "cmse-nonsecure-entry",
Custom =><= "custom",
EfiApi =><= "efiapi",
Fastcall { unwind: false } =><= "fastcall",
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_lowering/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
feature: sym::abi_riscv_interrupt,
explain: GateReason::Experimental,
}),
ExternAbi::CCmseNonSecureCall => Err(UnstableAbi {
ExternAbi::CmseNonSecureCall => Err(UnstableAbi {
abi,
feature: sym::abi_c_cmse_nonsecure_call,
feature: sym::abi_cmse_nonsecure_call,
explain: GateReason::Experimental,
}),
ExternAbi::CCmseNonSecureEntry => Err(UnstableAbi {
ExternAbi::CmseNonSecureEntry => Err(UnstableAbi {
abi,
feature: sym::cmse_nonsecure_entry,
explain: GateReason::Experimental,
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,14 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
&& !spans.is_empty()
{
let mut span: MultiSpan = spans.clone().into();
err.arg("ty", param_ty.to_string());
let msg = err.dcx.eagerly_translate_to_string(
fluent::borrowck_moved_a_fn_once_in_call_def,
err.args.iter(),
);
err.remove_arg("ty");
for sp in spans {
span.push_span_label(sp, fluent::borrowck_moved_a_fn_once_in_call_def);
span.push_span_label(sp, msg.clone());
}
span.push_span_label(
fn_call_span,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ impl Subdiagnostic for FormatUnusedArg {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
diag.arg("named", self.named);
let msg = diag.eagerly_translate(crate::fluent_generated::builtin_macros_format_unused_arg);
diag.remove_arg("named");
diag.span_label(self.span, msg);
}
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ fn thin_lto(
}

fn enable_autodiff_settings(ad: &[config::AutoDiff]) {
for &val in ad {
for val in ad {
// We intentionally don't use a wildcard, to not forget handling anything new.
match val {
config::AutoDiff::PrintPerf => {
Expand All @@ -599,6 +599,10 @@ fn enable_autodiff_settings(ad: &[config::AutoDiff]) {
config::AutoDiff::PrintTA => {
llvm::set_print_type(true);
}
config::AutoDiff::PrintTAFn(fun) => {
llvm::set_print_type(true); // Enable general type printing
llvm::set_print_type_fun(&fun); // Set specific function to analyze
}
config::AutoDiff::Inline => {
llvm::set_inline(true);
}
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ pub(crate) use self::Enzyme_AD::*;

#[cfg(llvm_enzyme)]
pub(crate) mod Enzyme_AD {
use std::ffi::{CString, c_char};

use libc::c_void;

unsafe extern "C" {
pub(crate) fn EnzymeSetCLBool(arg1: *mut ::std::os::raw::c_void, arg2: u8);
pub(crate) fn EnzymeSetCLString(arg1: *mut ::std::os::raw::c_void, arg2: *const c_char);
}
unsafe extern "C" {
static mut EnzymePrintPerf: c_void;
static mut EnzymePrintActivity: c_void;
static mut EnzymePrintType: c_void;
static mut EnzymeFunctionToAnalyze: c_void;
static mut EnzymePrint: c_void;
static mut EnzymeStrictAliasing: c_void;
static mut looseTypeAnalysis: c_void;
Expand All @@ -86,6 +91,15 @@ pub(crate) mod Enzyme_AD {
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrintType), print as u8);
}
}
pub(crate) fn set_print_type_fun(fun_name: &str) {
let c_fun_name = CString::new(fun_name).unwrap();
unsafe {
EnzymeSetCLString(
std::ptr::addr_of_mut!(EnzymeFunctionToAnalyze),
c_fun_name.as_ptr() as *const c_char,
);
}
}
pub(crate) fn set_print(print: bool) {
unsafe {
EnzymeSetCLBool(std::ptr::addr_of_mut!(EnzymePrint), print as u8);
Expand Down Expand Up @@ -132,6 +146,9 @@ pub(crate) mod Fallback_AD {
pub(crate) fn set_print_type(print: bool) {
unimplemented!()
}
pub(crate) fn set_print_type_fun(fun_name: &str) {
unimplemented!()
}
pub(crate) fn set_print(print: bool) {
unimplemented!()
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_const_eval/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ impl Subdiagnostic for FrameNote {
span.push_span_label(self.span, fluent::const_eval_frame_note_last);
}
let msg = diag.eagerly_translate(fluent::const_eval_frame_note);
diag.remove_arg("times");
diag.remove_arg("where_");
diag.remove_arg("instance");
diag.span_note(span, msg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0775.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Erroneous code example:
```ignore (no longer emitted)
#![feature(cmse_nonsecure_entry)]

pub extern "C-cmse-nonsecure-entry" fn entry_function() {}
pub extern "cmse-nonsecure-entry" fn entry_function() {}
```

To fix this error, compile your code for a Rust target that supports the
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_error_codes/src/error_codes/E0781.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
The `C-cmse-nonsecure-call` ABI can only be used with function pointers.
The `cmse-nonsecure-call` ABI can only be used with function pointers.

Erroneous code example:

```compile_fail,E0781
#![feature(abi_c_cmse_nonsecure_call)]
#![feature(abi_cmse_nonsecure_call)]

pub extern "C-cmse-nonsecure-call" fn test() {}
pub extern "cmse-nonsecure-call" fn test() {}
```

The `C-cmse-nonsecure-call` ABI should be used by casting function pointers to
The `cmse-nonsecure-call` ABI should be used by casting function pointers to
specific addresses.
14 changes: 7 additions & 7 deletions compiler/rustc_error_codes/src/error_codes/E0798.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Functions marked as `C-cmse-nonsecure-call` place restrictions on their
Functions marked as `cmse-nonsecure-call` place restrictions on their
inputs and outputs.

- inputs must fit in the 4 available 32-bit argument registers. Alignment
Expand All @@ -12,12 +12,12 @@ see [arm's aapcs32](https://github.com/ARM-software/abi-aa/releases).

Erroneous code example:

```ignore (only fails on supported targets)
#![feature(abi_c_cmse_nonsecure_call)]
```ignore (host errors will not match for target)
#![feature(abi_cmse_nonsecure_call)]

#[no_mangle]
pub fn test(
f: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32,
f: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32,
) -> u32 {
f(1, 2, 3, 4, 5)
}
Expand All @@ -27,12 +27,12 @@ Arguments' alignment is respected. In the example below, padding is inserted
so that the `u64` argument is passed in registers r2 and r3. There is then no
room left for the final `f32` argument

```ignore (only fails on supported targets)
#![feature(abi_c_cmse_nonsecure_call)]
```ignore (host errors will not match for target)
#![feature(abi_cmse_nonsecure_call)]

#[no_mangle]
pub fn test(
f: extern "C-cmse-nonsecure-call" fn(u32, u64, f32) -> u32,
f: extern "cmse-nonsecure-call" fn(u32, u64, f32) -> u32,
) -> u32 {
f(1, 2, 3.0)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,5 +690,5 @@ E0805: 0805,
// E0723, // unstable feature in `const` context
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
// E0744, // merged into E0728
// E0776, // Removed; cmse_nonsecure_entry is now `C-cmse-nonsecure-entry`
// E0776, // Removed; `#[cmse_nonsecure_entry]` is now `extern "cmse-nonsecure-entry"`
// E0796, // unused error code. We use `static_mut_refs` lint instead.
32 changes: 31 additions & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ pub struct DiagInner {
pub suggestions: Suggestions,
pub args: DiagArgMap,

// This is used to store args and restore them after a subdiagnostic is rendered.
pub reserved_args: DiagArgMap,

/// This is not used for highlighting or rendering any error message. Rather, it can be used
/// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of
/// `span` if there is one. Otherwise, it is `DUMMY_SP`.
Expand Down Expand Up @@ -319,6 +322,7 @@ impl DiagInner {
children: vec![],
suggestions: Suggestions::Enabled(vec![]),
args: Default::default(),
reserved_args: Default::default(),
sort_span: DUMMY_SP,
is_lint: None,
long_ty_path: None,
Expand Down Expand Up @@ -390,7 +394,27 @@ impl DiagInner {
}

pub(crate) fn arg(&mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagArg) {
self.args.insert(name.into(), arg.into_diag_arg(&mut self.long_ty_path));
let name = name.into();
let value = arg.into_diag_arg(&mut self.long_ty_path);
// This assertion is to avoid subdiagnostics overwriting an existing diagnostic arg.
debug_assert!(
!self.args.contains_key(&name) || self.args.get(&name) == Some(&value),
"arg {} already exists",
name
);
self.args.insert(name, value);
}

pub fn remove_arg(&mut self, name: &str) {
self.args.swap_remove(name);
}

pub fn store_args(&mut self) {
self.reserved_args = self.args.clone();
}

pub fn restore_args(&mut self) {
self.args = std::mem::take(&mut self.reserved_args);
}

/// Fields used for Hash, and PartialEq trait.
Expand Down Expand Up @@ -1423,6 +1447,12 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self.downgrade_to_delayed_bug();
self.emit()
}

pub fn remove_arg(&mut self, name: &str) {
if let Some(diag) = self.diag.as_mut() {
diag.remove_arg(name);
}
}
}

/// Destructor bomb: every `Diag` must be consumed (emitted, cancelled, etc.)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ declare_features! (

/// Allows using the `amdgpu-kernel` ABI.
(removed, abi_amdgpu_kernel, "1.77.0", Some(51575), None, 120495),
(removed, abi_c_cmse_nonsecure_call, "CURRENT_RUSTC_VERSION", Some(81391), Some("renamed to abi_cmse_nonsecure_call"), 142146),
(removed, advanced_slice_patterns, "1.42.0", Some(62254),
Some("merged into `#![feature(slice_patterns)]`"), 67712),
(removed, allocator, "1.0.0", None, None),
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ declare_features! (

/// Allows `extern "avr-interrupt" fn()` and `extern "avr-non-blocking-interrupt" fn()`.
(unstable, abi_avr_interrupt, "1.45.0", Some(69664)),
/// Allows `extern "C-cmse-nonsecure-call" fn()`.
(unstable, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391)),
/// Allows `extern "cmse-nonsecure-call" fn()`.
(unstable, abi_cmse_nonsecure_call, "CURRENT_RUSTC_VERSION", Some(81391)),
/// Allows `extern "custom" fn()`.
(unstable, abi_custom, "CURRENT_RUSTC_VERSION", Some(140829)),
/// Allows `extern "gpu-kernel" fn()`.
Expand Down Expand Up @@ -431,7 +431,7 @@ declare_features! (
(unstable, closure_lifetime_binder, "1.64.0", Some(97362)),
/// Allows `#[track_caller]` on closures and coroutines.
(unstable, closure_track_caller, "1.57.0", Some(87417)),
/// Allows `extern "C-cmse-nonsecure-entry" fn()`.
/// Allows `extern "cmse-nonsecure-entry" fn()`.
(unstable, cmse_nonsecure_entry, "1.48.0", Some(75835)),
/// Allows `async {}` expressions in const contexts.
(unstable, const_async_blocks, "1.53.0", Some(85368)),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ hir_analysis_closure_implicit_hrtb = implicit types in closure signatures are fo
.label = `for<...>` is here

hir_analysis_cmse_call_generic =
function pointers with the `"C-cmse-nonsecure-call"` ABI cannot contain generics in their type
function pointers with the `"cmse-nonsecure-call"` ABI cannot contain generics in their type

hir_analysis_cmse_entry_generic =
functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type
functions with the `"cmse-nonsecure-entry"` ABI cannot contain generics in their type

hir_analysis_cmse_inputs_stack_spill =
arguments for `{$abi}` function too large to pass via registers
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub(crate) enum AssocItemNotFoundSugg<'a> {
SimilarInOtherTrait {
#[primary_span]
span: Span,
trait_name: &'a str,
assoc_kind: &'static str,
suggested_name: Symbol,
},
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
fn_sig: ty::PolyFnSig<'tcx>,
) {
match abi {
ExternAbi::CCmseNonSecureCall => {
ExternAbi::CmseNonSecureCall => {
let hir_node = tcx.hir_node(hir_id);
let hir::Node::Ty(hir::Ty {
span: bare_fn_span,
Expand All @@ -38,7 +38,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
dcx,
span,
E0781,
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers"
"the `\"cmse-nonsecure-call\"` ABI is only allowed on function pointers"
)
.emit();
return;
Expand Down Expand Up @@ -78,7 +78,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
}
};
}
ExternAbi::CCmseNonSecureEntry => {
ExternAbi::CmseNonSecureEntry => {
let hir_node = tcx.hir_node(hir_id);
let Some(hir::FnSig { decl, span: fn_sig_span, .. }) = hir_node.fn_sig() else {
// might happen when this ABI is used incorrectly. That will be handled elsewhere
Expand Down Expand Up @@ -203,11 +203,11 @@ fn should_emit_generic_error<'tcx>(abi: ExternAbi, layout_err: &'tcx LayoutError
match layout_err {
TooGeneric(ty) => {
match abi {
ExternAbi::CCmseNonSecureCall => {
ExternAbi::CmseNonSecureCall => {
// prevent double reporting of this error
!ty.is_impl_trait()
}
ExternAbi::CCmseNonSecureEntry => true,
ExternAbi::CmseNonSecureEntry => true,
_ => bug!("invalid ABI: {abi}"),
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// change the associated item.
err.sugg = Some(errors::AssocItemNotFoundSugg::SimilarInOtherTrait {
span: assoc_ident.span,
trait_name: &trait_name,
assoc_kind: assoc_kind_str,
suggested_name,
});
Expand Down
Loading
Loading