about summary refs log tree commit diff
path: root/tests/ui/proc-macro
AgeCommit message (Collapse)AuthorLines
2025-04-16Explicitly annotate edition for `unpretty=expanded` and `unpretty=hir` testsLukas Wirth-4/+8
These emit prelude imports which means they are always edition dependent
2025-04-15Rollup merge of #139671 - m-ou-se:proc-macro-span, r=dtolnayStuart Cook-26/+13
Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file} Simplification/redesign of the unstable proc macro span API, tracked in https://github.com/rust-lang/rust/issues/54725: Before: ```rust impl Span { pub fn line(&self) -> usize; pub fn column(&self) -> usize; pub fn source_file(&self) -> SourceFile; } #[derive(Clone, Debug, PartialEq, Eq)] pub struct SourceFile { .. } impl !Send for SourceFile {} impl !Sync for SourceFile {} impl SourceFile { pub fn path(&self) -> PathBuf; pub fn is_real(&self) -> bool; } ``` After: ```rust impl Span { pub fn line(&self) -> usize; pub fn column(&self) -> usize; pub fn file(&self) -> String; // Mapped file name, for display purposes. pub fn local_file(&self) -> Option<PathBuf>; // Real file name as it exists on disk. } ``` This resolves the last blocker for stabilizing these methods. (Stabilizing will be a separate PR with FCP.)
2025-04-13UI tests: migrate remaining compile time `error-pattern`s to line annotationsVadim Petrochenkov-185/+188
when possible.
2025-04-11Replace proc_macro::SourceFile by Span::{file, local_file}.Mara Bos-14/+13
2025-04-11Remove proc_macro::SourceFile::is_real().Mara Bos-13/+1
2025-04-09Auto merge of #139555 - petrochenkov:errkind-ann, r=jieyouxubors-2/+2
UI tests: add missing diagnostic kinds where possible The subset of https://github.com/rust-lang/rust/pull/139427 that only adds diagnostic kinds to line annotations, without changing any other things in annotations or compiletest. After this only non-viral `NOTE`s and `HELP`s should be missing. r? `@jieyouxu`
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-2/+2
2025-04-07compiletest: Always preserve kind for compiler diagnosticsVadim Petrochenkov-4/+7
Those that didn't previously preserved kind are now marked as not requiring annotations to keep the previous behavior. Also, do not lose diagnostics with an empty message.
2025-04-03Use `cfg(false)` in UI testsclubby789-79/+79
2025-04-03Stabilize `cfg_boolean_literals`clubby789-16/+15
2025-04-03compiletest: Require `//~` annotations even if `error-pattern` is specifiedVadim Petrochenkov-9/+11
2025-04-02Remove `NtExpr` and `NtLiteral`.Nicholas Nethercote-61/+68
Notes about tests: - tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs: some messages are now duplicated due to repeated parsing. - tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs: ditto. - `tests/ui/proc-macro/macro-rules-derive-cfg.rs`: the diff looks large but the only difference is the insertion of a single invisible-delimited group around a metavar. - `tests/ui/attributes/nonterminal-expansion.rs`: a slight span degradation, somehow related to the recent massive attr parsing rewrite (#135726). I couldn't work out exactly what is going wrong, but I don't think it's worth holding things up for a single slightly suboptimal error message.
2025-03-31hygiene: Rename semi-transparent to semi-opaqueVadim Petrochenkov-5/+5
The former is just too long, see the examples in `hygiene.rs`
2025-03-31Auto merge of #139083 - petrochenkov:ctxtdecod3, r=nnethercotebors-10/+10
hygiene: Rewrite `apply_mark_internal` to be more understandable The previous implementation allocated new `SyntaxContext`s in the inverted order, and it was generally very hard to understand why its result matches what the `opaque` and `opaque_and_semitransparent` field docs promise. ```rust /// This context, but with all transparent and semi-transparent expansions filtered away. opaque: SyntaxContext, /// This context, but with all transparent expansions filtered away. opaque_and_semitransparent: SyntaxContext, ``` It also couldn't be easily reused for the case where the context id is pre-reserved like in #129827. The new implementation tries to follow the docs in a more straightforward way. I did the transformation in small steps, so it indeed matches the old implementation, not just the docs. So I suggest reading only the new version.
2025-03-30Rollup merge of #139122 - petrochenkov:norerr, r=compiler-errorsJacob Pratt-10/+3
Remove attribute `#[rustc_error]` It was an ancient way to write `check-pass` tests, but now it's no longer necessary (except for the `delayed_bug_from_inside_query` flavor, which is retained).
2025-03-30Revert "Auto merge of #129827 - bvanjoi:less-decoding, r=petrochenkov"Jakub Beránek-10/+10
Reverting because of a performance regression. This reverts commit d4812c8638173ec163825d56a72a33589483ec4c, reversing changes made to 5cc60728e7ee10eb2ae5f61f7d412d9805b22f0c.
2025-03-30Remove attribute `#[rustc_error]`Vadim Petrochenkov-10/+3
2025-03-29less decoding if it has the same syntax contextbohan-10/+10
2025-03-28hygiene: Rewrite `apply_mark_internal` to be more understandableVadim Petrochenkov-10/+10
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.