Skip to content

Commit 2237977

Browse files
authored
Rollup merge of #105875 - matthiaskrgr:needless_borrowed_reference, r=oli-obk
don't destuct references just to reborrow
2 parents 8892698 + a108d55 commit 2237977

File tree

22 files changed

+41
-42
lines changed

22 files changed

+41
-42
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ fn thin_lto(
425425
info!("going for that thin, thin LTO");
426426

427427
let green_modules: FxHashMap<_, _> =
428-
cached_modules.iter().map(|&(_, ref wp)| (wp.cgu_name.clone(), wp.clone())).collect();
428+
cached_modules.iter().map(|(_, wp)| (wp.cgu_name.clone(), wp.clone())).collect();
429429

430430
let full_scope_len = modules.len() + serialized_modules.len() + cached_modules.len();
431431
let mut thin_buffers = Vec::with_capacity(modules.len());

compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ fn link_natively<'a>(
722722

723723
linker::disable_localization(&mut cmd);
724724

725-
for &(ref k, ref v) in sess.target.link_env.as_ref() {
725+
for (k, v) in sess.target.link_env.as_ref() {
726726
cmd.env(k.as_ref(), v.as_ref());
727727
}
728728
for k in sess.target.link_env_remove.as_ref() {

compiler/rustc_codegen_ssa/src/back/linker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn get_linker<'a>(
108108
if sess.target.is_like_msvc {
109109
if let Some(ref tool) = msvc_tool {
110110
cmd.args(tool.args());
111-
for &(ref k, ref v) in tool.env() {
111+
for (k, v) in tool.env() {
112112
if k == "PATH" {
113113
new_path.extend(env::split_paths(v));
114114
msvc_changed_path = true;

compiler/rustc_const_eval/src/interpret/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
332332
Immediate::new_slice(ptr, length.eval_usize(*self.tcx, self.param_env), self);
333333
self.write_immediate(val, dest)
334334
}
335-
(&ty::Dynamic(ref data_a, ..), &ty::Dynamic(ref data_b, ..)) => {
335+
(ty::Dynamic(data_a, ..), ty::Dynamic(data_b, ..)) => {
336336
let val = self.read_immediate(src)?;
337337
if data_a.principal() == data_b.principal() {
338338
// A NOP cast that doesn't actually change anything, should be allowed even with mismatching vtables.

compiler/rustc_expand/src/mbe/macro_check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn check_nested_occurrences(
468468
// We check that the meta-variable is correctly used.
469469
check_occurrences(sess, node_id, tt, macros, binders, ops, valid);
470470
}
471-
(NestedMacroState::MacroName, &TokenTree::Delimited(_, ref del))
471+
(NestedMacroState::MacroName, TokenTree::Delimited(_, del))
472472
if del.delim == Delimiter::Parenthesis =>
473473
{
474474
state = NestedMacroState::MacroNameParen;
@@ -483,7 +483,7 @@ fn check_nested_occurrences(
483483
valid,
484484
);
485485
}
486-
(NestedMacroState::MacroNameParen, &TokenTree::Delimited(_, ref del))
486+
(NestedMacroState::MacroNameParen, TokenTree::Delimited(_, del))
487487
if del.delim == Delimiter::Brace =>
488488
{
489489
state = NestedMacroState::Empty;

compiler/rustc_expand/src/mbe/macro_rules.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ impl<'tt> FirstSets<'tt> {
792792
TokenTree::Sequence(sp, ref seq_rep) => {
793793
let subfirst_owned;
794794
let subfirst = match self.first.get(&sp.entire()) {
795-
Some(&Some(ref subfirst)) => subfirst,
795+
Some(Some(subfirst)) => subfirst,
796796
Some(&None) => {
797797
subfirst_owned = self.first(&seq_rep.tts);
798798
&subfirst_owned

compiler/rustc_hir_typeck/src/demand.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12751275
};
12761276

12771277
match (&expected_ty.kind(), &checked_ty.kind()) {
1278-
(&ty::Int(ref exp), &ty::Int(ref found)) => {
1278+
(ty::Int(exp), ty::Int(found)) => {
12791279
let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width())
12801280
{
12811281
(Some(exp), Some(found)) if exp < found => (true, false),
@@ -1288,7 +1288,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12881288
suggest_to_change_suffix_or_into(err, f2e_is_fallible, e2f_is_fallible);
12891289
true
12901290
}
1291-
(&ty::Uint(ref exp), &ty::Uint(ref found)) => {
1291+
(ty::Uint(exp), ty::Uint(found)) => {
12921292
let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width())
12931293
{
12941294
(Some(exp), Some(found)) if exp < found => (true, false),
@@ -1321,7 +1321,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13211321
suggest_to_change_suffix_or_into(err, f2e_is_fallible, e2f_is_fallible);
13221322
true
13231323
}
1324-
(&ty::Float(ref exp), &ty::Float(ref found)) => {
1324+
(ty::Float(exp), ty::Float(found)) => {
13251325
if found.bit_width() < exp.bit_width() {
13261326
suggest_to_change_suffix_or_into(err, false, true);
13271327
} else if literal_is_ty_suffixed(expr) {
@@ -1357,7 +1357,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13571357
}
13581358
true
13591359
}
1360-
(&ty::Float(ref exp), &ty::Uint(ref found)) => {
1360+
(ty::Float(exp), ty::Uint(found)) => {
13611361
// if `found` is `None` (meaning found is `usize`), don't suggest `.into()`
13621362
if exp.bit_width() > found.bit_width().unwrap_or(256) {
13631363
err.multipart_suggestion_verbose(
@@ -1386,7 +1386,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13861386
}
13871387
true
13881388
}
1389-
(&ty::Float(ref exp), &ty::Int(ref found)) => {
1389+
(ty::Float(exp), ty::Int(found)) => {
13901390
// if `found` is `None` (meaning found is `isize`), don't suggest `.into()`
13911391
if exp.bit_width() > found.bit_width().unwrap_or(256) {
13921392
err.multipart_suggestion_verbose(

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18741874
// I don't use 'is_range_literal' because only double-sided, half-open ranges count.
18751875
if let ExprKind::Struct(
18761876
QPath::LangItem(LangItem::Range, ..),
1877-
&[ref range_start, ref range_end],
1877+
[range_start, range_end],
18781878
_,
18791879
) = last_expr_field.expr.kind
18801880
&& let variant_field =

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
754754
return true
755755
}
756756
}
757-
&hir::FnRetTy::Return(ref ty) => {
757+
hir::FnRetTy::Return(ty) => {
758758
// Only point to return type if the expected type is the return type, as if they
759759
// are not, the expectation must have been caused by something else.
760760
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind);

compiler/rustc_incremental/src/assert_dep_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn dump_graph(query: &DepGraphQuery) {
249249
// dump a .txt file with just the edges:
250250
let txt_path = format!("{}.txt", path);
251251
let mut file = BufWriter::new(File::create(&txt_path).unwrap());
252-
for &(ref source, ref target) in &edges {
252+
for (source, target) in &edges {
253253
write!(file, "{:?} -> {:?}\n", source, target).unwrap();
254254
}
255255
}

compiler/rustc_infer/src/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'tcx> ProjectionCache<'_, 'tcx> {
200200
pub fn complete(&mut self, key: ProjectionCacheKey<'tcx>, result: EvaluationResult) {
201201
let mut map = self.map();
202202
match map.get(&key) {
203-
Some(&ProjectionCacheEntry::NormalizedTy { ref ty, complete: _ }) => {
203+
Some(ProjectionCacheEntry::NormalizedTy { ty, complete: _ }) => {
204204
info!("ProjectionCacheEntry::complete({:?}) - completing {:?}", key, ty);
205205
let mut ty = ty.clone();
206206
if result.must_apply_considering_regions() {

compiler/rustc_lint/src/context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,18 @@ impl LintStore {
438438
return CheckLintNameResult::Tool(Ok(&lint_ids));
439439
}
440440
},
441-
Some(&Id(ref id)) => return CheckLintNameResult::Tool(Ok(slice::from_ref(id))),
441+
Some(Id(id)) => return CheckLintNameResult::Tool(Ok(slice::from_ref(id))),
442442
// If the lint was registered as removed or renamed by the lint tool, we don't need
443443
// to treat tool_lints and rustc lints different and can use the code below.
444444
_ => {}
445445
}
446446
}
447447
match self.by_name.get(&complete_name) {
448-
Some(&Renamed(ref new_name, _)) => CheckLintNameResult::Warning(
448+
Some(Renamed(new_name, _)) => CheckLintNameResult::Warning(
449449
format!("lint `{}` has been renamed to `{}`", complete_name, new_name),
450450
Some(new_name.to_owned()),
451451
),
452-
Some(&Removed(ref reason)) => CheckLintNameResult::Warning(
452+
Some(Removed(reason)) => CheckLintNameResult::Warning(
453453
format!("lint `{}` has been removed: {}", complete_name, reason),
454454
None,
455455
),
@@ -470,7 +470,7 @@ impl LintStore {
470470
CheckLintNameResult::Ok(&lint_ids)
471471
}
472472
},
473-
Some(&Id(ref id)) => CheckLintNameResult::Ok(slice::from_ref(id)),
473+
Some(Id(id)) => CheckLintNameResult::Ok(slice::from_ref(id)),
474474
Some(&Ignored) => CheckLintNameResult::Ok(&[]),
475475
}
476476
}
@@ -513,7 +513,7 @@ impl LintStore {
513513
CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name)))
514514
}
515515
},
516-
Some(&Id(ref id)) => {
516+
Some(Id(id)) => {
517517
CheckLintNameResult::Tool(Err((Some(slice::from_ref(id)), complete_name)))
518518
}
519519
Some(other) => {

compiler/rustc_lint/src/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ impl UnusedImportBraces {
12791279
fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: &ast::Item) {
12801280
if let ast::UseTreeKind::Nested(ref items) = use_tree.kind {
12811281
// Recursively check nested UseTrees
1282-
for &(ref tree, _) in items {
1282+
for (tree, _) in items {
12831283
self.check_use_tree(cx, tree, item);
12841284
}
12851285

compiler/rustc_metadata/src/rmeta/encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18491849
// the assumption that they are numbered 1 to n.
18501850
// FIXME (#2166): This is not nearly enough to support correct versioning
18511851
// but is enough to get transitive crate dependencies working.
1852-
self.lazy_array(deps.iter().map(|&(_, ref dep)| dep))
1852+
self.lazy_array(deps.iter().map(|(_, dep)| dep))
18531853
}
18541854

18551855
fn encode_lib_features(&mut self) -> LazyArray<(Symbol, Option<Symbol>)> {
@@ -1986,7 +1986,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
19861986
self.lazy_array(
19871987
exported_symbols
19881988
.iter()
1989-
.filter(|&&(ref exported_symbol, _)| match *exported_symbol {
1989+
.filter(|&(exported_symbol, _)| match *exported_symbol {
19901990
ExportedSymbol::NoDefId(symbol_name) => symbol_name != metadata_symbol_name,
19911991
_ => true,
19921992
})

compiler/rustc_middle/src/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl<'tcx> Operand<'tcx> {
235235
{
236236
match self {
237237
&Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty,
238-
&Operand::Constant(ref c) => c.literal.ty(),
238+
Operand::Constant(c) => c.literal.ty(),
239239
}
240240
}
241241
}

compiler/rustc_middle/src/ty/flags.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl FlagComputation {
9595
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
9696
}
9797

98-
&ty::Generator(_, ref substs, _) => {
98+
ty::Generator(_, substs, _) => {
9999
let substs = substs.as_generator();
100100
let should_remove_further_specializable =
101101
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
@@ -186,7 +186,7 @@ impl FlagComputation {
186186

187187
&ty::Slice(tt) => self.add_ty(tt),
188188

189-
&ty::RawPtr(ref m) => {
189+
ty::RawPtr(m) => {
190190
self.add_ty(m.ty);
191191
}
192192

compiler/rustc_middle/src/ty/relate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
428428
Ok(a)
429429
}
430430

431-
(&ty::Param(ref a_p), &ty::Param(ref b_p)) if a_p.index == b_p.index => Ok(a),
431+
(ty::Param(a_p), ty::Param(b_p)) if a_p.index == b_p.index => Ok(a),
432432

433433
(ty::Placeholder(p1), ty::Placeholder(p2)) if p1 == p2 => Ok(a),
434434

compiler/rustc_mir_build/src/build/matches/test.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -551,16 +551,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
551551
//
552552
// FIXME(#29623) we could use PatKind::Range to rule
553553
// things out here, in some cases.
554-
(
555-
&TestKind::SwitchInt { switch_ty: _, ref options },
556-
&PatKind::Constant { ref value },
557-
) if is_switch_ty(match_pair.pattern.ty) => {
554+
(TestKind::SwitchInt { switch_ty: _, options }, PatKind::Constant { value })
555+
if is_switch_ty(match_pair.pattern.ty) =>
556+
{
558557
let index = options.get_index_of(value).unwrap();
559558
self.candidate_without_match_pair(match_pair_index, candidate);
560559
Some(index)
561560
}
562561

563-
(&TestKind::SwitchInt { switch_ty: _, ref options }, &PatKind::Range(ref range)) => {
562+
(TestKind::SwitchInt { switch_ty: _, options }, PatKind::Range(range)) => {
564563
let not_contained =
565564
self.values_not_contained_in_range(&*range, options).unwrap_or(false);
566565

@@ -578,7 +577,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
578577

579578
(
580579
&TestKind::Len { len: test_len, op: BinOp::Eq },
581-
&PatKind::Slice { ref prefix, ref slice, ref suffix },
580+
PatKind::Slice { prefix, slice, suffix },
582581
) => {
583582
let pat_len = (prefix.len() + suffix.len()) as u64;
584583
match (test_len.cmp(&pat_len), slice) {
@@ -615,7 +614,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
615614

616615
(
617616
&TestKind::Len { len: test_len, op: BinOp::Ge },
618-
&PatKind::Slice { ref prefix, ref slice, ref suffix },
617+
PatKind::Slice { prefix, slice, suffix },
619618
) => {
620619
// the test is `$actual_len >= test_len`
621620
let pat_len = (prefix.len() + suffix.len()) as u64;
@@ -651,7 +650,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
651650
}
652651
}
653652

654-
(&TestKind::Range(ref test), &PatKind::Range(ref pat)) => {
653+
(TestKind::Range(test), PatKind::Range(pat)) => {
655654
use std::cmp::Ordering::*;
656655

657656
if test == pat {
@@ -678,7 +677,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
678677
no_overlap
679678
}
680679

681-
(&TestKind::Range(ref range), &PatKind::Constant { value }) => {
680+
(TestKind::Range(range), &PatKind::Constant { value }) => {
682681
if let Some(false) = self.const_range_contains(&*range, value) {
683682
// `value` is not contained in the testing range,
684683
// so `value` can be matched only if this test fails.

compiler/rustc_passes/src/hir_stats.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'k> StatCollector<'k> {
121121

122122
fn print(&self, title: &str, prefix: &str) {
123123
let mut nodes: Vec<_> = self.nodes.iter().collect();
124-
nodes.sort_by_key(|&(_, ref node)| node.stats.count * node.stats.size);
124+
nodes.sort_by_key(|(_, node)| node.stats.count * node.stats.size);
125125

126126
let total_size = nodes.iter().map(|(_, node)| node.stats.count * node.stats.size).sum();
127127

@@ -147,7 +147,7 @@ impl<'k> StatCollector<'k> {
147147
);
148148
if !node.subnodes.is_empty() {
149149
let mut subnodes: Vec<_> = node.subnodes.iter().collect();
150-
subnodes.sort_by_key(|&(_, ref subnode)| subnode.count * subnode.size);
150+
subnodes.sort_by_key(|(_, subnode)| subnode.count * subnode.size);
151151

152152
for (label, subnode) in subnodes {
153153
let size = subnode.count * subnode.size;

compiler/rustc_resolve/src/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
576576
// Ensure there is at most one `self` in the list
577577
let self_spans = items
578578
.iter()
579-
.filter_map(|&(ref use_tree, _)| {
579+
.filter_map(|(use_tree, _)| {
580580
if let ast::UseTreeKind::Simple(..) = use_tree.kind {
581581
if use_tree.ident().name == kw::SelfLower {
582582
return Some(use_tree.span);

compiler/rustc_session/src/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ pub fn build_session(
13231323
let warnings_allow = sopts
13241324
.lint_opts
13251325
.iter()
1326-
.rfind(|&&(ref key, _)| *key == "warnings")
1326+
.rfind(|&(key, _)| *key == "warnings")
13271327
.map_or(false, |&(_, level)| level == lint::Allow);
13281328
let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow);
13291329
let can_emit_warnings = !(warnings_allow || cap_lints_allow);

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
226226
let arg_length = arguments.len();
227227
let distinct = matches!(other, &[ArgKind::Tuple(..)]);
228228
match (arg_length, arguments.get(0)) {
229-
(1, Some(&ArgKind::Tuple(_, ref fields))) => {
229+
(1, Some(ArgKind::Tuple(_, fields))) => {
230230
format!("a single {}-tuple as argument", fields.len())
231231
}
232232
_ => format!(

0 commit comments

Comments
 (0)