about summary refs log tree commit diff
path: root/compiler/rustc_ast_pretty
AgeCommit message (Collapse)AuthorLines
2023-03-28Add `(..)` syntax for RTNMichael Goulet-0/+4
2023-03-19Remove the `NodeId` of `ast::ExprKind::Async`Arpad Borsos-1/+1
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-4/+0
2023-03-02Force parentheses around `match` expression in binary expressionbwmf2-0/+4
2023-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-2/+5
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.
2023-02-21Use `ThinVec` in `ast::WhereClause`.Nicholas Nethercote-1/+1
2023-02-21Use `ThinVec` in `ast::Generics` and related types.Nicholas Nethercote-4/+4
2023-02-07Expand const-if-const trait bounds correctlyMichael Goulet-2/+12
2023-02-06remove unused importsklensy-1/+0
2023-02-02Rename `rust_2015` => `is_rust_2015`Maybe Waffle-1/+1
2023-01-31Use `Edition` methods a bit moreMaybe Waffle-1/+1
2023-01-27Replace format flags u32 by enums and bools.Mara Bos-14/+14
2023-01-26Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obkbors-1/+106
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.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-2/+2
2023-01-14Fix ast_pretty for format_args for {:x?} and {:X?}.Mara Bos-2/+2
They were accidentally swapped.
2023-01-12Add FIXME comments about asm and format_args ast_pretty.Mara Bos-0/+2
2023-01-12parse const closuresDeadbeef-0/+2
2023-01-12Expand format_args!() in rust_ast_lowering.Mara Bos-1/+104
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-10/+10
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-12-28Rename `Rptr` to `Ref` in AST and HIRNilstrieb-1/+1
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-12Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkovbors-2/+4
Remove `token::Lit` from `ast::MetaItemLit`. Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time. r? `@petrochenkov`
2022-12-06Remove outdated syntax from trait alias pretty printingMaybe Waffle-13/+2
2022-12-05Remove three uses of `LitKind::synthesize_token_lit`.Nicholas Nethercote-2/+3
2022-12-03Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514Matthias Krüger-15/+15
Remove useless borrows and derefs They are nothing more than noise. <sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
2022-12-03Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillotMatthias Krüger-0/+1
Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
2022-12-02Remove `token::Lit` from `ast::MetaItemLit`.Nicholas Nethercote-1/+1
`token::Lit` contains a `kind` field that indicates what kind of literal it is. `ast::MetaItemLit` currently wraps a `token::Lit` but also has its own `kind` field. This means that `ast::MetaItemLit` encodes the literal kind in two different ways. This commit changes `ast::MetaItemLit` so it no longer wraps `token::Lit`. It now contains the `symbol` and `suffix` fields from `token::Lit`, but not the `kind` field, eliminating the redundancy.
2022-12-02Add `StrStyle` to `ast::LitKind::ByteStr`.Nicholas Nethercote-1/+2
This is required to distinguish between cooked and raw byte string literals in an `ast::LitKind`, without referring to an adjacent `token::Lit`. It's a prerequisite for the next commit.
2022-12-02Rename `LitKind::to_token_lit` as `LitKind::synthesize_token_lit`.Nicholas Nethercote-1/+1
This makes it clearer that it's not a lossless conversion, which I find helpful.
2022-12-01Remove useless borrows and derefsMaybe Waffle-15/+15
2022-12-01rustc_ast_lowering: Stop lowering imports into multiple itemsVadim Petrochenkov-1/+1
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-12-01Auto merge of #104861 - nnethercote:attr-cleanups, r=petrochenkovbors-8/+11
Attribute cleanups Best reviewed one commit at a time. r? `@petrochenkov`
2022-11-29add `FIXME:` where it belongs Waffle Maybe-1/+1
suggestion from a friend!! 🐸 Co-authored-by: Michael Goulet <michael@errs.io>
2022-11-29`rustc_ast_pretty`: remove `ref` patternsMaybe Waffle-216/+214
2022-11-29Avoid more `MetaItem`-to-`Attribute` conversions.Nicholas Nethercote-8/+11
There is code for converting `Attribute` (syntactic) to `MetaItem` (semantic). There is also code for the reverse direction. The reverse direction isn't really necessary; it's currently only used when generating attributes, e.g. in `derive` code. This commit adds some new functions for creating `Attributes`s directly, without involving `MetaItem`s: `mk_attr_word`, `mk_attr_name_value_str`, `mk_attr_nested_word`, and `ExtCtxt::attr_{word,name_value_str,nested_word}`. These new methods replace the old functions for creating `Attribute`s: `mk_attr_inner`, `mk_attr_outer`, and `ExtCtxt::attribute`. Those functions took `MetaItem`s as input, and relied on many other functions that created `MetaItems`, which are also removed: `mk_name_value_item`, `mk_list_item`, `mk_word_item`, `mk_nested_word_item`, `{MetaItem,MetaItemKind,NestedMetaItem}::token_trees`, `MetaItemKind::attr_args`, `MetaItemLit::{from_lit_kind,to_token}`, `ExtCtxt::meta_word`. Overall this cuts more than 100 lines of code and makes thing simpler.
2022-11-28Keep track of the start of the argument block of a closureSarthak Singh-0/+1
2022-11-28Rename `NestedMetaItem::[Ll]iteral` as `NestedMetaItem::[Ll]it`.Nicholas Nethercote-1/+1
We already use a mix of `Literal` and `Lit`. The latter is better because it is shorter without causing any ambiguity.
2022-11-28Rename `ast::Lit` as `ast::MetaItemLit`.Nicholas Nethercote-6/+6
2022-11-28Remove `Lit::from_included_bytes`.Nicholas Nethercote-2/+2
`Lit::from_included_bytes` calls `Lit::from_lit_kind`, but the two call sites only need the resulting `token::Lit`, not the full `ast::Lit`. This commit changes those call sites to use `LitKind::to_token_lit`, which means `from_included_bytes` can be removed.
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-6/+6
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-1/+1
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-23/+17
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-8/+13
patterns.
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-6/+10
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
2022-11-11Introduce `ExprKind::IncludedBytes`clubby789-0/+4
2022-10-10Rename AssocItemKind::TyAlias to AssocItemKind::TypeMichael Goulet-1/+1
2022-09-29Remove from compiler/ cratesreez12g-1/+0
2022-09-14make `mk_attr_id` part of `ParseSess`SparrowLii-2/+4
2022-09-06Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillotbors-16/+10
`BindingAnnotation` refactor * `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`) * `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)` * Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}` One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`. I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
2022-09-03Fix global_asm macro pretty printingMichael Goulet-0/+2
2022-09-02Refactor and re-use BindingAnnotationCameron Steffen-16/+10