diff --git a/src/librustc_builtin_macros/format.rs b/src/librustc_builtin_macros/format.rs index 3724a83a9498..81c97bcea050 100644 --- a/src/librustc_builtin_macros/format.rs +++ b/src/librustc_builtin_macros/format.rs @@ -476,7 +476,7 @@ impl<'a, 'b> Context<'a, 'b> { match ty { Placeholder(_) => { // record every (position, type) combination only once - let ref mut seen_ty = self.arg_unique_types[arg]; + let seen_ty = &mut self.arg_unique_types[arg]; let i = seen_ty.iter().position(|x| *x == ty).unwrap_or_else(|| { let i = seen_ty.len(); seen_ty.push(ty); @@ -526,7 +526,7 @@ impl<'a, 'b> Context<'a, 'b> { // Map the arguments for i in 0..args_len { - let ref arg_types = self.arg_types[i]; + let arg_types = &self.arg_types[i]; let arg_offsets = arg_types.iter().map(|offset| sofar + *offset).collect::>(); self.arg_index_map.push(arg_offsets); sofar += self.arg_unique_types[i].len(); @@ -597,7 +597,7 @@ impl<'a, 'b> Context<'a, 'b> { let arg_idx = match arg_index_consumed.get_mut(i) { None => 0, // error already emitted elsewhere Some(offset) => { - let ref idx_map = self.arg_index_map[i]; + let idx_map = &self.arg_index_map[i]; // unwrap_or branch: error already emitted elsewhere let arg_idx = *idx_map.get(*offset).unwrap_or(&0); *offset += 1; @@ -721,7 +721,7 @@ impl<'a, 'b> Context<'a, 'b> { let name = names_pos[i]; let span = self.ecx.with_def_site_ctxt(e.span); pats.push(self.ecx.pat_ident(span, name)); - for ref arg_ty in self.arg_unique_types[i].iter() { + for arg_ty in self.arg_unique_types[i].iter() { locals.push(Context::format_arg(self.ecx, self.macsp, e.span, arg_ty, name)); } heads.push(self.ecx.expr_addr_of(e.span, e)); diff --git a/src/librustc_builtin_macros/global_allocator.rs b/src/librustc_builtin_macros/global_allocator.rs index 8de7455a09a6..5d16be3206aa 100644 --- a/src/librustc_builtin_macros/global_allocator.rs +++ b/src/librustc_builtin_macros/global_allocator.rs @@ -57,12 +57,12 @@ impl AllocFnFactory<'_, '_> { fn allocator_fn(&self, method: &AllocatorMethod) -> Stmt { let mut abi_args = Vec::new(); let mut i = 0; - let ref mut mk = || { + let mut mk = || { let name = self.cx.ident_of(&format!("arg{}", i), self.span); i += 1; name }; - let args = method.inputs.iter().map(|ty| self.arg_ty(ty, &mut abi_args, mk)).collect(); + let args = method.inputs.iter().map(|ty| self.arg_ty(ty, &mut abi_args, &mut mk)).collect(); let result = self.call_allocator(method.name, args); let (output_ty, output_expr) = self.ret_ty(&method.output, result); let decl = self.cx.fn_decl(abi_args, ast::FnRetTy::Ty(output_ty)); diff --git a/src/librustc_builtin_macros/test.rs b/src/librustc_builtin_macros/test.rs index 7fe65f28532d..bc194a3eec4c 100644 --- a/src/librustc_builtin_macros/test.rs +++ b/src/librustc_builtin_macros/test.rs @@ -313,7 +313,7 @@ fn should_fail(i: &ast::Item) -> bool { fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic { match attr::find_by_name(&i.attrs, sym::should_panic) { Some(attr) => { - let ref sd = cx.parse_sess.span_diagnostic; + let sd = &cx.parse_sess.span_diagnostic; match attr.meta_item_list() { // Handle #[should_panic(expected = "foo")] @@ -378,7 +378,7 @@ fn test_type(cx: &ExtCtxt<'_>) -> TestType { fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic); - let ref sd = cx.parse_sess.span_diagnostic; + let sd = &cx.parse_sess.span_diagnostic; if let ast::ItemKind::Fn(_, ref sig, ref generics, _) = i.kind { if let ast::Unsafe::Yes(span) = sig.header.unsafety { sd.struct_span_err(i.span, "unsafe functions cannot be used for tests") diff --git a/src/librustc_builtin_macros/test_harness.rs b/src/librustc_builtin_macros/test_harness.rs index 51a217028055..e7e1ad8eda78 100644 --- a/src/librustc_builtin_macros/test_harness.rs +++ b/src/librustc_builtin_macros/test_harness.rs @@ -326,7 +326,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P { /// &[&test1, &test2] fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P { debug!("building test vector from {} tests", cx.test_cases.len()); - let ref ecx = cx.ext_cx; + let ecx = &cx.ext_cx; ecx.expr_vec_slice( sp, diff --git a/src/librustc_infer/traits/select.rs b/src/librustc_infer/traits/select.rs index 4c312c9fce25..fd94e3b69940 100644 --- a/src/librustc_infer/traits/select.rs +++ b/src/librustc_infer/traits/select.rs @@ -1341,7 +1341,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { stack: &TraitObligationStack<'o, 'tcx>, ) -> Result, SelectionError<'tcx>> { let TraitObligationStack { obligation, .. } = *stack; - let ref obligation = Obligation { + let obligation = &Obligation { param_env: obligation.param_env, cause: obligation.cause.clone(), recursion_depth: obligation.recursion_depth, diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 286740f99dde..9fe21964b988 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -920,7 +920,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { let (blocks, local_decls) = self.source.basic_blocks_and_local_decls_mut(); match candidate { Candidate::Ref(loc) => { - let ref mut statement = blocks[loc.block].statements[loc.statement_index]; + let statement = &mut blocks[loc.block].statements[loc.statement_index]; match statement.kind { StatementKind::Assign(box ( _, @@ -971,7 +971,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { } } Candidate::Repeat(loc) => { - let ref mut statement = blocks[loc.block].statements[loc.statement_index]; + let statement = &mut blocks[loc.block].statements[loc.statement_index]; match statement.kind { StatementKind::Assign(box (_, Rvalue::Repeat(ref mut operand, _))) => { let ty = operand.ty(local_decls, self.tcx); diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/hair/pattern/_match.rs index 4c7e6e1754aa..5b054c045224 100644 --- a/src/librustc_mir_build/hair/pattern/_match.rs +++ b/src/librustc_mir_build/hair/pattern/_match.rs @@ -2331,7 +2331,7 @@ fn specialize_one_pattern<'p, 'tcx>( PatKind::Binding { .. } | PatKind::Wild => Some(ctor_wild_subpatterns.iter().collect()), PatKind::Variant { adt_def, variant_index, ref subpatterns, .. } => { - let ref variant = adt_def.variants[variant_index]; + let variant = &adt_def.variants[variant_index]; let is_non_exhaustive = cx.is_foreign_non_exhaustive_variant(pat.ty, variant); Some(Variant(variant.def_id)) .filter(|variant_constructor| variant_constructor == constructor)