Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4acf3ba
libtest: expose --fail-fast
sourcefrog Jun 20, 2025
547c729
Make fail-fast unstable
sourcefrog Jun 20, 2025
b5a4e5d
remove gates
Kivooeo Aug 3, 2025
9fd57df
add tests, some with incorrect lifetime extension behavior
dianne Aug 13, 2025
0976d6c
don't extend non-extended `super let` initializers' block tail temps
dianne Aug 25, 2025
d5b5a4a
additional tests
dianne Aug 25, 2025
1ebf69d
initial implementation of the darwin_objc unstable feature
jbatez Jun 5, 2025
9405e76
Detect attempt to use var-args in closure
estebank Sep 15, 2025
0e290e4
Silence inference error on `PatKind::Err`
estebank Sep 15, 2025
a84c8de
Fix existing test
estebank Sep 15, 2025
53b58b3
tests/run-make: Update list of statically linked musl targets
Gelbpunkt Sep 15, 2025
fa7e474
remove FIXME from `has_significant_drop`, replaced with checking non_…
tnuha Sep 15, 2025
d66fb49
Suggest removing Box::new
camsteffen Sep 6, 2025
c89b6a9
Iterator repeat: no infinite loop for `last` and `count`
hkBst Sep 10, 2025
c916e88
fmt
estebank Sep 16, 2025
ed85f98
remove redundant test
estebank Sep 16, 2025
8306a2f
Reword note
estebank Sep 16, 2025
e9270e3
Detect top-level `...` in argument type
estebank Sep 16, 2025
580b489
Update the minimum external LLVM to 20
cuviper Aug 7, 2025
e54602c
Merge similar output checks in assembly-llvm/x86_64-cmp
cuviper Aug 8, 2025
88bef49
Update the FIXME comments in the generic three_way_compare
cuviper Aug 8, 2025
d81872a
add Readme.md to tidy
simp4t7 Sep 12, 2025
53b91ea
Remove Rvalue::Len.
cjgillot Sep 14, 2025
f018b46
Update docs.
cjgillot Sep 16, 2025
de73af9
Add test.
cjgillot Sep 16, 2025
40d879a
Add test.
cjgillot Sep 14, 2025
fe3a784
Do not renumber resume local.
cjgillot Sep 14, 2025
eddd755
Bless ui.
cjgillot Sep 16, 2025
5419896
Use `LLVMDIBuilderCreateSubroutineType`
Zalathar Sep 16, 2025
2552deb
Use `LLVMDIBuilderCreateUnionType`
Zalathar Sep 16, 2025
bef8f64
Use `LLVMDIBuilderCreateArrayType`
Zalathar Sep 16, 2025
3e9048d
Use `LLVMDIBuilderCreateBasicType`
Zalathar Sep 16, 2025
bae6fde
Use `LLVMDIBuilderCreatePointerType`
Zalathar Sep 16, 2025
af88d14
Use `LLVMDIBuilderCreateStructType`
Zalathar Sep 16, 2025
9d93fab
Rollup merge of #142807 - sourcefrog:failfast, r=dtolnay
Zalathar Sep 17, 2025
feeb68e
Rollup merge of #144871 - Kivooeo:btree_entry_insert-stabilize, r=jhp…
Zalathar Sep 17, 2025
f104ecf
Rollup merge of #145071 - cuviper:min-llvm-20, r=nikic
Zalathar Sep 17, 2025
f21a9c9
Rollup merge of #145181 - Borgerr:remove-fixme-from-has-sigdrop, r=lcnr
Zalathar Sep 17, 2025
6ad9875
Rollup merge of #145660 - jbatez:darwin_objc, r=jdonszelmann,madsmtm,…
Zalathar Sep 17, 2025
c2e8264
Rollup merge of #145838 - dianne:non-extending-super-let, r=jackh726,…
Zalathar Sep 17, 2025
79f8acb
Rollup merge of #146259 - camsteffen:remove-the-box, r=jackh726
Zalathar Sep 17, 2025
cefd932
Rollup merge of #146410 - hkBst:repeat-1, r=jhpratt
Zalathar Sep 17, 2025
c7af12e
Rollup merge of #146460 - simp4t7:add-tidy-readme, r=clubby789
Zalathar Sep 17, 2025
577f18f
Rollup merge of #146552 - cjgillot:resume-noremap, r=jackh726
Zalathar Sep 17, 2025
6473a0f
Rollup merge of #146564 - cjgillot:mir-nolen, r=scottmcm
Zalathar Sep 17, 2025
61f5358
Rollup merge of #146581 - estebank:issue-146489, r=lcnr
Zalathar Sep 17, 2025
76f1159
Rollup merge of #146588 - Gelbpunkt:musl-default-linking-test, r=jiey…
Zalathar Sep 17, 2025
4e6640b
Rollup merge of #146631 - Zalathar:di-builder, r=nnethercote
Zalathar Sep 17, 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
Prev Previous commit
Next Next commit
Remove Rvalue::Len.
  • Loading branch information
cjgillot committed Sep 16, 2025
commit 53b91ea87fe4b430c33bd22dfdaaa6289bf9466a
3 changes: 1 addition & 2 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,9 +1557,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
);
}

&(Rvalue::Len(place) | Rvalue::Discriminant(place)) => {
&Rvalue::Discriminant(place) => {
let af = match *rvalue {
Rvalue::Len(..) => Some(ArtificialField::ArrayLength),
Rvalue::Discriminant(..) => None,
_ => unreachable!(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,11 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
self.consume_operand(location, op);
}

&(Rvalue::Len(place) | Rvalue::Discriminant(place)) => {
let af = match rvalue {
Rvalue::Len(..) => Some(ArtificialField::ArrayLength),
Rvalue::Discriminant(..) => None,
_ => unreachable!(),
};
&Rvalue::Discriminant(place) => {
self.access_place(
location,
place,
(Shallow(af), Read(ReadKind::Copy)),
(Shallow(None), Read(ReadKind::Copy)),
LocalMutationIsAllowed::No,
);
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
| Rvalue::BinaryOp(..)
| Rvalue::RawPtr(..)
| Rvalue::ThreadLocalRef(..)
| Rvalue::Len(..)
| Rvalue::Discriminant(..)
| Rvalue::NullaryOp(NullOp::OffsetOf(..), _) => {}
}
Expand Down Expand Up @@ -2201,7 +2200,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
| Rvalue::Repeat(..)
| Rvalue::Ref(..)
| Rvalue::RawPtr(..)
| Rvalue::Len(..)
| Rvalue::Cast(..)
| Rvalue::ShallowInitBox(..)
| Rvalue::BinaryOp(..)
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,12 +834,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
fx.bcx.ins().nop();
}
}
Rvalue::Len(place) => {
let place = codegen_place(fx, place);
let usize_layout = fx.layout_of(fx.tcx.types.usize);
let len = codegen_array_len(fx, place);
lval.write_cvalue(fx, CValue::by_val(len, usize_layout));
}
Rvalue::ShallowInitBox(ref operand, content_ty) => {
let content_ty = fx.monomorphize(content_ty);
let box_layout = fx.layout_of(Ty::new_box(fx.tcx, content_ty));
Expand Down
25 changes: 1 addition & 24 deletions compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use rustc_middle::{bug, mir, span_bug};
use rustc_session::config::OptLevel;
use tracing::{debug, instrument};

use super::FunctionCx;
use super::operand::{OperandRef, OperandRefBuilder, OperandValue};
use super::place::{PlaceRef, PlaceValue, codegen_tag_value};
use super::{FunctionCx, LocalRef};
use crate::common::{IntPredicate, TypeKind};
use crate::traits::*;
use crate::{MemFlags, base};
Expand Down Expand Up @@ -510,14 +510,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
self.codegen_place_to_pointer(bx, place, mk_ptr)
}

mir::Rvalue::Len(place) => {
let size = self.evaluate_array_len(bx, place);
OperandRef {
val: OperandValue::Immediate(size),
layout: bx.cx().layout_of(bx.tcx().types.usize),
}
}

mir::Rvalue::BinaryOp(op_with_overflow, box (ref lhs, ref rhs))
if let Some(op) = op_with_overflow.overflowing_to_wrapping() =>
{
Expand Down Expand Up @@ -749,21 +741,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}

fn evaluate_array_len(&mut self, bx: &mut Bx, place: mir::Place<'tcx>) -> Bx::Value {
// ZST are passed as operands and require special handling
// because codegen_place() panics if Local is operand.
if let Some(index) = place.as_local()
&& let LocalRef::Operand(op) = self.locals[index]
&& let ty::Array(_, n) = op.layout.ty.kind()
{
let n = n.try_to_target_usize(bx.tcx()).expect("expected monomorphic const in codegen");
return bx.cx().const_usize(n);
}
// use common size calculation for non zero-sized types
let cg_value = self.codegen_place(bx, place.as_ref());
cg_value.len(bx.cx())
}

/// Codegen an `Rvalue::RawPtr` or `Rvalue::Ref`
fn codegen_place_to_pointer(
&mut self,
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
Rvalue::Use(_)
| Rvalue::CopyForDeref(..)
| Rvalue::Repeat(..)
| Rvalue::Discriminant(..)
| Rvalue::Len(_) => {}
| Rvalue::Discriminant(..) => {}

Rvalue::Aggregate(kind, ..) => {
if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref()
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ where
Q::in_any_value_of_ty(cx, rvalue.ty(cx.body, cx.tcx))
}

Rvalue::Discriminant(place) | Rvalue::Len(place) => {
in_place::<Q, _>(cx, in_local, place.as_ref())
}
Rvalue::Discriminant(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),

Rvalue::CopyForDeref(place) => in_place::<Q, _>(cx, in_local, place.as_ref()),

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_const_eval/src/check_consts/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ where
| mir::Rvalue::CopyForDeref(..)
| mir::Rvalue::ThreadLocalRef(..)
| mir::Rvalue::Repeat(..)
| mir::Rvalue::Len(..)
| mir::Rvalue::BinaryOp(..)
| mir::Rvalue::NullaryOp(..)
| mir::Rvalue::UnaryOp(..)
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_const_eval/src/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tracing::{info, instrument, trace};

use super::{
FnArg, FnVal, ImmTy, Immediate, InterpCx, InterpResult, Machine, MemPlaceMeta, PlaceTy,
Projectable, Scalar, interp_ok, throw_ub, throw_unsup_format,
Projectable, interp_ok, throw_ub, throw_unsup_format,
};
use crate::interpret::EnteredTraceSpan;
use crate::{enter_trace_span, util};
Expand Down Expand Up @@ -225,12 +225,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
self.write_repeat(operand, &dest)?;
}

Len(place) => {
let src = self.eval_place(place)?;
let len = src.len(self)?;
self.write_scalar(Scalar::from_target_usize(len, self), &dest)?;
}

Ref(_, borrow_kind, place) => {
let src = self.eval_place(place)?;
let place = self.force_allocation(&src)?;
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,6 @@ impl<'tcx> Debug for Rvalue<'tcx> {
pretty_print_const(b, fmt, false)?;
write!(fmt, "]")
}
Len(ref a) => write!(fmt, "Len({a:?})"),
Cast(ref kind, ref place, ref ty) => {
with_no_trimmed_paths!(write!(fmt, "{place:?} as {ty} ({kind:?})"))
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/mir/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ impl<'tcx> Rvalue<'tcx> {
| Rvalue::Ref(_, _, _)
| Rvalue::ThreadLocalRef(_)
| Rvalue::RawPtr(_, _)
| Rvalue::Len(_)
| Rvalue::Cast(
CastKind::IntToInt
| CastKind::FloatToInt
Expand Down Expand Up @@ -739,7 +738,6 @@ impl<'tcx> Rvalue<'tcx> {
let place_ty = place.ty(local_decls, tcx).ty;
Ty::new_ptr(tcx, place_ty, kind.to_mutbl_lossy())
}
Rvalue::Len(..) => tcx.types.usize,
Rvalue::Cast(.., ty) => ty,
Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
let lhs_ty = lhs.ty(local_decls, tcx);
Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,16 +1407,6 @@ pub enum Rvalue<'tcx> {
/// model.
RawPtr(RawPtrKind, Place<'tcx>),

/// Yields the length of the place, as a `usize`.
///
/// If the type of the place is an array, this is the array length. For slices (`[T]`, not
/// `&[T]`) this accesses the place's metadata to determine the length. This rvalue is
/// ill-formed for places of other types.
///
/// This cannot be a `UnOp(PtrMetadata, _)` because that expects a value, and we only
/// have a place, and `UnOp(PtrMetadata, RawPtr(place))` is not a thing.
Len(Place<'tcx>),

/// Performs essentially all of the casts that can be performed via `as`.
///
/// This allows for casts from/to a variety of types.
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,14 +717,6 @@ macro_rules! make_mir_visitor {
self.visit_place(path, ctx, location);
}

Rvalue::Len(path) => {
self.visit_place(
path,
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),
location
);
}

Rvalue::Cast(_cast_kind, operand, ty) => {
self.visit_operand(operand, location);
self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
let source = self.parse_operand(args[0])?;
Ok(Rvalue::Cast(CastKind::PtrToPtr, source, expr.ty))
},
@call(mir_cast_unsize, args) => {
let source = self.parse_operand(args[0])?;
let kind = CastKind::PointerCoercion(ty::adjustment::PointerCoercion::Unsize, CoercionSource::AsCast);
Ok(Rvalue::Cast(kind, source, expr.ty))
},
@call(mir_checked, args) => {
parse_by_kind!(self, args[0], _, "binary op",
ExprKind::Binary { op, lhs, rhs } => {
Expand All @@ -247,7 +252,6 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
let offset = self.parse_operand(args[1])?;
Ok(Rvalue::BinaryOp(BinOp::Offset, Box::new((ptr, offset))))
},
@call(mir_len, args) => Ok(Rvalue::Len(self.parse_place(args[0])?)),
@call(mir_ptr_metadata, args) => Ok(Rvalue::UnaryOp(UnOp::PtrMetadata, self.parse_operand(args[0])?)),
@call(mir_copy_for_deref, args) => Ok(Rvalue::CopyForDeref(self.parse_place(args[0])?)),
ExprKind::Borrow { borrow_kind, arg } => Ok(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
///
/// For arrays it'll be `Operand::Constant` with the actual length;
/// For slices it'll be `Operand::Move` of a local using `PtrMetadata`.
fn len_of_slice_or_array(
pub(in crate::builder) fn len_of_slice_or_array(
&mut self,
block: BasicBlock,
place: Place<'tcx>,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_mir_build/src/builder/matches/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let actual = self.temp(usize_ty, test.span);

// actual = len(place)
self.cfg.push_assign(block, source_info, actual, Rvalue::Len(place));
let length_op = self.len_of_slice_or_array(block, place, test.span, source_info);
self.cfg.push_assign(block, source_info, actual, Rvalue::Use(length_op));

// expected = <N>
let expected = self.push_usize(block, source_info, len);
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ where
| Rvalue::Use(..)
| Rvalue::ThreadLocalRef(..)
| Rvalue::Repeat(..)
| Rvalue::Len(..)
| Rvalue::BinaryOp(..)
| Rvalue::NullaryOp(..)
| Rvalue::UnaryOp(..)
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_mir_dataflow/src/move_paths/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> {
Rvalue::Ref(..)
| Rvalue::RawPtr(..)
| Rvalue::Discriminant(..)
| Rvalue::Len(..)
| Rvalue::NullaryOp(
NullOp::SizeOf
| NullOp::AlignOf
Expand Down
38 changes: 17 additions & 21 deletions compiler/rustc_mir_transform/src/dataflow_const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,6 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
state: &mut State<FlatSet<Scalar>>,
) -> ValueOrPlace<FlatSet<Scalar>> {
let val = match rvalue {
Rvalue::Len(place) => {
let place_ty = place.ty(self.local_decls, self.tcx);
if let ty::Array(_, len) = place_ty.ty.kind() {
Const::Ty(self.tcx.types.usize, *len)
.try_eval_scalar(self.tcx, self.typing_env)
.map_or(FlatSet::Top, FlatSet::Elem)
} else if let [ProjectionElem::Deref] = place.projection[..] {
state.get_len(place.local.into(), &self.map)
} else {
FlatSet::Top
}
}
Rvalue::Cast(CastKind::IntToInt | CastKind::IntToFloat, operand, ty) => {
let Ok(layout) = self.tcx.layout_of(self.typing_env.as_query_input(*ty)) else {
return ValueOrPlace::Value(FlatSet::Top);
Expand Down Expand Up @@ -465,15 +453,23 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
let (val, _overflow) = self.binary_op(state, *op, left, right);
val
}
Rvalue::UnaryOp(op, operand) => match self.eval_operand(operand, state) {
FlatSet::Elem(value) => self
.ecx
.unary_op(*op, &value)
.discard_err()
.map_or(FlatSet::Top, |val| self.wrap_immediate(*val)),
FlatSet::Bottom => FlatSet::Bottom,
FlatSet::Top => FlatSet::Top,
},
Rvalue::UnaryOp(op, operand) => {
if let UnOp::PtrMetadata = op
&& let Some(place) = operand.place()
&& let Some(len) = self.map.find_len(place.as_ref())
{
return ValueOrPlace::Place(len);
}
match self.eval_operand(operand, state) {
FlatSet::Elem(value) => self
.ecx
.unary_op(*op, &value)
.discard_err()
.map_or(FlatSet::Top, |val| self.wrap_immediate(*val)),
FlatSet::Bottom => FlatSet::Bottom,
FlatSet::Top => FlatSet::Top,
}
}
Rvalue::NullaryOp(null_op, ty) => {
let Ok(layout) = self.tcx.layout_of(self.typing_env.as_query_input(*ty)) else {
return ValueOrPlace::Value(FlatSet::Top);
Expand Down
Loading