Skip to content

Commit e437841

Browse files
committed
Auto merge of #52830 - matthewjasper:bootstrap-prep, r=matthewjasper
[NLL] Fix some things for bootstrap Some changes that are required when bootstrapping rustc with NLL enabled. * Remove a bunch of unused `mut`s that aren't needed, but the existing lint doesn't catch. * Rewrite a function call to satisfy NLL borrowck. Note that the borrow is two-phase, but gets activated immediately by an unsizing coercion. cc #51823
2 parents 5ed2b51 + 18d5f82 commit e437841

File tree

14 files changed

+16
-15
lines changed

14 files changed

+16
-15
lines changed

src/libfmt_macros/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a> Iterator for Parser<'a> {
168168
if self.consume('{') {
169169
Some(String(self.string(pos + 1)))
170170
} else {
171-
let mut arg = self.argument();
171+
let arg = self.argument();
172172
if let Some(arg_pos) = self.must_consume('}').map(|end| {
173173
(pos + raw + 1, end + raw + 2)
174174
}) {

src/librustc/hir/lowering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2814,7 +2814,7 @@ impl<'a> LoweringContext<'a> {
28142814
let mut defs = self.expect_full_def_from_use(id);
28152815
// we want to return *something* from this function, so hang onto the first item
28162816
// for later
2817-
let mut ret_def = defs.next().unwrap_or(Def::Err);
2817+
let ret_def = defs.next().unwrap_or(Def::Err);
28182818

28192819
for (def, &new_node_id) in defs.zip([id1, id2].iter()) {
28202820
let vis = vis.clone();

src/librustc/traits/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
10541054
// found arguments is empty (assume the user just wants to ignore args in this case).
10551055
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
10561056
if found_args.is_empty() && is_closure {
1057-
let mut underscores = "_".repeat(expected_args.len())
1057+
let underscores = "_".repeat(expected_args.len())
10581058
.split("")
10591059
.filter(|s| !s.is_empty())
10601060
.collect::<Vec<_>>()

src/librustc/util/ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl PrintContext {
354354
};
355355
if has_default {
356356
if let Some(substs) = tcx.lift(&substs) {
357-
let mut types = substs.types().rev().skip(child_types);
357+
let types = substs.types().rev().skip(child_types);
358358
for ((def_id, has_default), actual) in type_params.zip(types) {
359359
if !has_default {
360360
break;

src/librustc_data_structures/sorted_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<K: Ord, V> SortedMap<K, V> {
5656
pub fn insert(&mut self, key: K, mut value: V) -> Option<V> {
5757
match self.lookup_index_for(&key) {
5858
Ok(index) => {
59-
let mut slot = unsafe {
59+
let slot = unsafe {
6060
self.data.get_unchecked_mut(index)
6161
};
6262
mem::swap(&mut slot.1, &mut value);

src/librustc_lint/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
146146
fn check_must_use(cx: &LateContext, def_id: DefId, sp: Span, describe_path: &str) -> bool {
147147
for attr in cx.tcx.get_attrs(def_id).iter() {
148148
if attr.check_name("must_use") {
149-
let mut msg = format!("unused {}`{}` which must be used",
149+
let msg = format!("unused {}`{}` which must be used",
150150
describe_path, cx.tcx.item_path_str(def_id));
151151
let mut err = cx.struct_span_lint(UNUSED_MUST_USE, sp, &msg);
152152
// check for #[must_use = "..."]

src/librustc_mir/borrow_check/nll/constraints/graph.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ impl ConstraintGraph {
2828
let mut next_constraints = IndexVec::from_elem(None, &set.constraints);
2929

3030
for (idx, constraint) in set.constraints.iter_enumerated().rev() {
31-
let mut head = &mut first_constraints[constraint.sup];
32-
let mut next = &mut next_constraints[idx];
31+
let head = &mut first_constraints[constraint.sup];
32+
let next = &mut next_constraints[idx];
3333
debug_assert!(next.is_none());
3434
*next = *head;
3535
*head = Some(idx);

src/librustc_mir/build/matches/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
259259
}
260260

261261
TestKind::Eq { value, mut ty } => {
262-
let mut val = Operand::Copy(place.clone());
262+
let val = Operand::Copy(place.clone());
263263
let mut expect = self.literal_operand(test.span, ty, value);
264264
// Use PartialEq::eq instead of BinOp::Eq
265265
// (the binop can only handle primitives)

src/librustc_mir/monomorphize/partitioning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ fn place_root_mono_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
353353
Visibility::Hidden
354354
}
355355
};
356-
let (linkage, mut visibility) = match mono_item.explicit_linkage(tcx) {
356+
let (linkage, visibility) = match mono_item.explicit_linkage(tcx) {
357357
Some(explicit_linkage) => (explicit_linkage, Visibility::Default),
358358
None => {
359359
match mono_item {

src/librustc_mir/transform/promote_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
390390
LocalDecl::new_return_place(tcx.types.never, mir.span)
391391
).collect();
392392

393-
let mut promoter = Promoter {
393+
let promoter = Promoter {
394394
promoted: Mir::new(
395395
IndexVec::new(),
396396
// FIXME: maybe try to filter this to avoid blowing up

src/librustc_passes/rvalue_promotion.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
248248
let tcx = self.tcx;
249249
let param_env = self.param_env;
250250
let region_scope_tree = self.tcx.region_scope_tree(item_def_id);
251-
euv::ExprUseVisitor::new(self, tcx, param_env, &region_scope_tree, self.tables, None)
251+
let tables = self.tables;
252+
euv::ExprUseVisitor::new(self, tcx, param_env, &region_scope_tree, tables, None)
252253
.consume_body(body);
253254

254255
let body_promotable = self.check_expr(&body.value);

src/librustc_resolve/resolve_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
865865
// this may resolve to either a value or a type, but for documentation
866866
// purposes it's good enough to just favor one over the other.
867867
self.per_ns(|this, ns| if let Some(binding) = result[ns].get().ok() {
868-
let mut import = this.import_map.entry(directive.id).or_default();
868+
let import = this.import_map.entry(directive.id).or_default();
869869
import[ns] = Some(PathResolution::new(binding.def()));
870870
});
871871

src/librustc_save_analysis/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
423423
let mut qualname = String::from("<");
424424
qualname.push_str(&self.tcx.hir.node_to_pretty_string(ty.id));
425425

426-
let mut trait_id = self.tcx.trait_id_of_impl(impl_id);
426+
let trait_id = self.tcx.trait_id_of_impl(impl_id);
427427
let mut decl_id = None;
428428
let mut docs = String::new();
429429
let mut attrs = vec![];

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ fn resolve(cx: &DocContext, path_str: &str, is_val: bool) -> Result<(Def, Option
11721172

11731173
// Try looking for methods and associated items
11741174
let mut split = path_str.rsplitn(2, "::");
1175-
let mut item_name = if let Some(first) = split.next() {
1175+
let item_name = if let Some(first) = split.next() {
11761176
first
11771177
} else {
11781178
return Err(())

0 commit comments

Comments
 (0)