Skip to content

Commit 7a96158

Browse files
committed
Auto merge of rust-lang#110967 - matthiaskrgr:rollup-vfbl7gm, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#110877 (Provide better type hints when a type doesn't support a binary operator) - rust-lang#110917 (only error combining +whole-archive and +bundle for rlibs) - rust-lang#110921 (Use `NonNull::new_unchecked` and `NonNull::len` in `rustc_arena`.) - rust-lang#110927 (Encoder/decoder cleanups) - rust-lang#110944 (share BinOp::Offset between CTFE and Miri) - rust-lang#110948 (run-make test: using single quotes to not trigger the shell) - rust-lang#110957 (Fix an ICE in conflict error diagnostics) - rust-lang#110960 (fix false negative for `unused_mut`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents f495605 + 34ef13b commit 7a96158

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+449
-342
lines changed

compiler/rustc_arena/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<T> ArenaChunk<T> {
7474
#[inline]
7575
unsafe fn new(capacity: usize) -> ArenaChunk<T> {
7676
ArenaChunk {
77-
storage: NonNull::new(Box::into_raw(Box::new_uninit_slice(capacity))).unwrap(),
77+
storage: NonNull::new_unchecked(Box::into_raw(Box::new_uninit_slice(capacity))),
7878
entries: 0,
7979
}
8080
}
@@ -85,7 +85,7 @@ impl<T> ArenaChunk<T> {
8585
// The branch on needs_drop() is an -O1 performance optimization.
8686
// Without the branch, dropping TypedArena<u8> takes linear time.
8787
if mem::needs_drop::<T>() {
88-
let slice = &mut *(self.storage.as_mut());
88+
let slice = self.storage.as_mut();
8989
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(&mut slice[..len]));
9090
}
9191
}
@@ -104,7 +104,7 @@ impl<T> ArenaChunk<T> {
104104
// A pointer as large as possible for zero-sized elements.
105105
ptr::invalid_mut(!0)
106106
} else {
107-
self.start().add((*self.storage.as_ptr()).len())
107+
self.start().add(self.storage.len())
108108
}
109109
}
110110
}
@@ -288,7 +288,7 @@ impl<T> TypedArena<T> {
288288
// If the previous chunk's len is less than HUGE_PAGE
289289
// bytes, then this chunk will be least double the previous
290290
// chunk's size.
291-
new_cap = (*last_chunk.storage.as_ptr()).len().min(HUGE_PAGE / elem_size / 2);
291+
new_cap = last_chunk.storage.len().min(HUGE_PAGE / elem_size / 2);
292292
new_cap *= 2;
293293
} else {
294294
new_cap = PAGE / elem_size;
@@ -396,7 +396,7 @@ impl DroplessArena {
396396
// If the previous chunk's len is less than HUGE_PAGE
397397
// bytes, then this chunk will be least double the previous
398398
// chunk's size.
399-
new_cap = (*last_chunk.storage.as_ptr()).len().min(HUGE_PAGE / 2);
399+
new_cap = last_chunk.storage.len().min(HUGE_PAGE / 2);
400400
new_cap *= 2;
401401
} else {
402402
new_cap = PAGE;

compiler/rustc_ast_pretty/src/pp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl Printer {
360360

361361
fn check_stack(&mut self, mut depth: usize) {
362362
while let Some(&index) = self.scan_stack.back() {
363-
let mut entry = &mut self.buf[index];
363+
let entry = &mut self.buf[index];
364364
match entry.token {
365365
Token::Begin(_) => {
366366
if depth == 0 {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13591359
}
13601360

13611361
// Get closure's arguments
1362-
let ty::Closure(_, substs) = typeck_results.expr_ty(closure_expr).kind() else { unreachable!() };
1362+
let ty::Closure(_, substs) = typeck_results.expr_ty(closure_expr).kind() else { /* hir::Closure can be a generator too */ return };
13631363
let sig = substs.as_closure().sig();
13641364
let tupled_params =
13651365
tcx.erase_late_bound_regions(sig.inputs().iter().next().unwrap().map_bound(|&b| b));

compiler/rustc_borrowck/src/lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ enum InitializationRequiringAction {
935935
PartialAssignment,
936936
}
937937

938+
#[derive(Debug)]
938939
struct RootPlace<'tcx> {
939940
place_local: Local,
940941
place_projection: &'tcx [PlaceElem<'tcx>],
@@ -1848,11 +1849,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
18481849
// is allowed, remove this match arm.
18491850
ty::Adt(..) | ty::Tuple(..) => {
18501851
check_parent_of_field(self, location, place_base, span, flow_state);
1851-
1852-
// rust-lang/rust#21232, #54499, #54986: during period where we reject
1853-
// partial initialization, do not complain about unnecessary `mut` on
1854-
// an attempt to do a partial initialization.
1855-
self.used_mut.insert(place.local);
18561852
}
18571853

18581854
_ => {}
@@ -1940,6 +1936,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
19401936
(prefix, base, span),
19411937
mpi,
19421938
);
1939+
1940+
// rust-lang/rust#21232, #54499, #54986: during period where we reject
1941+
// partial initialization, do not complain about unnecessary `mut` on
1942+
// an attempt to do a partial initialization.
1943+
this.used_mut.insert(base.local);
19431944
}
19441945
}
19451946
}

compiler/rustc_borrowck/src/member_constraints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn append_list(
221221
) {
222222
let mut p = target_list;
223223
loop {
224-
let mut r = &mut constraints[p];
224+
let r = &mut constraints[p];
225225
match r.next_constraint {
226226
Some(q) => p = q,
227227
None => {

compiler/rustc_codegen_ssa/src/back/link.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ fn link_rlib<'a>(
349349
let NativeLibKind::Static { bundle: None | Some(true), whole_archive } = lib.kind else {
350350
continue;
351351
};
352-
if whole_archive == Some(true) && !codegen_results.crate_info.feature_packed_bundled_libs {
352+
if whole_archive == Some(true)
353+
&& flavor == RlibFlavor::Normal
354+
&& !codegen_results.crate_info.feature_packed_bundled_libs
355+
{
353356
sess.emit_err(errors::IncompatibleLinkingModifiers);
354357
}
355358
if flavor == RlibFlavor::Normal && let Some(filename) = lib.filename {

compiler/rustc_const_eval/src/const_eval/machine.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -559,20 +559,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
559559
}
560560

561561
fn binary_ptr_op(
562-
ecx: &InterpCx<'mir, 'tcx, Self>,
563-
bin_op: mir::BinOp,
564-
left: &ImmTy<'tcx>,
565-
right: &ImmTy<'tcx>,
562+
_ecx: &InterpCx<'mir, 'tcx, Self>,
563+
_bin_op: mir::BinOp,
564+
_left: &ImmTy<'tcx>,
565+
_right: &ImmTy<'tcx>,
566566
) -> InterpResult<'tcx, (Scalar, bool, Ty<'tcx>)> {
567-
if bin_op == mir::BinOp::Offset {
568-
let ptr = left.to_scalar().to_pointer(ecx)?;
569-
let offset_count = right.to_scalar().to_target_isize(ecx)?;
570-
let pointee_ty = left.layout.ty.builtin_deref(true).unwrap().ty;
571-
572-
let offset_ptr = ecx.ptr_offset_inbounds(ptr, pointee_ty, offset_count)?;
573-
return Ok((Scalar::from_maybe_pointer(offset_ptr, ecx), false, left.layout.ty));
574-
}
575-
576567
throw_unsup_format!("pointer arithmetic or comparison is not supported at compile-time");
577568
}
578569

compiler/rustc_const_eval/src/interpret/operator.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,30 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
299299
Ok((val, false, ty))
300300
}
301301

302+
fn binary_ptr_op(
303+
&self,
304+
bin_op: mir::BinOp,
305+
left: &ImmTy<'tcx, M::Provenance>,
306+
right: &ImmTy<'tcx, M::Provenance>,
307+
) -> InterpResult<'tcx, (Scalar<M::Provenance>, bool, Ty<'tcx>)> {
308+
use rustc_middle::mir::BinOp::*;
309+
310+
match bin_op {
311+
// Pointer ops that are always supported.
312+
Offset => {
313+
let ptr = left.to_scalar().to_pointer(self)?;
314+
let offset_count = right.to_scalar().to_target_isize(self)?;
315+
let pointee_ty = left.layout.ty.builtin_deref(true).unwrap().ty;
316+
317+
let offset_ptr = self.ptr_offset_inbounds(ptr, pointee_ty, offset_count)?;
318+
Ok((Scalar::from_maybe_pointer(offset_ptr, self), false, left.layout.ty))
319+
}
320+
321+
// Fall back to machine hook so Miri can support more pointer ops.
322+
_ => M::binary_ptr_op(self, bin_op, left, right),
323+
}
324+
}
325+
302326
/// Returns the result of the specified operation, whether it overflowed, and
303327
/// the result type.
304328
pub fn overflowing_binary_op(
@@ -368,7 +392,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
368392
right.layout.ty
369393
);
370394

371-
M::binary_ptr_op(self, bin_op, left, right)
395+
self.binary_ptr_op(bin_op, left, right)
372396
}
373397
_ => span_bug!(
374398
self.cur_span(),

0 commit comments

Comments
 (0)