summary refs log tree commit diff
path: root/compiler/rustc_ast/src/token.rs
AgeCommit message (Collapse)AuthorLines
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-7/+7
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-12-16Little fixesDeep Majumder-1/+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-13remove unnecessary uses of `clone`Takayuki Maeda-1/+1
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-10/+10
2022-11-21Remove `ref` patterns from `rustc_ast`Maybe Waffle-3/+5
Also use if let chains in one case.
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-8/+42
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-11Auto merge of #99918 - WaffleLapkin:fnFnfun, r=estebankbors-0/+10
Recover wrong-cased keywords that start items (_this pr was inspired by [this tweet](https://twitter.com/Azumanga/status/1552982326409367561)_) r? `@estebank` We've talked a bit about this recovery, but I just wanted to make sure that this is the right approach :) For now I've only added the case insensitive recovery to `use`s, since most other items like `impl` blocks, modules, functions can start with multiple keywords which complicates the matter.
2022-10-12Use `tidy-alphabetical` in the compilerNilstrieb-1/+2
2022-10-03Rewrite `Token::is_op`.Nicholas Nethercote-11/+8
An exhaustive match is more readable and more future-proof.
2022-10-01Replace some `bool` params with an enumMaybe Waffle-3/+4
2022-10-01Recover wrong cased keywords starting functionsMaybe Waffle-0/+9
2022-09-30Rollup merge of #102493 - nnethercote:improve-size-assertions-some-more, r=lqdMatthias Krüger-8/+13
Group together more size assertions. Also add a few more assertions for some relevant token-related types. And fix an erroneous comment in `rustc_errors`. r? `@lqd`
2022-10-01Group together more size assertions.Nicholas Nethercote-8/+13
Also add a few more assertions for some relevant token-related types. And fix an erroneous comment in `rustc_errors`.
2022-09-29Inline `<Token as PartialEq<TokenKind>>::eq`.Nicholas Nethercote-0/+1
2022-09-26Remove `ast::Token::take`.Nicholas Nethercote-6/+1
Instead of replacing `TokenTreesReader::token` in two steps, we can just do it in one, which is both simpler and faster.
2022-09-11fix #101626, suggest pub instead of public for const type itemyukang-0/+1
2022-09-03Suggest removing unnecessary prefix let in patternsMichael Goulet-0/+24
2022-08-15suggest adding a missing semicolon before an itemTakayuki Maeda-0/+24
2022-06-02Revert #96682.Nicholas Nethercote-3/+2
The change was "Show invisible delimiters (within comments) when pretty printing". It's useful to show these delimiters, but is a breaking change for some proc macros. Fixes #97608.
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-1/+1
2022-05-05Rollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkovMatthias Krüger-2/+3
Show invisible delimeters (within comments) when pretty printing. Because invisible syntax is really hard to work with! r? `@petrochenkov`
2022-05-04Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkovbors-0/+9
Overhaul `MacArgs` Motivation: - Clarify some code that I found hard to understand. - Eliminate one use of three places where `TokenKind::Interpolated` values are created. r? `@petrochenkov`
2022-05-05Add a comment on `TokenKind::Interpolated`.Nicholas Nethercote-0/+9
2022-05-04Show invisible delimeters (within comments) when pretty printing.Nicholas Nethercote-2/+3
2022-05-04Remove unnecessary `NtIdent` in `Token::is_whole_expr`.Nicholas Nethercote-1/+1
The comment on this function explains that it's a specialized version of `maybe_whole_expr`. But `maybe_whole_expr` doesn't do anything with `NtIdent`, so `is_whole_expr` also doesn't need to.
2022-05-04Speed up `Token::{ident,lifetime}`.Nicholas Nethercote-6/+16
They're hot enough that the repeated matching done by `uninterpolate` has a measurable effect.
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-18/+25
2022-04-15Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelixDylan DPC-1/+1
Create (unstable) 2024 edition [On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition. This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024. For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical. ````@rustbot```` label +T-lang +S-waiting-on-review Not sure on the relevant team, to be honest.
2022-04-07Shrink `Nonterminal`.Nicholas Nethercote-4/+4
By heap allocating the argument within `NtPath`, `NtVis`, and `NtStmt`. This slightly reduces cumulative and peak allocation amounts, most notably on `deep-vector`.
2022-04-02Create 2024 editionJacob Pratt-1/+1
2022-03-31Rollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnayDylan DPC-2/+2
Reduce max hash in raw strings from u16 to u8 [Relevant discussion](https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc/topic/Max.20raw.20string.20delimiters)
2022-03-28Remove `Nonterminal::NtTT`.Nicholas Nethercote-5/+0
It's only needed for macro expansion, not as a general element in the AST. This commit removes it, adds `NtOrTt` for the parser and macro expansion cases, and renames the variants in `NamedMatch` to better match the new type.
2022-03-23Update syntax tree definitionGrisha Vartanyan-2/+2
2022-02-262 - Make more use of let_chainsCaio-12/+8
Continuation of #94376. cc #53667
2021-10-04Use `TokenKind::similar_tokens()`Fabian Wolff-0/+1
2021-09-04Fix formattingTheodore Luo Wang-1/+4
2021-09-04Use verbose suggestions and only match if the + is seen before a numeric literalTheodore Luo Wang-0/+4
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-04-27remove pat2021mark-10/+3
2021-04-15rename pat2015 to pat_parammark-7/+7
2021-03-22rename :pat2018 -> :pat215mark-7/+7
2021-03-15Extend `proc_macro_back_compat` lint to `procedural-masquerade`Aaron Hill-27/+0
We now lint on *any* use of `procedural-masquerade` crate. While this crate still exists, its main reverse dependency (`cssparser`) no longer depends on it. Any crates still depending off should stop doing so, as it only exists to support very old Rust versions. If a crate actually needs to support old versions of rustc via `procedural-masquerade`, then they'll just need to accept the warning until we remove it entirely (at the same time as the back-compat hack). The latest version of `procedural-masquerade` does not work with the latest rustc, but trying to check for the version seems like more trouble than it's worth. While working on this, I realized that the `proc-macro-hack` check was never actually doing anything. The corresponding enum variant in `proc-macro-hack` is named `Value` or `Nested` - it has never been called `Input`. Due to a strange Crater issue, the Crater run that tested adding this did *not* end up testing it - some of the crates that would have failed did not actually have their tests checked, making it seem as though the `proc-macro-hack` check was working. The Crater issue is being discussed at https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/Nearly.20identical.20Crater.20runs.20processed.20a.20crate.20differently/near/230406661 Despite the `proc-macro-hack` check not actually doing anything, we haven't gotten any reports from users about their build being broken. I went ahead and removed it entirely, since it's clear that no one is being affected by the `proc-macro-hack` regression in practice.
2021-03-14Introduce `proc_macro_back_compat` lint, and emit for `time-macros-impl`Aaron Hill-49/+1
Now that future-incompat-report support has landed in nightly Cargo, we can start to make progress towards removing the various proc-macro back-compat hacks that have accumulated in the compiler. This PR introduces a new lint `proc_macro_back_compat`, which results in a future-incompat-report entry being generated. All proc-macro back-compat warnings will be grouped under this lint. Note that this lint will never actually become a hard error - instead, we will remove the special cases for various macros, which will cause older versions of those crates to emit some other error. I've added code to fire this lint for the `time-macros-impl` case. This is the easiest case out of all of our current back-compat hacks - the crate was renamed to `time-macros`, so seeing a filename with `time-macros-impl` guarantees that an older version of the parent `time` crate is in use. When Cargo's future-incompat-report feature gets stabilized, affected users will start to see future-incompat warnings when they build their crates.
2021-03-06Change x64 size checks to not apply to x32.Harald van Dijk-2/+2
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-01-07rustc_parse: Better spans for synthesized token streamsVadim Petrochenkov-1/+1
2020-12-31Enable Pat2021 in edition 2021.Mara Bos-2/+1
2020-12-30Implement edition-based macro pat featuremark-5/+30
2020-12-24use matches!() macro in more placesMatthias Krüger-34/+19
2020-12-17docs: Edit rustc_ast::token::Tokenpierwill-1/+1
Add missing punctuation.