about summary refs log tree commit diff
path: root/compiler/rustc_ast_pretty/src/pprust
AgeCommit message (Collapse)AuthorLines
2021-12-05Pretty print async block without redundant spaceDavid Tolnay-1/+0
2021-12-05Rollup merge of #91437 - dtolnay:emptybrace, r=nagisaMatthias Krüger-24/+44
Pretty print empty blocks as {} **Example:** ```rust macro_rules! p { ($e:expr) => { println!("{}", stringify!($e)); }; ($i:item) => { println!("{}", stringify!($i)); }; } fn main() { p!(if true {}); p!(struct S {}); } ``` **Before:** ```console if true { } struct S { } ``` **After:** ```console if true {} struct S {} ``` This affects [`dbg!`](https://doc.rust-lang.org/std/macro.dbg.html), as well as ecosystem uses of stringify such as in [`anyhow::ensure!`](https://docs.rs/anyhow/1/anyhow/macro.ensure.html). Printing a `{ }` in today's heavily rustfmt'd world comes out looking jarring/sloppy.
2021-12-03Add initial AST and MIR support for unwinding from inline assemblyAmanieu d'Antras-0/+3
2021-12-01Pretty print empty blocks as {}David Tolnay-24/+44
2021-11-28expand: Turn `ast::Crate` into a first class expansion targetVadim Petrochenkov-0/+9
And stop creating a fake `mod` item for the crate root when expanding a crate.
2021-11-10Add support for specifying multiple clobber_abi in `asm!`asquared31415-2/+2
Allow multiple clobber_abi in asm Update docs Fix aarch64 test Combine abis Emit duplicate ABI error, empty ABI list error multiple clobber_abi
2021-11-07Auto merge of #90668 - matthiaskrgr:clippy_nov7, r=jyn514bors-5/+1
more clippy fixes
2021-11-07more clippy fixesMatthias Krüger-5/+1
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-17/+57
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-10-17Some "parenthesis" and "parentheses" fixesr00ster91-1/+1
2021-09-09Revert "Implement Anonymous{Struct, Union} in the AST"Felix S. Klock II-8/+0
This reverts commit 059b68dd677808e14e560802d235ad40beeba71e. Note that this was manually adjusted to retain some of the refactoring introduced by commit 059b68dd677808e14e560802d235ad40beeba71e, so that it could likewise retain the correction introduced in commit 5b4bc05fa57be19bb5962f4b7c0f165e194e3151
2021-09-09Revert "Fix ast expanded printing for anonymous types"Felix S. Klock II-6/+10
This reverts commit 5b4bc05fa57be19bb5962f4b7c0f165e194e3151.
2021-08-30Add let-else to ASTCameron Steffen-2/+8
2021-08-29Auto merge of #88262 - klensy:pprust-cow, r=nagisabors-48/+50
Cow'ify some pprust methods Reduce number of potential needless de/allocations by using `Cow<'static, str>` instead of explicit `String` type.
2021-08-28Treat macros as HIR itemsinquisitivecrystal-18/+30
2021-08-25Convert some functions to return Cow<'static,str> instead of String to ↵klensy-48/+50
reduce potential reallocations
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-17/+10
2021-08-12Add support for clobber_abi to asm!Amanieu d'Antras-0/+10
2021-07-25use vec![] macro to create Vector with first item inside instead of pushing ↵Matthias Krüger-2/+1
to an empty vec![] slightly reduces code bloat
2021-07-08Rework SESSION_GLOBALS API to prevent overwriting itGuillaume Gomez-3/+3
2021-07-03rustc_ast_pretty: Don't print space after `$`Noah Lev-3/+3
For example, this code: $arg:expr used to be pretty-printed as: $ arg : expr but is now pretty-printed as: $arg : expr
2021-06-29Rollup merge of #86358 - klensy:pp-loop, r=Mark-SimulacrumYuki Okushi-1/+0
fix pretty print for `loop`
2021-06-25Auto merge of #86599 - Amanieu:asm_raw, r=nagisabors-0/+3
Add a "raw" option for asm! which ignores format string specifiers This is useful when including raw assembly snippets using `include_str!`.
2021-06-24Add a "raw" option for asm! which ignores format string specifiersAmanieu d'Antras-0/+3
2021-06-23fix pretty print for `loop` in mir and hirklensy-1/+0
2021-06-22Auto merge of #85193 - pnkfelix:readd-support-for-inner-attrs-within-match, ↵bors-0/+5
r=nikomatsakis Re-add support for parsing (and pretty-printing) inner-attributes in match body Re-add support for parsing (and pretty-printing) inner-attributes within body of a `match`. In other words, we can do `match EXPR { #![inner_attr] ARM_1 ARM_2 ... }` again. I believe this unbreaks the only four crates that crater flagged as broken by PR #83312. (I am putting this up so that the lang-team can check it out and decide whether it changes their mind about what to do regarding PR #83312.)
2021-06-17Use `AttrVec` for `Arm`, `FieldDef`, and `Variant`Yuki Okushi-1/+1
2021-06-10Add support for using qualified paths with structs in expression and patternRyan Levick-6/+19
position.
2021-05-24Fix ast expanded printing for anonymous typesjedel1043-10/+6
2021-05-16Implement Anonymous{Struct, Union} in the ASTjedel1043-17/+33
Add unnamed_fields feature gate and gate unnamed fields on parsing
2021-05-15Remove some unncessary spaces from pretty-printed tokenstream outputAaron Hill-1/+4
In addition to making the output look nicer for all crates, this also aligns the pretty-printing output with what the `rental` crate expects. This will allow us to eventually disable a backwards-compat hack in a follow-up PR.
2021-05-13Add support for const operands and options to global_asm!Amanieu d'Antras-112/+113
On x86, the default syntax is also switched to Intel to match asm!
2021-05-11Re-add support for parsing (and pretty-printing) inner-attributes within ↵Felix S. Klock II-0/+5
body of a `match`. In other words, we can do `match EXPR { #![inner_attr] ARM_1 ARM_2 ... }` again. I believe this unbreaks the only four crates that crater flagged as broken by PR 83312. (I am putting this up so that the lang-team can check it out and decide whether it changes their mind about what to do regarding PR 83312.)
2021-05-03parser: Remove support for inner attributes on non-block expressionsVadim Petrochenkov-26/+9
2021-04-06Use AnonConst for asm! constantsAmanieu d'Antras-2/+2
2021-03-27Remove (lots of) dead codeJoshua Nelson-28/+0
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-23Update with commentskadmin-1/+0
2021-03-23Update with commentskadmin-3/+2
A bunch of nits fixed, and a new test for pretty printing the AST.
2021-03-23Some refactoringvarkor-0/+1
2021-03-23Add has_default to GenericParamDefKind::Constkadmin-0/+3
This currently creates a field which is always false on GenericParamDefKind for future use when consts are permitted to have defaults Update const_generics:default locations Previously just ignored them, now actually do something about them. Fix using type check instead of value Add parsing This adds all the necessary changes to lower const-generics defaults from parsing. Change P<Expr> to AnonConst This matches the arguments passed to instantiations of const generics, and makes it specific to just anonymous constants. Attempt to fix lowering bugs
2021-03-16ast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct`Vadim Petrochenkov-2/+2
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-1/+1
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-02-19Rollup merge of #82238 - petrochenkov:nocratemod, r=Aaron1011Dylan DPC-28/+25
ast: Keep expansion status for out-of-line module items I.e. whether a module `mod foo;` is already loaded from a file or not. This is a pre-requisite to correctly treating inner attributes on such modules (https://github.com/rust-lang/rust/issues/81661). With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`. Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level. Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`). `ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.
2021-02-18Rollup merge of #82066 - matthewjasper:trait-ref-fix, r=jackh726Dylan DPC-0/+1
Ensure valid TraitRefs are created for GATs This fixes `ProjectionTy::trait_ref` to use the correct substs. Places that need all of the substs have been updated to not use `trait_ref`. r? ````@jackh726````
2021-02-18ast: Keep expansion status for out-of-line module itemsVadim Petrochenkov-22/+20
Also remove `ast::Mod` which is mostly redundant now
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-9/+8
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
2021-02-16avoid full-slicing slicesMatthias Krüger-3/+3
If we already have a slice, there is no need to get another full-range slice from that, just use the original. clippy::redundant_slicing
2021-02-13Fix pretty printing of generic associated type constraintsMatthew Jasper-0/+1
2021-02-08Fix pretty printer macro_rules with semicolon.Eric Huss-0/+3
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-9/+15