72 Commits

Author SHA1 Message Date
Jonathan Brouwer
3fa0ec91d8
Rewrite empty attribute lint
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-06 09:51:35 +02:00
Jonathan Brouwer
2d8ffff10a
Port #[ignore] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-05 21:23:09 +02:00
Jonathan Brouwer
027126ce0b
Port #[non_exhaustive] to the new attribute parsing infrastructure 2025-07-04 20:30:42 +02:00
Matthias Krüger
f3e7ec5560
Rollup merge of #143400 - GrigorenkoPV:attributes/lints, r=jdonszelmann
Port `#[rustc_pass_by_value]` to the new attribute system

Part of rust-lang/rust#131229

r? `@oli-obk`
2025-07-04 16:22:36 +02:00
Pavel Grigorenko
ef4dece2cb Port #[rustc_pass_by_value] to the new attribute system 2025-07-04 00:07:56 +03:00
Jonathan Brouwer
fee5e3c3aa
Port #[no_implicit_prelude] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-03 20:59:40 +02:00
Pavel Grigorenko
35453a854c Add tidy-alphabetical for cross-crate attribute match 2025-07-03 21:36:28 +03:00
Jonathan Brouwer
3d5d72b761
Port #[target_feature] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-03 07:54:19 +02:00
Jonathan Brouwer
1e474c2c6c
Port #[rustc_object_lifetime_default] to the new attribute parsing infrastructure 2025-07-01 16:31:23 +02:00
bors
86e05cd300 Auto merge of #142921 - JonathanBrouwer:rustc_attributes_parser, r=oli-obk
Port `#[rustc_layout_scalar_valid_range_start/end]` to the new attrib…

Ports `rustc_layout_scalar_valid_range_start` and `rustc_layout_scalar_valid_range_end` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

r? `@jdonszelmann`
2025-07-01 08:33:00 +00:00
Anne Stijns
54cec0cf5a Port #[link_section] to the new attribute parsing infrastructure 2025-06-29 16:23:46 +02:00
Jonathan Brouwer
1249c14232
Port #[link_name] to the new attribute parsing infrastructure
Co-authored-by: Anne Stijns <anstijns@gmail.com>
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-28 13:53:37 +02:00
Jonathan Brouwer
f98ea3d144
Port #[rustc_layout_scalar_valid_range_start/end] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-27 09:08:21 +02:00
Jonathan Brouwer
9e35684072
Port #[used] to new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-27 08:58:26 +02:00
Jonathan Brouwer
287d9afce7
Port #[export_name] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-26 08:50:42 +02:00
Jana Dönszelmann
64a1a98f47
encode_cross_crate for hir attributes 2025-06-25 22:10:40 +02:00
Jubilee
2ad6272649
Rollup merge of #142825 - jdonszelmann:track-caller, r=oli-obk
Port `#[track_caller]` to the new attribute system

r? ``@oli-obk``

depends on https://github.com/rust-lang/rust/pull/142493

Closes rust-lang/rust#142783

(didn't add a test for this, this situation should simply never come up again, the code was simply wrong. lmk if I should add it, but it won't test something very useful)
2025-06-24 19:45:32 -07:00
Jubilee
f542909d1c
Rollup merge of #138780 - trifectatechfoundation:loop_match_attr, r=oli-obk,traviscross
Add `#[loop_match]` for improved DFA codegen

tracking issue: https://github.com/rust-lang/rust/issues/132306
project goal: https://github.com/rust-lang/rust-project-goals/issues/258

This PR adds the `#[loop_match]` attribute, which aims to improve code generation for state machines. For some (very exciting) benchmarks, see https://github.com/rust-lang/rust-project-goals/issues/258#issuecomment-2732965199

Currently, a very restricted syntax pattern is accepted. We'd like to get feedback and merge this now before we go too far in a direction that others have concerns with.

## current state

We accept code that looks like this

```rust
#[loop_match]
loop {
    state = 'blk: {
        match state {
            State::A => {
                #[const_continue]
                break 'blk State::B
            }
            State::B => { /* ... */ }
            /* ... */
        }
    }
}
```

- a loop should have the same semantics with and without `#[loop_match]`: normal `continue` and `break` continue to work
- `#[const_continue]` is only allowed in loops annotated with `#[loop_match]`
- the loop body needs to have this particular shape (a single assignment to the match scrutinee, with the body a labelled block containing just a match)

## future work

- perform const evaluation on the `break` value
- support more state/scrutinee types

## maybe future work

- allow `continue 'label value` syntax, which `#[const_continue]` could then use.
- allow the match to be on an arbitrary expression (e.g. `State::Initial`)
- attempt to also optimize `break`/`continue` expressions that are not marked with `#[const_continue]`

r? ``@traviscross``
2025-06-24 19:45:30 -07:00
Jana Dönszelmann
5d44fdd972
Rewrite #[track_caller] 2025-06-24 23:00:31 +02:00
Pavel Grigorenko
aa80a2b62c Port #[rustc_skip_during_method_dispatch] to the new attribute system 2025-06-23 22:48:20 +03:00
bjorn3
ba5556d239
Add #[loop_match] for improved DFA codegen
Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
2025-06-23 20:43:04 +02:00
Jana Dönszelmann
5c0a625205
move naked checks out of check_attr.rs 2025-06-23 12:22:57 +02:00
Jana Dönszelmann
82cbc3a35e
rewrite #[naked] parser 2025-06-23 12:21:43 +02:00
Jonathan Brouwer
2084831cd5
Port #[no_mangle] to new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-22 22:17:04 +02:00
Jonathan Brouwer
b24df42488
Port #[must_use] to new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-22 14:51:58 +02:00
Pavel Grigorenko
d86d3f3742 Port #[rustc_pub_transparent] to the new attribute system 2025-06-21 21:52:25 +03:00
Jana Dönszelmann
cd857f4bef
Rollup merge of #142539 - GrigorenkoPV:attributes/may_dangle, r=jdonszelmann
Port `#[may_dangle]` to the new attribute system

Very similar to rust-lang/rust#142498.

This is a part of rust-lang/rust#131229, so
r? `@jdonszelmann`
2025-06-21 15:32:05 +02:00
Pavel Grigorenko
045faa8c5c Port #[may_dangle] to the new attribute system 2025-06-20 22:39:14 +03:00
Jana Dönszelmann
de0fd27f34
cold 2025-06-20 15:06:29 +02:00
Trevor Gross
bab4ca914e
Rollup merge of #138291 - jdonszelmann:optimize-attr, r=oli-obk
rewrite `optimize` attribute to use new attribute parsing infrastructure

r? ```@oli-obk```

I'm afraid we'll get quite a few of these PRs in the future. If we get a lot of trivial changes I'll start merging multiple into one PR. They should be easy to review :)

Waiting on #138165 first
2025-06-20 02:50:37 -04:00
Jana Dönszelmann
b64fd13a04
convert the optimize attribute to a new parser 2025-06-18 13:48:42 +02:00
Folkert de Vries
1fdf2b5620
add #[align] attribute
Right now it's used for functions with `fn_align`, in the future it will
get more uses (statics, struct fields, etc.)
2025-06-18 12:37:08 +02:00
Jana Dönszelmann
780b902111
fix clippy 2025-06-17 23:22:51 +02:00
Jana Dönszelmann
ee976bbbca
fix bugs in inline/force_inline and diagnostics of all attr parsers 2025-06-17 23:19:31 +02:00
Jana Dönszelmann
0aade73c50
implement rustc_force_inline parser 2025-06-17 23:19:31 +02:00
Jonathan Dönszelmann
4f73cd0a6c implement inline parser 2025-06-17 23:19:31 +02:00
Jakub Beránek
1e950ef1b2
Rollup merge of #142498 - GrigorenkoPV:as-ptr-refactor, r=jdonszelmann
Port `#[rustc_as_ptr]` to the new attribute system

It might make sense to introduce some new parser analogous to `Single`, but even more simple: for parsing attributes that take no arguments and may appear only once (such as `#[rustc_as_ptr]` or `#[rustc_const_stable_indirect]`). Not sure if this should be a single `impl` parsing all such attributes, or one impl per attribute. Or how it will play along with the upcoming rework of attribute validation. Or how these argumentless attributes should be called (I've loosely referred to them as `markers` in the name of the new module in this PR, but not sure how good it is).

This is a part of rust-lang/rust#131229, so
r? `@jdonszelmann`

---

For reference, the `#[rustc_as_ptr]` attribute was created back in rust-lang/rust#132732 as a followup to rust-lang/rust#128985.
2025-06-16 19:54:34 +02:00
Pavel Grigorenko
da8d6bbd50 Port #[rustc_as_ptr] to the new attribute system 2025-06-16 18:13:27 +03:00
Jakub Beránek
3795658357
Rollup merge of #142082 - xizheyin:rustc_attr_data_structures, r=jdonszelmann
Refactor `rustc_attr_data_structures` documentation

I was reading through `AttributeKind` and realized that attributes like `InlineAttr` didn't appear in it, however, I found them in `rustc_codegen_ssa` and understood why (guessing).

There's almost no overall documentation for this crate, I've added the organized documentation at the top of `lib.rs`, and I've grouped the Attributes into two categories: `AttributeKind` that run all through the compiler, and the ones that are only used in `codegen_ssa`, such as `InlineAttr`, `OptimizeAttr`, `InstructionSetAttr`.

Also, I've added documentation for `AttributeKind` that further explains why attributes like `InlineAttr` don't appear in it, with examples for each variant.

r? ```@jdonszelmann```
2025-06-16 14:31:09 +02:00
xizheyin
1ac89f190f
Refactor rustc_attr_data_structures documentation
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-15 20:04:33 +08:00
Matthias Krüger
fac011eb2d
Rollup merge of #142158 - xizheyin:141617, r=jdonszelmann
Tracking the old name of renamed unstable library features

This PR resolves the first problem of rust-lang/rust#141617 : tracking renamed unstable features. The first commit is to add a ui test, and the second one tracks the changes. I will comment on the code for clarification.

r? `@jdonszelmann`
There have been a lot of PR's reviewed by you lately, thanks for your time!

cc `@jyn514`
2025-06-13 05:16:56 +02:00
xizheyin
b8066f94fd
Tracking the old name of renamed unstable library attribute
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-12 19:24:11 +08:00
Jana Dönszelmann
6072207a11
introduce new lint infra
lint on duplicates during attribute parsing
To do this we stuff them in the diagnostic context to be emitted after
hir is constructed
2025-06-12 09:56:47 +02:00
mejrs
dc14e73232 Delete unused variant and document AttributeKind 2025-06-06 11:43:22 +02:00
est31
f3245e48f9 Make #[cfg(version)] respect RUSTC_OVERRIDE_VERSION_STRING 2025-05-24 23:54:17 +02:00
Pietro Albini
2ce08ca5d6
update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
est31
7493e1cdf6 Make #![feature(let_chains)] bootstrap conditional in compiler/ 2025-04-23 16:40:30 +02:00
Mara Bos
5f4d676e70 Remove #[rustc_macro_edition_2021].
It was only temporarily used by pin!(), which no longer needs it.
2025-04-20 11:15:46 +02:00
Jana Dönszelmann
7c085f7ffd
add rustc_macro_edition_2021 2025-03-19 17:37:35 +01:00
Matthias Krüger
d93ef397ce
Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu
Use `RUSTC_LINT_FLAGS` more

An alternative to the failed #138084.

Fixes #138106.

r? ````@jieyouxu````
2025-03-12 17:59:08 +01:00