about summary refs log tree commit diff
path: root/tests/ui/attributes
AgeCommit message (Collapse)AuthorLines
2025-10-02Rollup merge of #146535 - joshtriplett:mbe-unsafe-attr, r=petrochenkovMatthias Krüger-10/+6
mbe: Implement `unsafe` attribute rules This implements `unsafe attr` rules for declarative `macro_rules!` attributes, as specified in [RFC 3697](https://github.com/rust-lang/rfcs/pull/3697). An invocation of an attribute that uses an `unsafe attr` rule requires the `unsafe(attr(...))` syntax. An invocation of an attribute that uses an ordinary `attr` rule must *not* use the `unsafe(attr(...))` syntax. `unsafe` is only supported on an `attr` rule, not any other kind of `macro_rules!` rule. Tracking issue for `macro_rules!` attributes: https://github.com/rust-lang/rust/issues/143547
2025-10-01mbe: Support `unsafe` attribute rulesJosh Triplett-10/+6
2025-09-27improve empty attribute diagnosticJana Dönszelmann-0/+1
2025-09-26Rollup merge of #147058 - GuillaumeGomez:ignore-more-ui-tests, r=KobzolMatthias Krüger-0/+2
Ignore more failing ui tests for GCC backend Needed for https://github.com/rust-lang/rust/pull/146414. r? ``@Kobzol``
2025-09-26Ignore more failing ui tests for GCC backendGuillaume Gomez-0/+2
2025-09-21port `#[debugger_visualizer]` to the new attribute systemJana Dönszelmann-32/+24
2025-09-21Changes to uitests for macro_export portJonathan Brouwer-28/+141
Co-authored-by: Anne Stijns <anstijns@gmail.com>
2025-09-13Rollup merge of #146389 - jdonszelmann:no-std, r=oli-obkJana Dönszelmann-0/+111
Convert `no_std` and `no_core` to the new attribute infrastructure r? ```@oli-obk``` Also added a test for these, since we didn't have any and I was kind of surprised new diagnostics didn't break anything hehe
2025-09-10fixup no_{core,std} handling codeJana Dönszelmann-0/+111
2025-09-09allow `#[rustc_align_static(N)]` on `static`sFolkert de Vries-0/+62
We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.
2025-08-29compiler: Add `{x86_64,aarch64,riscv64gc}-unknown-managarm-mlibc` targetsno92-0/+1
Co-authored-by: Dennis Bonke <dennis@managarm.org>
2025-08-27Changes to the uitestsJonathan Brouwer-77/+73
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-27Auto merge of #144841 - cjgillot:typeck-no-attrs, r=davidtwcobors-0/+27
Access less HIR attributes from typeck Typeck relies on attributes to modify its own behaviour. This is a problem, as this means that `typeck(some function)` may depend on the span and doc-comments of many other functions. This PR attempts to reduce such accesses to attributes. This yields to a sizeable perf improvement: https://github.com/rust-lang/rust/pull/144841#issuecomment-3153339771 Fixes https://github.com/rust-lang/rust/issues/124352
2025-08-26Rollup merge of #145792 - scrabsha:push-umpytyxunpxq, r=jdonszelmannSamuel Tardieu-0/+36
Use attribute name in message for "outer attr used as inner attr" errors
2025-08-25Use attribute name in message for "outer attr used as inner attr" errorsSasha Pourcelot-0/+36
2025-08-24Regression test for attributes on macro callsJonathan Brouwer-0/+278
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-24Port crate name to the new attribute systemJana Dönszelmann-18/+14
2025-08-23port attribute to the new parsing infrastructureJana Dönszelmann-18/+18
2025-08-22Updated uitests for new parserJonathan Brouwer-43/+41
2025-08-21refactor target checking, move out of context.rs and rename MaybeWarn to PolicyJana Dönszelmann-6/+6
2025-08-20Rollup merge of #140794 - karolzwolak:allow-unused-doc-65464, r=davidtwcoJacob Pratt-17/+17
mention lint group in default level lint note ### Summary This PR updates lint diagnostics so that default-level notes now mention the lint group they belong to, if any. Fixes: rust-lang/rust#65464. ### Example ```rust fn main() { let x = 5; } ``` Before: ``` = note: `#[warn(unused_variables)]` on by default ``` After: ``` = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default ``` ### Unchanged Cases Messages remain the same when the lint level is explicitly set, e.g.: * Attribute on the lint `#[warn(unused_variables)]`: ``` note: the lint level is defined here LL | #[warn(unused_variables)] | ^^^^^^^^^^^^^^^^ ``` * Attribute on the group `#[warn(unused)]:`: ``` = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` ``` * CLI option `-W unused`: ``` = note: `-W unused-variables` implied by `-W unused` = help: to override `-W unused` add `#[allow(unused_variables)]` ``` * CLI option `-W unused-variables`: ``` = note: requested on the command line with `-W unused-variables` ```
2025-08-19bless tests with new lint messagesKarol Zwolak-17/+17
2025-08-19Auto merge of #145600 - jieyouxu:rollup-jw0bpnt, r=jieyouxubors-0/+1
Rollup of 15 pull requests Successful merges: - rust-lang/rust#145338 (actually provide the correct args to coroutine witnesses) - rust-lang/rust#145429 (Couple of codegen_fn_attrs improvements) - rust-lang/rust#145452 (Do not strip binaries in bootstrap everytime if they are unchanged) - rust-lang/rust#145464 (Stabilize `const_pathbuf_osstring_new` feature) - rust-lang/rust#145474 (Properly recover from parenthesized use-bounds (precise capturing lists) plus small cleanups) - rust-lang/rust#145486 (Fix `unicode_data.rs` mention message) - rust-lang/rust#145490 (Trace some basic I/O operations in bootstrap) - rust-lang/rust#145493 (remove `should_render` in `PrintAttribute` derive) - rust-lang/rust#145500 (Port must_use to the new target checking) - rust-lang/rust#145505 (Simplify span caches) - rust-lang/rust#145510 (Visit and print async_fut local for async drop.) - rust-lang/rust#145511 (Rust build fails on OpenBSD after using file_lock feature) - rust-lang/rust#145532 (resolve: debug for block module) - rust-lang/rust#145533 (Reorder `lto` options from most to least optimizing) - rust-lang/rust#145537 (Do not consider a `T: !Sized` candidate to satisfy a `T: !MetaSized` obligation.) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-19Rollup merge of #145500 - JonathanBrouwer:must_use_target, r=jdonszelmann许杰友 Jieyou Xu (Joe)-0/+1
Port must_use to the new target checking This PR ports `must_use` to the new target checking logic This also adds a tool-only suggestion to remove attributes on invalid targets, as to not immediately undo the work of https://github.com/rust-lang/rust/pull/145274 r? `@jdonszelmann`
2025-08-19Rollup merge of #144983 - Oneirical:uncountable-integer, r=jieyouxu许杰友 Jieyou Xu (Joe)-0/+107
Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` Part of rust-lang/rust#133895 Methodology: 1. Refer to the previously written `tests/ui/SUMMARY.md` 2. Find an appropriate category for the test, using the original issue thread and the test contents. 3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers) 4. Rename the tests to make their purpose clearer Inspired by the methodology that ``@Kivooeo`` was using. r? ``@jieyouxu``
2025-08-19Update uitestsJonathan Brouwer-0/+1
2025-08-19Rollup merge of #145243 - jdonszelmann:inner-attr-errors, r=petrochenkovStuart Cook-15/+11
take attr style into account in diagnostics when the original attribute was specified as an inner attribute, the suggestion will now match that attribute style
2025-08-18Remove the no_sanitize attribute in favor of sanitizeBastian Kersting-130/+17
This removes the #[no_sanitize] attribute, which was behind an unstable feature named no_sanitize. Instead, we introduce the sanitize attribute which is more powerful and allows to be extended in the future (instead of just focusing on turning sanitizers off). This also makes sanitize(kernel_address = ..) attribute work with -Zsanitize=address To do it the same as how clang disables address sanitizer, we now disable ASAN on sanitize(kernel_address = "off") and KASAN on sanitize(address = "off"). The same was added to clang in https://reviews.llvm.org/D44981.
2025-08-17Rehome tests/ui/issues/ tests [5/?]Oneirical-0/+107
2025-08-16take attr style into account in attr diagnosticsJana Dönszelmann-15/+11
2025-08-14Update uitestsJonathan Brouwer-245/+289
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-14Rollup merge of #145323 - scrabsha:push-pqwvmznzzmpr, r=jdonszelmannGuillaume Gomez-19/+18
Port the `#[linkage]` attribute to the new attribute system r? `@jdonszelmann`
2025-08-14Rollup merge of #145250 - fmease:regr-test-for-attr-meta-ice, r=jdonszelmannGuillaume Gomez-0/+28
Add regression test for a former ICE involving helper attributes containing interpolated tokens Add regression test for rust-lang/rust#140612 from rust-lang/rust#140601 or rather rust-lang/rust#140859 that only added it to `stable` not `master`. Supersedes https://github.com/rust-lang/rust/pull/140584. r? `@jdonszelmann` or anyone
2025-08-14Add regression test for a former ICE involving helper attributes containing ↵León Orell Valerian Liehr-0/+28
interpolated tokens Co-authored-by: Jana Dönszelmann <jana@donsz.nl>
2025-08-13Port the `#[linkage]` attribute to the new attribute systemSasha Pourcelot-19/+18
2025-08-12Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmannStuart Cook-58/+273
Tweak invalid builtin attribute output - Add link to reference/docs when possible - More accurate suggestions by supporting multiple alternative suggestions ``` error: malformed `crate_type` attribute input --> $DIR/crate-type-macro-call.rs:1:1 | LL | #![crate_type = foo!()] | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/reference/linkage.html> help: the following are the possible correct uses | LL - #![crate_type = foo!()] LL + #![crate_type = "bin"] | LL - #![crate_type = foo!()] LL + #![crate_type = "cdylib"] | LL - #![crate_type = foo!()] LL + #![crate_type = "dylib"] | LL - #![crate_type = foo!()] LL + #![crate_type = "lib"] | = and 4 other candidates ```
2025-08-11Add more docs to templates for attrs with incorrect argumentsEsteban Küber-12/+42
2025-08-11fix testsEsteban Küber-5/+8
2025-08-11Add link to invalid `repr` errorEsteban Küber-0/+1
2025-08-11Add link to docs on malformed attributesEsteban Küber-0/+24
2025-08-11Allow attr entries to declare list of alternatives for `List` and ↵Esteban Küber-41/+198
`NamedValueStr` Modify `AttributeTemplate` to support list of alternatives for list and name value attribute styles. Suggestions now provide more correct suggested code: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler)] | LL - #[used(compiler, linker)] LL + #[used(linker)] | LL - #[used(compiler, linker)] LL + #[used] | ``` instead of the prior "masking" of the lack of this feature by suggesting pipe-separated lists: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler|linker)] | LL - #[used(compiler, linker)] LL + #[used] | ```
2025-08-11Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2)Sasha Pourcelot-6/+9
2025-08-10Start reporting future breakage for `ILL_FORMED_ATTRIBUTE_INPUT` in dependenciesJonathan Brouwer-0/+77
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-09Auto merge of #145086 - jdonszelmann:revert-allow-internal-unsafe, r=Kobzolbors-9/+6
Revert "Port `#[allow_internal_unsafe]` to the new attribute system" This reverts commit 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143 (PR: https://github.com/rust-lang/rust/pull/144857) r? `@Kobzol` cc: `@scrabsha` clean revert it seems :3
2025-08-08Rollup merge of #144039 - estebank:short-paths, r=fee1-deadTrevor Gross-3/+3
Use `tcx.short_string()` in more diagnostics `TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem).
2025-08-08Revert "Port `#[allow_internal_unsafe]` to the new attribute system"Jana Dönszelmann-9/+6
This reverts commit 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143.
2025-08-07Rollup merge of #144857 - scrabsha:push-pwtyrnmqkrtr, r=jdonszelmannTrevor Gross-6/+9
Port `#[allow_internal_unsafe]` to the new attribute system Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367. r? ````@jdonszelmann````
2025-08-07Use `tcx.short_string()` in more diagnosticsEsteban Küber-3/+3
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem). When we don't actually print out a shortened type we don't need the "use `--verbose`" note. On E0599 show type identity to avoid expanding the receiver's generic parameters. Unify wording on `long_ty_path` everywhere.
2025-08-07Port `#[allow_internal_unsafe]` to the new attribute systemSasha Pourcelot-6/+9
2025-08-07Rollup merge of #143929 - petrochenkov:depresolve, r=lcnrStuart Cook-14/+86
Mark all deprecation lints in name resolution as deny-by-default and report-in-deps This affects the next lints: - `MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS` - https://github.com/rust-lang/rust/issues/144408 - `LEGACY_DERIVE_HELPERS` - https://github.com/rust-lang/rust/issues/79202 - `PRIVATE_MACRO_USE` - https://github.com/rust-lang/rust/issues/120192 - `OUT_OF_SCOPE_MACRO_CALLS` - https://github.com/rust-lang/rust/issues/144406