summary refs log tree commit diff
path: root/compiler/rustc_hir_pretty/src
AgeCommit message (Collapse)AuthorLines
2022-09-08Introduce `DotDotPos`.Nicholas Nethercote-2/+3
This shrinks `hir::Pat` from 88 to 72 bytes.
2022-09-06Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillotbors-15/+9
`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-05Auto merge of #101261 - TaKO8Ki:separate-receiver-from-arguments-in-hir, ↵bors-7/+12
r=cjgillot Separate the receiver from arguments in HIR Related to #100232 cc `@cjgillot`
2022-09-05separate the receiver from arguments in HIRTakayuki Maeda-7/+12
2022-09-05Remove dead code from `print_generic_args`.Nicholas Nethercote-27/+7
2022-09-02Refactor and re-use BindingAnnotationCameron Steffen-15/+9
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-08-16Rename some things related to literals.Nicholas Nethercote-1/+1
- Rename `ast::Lit::token` as `ast::Lit::token_lit`, because its type is `token::Lit`, which is not a token. (This has been confusing me for a long time.) reasonable because we have an `ast::token::Lit` inside an `ast::Lit`. - Rename `LitKind::{from,to}_lit_token` as `LitKind::{from,to}_token_lit`, to match the above change and `token::Lit`.
2022-08-15Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillotbors-28/+32
Visit attributes in more places. This adds 3 loosely related changes (I can split PRs if desired): - Attribute checking on pattern struct fields. - Attribute checking on struct expression fields. - Lint level visiting on pattern struct fields, struct expression fields, and generic parameters. There are still some lints which ignore lint levels in various positions. This is a consequence of how the lints themselves are implemented. For example, lint levels on associated consts don't work with `unused_braces`.
2022-08-11Check attributes on struct expression fields.Eric Huss-14/+16
Attributes on struct expression fields were not being checked for validity. This adds the fields as HIR nodes so that `CheckAttrVisitor` can visit those nodes to check their attributes.
2022-08-11Check attributes on pattern fields.Eric Huss-14/+16
Attributes on pattern struct fields were not being checked for validity. This adds the fields as HIR nodes so that the `CheckAttrVisitor` can visit those nodes to check their attributes.
2022-08-12Fix HIR pretty printing of let elseMichael Goulet-0/+4
2022-07-17use rustc_hir_pretty::qpath_to_string to avoid span_to_snippet when ↵Michael Goulet-0/+4
rendering path
2022-07-14Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillotDylan DPC-3/+41
Implement `for<>` lifetime binder for closures This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following: ```rust let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) }; // ^^^^^^^^^^^--- new! ``` cc ``@Aaron1011`` ``@cjgillot``
2022-07-12Add an indirection for closures in `hir::ExprKind`Maybe Waffle-3/+3
This helps bring `hir::Expr` size down, `Closure` was the biggest variant, especially after `for<>` additions.
2022-07-12Lower closure binders to hir & properly check themMaybe Waffle-1/+39
2022-07-11move else block into the `Local` structDing Xiang Fei-3/+3
2022-07-11lower let-else in MIR insteadDing Xiang Fei-5/+17
2022-07-03clean up the borrowing in rustc_hir_prettyKaDiWa-281/+264
a lot of the `&`s and `ref`s were redundant
2022-07-01Factor out hir::Node::BindingCameron Steffen-1/+1
2022-06-21Use CreateParameter mode for closures too.Camille GILLOT-0/+2
2022-06-12Make `ExprKind::Closure` a struct variant.Camille GILLOT-3/+11
2022-06-04Compute lifetimes in scope at diagnostic time.Camille GILLOT-15/+20
2022-05-09use hir::Let in hir::GuardSparrowLii-7/+2
2022-04-30Store all generic bounds as where predicates.Camille GILLOT-14/+1
2022-04-30Inline WhereClause into Generics.Camille GILLOT-17/+13
2022-04-30Box HIR Generics and Impl.Camille GILLOT-4/+4
2022-04-23Stop pretty-printing HIR visibility.Camille GILLOT-79/+27
2022-04-23Stop visiting visibility.Camille GILLOT-1/+0
2022-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-3/+8
global_asm!
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-1/+1
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-09Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakisYuki Okushi-1/+0
Remove defaultness from ImplItem. This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-03Change pp indent to signed to allow negative indentsDavid Tolnay-1/+1
2022-02-03Remove defaultness from ImplItem.Camille GILLOT-1/+0
2022-01-27try apply `rustc_pass_by_value` to `Span`lcnr-1/+1
2022-01-21Remove a span from hir::ExprKind::MethodCallCameron Steffen-1/+1
2022-01-17Use Term in ProjectionPredicatekadmin-7/+6
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.
2022-01-17add eq constraints on associated constantskadmin-0/+4
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-61/+0
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-17Rollup merge of #92921 - dtolnay:printernew, r=wesleywiserMatthias Krüger-2/+2
Rename Printer constructor from mk_printer() to Printer::new() The original naming is left over from 2011 which was before impl blocks and associated functions existed. https://github.com/rust-lang/rust/blob/21313d623a505086b2973f30c19db4f1d6ec8f61/src/comp/pretty/pp.rs
2022-01-16Rollup merge of #92487 - dtolnay:traitalias, r=matthewjasperMatthias Krüger-3/+3
Fix unclosed boxes in pretty printing of TraitAlias This was causing trait aliases to not even render at all in stringified / pretty printed output. ```rust macro_rules! repro { ($item:item) => { stringify!($item) }; } fn main() { println!("{:?}", repro!(pub trait Trait<T> = Sized where T: 'a;)); } ``` Before:&ensp;`""` After:&ensp;`"pub trait Trait<T> = Sized where T: 'a;"` The fix is copied from how `head`/`end` for `ItemKind::Use`, `ItemKind::ExternCrate`, and `ItemKind::Mod` are all done in the pretty printer: https://github.com/rust-lang/rust/blob/dd3ac41495e85a9b7b5cb3186379d02ce17e51fe/compiler/rustc_ast_pretty/src/pprust/state.rs#L1178-L1184
2022-01-14Rename Printer constructor from mk_printer() to Printer::new()David Tolnay-2/+2
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-61/+0
2022-01-04Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwUMatthias Krüger-3/+10
Allow `_` as the length of array types and repeat expressions r? `@BoxyUwU` cc `@varkor`
2022-01-03Rollup merge of #92418 - dtolnay:emptystructpat, r=michaelwoeristerMatthias Krüger-2/+8
Fix spacing in pretty printed PatKind::Struct with no fields Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($pat:pat) => { stringify!($pat) }; } fn main() { println!("{}", repro!(Struct {})); } ``` Before:&ensp;<code>Struct&nbsp;{&nbsp;&nbsp;}</code> After:&ensp;<code>Struct&nbsp;{}</code>
2022-01-01Fix unclosed boxes in pretty printing of TraitAliasDavid Tolnay-3/+3
2021-12-29Fix whitespace in pretty printed PatKind::RangeDavid Tolnay-1/+0
2021-12-29Fix spacing in pretty printed PatKind::Struct with no fieldsDavid Tolnay-2/+8
2021-12-28Print space after formal generic params in fn typeDavid Tolnay-4/+1
2021-12-23implement `generic_arg_infer` for array lengthslcnr-3/+10