about summary refs log tree commit diff
path: root/tests/ui/macros
AgeCommit message (Collapse)AuthorLines
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>
2024-08-18stabilize raw_ref_opRalf Jung-1/+0
2024-08-16Fix wrong source location for some incorrect macro definitionsWafarm-6/+6
2024-08-16Overhaul token collection.Nicholas Nethercote-16/+8
This commit does the following. - Renames `collect_tokens_trailing_token` as `collect_tokens`, because (a) it's annoying long, and (b) the `_trailing_token` bit is less accurate now that its types have changed. - In `collect_tokens`, adds a `Option<CollectPos>` argument and a `UsePreAttrPos` in the return type of `f`. These are used in `parse_expr_force_collect` (for vanilla expressions) and in `parse_stmt_without_recovery` (for two different cases of expression statements). Together these ensure are enough to fix all the problems with token collection and assoc expressions. The changes to the `stringify.rs` test demonstrate some of these. - Adds a new test. The code in this test was causing an assertion failure prior to this commit, due to an invalid `NodeRange`. The extra complexity is annoying, but necessary to fix the existing problems.
2024-08-16Add some attribute `stringify!` tests.Nicholas Nethercote-2/+53
A couple of these are marked `FIXME` because they demonstrate existing bugs with token collection.
2024-07-31Rollup merge of #126697 - vincenzopalazzo:macros/find_the_expression_tok, ↵Matthias Krüger-0/+73
r=eholk,compiler-errors [RFC] mbe: consider the `_` in 2024 an expression This commit is adding the possibility to parse the `_` as an expression inside the esition 2024. Link: https://rust-lang.zulipchat.com/#narrow/stream/404510-wg-macros/topic/supporting.20.60_.60.20expressions Issue https://github.com/rust-lang/rust/issues/123742 r? `@eholk`
2024-07-31tests: add the _ as expr test for cargo fixVincenzo Palazzo-2/+2
Co-authored-by: Eric Holk <eric@theincredibleholk.org> Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>