diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-06-17 23:19:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-17 23:19:34 +0200 |
| commit | e95fb09dfbd9d25f0a12e7ea84fdf3a896533d54 (patch) | |
| tree | 035b55bba8c925a0dc90168973c09f4d6a0e9794 /compiler/rustc_ast/src/ast.rs | |
| parent | 0772ee7f8b2b4acac1f6e82b0f65a78b38817502 (diff) | |
| parent | 5f0dd44b3b1b142582d3dc8264cb2b8dd8f7c7f0 (diff) | |
| download | rust-e95fb09dfbd9d25f0a12e7ea84fdf3a896533d54.tar.gz rust-e95fb09dfbd9d25f0a12e7ea84fdf3a896533d54.zip | |
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
Diffstat (limited to 'compiler/rustc_ast/src/ast.rs')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 4489a424c0d..11afd359e5a 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -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; |
