avoid &mut P<T> in visit_expr etc methods

This commit is contained in:
Deadbeef
2025-06-12 00:02:12 +08:00
parent 14346303d7
commit 5f0dd44b3b
11 changed files with 62 additions and 45 deletions

View File

@@ -693,6 +693,12 @@ impl Pat {
}
}
impl From<P<Pat>> for Pat {
fn from(value: P<Pat>) -> Self {
*value
}
}
/// A single field in a struct pattern.
///
/// Patterns like the fields of `Foo { x, ref y, ref mut z }`
@@ -1522,17 +1528,23 @@ impl Expr {
)
}
/// Creates a dummy `P<Expr>`.
/// Creates a dummy `Expr`.
///
/// Should only be used when it will be replaced afterwards or as a return value when an error was encountered.
pub fn dummy() -> P<Expr> {
P(Expr {
pub fn dummy() -> Expr {
Expr {
id: DUMMY_NODE_ID,
kind: ExprKind::Dummy,
span: DUMMY_SP,
attrs: ThinVec::new(),
tokens: None,
})
}
}
}
impl From<P<Expr>> for Expr {
fn from(value: P<Expr>) -> Self {
*value
}
}
@@ -2343,6 +2355,12 @@ impl Clone for Ty {
}
}
impl From<P<Ty>> for Ty {
fn from(value: P<Ty>) -> Self {
*value
}
}
impl Ty {
pub fn peel_refs(&self) -> &Self {
let mut final_ty = self;