about summary refs log tree commit diff
path: root/src/test/ui/macros
AgeCommit message (Collapse)AuthorLines
2021-06-07Include macro name in 'local ambiguity' errorAaron Hill-2/+2
Currently, we only point at the span of the macro argument. When the macro call is itself generated by another macro, this can make it difficult or impossible to determine which macro is responsible for producing the error.
2021-05-29Use correct edition when parsing `:pat` matchersAaron Hill-0/+32
As described in issue #85708, we currently do not properly decode `SyntaxContext::root()` and `ExpnId::root()` from foreign crates. As a result, when we decode a span from a foreign crate with `SyntaxContext::root()`, we end up up considering it to have the edition of the *current* crate, instead of the foreign crate where it was originally created. A full fix for this issue will be a fairly significant undertaking. Fortunately, it's possible to implement a partial fix, which gives us the correct edition-dependent behavior for `:pat` matchers when the macro is loaded from another crate. Since we have the edition of the macro's defining crate available, we can 'recover' from seeing a `SyntaxContext::root()` and use the edition of the macro's defining crate. Any solution to issue #85708 must reproduce the behavior of this targeted fix - properly preserving a foreign `SyntaxContext::root()` means (among other things) preserving its edition, which by definition is the edition of the foreign crate itself. Therefore, this fix moves us closer to the correct overall solution, and does not expose any new incorrect behavior to macros.
2021-05-15Remove some unncessary spaces from pretty-printed tokenstream outputAaron Hill-7/+7
In addition to making the output look nicer for all crates, this also aligns the pretty-printing output with what the `rental` crate expects. This will allow us to eventually disable a backwards-compat hack in a follow-up PR.
2021-05-13Add support for const operands and options to global_asm!Amanieu d'Antras-5/+5
On x86, the default syntax is also switched to Intel to match asm!
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-54/+54
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-05-12Update stderrAaron Hill-23/+8
The spans generated by `quote!` are (intentionally) no longer all the same, so I removed that check entirely.
2021-04-28Auto merge of #83386 - mark-i-m:stabilize-pat2015, r=nikomatsakisbors-43/+41
Stabilize `:pat_param` and remove `:pat2021` Blocked on #83384 cc `@rust-lang/lang` #79278 If I understand `@nikomatsakis` in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/or.20patterns/near/231133873, another FCP is not needed. r? `@nikomatsakis`
2021-04-27remove pat2021mark-27/+25
2021-04-23Revert "Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakis"Santiago Pastorino-121/+0
This reverts commit e2561c58a41023a14e0e583113dcf55e1ecb236a, reversing changes made to 2982ba50fc4bb629b8fe4108a81cb2f9b053510b.
2021-04-15update testmark-4/+4
2021-04-15rename pat2015 to pat_parammark-15/+15
2021-04-15Run buffered lints attached to anon constsAaron Hill-0/+34
Fixes #84195
2021-04-15Rollup merge of #84185 - hi-rustin:rustin-patch-macro, r=nikomatsakisDylan DPC-0/+113
add more pat2021 tests close https://github.com/rust-lang/rust/issues/84138 r? ```@nikomatsakis```
2021-04-14test: add reasonable casehi-rustin-2/+2
2021-04-14test: add more caseshi-rustin-3/+69
2021-04-14add macro-or-patterns-2021 testhi-rustin-0/+47
2021-04-12Fix lookahead with None-delimited groupAaron Hill-0/+15
2021-04-10Expand derive invocations in left-to-right orderAaron Hill-20/+20
While derives were being collected in left-to-order order, the corresponding `Invocation`s were being pushed in the wrong order.
2021-04-06Rollup merge of #83814 - petrochenkov:emptyexpr, r=davidtwcoYuki Okushi-0/+31
expand: Do not ICE when a legacy AST-based macro attribute produces and empty expression Fixes https://github.com/rust-lang/rust/issues/80251 The reported error is the same as for `let _ = #[cfg(FALSE)] EXPR;`
2021-04-03Remove redundant `ignore-tidy-linelength` annotationsSimon Jakobi-7/+5
This is step 2 towards fixing #77548. In the codegen and codegen-units test suites, the `//` comment markers were kept in order not to affect any source locations. This is because these tests cannot be automatically `--bless`ed.
2021-04-03expand: Do not ICE when a legacy AST-based macro attribute produces and ↵Vadim Petrochenkov-0/+31
empty expression
2021-04-02address commentshi-rustin-12/+12
2021-04-01add OR_PATTERNS_BACK_COMPAT linthi-rustin-0/+84
test: add more cases test: add comments refine msg
2021-03-28Rollup merge of #83348 - osa1:issue83344, r=jackh726Yuki Okushi-0/+14
format macro argument parsing fix When the character next to `{}` is "shifted" (when mapping a byte index in the format string to span) we should avoid shifting the span end index, so first map the index of `}` to span, then bump the span, instead of first mapping the next byte index to a span (which causes bumping the end span too much). Regression test added. Fixes #83344 --- r? ```@estebank```
2021-03-27format macro argument parsing fixÖmer Sinan Ağacan-0/+14
When the character next to `{}` is "shifted" (when mapping a byte index in the format string to span) we should avoid shifting the span end index, so first map the index of `}` to span, then bump the span, instead of first mapping the next byte index to a span (which causes bumping the end span too much). Regression test added. Fixes #83344
2021-03-27Rollup merge of #83343 - osa1:issue83340, r=jackh726Yuki Okushi-0/+16
Simplify and fix byte skipping in format! string parser Fixes '\\' handling in format strings. Fixes #83340
2021-03-23Rollup merge of #83384 - mark-i-m:rename-pat2018, r=joshtriplettYuki Okushi-1/+1
rename :pat2018 -> :pat2015 as requested by T-lang on zulip: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/or.20patterns/near/231133873 No functional changes here... just renaming. r? `@nikomatsakis`
2021-03-22Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakisbors-1/+0
Stabilize or_patterns (RFC 2535, 2530, 2175) closes #54883 This PR stabilizes the or_patterns feature in Rust 1.53. This is blocked on the following (in order): - [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021 - [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705) - It looks like we will need to pursue some sort of edition-based transition for `:pat`. - [x] Nomination and discussion by T-lang - [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100). - [ ] An FCP on stabilization EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-22rename :pat2018 -> :pat215mark-1/+1
2021-03-21Simplify and fix byte skipping in format! string parserÖmer Sinan Ağacan-0/+16
Fixes '\\' handling in format strings. Fixes #83340
2021-03-20Move some tests to more reasonable directories - 5Caio-0/+18
2021-03-19update testsmark-1/+0
2021-03-13Add regression testshyd-dev-0/+29
2021-02-23Rollup merge of #82296 - spastorino:pubrules, r=nikomatsakisDylan DPC-0/+121
Support `pub` on `macro_rules` This rebases and updates `since` version of #78166 from ``@petrochenkov`` r? ``@nikomatsakis``
2021-02-21Suggest `return`ing tail expressions that match return typeEsteban Küber-0/+5
Some newcomers are confused by the behavior of tail expressions, interpreting that "leaving out the `;` makes it the return value". To help them go in the right direction, suggest using `return` instead when applicable.
2021-02-19Support `pub` on `macro_rules`Vadim Petrochenkov-0/+121
2021-02-18Rollup merge of #82203 - c410-f3r:tests-tests-tests, r=Dylan-DPCYuki Okushi-0/+94
Move some tests to more reasonable directories - 4 cc #81941
2021-02-16Move some tests to more reasonable directoriesCaio-0/+94
2021-02-16Ensure debug_assert! tests get runTeddy Katz-0/+1
2021-02-16Document that `assert!` format arguments are evaluated lazilyTeddy Katz-0/+11
It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example: ```rust assert!( some_condition, "The state is invalid. Details: {}", expensive_call_to_get_debugging_info(), ); ``` It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.
2021-02-07expand/resolve: Turn `#[derive]` into a regular macro attributeVadim Petrochenkov-22/+22
2021-02-06path trimming: ignore type aliasesDan Aloni-1/+1
2021-02-03Allow/fix non_fmt_panic in tests.Mara Bos-0/+2
2021-02-03Add lint for `panic!(123)` which is not accepted in Rust 2021.Mara Bos-1/+1
This extends the `panic_fmt` lint to warn for all cases where the first argument cannot be interpreted as a format string, as will happen in Rust 2021. It suggests to add `"{}", ` to format the message as a string. In the case of `std::panic!()`, it also suggests the recently stabilized `std::panic::panic_any()` function as an alternative. It renames the lint to `non_fmt_panic` to match the lint naming guidelines.
2021-01-31Move some tests to more reasonable directoriesCaio-0/+14
2021-01-18Rollup merge of #81071 - osa1:fix_81006, r=estebankAshley Mannix-0/+24
rustc_parse_format: Fix character indices in find_skips Fixes #81006
2021-01-17rustc_parse_format: Fix character indices in find_skipsÖmer Sinan Ağacan-0/+24
Fixes #81006
2021-01-17Force vec! to expressions onlyDániel Buga-0/+20
2021-01-16Move some tests to more reasonable directories - 2Caio-0/+77
Address comments Update limits
2021-01-13Update tests for extern block lintingMark Rousskov-4/+10