about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
AgeCommit message (Collapse)AuthorLines
2021-03-07Account for `if (let pat = expr) {}`Esteban Küber-0/+8
Partially address #82827.
2021-03-06rustc_ast: Replace `AstLike::finalize_tokens` with a getter `tokens_mut`Vadim Petrochenkov-64/+34
2021-03-06Change x64 size checks to not apply to x32.Harald van Dijk-7/+7
Rust contains various size checks conditional on target_arch = "x86_64", but these checks were never intended to apply to x86_64-unknown-linux-gnux32. Add target_pointer_width = "64" to the conditions.
2021-03-01Rename rustdoc lints to be a tool lint instead of built-in.Joshua Nelson-1/+1
- Rename `broken_intra_doc_links` to `rustdoc::broken_intra_doc_links` - Ensure that the old lint names still work and give deprecation errors - Register lints even when running doctests Otherwise, all `rustdoc::` lints would be ignored. - Register all existing lints as removed This unfortunately doesn't work with `register_renamed` because tool lints have not yet been registered when rustc is running. For similar reasons, `check_backwards_compat` doesn't work either. Call `register_removed` directly instead. - Fix fallout + Rustdoc lints for compiler/ + Rustdoc lints for library/ Note that this does *not* suggest `rustdoc::broken_intra_doc_links` for `rustdoc::intra_doc_link_resolution_failure`, since there was no time when the latter was valid.
2021-02-27Combine HasAttrs and HasTokens into AstLikeAaron Hill-184/+224
When token-based attribute handling is implemeneted in #80689, we will need to access tokens from `HasAttrs` (to perform cfg-stripping), and we will to access attributes from `HasTokens` (to construct a `PreexpTokenStream`). This PR merges the `HasAttrs` and `HasTokens` traits into a new `AstLike` trait. The previous `HasAttrs` impls from `Vec<Attribute>` and `AttrVec` are removed - they aren't attribute targets, so the impls never really made sense.
2021-02-25Rollup merge of #82321 - bugadani:ast3, r=varkorDylan DPC-2/+2
AST: Remove some unnecessary boxes
2021-02-21New pass to deduplicate blocksSimon Vandel Sillesen-2/+2
2021-02-20Remove some P-sDániel Buga-2/+2
2021-02-18ast: Keep expansion status for out-of-line module itemsVadim Petrochenkov-23/+35
Also remove `ast::Mod` which is mostly redundant now
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-27/+15
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-13Require passing an `AttrWrapper` to `collect_tokens_trailing_token`Aaron Hill-0/+15
This is a pure refactoring split out from #80689. It represents the most invasive part of that PR, requiring changes in every caller of `parse_outer_attributes` In order to eagerly expand `#[cfg]` attributes while preserving the original `TokenStream`, we need to know the range of tokens that corresponds to every attribute target. This is accomplished by making `parse_outer_attributes` return an opaque `AttrWrapper` struct. An `AttrWrapper` must be converted to a plain `AttrVec` by passing it to `collect_tokens_trailing_token`. This makes it difficult to accidentally construct an AST node with attributes without calling `collect_tokens_trailing_token`, since AST nodes store an `AttrVec`, not an `AttrWrapper`. As a result, we now call `collect_tokens_trailing_token` for attribute targets which only support inert attributes, such as generic arguments and struct fields. Currently, the constructed `LazyTokenStream` is simply discarded. Future PRs will record the token range corresponding to the attribute target, allowing those tokens to be removed from an enclosing `collect_tokens_trailing_token` call if necessary.
2021-02-11Auto merge of #80860 - camelid:nodeid-docs, r=sanxiynbors-4/+10
Document `NodeId`
2021-02-07Clarify docs for `DUMMY_NODE_ID`Camelid-3/+3
2021-02-04Rollup merge of #81645 - m-ou-se:panic-lint, r=estebank,flip1995Mara Bos-1/+1
Add lint for `panic!(123)` which is not accepted in Rust 2021. This extends the `panic_fmt` lint to warn for all cases where the first argument cannot be interpreted as a format string, as will happen in Rust 2021. It suggests to add `"{}",` to format the message as a string. In the case of `std::panic!()`, it also suggests the recently stabilized `std::panic::panic_any()` function as an alternative. It renames the lint to `non_fmt_panic` to match the lint naming guidelines. ![image](https://user-images.githubusercontent.com/783247/106520928-675ea680-64d5-11eb-81f7-d8fa48b93a0b.png) This is part of #80162. r? ```@estebank```
2021-02-04Stabilize feature(iterator_fold_self): Iterator::reduceMara Bos-1/+0
2021-02-03Make panic/assert calls in rustc compatible with Rust 2021.Mara Bos-1/+1
2021-02-02Let a portion of DefPathHash uniquely identify the DefPath's crate.Michael Woerister-36/+0
This allows to directly map from a DefPathHash to the crate it originates from, without constructing side tables to do that mapping. It also allows to reliably and cheaply check for DefPathHash collisions.
2021-02-01Assert the size of the refactored enumsDániel Buga-0/+10
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-53/+73
2021-01-22Refactor token collection to capture trailing token immediatelyAaron Hill-11/+0
2021-01-17Replace let Some(..) = with .is_some()wcampbell-1/+1
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2021-01-16Remove unnecessary manual shrink_to_fit callsDániel Buga-3/+0
2021-01-15Auto merge of #80993 - Aaron1011:collect-set-tokens, r=petrochenkovbors-10/+66
Set tokens on AST node in `collect_tokens` A new `HasTokens` trait is introduced, which is used to move logic from the callers of `collect_tokens` into the body of `collect_tokens`. In addition to reducing duplication, this paves the way for PR #80689, which needs to perform additional logic during token collection.
2021-01-13Set tokens on AST node in `collect_tokens`Aaron Hill-10/+66
A new `HasTokens` trait is introduced, which is used to move logic from the callers of `collect_tokens` into the body of `collect_tokens`. In addition to reducing duplication, this paves the way for PR #80689, which needs to perform additional logic during token collection.
2021-01-11Document `NodeId`Camelid-3/+9
2021-01-10Rework diagnostics for wrong number of generic argsPatryk Wychowaniec-2/+12
2021-01-09ast: Remove some indirection layers from values in key-value attributesVadim Petrochenkov-37/+31
2021-01-08Rollup merge of #80784 - petrochenkov:nontspan, r=Aaron1011Yuki Okushi-1/+1
rustc_parse: Better spans for synthesized token streams I think using the nonterminal span for synthesizing its tokens is a better approximation than using `DUMMY_SP` or the attribute span like #79472 did in `expand.rs`. r? `@Aaron1011`
2021-01-08Rollup merge of #80659 - pierwill:edit-tokenstream, r=davidtwcoYuki Okushi-16/+17
Edit rustc_ast::tokenstream docs Fix some punctuation and wording, and add intra-documentation links.
2021-01-07rustc_parse: Better spans for synthesized token streamsVadim Petrochenkov-1/+1
2021-01-03Edit rustc_ast::tokenstream docspierwill-16/+17
Fix some punctuation and wording, and add intra-documentation links.
2021-01-02reduce borrowing and (de)referencing around match patterns ↵Matthias Krüger-3/+3
(clippy::match_ref_pats)
2021-01-01first pass at default values for const genericsJulian Knodt-2/+10
- Adds optional default values to const generic parameters in the AST and HIR - Parses these optional default values - Adds a `const_generics_defaults` feature gate
2020-12-31Enable Pat2021 in edition 2021.Mara Bos-2/+1
2020-12-31Auto merge of #80459 - mark-i-m:or-pat-reg, r=petrochenkovbors-5/+30
Implement edition-based macro :pat feature This PR does two things: 1. Fixes the perf regression from https://github.com/rust-lang/rust/pull/80100#issuecomment-750893149 2. Implements `:pat2018` and `:pat2021` matchers, as described by `@joshtriplett` in https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090 behind the feature gate `edition_macro_pat`. r? `@petrochenkov` cc `@Mark-Simulacrum`
2020-12-30Rollup merge of #80128 - pierwill:pierwill-docs-fieldpat, r=jyn514Mara Bos-6/+6
Edit rustc_ast::ast::FieldPat docs Punctuation fixes.
2020-12-30Implement edition-based macro pat featuremark-5/+30
2020-12-30Auto merge of #80503 - JohnTitor:rollup-b26vglu, r=JohnTitorbors-10/+4
Rollup of 13 pull requests Successful merges: - #79812 (Lint on redundant trailing semicolon after item) - #80348 (remove redundant clones (clippy::redundant_clone)) - #80358 (Edit rustc_span documentation) - #80457 (Add missing commas to `rustc_ast_pretty::pp` docs) - #80461 (Add llvm-libunwind change to bootstrap CHANGELOG) - #80464 (Use Option::map_or instead of open coding it) - #80465 (Fix typo in ffi-pure.md) - #80467 (More uses of the matches! macro) - #80469 (Fix small typo in time comment) - #80472 (Use sans-serif font for the "all items" page links) - #80477 (Make forget intrinsic safe) - #80482 (don't clone copy types) - #80487 (don't redundantly repeat field names) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-29More uses of the matches! macroLingMan-10/+4
2020-12-29Remove pretty-print/reparse hack, and add derive-specific hackAaron Hill-0/+6
2020-12-28Rollup merge of #80344 - matthiaskrgr:matches, r=Dylan-DPCDylan DPC-87/+40
use matches!() macro in more places
2020-12-26stabilize min_const_genericsBastian Kauschke-1/+1
2020-12-24use matches!() macro in more placesMatthias Krüger-87/+40
2020-12-22Rework beautify_doc_string so that it returns a Symbol instead of a StringGuillaume Gomez-35/+37
2020-12-17docs: Edit rustc_ast::token::Tokenpierwill-1/+1
Add missing punctuation.
2020-12-17Edit rustc_ast::ast::FieldPat docspierwill-6/+6
Punctuation fixes.
2020-12-09Accept arbitrary expressions in key-value attributes at parse timeVadim Petrochenkov-30/+9
2020-12-01Add documentation for name_value_literal_span methodsGuillaume Gomez-0/+14
2020-12-01Improve some attributes error spansGuillaume Gomez-1/+3
2020-12-01Created NestedMetaItem::name_value_literal_span methodGuillaume Gomez-0/+15