Rollup merge of #142371 - fee1-dead-contrib:push-xqlkumzurkus, r=petrochenkov

avoid `&mut P<T>` in `visit_expr` etc methods

trying a different way than rust-lang/rust#141636
r? ghost
This commit is contained in:
Jacob Pratt
2025-06-17 23:19:34 +02:00
committed by GitHub
11 changed files with 62 additions and 45 deletions

View File

@@ -710,6 +710,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 }`
@@ -1553,17 +1559,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
}
}
@@ -2374,6 +2386,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;