From bc4ab23772b046b2f30b44efa849a874a90e17dc Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Mon, 29 Jun 2026 18:20:03 +0300 Subject: [PATCH 01/18] std: map ENOTSUP to ErrorKind::Unsupported decode_error_kind maps EOPNOTSUPP to Unsupported but not ENOTSUP. The two are the same value on some targets (Linux, FreeBSD), where that arm already covers both, and different on others (Apple, OpenBSD), where ENOTSUP fell through to Uncategorized. Since they alias on some targets, an or-pattern would be an unreachable arm there; use a match guard, like the existing EAGAIN/EWOULDBLOCK arm. --- library/std/src/sys/io/error/unix.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/io/error/unix.rs b/library/std/src/sys/io/error/unix.rs index c545558c3867e..5bd61e962e6db 100644 --- a/library/std/src/sys/io/error/unix.rs +++ b/library/std/src/sys/io/error/unix.rs @@ -176,11 +176,15 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind { libc::EXDEV => CrossesDevices, libc::EINPROGRESS => InProgress, libc::EMFILE | libc::ENFILE => TooManyOpenFiles, - libc::EOPNOTSUPP => Unsupported, libc::EIO => InputOutputError, libc::EACCES | libc::EPERM => PermissionDenied, + // EOPNOTSUPP and ENOTSUP can have the same value on some systems, + // but different values on others (e.g. Apple), so we can't use a + // match clause + x if x == libc::EOPNOTSUPP || x == libc::ENOTSUP => Unsupported, + // These two constants can have the same value on some systems, // but different values on others, so we can't use a match // clause From 11b6b76a52f016d46a3e178cfa7b209299bcdd57 Mon Sep 17 00:00:00 2001 From: qaijuang <237468078+qaijuang@users.noreply.github.com> Date: Fri, 15 May 2026 02:23:15 -0400 Subject: [PATCH 02/18] Add regression test for ambiguous binop with as _ --- tests/ui/inference/multiple-impl-apply.rs | 14 ++++++++++++++ tests/ui/inference/multiple-impl-apply.stderr | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/ui/inference/multiple-impl-apply.rs b/tests/ui/inference/multiple-impl-apply.rs index 314fe0f2ae510..86d27ccbfa32a 100644 --- a/tests/ui/inference/multiple-impl-apply.rs +++ b/tests/ui/inference/multiple-impl-apply.rs @@ -46,3 +46,17 @@ fn main() { fn magic_foo(arg: Baz) -> Foo { arg.into() } + +struct Value; + +impl PartialEq for u32 { + fn eq(&self, _: &Value) -> bool { + false + } +} + +fn partial_eq_with_infer_cast() { + // https://github.com/rust-lang/rust/issues/156004 + let n: u32 = 17; + let _ = n == 42usize as _; //~ ERROR E0282 +} diff --git a/tests/ui/inference/multiple-impl-apply.stderr b/tests/ui/inference/multiple-impl-apply.stderr index 1a81955e1e88c..b9531fefafed9 100644 --- a/tests/ui/inference/multiple-impl-apply.stderr +++ b/tests/ui/inference/multiple-impl-apply.stderr @@ -18,6 +18,13 @@ help: consider giving `y` an explicit type LL | let y: /* Type */ = x.into(); | ++++++++++++ -error: aborting due to 1 previous error +error[E0282]: type annotations needed + --> $DIR/multiple-impl-apply.rs:61:29 + | +LL | let _ = n == 42usize as _; + | ^ cannot infer type + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0283`. +Some errors have detailed explanations: E0282, E0283. +For more information about an error, try `rustc --explain E0282`. From 587616255737ff483d7ccac445eba3f30d0c2ef9 Mon Sep 17 00:00:00 2001 From: qaijuang <237468078+qaijuang@users.noreply.github.com> Date: Wed, 27 May 2026 11:15:34 -0400 Subject: [PATCH 03/18] Report binop ambiguity for unresolved as _ casts --- compiler/rustc_hir_typeck/src/cast.rs | 71 ++++++++++++++++++- tests/ui/inference/multiple-impl-apply.rs | 45 +++++++++++- tests/ui/inference/multiple-impl-apply.stderr | 52 +++++++++++++- 3 files changed, 161 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 4cbeaa6278049..a303aedb64305 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -34,6 +34,7 @@ use rustc_errors::{Applicability, Diag, ErrorGuaranteed}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::{self as hir, ExprKind}; use rustc_infer::infer::DefineOpaqueTypes; +use rustc_infer::traits::ObligationCauseCode; use rustc_macros::{TypeFoldable, TypeVisitable}; use rustc_middle::mir::Mutability; use rustc_middle::ty::adjustment::AllowTwoPhase; @@ -46,6 +47,7 @@ use rustc_middle::{bug, span_bug}; use rustc_session::lint; use rustc_span::{DUMMY_SP, Span, sym}; use rustc_trait_selection::infer::InferCtxtExt; +use rustc_trait_selection::traits::{self, ObligationCtxt, TraitEngine}; use tracing::{debug, instrument}; use super::FnCtxt; @@ -799,7 +801,16 @@ impl<'a, 'tcx> CastCheck<'tcx> { pub(crate) fn check(mut self, fcx: &FnCtxt<'a, 'tcx>) { let expr_span = self.expr_span_for_type_resolution(fcx); self.expr_ty = fcx.structurally_resolve_type(expr_span, self.expr_ty); - self.cast_ty = fcx.structurally_resolve_type(self.cast_span, self.cast_ty); + self.cast_ty = fcx.resolve_vars_with_obligations(self.cast_ty); + if self.cast_ty.is_ty_var() { + self.cast_ty = if let Some(guar) = self.try_report_ambiguous_binop_for_infer_cast(fcx) { + let err = Ty::new_error(fcx.tcx, guar); + fcx.demand_suptype(self.cast_span, err, self.cast_ty); + err + } else { + fcx.type_must_be_known_at_this_point(self.cast_span, self.cast_ty) + }; + } debug!("check_cast({}, {:?} as {:?})", self.expr.hir_id, self.expr_ty, self.cast_ty); @@ -839,6 +850,64 @@ impl<'a, 'tcx> CastCheck<'tcx> { }; } } + + /// Prefer a pending operator ambiguity over a generic `as _` inference failure. + #[cold] + fn try_report_ambiguous_binop_for_infer_cast( + &self, + fcx: &FnCtxt<'a, 'tcx>, + ) -> Option { + let errors: Vec<_> = fcx + .fulfillment_cx + .borrow() + .pending_obligations() + .into_iter() + .filter_map(|mut obligation| { + let predicate = fcx.resolve_vars_if_possible(obligation.predicate); + if !matches!( + predicate.kind().skip_binder(), + ty::PredicateKind::Clause(ty::ClauseKind::Trait(_)) + ) { + return None; + } + let cast_span = self.cast_span; + + let ObligationCauseCode::BinOp { lhs_hir_id, rhs_hir_id, rhs_span, .. } = + obligation.cause.code() + else { + return None; + }; + let lhs_ty = fcx.resolve_vars_if_possible(fcx.node_ty(*lhs_hir_id)); + let rhs_ty = fcx.resolve_vars_if_possible(fcx.node_ty(*rhs_hir_id)); + + if (fcx.tcx.hir_span(*lhs_hir_id).contains(cast_span) + && lhs_ty.contains(self.cast_ty)) + || (rhs_span.contains(cast_span) && rhs_ty.contains(self.cast_ty)) + { + obligation.cause.span = cast_span; + obligation.predicate = predicate; + + let ocx = ObligationCtxt::new_with_diagnostics(&fcx.infcx); + ocx.register_obligation(obligation); + ocx.evaluate_obligations_error_on_ambiguity().into_iter().find(|error| { + matches!( + error.code, + traits::FulfillmentErrorCode::Ambiguity { overflow: None } + ) + }) + } else { + None + } + }) + .collect(); + + if errors.is_empty() { + None + } else { + Some(fcx.err_ctxt().report_fulfillment_errors(errors.into())) + } + } + /// Checks a cast, and report an error if one exists. In some cases, this /// can return Ok and create type errors in the fcx rather than returning /// directly. coercion-cast is handled in check instead of here. diff --git a/tests/ui/inference/multiple-impl-apply.rs b/tests/ui/inference/multiple-impl-apply.rs index 86d27ccbfa32a..d96ee635317a7 100644 --- a/tests/ui/inference/multiple-impl-apply.rs +++ b/tests/ui/inference/multiple-impl-apply.rs @@ -55,8 +55,47 @@ impl PartialEq for u32 { } } -fn partial_eq_with_infer_cast() { - // https://github.com/rust-lang/rust/issues/156004 +impl PartialEq for Value { + fn eq(&self, _: &u32) -> bool { + false + } +} + +// https://github.com/rust-lang/rust/issues/156004 +fn partial_eq_with_infer_cast_on_rhs() { + let n: u32 = 17; + let _ = n == 42usize as _; //~ ERROR E0283 +} + +fn partial_eq_with_infer_cast_on_lhs() { + let n: u32 = 17; + let _ = 42usize as _ == n; //~ ERROR E0283 +} + +fn unrelated_infer_cast_in_lhs() { let n: u32 = 17; - let _ = n == 42usize as _; //~ ERROR E0282 + let _ = ( + { + let _ = 42usize as _; //~ ERROR E0282 + Default::default() + } + ) == n; +} + +struct AddRhs; + +impl std::ops::Add for u32 { + type Output = (); + + fn add(self, _: AddRhs) {} +} + +impl std::ops::Add for i32 { + type Output = (); + + fn add(self, _: AddRhs) {} +} + +fn add_with_infer_cast_on_lhs() { + let _: () = 42usize as _ + AddRhs; //~ ERROR E0283 } diff --git a/tests/ui/inference/multiple-impl-apply.stderr b/tests/ui/inference/multiple-impl-apply.stderr index b9531fefafed9..b45ca48e62268 100644 --- a/tests/ui/inference/multiple-impl-apply.stderr +++ b/tests/ui/inference/multiple-impl-apply.stderr @@ -18,13 +18,59 @@ help: consider giving `y` an explicit type LL | let y: /* Type */ = x.into(); | ++++++++++++ -error[E0282]: type annotations needed - --> $DIR/multiple-impl-apply.rs:61:29 +error[E0283]: type annotations needed + --> $DIR/multiple-impl-apply.rs:67:29 | LL | let _ = n == 42usize as _; | ^ cannot infer type + | +note: multiple `impl`s satisfying `u32: PartialEq<_>` found + --> $DIR/multiple-impl-apply.rs:52:1 + | +LL | impl PartialEq for u32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: and another `impl` found in the `core` crate: `impl PartialEq for u32;` + +error[E0283]: type annotations needed + --> $DIR/multiple-impl-apply.rs:72:24 + | +LL | let _ = 42usize as _ == n; + | ^ cannot infer type + | +note: multiple `impl`s satisfying `_: PartialEq` found + --> $DIR/multiple-impl-apply.rs:58:1 + | +LL | impl PartialEq for Value { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: and another `impl` found in the `core` crate: `impl PartialEq for u32;` + +error[E0282]: type annotations needed + --> $DIR/multiple-impl-apply.rs:79:17 + | +LL | let _ = 42usize as _; + | ^ - type must be known at this point + | +help: consider giving this pattern a type + | +LL | let _: /* Type */ = 42usize as _; + | ++++++++++++ + +error[E0283]: type annotations needed + --> $DIR/multiple-impl-apply.rs:100:28 + | +LL | let _: () = 42usize as _ + AddRhs; + | ^ cannot infer type + | +note: multiple `impl`s satisfying `_: Add` found + --> $DIR/multiple-impl-apply.rs:87:1 + | +LL | impl std::ops::Add for u32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl std::ops::Add for i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0282, E0283. For more information about an error, try `rustc --explain E0282`. From be32f36e535578f65e6de48ab67e5680337268c6 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Fri, 14 Aug 2026 01:03:45 +0200 Subject: [PATCH 04/18] update bpf abi to match LLVM 23 --- compiler/rustc_target/src/callconv/bpf.rs | 34 +++++- tests/codegen-llvm/bpf-abi-indirect-return.rs | 28 ----- tests/codegen-llvm/bpf-abi/indirect-return.rs | 33 ++++++ .../bpf-abi/struct-return-regs.rs | 107 ++++++++++++++++++ tests/codegen-llvm/bpf-abi/struct-return.rs | 95 ++++++++++++++++ 5 files changed, 265 insertions(+), 32 deletions(-) delete mode 100644 tests/codegen-llvm/bpf-abi-indirect-return.rs create mode 100644 tests/codegen-llvm/bpf-abi/indirect-return.rs create mode 100644 tests/codegen-llvm/bpf-abi/struct-return-regs.rs create mode 100644 tests/codegen-llvm/bpf-abi/struct-return.rs diff --git a/compiler/rustc_target/src/callconv/bpf.rs b/compiler/rustc_target/src/callconv/bpf.rs index 3624f406704e9..d3c936727723e 100644 --- a/compiler/rustc_target/src/callconv/bpf.rs +++ b/compiler/rustc_target/src/callconv/bpf.rs @@ -1,11 +1,33 @@ // see https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/BPF/BPFCallingConv.td -use rustc_abi::TyAbiInterface; +use rustc_abi::{Reg, RegKind, Size, TyAbiInterface}; -use crate::callconv::{ArgAbi, FnAbi}; +use crate::callconv::{ArgAbi, CastTarget, FnAbi, Uniform}; + +fn classify_aggregate_type(arg: &mut ArgAbi<'_, Ty>) { + let size = arg.layout.size; + + match size.bits() { + 0 => return, + 1..=64 => { + arg.cast_to(Reg { kind: RegKind::Integer, size }); + } + 65..=128 => { + arg.cast_to(CastTarget::from(Uniform::new(Reg::i64(), Size::from_bytes(16)))); + } + _ => { + arg.make_indirect(); + } + } +} fn classify_ret(ret: &mut ArgAbi<'_, Ty>) { + if !ret.layout.is_sized() { + // Not touching this... + return; + } + if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 { - ret.make_indirect(); + classify_aggregate_type(ret); } else { ret.extend_integer_width_to(32); } @@ -15,12 +37,16 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) where Ty: TyAbiInterface<'a, C> + Copy, { + if !arg.layout.is_sized() { + // Not touching this... + return; + } if arg.layout.pass_indirectly_in_non_rustic_abis(cx) { arg.make_indirect(); return; } if arg.layout.is_aggregate() || arg.layout.size.bits() > 64 { - arg.make_indirect(); + classify_aggregate_type(arg); } else { arg.extend_integer_width_to(32); } diff --git a/tests/codegen-llvm/bpf-abi-indirect-return.rs b/tests/codegen-llvm/bpf-abi-indirect-return.rs deleted file mode 100644 index a0406742e2210..0000000000000 --- a/tests/codegen-llvm/bpf-abi-indirect-return.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Checks that results larger than one register are returned indirectly -//@ add-minicore -//@ needs-llvm-components: bpf -//@ compile-flags: --target bpfel-unknown-none - -#![crate_type = "lib"] -#![feature(no_core)] -#![no_core] - -extern crate minicore; - -#[no_mangle] -fn outer(a: u64) -> u64 { - inner_big(a).b -} - -struct Big { - a: [u16; 32], - b: u64, -} - -// CHECK-LABEL: define {{.*}} @_R{{.*}}inner_big( -// CHECK-SAME: ptr{{[^,]*}}, -// CHECK-SAME: i64{{[^)]*}} -#[inline(never)] -fn inner_big(a: u64) -> Big { - Big { a: [a as u16; 32], b: 42 } -} diff --git a/tests/codegen-llvm/bpf-abi/indirect-return.rs b/tests/codegen-llvm/bpf-abi/indirect-return.rs new file mode 100644 index 0000000000000..c285bd9431c58 --- /dev/null +++ b/tests/codegen-llvm/bpf-abi/indirect-return.rs @@ -0,0 +1,33 @@ +// Checks that results larger than one register are returned indirectly +//@ add-minicore +//@ revisions: bpfel bpfeb +//@[bpfel] compile-flags: --target=bpfel-unknown-none +//@[bpfeb] compile-flags: --target=bpfeb-unknown-none +//@ needs-llvm-components: bpf +//@ compile-flags: -Copt-level=3 +#![crate_type = "lib"] +#![feature(no_core)] +#![no_core] + +extern crate minicore; + +struct Big { + a: [u16; 32], + b: u64, +} + +// CHECK-LABEL: define{{.*}} @inner_big_rust( +// CHECK-SAME: ptr{{[^,]*}}, +// CHECK-SAME: i64{{[^)]*}} +#[unsafe(no_mangle)] +fn inner_big_rust(a: u64) -> Big { + Big { a: [a as u16; 32], b: 42 } +} + +// CHECK-LABEL: define{{.*}} @inner_big_c( +// CHECK-SAME: ptr{{[^,]*}}, +// CHECK-SAME: i64{{[^)]*}} +#[unsafe(no_mangle)] +extern "C" fn inner_big_c(a: u64) -> Big { + Big { a: [a as u16; 32], b: 42 } +} diff --git a/tests/codegen-llvm/bpf-abi/struct-return-regs.rs b/tests/codegen-llvm/bpf-abi/struct-return-regs.rs new file mode 100644 index 0000000000000..cc97a41d9802d --- /dev/null +++ b/tests/codegen-llvm/bpf-abi/struct-return-regs.rs @@ -0,0 +1,107 @@ +//@ add-minicore +//@ revisions: bpfel bpfeb +//@[bpfel] compile-flags: --target=bpfel-unknown-none +//@[bpfeb] compile-flags: --target=bpfeb-unknown-none +//@ needs-llvm-components: bpf +//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes +//@ min-llvm-version: 23 +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] + +extern crate minicore; +use minicore::*; + +#[repr(C)] +struct Foo0 { + a: i8, +} + +#[repr(C)] +struct Foo1 { + a: i32, +} + +#[repr(C)] +struct Foo2 { + a: i32, + b: i64, +} + +#[repr(C)] +struct Foo3 { + a: i32, + b: i32, + c: i64, +} + +impl Copy for Foo0 {} +impl Copy for Foo1 {} +impl Copy for Foo2 {} +impl Copy for Foo3 {} + +// CHECK-LABEL: define{{.*}} i8 @bar0( +// CHECK: ret i8 +#[no_mangle] +extern "C" fn bar0(a: i8) -> Foo0 { + Foo0 { a } +} + +// CHECK-LABEL: define{{.*}} i32 @bar1( +// CHECK: ret i32 +#[no_mangle] +extern "C" fn bar1(a: i32) -> Foo1 { + Foo1 { a } +} + +// CHECK-LABEL: define{{.*}} [2 x i64] @bar2( +// CHECK: ret [2 x i64] +#[no_mangle] +extern "C" fn bar2(a: i32, b: i32) -> Foo2 { + Foo2 { a, b: b as i64 } +} + +// CHECK-LABEL: define{{.*}} [2 x i64] @bar3( +// CHECK: ret [2 x i64] +#[no_mangle] +extern "C" fn bar3(a: i32, b: i32, c: i32) -> Foo3 { + Foo3 { a, b, c: c as i64 } +} + +// CHECK-LABEL: define{{.*}} i8 @check0( +// CHECK: %[[C1:.*]] = call i8 @bar0( +// CHECK: store i8 %[[C1]] +#[no_mangle] +extern "C" fn check0(a: i8) -> i8 { + let v = bar0(a); + v.a +} + +// CHECK-LABEL: define{{.*}} i32 @check1( +// CHECK: %[[C1:.*]] = call i32 @bar1( +// CHECK: store i32 %[[C1]] +#[no_mangle] +extern "C" fn check1(a: i32) -> i32 { + let v = bar1(a); + v.a +} + +// CHECK-LABEL: define{{.*}} i32 @check2( +// CHECK: %[[C2:.*]] = call [2 x i64] @bar2( +// CHECK: store [2 x i64] %[[C2]] +#[no_mangle] +extern "C" fn check2(a: i32, b: i32) -> i32 { + let v = bar2(a, b); + hint::black_box(v); + v.a +} + +// CHECK-LABEL: define{{.*}} i32 @check3( +// CHECK: %[[C3:.*]] = call [2 x i64] @bar3( +// CHECK: store [2 x i64] %[[C3]] +#[no_mangle] +extern "C" fn check3(a: i32, b: i32, c: i32) -> i32 { + let v = bar3(a, b, c); + hint::black_box(v); + v.a +} diff --git a/tests/codegen-llvm/bpf-abi/struct-return.rs b/tests/codegen-llvm/bpf-abi/struct-return.rs new file mode 100644 index 0000000000000..46871a93aacc8 --- /dev/null +++ b/tests/codegen-llvm/bpf-abi/struct-return.rs @@ -0,0 +1,95 @@ +//@ add-minicore +//@ revisions: bpfel bpfeb +//@[bpfel] compile-flags: --target=bpfel-unknown-none +//@[bpfeb] compile-flags: --target=bpfeb-unknown-none +//@ needs-llvm-components: bpf +//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes +//@ min-llvm-version: 23 +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] + +extern crate minicore; +use minicore::*; + +#[repr(C)] +struct T1 {} + +#[repr(C)] +struct T2 { + a: i32, +} +impl Copy for T2 {} + +#[repr(C)] +struct T3 { + a: i32, + b: i64, +} + +#[repr(C)] +struct T4 { + a: i64, + b: i64, + c: i64, +} + +#[repr(C)] +struct T5 { + a: i8, +} + +#[repr(C)] +union U1 { + a: i32, + b: i64, +} + +// CHECK: define{{.*}} void @foo1() +#[no_mangle] +extern "C" fn foo1() -> T1 { + T1 {} +} + +// CHECK: define{{.*}} i32 @foo2() +#[no_mangle] +extern "C" fn foo2() -> T2 { + T2 { a: 0 } +} + +// CHECK: define{{.*}} [2 x i64] @foo3() +#[no_mangle] +extern "C" fn foo3() -> T3 { + T3 { a: 0, b: 0 } +} + +// CHECK: define{{.*}} void @foo4(ptr{{.*}}sret([24 x i8]){{.*}}align 8 +#[no_mangle] +extern "C" fn foo4() -> T4 { + T4 { a: 0, b: 0, c: 0 } +} + +// CHECK: define{{.*}} i8 @foo5() +#[no_mangle] +extern "C" fn foo5() -> T5 { + T5 { a: 0 } +} + +// CHECK: define{{.*}} i64 @foou() +#[no_mangle] +extern "C" fn foou() -> U1 { + U1 { b: 0 } +} + +// CHECK-LABEL: define{{.*}} i32 @bar() +// CHECK: %[[C2:.*]] = call i32 @foo2() +// CHECK: store i32 %[[C2]] +// CHECK: %[[C3:.*]] = call [2 x i64] @foo3() +// CHECK: store [2 x i64] %[[C3]] +#[no_mangle] +extern "C" fn bar() -> i32 { + let a = foo2(); + let b = foo3(); + hint::black_box((a, b)); + a.a +} From c92b4fd9e10b4dd48afa0efe1f86ec0e9861a071 Mon Sep 17 00:00:00 2001 From: panstromek Date: Sat, 15 Aug 2026 15:12:36 +0200 Subject: [PATCH 05/18] remove unused variable --- compiler/rustc_macros/src/serialize.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 5ae6fb241c98d..9017d8ce1bd34 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -241,7 +241,6 @@ fn encodable_body( } }; - let mut variant_idx = 0usize; let encode_inner = s.each_variant(|vi| { let encode_fields: TokenStream = vi .bindings() @@ -257,7 +256,6 @@ fn encodable_body( result }) .collect(); - variant_idx += 1; encode_fields }); quote! { From df3231a12ce62d6568c31669d44154afa61363a0 Mon Sep 17 00:00:00 2001 From: panstromek Date: Sat, 15 Aug 2026 15:35:34 +0200 Subject: [PATCH 06/18] add comment explaining why we generate two match statements in Encodable derive --- compiler/rustc_macros/src/serialize.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 9017d8ce1bd34..8cfde859bc0b5 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -215,6 +215,9 @@ fn encodable_body( } } _ => { + // This code generates two separate match statements on purpose, because + // LLVM can optimize the first one into direct discriminant read. + // See: https://github.com/rust-lang/rust/pull/108440 let disc = { let mut variant_idx = 0usize; let encode_inner = s.each_variant(|_| { From 71d2bedfcad3361cb799a4accd8720f76fb140cc Mon Sep 17 00:00:00 2001 From: panstromek Date: Sun, 16 Aug 2026 13:06:19 +0200 Subject: [PATCH 07/18] add test to capture Encodable derive output --- tests/ui-fulldeps/derive-encodable.rs | 43 ++++++++ tests/ui-fulldeps/derive-encodable.stdout | 114 ++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 tests/ui-fulldeps/derive-encodable.rs create mode 100644 tests/ui-fulldeps/derive-encodable.stdout diff --git a/tests/ui-fulldeps/derive-encodable.rs b/tests/ui-fulldeps/derive-encodable.rs new file mode 100644 index 0000000000000..daf27cb17b867 --- /dev/null +++ b/tests/ui-fulldeps/derive-encodable.rs @@ -0,0 +1,43 @@ +//@ edition: 2024 +//@ check-pass +//@ compile-flags: -Zunpretty=expanded + +#![crate_type = "rlib"] +#![feature(rustc_private)] + +extern crate rustc_macros; +extern crate rustc_serialize; +extern crate rustc_span; + +use rustc_macros::Encodable; + +#[derive(Encodable)] +struct UnitStruct; + +#[derive(Encodable)] +struct EmptyStruct {} + +#[derive(Encodable)] +enum EmptyEnum {} + +#[derive(Encodable)] +enum SingleFieldlessEnum { + A, +} + +#[derive(Encodable)] +enum SingleEnum { + A(u32), +} + +#[derive(Encodable)] +enum FieldlessEnum { + A, + B, +} + +#[derive(Encodable)] +enum PartlyFieldlessEnum { + A, + B(u32), +} diff --git a/tests/ui-fulldeps/derive-encodable.stdout b/tests/ui-fulldeps/derive-encodable.stdout new file mode 100644 index 0000000000000..a6891b62d36d7 --- /dev/null +++ b/tests/ui-fulldeps/derive-encodable.stdout @@ -0,0 +1,114 @@ +#![feature(prelude_import)] +//@ edition: 2024 +//@ check-pass +//@ compile-flags: -Zunpretty=expanded + +#![crate_type = "rlib"] +#![feature(rustc_private)] +extern crate std; +#[prelude_import] +use std::prelude::rust_2024::*; + +extern crate rustc_macros; +extern crate rustc_serialize; +extern crate rustc_span; + +use rustc_macros::Encodable; + +struct UnitStruct; +const _: () = + { + impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> + for UnitStruct { + fn encode(&self, __encoder: &mut __E) { + match *self { UnitStruct => {} } + } + } + }; + +struct EmptyStruct {} +const _: () = + { + impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> + for EmptyStruct { + fn encode(&self, __encoder: &mut __E) { + match *self { EmptyStruct {} => {} } + } + } + }; + +enum EmptyEnum {} +const _: () = + { + impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> + for EmptyEnum { + fn encode(&self, __encoder: &mut __E) { match *self {} } + } + }; + +enum SingleFieldlessEnum { A, } +const _: () = + { + impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> + for SingleFieldlessEnum { + fn encode(&self, __encoder: &mut __E) { + match *self { SingleFieldlessEnum::A => {} } + } + } + }; + +enum SingleEnum { A(u32), } +const _: () = + { + impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> + for SingleEnum { + fn encode(&self, __encoder: &mut __E) { + match *self { + SingleEnum::A(ref __binding_0) => { + ::rustc_serialize::Encodable::<__E>::encode(__binding_0, + __encoder); + } + } + } + } + }; + +enum FieldlessEnum { A, B, } +const _: () = + { + impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> + for FieldlessEnum { + fn encode(&self, __encoder: &mut __E) { + let disc = + match *self { + FieldlessEnum::A => { 0usize } + FieldlessEnum::B => { 1usize } + }; + ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8); + match *self { FieldlessEnum::A => {} FieldlessEnum::B => {} } + } + } + }; + +enum PartlyFieldlessEnum { A, B(u32), } +const _: () = + { + impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> + for PartlyFieldlessEnum { + fn encode(&self, __encoder: &mut __E) { + let disc = + match *self { + PartlyFieldlessEnum::A => { 0usize } + PartlyFieldlessEnum::B(ref __binding_0) => { 1usize } + }; + ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8); + match *self { + PartlyFieldlessEnum::A => {} + PartlyFieldlessEnum::B(ref __binding_0) => { + ::rustc_serialize::Encodable::<__E>::encode(__binding_0, + __encoder); + } + } + } + } + }; From 26ec2ac85289e3dc699be75946a3278ad35ab5f5 Mon Sep 17 00:00:00 2001 From: panstromek Date: Sat, 15 Aug 2026 15:44:41 +0200 Subject: [PATCH 08/18] Don't generate empty match for fieldless enums in Encodable derive --- compiler/rustc_macros/src/serialize.rs | 47 +++++++++++++---------- tests/ui-fulldeps/derive-encodable.stdout | 1 - 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 8cfde859bc0b5..57383a1cdfce6 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -244,27 +244,32 @@ fn encodable_body( } }; - let encode_inner = s.each_variant(|vi| { - let encode_fields: TokenStream = vi - .bindings() - .iter() - .map(|binding| { - let bind_ident = &binding.binding; - let result = quote! { - ::rustc_serialize::Encodable::<#encoder_ty>::encode( - #bind_ident, - __encoder, - ); - }; - result - }) - .collect(); - encode_fields - }); - quote! { - #disc - match *self { - #encode_inner + if s.variants().iter().all(|v| v.bindings().is_empty()) { + // Avoid generating second match statement if all variants are fieldless + disc + } else { + let encode_inner = s.each_variant(|vi| { + let encode_fields: TokenStream = vi + .bindings() + .iter() + .map(|binding| { + let bind_ident = &binding.binding; + let result = quote! { + ::rustc_serialize::Encodable::<#encoder_ty>::encode( + #bind_ident, + __encoder, + ); + }; + result + }) + .collect(); + encode_fields + }); + quote! { + #disc + match *self { + #encode_inner + } } } } diff --git a/tests/ui-fulldeps/derive-encodable.stdout b/tests/ui-fulldeps/derive-encodable.stdout index a6891b62d36d7..94795d3a2320e 100644 --- a/tests/ui-fulldeps/derive-encodable.stdout +++ b/tests/ui-fulldeps/derive-encodable.stdout @@ -85,7 +85,6 @@ const _: () = FieldlessEnum::B => { 1usize } }; ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8); - match *self { FieldlessEnum::A => {} FieldlessEnum::B => {} } } } }; From e5f1dea36328128e88c0d7559ab49ac0c6dd10ee Mon Sep 17 00:00:00 2001 From: panstromek Date: Sat, 15 Aug 2026 15:46:01 +0200 Subject: [PATCH 09/18] remove redundant variable --- compiler/rustc_macros/src/serialize.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 57383a1cdfce6..8956fca51b442 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -248,9 +248,8 @@ fn encodable_body( // Avoid generating second match statement if all variants are fieldless disc } else { - let encode_inner = s.each_variant(|vi| { - let encode_fields: TokenStream = vi - .bindings() + let encode_inner = s.each_variant(|vi| -> TokenStream { + vi.bindings() .iter() .map(|binding| { let bind_ident = &binding.binding; @@ -262,8 +261,7 @@ fn encodable_body( }; result }) - .collect(); - encode_fields + .collect() }); quote! { #disc From 3efc459948c5bd73906eb68cc2d81b61e63599ad Mon Sep 17 00:00:00 2001 From: panstromek Date: Sat, 15 Aug 2026 16:03:04 +0200 Subject: [PATCH 10/18] Avoid generating match for structs in Encodable derive --- compiler/rustc_macros/src/serialize.rs | 36 ++++++++++++----------- tests/ui-fulldeps/derive-encodable.stdout | 17 ++++------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 8956fca51b442..8de2e1748f1e2 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -194,24 +194,26 @@ fn encodable_body( match *self {} } } - [_] => { - let encode_inner = s.each_variant(|vi| { - vi.bindings() - .iter() - .map(|binding| { - let bind_ident = &binding.binding; - let result = quote! { - ::rustc_serialize::Encodable::<#encoder_ty>::encode( - #bind_ident, - __encoder, - ); - }; - result - }) - .collect::() - }); + [vi] => { + let pat = vi.pat(); + let body = vi + .bindings() + .iter() + .map(|binding| { + let bind_ident = &binding.binding; + let result = quote! { + ::rustc_serialize::Encodable::<#encoder_ty>::encode( + #bind_ident, + __encoder, + ); + }; + result + }) + .collect::(); + quote! { - match *self { #encode_inner } + let #pat = *self; + #body } } _ => { diff --git a/tests/ui-fulldeps/derive-encodable.stdout b/tests/ui-fulldeps/derive-encodable.stdout index 94795d3a2320e..aae4fb5c8b67e 100644 --- a/tests/ui-fulldeps/derive-encodable.stdout +++ b/tests/ui-fulldeps/derive-encodable.stdout @@ -20,9 +20,7 @@ const _: () = { impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> for UnitStruct { - fn encode(&self, __encoder: &mut __E) { - match *self { UnitStruct => {} } - } + fn encode(&self, __encoder: &mut __E) { let UnitStruct = *self; } } }; @@ -32,7 +30,7 @@ const _: () = impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> for EmptyStruct { fn encode(&self, __encoder: &mut __E) { - match *self { EmptyStruct {} => {} } + let EmptyStruct {} = *self; } } }; @@ -52,7 +50,7 @@ const _: () = impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> for SingleFieldlessEnum { fn encode(&self, __encoder: &mut __E) { - match *self { SingleFieldlessEnum::A => {} } + let SingleFieldlessEnum::A = *self; } } }; @@ -63,12 +61,9 @@ const _: () = impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> for SingleEnum { fn encode(&self, __encoder: &mut __E) { - match *self { - SingleEnum::A(ref __binding_0) => { - ::rustc_serialize::Encodable::<__E>::encode(__binding_0, - __encoder); - } - } + let SingleEnum::A(ref __binding_0) = *self; + ::rustc_serialize::Encodable::<__E>::encode(__binding_0, + __encoder); } } }; From 50804da5224ac6dfb0c3561ef4391eb0fdbf3d44 Mon Sep 17 00:00:00 2001 From: panstromek Date: Sat, 15 Aug 2026 16:05:48 +0200 Subject: [PATCH 11/18] don't generate empty match for fieldless enums in Encodable derive --- compiler/rustc_macros/src/serialize.rs | 4 +--- tests/ui-fulldeps/derive-encodable.stdout | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 8de2e1748f1e2..e8be5963898f0 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -190,9 +190,7 @@ fn encodable_body( let encode_body = match s.variants() { [] => { - quote! { - match *self {} - } + quote! {} } [vi] => { let pat = vi.pat(); diff --git a/tests/ui-fulldeps/derive-encodable.stdout b/tests/ui-fulldeps/derive-encodable.stdout index aae4fb5c8b67e..d0485b6d1e64c 100644 --- a/tests/ui-fulldeps/derive-encodable.stdout +++ b/tests/ui-fulldeps/derive-encodable.stdout @@ -40,7 +40,7 @@ const _: () = { impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> for EmptyEnum { - fn encode(&self, __encoder: &mut __E) { match *self {} } + fn encode(&self, __encoder: &mut __E) {} } }; From aa49d140b54cac7e7aaa53fc9ab0640d3ad0cd5a Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Sun, 16 Aug 2026 17:38:34 +0300 Subject: [PATCH 12/18] std: move ENOSYS next to the other Unsupported arms --- library/std/src/sys/io/error/unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/io/error/unix.rs b/library/std/src/sys/io/error/unix.rs index 5bd61e962e6db..ce2a56fa88410 100644 --- a/library/std/src/sys/io/error/unix.rs +++ b/library/std/src/sys/io/error/unix.rs @@ -158,7 +158,6 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind { libc::ENOENT => NotFound, libc::ENOMEM => OutOfMemory, libc::ENOSPC => StorageFull, - libc::ENOSYS => Unsupported, libc::EMLINK => TooManyLinks, libc::ENAMETOOLONG => InvalidFilename, libc::ENETDOWN => NetworkDown, @@ -180,6 +179,7 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind { libc::EACCES | libc::EPERM => PermissionDenied, + libc::ENOSYS => Unsupported, // EOPNOTSUPP and ENOTSUP can have the same value on some systems, // but different values on others (e.g. Apple), so we can't use a // match clause From 8107229db9d10d51a5f49540f2bff298bffa91eb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 16 Aug 2026 22:31:45 +0200 Subject: [PATCH 13/18] remove pointless span for partial-mitigations diagnostics --- compiler/rustc_metadata/src/creader.rs | 5 +-- compiler/rustc_metadata/src/diagnostics.rs | 2 - ...rd-future-allow-reset-by-mitigation.stderr | 20 ---------- .../err-allow-partial-mitigations-1-error.rs | 10 ++--- ...ror.stack-protector-allow-then-deny.stderr | 20 ---------- ...tector-but-allow-control-flow-guard.stderr | 20 ---------- ...or-future-allow-reset-by-mitigation.stderr | 20 ---------- ...ture-deny-allow-reset-by-mitigation.stderr | 20 ---------- ...tor-future-deny-reset-by-mitigation.stderr | 20 ---------- ...tack-protector-future-explicit-deny.stderr | 20 ---------- ...ions-1-error.stack-protector-future.stderr | 20 ---------- ...w-partial-mitigations-2-errors.both.stderr | 40 ------------------- ....enable-separately-disable-together.stderr | 40 ------------------- ....enable-together-disable-separately.stderr | 40 ------------------- .../err-allow-partial-mitigations-2-errors.rs | 20 +++++----- ...ion.control-flow-2024-explicit-deny.stderr | 20 ---------- ...low-partial-mitigations-current-edition.rs | 10 ++--- 17 files changed, 22 insertions(+), 325 deletions(-) diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 880095236b415..25c15fbe8bf04 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -449,7 +449,7 @@ impl CStore { pub fn report_session_incompatibilities(&self, tcx: TyCtxt<'_>, krate: &Crate) { self.report_incompatible_target_modifiers(tcx); - self.report_incompatible_partial_mitigations(tcx, krate); + self.report_incompatible_partial_mitigations(tcx); self.report_incompatible_async_drop_feature(tcx, krate); } @@ -473,7 +473,7 @@ impl CStore { } } - pub fn report_incompatible_partial_mitigations(&self, tcx: TyCtxt<'_>, krate: &Crate) { + pub fn report_incompatible_partial_mitigations(&self, tcx: TyCtxt<'_>) { let my_mitigations = tcx.sess.gather_enabled_denied_partial_mitigations(); let mut my_mitigations: BTreeMap<_, _> = my_mitigations.iter().map(|mitigation| (mitigation.kind, mitigation)).collect(); @@ -500,7 +500,6 @@ impl CStore { *errors += 1; tcx.dcx().emit_err(diagnostics::MitigationLessStrictInDependency { - span: krate.spans.inner_span.shrink_to_lo(), mitigation_name: my_mitigation.kind.to_string(), mitigation_level: my_mitigation.level.level_str().to_string(), extern_crate: data.name(), diff --git a/compiler/rustc_metadata/src/diagnostics.rs b/compiler/rustc_metadata/src/diagnostics.rs index 16af9baac448f..b98a0ce25af37 100644 --- a/compiler/rustc_metadata/src/diagnostics.rs +++ b/compiler/rustc_metadata/src/diagnostics.rs @@ -664,8 +664,6 @@ pub(crate) struct UnusedCrateDependency { "it is possible to disable `-Z allow-partial-mitigations={$mitigation_name}` via `-Z deny-partial-mitigations={$mitigation_name}`" )] pub(crate) struct MitigationLessStrictInDependency { - #[primary_span] - pub span: Span, pub mitigation_name: String, pub mitigation_level: String, pub extern_crate: Symbol, diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.control-flow-guard-future-allow-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.control-flow-guard-future-allow-reset-by-mitigation.stderr index 1103e17a17f59..bdb8962a408a7 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.control-flow-guard-future-allow-reset-by-mitigation.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.control-flow-guard-future-allow-reset-by-mitigation.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.rs b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.rs index 09fe013cfdd34..3d8b39145ec8d 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.rs +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.rs @@ -35,8 +35,8 @@ //@ [stack-protector-future-deny-allow-reset-by-mitigation] compile-flags: -Z unstable-options -Z deny-partial-mitigations=stack-protector -Z allow-partial-mitigations=stack-protector -Z stack-protector=all fn main() {} -//~^ ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-allow-then-deny.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-allow-then-deny.stderr index 3fde64abb2f36..cb791558ad1bb 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-allow-then-deny.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-allow-then-deny.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-but-allow-control-flow-guard.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-but-allow-control-flow-guard.stderr index 3fde64abb2f36..cb791558ad1bb 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-but-allow-control-flow-guard.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-but-allow-control-flow-guard.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-allow-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-allow-reset-by-mitigation.stderr index 3fde64abb2f36..cb791558ad1bb 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-allow-reset-by-mitigation.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-allow-reset-by-mitigation.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-allow-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-allow-reset-by-mitigation.stderr index 3fde64abb2f36..cb791558ad1bb 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-allow-reset-by-mitigation.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-allow-reset-by-mitigation.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-reset-by-mitigation.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-reset-by-mitigation.stderr index 3fde64abb2f36..cb791558ad1bb 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-reset-by-mitigation.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-deny-reset-by-mitigation.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-explicit-deny.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-explicit-deny.stderr index 3fde64abb2f36..cb791558ad1bb 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-explicit-deny.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future-explicit-deny.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future.stderr index 3fde64abb2f36..cb791558ad1bb 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-1-error.stack-protector-future.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-1-error.rs:37:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.both.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.both.stderr index acc9dd234c693..2d7f3f904101a 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.both.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.both.stderr @@ -1,89 +1,49 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-separately-disable-together.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-separately-disable-together.stderr index acc9dd234c693..2d7f3f904101a 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-separately-disable-together.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-separately-disable-together.stderr @@ -1,89 +1,49 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-together-disable-separately.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-together-disable-separately.stderr index acc9dd234c693..2d7f3f904101a 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-together-disable-separately.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.enable-together-disable-separately.stderr @@ -1,89 +1,49 @@ error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `unwind/libc`, that is not compiled with `stack-protector=all` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z deny-partial-mitigations=stack-protector` error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-2-errors.rs:21:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.rs b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.rs index 3424ed2a8dd9c..8562bd1660034 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.rs +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-2-errors.rs @@ -19,13 +19,13 @@ //@ [enable-together-disable-separately] compile-flags: -Z unstable-options -C control-flow-guard=on -Z stack-protector=all -Z allow-partial-mitigations=stack-protector,control-flow-guard -Z deny-partial-mitigations=control-flow-guard -Z deny-partial-mitigations=stack-protector fn main() {} -//~^ ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.control-flow-2024-explicit-deny.stderr b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.control-flow-2024-explicit-deny.stderr index 8f19f30d76569..bdb8962a408a7 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.control-flow-2024-explicit-deny.stderr +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.control-flow-2024-explicit-deny.stderr @@ -1,44 +1,24 @@ error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1 - | -LL | fn main() {} - | ^ | = note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1 - | -LL | fn main() {} - | ^ | = note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1 - | -LL | fn main() {} - | ^ | = note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1 - | -LL | fn main() {} - | ^ | = note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` error: your program uses the crate `unwind/libc`, that is not compiled with `control-flow-guard` enabled - --> $DIR/err-allow-partial-mitigations-current-edition.rs:18:1 - | -LL | fn main() {} - | ^ | = note: recompile `unwind/libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation partially enabled = help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z deny-partial-mitigations=control-flow-guard` diff --git a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs index a9dc29290d7b4..f400319f39efe 100644 --- a/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs +++ b/tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs @@ -16,8 +16,8 @@ fn main() {} -//~^ ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with -//~| ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with +//~? ERROR that is not compiled with From 2828d3e329948e56f2d8dd5f4397642ce66c25f4 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Mon, 17 Aug 2026 13:56:23 +0100 Subject: [PATCH 14/18] mailmap: Add Wilfred --- .mailmap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.mailmap b/.mailmap index 19adab647a553..61d85c105549c 100644 --- a/.mailmap +++ b/.mailmap @@ -716,6 +716,8 @@ Weihang Lo Weihang Lo Wesley Wiser whitequark +Wilfred Hughes +Wilfred Hughes Will Crichton Will Crichton William Ting From 93510b82535de603850bd67595b901624b257d97 Mon Sep 17 00:00:00 2001 From: panstromek Date: Sun, 16 Aug 2026 13:19:24 +0200 Subject: [PATCH 15/18] Don't generate code in for all Unit-like types Encodable derive --- compiler/rustc_macros/src/serialize.rs | 5 +++++ tests/ui-fulldeps/derive-encodable.stdout | 10 +++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index e8be5963898f0..801c12e776770 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -192,6 +192,11 @@ fn encodable_body( [] => { quote! {} } + // Unit-like types don't need to encode anything. + // This covers fieldless structs and enums with zero or one fieldless variant. + [vi] if vi.bindings().is_empty() => { + quote! {} + } [vi] => { let pat = vi.pat(); let body = vi diff --git a/tests/ui-fulldeps/derive-encodable.stdout b/tests/ui-fulldeps/derive-encodable.stdout index d0485b6d1e64c..50700ab15f9c5 100644 --- a/tests/ui-fulldeps/derive-encodable.stdout +++ b/tests/ui-fulldeps/derive-encodable.stdout @@ -20,7 +20,7 @@ const _: () = { impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> for UnitStruct { - fn encode(&self, __encoder: &mut __E) { let UnitStruct = *self; } + fn encode(&self, __encoder: &mut __E) {} } }; @@ -29,9 +29,7 @@ const _: () = { impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> for EmptyStruct { - fn encode(&self, __encoder: &mut __E) { - let EmptyStruct {} = *self; - } + fn encode(&self, __encoder: &mut __E) {} } }; @@ -49,9 +47,7 @@ const _: () = { impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E> for SingleFieldlessEnum { - fn encode(&self, __encoder: &mut __E) { - let SingleFieldlessEnum::A = *self; - } + fn encode(&self, __encoder: &mut __E) {} } }; From 2a56199cb5f1b184d04e1ed9792329439ae82af1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 17 Aug 2026 17:09:32 +0200 Subject: [PATCH 16/18] document meaning of empty feature name in correct_fixed_length_vector_abi tables --- compiler/rustc_target/src/target_features.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 1ba821c57214f..0500c1619f301 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -1099,7 +1099,8 @@ pub fn feature_to_arch_names(feature: &str) -> Vec<&'static str> { } // These arrays represent the least-constraining feature that is required for vector types up to a -// certain size to have their "proper" ABI on each architecture. +// certain size to have their "proper" ABI on each architecture. An empty feature name means +// that the given length is unconditionally available. // Note that they must be kept sorted by vector size. const X86_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI: &'static [(u64, &'static str)] = &[(128, "sse"), (256, "avx"), (512, "avx512f")]; // FIXME: might need changes for AVX10. From 87fd65991e7dbde2e0176cb99519385e5f2ecb27 Mon Sep 17 00:00:00 2001 From: "Bang, Ly {MMSL~BASEL}" Date: Mon, 17 Aug 2026 23:55:56 +0700 Subject: [PATCH 17/18] Add regression test for missing size bound suggestion for trait item --- .../missing/missing-items/auxiliary/randmock.rs | 4 ++++ .../missing-size-bound-issue-85643.rs | 15 +++++++++++++++ .../missing-size-bound-issue-85643.stderr | 11 +++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/ui/missing/missing-items/auxiliary/randmock.rs create mode 100644 tests/ui/missing/missing-items/missing-size-bound-issue-85643.rs create mode 100644 tests/ui/missing/missing-items/missing-size-bound-issue-85643.stderr diff --git a/tests/ui/missing/missing-items/auxiliary/randmock.rs b/tests/ui/missing/missing-items/auxiliary/randmock.rs new file mode 100644 index 0000000000000..a2215bb775f07 --- /dev/null +++ b/tests/ui/missing/missing-items/auxiliary/randmock.rs @@ -0,0 +1,4 @@ +pub trait SecondTestTrait{} +pub trait TestTrait { + fn test(&self, rng: &mut R) -> T; +} diff --git a/tests/ui/missing/missing-items/missing-size-bound-issue-85643.rs b/tests/ui/missing/missing-items/missing-size-bound-issue-85643.rs new file mode 100644 index 0000000000000..d2f792867da9b --- /dev/null +++ b/tests/ui/missing/missing-items/missing-size-bound-issue-85643.rs @@ -0,0 +1,15 @@ +// Regression test for issue https://github.com/rust-lang/rust/issues/85643 +// where ?Sized bound is missing from suggestion + +//@ aux-build: randmock.rs + +extern crate randmock; + +use randmock::*; + +struct D; + +impl TestTrait<()> for D {} +//~^ ERROR not all trait items implemented, missing: `test` +//~| HELP implement the missing item: `fn test(&self, _: &mut R) where R: ?Sized, R: SecondTestTrait { todo!() }` +fn main() {} diff --git a/tests/ui/missing/missing-items/missing-size-bound-issue-85643.stderr b/tests/ui/missing/missing-items/missing-size-bound-issue-85643.stderr new file mode 100644 index 0000000000000..ee0a63eed9243 --- /dev/null +++ b/tests/ui/missing/missing-items/missing-size-bound-issue-85643.stderr @@ -0,0 +1,11 @@ +error[E0046]: not all trait items implemented, missing: `test` + --> $DIR/missing-size-bound-issue-85643.rs:12:1 + | +LL | impl TestTrait<()> for D {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ missing `test` in implementation + | + = help: implement the missing item: `fn test(&self, _: &mut R) where R: ?Sized, R: SecondTestTrait { todo!() }` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0046`. From 9755e3186e20526f5040db57d6a0d796a3c4a9a5 Mon Sep 17 00:00:00 2001 From: okaneco <47607823+okaneco@users.noreply.github.com> Date: Mon, 17 Aug 2026 13:05:10 -0400 Subject: [PATCH 18/18] core/num: Implement feature `float_nan_to` Add function `nan_to` on floats which replaces NaN values with a user-specified value or returns the original value if it is not a NaN. --- library/core/src/num/f128.rs | 27 +++++++++++++++++++++++++++ library/core/src/num/f16.rs | 27 +++++++++++++++++++++++++++ library/core/src/num/f32.rs | 24 ++++++++++++++++++++++++ library/core/src/num/f64.rs | 24 ++++++++++++++++++++++++ 4 files changed, 102 insertions(+) diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 4875835695e69..e876b2d7bd312 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -1602,6 +1602,33 @@ impl f128 { pub const fn algebraic_rem(self, rhs: f128) -> f128 { intrinsics::frem_algebraic(self, rhs) } + + /// Returns `self` if the value is not NaN, otherwise returns `replacement` + /// if `self` is NaN. + /// + /// # Examples + /// + /// ``` + /// #![feature(f128)] + /// #![feature(float_nan_to)] + /// # #[cfg(target_has_reliable_f128)] { + /// + /// let n = f128::NAN; + /// let x = 2.0f128; + /// let y = f128::INFINITY; + /// + /// assert_eq!(n.nan_to(0.0f128), 0.0f128); + /// assert_eq!(x.nan_to(0.0f128), 2.0f128); + /// assert_eq!(y.nan_to(0.0f128), f128::INFINITY); + /// # } + /// ``` + #[must_use = "method returns a new float and does not mutate the original value"] + #[unstable(feature = "float_nan_to", issue = "161248")] + #[rustc_const_unstable(feature = "float_nan_to", issue = "161248")] + #[inline] + pub const fn nan_to(self, replacement: f128) -> f128 { + if self.is_nan() { replacement } else { self } + } } // Functions in this module fall into `core_float_math` diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index 186945db9ae92..e649f6643fe59 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -1588,6 +1588,33 @@ impl f16 { pub const fn algebraic_rem(self, rhs: f16) -> f16 { intrinsics::frem_algebraic(self, rhs) } + + /// Returns `self` if the value is not NaN, otherwise returns `replacement` + /// if `self` is NaN. + /// + /// # Examples + /// + /// ``` + /// #![feature(f16)] + /// #![feature(float_nan_to)] + /// # #[cfg(target_has_reliable_f16)] { + /// + /// let n = f16::NAN; + /// let x = 2.0f16; + /// let y = f16::INFINITY; + /// + /// assert_eq!(n.nan_to(0.0f16), 0.0f16); + /// assert_eq!(x.nan_to(0.0f16), 2.0f16); + /// assert_eq!(y.nan_to(0.0f16), f16::INFINITY); + /// # } + /// ``` + #[must_use = "method returns a new float and does not mutate the original value"] + #[unstable(feature = "float_nan_to", issue = "161248")] + #[rustc_const_unstable(feature = "float_nan_to", issue = "161248")] + #[inline] + pub const fn nan_to(self, replacement: f16) -> f16 { + if self.is_nan() { replacement } else { self } + } } // Functions in this module fall into `core_float_math` diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 49271ae6e01a9..971ecac73d6a6 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -1783,6 +1783,30 @@ impl f32 { pub const fn algebraic_rem(self, rhs: f32) -> f32 { intrinsics::frem_algebraic(self, rhs) } + + /// Returns `self` if the value is not NaN, otherwise returns `replacement` + /// if `self` is NaN. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_nan_to)] + /// + /// let n = f32::NAN; + /// let x = 2.0f32; + /// let y = f32::INFINITY; + /// + /// assert_eq!(n.nan_to(0.0f32), 0.0f32); + /// assert_eq!(x.nan_to(0.0f32), 2.0f32); + /// assert_eq!(y.nan_to(0.0f32), f32::INFINITY); + /// ``` + #[must_use = "method returns a new float and does not mutate the original value"] + #[unstable(feature = "float_nan_to", issue = "161248")] + #[rustc_const_unstable(feature = "float_nan_to", issue = "161248")] + #[inline] + pub const fn nan_to(self, replacement: f32) -> f32 { + if self.is_nan() { replacement } else { self } + } } /// Experimental implementations of floating point functions in `core`. diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 77369b723511f..724bfd2a08f6e 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -1763,6 +1763,30 @@ impl f64 { pub const fn algebraic_rem(self, rhs: f64) -> f64 { intrinsics::frem_algebraic(self, rhs) } + + /// Returns `self` if the value is not NaN, otherwise returns `replacement` + /// if `self` is NaN. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_nan_to)] + /// + /// let n = f64::NAN; + /// let x = 2.0f64; + /// let y = f64::INFINITY; + /// + /// assert_eq!(n.nan_to(0.0f64), 0.0f64); + /// assert_eq!(x.nan_to(0.0f64), 2.0f64); + /// assert_eq!(y.nan_to(0.0f64), f64::INFINITY); + /// ``` + #[must_use = "method returns a new float and does not mutate the original value"] + #[unstable(feature = "float_nan_to", issue = "161248")] + #[rustc_const_unstable(feature = "float_nan_to", issue = "161248")] + #[inline] + pub const fn nan_to(self, replacement: f64) -> f64 { + if self.is_nan() { replacement } else { self } + } } #[unstable(feature = "core_float_math", issue = "137578")]