about summary refs log tree commit diff
path: root/tests/ui/proc-macro
AgeCommit message (Collapse)AuthorLines
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
2024-04-09Further cleanup cfgs in the UI test suiteUrgau-4/+2
This commit does three things: 1. replaces (the last remaining) never true cfgs by the FALSE cfg 2. fix derive-helper-configured.rs (typo in directive) 3. and comment some current unused #[cfg_attr] (missing revisions)
2024-04-07Unify all the always-false cfgs under the `FALSE` cfgUrgau-1/+1
2024-04-04Rollup merge of #123431 - ↵Matthias Krüger-2/+0
slanterns:literal_byte_character_c_string_stabilize, r=dtolnay Stabilize `proc_macro_byte_character` and `proc_macro_c_str_literals` This PR stabilizes `proc_macro_byte_character` and `proc_macro_c_str_literals`: ```rust // proc_macro::Literal impl Literal { pub fn byte_character(byte: u8) -> Literal; pub fn c_string(string: &CStr) -> Literal } ``` <br> Tracking issue: https://github.com/rust-lang/rust/issues/115268, https://github.com/rust-lang/rust/issues/119750. Implementation PR: https://github.com/rust-lang/rust/pull/112711, https://github.com/rust-lang/rust/pull/119651. FCPs already completed in their respective tracking issues. Closes https://github.com/rust-lang/rust/issues/115268. Closes https://github.com/rust-lang/rust/issues/119750. r? libs-api
2024-04-04rebaseBoxy-1/+14
2024-04-04Stabilize `Literal::c_string`Slanterns-1/+0
2024-04-04Stabilize `Literal::byte_character`Slanterns-1/+0
2024-03-25Add needs-unwind for proc macro testsbjorn3-1/+8
Rustc gives a warning when compiling proc macros with panic=abort.
2024-03-11Update test directives for `wasm32-wasip1`Alex Crichton-2/+0
* The WASI targets deal with the `main` symbol a bit differently than native so some `codegen` and `assembly` tests have been ignored. * All `ignore-emscripten` directives have been updated to `ignore-wasm32` to be more clear that all wasm targets are ignored and it's not just Emscripten. * Most `ignore-wasm32-bare` directives are now gone. * Some ignore directives for wasm were switched to `needs-unwind` instead. * Many `ignore-wasm32*` directives are removed as the tests work with WASI as opposed to `wasm32-unknown-unknown`.
2024-03-07Rollup merge of #122107 - Urgau:non_local_def-allow, r=WaffleLapkinMatthias Krüger-4/+10
Temporarily make allow-by-default the `non_local_definitions` lint T-lang [decided in their triage meeting](https://hackmd.io/U-CKiZx_RKiaANAPXtWf7g#non_local_definitions-common-issues-impl-for-ampLocal-FromltLocalgt-for-Global-%E2%80%A6-rust121621) to try to use a [better logic](https://github.com/rust-lang/rust/issues/121621#issuecomment-1976826895) for detecting non-local `impl` definitions given the [numerous reports](https://github.com/rust-lang/rust/issues/121621) we got. Until that is done and also because the beta cut is next week, switch the lint to allow-by-default until it's implemented. r? `@WaffleLapkin`
2024-03-06Temporarily make allow-by-default the non_local_definitions lintUrgau-4/+10
2024-03-03Be more lax in `.into_iter()` suggestion when encountering `Iterator` ↵Esteban Küber-5/+2
methods on non-`Iterator` ``` error[E0599]: no method named `map` found for struct `Vec<bool>` in the current scope --> $DIR/vec-on-unimplemented.rs:3:23 | LL | vec![true, false].map(|v| !v).collect::<Vec<_>>(); | ^^^ `Vec<bool>` is not an iterator | help: call `.into_iter()` first | LL | vec![true, false].into_iter().map(|v| !v).collect::<Vec<_>>(); | ++++++++++++ ``` We used to provide some help through `rustc_on_unimplemented` on non-`impl Trait` and non-type-params, but this lets us get rid of some otherwise unnecessary conditions in the annotation on `Iterator`.
2024-02-25Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkinbors-0/+28
Implement RFC 3373: Avoid non-local definitions in functions This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-19Rollup merge of #121275 - tshepang:test-panicking-proc-macros, r=nnethercoteMatthias Krüger-0/+18
add test for panicking attribute macros