248 Commits

Author SHA1 Message Date
Sasha Pourcelot
a8e9ca195e Use attribute name in message for "outer attr used as inner attr" errors 2025-08-25 21:31:04 +02:00
Jana Dönszelmann
48a4e2d2dd
fix ICE on stable related to attrs on macros 2025-08-24 09:20:57 +02:00
Jana Dönszelmann
59ceb02d65
Port crate name to the new attribute system 2025-08-24 09:20:57 +02:00
Jana Dönszelmann
4b35cde904
Support lints in early attribute parsing 2025-08-24 09:14:49 +02:00
Jana Dönszelmann
3bf6144461
Allow errors to be emitted as fatal during attribute parsing 2025-08-24 09:14:49 +02:00
Jana Dönszelmann
1c03ae19db
port attribute to the new parsing infrastructure 2025-08-23 12:31:07 +02:00
Jacob Pratt
87f49e4434
Rollup merge of #145762 - jdonszelmann:attrs-strings-to-symbols, r=lqd
convert strings to symbols in attr diagnostics

r? `@lcnr`

As you rightfully noticed in https://github.com/rust-lang/rust/pull/145670
2025-08-22 22:01:01 -04:00
Jacob Pratt
45d5109ad8
Rollup merge of #145573 - veluca93:unsafe-force-target-feature, r=davidtwco
Add an experimental unsafe(force_target_feature) attribute.

This uses the feature gate for https://github.com/rust-lang/rust/issues/143352, but is described in https://github.com/rust-lang/rfcs/pull/3820 which is strongly tied to the experiment.
2025-08-22 22:00:51 -04:00
Jana Dönszelmann
f6ac728aad
convert strings to symbols in attr diagnostics 2025-08-22 22:30:00 +02:00
Jonathan Brouwer
17e34f6b24
Use the new attribute parser throughout the codebase 2025-08-22 08:58:45 +02:00
Jonathan Brouwer
549314bdb7
Rewrite the new attribute parser 2025-08-22 08:38:37 +02:00
Jonathan Brouwer
21d3189779
Move validate_attr to rustc_attr_parsing 2025-08-22 08:37:19 +02:00
Luca Versari
291da71b2a Add an experimental unsafe(force_target_feature) attribute.
This uses the feature gate for
https://github.com/rust-lang/rust/issues/143352, but is described in
https://github.com/rust-lang/rfcs/pull/3820 which is strongly tied to
the experiment.
2025-08-22 01:26:26 +02:00
Jana Dönszelmann
becefdda36
split up context.rs 2025-08-21 13:15:30 +02:00
Jana Dönszelmann
9da854115f
Introduce a prelude for very common imports across dozens of files 2025-08-21 13:15:30 +02:00
Jana Dönszelmann
2158e2d4d7
refactor target checking, move out of context.rs and rename MaybeWarn to Policy 2025-08-21 13:15:30 +02:00
bors
f605b57042 Auto merge of #145601 - jieyouxu:rollup-t5mbqhc, r=jieyouxu
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#145538 (bufreader::Buffer::backshift: don't move the uninit bytes)
 - rust-lang/rust#145542 (triagebot: Don't warn no-mentions on subtree updates)
 - rust-lang/rust#145549 (Update rust maintainers in openharmony.md)
 - rust-lang/rust#145550 (Avoid using `()` in `derive(From)` output.)
 - rust-lang/rust#145556 (Allow stability attributes on extern crates)
 - rust-lang/rust#145560 (Remove unused `PartialOrd`/`Ord` from bootstrap)
 - rust-lang/rust#145568 (ignore frontmatters in `TokenStream::new`)
 - rust-lang/rust#145571 (remove myself from some adhoc-groups and pings)
 - rust-lang/rust#145576 (Add change tracker entry for `--timings`)
 - rust-lang/rust#145578 (Add VEXos "linked files" support to `armv7a-vex-v5`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-19 23:52:06 +00:00
许杰友 Jieyou Xu (Joe)
95615916b1
Rollup merge of #145556 - JonathanBrouwer:extern-crate-stable, r=jdonszelmann
Allow stability attributes on extern crates

Fixes https://github.com/rust-lang/rust/issues/145497

r? ``@jdonszelmann``
2025-08-19 19:50:03 +08:00
许杰友 Jieyou Xu (Joe)
758866d48b
Rollup merge of #145500 - JonathanBrouwer:must_use_target, r=jdonszelmann
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-19 19:45:36 +08:00
Jonathan Brouwer
c1c204d707
Port must_use to the new target checking 2025-08-19 09:03:50 +02:00
Jonathan Brouwer
f0addd040a
Make tool-only suggestion to remove attributes on invalid targets 2025-08-19 09:03:07 +02:00
Stuart Cook
11c6d898b6
Rollup merge of #145243 - jdonszelmann:inner-attr-errors, r=petrochenkov
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-19 14:18:23 +10:00
Jonathan Brouwer
d4175033f0
Allow stability attributes on extern crates 2025-08-18 10:05:11 +02:00
Stuart Cook
ab57f43bc8
Rollup merge of #145485 - JonathanBrouwer:fix-deprecation-targets, r=jdonszelmann
Fix deprecation attributes on foreign statics

r? ````````@jdonszelmann````````

Fixes https://github.com/rust-lang/rust/issues/145437
2025-08-18 15:31:15 +10:00
Jana Dönszelmann
70e26c1b7b
take attr style into account in attr diagnostics 2025-08-16 10:51:09 +02:00
Jonathan Brouwer
a69ba29a0f
Fix deprecation attribute on foreign statics & types 2025-08-16 09:44:43 +02:00
Jonathan Brouwer
e8f90b12fc
Don't show foreign types as an allowed target if the feature is not enabled 2025-08-16 09:44:39 +02:00
Sasha Pourcelot
51bccdd1ab Port #[custom_mir(..)] to the new attribute system 2025-08-15 11:19:29 +02:00
Jonathan Brouwer
35e04b67a6
Specify the list of allowed targets per attribute 2025-08-14 18:18:22 +02:00
Jonathan Brouwer
744d39ebe6
Allow attribute parsers to specify a list of allowed targets
Every acceptor gets an `ALLOWED_TARGETS` specification which can specify per target whether it is allowed, warned, or errored.
2025-08-14 18:11:56 +02:00
Jonathan Brouwer
e7ef23e90e
Pass the target type down to parse_attribute_list 2025-08-14 18:11:56 +02:00
Sasha Pourcelot
d435197afc Port the #[linkage] attribute to the new attribute system 2025-08-13 21:01:37 +02:00
Stuart Cook
d862ae2fce
Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmann
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-12 20:37:53 +10:00
Esteban Küber
adccb8d214 Rework NameValueStr 2025-08-11 17:02:43 +00:00
Esteban Küber
32ee26c625 Add more docs to templates for attrs with incorrect arguments 2025-08-11 17:02:32 +00:00
Esteban Küber
6bb29af766 Add link to invalid repr error 2025-08-11 16:00:49 +00:00
Esteban Küber
189f264926 Allow attr entries to declare list of alternatives for List and 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-11 16:00:49 +00:00
Sasha Pourcelot
6603fe1caa Port #[allow_internal_unsafe] to the new attribute system (attempt 2) 2025-08-11 15:01:52 +02:00
Jana Dönszelmann
866bc26475
Revert "Port #[allow_internal_unsafe] to the new attribute system"
This reverts commit 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143.
2025-08-08 11:54:20 +02:00
Trevor Gross
8f519761a5
Rollup merge of #144857 - scrabsha:push-pwtyrnmqkrtr, r=jdonszelmann
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-07 19:36:35 -05:00
Sasha Pourcelot
4f7a6ace9e Port #[allow_internal_unsafe] to the new attribute system 2025-08-07 15:47:21 +02:00
Stuart Cook
995ca3e532
Rollup merge of #143808 - JonathanBrouwer:should_panic_parser, r=jdonszelmann
Port `#[should_panic]` to the new attribute parsing infrastructure

Ports `#[should_panic]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163

r? ```@jdonszelmann```
2025-08-07 20:49:40 +10:00
Jonathan Brouwer
f7ad4065fe
Port #[should_panic] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-06 21:37:51 +02:00
Guillaume Gomez
96a41c5aba
Rollup merge of #144794 - scrabsha:push-noqrrttovmwy, r=jdonszelmann
Port `#[coroutine]` to the new attribute system

Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367.

r? `````@jdonszelmann`````
2025-08-06 21:29:27 +02:00
Samuel Tardieu
149ee59876
Rollup merge of #144866 - JonathanBrouwer:should_emit_fix, r=jdonszelmann
Remove `SHOULD_EMIT_LINTS` in favor of `should_emit`

r? ``@jdonszelmann``
2025-08-05 03:51:37 +02:00
Sasha Pourcelot
904e2af3a9 Port #[coroutine] to the new attribute system
Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367.
2025-08-04 18:37:40 +02:00
Samuel Tardieu
3823f0bc07
Rollup merge of #144738 - bjorn3:remove_omit_gdb_pretty_printer_section, r=jieyouxu
Remove the omit_gdb_pretty_printer_section attribute

Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-08-03 21:56:56 +02:00
Jonathan Brouwer
f92934f43a
Remove SHOULD_EMIT_LINTS in favor of should_emit 2025-08-03 21:48:23 +02:00
bjorn3
ae2f8d9216 Remove the omit_gdb_pretty_printer_section attribute
Disabling loading of pretty printers in the debugger itself is more
reliable. Before this commit the .gdb_debug_scripts section couldn't be
included in dylibs or rlibs as otherwise there is no way to disable the
section anymore without recompiling the entire standard library.
2025-08-01 20:04:59 +00:00
Jonathan Brouwer
32cf3d48b3
Cleanup the definition of group_type
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-01 17:08:02 +02:00