diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-09-17 17:28:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-17 17:28:33 +0200 |
| commit | c896f06bdb4e4773560ec44ab48668d4b152f659 (patch) | |
| tree | 87e7219ffb21f9cef595f47497957e163eee9c00 | |
| parent | 62f2ec9b59792126c813a46280228436a4f3aa35 (diff) | |
| parent | c16a90479a9fcf9884a90b69f498f2900ea2519d (diff) | |
| download | rust-c896f06bdb4e4773560ec44ab48668d4b152f659.tar.gz rust-c896f06bdb4e4773560ec44ab48668d4b152f659.zip | |
Rollup merge of #130314 - compiler-errors:mac-prec, r=davidtwco
Use the same precedence for all macro-like exprs No need to make these have a different precedence since they're all written like `whatever!(expr)`, and it makes it simpler when adding new macro-based built-in operators in the future.
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/util/parser.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 7 |
3 files changed, 10 insertions, 14 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index f433f2eca1a..ac65b7b22bc 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1293,7 +1293,7 @@ impl Expr { ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node), ExprKind::Unary(..) => ExprPrecedence::Unary, ExprKind::Lit(_) | ExprKind::IncludedBytes(..) => ExprPrecedence::Lit, - ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast, + ExprKind::Cast(..) => ExprPrecedence::Cast, ExprKind::Let(..) => ExprPrecedence::Let, ExprKind::If(..) => ExprPrecedence::If, ExprKind::While(..) => ExprPrecedence::While, @@ -1317,17 +1317,18 @@ impl Expr { ExprKind::Break(..) => ExprPrecedence::Break, ExprKind::Continue(..) => ExprPrecedence::Continue, ExprKind::Ret(..) => ExprPrecedence::Ret, - ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm, - ExprKind::OffsetOf(..) => ExprPrecedence::OffsetOf, - ExprKind::MacCall(..) => ExprPrecedence::Mac, ExprKind::Struct(..) => ExprPrecedence::Struct, ExprKind::Repeat(..) => ExprPrecedence::Repeat, ExprKind::Paren(..) => ExprPrecedence::Paren, ExprKind::Try(..) => ExprPrecedence::Try, ExprKind::Yield(..) => ExprPrecedence::Yield, ExprKind::Yeet(..) => ExprPrecedence::Yeet, - ExprKind::FormatArgs(..) => ExprPrecedence::FormatArgs, ExprKind::Become(..) => ExprPrecedence::Become, + ExprKind::InlineAsm(..) + | ExprKind::Type(..) + | ExprKind::OffsetOf(..) + | ExprKind::FormatArgs(..) + | ExprKind::MacCall(..) => ExprPrecedence::Mac, ExprKind::Err(_) | ExprKind::Dummy => ExprPrecedence::Err, } } diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 8436c760d16..d8dad4550c0 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -265,10 +265,7 @@ pub enum ExprPrecedence { Field, Index, Try, - InlineAsm, - OffsetOf, Mac, - FormatArgs, Array, Repeat, @@ -333,17 +330,14 @@ impl ExprPrecedence { | ExprPrecedence::ConstBlock | ExprPrecedence::Field | ExprPrecedence::ForLoop - | ExprPrecedence::FormatArgs | ExprPrecedence::Gen | ExprPrecedence::If | ExprPrecedence::Index - | ExprPrecedence::InlineAsm | ExprPrecedence::Lit | ExprPrecedence::Loop | ExprPrecedence::Mac | ExprPrecedence::Match | ExprPrecedence::MethodCall - | ExprPrecedence::OffsetOf | ExprPrecedence::Paren | ExprPrecedence::Path | ExprPrecedence::PostfixMatch diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index ee03f780e16..26118bcbb9f 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1726,7 +1726,7 @@ impl Expr<'_> { ExprKind::Binary(op, ..) => ExprPrecedence::Binary(op.node), ExprKind::Unary(..) => ExprPrecedence::Unary, ExprKind::Lit(_) => ExprPrecedence::Lit, - ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast, + ExprKind::Cast(..) => ExprPrecedence::Cast, ExprKind::DropTemps(ref expr, ..) => expr.precedence(), ExprKind::If(..) => ExprPrecedence::If, ExprKind::Let(..) => ExprPrecedence::Let, @@ -1744,11 +1744,12 @@ impl Expr<'_> { ExprKind::Continue(..) => ExprPrecedence::Continue, ExprKind::Ret(..) => ExprPrecedence::Ret, ExprKind::Become(..) => ExprPrecedence::Become, - ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm, - ExprKind::OffsetOf(..) => ExprPrecedence::OffsetOf, ExprKind::Struct(..) => ExprPrecedence::Struct, ExprKind::Repeat(..) => ExprPrecedence::Repeat, ExprKind::Yield(..) => ExprPrecedence::Yield, + ExprKind::Type(..) | ExprKind::InlineAsm(..) | ExprKind::OffsetOf(..) => { + ExprPrecedence::Mac + } ExprKind::Err(_) => ExprPrecedence::Err, } } |
