about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
AgeCommit message (Collapse)AuthorLines
2022-12-18Make `#[custom_encodable]` an attribute for `newtype_index`Nilstrieb-1/+1
Makes the syntax a little more rusty.
2022-12-16Little fixesDeep Majumder-1/+1
2022-12-15more clippy::complexity fixesMatthias Krüger-7/+1
2022-12-14Allow .. to be parsed as let initializerDeep Majumder-0/+4
.. and ..= are valid expressions, however when used in a let statement it is not parsed.
2022-12-13Rollup merge of #105620 - TaKO8Ki:remove-unnecessary-uses-of-clone, ↵Matthias Krüger-1/+1
r=compiler-errors Remove unnecessary uses of `clone`
2022-12-13remove unnecessary uses of `clone`Takayuki Maeda-1/+1
2022-12-12Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkovbors-73/+111
Remove `token::Lit` from `ast::MetaItemLit`. Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time. r? `@petrochenkov`
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-3/+1
2022-12-05Remove `LitKind::synthesize_token_lit`.Nicholas Nethercote-39/+44
It has a single call site in the HIR pretty printer, where the resulting token lit is immediately converted to a string. This commit replaces `LitKind::synthesize_token_lit` with a `Display` impl for `LitKind`, which can be used by the HIR pretty printer.
2022-12-05Remove three uses of `LitKind::synthesize_token_lit`.Nicholas Nethercote-2/+3
2022-12-05Remove `ExtCtxt::expr_lit`.Nicholas Nethercote-11/+23
2022-12-05Remove `mk_name_value_item{,_str}`.Nicholas Nethercote-15/+0
There are better ways to create the meta items. - In the rustdoc tests, the commit adds `dummy_meta_item_name_value`, which matches the existing `dummy_meta_item_word` function and `dummy_meta_item_list` macro. - In `types.rs` the commit clones the existing meta item and then modifies the clone.
2022-12-04Rollup merge of #105142 - nbdd0121:inline_const, r=petrochenkovMatthias Krüger-0/+1
Make inline const block `ExprWithBlock` Fix https://github.com/rust-lang/rust/pull/104087#issuecomment-1324190817 `@rustbot` label: +T-lang +F-inline_const
2022-12-03Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514Matthias Krüger-19/+18
Remove useless borrows and derefs They are nothing more than noise. <sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
2022-12-03Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillotMatthias Krüger-1/+5
Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
2022-12-02Reorder `StrLit` fields.Nicholas Nethercote-4/+5
To better match `MetaItemLit`.
2022-12-02Remove `token::Lit` from `ast::MetaItemLit`.Nicholas Nethercote-6/+33
`token::Lit` contains a `kind` field that indicates what kind of literal it is. `ast::MetaItemLit` currently wraps a `token::Lit` but also has its own `kind` field. This means that `ast::MetaItemLit` encodes the literal kind in two different ways. This commit changes `ast::MetaItemLit` so it no longer wraps `token::Lit`. It now contains the `symbol` and `suffix` fields from `token::Lit`, but not the `kind` field, eliminating the redundancy.
2022-12-02Add `StrStyle` to `ast::LitKind::ByteStr`.Nicholas Nethercote-8/+15
This is required to distinguish between cooked and raw byte string literals in an `ast::LitKind`, without referring to an adjacent `token::Lit`. It's a prerequisite for the next commit.
2022-12-02Rename `LitKind::to_token_lit` as `LitKind::synthesize_token_lit`.Nicholas Nethercote-4/+4
This makes it clearer that it's not a lossless conversion, which I find helpful.
2022-12-01Make inline const block `ExprWithBlock`Gary Guo-0/+1
2022-12-01Remove useless borrows and derefsMaybe Waffle-19/+18
2022-12-01rustc_ast_lowering: Stop lowering imports into multiple itemsVadim Petrochenkov-12/+5
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-11-29Avoid more `MetaItem`-to-`Attribute` conversions.Nicholas Nethercote-124/+52
There is code for converting `Attribute` (syntactic) to `MetaItem` (semantic). There is also code for the reverse direction. The reverse direction isn't really necessary; it's currently only used when generating attributes, e.g. in `derive` code. This commit adds some new functions for creating `Attributes`s directly, without involving `MetaItem`s: `mk_attr_word`, `mk_attr_name_value_str`, `mk_attr_nested_word`, and `ExtCtxt::attr_{word,name_value_str,nested_word}`. These new methods replace the old functions for creating `Attribute`s: `mk_attr_inner`, `mk_attr_outer`, and `ExtCtxt::attribute`. Those functions took `MetaItem`s as input, and relied on many other functions that created `MetaItems`, which are also removed: `mk_name_value_item`, `mk_list_item`, `mk_word_item`, `mk_nested_word_item`, `{MetaItem,MetaItemKind,NestedMetaItem}::token_trees`, `MetaItemKind::attr_args`, `MetaItemLit::{from_lit_kind,to_token}`, `ExtCtxt::meta_word`. Overall this cuts more than 100 lines of code and makes thing simpler.
2022-11-29Inline and remove `MetaItemLit::from_lit_kind`.Nicholas Nethercote-9/+2
It has a single call site.
2022-11-29Reorder some types.Nicholas Nethercote-27/+27
So that `Attribute` and `MetaItem` are listed first, and then the component types are below them in a logical order.
2022-11-29Improve comments about attributes and meta items.Nicholas Nethercote-10/+14
I have found the distinction confusing.
2022-11-28Keep track of the start of the argument block of a closureSarthak Singh-1/+5
2022-11-28Rename `NestedMetaItem::[Ll]iteral` as `NestedMetaItem::[Ll]it`.Nicholas Nethercote-8/+8
We already use a mix of `Literal` and `Lit`. The latter is better because it is shorter without causing any ambiguity.
2022-11-28Adjust comments on `StrLit`.Nicholas Nethercote-2/+1
2022-11-28Rename `ast::Lit` as `ast::MetaItemLit`.Nicholas Nethercote-31/+32
2022-11-28Remove `Lit::from_included_bytes`.Nicholas Nethercote-8/+0
`Lit::from_included_bytes` calls `Lit::from_lit_kind`, but the two call sites only need the resulting `token::Lit`, not the full `ast::Lit`. This commit changes those call sites to use `LitKind::to_token_lit`, which means `from_included_bytes` can be removed.
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-31/+33
2022-11-26Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errorsGuillaume Gomez-2/+30
Use the power of adding helper function to simplify code w/ `Mutability` r? `@compiler-errors`
2022-11-23Add `Mutability::mutably_str`Maybe Waffle-0/+8
2022-11-23Don't accept `Mutability` by refMaybe Waffle-2/+2
2022-11-23Add `Mutability::{is_mut,is_not}`Maybe Waffle-0/+10
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-3/+4
2022-11-23Add `Mutability::ref_prefix_str`, order `Mutability`, simplify codeMaybe Waffle-1/+11
2022-11-23Fix an ICE parsing a malformed attribute.Nicholas Nethercote-3/+6
Fixes #104620.
2022-11-22Auto merge of #103578 - petrochenkov:nofict, r=nagisabors-1/+1
Unreserve braced enum variants in value namespace With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed. Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-90/+107
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-1/+1
2022-11-21Remove `ref` patterns from `rustc_ast`Maybe Waffle-224/+214
Also use if let chains in one case.
2022-11-17Use `ThinVec` in `ast::Path`.Nicholas Nethercote-16/+15
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-43/+82
patterns.
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-48/+65
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
2022-11-15Rollup merge of #104391 - nnethercote:deriving-cleanups, r=jackh726Matthias Krüger-9/+7
Deriving cleanups Fixing some minor problems `@RalfJung` found in #99046. r? `@RalfJung`
2022-11-14Remove TraitDef::generics.Nicholas Nethercote-9/+7
Because it's always empty.
2022-11-14Auto merge of #103858 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-1/+1
Bump bootstrap compiler to 1.66 This PR: - Bumps version placeholders to release - Bumps to latest beta - cfg-steps code r? `@pietroalbini`
2022-11-11Introduce `ExprKind::IncludedBytes`clubby789-3/+17