about summary refs log tree commit diff
path: root/compiler/rustc_ast/src/util/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-01-26 12:44:47 +0000
committerbors <bors@rust-lang.org>2023-01-26 12:44:47 +0000
commit3e977638728922d3a6cc7bea34a2fdb8ae97f7c0 (patch)
treeccf38bab26084eb37c133e60987ba7bd4318ec9b /compiler/rustc_ast/src/util/parser.rs
parent40fda7b3fe2b10c6e1a0568b59516f5e7f381886 (diff)
parentdb731e42b3c139587cd7a87acaa92cd82ab8a11c (diff)
downloadrust-3e977638728922d3a6cc7bea34a2fdb8ae97f7c0.tar.gz
rust-3e977638728922d3a6cc7bea34a2fdb8ae97f7c0.zip
Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk
Move format_args!() into AST (and expand it during AST lowering)

Implements https://github.com/rust-lang/compiler-team/issues/541

This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier.

This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`.

This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
Diffstat (limited to 'compiler/rustc_ast/src/util/parser.rs')
-rw-r--r--compiler/rustc_ast/src/util/parser.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs
index 4f7099c7be8..81efdaa44b3 100644
--- a/compiler/rustc_ast/src/util/parser.rs
+++ b/compiler/rustc_ast/src/util/parser.rs
@@ -271,6 +271,7 @@ pub enum ExprPrecedence {
     Try,
     InlineAsm,
     Mac,
+    FormatArgs,
 
     Array,
     Repeat,
@@ -335,7 +336,8 @@ impl ExprPrecedence {
             | ExprPrecedence::Index
             | ExprPrecedence::Try
             | ExprPrecedence::InlineAsm
-            | ExprPrecedence::Mac => PREC_POSTFIX,
+            | ExprPrecedence::Mac
+            | ExprPrecedence::FormatArgs => PREC_POSTFIX,
 
             // Never need parens
             ExprPrecedence::Array