Skip to content

Rollup of 8 pull requests #145126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Aug 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
efcae7d
properly use caller-side panic location for some GenericArgs methods
RalfJung Jul 19, 2025
de1b999
atomicrmw on pointers: move integer-pointer cast hacks into backend
RalfJung Jul 19, 2025
6bf3cbe
In rustc_pattern_analysis, put `true` witnesses before `false` witnesses
ChayimFriedman2 Jul 27, 2025
fc46354
more strongly dissuade use of `skip_binder`
lcnr Aug 1, 2025
cdb299c
Enable f16 and f128 on targets that were fixed in LLVM21
tgross35 Aug 6, 2025
9919665
Use `tcx.short_string()` in more diagnostics
estebank Jul 16, 2025
26c12c7
Account for bare tuples in field searching logic
estebank Jul 29, 2025
dd3b825
Do not suggest pinning missing `.get_ref()`
estebank Jul 29, 2025
a17e8cf
Do not provide field typo suggestions for tuples and tuple structs
estebank Jul 30, 2025
eace82c
review comment
estebank Jul 30, 2025
d434cae
Add target_env = "macabi" and target_env = "sim"
madsmtm Mar 1, 2025
2054a0c
mbe: In error messages, don't assume attributes are always proc macros
joshtriplett Jul 28, 2025
bad0d45
mbe: Parse macro attribute rules
joshtriplett Jul 6, 2025
f0a5e70
mbe: Fix error message for using a macro with no `attr` rules as an a…
joshtriplett Jul 28, 2025
0cc0b11
mbe: Emit an error if a macro call has no function-like rules
joshtriplett Aug 8, 2025
34be8ab
mbe: Handle applying attribute rules with paths
joshtriplett Jul 11, 2025
549c2fe
mbe: Handle local `macro_rules` attr resolution
joshtriplett Jul 27, 2025
4f999f7
mbe: Add test for `macro_rules` attributes
joshtriplett Jul 28, 2025
bd5206e
mbe: Add test for attribute expansion with `compile_error!`
joshtriplett Aug 8, 2025
1500195
mbe: Add a test for calling a macro with no function-like rules
joshtriplett Aug 8, 2025
9a9ccc0
mbe: Add parser test for macro attribute recovery
joshtriplett Aug 8, 2025
489734c
mbe: Add a test confirming that a macro attribute can apply itself re…
joshtriplett Jul 28, 2025
f88839d
mbe: Add a test checking for infinite recursion in macro attributes
joshtriplett Jul 28, 2025
6674fe2
Rollup merge of #139451 - madsmtm:apple-target-env-abi, r=wesleywiser
tgross35 Aug 8, 2025
f5dda19
Rollup merge of #144039 - estebank:short-paths, r=fee1-dead
tgross35 Aug 8, 2025
6fa6a85
Rollup merge of #144192 - RalfJung:atomicrmw-ptr, r=nikic
tgross35 Aug 8, 2025
18abf3a
Rollup merge of #144545 - ChayimFriedman2:bool-witness-order, r=Nadri…
tgross35 Aug 8, 2025
804d1a1
Rollup merge of #144579 - joshtriplett:mbe-attr, r=petrochenkov
tgross35 Aug 8, 2025
d47f8ad
Rollup merge of #144649 - estebank:issue-144602, r=lcnr
tgross35 Aug 8, 2025
063e01b
Rollup merge of #144775 - lcnr:skip_binder-comment, r=BoxyUwU
tgross35 Aug 8, 2025
660bf91
Rollup merge of #144987 - tgross35:llvm21-f16-f128, r=nikic
tgross35 Aug 8, 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
24 changes: 12 additions & 12 deletions compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let layout = amount.layout();
match layout.ty.kind() {
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
ty::Uint(_) | ty::Int(_) => {}
_ => {
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
return Ok(());
Expand All @@ -982,7 +982,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old =
fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Add, ptr, amount);

let old = CValue::by_val(old, layout);
let old = CValue::by_val(old, ret.layout());
ret.write_cvalue(fx, old);
}
sym::atomic_xsub => {
Expand All @@ -991,7 +991,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let layout = amount.layout();
match layout.ty.kind() {
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
ty::Uint(_) | ty::Int(_) => {}
_ => {
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
return Ok(());
Expand All @@ -1004,7 +1004,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old =
fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Sub, ptr, amount);

let old = CValue::by_val(old, layout);
let old = CValue::by_val(old, ret.layout());
ret.write_cvalue(fx, old);
}
sym::atomic_and => {
Expand All @@ -1013,7 +1013,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let layout = src.layout();
match layout.ty.kind() {
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
ty::Uint(_) | ty::Int(_) => {}
_ => {
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
return Ok(());
Expand All @@ -1025,7 +1025,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::And, ptr, src);

let old = CValue::by_val(old, layout);
let old = CValue::by_val(old, ret.layout());
ret.write_cvalue(fx, old);
}
sym::atomic_or => {
Expand All @@ -1034,7 +1034,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let layout = src.layout();
match layout.ty.kind() {
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
ty::Uint(_) | ty::Int(_) => {}
_ => {
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
return Ok(());
Expand All @@ -1046,7 +1046,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Or, ptr, src);

let old = CValue::by_val(old, layout);
let old = CValue::by_val(old, ret.layout());
ret.write_cvalue(fx, old);
}
sym::atomic_xor => {
Expand All @@ -1055,7 +1055,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let layout = src.layout();
match layout.ty.kind() {
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
ty::Uint(_) | ty::Int(_) => {}
_ => {
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
return Ok(());
Expand All @@ -1067,7 +1067,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Xor, ptr, src);

let old = CValue::by_val(old, layout);
let old = CValue::by_val(old, ret.layout());
ret.write_cvalue(fx, old);
}
sym::atomic_nand => {
Expand All @@ -1076,7 +1076,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let layout = src.layout();
match layout.ty.kind() {
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
ty::Uint(_) | ty::Int(_) => {}
_ => {
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
return Ok(());
Expand All @@ -1088,7 +1088,7 @@ fn codegen_regular_intrinsic_call<'tcx>(

let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Nand, ptr, src);

let old = CValue::by_val(old, layout);
let old = CValue::by_val(old, ret.layout());
ret.write_cvalue(fx, old);
}
sym::atomic_max => {
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
dst: RValue<'gcc>,
src: RValue<'gcc>,
order: AtomicOrdering,
ret_ptr: bool,
) -> RValue<'gcc> {
let size = get_maybe_pointer_size(src);
let name = match op {
Expand Down Expand Up @@ -1698,14 +1699,18 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let atomic_function = self.context.get_builtin_function(name);
let order = self.context.new_rvalue_from_int(self.i32_type, order.to_gcc());

// FIXME: If `ret_ptr` is true and `src` is an integer, we should really tell GCC
// that this is a pointer operation that needs to preserve provenance -- but like LLVM,
// GCC does not currently seems to support that.
let void_ptr_type = self.context.new_type::<*mut ()>();
let volatile_void_ptr_type = void_ptr_type.make_volatile();
let dst = self.context.new_cast(self.location, dst, volatile_void_ptr_type);
// FIXME(antoyo): not sure why, but we have the wrong type here.
let new_src_type = atomic_function.get_param(1).to_rvalue().get_type();
let src = self.context.new_bitcast(self.location, src, new_src_type);
let res = self.context.new_call(self.location, atomic_function, &[dst, src, order]);
self.context.new_cast(self.location, res, src.get_type())
let res_type = if ret_ptr { void_ptr_type } else { src.get_type() };
self.context.new_cast(self.location, res, res_type)
}

fn atomic_fence(&mut self, order: AtomicOrdering, scope: SynchronizationScope) {
Expand Down
14 changes: 6 additions & 8 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,15 +1327,13 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
&mut self,
op: rustc_codegen_ssa::common::AtomicRmwBinOp,
dst: &'ll Value,
mut src: &'ll Value,
src: &'ll Value,
order: rustc_middle::ty::AtomicOrdering,
ret_ptr: bool,
) -> &'ll Value {
// The only RMW operation that LLVM supports on pointers is compare-exchange.
let requires_cast_to_int = self.val_ty(src) == self.type_ptr()
&& op != rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg;
if requires_cast_to_int {
src = self.ptrtoint(src, self.type_isize());
}
// FIXME: If `ret_ptr` is true and `src` is not a pointer, we *should* tell LLVM that the
// LHS is a pointer and the operation should be provenance-preserving, but LLVM does not
// currently support that (https://github.com/llvm/llvm-project/issues/120837).
let mut res = unsafe {
llvm::LLVMBuildAtomicRMW(
self.llbuilder,
Expand All @@ -1346,7 +1344,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
llvm::False, // SingleThreaded
)
};
if requires_cast_to_int {
if ret_ptr && self.val_ty(res) != self.type_ptr() {
res = self.inttoptr(res, self.type_ptr());
}
res
Expand Down
24 changes: 13 additions & 11 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,24 +377,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
let target_abi = sess.target.options.abi.as_ref();
let target_pointer_width = sess.target.pointer_width;
let version = get_version();
let lt_20_1_1 = version < (20, 1, 1);
let lt_21_0_0 = version < (21, 0, 0);

cfg.has_reliable_f16 = match (target_arch, target_os) {
// Selection failure <https://github.com/llvm/llvm-project/issues/50374>
("s390x", _) => false,
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (now fixed)
// LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in llvm20)
("aarch64", _)
if !cfg.target_features.iter().any(|f| f.as_str() == "neon")
&& version < (20, 1, 1) =>
if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 =>
{
false
}
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
("arm64ec", _) => false,
// Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
("s390x", _) if lt_21_0_0 => false,
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
// Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
("csky", _) => false,
("hexagon", _) => false,
("hexagon", _) if lt_21_0_0 => false, // (fixed in llvm21)
("powerpc" | "powerpc64", _) => false,
("sparc" | "sparc64", _) => false,
("wasm32" | "wasm64", _) => false,
Expand All @@ -407,9 +408,10 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
cfg.has_reliable_f128 = match (target_arch, target_os) {
// Unsupported <https://github.com/llvm/llvm-project/issues/94434>
("arm64ec", _) => false,
// Selection bug <https://github.com/llvm/llvm-project/issues/96432>
("mips64" | "mips64r6", _) => false,
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>
// Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in llvm20)
("mips64" | "mips64r6", _) if lt_20_1_1 => false,
// Selection bug <https://github.com/llvm/llvm-project/issues/95471>. This issue is closed
// but basic math still does not work.
("nvptx64", _) => false,
// Unsupported https://github.com/llvm/llvm-project/issues/121122
("amdgpu", _) => false,
Expand All @@ -419,8 +421,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
// ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
("sparc", _) => false,
// Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
// not fail if our compiler-builtins is linked.
("x86", _) => false,
// not fail if our compiler-builtins is linked. (fixed in llvm21)
("x86", _) if lt_21_0_0 => false,
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
// There are no known problems on other platforms, so the only requirement is that symbols
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ codegen_ssa_invalid_monomorphization_basic_float_type = invalid monomorphization
codegen_ssa_invalid_monomorphization_basic_integer_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
codegen_ssa_invalid_monomorphization_basic_integer_or_ptr_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer or pointer type, found `{$ty}`
codegen_ssa_invalid_monomorphization_cannot_return = invalid monomorphization of `{$name}` intrinsic: cannot return `{$ret_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
codegen_ssa_invalid_monomorphization_cast_wide_pointer = invalid monomorphization of `{$name}` intrinsic: cannot cast wide pointer `{$ty}`
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod tests;

/// The canonical name of the desired SDK for a given target.
pub(super) fn sdk_name(target: &Target) -> &'static str {
match (&*target.os, &*target.abi) {
match (&*target.os, &*target.env) {
("macos", "") => "MacOSX",
("ios", "") => "iPhoneOS",
("ios", "sim") => "iPhoneSimulator",
Expand All @@ -34,7 +34,7 @@ pub(super) fn sdk_name(target: &Target) -> &'static str {
}

pub(super) fn macho_platform(target: &Target) -> u32 {
match (&*target.os, &*target.abi) {
match (&*target.os, &*target.env) {
("macos", _) => object::macho::PLATFORM_MACOS,
("ios", "macabi") => object::macho::PLATFORM_MACCATALYST,
("ios", "sim") => object::macho::PLATFORM_IOSSIMULATOR,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3026,7 +3026,7 @@ pub(crate) fn are_upstream_rust_objects_already_included(sess: &Session) -> bool
/// We need to communicate five things to the linker on Apple/Darwin targets:
/// - The architecture.
/// - The operating system (and that it's an Apple platform).
/// - The environment / ABI.
/// - The environment.
/// - The deployment target.
/// - The SDK version.
fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
Expand All @@ -3040,7 +3040,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
// `sess.target.arch` (`target_arch`) is not detailed enough.
let llvm_arch = sess.target.llvm_target.split_once('-').expect("LLVM target must have arch").0;
let target_os = &*sess.target.os;
let target_abi = &*sess.target.abi;
let target_env = &*sess.target.env;

// The architecture name to forward to the linker.
//
Expand Down Expand Up @@ -3091,14 +3091,14 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
// > - visionos-simulator
// > - xros-simulator
// > - driverkit
let platform_name = match (target_os, target_abi) {
let platform_name = match (target_os, target_env) {
(os, "") => os,
("ios", "macabi") => "mac-catalyst",
("ios", "sim") => "ios-simulator",
("tvos", "sim") => "tvos-simulator",
("watchos", "sim") => "watchos-simulator",
("visionos", "sim") => "visionos-simulator",
_ => bug!("invalid OS/ABI combination for Apple target: {target_os}, {target_abi}"),
_ => bug!("invalid OS/env combination for Apple target: {target_os}, {target_env}"),
};

let min_version = sess.apple_deployment_target().fmt_full().to_string();
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,14 @@ pub enum InvalidMonomorphization<'tcx> {
ty: Ty<'tcx>,
},

#[diag(codegen_ssa_invalid_monomorphization_basic_integer_or_ptr_type, code = E0511)]
BasicIntegerOrPtrType {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},

#[diag(codegen_ssa_invalid_monomorphization_basic_float_type, code = E0511)]
BasicFloatType {
#[primary_span]
Expand Down
Loading
Loading