Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #110966

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3d80dd9
Clean up some builtin operator typeck logic
compiler-errors Apr 26, 2023
015acc2
Provide RHS type hint when reporting operator error
compiler-errors Apr 27, 2023
3125979
Fix a bad binop error when we need a call
compiler-errors Apr 27, 2023
6a89e94
only error with +whole-archive,+bundle for rlibs
Be-ing Apr 27, 2023
b51deba
Remove `MemDecoder::read_raw_bytes_inherent`.
nnethercote Apr 27, 2023
37c9e45
Add a comment explaining the lack of `Decoder::read_enum_variant`.
nnethercote Apr 27, 2023
618841b
Use `NonNull::new_unchecked` and `NonNull::len` in
JohnBobbo96 Apr 28, 2023
fa133f5
Remove a low-value assertion.
nnethercote Apr 27, 2023
7a16d25
Add some provided methods to `Encoder`/`Decoder`.
nnethercote Apr 27, 2023
a676dfa
Remove `MemDecoder::read_byte`.
nnethercote Apr 27, 2023
23e91d4
Remove some unnecessary derives.
nnethercote Apr 28, 2023
586d17d
share BinOp::Offset between CTFE and Miri
RalfJung Apr 28, 2023
f1b88ea
run-make test: using single quotes to not trigger the shell
TimNN Apr 28, 2023
b29b56f
Add regression test for issue 110929
WaffleLapkin Apr 28, 2023
69c71da
fix false negative for `unused_mut`
Apr 28, 2023
754a62c
Fix an ICE in conflict errors diagnostics
WaffleLapkin Apr 28, 2023
fc63926
remove unused `mut`s
Apr 28, 2023
9ab5dd5
Rollup merge of #110877 - compiler-errors:binop-err, r=cjgillot
matthiaskrgr Apr 28, 2023
0a9d44d
Rollup merge of #110917 - Be-ing:whole_archive_with_staticlib_fix, r=…
matthiaskrgr Apr 28, 2023
4d32087
Rollup merge of #110921 - JohnBobbo96:rustc_arena_nonnull, r=Nilstrieb
matthiaskrgr Apr 28, 2023
7c1c6c3
Rollup merge of #110927 - nnethercote:Encoder-Decoder-cleanups, r=sco…
matthiaskrgr Apr 28, 2023
fa177ea
Rollup merge of #110944 - RalfJung:offset, r=compiler-errors
matthiaskrgr Apr 28, 2023
c8430b2
Rollup merge of #110948 - TimNN:patch-1, r=WaffleLapkin
matthiaskrgr Apr 28, 2023
dd0dc9b
Rollup merge of #110957 - WaffleLapkin:reach_generator_conflict_error…
matthiaskrgr Apr 28, 2023
3467866
Rollup merge of #110960 - lukas-code:unused-mut, r=compiler-errors
matthiaskrgr Apr 28, 2023
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
10 changes: 5 additions & 5 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<T> ArenaChunk<T> {
#[inline]
unsafe fn new(capacity: usize) -> ArenaChunk<T> {
ArenaChunk {
storage: NonNull::new(Box::into_raw(Box::new_uninit_slice(capacity))).unwrap(),
storage: NonNull::new_unchecked(Box::into_raw(Box::new_uninit_slice(capacity))),
entries: 0,
}
}
Expand All @@ -85,7 +85,7 @@ impl<T> ArenaChunk<T> {
// The branch on needs_drop() is an -O1 performance optimization.
// Without the branch, dropping TypedArena<u8> takes linear time.
if mem::needs_drop::<T>() {
let slice = &mut *(self.storage.as_mut());
let slice = self.storage.as_mut();
ptr::drop_in_place(MaybeUninit::slice_assume_init_mut(&mut slice[..len]));
}
}
Expand All @@ -104,7 +104,7 @@ impl<T> ArenaChunk<T> {
// A pointer as large as possible for zero-sized elements.
ptr::invalid_mut(!0)
} else {
self.start().add((*self.storage.as_ptr()).len())
self.start().add(self.storage.len())
}
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ impl<T> TypedArena<T> {
// If the previous chunk's len is less than HUGE_PAGE
// bytes, then this chunk will be least double the previous
// chunk's size.
new_cap = (*last_chunk.storage.as_ptr()).len().min(HUGE_PAGE / elem_size / 2);
new_cap = last_chunk.storage.len().min(HUGE_PAGE / elem_size / 2);
new_cap *= 2;
} else {
new_cap = PAGE / elem_size;
Expand Down Expand Up @@ -396,7 +396,7 @@ impl DroplessArena {
// If the previous chunk's len is less than HUGE_PAGE
// bytes, then this chunk will be least double the previous
// chunk's size.
new_cap = (*last_chunk.storage.as_ptr()).len().min(HUGE_PAGE / 2);
new_cap = last_chunk.storage.len().min(HUGE_PAGE / 2);
new_cap *= 2;
} else {
new_cap = PAGE;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl Printer {

fn check_stack(&mut self, mut depth: usize) {
while let Some(&index) = self.scan_stack.back() {
let mut entry = &mut self.buf[index];
let entry = &mut self.buf[index];
match entry.token {
Token::Begin(_) => {
if depth == 0 {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}

// Get closure's arguments
let ty::Closure(_, substs) = typeck_results.expr_ty(closure_expr).kind() else { unreachable!() };
let ty::Closure(_, substs) = typeck_results.expr_ty(closure_expr).kind() else { /* hir::Closure can be a generator too */ return };
let sig = substs.as_closure().sig();
let tupled_params =
tcx.erase_late_bound_regions(sig.inputs().iter().next().unwrap().map_bound(|&b| b));
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ enum InitializationRequiringAction {
PartialAssignment,
}

#[derive(Debug)]
struct RootPlace<'tcx> {
place_local: Local,
place_projection: &'tcx [PlaceElem<'tcx>],
Expand Down Expand Up @@ -1848,11 +1849,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// is allowed, remove this match arm.
ty::Adt(..) | ty::Tuple(..) => {
check_parent_of_field(self, location, place_base, span, flow_state);

// rust-lang/rust#21232, #54499, #54986: during period where we reject
// partial initialization, do not complain about unnecessary `mut` on
// an attempt to do a partial initialization.
self.used_mut.insert(place.local);
}

_ => {}
Expand Down Expand Up @@ -1940,6 +1936,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
(prefix, base, span),
mpi,
);

// rust-lang/rust#21232, #54499, #54986: during period where we reject
// partial initialization, do not complain about unnecessary `mut` on
// an attempt to do a partial initialization.
this.used_mut.insert(base.local);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/member_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn append_list(
) {
let mut p = target_list;
loop {
let mut r = &mut constraints[p];
let r = &mut constraints[p];
match r.next_constraint {
Some(q) => p = q,
None => {
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ fn link_rlib<'a>(
let NativeLibKind::Static { bundle: None | Some(true), whole_archive } = lib.kind else {
continue;
};
if whole_archive == Some(true) && !codegen_results.crate_info.feature_packed_bundled_libs {
if whole_archive == Some(true)
&& flavor == RlibFlavor::Normal
&& !codegen_results.crate_info.feature_packed_bundled_libs
{
sess.emit_err(errors::IncompatibleLinkingModifiers);
}
if flavor == RlibFlavor::Normal && let Some(filename) = lib.filename {
Expand Down
17 changes: 4 additions & 13 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,20 +559,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
}

fn binary_ptr_op(
ecx: &InterpCx<'mir, 'tcx, Self>,
bin_op: mir::BinOp,
left: &ImmTy<'tcx>,
right: &ImmTy<'tcx>,
_ecx: &InterpCx<'mir, 'tcx, Self>,
_bin_op: mir::BinOp,
_left: &ImmTy<'tcx>,
_right: &ImmTy<'tcx>,
) -> InterpResult<'tcx, (Scalar, bool, Ty<'tcx>)> {
if bin_op == mir::BinOp::Offset {
let ptr = left.to_scalar().to_pointer(ecx)?;
let offset_count = right.to_scalar().to_target_isize(ecx)?;
let pointee_ty = left.layout.ty.builtin_deref(true).unwrap().ty;

let offset_ptr = ecx.ptr_offset_inbounds(ptr, pointee_ty, offset_count)?;
return Ok((Scalar::from_maybe_pointer(offset_ptr, ecx), false, left.layout.ty));
}

throw_unsup_format!("pointer arithmetic or comparison is not supported at compile-time");
}

Expand Down
26 changes: 25 additions & 1 deletion compiler/rustc_const_eval/src/interpret/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,30 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Ok((val, false, ty))
}

fn binary_ptr_op(
&self,
bin_op: mir::BinOp,
left: &ImmTy<'tcx, M::Provenance>,
right: &ImmTy<'tcx, M::Provenance>,
) -> InterpResult<'tcx, (Scalar<M::Provenance>, bool, Ty<'tcx>)> {
use rustc_middle::mir::BinOp::*;

match bin_op {
// Pointer ops that are always supported.
Offset => {
let ptr = left.to_scalar().to_pointer(self)?;
let offset_count = right.to_scalar().to_target_isize(self)?;
let pointee_ty = left.layout.ty.builtin_deref(true).unwrap().ty;

let offset_ptr = self.ptr_offset_inbounds(ptr, pointee_ty, offset_count)?;
Ok((Scalar::from_maybe_pointer(offset_ptr, self), false, left.layout.ty))
}

// Fall back to machine hook so Miri can support more pointer ops.
_ => M::binary_ptr_op(self, bin_op, left, right),
}
}

/// Returns the result of the specified operation, whether it overflowed, and
/// the result type.
pub fn overflowing_binary_op(
Expand Down Expand Up @@ -368,7 +392,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
right.layout.ty
);

M::binary_ptr_op(self, bin_op, left, right)
self.binary_ptr_op(bin_op, left, right)
}
_ => span_bug!(
self.cur_span(),
Expand Down
Loading