Commit graph

2148 commits

Author SHA1 Message Date
Keith-Cancel
4c93efae2b Fix ICE: When Trying to check visibility of a #[type_const], check RHS instead.
We want to evaluate the rhs of a type_const.

Also added an early return/guard in eval_in_interpreter which is used in functions like `eval_to_allocation_raw_provider`

Lastly add a debug assert to `thir_body()` if we have gotten there with a type_const something as gone wrong.

Get rid of a call to is_type_const() and instead use a match arm.

Change this is_type_const() check to a debug_assert!()

Change to use an if else statment instead.

Update type_const-pub.rs

Fix formatting.

Noticed that this is the same check as is_type_const() centralize it.

Add test case for pub type_const.
2026-01-16 20:30:58 -08:00
bors
22c74ba918 Auto merge of #151056 - mejrs:do_not_recommend, r=JonathanBrouwer
Port `diagnostic::do_not_recommend` to new attr parsing

r? @jdonszelmann
2026-01-15 19:35:19 +00:00
Jonathan Brouwer
db10879fd1
Rollup merge of #151096 - rm-providers-deref, r=oli-obk
Remove `Deref`/`DerefMut` impl for `Providers`.

It's described as a "backwards compatibility hack to keep the diff small". Removing it requires only a modest amount of churn, and the resulting code is clearer without the invisible derefs.

r? @oli-obk
2026-01-14 11:05:42 +01:00
Nicholas Nethercote
3aa31788b5 Remove Deref/DerefMut impl for Providers.
It's described as a "backwards compatibility hack to keep the diff
small". Removing it requires only a modest amount of churn, and the
resulting code is clearer without the invisible derefs.
2026-01-14 15:55:59 +11:00
mejrs
a1e2cea685 Port do_not_recommend to new attr parsing 2026-01-13 20:43:37 +01:00
Jonathan Brouwer
abcbf72bab
Port #[rustc_dump_predicates] 2026-01-13 15:25:28 +01:00
Jonathan Brouwer
a4c34b421c
Port #[rustc_dump_vtable] 2026-01-13 15:25:28 +01:00
Jonathan Brouwer
2a455409e3
Port #[rustc_dump_item_bounds] 2026-01-13 15:25:27 +01:00
Jonathan Brouwer
cf4d480eff
Port #[rustc_dump_def_parents] 2026-01-13 15:25:27 +01:00
Jonathan Brouwer
84d59d0731
Port #[rustc_dump_user_args] 2026-01-13 15:25:24 +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
Jana Dönszelmann
6d0f23adad
rename extern item to foreign item 2026-01-12 08:07:23 +01:00
Jana Dönszelmann
322bbdfaaf
rename eii-extern-target 2026-01-12 08:07:23 +01:00
Matthias Krüger
565c663413
Rollup merge of #150964 - list_all_attrs, r=jdonszelmann
Completely list all unparsed attributes

Also introduce a `SPECIAL_ATTRIBUTES` list, since `cfg` was incorrectly being detected as an unparsed attribute in `check_attr`.

I will also update https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163

r? @jdonszelmann
2026-01-12 00:02:55 +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
eac7bda659
Completely list all unparsed attributes 2026-01-11 12:56:00 +01:00
Jonathan Brouwer
6153fa0f88
Fix that cfg attribute was incorrectly not a parsed attribute 2026-01-11 12:12:53 +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
Jana Dönszelmann
52b3ac476c
trick with super imports that fixes nameres in anonymous modules 2026-01-09 09:29:02 +01:00
Jana Dönszelmann
5ddda0c37b
fix up diagnostics referring to the right items 2026-01-09 09:29:02 +01:00
Jana Dönszelmann
e3cff18370
dont resolve defaults anymore, store foreign item defid instead of macro 2026-01-09 09:29:02 +01:00
bors
d9617c8d9a Auto merge of #150310 - JonathanBrouwer:cfg_trace2, r=jdonszelmann
Port `#[cfg]` and `#[cfg_attr]` trace attributes to the new attribute parsers

This PR converts `cfg` and `cfg_trace` attributes to the new parsed representation.

The primary challenge is that re-parsing these attributes in the HIR is a performance regression, since these attributes were only used in rustdoc and clippy parsing them in the HIR is extra work that was not done in the compiler before. To solve this, we only parse the attributes once and then store their parsed representation in the AST.
2026-01-06 22:59:32 +00:00
Jonathan Brouwer
8b1bf8af85
Rollup merge of #144113 - mu001999-contrib:dead-code/allow-trait, r=jdonszelmann
Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items

https://github.com/rust-lang/rust/blob/master/compiler/rustc_passes/src/dead.rs#L360-L361 won't insert assoc items into the live set, so that impl items cannot be marked live.

This PR lets impls and impl items can inherit lint levels of the corresponding traits and trait items.

Fixes rust-lang/rust#144060

r? ````@petrochenkov````
2026-01-06 16:19:39 +01:00
Jonathan Brouwer
5590fc034c
Make cfg and cfg_attr trace attributes into early parsed attributes 2026-01-06 09:04:08 +01:00
Jakub Beránek
b198dffd98
Rollup merge of #149790 - JonathanBrouwer:attr-path-perf, r=jdonszelmann
Remove `Span` from segments of `AttrPath`

r? jdonszelmann
2026-01-05 15:54:12 +01:00
Jonathan Brouwer
5183d8f15d
Rollup merge of #150193 - Bryntet:parse_instruction_set, r=JonathanBrouwer
Port `#[instruction_set]` to attribute parser

Please note the test changes, and deprecation of `E0778` and `E0779`

In my opinion, all errors related to this attribute are improved I think, except for if you have `#[instruction_set(arm::)]` in which case there's an `error: expected identifier, found <eof>`, which is quite unhelpful I think, but this seems to be a limitation of the general attribute parsing flow

r? `@JonathanBrouwer`
2025-12-31 14:30:47 +01:00
Edvin Bryntesson
acd6ba4edb
Port #[instruction_set] to attribute parser 2025-12-31 03:01:05 +01:00
Mu001999
12474ce192 Impls and impl items inherit lint levels of the corresponding traits and trait items 2025-12-28 15:17:14 +08:00
Jonathan Brouwer
d63068b3b4
Rollup merge of #150405 - estebank:matches-could-be-equals, r=Kivooeo
Don't use `matches!` when `==` suffices

In the codebase we sometimes use `matches!` for values that can actually just be compared. Replace them with `==`.

Subset of rust-lang/rust#149933.
2025-12-27 13:42:01 +01:00
Jonathan Brouwer
096bb5b615
Rollup merge of #150236 - Bryntet:parse_rustc_must_impl, r=JonathanBrouwer
Port `#[rustc_must_implement_one_of]` to attribute parser

Stumbled upon a weird (bug ?) behaviour while making this PR

it seems like it is possible to reach `check_attr.rs` checks without the attribute allowed target checks having already been finished, I added a comment about how to reproduce this in `check_attr.rs`

otherwise good to note is that a bunch of code was moved from `compiler/rustc_hir_analysis/src/collect.rs` to `check_attr.rs`

r? `@JonathanBrouwer`
2025-12-26 21:50:17 +01:00
Esteban Küber
9f566f2463 Don't use matches! when == suffices
In the codebase we sometimes use `matches!` for values that can actually just be compared. Replace them with `==`.
2025-12-26 20:28:19 +00:00
Edvin Bryntesson
94e16291e0
Port #[rustc_must_implement_one_of] to attribute parser 2025-12-26 19:08:21 +01:00
Jonathan Brouwer
7afba2977d
Make attr path symbols rather than idents 2025-12-22 16:26:14 +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
Edvin Bryntesson
44cfed7465
Port #[rustc_lint_diagnostics] to attribute parser 2025-12-18 23:36:26 +01:00
Edvin Bryntesson
5277241d27
Port #[rustc_lint_untracked_query_information] to attribute parser 2025-12-18 23:33:25 +01:00
Jonathan Brouwer
521aca2b17
Rollup merge of #150125 - Bryntet:parse_rustc_lint_opt_deny_field_access, r=JonathanBrouwer
Port `#[rustc_lint_opt_deny_field_access]` to attribute parser

r? ``@JonathanBrouwer``
2025-12-18 18:37:22 +01:00
Jonathan Brouwer
4c9451bff8
Rollup merge of #150102 - jdonszelmann:fix-149982, r=Kivooeo
Fixed ICE for EII with multiple defaults due to duplicate definition in nameres

r? ``@jieyouxu`` (since you looked at the other one)

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

Previously a [fix was proposed](https://github.com/rust-lang/rust/pull/149985) by ``@SATVIKsynopsis`` which I marked as co-author on the first commit for the test they contributed. I'm closing this previous PR.

Duplicate definitions of EII defaults shouldn't be possible. I want to still panic on them, since I want to know when other bugs exist. However, in this case the duplicate was caused by something more subtle: both eiis have the same name, and as such a "duplicate definition" error is given. However, the compiler gracefully continues compiling despite that, assuming only one of the two EIIs is actually defined.

Both defaults then name resolve, and find the same single remaining EII, and both register themselves to be its default, breaking the single-default assumption.

The solution: I added a span-delayed-bug, to make sure we only panic if we hadn't previously had this duplicate definition name resolution error.

Thanks to ``@SATVIKsynopsis`` for their attempt. Adding a diagnostic here could make some sense, but nonetheless I think this is the better solution here <3
Also thanks to ``@yaahc`` for debugging help, she made me understand the name resolution of the situation so much better and is just lovely in general :3

The last commit is something I tried during debugging, which felt like a relevant test to add (one where both eiis also have the same function name)
2025-12-18 18:37:21 +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
96e453d713
Port #[rustc_lint_query_instability] to parsed attribute 2025-12-17 18:28:37 +01:00
Edvin Bryntesson
81d20363b3
Port #[rustc_lint_opt_ty] to parsed attribute 2025-12-17 18:23:49 +01:00
Edvin Bryntesson
bbda675aac
Port #[rustc_no_implicit_autorefs] to attribute parser 2025-12-17 18:22:19 +01:00
Jana Dönszelmann
1cd7cb1e8d
turn panic into span_delayed_bug 2025-12-17 18:04:03 +01:00
Edvin Bryntesson
5692064521
Port #[rustc_never_returns_null_ptr] to attribute parser 2025-12-17 12:35:32 +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