Commit Graph

357 Commits

Author SHA1 Message Date
Guillaume Gomez c910511cab Move remaining doc attribute parsing errors to warnings 2026-02-04 10:54:45 +01:00
Guillaume Gomez 7dbbab63e2 Emit a future error warning for duplicate doc attribute 2026-02-04 10:54:44 +01:00
Jamie Hill-Daniel b226583d94 Treat unions as 'data types' in attr parsing diagnostics 2026-01-29 15:51:43 +00:00
Jamie Hill-Daniel e73dfaa62f Move collect_crate_types to rustc_interface, and use new attribute parser 2026-01-22 02:34:28 +00:00
Jamie Hill-Daniel 66b78b700b Port crate_type to attribute parser 2026-01-22 02:34:28 +00:00
Jamie Hill-Daniel 8a1d6d319b Add test for malformed and misapplied crate_type 2026-01-22 02:30:56 +00:00
Edvin Bryntesson b65e1fdcb8 Port #[patchable_function_entry] to attr parser 2026-01-20 11:46:05 +01:00
Jonathan Brouwer f5a1fc75ad Update uitests 2026-01-18 22:41:00 +01:00
mejrs a1e2cea685 Port do_not_recommend to new attr parsing 2026-01-13 20:43:37 +01:00
Edvin Bryntesson 418cff3ec0 Port #[must_not_suspend] to attribute parser 2026-01-12 18:16:37 +01:00
Jonathan Brouwer f0da7832b7 Update uitests 2026-01-11 10:54:45 +01:00
Martin Nordholts 8e3d60447c Finish transition from semitransparent to semiopaque for rustc_macro_transparency 2026-01-08 19:14:45 +01:00
Edvin Bryntesson acd6ba4edb Port #[instruction_set] to attribute parser 2025-12-31 03:01:05 +01:00
Edvin Bryntesson d719a49b28 Port #[cfi_encoding] to attribute parser 2025-12-21 22:11:33 +01:00
Edvin Bryntesson 120f0d4f07 Port #[thread_local] to attribute parser 2025-12-20 15:38:42 +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
Jonathan Brouwer f3fa567fdf Rollup merge of #150032 - Kivooeo:annotate-snippets-stable, r=Muscraft
Use annotate-snippet as default emitter on stable

This is implementation of https://github.com/rust-lang/rust/issues/149932

Now, after MCP was accepted, we can use annotate-snippet as default emitter for errors, that means that we not longer need of previous emitter, so this PR removed previous emitter and makes annotate-snippet new default one both on stable and nightly

(this PR does not remove a code of previous emitter it just removes a `Default` option of `HumanReadableErrorType` enum, and keeping only `HumanReadableErrorType::AnnotateSnippet` as it now uses by default)
2025-12-16 20:21:10 +01:00
Kivooeo 84f2854bc3 remove fixme & update stderr files 2025-12-16 13:23:48 +00:00
Stuart Cook bd1e142ac0 Rollup merge of #148756 - JonathanBrouwer:link_section_targets2, r=jdonszelmann
Warn on codegen attributes on required trait methods

This PR turns applying the following attributes on required trait methods (that is, trait methods **without** a default implementation) into a FCW:
- `#[cold]`
- `#[link_section]`
- `#[linkage]` (unstable)
- `#[rustc_allow_const_fn_unstable]` (internal attribute)

These attributes already had no effect when applied to a required trait method, this PR only adds a warning.

Furthermore, it adds a comment in the code that the following codegen attributes are *inherited* when applied to a required trait method:
- `#[track_caller]`
- `#[align]` (unstable)

````@rustbot```` labels +I-lang-nominated
````@rust-lang/lang````

Two questions for the lang team:
- Is adding this warning ok?
- Does the current behaviour of these attributes align with that you would expect them to be?

Fixes https://github.com/rust-lang/rust/issues/147432
2025-12-16 14:40:40 +11:00
Jonathan Brouwer 8fa10c0ed7 Add regression test for codegen attributes on required trait methods
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-12-13 20:19:20 +01:00
Jonathan Brouwer ae39d3d9ab Improve spans of malformed attribute errors 2025-12-13 17:13:36 +01:00
Jonathan Brouwer 69a59e8e87 Stop using IllFormedAttributeInputLint for must_use 2025-12-13 15:14:01 +01:00
Jonathan Brouwer 6a7ed1353d Stop using IllFormedAttributeInputLint for macro_use 2025-12-13 15:14:01 +01:00
Jonathan Brouwer f357e51e89 Stop using IllFormedAttributeInputLint for macro_use 2025-12-13 15:13:04 +01:00
bors fa5eda19b9 Auto merge of #149917 - GuillaumeGomez:malformed-attribute-suggestions, r=JonathanBrouwer
If there are too many suggestions for malformed attribute, do not suggest them

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

This not only covers for doc attributes but for all attributes, so don't hesitate to tell me if you want it to be limited to only doc attributes (although I think it's actually a nice improvement overall).

Also, I picked 3 as the maximum number of suggestions before it becomes noise, but it's very much open to debate.

r? `@JonathanBrouwer`
2025-12-12 18:18:14 +00:00
Guillaume Gomez d025cdef7d If there are too many suggestions for malformed attribute, do not suggest them 2025-12-12 14:55:17 +01:00
Matthias Krüger b826d06771 Rollup merge of #149791 - clubby789:cfg-bool-lints, r=jdonszelmann
Remove uses of `cfg({any()/all()})`

~~This implements the followup warning suggested in https://github.com/rust-lang/rfcs/pull/3695~~
~~Lint against an empty `cfg(any/all)`, suggest the boolean literal equivalents.~~
https://github.com/rust-lang/rust/pull/149791#issuecomment-3638624348

Tracking issue: https://github.com/rust-lang/rust/issues/131204
2025-12-12 12:19:09 +01:00
bors 5b150d238f Auto merge of #149645 - GuillaumeGomez:doc-attr-based, r=jdonszelmann,jonathanbrouwer
Port `doc` attributes to new attribute API

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

This PR ports the `doc` attributes to the new attribute API. However, there are things that will need to be fixed in a follow-up:

* Some part of `cfg_old.rs` are likely unused now, so they should be removed.
* Not all error/lints are emitted at the same time anymore, making them kinda less useful considering that you need to run and fix rustc/rustdoc multiple times to get through all of them.
* For coherency with the other attribute errors, I didn't modify the default output too much, meaning that we have some new messages now. I'll likely come back to that to check if the previous ones were better in a case-by-case approach.
* `doc(test(attr(...)))` is handled in a horrifying manner currently. Until we can handle it correctly with the `Attribute` system, it'll remain that thing we're all very ashamed of. 😈
* A type in rustdoc got its size increased, I'll check the impact on performance. But in any case, I plan to improve it in a follow-up so should be "ok".
* Because of error reporting, some fields of `Doc` are suboptimal, like `inline` which instead of being an `Option` is a `ThinVec` because we report the error later on. Part of the things I'm not super happy about but can be postponed to future me.
* In `src/librustdoc/clean/cfg.rs`, the `pub(crate) fn parse(cfg: &MetaItemInner) -> Result<Cfg, InvalidCfgError> {` function should be removed once `cfg_trace` has been ported to new `cfg` API.
* Size of type `DocFragment` went from 32 to 48. Would be nice to get it back to 32.
* ``malformed `doc` attribute input`` wasn't meant for so many candidates, should be improved.
* See how many of the checks in `check_attr` we can move to attribute parsing
* Port target checking to be in the attribute parser completely
* Fix target checking for `doc(alias)` on fields & patterns

And finally, once this PR is merged, I plan to finally stabilize `doc_cfg` feature. :)

cc `@jdonszelmann`
r? `@JonathanBrouwer`
2025-12-11 21:08:19 +00:00
Jamie Hill-Daniel c96ff2d429 Remove uses of cfg(any()/all()) 2025-12-10 23:41:19 +00:00
Guillaume Gomez 2bc2a0db69 For now, ignore target checking for doc attributes in attr_parsing 2025-12-10 20:18:42 +01:00
Guillaume Gomez 4936973d49 Fix ui tests 2025-12-10 12:28:05 +01:00
Matthias Krüger 4da61b6d69 Rollup merge of #149816 - estebank:verbose-typo-suggestion, r=JonathanBrouwer,Kivooeo
Make typo in field and name suggestions verbose

Part of https://github.com/rust-lang/rust/issues/141973.
2025-12-10 07:54:21 +01:00
Esteban Küber 6cd44a472c Make typo in field and name suggestions verbose 2025-12-09 17:29:23 +00:00
Esteban Küber 0b0e826c0f Rework attribute recovery logic 2025-12-09 01:16:05 +00:00
Matthias Krüger 0c95abb979 Rollup merge of #149524 - JonathanBrouwer:move_attr_safety, r=jdonszelmann
Move attribute safety checking to attribute parsing

This PR moves attribute safety checking to be done during attribute parsing. The `cfg` and `cfg_attr` attribute no longer need special-cased safety checking, yay!

This PR is a part 1 of 2, in the second part I'd like to define attribute safety in the attribute parsers rather than getting the information from BUILTIN_ATTRIBUTE_MAP, but to keep PRs reviewable lets do that separately.

Fixes https://github.com/rust-lang/rust/issues/148453 by reordering the diagnostics. The "cannot find attribute" diagnostic now appears first, but both diagnostics still appear.

r? `@jdonszelmann`
2025-12-04 16:07:53 +01:00
Jonathan Brouwer 892bd18ad8 Add a regression test for unsafe nonexistent attributes 2025-12-03 17:00:08 +01:00
Jonathan Brouwer 6e3a015400 UI test changes 2025-12-03 17:00:08 +01:00
xonx4l 4b000cfacd Merge E0412 into E0425 2025-12-02 18:25:13 +00:00
Matthias Krüger 3f1e4f8fee Rollup merge of #149398 - Aditya-PS-05:test-issue-143987-align-struct-fields, r=Kivooeo
add regression test for issue #143987

closes rust-lang/rust#143987
2025-11-28 15:19:16 +01:00
bors e6edf3ae53 Auto merge of #147498 - ferrocene:pvdrz/edition-range-gating, r=jieyouxu,fmease
Gate tests with the right edition

This PR guarantees that `./x test --test-args="--edition XXXX" ui` runs correctly with the 2015, 2018 and 2021 editions.

I don't expect this PR to hold up over time but it helps to submit further updates to the `//@ edition` directives of tests where we can use the new range syntax to have a more robust testing across different editions

r? `@fmease`

---

try-job: aarch64-gnu
try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
try-job: test-various
try-job: armhf-gnu
2025-11-27 22:37:05 +00:00
Aditya-PS-05 3ceea4768b add issue link in test 2025-11-28 02:45:42 +05:30
Aditya-PS-05 b27bb83592 add regression test for align attribute on struct fields 2025-11-28 02:45:42 +05:30
Christian Poveda b2ab7cf980 Gate 2015 UI tests 2025-11-27 11:19:00 -05:00
Sasha Pourcelot 2ab2090937 Port the #![windows_subsystem] attribute to the new attribute system 2025-11-27 00:17:48 +01:00
Stuart Cook 7327bbc811 Rollup merge of #148647 - JonathanBrouwer:unsafe_attr_refactor, r=jdonszelmann
Check unsafety for non-macro attributes in `validate_attr`

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

Also adds a test for a previously untested case, unnecessary unsafe on a proc macro attribute

In preparation for https://github.com/rust-lang/rust/issues/148453
2025-11-11 21:09:41 +11:00
Jonathan Brouwer 87b2796ee6 Add test for unnecessary unsafe on proc macro attr
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-11-07 13:59:44 +01:00
Jonathan Brouwer c8618d2efa Refactor safety checking for attributes
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-11-07 13:52:55 +01:00
Lucas Baumann d198633b95 add realtime sanitizer 2025-11-06 13:20:12 +01:00
beetrees 7354d3d9c2 Add #[rustc_pass_indirectly_in_non_rustic_abis] 2025-11-04 09:56:17 +01:00