about summary refs log tree commit diff
path: root/compiler/rustc_expand/src/mbe
AgeCommit message (Collapse)AuthorLines
2024-12-15Add hir::AttributeJonathan Dönszelmann-2/+2
2024-12-01Fix #128346Caio-2/+4
2024-11-21Prepare for invisible delimiters.Nicholas Nethercote-2/+4
Current places where `Interpolated` is used are going to change to instead use invisible delimiters. This prepares for that. - It adds invisible delimiter cases to the `can_begin_*`/`may_be_*` methods and the `failed_to_match_macro` that are equivalent to the existing `Interpolated` cases. - It adds panics/asserts in some places where invisible delimiters should never occur. - In `Parser::parse_struct_fields` it excludes an ident + invisible delimiter from special consideration in an error message, because that's quite different to an ident + paren/brace/bracket.
2024-11-21Introduce `InvisibleOrigin` on invisible delimiters.Nicholas Nethercote-6/+7
It's not used meaningfully yet, but will be needed to get rid of interpolated tokens.
2024-10-30Rollup merge of #132332 - nnethercote:use-token_descr-more, r=estebankMatthias Krüger-13/+5
Use `token_descr` more in error messages This is the first two commits from #124141, put into their own PR to get things rolling. Commit messages have the details. r? ``@estebank`` cc ``@petrochenkov``
2024-10-29Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillotJubilee-2/+3
compiler: apply clippy::clone_on_ref_ptr for CI Apply lint https://rust-lang.github.io/rust-clippy/master/index.html#/clone_on_ref_ptr for compiler, also see https://github.com/rust-lang/rust/pull/131225#discussion_r1790109443. Some Arc's can be misplaced with Lrc's, sorry. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/enable.20more.20clippy.20lints.20for.20compiler.20.28and.5Cor.20std.29
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-2/+3
2024-10-28Tweak more warnings.Nicholas Nethercote-13/+5
Much like the previous commit. I think the removal of "the token" in each message is fine here. There are many more error messages that mention tokens without saying "the token" than those that do say it.
2024-10-26expand: Stop using artificial `ast::Item` for macros loaded from metadataVadim Petrochenkov-55/+43
2024-10-23Rollup merge of #132060 - joshtriplett:innermost-outermost, r=jieyouxuLeón Orell Valerian Liehr-3/+3
"innermost", "outermost", "leftmost", and "rightmost" don't need hyphens These are all standard dictionary words and don't require hyphenation. ----- Encountered an instance of this in error messages and it bugged me, so I figured I'd fix it across the entire codebase.
2024-10-23"innermost", "outermost", "leftmost", and "rightmost" don't need hyphensJosh Triplett-3/+3
These are all standard dictionary words and don't require hyphenation.
2024-10-23nightly feature tracking: get rid of the per-feature bool fieldsRalf Jung-2/+2
2024-10-22terminology: #[feature] *enables* a feature (instead of "declaring" or ↵Ralf Jung-1/+1
"activating" it)
2024-10-01Stabilize expr_2021 fragment in all editionsEric Holk-36/+6
Co-authored-by: Michael Goulet <michael@errs.io> Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-69/+63
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-8/+8
2024-09-06Add initial support for raw lifetimesMichael Goulet-4/+6
2024-08-27Add `warn(unreachable_pub)` to `rustc_expand`.Nicholas Nethercote-10/+10
Plus a tiny bit of reformatting.
2024-08-16Fix wrong source location for some incorrect macro definitionsWafarm-6/+13
2024-08-14Use `impl PartialEq<TokenKind> for Token` more.Nicholas Nethercote-1/+1
This lets us compare a `Token` with a `TokenKind`. It's used a lot, but can be used even more, avoiding the need for some `.kind` uses.
2024-08-07refactor(rustc_expand::mbe): Don't require full ExtCtxt when not necessaryFelix Rath-28/+28
2024-07-29Reformat `use` declarations.Nicholas Nethercote-59/+59
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-27Make `missing_fragment_specifier` an error in edition 2024Trevor Gross-7/+18
`missing_fragment_specifier` has been a future compatibility warning since 2017. Uplifting it to an unconditional hard error was attempted in 2020, but eventually reverted due to fallout. Make it an error only in edition >= 2024, leaving the lint for older editions. This change will make it easier to support more macro syntax that relies on usage of `$`. Fixes <https://github.com/rust-lang/rust/issues/40107>
2024-07-22Always pass the visitor as the first argument to walk* functionsOli Scherer-2/+2
2024-07-19Allow concat in repetitionsCaio-45/+72
2024-07-17Add support for literalsCaio-24/+37
2024-07-08Rollup merge of #126841 - c410-f3r:concat-again, r=petrochenkov许杰友 Jieyou Xu (Joe)-26/+80
[`macro_metavar_expr_concat`] Add support for literals Adds support for things like `${concat($variable, 123)}` or `${concat("hello", "_world")}` . cc #124225
2024-07-06Add support for literalsCaio-26/+80
2024-07-02Shrink parser positions from `usize` to `u32`.Nicholas Nethercote-9/+9
The number of source code bytes can't exceed a `u32`'s range, so a token position also can't. This reduces the size of `Parser` and `LazyAttrTokenStreamImpl` by eight bytes each.
2024-06-23Rework pattern and expression nonterminal kinds.Nicholas Nethercote-12/+12
Merge `PatParam`/`PatWithOr`, and `Expr`/`Expr2021`, for a few reasons. - It's conceptually nice, because the two pattern kinds and the two expression kinds are very similar. - With expressions in particular, there are several places where both expression kinds get the same treatment. - It removes one unreachable match arm. - Most importantly, for #124141 I will need to introduce a new type `MetaVarKind` that is very similar to `NonterminalKind`, but records a couple of extra fields for expression metavars. It's nicer to have a single `MetaVarKind::Expr` expression variant to hold those extra fields instead of duplicating them across two variants `MetaVarKind::{Expr,Expr2021}`. And then it makes sense for patterns to be treated the same way, and for `NonterminalKind` to also be treated the same way. I also clarified the comments, because I have long found them a little hard to understand.
2024-06-23Tweak some ugly formatting.Nicholas Nethercote-1/+4
2024-06-23Import `NonterminalKind` in `compiler/rustc_expand/src/mbe/quoted.rs`.Nicholas Nethercote-30/+25
So we can omit the `token::` qualifier, which gives more space to some cramped code.
2024-06-21Rollup merge of #126700 - compiler-errors:fragment, r=fmeaseMatthias Krüger-2/+5
Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does Parse the `:expr` fragment as `:expr_2021` in editions <=2021, and as `:expr` in edition 2024. This is similar to how we parse `:pat` as `:pat_param` in edition <=2018 and `:pat_with_or` in >=2021, and means we can get rid of a span dependency from `nonterminal_may_begin_with`. Specifically, this fixes a theoretical regression since the `expr_2021` macro fragment previously would allow `const {}` if the *caller* is edition 2024. This is inconsistent with the way that the `pat` macro fragment was upgraded, and also leads to surprising behavior when a macro *caller* crate upgrades to edtion 2024, since they may have parsing changes that they never asked for (with no way of opting out of it). This PR also allows using `expr_2021` in all editions. Why was this was disallowed in the first place? It's purely additive, and also it's still feature gated? r? ```@fmease``` ```@eholk``` cc ```@vincenzopalazzo``` cc #123865 Tracking: - https://github.com/rust-lang/rust/issues/123742
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+1
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-19Allow naming expr_2021 in all editionsMichael Goulet-2/+5
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-11/+6
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-8/+13
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18Prefer `dcx` methods over fields or fields' methodsOli Scherer-21/+22
2024-06-15Rollup merge of #125829 - petrochenkov:upctxt2, r=michaelwoeristerMatthias Krüger-1/+1
rustc_span: Add conveniences for working with span formats This is the refactoring part of https://github.com/rust-lang/rust/pull/125017.
2024-06-13Add a new concat metavar exprCaio-27/+145
2024-06-13rustc_span: By-value interface for ctxt updateVadim Petrochenkov-1/+1
2024-06-10rustc_span: Optimize syntax context updates in spansVadim Petrochenkov-5/+5
2024-05-28Remove a stray comment that shouldn't be here.Nicholas Nethercote-1/+0
2024-05-27Rollup merge of #125530 - SparrowLii:expand2, r=petrochenkovGuillaume Gomez-32/+31
cleanup dependence of `ExtCtxt` in transcribe when macro expansion part of #125356 We can remove `transcribe`’s dependence on `ExtCtxt` to facilitate subsequent work (such as moving macro expansion into the incremental compilation system) r? ```@petrochenkov``` Thanks for the reviewing!
2024-05-25cleanup dependence of `ExtCtxt` in transcribe when macro expansionSparrowLii-32/+31
2024-05-23Rollup merge of #125316 - nnethercote:tweak-Spacing, r=petrochenkovMatthias Krüger-11/+34
Tweak `Spacing` use Some clean-up precursors to #125174. r? ``@petrochenkov``
2024-05-23Add some comments.Nicholas Nethercote-0/+15
2024-05-23Clarify `parse` a little.Nicholas Nethercote-3/+8
- Name the colon span as `colon_span` to distinguish it from the other `span` local variable. - Just use basic pattern matching, which is easier to read than `map_or`.
2024-05-23Clarify the meaning of the span within `mbe::TokenTree::MetaVar`.Nicholas Nethercote-8/+11
2024-05-21Rename buffer_lint_with_diagnostic to buffer_lintXiretza-4/+4