about summary refs log tree commit diff
path: root/compiler/rustc_ast_pretty/src
AgeCommit message (Collapse)AuthorLines
2021-12-29Rollup merge of #92372 - dtolnay:fntype, r=jackh726Matthias Krüger-4/+1
Print space after formal generic params in fn type Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($ty:ty) => { stringify!($ty) }; } fn main() { println!("{}", repro!(for<'a> fn(&'a u8))); } ``` Before:&ensp;`for<'a>fn(&'a u8)` After:&ensp;`for<'a> fn(&'a u8)` The pretty printer's `print_formal_generic_params` already prints formal generic params correctly with a space, we just need to call it when printing BareFn types instead of reimplementing the printing incorrectly without a space. https://github.com/rust-lang/rust/blob/83b15bfe1c15f325bc186ebfe3691b729ed59f2b/compiler/rustc_ast_pretty/src/pprust/state.rs#L1394-L1400
2021-12-29Rollup merge of #92371 - dtolnay:attrblock, r=oli-obkMatthias Krüger-11/+12
Remove pretty printer space inside block with only outer attrs Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($expr:expr) => { stringify!($expr) }; } fn main() { println!("{}", repro!(#[attr] {})); } ``` Before:&ensp;`#[attr] { }` After:&ensp;`#[attr] {}`
2021-12-28Print space after formal generic params in fn typeDavid Tolnay-4/+1
2021-12-28Remove pretty printer space inside block with only outer attrsDavid Tolnay-11/+12
2021-12-28Parse and suggest moving where clauses after equals for type aliasesJack Huey-28/+28
2021-12-27Remove &self from PrintState::to_stringDavid Tolnay-24/+24
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-10Rollup merge of #91625 - est31:remove_indexes, r=oli-obkMatthias Krüger-14/+14
Remove redundant [..]s
2021-12-09Remove redundant [..]sest31-14/+14
2021-12-08Pretty print break and continue without redundant spaceDavid Tolnay-5/+3
2021-12-07Remove unneeded access to pretty printer's `s` field in favor of derefDavid Tolnay-165/+165
2021-12-07Rollup merge of #91562 - dtolnay:asyncspace, r=Mark-SimulacrumMatthias Krüger-1/+0
Pretty print async block without redundant space **Repro:** ```rust macro_rules! m { ($e:expr) => { stringify!($e) }; } fn main() { println!("{:?}", m!(async {})); } ``` **Before:** <code>"async&nbsp;&nbsp;{}"</code> **After:** `"async {}"` <br> In this function: https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/pprust/state.rs#L2049-L2051 the `print_capture_clause` and `word_nbsp`/`word_space` calls already put a space after the `async` and `move` keywords being printed. The extra `self.s.space()` call removed by this PR resulted in the redundant double space. https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/pprust/state.rs#L2640-L2645 https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/helpers.rs#L34-L37 https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/helpers.rs#L5-L8
2021-12-05Delete duplicated helpers from HIR printerDavid Tolnay-33/+29
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-24remove cfg(bootstrap)Pietro Albini-1/+0
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.