1
Fork 0

Implement .use keyword as an alias of clone

This commit is contained in:
Santiago Pastorino 2024-10-02 16:35:37 -03:00
parent 0cf8dbc96c
commit 05c516446a
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
36 changed files with 247 additions and 24 deletions

View file

@ -312,6 +312,14 @@ pub enum ExprKind<'tcx> {
/// (e.g. `foo(a, b)` in `x.foo(a, b)`).
fn_span: Span,
},
/// A use expression `x.use`.
ByUse {
/// The expression on which use is applied.
expr: ExprId,
/// The span of use, without the dot and receiver
/// (e.g. `use` in `x.use`).
span: Span,
},
/// A *non-overloaded* dereference.
Deref {
arg: ExprId,

View file

@ -59,6 +59,9 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
visitor.visit_expr(&visitor.thir()[arg]);
}
}
ByUse { expr, span: _ } => {
visitor.visit_expr(&visitor.thir()[expr]);
}
Deref { arg } => visitor.visit_expr(&visitor.thir()[arg]),
Binary { lhs, rhs, op: _ } | LogicalOp { lhs, rhs, op: _ } => {
visitor.visit_expr(&visitor.thir()[lhs]);