Commit Graph

273 Commits

Author SHA1 Message Date
Jacob Pratt 22f973db34 Rollup merge of #152568 - JonathanBrouwer:port_lang, r=jdonszelmann
Port `#[lang]` and `#[panic_handler]` to the new attribute parsers

For https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163

r? @jdonszelmann
2026-02-13 22:26:35 -05:00
Jonathan Brouwer c61c2603cf Port #[lang] to the new attribute parsers 2026-02-13 16:04:19 +00:00
Jonathan Brouwer 6eb2a8fa9e Reformat existing error messages 2026-02-09 19:12:22 +01:00
Jonathan Brouwer 99c6009c45 Reformat existing messages 2026-02-08 23:07:58 +01:00
Jonathan Brouwer ea43035654 Convert to inline diagnostics in rustc_passes 2026-02-06 13:31:54 +01:00
Jamie Hill-Daniel 522778e348 Move query-dep-graph opt check to attr parsing 2026-02-04 21:00:37 +00:00
Jamie Hill-Daniel 94a0ba50e1 Port rustc_clean to attribute parser
Also remove mentions of removed `rustc_dirty`
2026-02-04 20:58:02 +00:00
Jamie Hill-Daniel 72338fafb2 Port rustc_layout to attribute parser 2026-01-29 22:23:58 +00:00
mejrs a1e2cea685 Port do_not_recommend to new attr parsing 2026-01-13 20:43:37 +01:00
Jonathan Brouwer a2994063d4 Rollup merge of #150943 - port_must_not_suspend, r=jdonszelmann,JonathanBrouwer
Port `#[must_not_suspend]` to attribute parser

Tracking issue: rust-lang/rust#131229

r? @JonathanBrouwer
2026-01-13 09:01:31 +01:00
Jonathan Brouwer e33f5aa634 Rollup merge of #150934 - move-doc-attr-checks, r=JonathanBrouwer
Move some checks from `check_doc_attrs` directly into `rustc_attr_parsing`

Part of https://github.com/rust-lang/rust/issues/149865.

I also used this opportunity to remove the `id_is_crate_root` method.

Once this is merged, I think I'll try to see if we can remove `target_id` as well.

r? @JonathanBrouwer
2026-01-13 09:01:31 +01:00
Edvin Bryntesson 418cff3ec0 Port #[must_not_suspend] to attribute parser 2026-01-12 18:16:37 +01:00
Matthias Krüger d6621f07ae Rollup merge of #150938 - collapse_debuginfo, r=jdonszelmann
Port `#[collapse_debuginfo]` to the new attribute parsing system

Tracking issue: https://github.com/rust-lang/rust/issues/131229

Felt like doing one again, has been a while :3

r? @jdonszelmann
2026-01-12 00:02:54 +01:00
Guillaume Gomez ef1e4e65b7 Move checks from check_doc_attrs directly into rustc_attr_parsing 2026-01-11 18:36:03 +01:00
Jonathan Brouwer b5dd72d292 Port #[collapse_debuginfo] to the new attribute parsing system 2026-01-11 10:54:45 +01:00
Edvin Bryntesson 76fcac2371 Port #[rustc_has_incoherent_inherent_impls] to attribute parser 2026-01-10 23:58:03 +01:00
Edvin Bryntesson 94e16291e0 Port #[rustc_must_implement_one_of] to attribute parser 2025-12-26 19:08:21 +01:00
Edvin Bryntesson 120f0d4f07 Port #[thread_local] to attribute parser 2025-12-20 15:38:42 +01:00
Edvin Bryntesson 44cfed7465 Port #[rustc_lint_diagnostics] to attribute parser 2025-12-18 23:36:26 +01:00
Edvin Bryntesson fe34b17c2a Port #[rustc_lint_opt_deny_field_access] to attribute parser 2025-12-18 12:19:07 +01:00
Edvin Bryntesson 81d20363b3 Port #[rustc_lint_opt_ty] to parsed attribute 2025-12-17 18:23:49 +01:00
Jacob Pratt 656d4e8a96 Rollup merge of #150072 - Bryntet:parse_no_link, r=JonathanBrouwer
Port #[no_link] to use attribute parser

Adds `#[no_link]` to the attribute parser, as well as adds tests making sure to FCW warn on `field`, `arm`, and `macrodef `
2025-12-16 23:10:12 -05:00
Edvin Bryntesson 52bcaabdb8 Port #[no_link] to use attribute parser 2025-12-16 22:45:32 +01:00
Edvin Bryntesson 4bd0e65bde Port #[rustc_legacy_const_generics] to use attribute parser 2025-12-16 20:29:01 +01:00
Jana Dönszelmann 1cbdaf246b EII collection queries
EII collection queries
2025-12-12 11:28:58 +01:00
Jana Dönszelmann 33df6ccb21 EII lowering 2025-12-12 11:28:58 +01:00
Guillaume Gomez 9c8c67bfdd Fix warning messages 2025-12-10 12:27:34 +01:00
Guillaume Gomez acb32df7b1 Continue migration to new Attribute API for doc attribute 2025-12-10 12:27:33 +01:00
Jana Dönszelmann df007cf800 rewrite doc attribute (non-doc-comments) 2025-12-10 12:27:33 +01:00
Sasha Pourcelot a57470ff72 Look for typos when reporting an unknown nightly feature 2025-12-05 20:06:10 +00:00
binarycat 2ee6196078 validate usage of crate-level doc attributes 2025-11-23 12:00:53 -06:00
Stuart Cook 6487148d80 Rollup merge of #146495 - fmease:rustdoc-erase-doc-priv-items-attr, r=GuillaumeGomez
rustdoc: Erase `#![doc(document_private_items)]`

I just found out about the existence of `#![doc(document_private_items)]`. Apparently it was added by PR rust-lang/rust#50669 back in 2018 without any tests or docs as a replacement for some specific forms of the removed `#![doc(passes)]` / `#![doc(no_default_passes)]`.

However, rustc and rustdoc actually emit the deny-by-default lint `invalid_doc_attributes` for it (but if you allow it, the attribute does function)! To be more precise since PR rust-lang/rust#82708 (1.52, May 2021) which introduced lint `invalid_doc_attributes`, rust{,do}c has emitted a future-incompat warning for this attribute. And since PR rust-lang/rust#111505 (1.78, May 2024) that lint is deny by default. I presume nobody knew this attribute existed and thus it was never allowlisted.

Given the fact that since 2021 nobody has ever opened a ticket ([via](https://github.com/rust-lang/rust/issues?q=is%3Aissue+document_private_items)) complaining about the lint emission and the fact that GitHub code search doesn't yield any actual uses ([via](https://github.com/search?q=%2F%23%21%5C%5Bdoc%5C%28.*%3Fdocument_private_items%2F+language%3ARust&type=code&ref=advsearch)), I'm led to believe that nobody knows about and uses this attribute.

I don't find the existence of this attribute to be justified since in my view the flag `--document-private-items` is strictly superior: In most if not all cases, you don't want to "couple" your crate with this "mode" even if you gate it behind a cfg; instead, you most likely want to set this manually at invocation time, via a build config file like `.cargo/config.toml` or via a command runner like `just` I'd say.

Because of this I propose to wipe this attribute from existence. I don't believe it's worth cratering this (i.e., temporarily emitting a hard error for this attribute and running crater) given the fact that it's been undocumented since forever and led to a warning for years.
2025-11-11 21:09:33 +11:00
Jana Dönszelmann 047c37cf23 convert rustc_main to the new attribute parsing infrastructure 2025-10-14 17:55:00 +02:00
Camille GILLOT ca0379d6cd Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
Camille GILLOT 5620c82e53 Report uninhabited call return types on MIR. 2025-10-11 20:50:20 +00:00
Jules Bertholet d5ba5c1c92 Mark PatternTypo suggestion as maybe incorrect 2025-10-03 16:00:15 -04:00
Guillaume Gomez 9362ab549f Improve code and fix typo 2025-09-27 11:29:50 +02:00
Guillaume Gomez 63aefe0737 Strenghten checks for doc(auto_cfg(show/hide)) attributes 2025-09-27 11:29:48 +02:00
Guillaume Gomez 7c00bccd3b Implement RFC 3631 2025-09-27 11:29:48 +02:00
Jana Dönszelmann 9acc63a48c port #[debugger_visualizer] to the new attribute system 2025-09-21 21:30:16 -07:00
Jonathan Brouwer 6abcadc235 Port #[macro_export] to the new attribute parsing infrastructure
Co-authored-by: Anne Stijns <anstijns@gmail.com>
2025-09-21 10:42:47 -04:00
León Orell Valerian Liehr 044d15b748 Erase #![doc(document_private_items)] 2025-09-13 02:52:01 +02:00
Folkert de Vries cbacd00f10 allow #[rustc_align_static(N)] on statics
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-09-09 21:54:54 +02:00
Stuart Cook 3a6ae1167f Rollup merge of #145827 - estebank:issue-51976, r=jackh726
On unused binding or binding not present in all patterns, suggest potential typo of unit struct/variant or const

When encountering an or-pattern with a binding not available in all patterns, look for consts and unit struct/variants that have similar names as the binding to detect typos.

```
error[E0408]: variable `Ban` is not bound in all patterns
  --> $DIR/binding-typo.rs:22:9
   |
LL |         (Foo, _) | (Ban, Foo) => {}
   |         ^^^^^^^^    --- variable not in all patterns
   |         |
   |         pattern doesn't bind `Ban`
   |
help: you might have meant to use the similarly named unit variant `Bar`
   |
LL -         (Foo, _) | (Ban, Foo) => {}
LL +         (Foo, _) | (Bar, Foo) => {}
   |
```

For items that are not in the immedate scope, suggest the full path for them:

```
error[E0408]: variable `Non` is not bound in all patterns
  --> $DIR/binding-typo-2.rs:51:16
   |
LL |         (Non | Some(_))=> {}
   |          ---   ^^^^^^^ pattern doesn't bind `Non`
   |          |
   |          variable not in all patterns
   |
help: you might have meant to use the similarly named unit variant `None`
   |
LL -         (Non | Some(_))=> {}
LL +         (core::option::Option::None | Some(_))=> {}
   |
```

When encountering a typo in a pattern that gets interpreted as an unused binding, look for unit struct/variant of the same type as the binding:

```
error: unused variable: `Non`
  --> $DIR/binding-typo-2.rs:36:9
   |
LL |         Non => {}
   |         ^^^
   |
help: if this is intentional, prefix it with an underscore
   |
LL |         _Non => {}
   |         +
help: you might have meant to pattern match on the similarly named variant `None`
   |
LL -         Non => {}
LL +         std::prelude::v1::None => {}
   |
```

 Suggest constant on unused binding in a pattern

```
error: unused variable: `Batery`
  --> $DIR/binding-typo-2.rs:110:9
   |
LL |         Batery => {}
   |         ^^^^^^
   |
help: if this is intentional, prefix it with an underscore
   |
LL |         _Batery => {}
   |         +
help: you might have meant to pattern match on the similarly named constant `Battery`
   |
LL |         Battery => {}
   |            +
```

Fix rust-lang/rust#51976.
2025-09-04 10:01:54 +10:00
Esteban Küber 00f6fe1b6c On unused binding in pattern, suggest unit struct/variant with similar name
When encountering a typo in a pattern that gets interpreted as an unused binding, look for unit struct/variant of the same type as the binding:

```
error: unused variable: `Non`
  --> $DIR/binding-typo-2.rs:36:9
   |
LL |         Non => {}
   |         ^^^
   |
help: if this is intentional, prefix it with an underscore
   |
LL |         _Non => {}
   |         +
help: you might have meant to pattern match on the similarly named variant `None`
   |
LL -         Non => {}
LL +         std::prelude::v1::None => {}
   |
```
2025-08-30 16:24:26 +00:00
Guillaume Gomez ab0ee84eac Add new doc(attribute = "...") attribute 2025-08-28 15:56:29 +02:00
Sasha Pourcelot a8e9ca195e Use attribute name in message for "outer attr used as inner attr" errors 2025-08-25 21:31:04 +02: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
Stuart Cook 633cc0cc6c Rollup merge of #142681 - 1c3t3a:sanitize-off-on, r=rcvalle
Remove the `#[no_sanitize]` attribute in favor of `#[sanitize(xyz = "on|off")]`

This came up during the sanitizer stabilization (rust-lang/rust#123617). Instead of a `#[no_sanitize(xyz)]` attribute, we would like to have a `#[sanitize(xyz = "on|off")]` attribute, which is more powerful and allows to be extended in the future (instead
of just focusing on turning sanitizers off). The implementation is done according to what was [discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/343119-project-exploit-mitigations/topic/Stabilize.20the.20.60no_sanitize.60.20attribute/with/495377292)).

The new attribute also works on modules, traits and impl items and thus enables usage as the following:
```rust
#[sanitize(address = "off")]
mod foo {
    fn unsanitized(..) {}

    #[sanitize(address = "on")]
    fn sanitized(..) {}
}

trait MyTrait {
  #[sanitize(address = "off")]
  fn unsanitized_default(..) {}
}

#[sanitize(thread = "off")]
impl MyTrait for () {
    ...
}
```

r? ```@rcvalle```
2025-08-19 14:18:16 +10:00