Skip to content

Commit 6d13315

Browse files
committed
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 rust-lang/compiler-team#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.
2 parents 1d9afb2 + 80d196d commit 6d13315

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: src/expr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,10 @@ pub(crate) fn format_expr(
400400
}
401401
}
402402
ast::ExprKind::Underscore => Some("_".to_owned()),
403-
ast::ExprKind::IncludedBytes(..) => unreachable!(),
403+
ast::ExprKind::FormatArgs(..) | ast::ExprKind::IncludedBytes(..) => {
404+
// These do not occur in the AST because macros aren't expanded.
405+
unreachable!()
406+
}
404407
ast::ExprKind::Err => None,
405408
};
406409

Diff for: src/utils.rs

+1
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ pub(crate) fn first_line_ends_with(s: &str, c: char) -> bool {
463463
pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr: &str) -> bool {
464464
match expr.kind {
465465
ast::ExprKind::MacCall(..)
466+
| ast::ExprKind::FormatArgs(..)
466467
| ast::ExprKind::Call(..)
467468
| ast::ExprKind::MethodCall(..)
468469
| ast::ExprKind::Array(..)

0 commit comments

Comments
 (0)