summary refs log tree commit diff
path: root/tests/ui/proc-macro
AgeCommit message (Collapse)AuthorLines
2025-03-26expand: Leave traces when expanding `cfg` attributesVadim Petrochenkov-14/+36
2025-03-25compiletest: Support matching on diagnostics without a spanVadim Petrochenkov-19/+22
2025-03-17expand: Leave traces when expanding `cfg_attr` attributesVadim Petrochenkov-0/+79
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-4/+0
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-07More denesting of invisibly-delimited groups.Nicholas Nethercote-0/+28
This time when converting them to proc-macro `Group` form.
2025-03-07Remove `NtItem` and `NtStmt`.Nicholas Nethercote-37/+43
This involves replacing `nt_pretty_printing_compatibility_hack` with `stream_pretty_printing_compatibility_hack`. The handling of statements in `transcribe` is slightly different to other nonterminal kinds, due to the lack of `from_ast` implementation for empty statements. Notable test changes: - `tests/ui/proc-macro/expand-to-derive.rs`: the diff looks large but the only difference is the insertion of a single invisible-delimited group around a metavar.
2025-02-24tests: Add regression test for derive token invalidation (#81099)Vadim Petrochenkov-0/+172
2025-02-23Rollup merge of #137415 - chenyukang:yukang-fix-137345-invalid-sugg, r=estebankMatthias Krüger-0/+49
Remove invalid suggestion of into_iter for extern macro Fixes #137345 #109082 is closed due to performance issue, do we have any other solution for this kind of issue?
2025-02-22remove invalid suggestion of into_iter for extern macroyukang-0/+49
2025-02-21Inject `compiler_builtins` during postprocessing rather than via ASTTrevor Gross-10/+8
`compiler_builtins` is currently injected as `extern crate compiler_builtins as _`. This has made gating via diagnostics difficult because it appears in the crate graph as a non-private dependency, and there isn't an easy way to differentiate between the injected AST and user-specified `extern crate compiler_builtins`. Resolve this by injecting `compiler_builtins` during postprocessing rather than early in the AST. Most of the time this isn't even needed because it shows up in `std` or `core`'s crate graph, but injection is still needed to ensure `#![no_core]` works correctly. A similar change was attempted at [1] but this encountered errors building `proc_macro` and `rustc-std-workspace-std`. Similar failures showed up while working on this patch, which were traced back to `compiler_builtins` showing up in the graph twice (once via dependency and once via injection). This is resolved by not injecting if a `#![compiler_builtins]` crate already exists. [1]: https://github.com/rust-lang/rust/pull/113634
2025-02-11compiler: replace ExternAbi::name calls with formattersJubilee Young-1/+1
Most of these just format the ABI string, so... just format ExternAbi? This makes it more consistent and less jank when we can do it.
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-6/+9
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-03Check Sizedness of return type in WFMichael Goulet-0/+6
2025-01-19fully de-stabilize all custom inner attributesRalf Jung-55/+31
2025-01-15Rollup merge of #132397 - m-ou-se:warn-missing-abi, r=NadrierilJacob Pratt-7/+15
Make missing_abi lint warn-by-default. This makes the missing_abi lint warn-by-default, as suggested here: https://github.com/rust-lang/rfcs/pull/3722#issuecomment-2447719047 This needs a lang FCP.
2025-01-10Rollup merge of #134693 - SpriteOvO:proc-macro-use-to-tokens-in-quote, ↵Jacob Pratt-49/+604
r=tgross35 proc_macro: Use `ToTokens` trait in `quote` macro Tracking issues: #130977, #54722 This PR changed `proc_macro::quote!` to use `ToTokens` trait instead of `TokenStream::from`, and migrated test cases from `quote` crate. r? `@dtolnay` CC `@tgross35`
2025-01-09Fix `proc_macro::quote!` for raw identAsuna-1/+21
2025-01-09Migrate check-fail tests for `proc_macro::quote!` from `quote` crateAsuna-0/+163
2025-01-09Migrate basic tests for `proc_macro::quote!` from `quote` crateAsuna-0/+368
2025-01-09Append `TokenTree` with `ToTokens` in `proc_macro::quote!`Asuna-19/+23
2025-01-07Update tests.Mara Bos-7/+15
2025-01-06Normalize each signature input/output in typeck_with_fallback with its own spanMichael Goulet-2/+3
2025-01-01Try to write the panic message with a single `write_all` callJohn Kåre Alsaker-0/+1
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-14/+14
2024-11-28Update more 2024 tests to remove -Zunstable-optionsEric Huss-1/+0
2024-11-27Update tests to use new proc-macro headerEric Huss-824/+361
2024-11-20Use edition of `macro_rules` when compiling the macroEric Huss-14/+2
2024-11-20Add tests for the edition of macro_rules from a proc-macroEric Huss-0/+81
2024-11-11remove attributes from generics in built-in derive macrosPonasKovas-0/+31
add a test add github issue link to description of the test replace new ThinVec with clear() Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2024-11-03use backticks instead of single quotes when reporting "use of unstable ↵dianne-1/+1
library feature" This is consistent with all other diagnostics I could find containing features and enables the use of `DiagSymbolList` for generalizing diagnostics for unstable library features to multiple features.
2024-10-28Tweak `expand_incomplete_parse` warning.Nicholas Nethercote-8/+8
By using `token_descr`, as is done for many other errors, we can get slightly better descriptions in error messages, e.g. "macro expansion ignores token `let` and any following" becomes "macro expansion ignores keyword `let` and any tokens following". This will be more important once invisible delimiters start being mentioned in error messages -- without this commit, that leads to error messages such as "error at ``" because invisible delimiters are pretty printed as an empty string.
2024-10-11Remove deprecation note in the `non_local_definitions` warningUrgau-1/+0
2024-08-24Avoid double-handling of attributes in `collect_tokens`.Nicholas Nethercote-29/+2
By keeping track of attributes that have been previously processed. This fixes the `macro-rules-derive-cfg.stdout` test, and is necessary for #124141 which removes nonterminals. Also shrink the `SmallVec` inline size used in `IntervalSet`. 2 gives slightly better perf than 4 now that there's an `IntervalSet` in `Parser`, which is cloned reasonably often.
2024-08-23Tweak `tests/ui/proc-macro/macro-rules-derive-cfg.rs`.Nicholas Nethercote-98/+102
- Trim some unnecessary fat from the type declaration. - Add another attribute, to make it a stronger test of `cfg_attr` processing. Note that the current output is incorrect, because it duplicates the added attribute. The next commit will fix this.
2024-08-12Fix bug in `Parser::look_ahead`.Nicholas Nethercote-0/+58
The special case was failing to handle invisible delimiters on one path. Fixes #128895.
2024-07-24Improve spans on evaluated `cfg_attr`s.Nicholas Nethercote-13/+13
When converting something like `#![cfg_attr(cond, attr)]` into `#![attr]`, we currently duplicate the `#` token and the `!` token. But weirdly, there is also this comment: // We don't really have a good span to use for the synthesized `[]` // in `#[attr]`, so just use the span of the `#` token. Maybe that comment used to be true? But now it is false: we can duplicate the existing delimiters (and their spans and spacing), much like we do for the `#` and `!`. This commit does that, thus removing the incorrect comment, and improving the spans on `Group`s in a few proc-macro tests.
2024-07-11Always use a colon in `//@ normalize-*:` headersZalathar-14/+14
2024-06-19Change how `parse_expr_force_collect` works.Nicholas Nethercote-26/+1
It now parses outer attributes before collecting tokens. This avoids the problem where the outer attribute tokens were being stored twice -- for the attribute tokesn, and also for the expression tokens. Fixes #86055.
2024-06-13Remove superfluous escaping from byte, byte str, and c str literalsDavid Tolnay-7/+7
2024-06-13Add more Literal::to_string testsDavid Tolnay-11/+36
2024-06-13Rename proc_macro::Literal tests from parse.rs to literal.rsDavid Tolnay-2/+2
This module contains tests not just of parse (FromStr) but also to_string (Display) for literals.
2024-06-11Auto merge of #125174 - nnethercote:less-ast-pretty-printing, r=petrochenkovbors-16/+7
Print `token::Interpolated` with token stream pretty printing. This is a step towards removing `token::Interpolated` (#124141). It unavoidably changes the output of the `stringify!` macro, generally for the better. r? `@petrochenkov`
2024-06-06Revert "Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, ↵Rémy Rakic-1/+2
r=davidtwco" This reverts commit 57dad1d75e562ff73051c1c43b07eaf65c7dbd74, reversing changes made to 36316df9fe6c3e246153fe6e78967643cf08c148.
2024-06-05Print `token::Interpolated` with token stream pretty printing.Nicholas Nethercote-16/+7
Instead of using AST pretty printing. This is a step towards removing `token::Interpolated`, which will eventually (in #124141) be replaced with a token stream within invisible delimiters. This changes (improves) the output of the `stringify!` macro in some cases. This is allowed. As the `stringify!` docs say: "Note that the expanded results of the input tokens may change in the future. You should be careful if you rely on the output." Test changes: - tests/ui/macros/stringify.rs: this used to test both token stream pretty printing and AST pretty printing via different ways of invoking of `stringify!` (i.e. `$expr` vs `$tt`). But those two different invocations now give the same result, which is a nice consistency improvement. This removes the need for all the `c2*` macros. The AST pretty printer now has more thorough testing thanks to #125236. - tests/ui/proc-macro/*: minor improvements where small differences between `INPUT (DISPLAY)` output and `DEEP-RE-COLLECTED (DISPLAY)` output disappear.
2024-06-04Rollup merge of #125596 - nnethercote:rental-hard-error, r=estebankGuillaume Gomez-450/+4
Convert `proc_macro_back_compat` lint to an unconditional error. We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in #73345. The lint was added in #83127. The tracking issue is #83125. The direct motivation for the change is that providing the alternative behaviour is interfering with #125174 and follow-on work. r? ``@estebank``
2024-05-28Convert `proc_macro_back_compat` lint to an unconditional error.Nicholas Nethercote-450/+4
We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in #73345. The lint was added in #83127. The tracking issue is #83125. The direct motivation for the change is that providing the alternative behaviour is interfering with #125174 and follow-on work.
2024-05-27non_local_defs: improve exception note for impl and macro_rules!Urgau-1/+0
- Remove wrong exception text for non-local macro_rules! - Simplify anonymous const exception note
2024-05-27non_local_defs: switch to more friendly primary messageUrgau-1/+1
2024-05-17Rename Unsafe to SafetySantiago Pastorino-1/+1
2024-04-18Disallow ambiguous attributes on expressionsDominik Stolz-2/+1