Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ impl Expr {
// need parens sometimes. E.g. we can print `(let _ = a) && b` as `let _ = a && b`
// but we need to print `(let _ = a) < b` as-is with parens.
| ExprKind::Let(..)
| ExprKind::Move(..)
| ExprKind::Unary(..) => ExprPrecedence::Prefix,

// Need parens if and only if there are prefix attributes.
Expand Down Expand Up @@ -1763,6 +1764,8 @@ pub enum ExprKind {
Binary(BinOp, Box<Expr>, Box<Expr>),
/// A unary operation (e.g., `!x`, `*x`).
Unary(UnOp, Box<Expr>),
/// A `move(expr)` expression.
Move(Box<Expr>, Span),
/// A literal (e.g., `1`, `"foo"`).
Lit(token::Lit),
/// A cast (e.g., `foo as f64`).
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_ast/src/util/classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub fn leading_labeled_expr(mut expr: &ast::Expr) -> bool {
Assign(e, _, _)
| AssignOp(_, e, _)
| Await(e, _)
| Move(e, _)
| Use(e, _)
| Binary(_, e, _)
| Call(e, _)
Expand Down Expand Up @@ -183,6 +184,7 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<TrailingBrace<'_>> {
| Ret(Some(e))
| Unary(_, e)
| Yeet(Some(e))
| Move(e, _)
| Become(e) => {
expr = e;
}
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,9 @@ macro_rules! common_visitor_and_walkers {
visit_visitable!($($mut)? vis, block, opt_label),
ExprKind::Gen(capt, body, kind, decl_span) =>
visit_visitable!($($mut)? vis, capt, body, kind, decl_span),
ExprKind::Await(expr, span) | ExprKind::Use(expr, span) =>
ExprKind::Await(expr, span)
| ExprKind::Move(expr, span)
| ExprKind::Use(expr, span) =>
visit_visitable!($($mut)? vis, expr, span),
ExprKind::Assign(lhs, rhs, span) =>
visit_visitable!($($mut)? vis, lhs, rhs, span),
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ pub(crate) struct ClosureCannotBeStatic {
pub fn_decl_span: Span,
}

#[derive(Diagnostic)]
#[diag("`move(expr)` is only supported in plain closures")]
pub(crate) struct MoveExprOnlyInPlainClosures {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("functional record updates are not allowed in destructuring assignments")]
pub(crate) struct FunctionalRecordUpdateDestructuringAssignment {
Expand Down
Loading
Loading