diff options
| author | bors <bors@rust-lang.org> | 2023-01-26 12:44:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-01-26 12:44:47 +0000 |
| commit | 3e977638728922d3a6cc7bea34a2fdb8ae97f7c0 (patch) | |
| tree | ccf38bab26084eb37c133e60987ba7bd4318ec9b /src/tools/rustfmt | |
| parent | 40fda7b3fe2b10c6e1a0568b59516f5e7f381886 (diff) | |
| parent | db731e42b3c139587cd7a87acaa92cd82ab8a11c (diff) | |
| download | rust-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 'src/tools/rustfmt')
| -rw-r--r-- | src/tools/rustfmt/src/expr.rs | 5 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/utils.rs | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index 0be4c3cf168..3f0f217f890 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -400,7 +400,10 @@ pub(crate) fn format_expr( } } ast::ExprKind::Underscore => Some("_".to_owned()), - ast::ExprKind::IncludedBytes(..) => unreachable!(), + ast::ExprKind::FormatArgs(..) | ast::ExprKind::IncludedBytes(..) => { + // These do not occur in the AST because macros aren't expanded. + unreachable!() + } ast::ExprKind::Err => None, }; diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs index f681f55b37b..1e89f3ae75f 100644 --- a/src/tools/rustfmt/src/utils.rs +++ b/src/tools/rustfmt/src/utils.rs @@ -463,6 +463,7 @@ pub(crate) fn first_line_ends_with(s: &str, c: char) -> bool { pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr: &str) -> bool { match expr.kind { ast::ExprKind::MacCall(..) + | ast::ExprKind::FormatArgs(..) | ast::ExprKind::Call(..) | ast::ExprKind::MethodCall(..) | ast::ExprKind::Array(..) |
