Skip to content

Rollup of 5 pull requests #71190

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

Closed
wants to merge 18 commits into from
Closed
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
@@ -971,7 +971,7 @@ impl<T> Vec<T> {
}

let len = self.len();
if !(index < len) {
if index >= len {
assert_failed(index, len);
}
unsafe {
@@ -1010,7 +1010,7 @@ impl<T> Vec<T> {
}

let len = self.len();
if !(index <= len) {
if index > len {
assert_failed(index, len);
}

@@ -1058,7 +1058,7 @@ impl<T> Vec<T> {
}

let len = self.len();
if !(index < len) {
if index >= len {
assert_failed(index, len);
}
unsafe {
@@ -1331,10 +1331,10 @@ impl<T> Vec<T> {
panic!("end drain index (is {}) should be <= len (is {})", end, len);
}

if !(start <= end) {
if start > end {
start_assert_failed(start, end);
}
if !(end <= len) {
if end > len {
end_assert_failed(end, len);
}

@@ -1432,7 +1432,7 @@ impl<T> Vec<T> {
panic!("`at` split index (is {}) should be <= len (is {})", at, len);
}

if !(at <= self.len()) {
if at > self.len() {
assert_failed(at, self.len());
}

2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/deriving/debug.rs
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
let span = cx.with_def_site_ctxt(span);
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked));
let builder = cx.ident_of("debug_trait_builder", span);
let builder_expr = cx.expr_ident(span, builder.clone());
let builder_expr = cx.expr_ident(span, builder);

let fmt = substr.nonself_args[0].clone();

2 changes: 1 addition & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
@@ -2005,7 +2005,7 @@ fn emit_to_destination(
let _buffer_lock = lock::acquire_global_lock("rustc_errors");
for (pos, line) in rendered_buffer.iter().enumerate() {
for part in line {
dst.apply_style(lvl.clone(), part.style)?;
dst.apply_style(*lvl, part.style)?;
write!(dst, "{}", part.text)?;
dst.reset()?;
}
6 changes: 3 additions & 3 deletions src/librustc_infer/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
@@ -871,7 +871,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
return Some(());
}
if let &ty::Adt(def, _) = &ta.kind {
let path_ = self.tcx.def_path_str(def.did.clone());
let path_ = self.tcx.def_path_str(def.did);
if path_ == other_path {
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
return Some(());
@@ -1091,8 +1091,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1);
let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2);
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
let path1 = self.tcx.def_path_str(def1.did.clone());
let path2 = self.tcx.def_path_str(def2.did.clone());
let path1 = self.tcx.def_path_str(def1.did);
let path2 = self.tcx.def_path_str(def2.did);
if def1.did == def2.did {
// Easy case. Replace same types with `_` to shorten the output and highlight
// the differing ones.
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
@@ -452,7 +452,7 @@ where
// even though a satisfactory solution exists.
let generic = GenericKind::Projection(projection_ty);
let verify_bound = self.verify_bound.generic_bound(generic);
self.delegate.push_verify(origin, generic.clone(), region, verify_bound);
self.delegate.push_verify(origin, generic, region, verify_bound);
}
}

1 change: 0 additions & 1 deletion src/librustc_infer/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
@@ -297,7 +297,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
self.collect_outlives_from_predicate_list(
move |ty| ty == identity_proj,
traits::elaborate_predicates(tcx, trait_predicates)
.into_iter()
.map(|o| o.predicate)
.collect::<Vec<_>>(),
)
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
@@ -1056,7 +1056,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
place: {:?}",
place_span.0
);
this.reservation_error_reported.insert(place_span.0.clone());
this.reservation_error_reported.insert(place_span.0);
}
Activation(_, activating) => {
debug!(
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/region_infer/mod.rs
Original file line number Diff line number Diff line change
@@ -495,7 +495,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// to store those. Otherwise, we'll pass in `None` to the
// functions below, which will trigger them to report errors
// eagerly.
let mut outlives_requirements = infcx.tcx.is_closure(mir_def_id).then(|| vec![]);
let mut outlives_requirements = infcx.tcx.is_closure(mir_def_id).then(Vec::new);

self.check_type_tests(infcx, body, outlives_requirements.as_mut(), &mut errors_buffer);

7 changes: 3 additions & 4 deletions src/librustc_mir/dataflow/move_paths/builder.rs
Original file line number Diff line number Diff line change
@@ -286,7 +286,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
// Box starts out uninitialized - need to create a separate
// move-path for the interior so it will be separate from
// the exterior.
self.create_move_path(self.builder.tcx.mk_place_deref(place.clone()));
self.create_move_path(self.builder.tcx.mk_place_deref(*place));
self.gather_init(place.as_ref(), InitKind::Shallow);
} else {
self.gather_init(place.as_ref(), InitKind::Deep);
@@ -458,9 +458,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
for offset in from..to {
let elem =
ProjectionElem::ConstantIndex { offset, min_length: len, from_end: false };
let path = self.add_move_path(base_path, &elem, |tcx| {
tcx.mk_place_elem(base_place.clone(), elem)
});
let path =
self.add_move_path(base_path, &elem, |tcx| tcx.mk_place_elem(base_place, elem));
self.record_move(place, path);
}
} else {
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
@@ -549,7 +549,7 @@ where
let n = base.len(self)?;
if n < u64::from(min_length) {
// This can only be reached in ConstProp and non-rustc-MIR.
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n.into() });
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n });
}

let index = if from_end {
2 changes: 1 addition & 1 deletion src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
@@ -335,7 +335,7 @@ fn collect_items_rec<'tcx>(
recursion_depths: &mut DefIdMap<usize>,
inlining_map: MTRef<'_, MTLock<InliningMap<'tcx>>>,
) {
if !visited.lock_mut().insert(starting_point.clone()) {
if !visited.lock_mut().insert(starting_point) {
// We've been here already, no need to search again.
return;
}
8 changes: 4 additions & 4 deletions src/librustc_mir/shim.rs
Original file line number Diff line number Diff line change
@@ -538,7 +538,7 @@ impl CloneShimBuilder<'tcx> {
// BB #2
// `dest[i] = Clone::clone(src[beg])`;
// Goto #3 if ok, #5 if unwinding happens.
let dest_field = self.tcx.mk_place_index(dest.clone(), beg);
let dest_field = self.tcx.mk_place_index(dest, beg);
let src_field = self.tcx.mk_place_index(src, beg);
self.make_clone_call(dest_field, src_field, ty, BasicBlock::new(3), BasicBlock::new(5));

@@ -620,9 +620,9 @@ impl CloneShimBuilder<'tcx> {
let mut previous_field = None;
for (i, ity) in tys.enumerate() {
let field = Field::new(i);
let src_field = self.tcx.mk_place_field(src.clone(), field, ity);
let src_field = self.tcx.mk_place_field(src, field, ity);

let dest_field = self.tcx.mk_place_field(dest.clone(), field, ity);
let dest_field = self.tcx.mk_place_field(dest, field, ity);

// #(2i + 1) is the cleanup block for the previous clone operation
let cleanup_block = self.block_index_offset(1);
@@ -633,7 +633,7 @@ impl CloneShimBuilder<'tcx> {
// BB #(2i)
// `dest.i = Clone::clone(&src.i);`
// Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens.
self.make_clone_call(dest_field.clone(), src_field, ity, next_block, cleanup_block);
self.make_clone_call(dest_field, src_field, ity, next_block, cleanup_block);

// BB #(2i + 1) (cleanup)
if let Some((previous_field, previous_cleanup)) = previous_field.take() {
10 changes: 0 additions & 10 deletions src/librustc_mir/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
@@ -90,16 +90,6 @@ impl NonConstOp for FnCallNonConst {
}
}

/// A function call where the callee is not a function definition or function pointer, e.g. a
/// closure.
///
/// This can be subdivided in the future to produce a better error message.
#[derive(Debug)]
pub struct FnCallOther;
impl NonConstOp for FnCallOther {
const IS_SUPPORTED_IN_MIRI: bool = false;
}

/// A call to a `#[unstable]` const fn or `#[rustc_const_unstable]` function.
///
/// Contains the name of the feature that would allow the use of this function.
11 changes: 5 additions & 6 deletions src/librustc_mir/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
@@ -495,11 +495,11 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
}
}

fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, location: Location) {
trace!("visit_terminator_kind: kind={:?} location={:?}", kind, location);
self.super_terminator_kind(kind, location);
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
trace!("visit_terminator: terminator={:?} location={:?}", terminator, location);
self.super_terminator(terminator, location);

match kind {
match &terminator.kind {
TerminatorKind::Call { func, .. } => {
let fn_ty = func.ty(*self.body, self.tcx);

@@ -511,8 +511,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
return;
}
_ => {
self.check_op(ops::FnCallOther);
return;
span_bug!(terminator.source_info.span, "invalid callee of type {:?}", fn_ty)
}
};

10 changes: 5 additions & 5 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
@@ -581,11 +581,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
return None;
}

// FIXME we need to revisit this for #67176
if rvalue.needs_subst() {
return None;
}

// Perform any special handling for specific Rvalue types.
// Generally, checks here fall into one of two categories:
// 1. Additional checking to provide useful lints to the user
@@ -626,6 +621,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
_ => {}
}

// FIXME we need to revisit this for #67176
if rvalue.needs_subst() {
return None;
}

self.use_ecx(|this| {
trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place);
this.ecx.eval_rvalue_into_place(rvalue, place)?;
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/inline.rs
Original file line number Diff line number Diff line change
@@ -582,7 +582,7 @@ impl Inliner<'tcx> {
let tuple_tmp_args = tuple_tys.iter().enumerate().map(|(i, ty)| {
// This is e.g., `tuple_tmp.0` in our example above.
let tuple_field =
Operand::Move(tcx.mk_place_field(tuple.clone(), Field::new(i), ty.expect_ty()));
Operand::Move(tcx.mk_place_field(tuple, Field::new(i), ty.expect_ty()));

// Spill to a local to make e.g., `tmp0`.
self.create_temp_if_necessary(tuple_field, callsite, caller_body)
4 changes: 2 additions & 2 deletions src/librustc_mir/util/aggregate.rs
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ pub fn expand_aggregate<'tcx>(
let offset = i as u32;
assert_eq!(offset as usize, i);
tcx.mk_place_elem(
lhs.clone(),
lhs,
ProjectionElem::ConstantIndex {
offset,
// FIXME(eddyb) `min_length` doesn't appear to be used.
@@ -66,7 +66,7 @@ pub fn expand_aggregate<'tcx>(
)
} else {
let field = Field::new(active_field_index.unwrap_or(i));
tcx.mk_place_field(lhs.clone(), field, ty)
tcx.mk_place_field(lhs, field, ty)
};
Statement { source_info, kind: StatementKind::Assign(box (lhs_field, Rvalue::Use(op))) }
})
20 changes: 10 additions & 10 deletions src/librustc_mir/util/elaborate_drops.rs
Original file line number Diff line number Diff line change
@@ -212,7 +212,7 @@ where
assert_eq!(self.elaborator.param_env().reveal, Reveal::All);
let field_ty =
tcx.normalize_erasing_regions(self.elaborator.param_env(), f.ty(tcx, substs));
(tcx.mk_place_field(base_place.clone(), field, field_ty), subpath)
(tcx.mk_place_field(base_place, field, field_ty), subpath)
})
.collect()
}
@@ -340,7 +340,7 @@ where
.enumerate()
.map(|(i, &ty)| {
(
self.tcx().mk_place_field(self.place.clone(), Field::new(i), ty),
self.tcx().mk_place_field(self.place, Field::new(i), ty),
self.elaborator.field_subpath(self.path, Field::new(i)),
)
})
@@ -353,7 +353,7 @@ where
fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock {
debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs);

let interior = self.tcx().mk_place_deref(self.place.clone());
let interior = self.tcx().mk_place_deref(self.place);
let interior_path = self.elaborator.deref_subpath(self.path);

let succ = self.succ; // FIXME(#43234)
@@ -434,7 +434,7 @@ where

if let Some(variant_path) = subpath {
let base_place = tcx.mk_place_elem(
self.place.clone(),
self.place,
ProjectionElem::Downcast(Some(variant.ident.name), variant_index),
);
let fields = self.move_paths_for_fields(base_place, variant_path, &variant, substs);
@@ -622,7 +622,7 @@ where
(Rvalue::Use(copy(cur.into())), Rvalue::BinaryOp(BinOp::Offset, move_(cur.into()), one))
} else {
(
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place.clone(), cur)),
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)),
Rvalue::BinaryOp(BinOp::Add, move_(cur.into()), one),
)
};
@@ -654,7 +654,7 @@ where
self.elaborator.patch().patch_terminator(
drop_block,
TerminatorKind::Drop {
location: tcx.mk_place_deref(ptr.clone()),
location: tcx.mk_place_deref(ptr),
target: loop_block,
unwind: unwind.into_option(),
},
@@ -682,7 +682,7 @@ where
.map(|i| {
(
tcx.mk_place_elem(
self.place.clone(),
self.place,
ProjectionElem::ConstantIndex {
offset: i,
min_length: size,
@@ -719,8 +719,8 @@ where
switch_ty: tcx.types.usize,
values: From::from(USIZE_SWITCH_ZERO),
targets: vec![
self.drop_loop_pair(ety, false, len.clone()),
self.drop_loop_pair(ety, true, len.clone()),
self.drop_loop_pair(ety, false, len),
self.drop_loop_pair(ety, true, len),
],
},
}),
@@ -912,7 +912,7 @@ where
.map(|(i, f)| {
let field = Field::new(i);
let field_ty = f.ty(tcx, substs);
Operand::Move(tcx.mk_place_field(self.place.clone(), field, field_ty))
Operand::Move(tcx.mk_place_field(self.place, field, field_ty))
})
.collect();

4 changes: 2 additions & 2 deletions src/librustc_mir_build/build/block.rs
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ use crate::build::matches::ArmHasGuard;
use crate::build::ForGuard::OutsideGuard;
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use crate::hair::*;
use rustc_middle::mir::*;
use rustc_hir as hir;
use rustc_middle::mir::*;
use rustc_span::Span;

impl<'a, 'tcx> Builder<'a, 'tcx> {
@@ -29,7 +29,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// This is a `break`-able block
let exit_block = this.cfg.start_new_block();
let block_exit =
this.in_breakable_scope(None, exit_block, destination.clone(), |this| {
this.in_breakable_scope(None, exit_block, destination, |this| {
this.ast_block_stmts(destination, block, span, stmts, expr, safety_mode)
});
this.cfg.goto(unpack!(block_exit), source_info, exit_block);
Loading