summary refs log tree commit diff
path: root/compiler/rustc_hir_pretty/src
AgeCommit message (Collapse)AuthorLines
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
2021-12-17Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisabors-6/+10
Implement let-else type annotations natively Tracking issue: #87335 Fixes #89688, fixes #89807, edit: fixes #89960 as well As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved. This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically: * `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~ * It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that. * ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~ * ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~ * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~ Some other misc notes: * ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~ * in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.
2021-12-13Keep info on pre-desugaring expression for better "incorrect `.await`" ↵Esteban Kuber-1/+1
suggestion Keep the `HirId` of `.await`ed expressions so in the case of a `fn` call on on a sync `fn`, we can suggest maybe turning it into an `async fn`.
2021-12-13let-else: add hir::Let and type check it like a hir::LocalCormac Relf-6/+10
unify typeck of hir::Local and hir::Let remove extraneous pub(crate/super)
2021-12-10Rollup merge of #91625 - est31:remove_indexes, r=oli-obkMatthias Krüger-6/+6
Remove redundant [..]s
2021-12-09Remove redundant [..]sest31-6/+6
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-177/+177
2021-12-05Delete duplicated helpers from HIR printerDavid Tolnay-81/+1
2021-12-05Rollup merge of #91437 - dtolnay:emptybrace, r=nagisaMatthias Krüger-2/+2
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-2/+2
2021-10-18Auto merge of #89124 - cjgillot:owner-info, r=michaelwoeristerbors-9/+8
Index and hash HIR as part of lowering Part of https://github.com/rust-lang/rust/pull/88186 ~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~ Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner. r? `@michaelwoerister` cc `@petrochenkov`
2021-10-17Some "parenthesis" and "parentheses" fixesr00ster91-1/+1
2021-10-09Stop referring to hir::Crate in hir_pretty.Camille GILLOT-9/+8
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-13/+0
2021-09-11don't convert types into identical typesMatthias Krüger-1/+1
example: let x: String = String::new().into();
2021-09-07Don't move ?Trait bounds to param bounds if they're in where clausesjackh726-3/+0
2021-08-28Remove obsolete `MacroDef` variant of `OwnerNode`inquisitivecrystal-1/+0
2021-08-28Treat macros as HIR itemsinquisitivecrystal-0/+5
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-63/+61