Skip to content

Commit 4080232

Browse files
committed
Remove P<> from visit_expr
1 parent 6aa0631 commit 4080232

File tree

7 files changed

+19
-21
lines changed

7 files changed

+19
-21
lines changed

compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub trait MutVisitor: Sized {
184184
walk_anon_const(self, c);
185185
}
186186

187-
fn visit_expr(&mut self, e: &mut P<Expr>) {
187+
fn visit_expr(&mut self, e: &mut Expr) {
188188
walk_expr(self, e);
189189
}
190190

compiler/rustc_builtin_macros/src/cfg_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl CfgEval<'_> {
165165

166166
impl MutVisitor for CfgEval<'_> {
167167
#[instrument(level = "trace", skip(self))]
168-
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
168+
fn visit_expr(&mut self, expr: &mut ast::Expr) {
169169
self.0.configure_expr(expr, false);
170170
mut_visit::walk_expr(self, expr);
171171
}

compiler/rustc_expand/src/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Conditional compilation stripping.
22
3-
use rustc_ast::ptr::P;
43
use rustc_ast::token::{Delimiter, Token, TokenKind};
54
use rustc_ast::tokenstream::{
65
AttrTokenStream, AttrTokenTree, LazyAttrTokenStream, Spacing, TokenTree,
@@ -427,7 +426,7 @@ impl<'a> StripUnconfigured<'a> {
427426
}
428427

429428
#[instrument(level = "trace", skip(self))]
430-
pub fn configure_expr(&self, expr: &mut P<ast::Expr>, method_receiver: bool) {
429+
pub fn configure_expr(&self, expr: &mut ast::Expr, method_receiver: bool) {
431430
if !method_receiver {
432431
for attr in expr.attrs.iter() {
433432
self.maybe_emit_expr_attr_err(attr);

compiler/rustc_expand/src/expand.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1640,15 +1640,15 @@ impl InvocationCollectorNode for P<ast::Pat> {
16401640
}
16411641
}
16421642

1643-
impl InvocationCollectorNode for P<ast::Expr> {
1644-
type OutputTy = P<ast::Expr>;
1643+
impl InvocationCollectorNode for ast::Expr {
1644+
type OutputTy = ast::Expr;
16451645
type AttrsTy = ast::AttrVec;
16461646
const KIND: AstFragmentKind = AstFragmentKind::Expr;
16471647
fn to_annotatable(self) -> Annotatable {
1648-
Annotatable::Expr(self)
1648+
Annotatable::Expr(P(self))
16491649
}
16501650
fn fragment_to_output(fragment: AstFragment) -> Self::OutputTy {
1651-
fragment.make_expr()
1651+
fragment.make_expr().into_inner()
16521652
}
16531653
fn descr() -> &'static str {
16541654
"an expression"
@@ -1660,9 +1660,8 @@ impl InvocationCollectorNode for P<ast::Expr> {
16601660
matches!(self.kind, ExprKind::MacCall(..))
16611661
}
16621662
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
1663-
let node = self.into_inner();
1664-
match node.kind {
1665-
ExprKind::MacCall(mac) => (mac, node.attrs, AddSemicolon::No),
1663+
match self.kind {
1664+
ExprKind::MacCall(mac) => (mac, self.attrs, AddSemicolon::No),
16661665
_ => unreachable!(),
16671666
}
16681667
}
@@ -2184,7 +2183,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
21842183
self.visit_node(node)
21852184
}
21862185

2187-
fn visit_expr(&mut self, node: &mut P<ast::Expr>) {
2186+
fn visit_expr(&mut self, node: &mut ast::Expr) {
21882187
// FIXME: Feature gating is performed inconsistently between `Expr` and `OptExpr`.
21892188
if let Some(attr) = node.attrs.first() {
21902189
self.cfg().maybe_emit_expr_attr_err(attr);

compiler/rustc_expand/src/placeholders.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ impl MutVisitor for PlaceholderExpander {
301301
}
302302
}
303303

304-
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
304+
fn visit_expr(&mut self, expr: &mut ast::Expr) {
305305
match expr.kind {
306-
ast::ExprKind::MacCall(_) => *expr = self.remove(expr.id).make_expr(),
306+
ast::ExprKind::MacCall(_) => *expr = self.remove(expr.id).make_expr().into_inner(),
307307
_ => walk_expr(self, expr),
308308
}
309309
}

compiler/rustc_parse/src/parser/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3944,7 +3944,7 @@ impl<'a> CondChecker<'a> {
39443944
}
39453945

39463946
impl MutVisitor for CondChecker<'_> {
3947-
fn visit_expr(&mut self, e: &mut P<Expr>) {
3947+
fn visit_expr(&mut self, e: &mut Expr) {
39483948
use ForbiddenLetReason::*;
39493949

39503950
let span = e.span;

tests/ui-fulldeps/pprust-expr-roundtrip.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
188188
struct RemoveParens;
189189

190190
impl MutVisitor for RemoveParens {
191-
fn visit_expr(&mut self, e: &mut P<Expr>) {
191+
fn visit_expr(&mut self, e: &mut Expr) {
192192
match e.kind.clone() {
193-
ExprKind::Paren(inner) => *e = inner,
193+
ExprKind::Paren(inner) => *e = inner.into_inner(),
194194
_ => {}
195195
};
196196
mut_visit::walk_expr(self, e);
@@ -201,16 +201,16 @@ impl MutVisitor for RemoveParens {
201201
struct AddParens;
202202

203203
impl MutVisitor for AddParens {
204-
fn visit_expr(&mut self, e: &mut P<Expr>) {
204+
fn visit_expr(&mut self, e: &mut Expr) {
205205
mut_visit::walk_expr(self, e);
206206
visit_clobber(e, |e| {
207-
P(Expr {
207+
Expr {
208208
id: DUMMY_NODE_ID,
209-
kind: ExprKind::Paren(e),
209+
kind: ExprKind::Paren(P(e)),
210210
span: DUMMY_SP,
211211
attrs: AttrVec::new(),
212212
tokens: None,
213-
})
213+
}
214214
});
215215
}
216216
}

0 commit comments

Comments
 (0)