summary refs log tree commit diff
path: root/src/test/ui/macros
AgeCommit message (Collapse)AuthorLines
2021-05-03Remove assert_matches usersMark Rousskov-11/+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
2020-12-31Auto merge of #80459 - mark-i-m:or-pat-reg, r=petrochenkovbors-0/+14
Implement edition-based macro :pat feature This PR does two things: 1. Fixes the perf regression from https://github.com/rust-lang/rust/pull/80100#issuecomment-750893149 2. Implements `:pat2018` and `:pat2021` matchers, as described by `@joshtriplett` in https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090 behind the feature gate `edition_macro_pat`. r? `@petrochenkov` cc `@Mark-Simulacrum`
2020-12-30Implement edition-based macro pat featuremark-0/+14
2020-12-29Remove `compile-fail` test suiteVadim Petrochenkov-38/+71
2020-12-22Revert "Promote missing_fragment_specifier to hard error"Wesley Wiser-0/+10
This reverts commit 02eae432e7476a0686633a8c2b7cb1d5aab1bd2c.
2020-12-19implement edition-specific :pat behavior for 2015/18mark-13/+18
2020-12-09Accept arbitrary expressions in key-value attributes at parse timeVadim Petrochenkov-3/+3
2020-12-02Tweak diagnostics on shadowing lifetimes/labelsYuki Okushi-1/+1
2020-11-29Update tests to remove old numeric constantsbstrie-1/+1
Part of #68490. Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros. For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.
2020-11-26Fix new 'unnecessary trailing semicolon' warningsAaron Hill-2/+2
2020-11-23Qualify `panic!` as `core::panic!` in non-built-in `core` macrosCamelid-0/+13
Otherwise code like this #![no_implicit_prelude] fn main() { ::std::todo!(); ::std::unimplemented!(); } will fail to compile, which is unfortunate and presumably unintended. This changes many invocations of `panic!` in a `macro_rules!` definition to invocations of `$crate::panic!`, which makes the invocations hygienic. Note that this does not make the built-in macro `assert!` hygienic.
2020-10-19Ignore panic_fmt lint in macro-comma-behavior-rpass ui test.Mara Bos-0/+1
2020-11-09add regression test for #78892SNCPlay42-0/+14
2020-11-02Treat trailing semicolon as a statement in macro callAaron Hill-0/+27
See https://github.com/rust-lang/rust/issues/61733#issuecomment-716188981 We now preserve the trailing semicolon in a macro invocation, even if the macro expands to nothing. As a result, the following code no longer compiles: ```rust macro_rules! empty { () => { } } fn foo() -> bool { //~ ERROR mismatched { true } //~ ERROR mismatched empty!(); } ``` Previously, `{ true }` would be considered the trailing expression, even though there's a semicolon in `empty!();` This makes macro expansion more token-based.
2020-10-25Rollup merge of #77984 - Aaron1011:fix/macro-mod-weird-parent, r=petrochenkovYuki Okushi-0/+25
Compute proper module parent during resolution Fixes #75982 The direct parent of a module may not be a module (e.g. `const _: () = { #[path = "foo.rs"] mod foo; };`). To find the parent of a module for purposes of resolution, we need to walk up the tree until we hit a module or a crate root.
2020-10-24Rollup merge of #78327 - petrochenkov:inconsist, r=Aaron1011Jonas Schievink-0/+25
resolve: Relax macro resolution consistency check to account for any errors The check was previously omitted only when ambiguity errors or `Res::Err` were encountered, but the "macro-expanded `extern crate` items cannot shadow..." error (at least) can cause same inconsistencies as well. Fixes https://github.com/rust-lang/rust/issues/78325
2020-10-24Compute proper module parent during resolutionAaron Hill-0/+25
Fixes #75982 The direct parent of a module may not be a module (e.g. `const _: () = { #[path = "foo.rs"] mod foo; };`). To find the parent of a module for purposes of resolution, we need to walk up the tree until we hit a module or a crate root.
2020-10-24resolve: Relax macro resolution consistency check to account for any errorsVadim Petrochenkov-0/+25
2020-10-24Rollup merge of #78264 - JohnTitor:macro-test, r=petrochenkovJonas Schievink-0/+10
Add regression test for issue-77475 Closes #77475
2020-10-23Auto merge of #77015 - davidtwco:check-attr-variant-closure-expr, r=lcnrbors-17/+1
passes: `check_attr` on more targets This PR modifies `check_attr` so that: - Enum variants are now checked (some attributes would not have been prohibited on variants previously). - `check_expr_attributes` and `check_stmt_attributes` are removed as `check_attributes` can perform the same checks. This means that codegen attribute errors aren't shown if there are other errors first (e.g. from other attributes, as shown in `src/test/ui/macros/issue-68060.rs` changes below).
2020-10-23Add regression test for issue-77475Yuki Okushi-0/+10
2020-09-30Re-run tests with --blessTemirkhan Myrzamadi-0/+3
2020-09-28passes: `check_attr` on more targetsDavid Wood-17/+1
This commit modifies `check_attr` so that: - Enum variants are now checked (some attributes would not have been prohibited on variants previously). - `check_expr_attributes` and `check_stmt_attributes` are removed as `check_attributes` can perform the same checks. Signed-off-by: David Wood <david@davidtw.co>
2020-09-21Record `tcx.def_span` instead of `item.span` in crate metadataAaron Hill-8/+4
This was missed in PR #75465. As a result, a few places have been using the full body span of functions, instead of just the header span.
2020-09-12Auto merge of #73461 - calebzulawski:validate-attribute-placement, ↵bors-11/+9
r=matthewjasper Validate built-in attribute placement Closes #54584, closes #47725, closes #54044. I've changed silently ignoring some incorrectly placed attributes to errors. I'm not sure what the policy is since this can theoretically break code (should they be warnings instead? does it warrant a crater run?).
2020-09-09Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasperTyler Mandry-14/+14
Improve unresolved use error message "use of undeclared type or module `foo`" doesn't mention that it could be a crate. This error can happen when users forget to add a dependency to `Cargo.toml`, so I think it's important to mention that it could be a missing crate. I've used a heuristic based on Rust's naming conventions. It complains about an unknown type if the ident starts with an upper-case letter, and crate or module otherwise. It seems to work very well. The expanded error help covers both an unknown type and a missing crate case.
2020-09-08Update testsGuillaume Gomez-1/+2
2020-09-05Allow #[cold], #[track_caller] on closures. Fix whitespace in error messages.Caleb Zulawski-15/+3
2020-09-05Emit warnings for misplaced attributes used by some cratesCaleb Zulawski-1/+4
2020-09-05Check placement of more attributesCaleb Zulawski-11/+18
2020-09-02Auto merge of #76160 - scileo:format-recovery, r=petrochenkovbors-2/+2
Improve recovery on malformed format call The token following a format expression should be a comma. However, when it is replaced with a similar token (such as a dot), then the corresponding error is emitted, but the token is treated as a comma, and the parsing step continues. r? @petrochenkov
2020-09-02Improve recovery on malformed format callSasha-2/+2
If a comma in a format call is replaced with a similar token, then we emit an error and continue parsing, instead of stopping at this point.