Skip to content

Commit b97ec39

Browse files
committed
rustc_ast_lowering: remove ref patterns
1 parent a603635 commit b97ec39

File tree

8 files changed

+267
-300
lines changed

8 files changed

+267
-300
lines changed

compiler/rustc_ast_lowering/src/asm.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
123123
.operands
124124
.iter()
125125
.map(|(op, op_sp)| {
126-
let lower_reg = |reg| match reg {
126+
let lower_reg = |&reg: &_| match reg {
127127
InlineAsmRegOrRegClass::Reg(reg) => {
128128
asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
129129
asm::InlineAsmReg::parse(asm_arch, reg).unwrap_or_else(|error| {
@@ -152,32 +152,30 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
152152
}
153153
};
154154

155-
let op = match *op {
156-
InlineAsmOperand::In { reg, ref expr } => hir::InlineAsmOperand::In {
155+
let op = match op {
156+
InlineAsmOperand::In { reg, expr } => hir::InlineAsmOperand::In {
157157
reg: lower_reg(reg),
158158
expr: self.lower_expr(expr),
159159
},
160-
InlineAsmOperand::Out { reg, late, ref expr } => hir::InlineAsmOperand::Out {
160+
InlineAsmOperand::Out { reg, late, expr } => hir::InlineAsmOperand::Out {
161161
reg: lower_reg(reg),
162-
late,
162+
late: *late,
163163
expr: expr.as_ref().map(|expr| self.lower_expr(expr)),
164164
},
165-
InlineAsmOperand::InOut { reg, late, ref expr } => {
166-
hir::InlineAsmOperand::InOut {
167-
reg: lower_reg(reg),
168-
late,
169-
expr: self.lower_expr(expr),
170-
}
171-
}
172-
InlineAsmOperand::SplitInOut { reg, late, ref in_expr, ref out_expr } => {
165+
InlineAsmOperand::InOut { reg, late, expr } => hir::InlineAsmOperand::InOut {
166+
reg: lower_reg(reg),
167+
late: *late,
168+
expr: self.lower_expr(expr),
169+
},
170+
InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
173171
hir::InlineAsmOperand::SplitInOut {
174172
reg: lower_reg(reg),
175-
late,
173+
late: *late,
176174
in_expr: self.lower_expr(in_expr),
177175
out_expr: out_expr.as_ref().map(|expr| self.lower_expr(expr)),
178176
}
179177
}
180-
InlineAsmOperand::Const { ref anon_const } => {
178+
InlineAsmOperand::Const { anon_const } => {
181179
if !self.tcx.features().asm_const {
182180
feature_err(
183181
&sess.parse_sess,
@@ -191,7 +189,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
191189
anon_const: self.lower_anon_const(anon_const),
192190
}
193191
}
194-
InlineAsmOperand::Sym { ref sym } => {
192+
InlineAsmOperand::Sym { sym } => {
195193
let static_def_id = self
196194
.resolver
197195
.get_partial_res(sym.id)
@@ -347,7 +345,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
347345
skip = true;
348346

349347
let idx2 = *o.get();
350-
let &(ref op2, op_sp2) = &operands[idx2];
348+
let (ref op2, op_sp2) = operands[idx2];
351349
let Some(asm::InlineAsmRegOrRegClass::Reg(reg2)) = op2.reg() else {
352350
unreachable!();
353351
};

compiler/rustc_ast_lowering/src/block.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
3131
let mut stmts = SmallVec::<[hir::Stmt<'hir>; 8]>::new();
3232
let mut expr = None;
3333
while let [s, tail @ ..] = ast_stmts {
34-
match s.kind {
35-
StmtKind::Local(ref local) => {
34+
match &s.kind {
35+
StmtKind::Local(local) => {
3636
let hir_id = self.lower_node_id(s.id);
3737
let local = self.lower_local(local);
3838
self.alias_attrs(hir_id, local.hir_id);
3939
let kind = hir::StmtKind::Local(local);
4040
let span = self.lower_span(s.span);
4141
stmts.push(hir::Stmt { hir_id, kind, span });
4242
}
43-
StmtKind::Item(ref it) => {
43+
StmtKind::Item(it) => {
4444
stmts.extend(self.lower_item_ref(it).into_iter().enumerate().map(
4545
|(i, item_id)| {
4646
let hir_id = match i {
@@ -53,7 +53,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
5353
},
5454
));
5555
}
56-
StmtKind::Expr(ref e) => {
56+
StmtKind::Expr(e) => {
5757
let e = self.lower_expr(e);
5858
if tail.is_empty() {
5959
expr = Some(e);
@@ -65,7 +65,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
6565
stmts.push(hir::Stmt { hir_id, kind, span });
6666
}
6767
}
68-
StmtKind::Semi(ref e) => {
68+
StmtKind::Semi(e) => {
6969
let e = self.lower_expr(e);
7070
let hir_id = self.lower_node_id(s.id);
7171
self.alias_attrs(hir_id, e.hir_id);

0 commit comments

Comments
 (0)