summary refs log tree commit diff
path: root/src/test/ui/macros
AgeCommit message (Collapse)AuthorLines
2022-08-05Move write! and writeln! temporaries test to check-failDavid Tolnay-16/+93
2022-08-05Regression in issue 99684 fixedDavid Tolnay-31/+1
2022-08-05Add regression test minimized from async-std writeDavid Tolnay-0/+67
2022-07-21Rollup merge of #99435 - CAD97:revert-dollar-dollar-crate, r=Mark-SimulacrumMatthias Krüger-19/+55
Revert "Stabilize $$ in Rust 1.63.0" This mechanically reverts commit 9edaa76adce4de737db54194eb13d6c298827b37, the one commit from #95860. https://github.com/rust-lang/rust/issues/99035; the behavior of `$$crate` is potentially unexpected and not ready to be stabilized. https://github.com/rust-lang/rust/pull/99193 attempts to forbid `$$crate` without also destabilizing `$$` more generally. `@rustbot` modify labels +T-compiler +T-lang +P-medium +beta-nominated +relnotes (applying the labels I think are accurate from the issue and alternative partial revert) cc `@Mark-Simulacrum`
2022-06-23Rollup merge of #98353 - beetrees:builtin-macros-cfg-diag, r=davidtwcoMichael Goulet-1/+10
Migrate two diagnostics from the `rustc_builtin_macros` crate Migrate two diagnostics to use the struct derive and be translatable. r? ```@davidtwco```
2022-06-21Add UI test for `cfg!(foo, bar)`beetrees-1/+10
2022-06-21Move some tests to more reasonable directoriesCaio-0/+30
2022-06-21Auto merge of #98148 - c410-f3r:assert-compiler, r=oli-obkbors-0/+42
[RFC 2011] Expand expressions where possible Tracking issue: https://github.com/rust-lang/rust/issues/44838 Fourth step of https://github.com/rust-lang/rust/pull/96496 Extends https://github.com/rust-lang/rust/pull/97665 considering expressions that are good candidates for expansion. r? `@oli-obk`
2022-06-16diagnostics: fix trailing spaceklensy-1/+1
2022-06-15[RFC 2011] Expand expressions where possibleCaio-0/+42
2022-06-15[RFC 2011] Minimal initial implementationCaio-15/+379
2022-06-13Move testsCaio-0/+26
2022-06-07Stabilize $$ in Rust 1.63.0Caio-55/+19
2022-06-02Bless tests.Camille GILLOT-16/+1
2022-05-23Rollup merge of #97254 - jhpratt:remove-crate-vis, r=cjgillotDylan DPC-3/+1
Remove feature: `crate` visibility modifier FCP completed in #53120.
2022-05-22Add test of temporaries inside format_args of core/std macrosDavid Tolnay-0/+70
2022-05-22Rollup merge of #97043 - c410-f3r:z-errors, r=petrochenkovJack Huey-0/+17
Move some tests to more reasonable directories r? `@petrochenkov`
2022-05-21Remove feature: `crate` visibility modifierJacob Pratt-3/+1
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-10/+9
2022-05-20Move testsCaio-0/+17
2022-05-13Rollup merge of #96948 - ludfo774:macro-trailing-comma-test, r=joshtriplettMatthias Krüger-0/+6
Add test of matches macro for trailing commas Almost all macros are tested for trailing commas. The macro matches! was however not tested. This PR adds that test case. Related to #46238
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-1/+10
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-11Add test of matches macro for trailing commasludfo774-0/+6
2022-05-08Move some tests to more reasonable placesCaio-0/+21
2022-05-05Allow unused rules in the testsuite where the lint triggersest31-1/+10
2022-05-03Tweak wordingEsteban Kuber-2/+2
2022-05-03When suggesting to import an item, also suggest changing the path if appropriateEsteban Küber-1/+6
When we don't find an item we search all of them for an appropriate import and suggest `use`ing it. This is sometimes done for expressions that have paths with more than one segment. We now also suggest changing that path to work with the `use`. Fix #95413
2022-05-01Move some tests to more reasonable placesCaio-0/+13
2022-04-27Make [e]println macros eagerly drop temporaries (for backport)David Tolnay-1/+1
2022-04-21Move some tests to more reasonable directoriesCaio-0/+28
2022-04-16Auto merge of #92364 - jackh726:Quantumplation/65853/param-heuristics, ↵bors-1/+11
r=estebank Better method call error messages Rebase/continuation of #71827 ~Based on #92360~ ~Based on #93118~ There's a decent description in #71827 that I won't copy here (for now at least) In addition to rebasing, I've tried to restore most of the original suggestions for invalid arguments. Unfortunately, this does make some of the errors a bit verbose. To fix this will require a bit of refactoring to some of the generalized error suggestion functions, and I just don't have the time to go into it right now. I think this is in a state that the error messages are overall better than before without a reduction in the suggestions given. ~I've tried to split out some of the easier and self-contained changes into separate commits (mostly in #92360, but also one here). There might be more than can be done here, but again just lacking time.~ r? `@estebank` as the original reviewer of #71827
2022-04-16Implementation for 65853Jack Huey-1/+11
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear.
2022-04-15Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwcoDylan DPC-30/+29
Stabilize `derive_default_enum` This stabilizes `#![feature(derive_default_enum)]`, as proposed in [RFC 3107](https://github.com/rust-lang/rfcs/pull/3107) and tracked in #87517. In short, it permits you to `#[derive(Default)]` on `enum`s, indicating what the default should be by placing a `#[default]` attribute on the desired variant (which must be a unit variant in the interest of forward compatibility). ```````@rustbot``````` label +S-waiting-on-review +T-lang
2022-04-09expand: Remove `ParseSess::missing_fragment_specifiers`Vadim Petrochenkov-7/+102
It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.
2022-04-07Stabilize `derive_default_enum`Jacob Pratt-30/+29
2022-04-07[macro_metavar_expr] Add tests to ensure the feature requirementCaio-1/+117
2022-04-01Fix `thread_local!` macro to be compatible with `no_implicit_prelude`niluxv-0/+8
Fixes issue #95533
2022-03-30Clarify comments about doc comments in macros.Nicholas Nethercote-2/+3
2022-03-28Ignore doc comments in a declarative macro matcher.Nicholas Nethercote-0/+13
Fixes #95267. Reverts to the old behaviour before #95159 introduced a regression.
2022-03-16Rollup merge of #94868 - dtolnay:noblock, r=Dylan-DPCDylan DPC-1/+1
Format core and std macro rules, removing needless surrounding blocks Many of the asserting and printing macros in `core` and `std` are written with prehistoric-looking formatting, like this: https://github.com/rust-lang/rust/blob/335ffbfa547df94ac236f5c56130cecf99c8d82b/library/std/src/macros.rs#L96-L101 In modern Rust style this would conventionally be written as follows instead, always using braces and a trailing semicolon on the macro arms: https://github.com/rust-lang/rust/blob/af53809c874e0afb7be966df4d3cfcaa05277c53/library/std/src/macros.rs#L98-L105 Getting rid of the unneeded braces inside the expansion reduces extraneous indentation in macro-expanded code. For example: ```rust println!("repro {}", true); ``` ```rust // before: { ::std::io::_print( ::core::fmt::Arguments::new_v1( &["repro ", "\n"], &[::core::fmt::ArgumentV1::new_display(&true)], ), ); }; ``` ```rust // after: ::std::io::_print( ::core::fmt::Arguments::new_v1( &["repro ", "\n"], &[::core::fmt::ArgumentV1::new_display(&true)], ), ); ```
2022-03-11Format core and std macro rules, removing needless surrounding blocksDavid Tolnay-1/+1
2022-03-11Implement macro meta-variable expressionCaio-83/+689
2022-03-10Rollup merge of #94368 - c410-f3r:metaaaaaaaaaaaaaaaaaaaaaaaaaaa, r=petrochenkovDylan DPC-0/+578
[1/2] Implement macro meta-variable expressions See https://github.com/rust-lang/rust/pull/93545#issuecomment-1050963295 The logic behind `length`, `index` and `count` was removed but the parsing code is still present, i.e., everything is simply ignored like `ignored`. r? ``@petrochenkov``
2022-03-09Permit `#[deprecated]` in stdlibJacob Pratt-2/+2
2022-03-09Implement macro meta-variable expressionsCaio-0/+578
2022-03-04Change `rustc_deprecated` to use `note`Jacob Pratt-6/+6
This keeps `reason` around for the time being. This is necessary to avoid breakage during the bootstrap process. This change, as a whole, brings `#[rustc_deprecated]` more in line with `#[deprecated]`.
2022-03-03Cleanup feature gates.Camille GILLOT-14/+13
2022-02-07Auto merge of #93179 - Urgau:unreachable-2021, r=m-ou-se,oli-obkbors-0/+70
Fix invalid special casing of the unreachable! macro This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro. ~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC #2795 mentioned this as a future possibility. This feature is [required](https://github.com/rust-lang/rust/issues/92137#issuecomment-1018630522) because of concatenation that needs to be done inside the macro:~~ ```rust $crate::concat!("internal error: entered unreachable code: ", $fmt) ``` **In summary** the new behavior for the `unreachable!` macro with this pr is: Edition 2021: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is 5 ``` Edition <= 2018: ```rust let x = 5; unreachable!("x is {x}"); ``` ``` internal error: entered unreachable code: x is {x} ``` Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](https://github.com/rust-lang/rust/issues/92137#issuecomment-998441613). If someone could start a perf run and then a crater run this would be appreciated. Fixes https://github.com/rust-lang/rust/issues/92137
2022-02-03Bless all pretty printer tests and ui testsDavid Tolnay-10/+10
2022-01-31Take in account the unreachable! macro in the non_fmt_panic lintLoïc BRANSTETT-0/+31