about summary refs log tree commit diff
path: root/tests/ui/proc-macro
AgeCommit message (Collapse)AuthorLines
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
2024-02-18add test for panicking attribute macrosTshepang Mbambo-0/+18
2024-02-18macro_rules: Preserve all metavariable spans in a global side tableVadim Petrochenkov-1/+1
2024-02-17Implement RFC3373 non local definitions lintUrgau-0/+28
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-872/+872
2024-02-14Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errorsbors-4/+51
Continue compilation after check_mod_type_wf errors The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too. The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication. fixes https://github.com/rust-lang/rust/issues/120860
2024-02-14Continue compilation after check_mod_type_wf errorsOli Scherer-4/+51
2024-02-13Do not point at `#[allow(_)]` as the reason for compat lint triggeringEsteban Küber-10/+0
Fix #121009.
2024-02-11Rollup merge of #120272 - ↵Matthias Krüger-0/+51
long-long-float:suppress-suggestions-in-derive-macro, r=oli-obk Suppress suggestions in derive macro close #118809 I suppress warnings inside derive macros. For example, the compiler emits following error by a program described in https://github.com/rust-lang/rust/issues/118809#issuecomment-1852256687 with a suggestion that indicates invalid syntax. ``` error[E0308]: `?` operator has incompatible types --> src/main.rs:3:17 | 3 | #[derive(Debug, Deserialize)] | ^^^^^^^^^^^ expected `u32`, found `u64` | = note: `?` operator cannot convert from `u64` to `u32` = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit | 3 | #[derive(Debug, Deserialize.try_into().unwrap())] | ++++++++++++++++++++ For more information about this error, try `rustc --explain E0308`. error: could not compile `serde_test` (bin "serde_test") due to 2 previous errors ``` In this PR, suggestions to cast are suppressed. ``` error[E0308]: `?` operator has incompatible types --> src/main.rs:3:17 | 3 | #[derive(Debug, Deserialize)] | ^^^^^^^^^^^ expected `u32`, found `u64` | = note: `?` operator cannot convert from `u64` to `u32` = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0308`. error: could not compile `serde_test` (bin "serde_test") due to 2 previous errors ```
2024-02-11Add test for the issuelong-long-float-0/+51
2024-02-07Update testsr0cky-0/+3
2024-01-31Auto merge of #120227 - nnethercote:further-improve-space_between, ↵bors-66/+45
r=petrochenkov Further improve `space_between` `space_between` is used by `print_tts` to decide when spaces should be put between tokens. This PR improves it in two ways: - avoid unnecessary spaces before semicolons, and - don't omit some necessary spaces before/after some punctuation symbols. r? `@petrochenkov`
2024-01-29Supress unhelpful diagnostics for unresolved top level attributesyukang-10/+44
2024-01-22Fix some cases in `space_between`.Nicholas Nethercote-1/+1
There are a number of cases where we erroneously omit the space between two tokens, all involving an exception to a more general case. The affected tokens are `$`, `!`, `.`, `,`, and `let` followed by a parenthesis. This fixes a lot of FIXME comments.
2024-01-22Don't insert spaces before most semicolons in `print_tts`.Nicholas Nethercote-65/+44
This gives better output for code produced by proc macros.
2024-01-16proc_macro_c_str_literals: Implement Literal::c_string constructornovafacing-4/+6
2024-01-13Bless testsGeorge-lewis-0/+19
Update tests
2024-01-12Rename `--env` option flag to `--env-set`Guillaume Gomez-1/+1
2024-01-05Replace some usage of `#[rustc_on_unimplemented]` withGeorg Semmler-0/+6
`#[diagnostic::on_unimplemented]` This commit replaces those `#[rustc_on_unimplemented]` attributes with their equivalent `#[diagnostic::on_unimplemented]` where this is supported (So no filter or any extended option)