about summary refs log tree commit diff
path: root/tests/ui/macros
AgeCommit message (Collapse)AuthorLines
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-90/+135
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-06Remove some unnecessary parens in `assert!` conditionsEsteban Küber-2/+2
While working on #122661, some of these started triggering our "unnecessary parens" lints due to a change in the `assert!` desugaring. A cursory search identified a few more. Some of these have been carried from before 1.0, were a bulk rename from the previous name of `assert!` left them in that state. I went and removed as many of these unnecessary parens as possible in order to have fewer annoyances in the future if we make the lint smarter.
2025-02-04Rename and Move some UI tests to more suitable subdirsDuskyElf-0/+35
2025-01-25Auto merge of #133154 - estebank:issue-133137, r=wesleywiserbors-18/+23
Reword resolve errors caused by likely missing crate in dep tree Reword label and add `help`: ``` error[E0432]: unresolved import `some_novel_crate` --> f704.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` | = help: if you wanted to use a crate named `some_novel_crate`, use `cargo add some_novel_crate` to add it to your `Cargo.toml` ``` Fix #133137.
2025-01-24Rollup merge of #135926 - jieyouxu:needs-subprocess-thread, r=oli-obkMatthias Krüger-21/+21
Implement `needs-subprocess` directive, and cleanup a bunch of tests to use `needs-{subprocess,threads}` ### Summary Closes #128295. - Implements `//@ needs-subprocess` directive in compiletest as requested in #128295. However, compiletest is a host tool, so we can't just try to spawn process because that spawns the process on *host*, not the *target*, under cross-compilation scenarios. - The short-term solution is to add *Yet Another* list of allow-list targets. - The long-term solution is to first check if a `$target` supports std, then try to run a binary to do run-time capability detection *on the target*. But that is tricky because you have to build-and-run a binary *for the target*. - This PR picks the short-term solution, because the long-term solution is highly non-trivial, and it's already an improvement over individual `ignore-*`s all over the place. - Opened an issue about the long-term solution in #135928. - Documents `//@ needs-subprocess` in rustc-dev-guide. - Replace `ignore-{wasm,wasm32,emscripten,sgx}` with `needs-{subprocess,threads}` where suitable in tests. - Some drive-by test changes as I was trying to figure out if I could use `needs-{subprocess,threads}` and found some bits needlessly distracting. Count of tests that use `ignore-{wasm,wasm32,emscripten,sgx}` before and after this PR: | State | `ignore-sgx` | `ignore-wasm` | `ignore-emscripten` | | - | - | - | - | | Before this PR | 96 | 88 | 207 | | After this PR | 36 | 38 | 61 | <details> <summary>Commands used to find out locally</summary> ``` --- before [17:40] Joe:rust (fresh) | rg --no-ignore -l "ignore-sgx" tests | wc -l 96 [17:40] Joe:rust (fresh) | rg --no-ignore -l "ignore-wasm" tests | wc -l 88 [17:40] Joe:rust (fresh) | rg --no-ignore -l "ignore-emscripten" tests | wc -l 207 --- after [17:39] Joe:rust (needs-subprocess-thread) | rg --no-ignore -l "ignore-sgx" tests | wc -l 36 [17:39] Joe:rust (needs-subprocess-thread) | rg --no-ignore -l "ignore-wasm" tests | wc -l 38 [17:39] Joe:rust (needs-subprocess-thread) | rg --no-ignore -l "ignore-emscripten" tests | wc -l 61 ``` </details> ### Review advice - Best reviewed commit-by-commit. - Non-trivial test changes (not mechanically simple replacements) are split into individual commits to help with review. Their individual commit messages give some basic description of the changes. - I *could* split some test changes out into another PR, but I found that I needed to change some tests to `needs-threads`, some to `needs-subprocess`, and some needed to use *both*, so they might conflict and become very annoying. --- r? ``@ghost`` (need to run try jobs) try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: i686-mingw try-job: x86_64-mingw-1 try-job: x86_64-apple-1 try-job: aarch64-apple try-job: aarch64-gnu try-job: test-various try-job: armhf-gnu
2025-01-24Reword "crate not found" resolve messageEsteban Küber-18/+23
``` error[E0432]: unresolved import `some_novel_crate` --> file.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` ``` On resolve errors where there might be a missing crate, mention `cargo add foo`: ``` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:4:11 | LL | impl From<nope::Thing> for Error { | ^^^^ use of unresolved module or unlinked crate `nope` | = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml` ```
2025-01-23tests: use `needs-subprocess` instead of `ignore-{wasm32,emscripten,sgx}`许杰友 Jieyou Xu (Joe)-21/+21
2025-01-23Bless and add testsBoxy-7/+0
2025-01-22Auto merge of #135896 - matthiaskrgr:rollup-g6rv7za, r=matthiaskrgrbors-3/+8
Rollup of 9 pull requests Successful merges: - #132983 (Edit dangling pointers ) - #135409 (Fix ICE-133117: multiple never-pattern arm doesn't have false_edge_start_block) - #135557 (Point at invalid utf-8 span on user's source code) - #135596 (Properly note when query stack is being cut off) - #135794 (Detect missing fields with default values and suggest `..`) - #135814 (ci: use ghcr buildkit image) - #135826 (Misc. `rustc_resolve` cleanups) - #135837 (Remove test panic from File::open) - #135856 (Library: Finalize dyn compatibility renaming) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-22Point at invalid utf-8 span on user's source codeEsteban Küber-3/+8
``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `[193]` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-21make UI tests that use `--test` work on panic=abort targetsJorge Aparicio-2/+6
by adding `-Zpanic_abort_test`, which is a no-op on panic=unwind targets fixes #135819
2025-01-15Treat safe target_feature functions as unsafe by defaultOli Scherer-10/+2
2025-01-08Rename PatKind::Lit to ExprOli Scherer-1/+1
2025-01-04Rollup merge of #135046 - RalfJung:rustc_box_intrinsic, r=compiler-errorsJubilee-7/+28
turn rustc_box into an intrinsic I am not entirely sure why this was made a special magic attribute, but an intrinsic seems like a more natural way to add magic expressions to the language.
2025-01-03Rollup merge of #135044 - compiler-errors:better-infer-suggestions-in-const, ↵Matthias Krüger-6/+3
r=oli-obk Improve infer (`_`) suggestions in `const`s and `static`s Fixes https://github.com/rust-lang/rust/issues/135010. This PR does a few things to (imo) greatly improve the error message when users write something like `static FOO: [i32; _] = [1, 2, 3]`. Firstly, it adapts the recovery code for when we encounter `_` in a const/static to work a bit more like `fn foo() -> _`, and removes the somewhat redundant query `diagnostic_only_typeck`. Secondly, it changes the lowering for `[T; _]` to always lower under the `feature(generic_arg_infer)` logic to `ConstArgKind::Infer`. We still issue the feature error, so it's not doing anything *observable* on the good path, but it does mean that we no longer erroneously interpret `[T; _]`'s array length as a `_` **wildcard expression** (à la destructuring assignment, like `(_, y) = expr`). Lastly it makes the suggestions verbose and fixes (well, suppresses) a bug with stashing and suggestions. r? oli-obk
2025-01-03turn rustc_box into an intrinsicRalf Jung-7/+28
2025-01-02Fix macro shenanigansMichael Goulet-6/+2
2025-01-02Make suggestion verbose and tweak error messageMichael Goulet-4/+5
2025-01-01Try to write the panic message with a single `write_all` callJohn Kåre Alsaker-0/+1
2024-12-27Rollup merge of #134759 - Zalathar:normalize, r=jieyouxu许杰友 Jieyou Xu (Joe)-1/+1
compiletest: Remove the `-test` suffix from normalize directives This suffix was an artifact of using the same condition-checking engine as the `ignore-*` and `only-*` directives, but in practice we have only 2 tests that legitimately use a condition, and both of them only care about 32-bit vs 64-bit. This PR detaches `normalize-*` directives from the condition checker, and replaces it with a much simpler system of four explicit `NormalizeKind` values. It then takes advantage of that simplicity to get rid of the `-test` suffix. --- Addresses one of the points of #126372. The new name-checking code is a bit quaint, but I think it's a definite improvement over the status quo. --- The corresponding dev-guide update is https://github.com/rust-lang/rustc-dev-guide/pull/2172. r? jieyouxu
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-1/+1
2024-12-26Rollup merge of #131522 - c410-f3r:unlock-rfc-2011, r=chenyukangJacob Pratt-2/+42
[macro_metavar_expr_concat] Fix #128346 Fix #128346 Fix #131393 The syntax is invalid in both issues so I guess that theoretically the compiler should have aborted early. This PR tries to fix a local problem but let me know if there are better options. cc `@petrochenkov` if you are interested
2024-12-21Use E0665 for missing `#[default]` errorEsteban Küber-29/+61
Use orphaned error code for the same error it belonged to before. ``` error[E0665]: `#[derive(Default)]` on enum with no `#[default]` --> $DIR/macros-nonfatal-errors.rs:42:10 | LL | #[derive(Default)] | ^^^^^^^ LL | / enum NoDeclaredDefault { LL | | Foo, LL | | Bar, LL | | } | |_- this enum needs a unit variant marked with `#[default]` | = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) help: make this unit variant default by placing `#[default]` on it | LL | #[default] Foo, | ~~~~~~~~~~~~~~ help: make this unit variant default by placing `#[default]` on it | LL | #[default] Bar, | ~~~~~~~~~~~~~~ ```
2024-12-15Add hir::AttributeJonathan Dönszelmann-3/+1
2024-12-13Stabilize async closuresMichael Goulet-1/+0
2024-12-01Fix #128346Caio-2/+42
2024-11-28Update more 2024 tests to remove -Zunstable-optionsEric Huss-16/+15
2024-11-27Update tests to use new proc-macro headerEric Huss-22/+6
2024-11-26tests: remove `//@ pretty-expanded` usages许杰友 Jieyou Xu (Joe)-8/+0
Done with ```bash sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs ``` and ``` sd '//@pretty-expanded.*\n' '' tests/ui/**/*.rs ```
2024-11-23Rollup merge of #132949 - clubby789:macro-rules-attr-derive, r=fmease许杰友 Jieyou Xu (Joe)-2/+53
Add specific diagnostic for using macro_rules macro as attribute/derive Fixes #132928
2024-11-22Stabilize the 2024 editionEric Huss-6/+6
2024-11-22Diagnostic for using macro_rules macro as attr/deriveclubby789-28/+18
2024-11-12Add test for using macro_rules macro as attribute/deriveclubby789-0/+61
2024-11-03use backticks instead of single quotes when reporting "use of unstable ↵dianne-7/+7
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-30Annotate `input` reference testsEric Huss-1/+3
2024-10-28Tweak more warnings.Nicholas Nethercote-69/+69
Much like the previous commit. I think the removal of "the token" in each message is fine here. There are many more error messages that mention tokens without saying "the token" than those that do say it.
2024-10-28Tweak `expand_incomplete_parse` warning.Nicholas Nethercote-17/+17
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-23"innermost", "outermost", "leftmost", and "rightmost" don't need hyphensJosh Triplett-21/+21
These are all standard dictionary words and don't require hyphenation.
2024-10-14Remove `'apostrophes'` from `rustc_parse_format`Lieselotte-2/+2
2024-10-14Rollup merge of #131430 - surechen:fix_130495, r=jieyouxuMatthias Krüger-0/+72
Special treatment empty tuple when suggest adding a string literal in format macro. For example: ```rust let s = "123"; println!({}, "sss", s); ``` Suggest: `println!("{:?} {} {}", {}, "sss", s);` fixes #130170
2024-10-14Special treatment empty tuple when suggest adding a string literal in format ↵surechen-0/+72
macro. For example: ```rust let s = "123"; println!({}, "sss", s); ``` Suggest: `println!("{:?} {} {}", {}, "sss", s);` fixes #130170
2024-10-04Rollup merge of #131034 - Urgau:cfg-true-false, r=nnethercoteGuillaume Gomez-3/+3
Implement RFC3695 Allow boolean literals as cfg predicates This PR implements https://github.com/rust-lang/rfcs/pull/3695: allow boolean literals as cfg predicates, i.e. `cfg(true)` and `cfg(false)`. r? `@nnethercote` *(or anyone with parser knowledge)* cc `@clubby789`
2024-10-04Improve non-boolean literal error in cfg predicateUrgau-2/+2
2024-10-01Use `ast::NestedMetaItem` when evaluating cfg predicateUrgau-3/+3
2024-10-01Stabilize expr_2021 fragment in all editionsEric Holk-56/+35
Co-authored-by: Michael Goulet <michael@errs.io> Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-09-23Rollup merge of #130551 - nnethercote:fix-break-last-token, r=petrochenkovJubilee-0/+16
Fix `break_last_token`. It currently doesn't handle the three-char tokens `>>=` and `<<=` correctly. These can be broken twice, resulting in three individual tokens. This is a latent bug that currently doesn't cause any problems, but does cause problems for #124141, because that PR increases the usage of lazy token streams. r? `@petrochenkov`
2024-09-23Fix `break_last_token`.Nicholas Nethercote-0/+16
It currently doesn't handle the three-char tokens `>>=` and `<<=` correctly. These can be broken twice, resulting in three individual tokens. This is a latent bug that currently doesn't cause any problems, but does cause problems for #124141, because that PR increases the usage of lazy token streams.
2024-09-18Add known-bug and update comments to describe correct behavior in light of bugEric Holk-6/+3
2024-09-17Add coverage for pat tooEric Holk-30/+45
In 2021 pat was changed to recognize `|` at the top level, with pat_param added to retain the old behavior. This means pat is subject to the same cross-edition behavior as expr will be in 2024. Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-09-17test: cross-edition metavar fragment specifiersVincenzo Palazzo-0/+40
There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. Co-Authored-By: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Co-Authored-By: Eric Holk <eric@theincredibleholk.org>