Skip to content

Commit a767c7a

Browse files
committed
Avoid using deref_mut
1 parent dfd9184 commit a767c7a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_builtin_macros/src/test_harness.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Code that generates a test runner to run all the tests in a crate
22

33
use std::mem;
4-
use std::ops::DerefMut;
54

65
use rustc_ast as ast;
76
use rustc_ast::entry::EntryPointType;
@@ -130,8 +129,9 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
130129
c.items.push(mk_main(&mut self.cx));
131130
}
132131

133-
fn visit_item(&mut self, i: &mut P<ast::Item>) {
134-
let item = i.deref_mut();
132+
fn visit_item(&mut self, item: &mut P<ast::Item>) {
133+
let item = &mut **item;
134+
135135
if let Some(name) = get_test_name(&item) {
136136
debug!("this is a test item");
137137

@@ -198,13 +198,11 @@ struct EntryPointCleaner<'a> {
198198
}
199199

200200
impl<'a> MutVisitor for EntryPointCleaner<'a> {
201-
fn visit_item(&mut self, i: &mut P<ast::Item>) {
201+
fn visit_item(&mut self, item: &mut P<ast::Item>) {
202202
self.depth += 1;
203-
ast::mut_visit::walk_item(self, i, ());
203+
ast::mut_visit::walk_item(self, item, ());
204204
self.depth -= 1;
205205

206-
let item = i.deref_mut();
207-
208206
// Remove any #[rustc_main] or #[start] from the AST so it doesn't
209207
// clash with the one we're going to add, but mark it as
210208
// #[allow(dead_code)] to avoid printing warnings.

0 commit comments

Comments
 (0)