Skip to content

Commit 3fc5c11

Browse files
committed
Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg)
1 parent 3e70c8e commit 3fc5c11

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

src/librustc_builtin_macros/format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl<'a, 'b> Context<'a, 'b> {
476476
match ty {
477477
Placeholder(_) => {
478478
// record every (position, type) combination only once
479-
let ref mut seen_ty = self.arg_unique_types[arg];
479+
let seen_ty = &mut self.arg_unique_types[arg];
480480
let i = seen_ty.iter().position(|x| *x == ty).unwrap_or_else(|| {
481481
let i = seen_ty.len();
482482
seen_ty.push(ty);
@@ -526,7 +526,7 @@ impl<'a, 'b> Context<'a, 'b> {
526526

527527
// Map the arguments
528528
for i in 0..args_len {
529-
let ref arg_types = self.arg_types[i];
529+
let arg_types = &self.arg_types[i];
530530
let arg_offsets = arg_types.iter().map(|offset| sofar + *offset).collect::<Vec<_>>();
531531
self.arg_index_map.push(arg_offsets);
532532
sofar += self.arg_unique_types[i].len();
@@ -597,7 +597,7 @@ impl<'a, 'b> Context<'a, 'b> {
597597
let arg_idx = match arg_index_consumed.get_mut(i) {
598598
None => 0, // error already emitted elsewhere
599599
Some(offset) => {
600-
let ref idx_map = self.arg_index_map[i];
600+
let idx_map = &self.arg_index_map[i];
601601
// unwrap_or branch: error already emitted elsewhere
602602
let arg_idx = *idx_map.get(*offset).unwrap_or(&0);
603603
*offset += 1;
@@ -721,7 +721,7 @@ impl<'a, 'b> Context<'a, 'b> {
721721
let name = names_pos[i];
722722
let span = self.ecx.with_def_site_ctxt(e.span);
723723
pats.push(self.ecx.pat_ident(span, name));
724-
for ref arg_ty in self.arg_unique_types[i].iter() {
724+
for arg_ty in self.arg_unique_types[i].iter() {
725725
locals.push(Context::format_arg(self.ecx, self.macsp, e.span, arg_ty, name));
726726
}
727727
heads.push(self.ecx.expr_addr_of(e.span, e));

src/librustc_builtin_macros/global_allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ impl AllocFnFactory<'_, '_> {
5757
fn allocator_fn(&self, method: &AllocatorMethod) -> Stmt {
5858
let mut abi_args = Vec::new();
5959
let mut i = 0;
60-
let ref mut mk = || {
60+
let mut mk = || {
6161
let name = self.cx.ident_of(&format!("arg{}", i), self.span);
6262
i += 1;
6363
name
6464
};
65-
let args = method.inputs.iter().map(|ty| self.arg_ty(ty, &mut abi_args, mk)).collect();
65+
let args = method.inputs.iter().map(|ty| self.arg_ty(ty, &mut abi_args, &mut mk)).collect();
6666
let result = self.call_allocator(method.name, args);
6767
let (output_ty, output_expr) = self.ret_ty(&method.output, result);
6868
let decl = self.cx.fn_decl(abi_args, ast::FnRetTy::Ty(output_ty));

src/librustc_builtin_macros/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ fn should_fail(i: &ast::Item) -> bool {
313313
fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
314314
match attr::find_by_name(&i.attrs, sym::should_panic) {
315315
Some(attr) => {
316-
let ref sd = cx.parse_sess.span_diagnostic;
316+
let sd = &cx.parse_sess.span_diagnostic;
317317

318318
match attr.meta_item_list() {
319319
// Handle #[should_panic(expected = "foo")]
@@ -378,7 +378,7 @@ fn test_type(cx: &ExtCtxt<'_>) -> TestType {
378378

379379
fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
380380
let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic);
381-
let ref sd = cx.parse_sess.span_diagnostic;
381+
let sd = &cx.parse_sess.span_diagnostic;
382382
if let ast::ItemKind::Fn(_, ref sig, ref generics, _) = i.kind {
383383
if let ast::Unsafe::Yes(span) = sig.header.unsafety {
384384
sd.struct_span_err(i.span, "unsafe functions cannot be used for tests")

src/librustc_builtin_macros/test_harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
326326
/// &[&test1, &test2]
327327
fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P<ast::Expr> {
328328
debug!("building test vector from {} tests", cx.test_cases.len());
329-
let ref ecx = cx.ext_cx;
329+
let ecx = &cx.ext_cx;
330330

331331
ecx.expr_vec_slice(
332332
sp,

src/librustc_infer/traits/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13411341
stack: &TraitObligationStack<'o, 'tcx>,
13421342
) -> Result<SelectionCandidateSet<'tcx>, SelectionError<'tcx>> {
13431343
let TraitObligationStack { obligation, .. } = *stack;
1344-
let ref obligation = Obligation {
1344+
let obligation = &Obligation {
13451345
param_env: obligation.param_env,
13461346
cause: obligation.cause.clone(),
13471347
recursion_depth: obligation.recursion_depth,

src/librustc_mir/transform/promote_consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
920920
let (blocks, local_decls) = self.source.basic_blocks_and_local_decls_mut();
921921
match candidate {
922922
Candidate::Ref(loc) => {
923-
let ref mut statement = blocks[loc.block].statements[loc.statement_index];
923+
let statement = &mut blocks[loc.block].statements[loc.statement_index];
924924
match statement.kind {
925925
StatementKind::Assign(box (
926926
_,
@@ -971,7 +971,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
971971
}
972972
}
973973
Candidate::Repeat(loc) => {
974-
let ref mut statement = blocks[loc.block].statements[loc.statement_index];
974+
let statement = &mut blocks[loc.block].statements[loc.statement_index];
975975
match statement.kind {
976976
StatementKind::Assign(box (_, Rvalue::Repeat(ref mut operand, _))) => {
977977
let ty = operand.ty(local_decls, self.tcx);

src/librustc_mir_build/hair/pattern/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ fn specialize_one_pattern<'p, 'tcx>(
23312331
PatKind::Binding { .. } | PatKind::Wild => Some(ctor_wild_subpatterns.iter().collect()),
23322332

23332333
PatKind::Variant { adt_def, variant_index, ref subpatterns, .. } => {
2334-
let ref variant = adt_def.variants[variant_index];
2334+
let variant = &adt_def.variants[variant_index];
23352335
let is_non_exhaustive = cx.is_foreign_non_exhaustive_variant(pat.ty, variant);
23362336
Some(Variant(variant.def_id))
23372337
.filter(|variant_constructor| variant_constructor == constructor)

0 commit comments

Comments
 (0)