Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3c56c2e
stabilize `const_slice_reverse`
fee1-dead Jul 3, 2025
229be21
Add ui test unnessary-error-issue-138401.rs
xizheyin Jun 24, 2025
45e04b8
Allow `Rvalue::Repeat` to return true in `rvalue_creates_operand` too
scottmcm Jul 10, 2025
132a47e
Correct which exploit mitigations are enabled by default
1c3t3a Jul 15, 2025
49ae52e
Fix encoding of `link_section` and `no_mangle` cross crate
JonathanBrouwer Jul 17, 2025
9f16db6
Regression test
JonathanBrouwer Jul 17, 2025
12eedaf
Report the range of uninit bytes in CTFE errors
oli-obk Jun 18, 2025
2ce0b66
HIR ty lowering: Simplify signature of `lower_poly_trait_ref`
fmease Jun 18, 2025
10d7e5f
HIR ty lowering: Validate relaxed bounds in trait object types
fmease Jun 18, 2025
9788f59
Update comment about `where Ty:`
fmease Jun 18, 2025
1df99f2
AST lowering: More robustly deal with relaxed bounds
fmease Jun 18, 2025
652ba27
Show the memory of uninit reads
oli-obk Jun 18, 2025
8e840f7
opt-dist: make llvm builds optional
ognevny Jul 18, 2025
84ed70b
Reword diagnostics about relaxed bounds in invalid contexts
fmease Jun 20, 2025
879f62b
Reword diagnostic about relaxing non-`Sized` bound
fmease Jun 19, 2025
cdc3d70
Don't reject *multiple* relaxed bounds, reject *duplicate* ones.
fmease Jul 18, 2025
82a02ae
HIR ty lowering: Validate `PointeeSized` bounds
fmease Jun 20, 2025
466d33c
inline CrateLoader inside of CStore
LorrensP-2158466 Jul 15, 2025
181c1bd
Deduplicate `unmatched_delims` in `rustc_parse` to reduce confusion
xizheyin Jul 10, 2025
c65d3ce
Generalize `unsize` and `unsize_into` destinations
oli-obk Jul 3, 2025
af171b2
Rollup merge of #138554 - xizheyin:issue-138401, r=chenyukang
matthiaskrgr Jul 18, 2025
2ddbf3a
Rollup merge of #142673 - oli-obk:uninit-read-mem, r=RalfJung
matthiaskrgr Jul 18, 2025
c2dc9f3
Rollup merge of #142693 - fmease:unbound-bettering, r=compiler-errors
matthiaskrgr Jul 18, 2025
26ea00b
Rollup merge of #143382 - fee1-dead-contrib:push-trrymlzqmmoz, r=jhpratt
matthiaskrgr Jul 18, 2025
38859dd
Rollup merge of #143720 - scottmcm:rvalue-always-operand, r=lcnr
matthiaskrgr Jul 18, 2025
149c9db
Rollup merge of #143928 - ognevny:opt-dist-build-llvm, r=Kobzol
matthiaskrgr Jul 18, 2025
0818fba
Rollup merge of #143961 - 1c3t3a:correct-exploit-mitigations, r=rcvalle
matthiaskrgr Jul 18, 2025
dbdcc43
Rollup merge of #144050 - JonathanBrouwer:cross-crate-reexport, r=jdo…
matthiaskrgr Jul 18, 2025
70e8a77
Rollup merge of #144059 - LorrensP-2158466:remove-crate-loader, r=pet…
matthiaskrgr Jul 18, 2025
cb7cfa4
Rollup merge of #144123 - oli-obk:ctfe-unsize, r=RalfJung
matthiaskrgr Jul 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
OperandRef { val: OperandValue::Immediate(static_), layout }
}
mir::Rvalue::Use(ref operand) => self.codegen_operand(bx, operand),
mir::Rvalue::Repeat(..) => bug!("{rvalue:?} in codegen_rvalue_operand"),
mir::Rvalue::Repeat(ref elem, len_const) => {
// All arrays have `BackendRepr::Memory`, so only the ZST cases
// end up here. Anything else forces the destination local to be
// `Memory`, and thus ends up handled in `codegen_rvalue` instead.
let operand = self.codegen_operand(bx, elem);
let array_ty = Ty::new_array_with_const_len(bx.tcx(), operand.layout.ty, len_const);
let array_ty = self.monomorphize(array_ty);
let array_layout = bx.layout_of(array_ty);
assert!(array_layout.is_zst());
OperandRef { val: OperandValue::ZeroSized, layout: array_layout }
}
mir::Rvalue::Aggregate(ref kind, ref fields) => {
let (variant_index, active_field_index) = match **kind {
mir::AggregateKind::Adt(_, variant_index, _, _, active_field_index) => {
Expand Down Expand Up @@ -1000,12 +1010,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
mir::Rvalue::NullaryOp(..) |
mir::Rvalue::ThreadLocalRef(_) |
mir::Rvalue::Use(..) |
mir::Rvalue::Repeat(..) | // (*)
mir::Rvalue::Aggregate(..) | // (*)
mir::Rvalue::WrapUnsafeBinder(..) => // (*)
true,
// Arrays are always aggregates, so it's not worth checking anything here.
// (If it's really `[(); N]` or `[T; 0]` and we use the place path, fine.)
mir::Rvalue::Repeat(..) => false,
}

// (*) this is only true if the type is suitable
Expand Down
39 changes: 39 additions & 0 deletions tests/codegen/repeat-operand.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//@ compile-flags: -Copt-level=1 -Cno-prepopulate-passes

// This test is here to hit the `Rvalue::Repeat` case in `codegen_rvalue_operand`.
// It only applies when the resulting array is a ZST, so the test is written in
// such a way as to keep MIR optimizations from seeing that fact and removing
// the local and statement altogether. (At the time of writing, no other codegen
// test hit that code path, nor did a stage 2 build of the compiler.)

#![crate_type = "lib"]

#[repr(transparent)]
pub struct Wrapper<T, const N: usize>([T; N]);

// CHECK-LABEL: define {{.+}}do_repeat{{.+}}()
// CHECK-NEXT: start:
// CHECK-NOT: alloca
// CHECK-NEXT: ret void
// CHECK-LABEL: define {{.+}}do_repeat{{.+}}(i32 noundef %x)
// CHECK-NEXT: start:
// CHECK-NOT: alloca
// CHECK-NEXT: ret void
#[inline(never)]
pub fn do_repeat<T: Copy, const N: usize>(x: T) -> Wrapper<T, N> {
Wrapper([x; N])
}

// CHECK-LABEL: @trigger_repeat_zero_len
#[no_mangle]
pub fn trigger_repeat_zero_len() -> Wrapper<u32, 0> {
// CHECK: call void {{.+}}do_repeat{{.+}}(i32 noundef 4)
do_repeat(4)
}

// CHECK-LABEL: @trigger_repeat_zst
#[no_mangle]
pub fn trigger_repeat_zst() -> Wrapper<(), 8> {
// CHECK: call void {{.+}}do_repeat{{.+}}()
do_repeat(())
}