about summary refs log tree commit diff
path: root/src/librustc_ast_pretty/pprust.rs
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-2862/+0
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-10/+10
2020-08-06rustc_ast/comments: Modernize some enum reexportsVadim Petrochenkov-12/+13
2020-08-06rustc_ast: Stop using "string typing" for doc comment tokensVadim Petrochenkov-6/+21
Explicitly store their kind and style retrieved during lexing in the token
2020-08-02pprust: adjust mixed comment printingDavid Wood-1/+3
This commit adjusts the pretty printing of mixed comments so that the initial zero-break isn't emitted at the beginning of the line. Through this, the `block-comment-wchar` test can have the `pp-exact` file removed, as it no longer converges from pretty printing of the source. Signed-off-by: David Wood <david@davidtw.co>
2020-07-15Auto merge of #74175 - nnethercote:more-static-symbols, r=oli-obkbors-5/+9
More static symbols These commits add some more static symbols and convert lots of places to use them. r? @oli-obk
2020-07-15Remove lots of `Symbol::as_str()` calls.Nicholas Nethercote-5/+9
In various ways, such as changing functions to take a `Symbol` instead of a `&str`.
2020-07-12pprust: support multiline comments within linesDavid Wood-2/+13
This commit adds support to rustc_ast_pretty for multiline comments that start and end within a line of source code. Signed-off-by: David Wood <david@davidtw.co>
2020-07-02Auto merge of #73954 - Manishearth:rollup-8qvh170, r=Manishearthbors-19/+19
Rollup of 10 pull requests Successful merges: - #73414 (Implement `slice_strip` feature) - #73564 (linker: Create GNU_EH_FRAME header by default when producing ELFs) - #73622 (Deny unsafe ops in unsafe fns in libcore) - #73684 (add spans to injected coverage counters, extract with CoverageData query) - #73812 (ast_pretty: Pass some token streams and trees by reference) - #73853 (Add newline to rustc MultiSpan docs) - #73883 (Compile rustdoc less often.) - #73885 (Fix wasm32 being broken due to a NodeJS version bump) - #73903 (Changes required for rustc/cargo to build for iOS targets) - #73938 (Optimise fast path of checked_ops with `unlikely`) Failed merges: r? @ghost
2020-07-01Rollup merge of #73569 - Aaron1011:fix/macro-rules-group, r=petrochenkovManish Goregaokar-1/+1
Handle `macro_rules!` tokens consistently across crates When we serialize a `macro_rules!` macro, we used a 'lowered' `TokenStream` for its body, which has all `Nonterminal`s expanded in-place via `nt_to_tokenstream`. This matters when an 'outer' `macro_rules!` macro expands to an 'inner' `macro_rules!` macro - the inner macro may use tokens captured from the 'outer' macro in its definition. This means that invoking a foreign `macro_rules!` macro may use a different body `TokenStream` than when the same `macro_rules!` macro is invoked in the same crate. This difference is observable by proc-macros invoked by a `macro_rules!` macro - a `None`-delimited group will be seen in the same-crate case (inserted when convering `Nonterminal`s to the `proc_macro` crate's structs), but no `None`-delimited group in the cross-crate case. To fix this inconsistency, we now insert `None`-delimited groups when 'lowering' a `Nonterminal` `macro_rules!` body, just as we do in `proc_macro_server`. Additionally, we no longer print extra spaces for `None`-delimited groups - as far as pretty-printing is concerned, they don't exist (only their contents do). This ensures that `Display` output of a `TokenStream` does not depend on which crate a `macro_rules!` macro was invoked from. This PR is necessary in order to patch the `solana-genesis-programs` for the upcoming hygiene serialization breakage (https://github.com/rust-lang/rust/pull/72121#issuecomment-646924847). The `solana-genesis-programs` crate will need to use a proc macro to re-span certain tokens in a nested `macro_rules!`, which requires us to consistently use a `None`-delimited group. See `src/test/ui/proc-macro/nested-macro-rules.rs` for an example of the kind of nested `macro_rules!` affected by this crate.
2020-07-01Don't print additional spaces when pretty-printing NoDelim groupsAaron Hill-1/+1
2020-07-01Remove `token::FlattenGroup`Vadim Petrochenkov-1/+1
2020-07-01expand: Stop using nonterminals for passing tokens to attribute and derive ↵Vadim Petrochenkov-3/+15
macros
2020-06-27ast_pretty: Pass some token streams and trees by referenceVadim Petrochenkov-19/+19
2020-06-26Rollup merge of #73597 - ayazhafiz:i/const-span, r=ecstatic-morseManish Goregaokar-1/+1
Record span of `const` kw in GenericParamKind Context: this is needed for a fix of https://github.com/rust-lang/rustfmt/issues/4263, which currently records the span of a const generic param incorrectly because the location of the `const` kw is not known. I am not sure how to add tests for this; any guidance in how to do so would be appreciated :slightly_smiling_face:
2020-06-26proc_macro: Stop flattening groups with dummy spansVadim Petrochenkov-1/+1
2020-06-23Record span of `const` kw in GenericParamKindAyaz Hafiz-1/+1
Context: this is needed to fix https://github.com/rust-lang/rustfmt/issues/4263, which currently records the span of a const generic param incorrectly because the location of the `const` kw is not known. I am not sure how to add tests for this; any guidance in how to do so would be appreciated :slightly_smiling_face:
2020-06-11Rollup merge of #73182 - Aaron1011:feature/call-fn-span, r=matthewjasperDylan DPC-1/+1
Track span of function in method calls, and use this in #[track_caller] Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-10Track span of function in method calls, and use this in #[track_caller]Aaron Hill-1/+1
Fixes #69977 When we parse a chain of method calls like `foo.a().b().c()`, each `MethodCallExpr` gets assigned a span that starts at the beginning of the call chain (`foo`). While this is useful for diagnostics, it means that `Location::caller` will return the same location for every call in a call chain. This PR makes us separately record the span of the function name and arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This `Span` is passed through HIR lowering and MIR building to `TerminatorKind::Call`, where it is used in preference to `Terminator.source_info.span` when determining `Location::caller`. This new span is also useful for diagnostics where we want to emphasize a particular method call - for an example, see https://github.com/rust-lang/rust/pull/72389#discussion_r436035990
2020-06-08Don't lose empty `where` clause when pretty-printingAaron Hill-2/+6
Previously, we would parse `struct Foo where;` and `struct Foo;` identically, leading to an 'empty' `where` clause being omitted during pretty printing. This will cause us to lose spans when proc-macros involved, since we will have a collected `where` token that does not appear in the pretty-printed item. We now explicitly track the presence of a `where` token during parsing, so that we can distinguish between `struct Foo where;` and `struct Foo;` during pretty-printing
2020-05-18Move InlineAsmTemplatePiece and InlineAsmOptions to librustc_astAmanieu d'Antras-1/+1
2020-05-18Implement att_syntax optionAmanieu d'Antras-0/+3
2020-05-18Add asm! to ASTAmanieu d'Antras-0/+112
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-17/+17
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-2/+3
2020-04-06Rollup merge of #70519 - estebank:constraints-before-args-spans, r=CentrilMazdak Farrokhzad-2/+2
Tweak output of type params and constraints in the wrong order r? @Centril @varkor
2020-03-30Use if let instead of match when only matching a single variant ↵Matthias Krüger-19/+12
(clippy::single_match) Makes code more compact and reduces nestig.
2020-03-29Suggest correct order for arguments when encountering early constraintsEsteban Küber-2/+2
When encountering constraints before type arguments or lifetimes, suggest the correct order.
2020-03-27parse: move constraint/arg restriction to ast_validation.Mazdak Farrokhzad-24/+17
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-3/+3
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-17Don't prepend with space before parenGuillaume Gomez-4/+14
2020-03-16ast/hir: `MacroDef::legacy` -> `MacroDef::macro_rules`Vadim Petrochenkov-1/+1
2020-03-15Rollup merge of #69589 - petrochenkov:maccall, r=CentrilMazdak Farrokhzad-8/+8
ast: `Mac`/`Macro` -> `MacCall` It's now obvious that these refer to macro calls rather than to macro definitions. It's also a single name instead of two different names in different places. `rustc_expand` usually calls macro calls in a wide sense (including attributes and derives) "macro invocations", but structures and variants renamed in this PR are only relevant to fn-like macros, so it's simpler and clearer to just call them calls. cc https://github.com/rust-lang/rust/pull/63586#discussion_r314232513 r? @eddyb
2020-03-12ast: `Mac`/`Macro` -> `MacCall`Vadim Petrochenkov-8/+8
2020-03-12Rollup merge of #69722 - estebank:negative-impl-span-ast, r=CentrilMazdak Farrokhzad-1/+1
Tweak output for invalid negative impl AST errors Use more accurate spans for negative `impl` errors. r? @Centril
2020-03-06Auto merge of #69586 - petrochenkov:unmerge, r=Centrilbors-18/+24
ast: Unmerge structures for associated items and foreign items Follow-up to https://github.com/rust-lang/rust/pull/69194. r? @Centril
2020-03-04Tweak output for invalid negative impl AST errorsEsteban Küber-1/+1
2020-03-01encode `;` stmt w/o expr as `StmtKind::Empty`Mazdak Farrokhzad-13/+7
2020-03-01ast: Unmerge structures for associated items and foreign itemsVadim Petrochenkov-18/+24
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-9/+9
2020-02-28use is_empty() instead of len() == x to determine if structs are empty.Matthias Krüger-1/+1
2020-02-26Rollup merge of #69423 - petrochenkov:nont, r=CentrilDylan DPC-11/+0
syntax: Remove `Nt(Impl,Trait,Foreign)Item` Follow-up to https://github.com/rust-lang/rust/pull/69366. r? @Centril
2020-02-26Rollup merge of #69387 - petrochenkov:idprint, r=Mark-SimulacrumDylan DPC-38/+4
Deduplicate identifier printing a bit https://github.com/rust-lang/rust/pull/67010 introduced a couple more subtly different ways to print an identifier. This PR attempts to restore the order. The most basic identifier printing interface is `Formatter`-based now, so `String`s are not allocated unless required. r? @Mark-Simulacrum
2020-02-24syntax: Remove `Nt(Impl,Trait,Foreign)Item`Vadim Petrochenkov-11/+0
2020-02-24parse/ast: move `Defaultness` into variants.Mazdak Farrokhzad-17/+14
2020-02-24ast: add `Defaultness` to `Item`, making `AssocItem` an alias.Mazdak Farrokhzad-2/+2
2020-02-24add `Span` to `ast::Defaultness::Default`.Mazdak Farrokhzad-1/+1
2020-02-23Deduplicate identifier printing a bitVadim Petrochenkov-38/+4
2020-02-23Rollup merge of #69375 - Menschenkindlein:master, r=Dylan-DPCDylan DPC-10/+10
Rename CodeMap to SourceMap follow up See https://github.com/rust-lang/rust/issues/51574
2020-02-22Rename CodeMap to SourceMap follow upMaxim Zholobak-10/+10