mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
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.
This commit is contained in:
commit
6d133152f8
@ -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,
|
||||
};
|
||||
|
||||
|
@ -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(..)
|
||||
|
Loading…
Reference in New Issue
Block a user