137 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
Jana Dönszelmann
5026d0cd8e
Rollup merge of #142876 - JonathanBrouwer:target_feature_parser, r=oli-obk
Port `#[target_feature]` to new attribute parsing infrastructure

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

r? ``@jdonszelmann``
2025-07-03 13:29:36 +02:00
Jana Dönszelmann
f6d37a25a9
Rollup merge of #134006 - klensy:typos, r=nnethercote
setup typos check in CI

This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying?

Also includes commits with actual typo fixes.

MCP: https://github.com/rust-lang/compiler-team/issues/817

typos check currently turned for:
* ./compiler
* ./library
* ./src/bootstrap
* ./src/librustdoc

After merging, PRs which enables checks for other crates (tools) can be implemented too.

Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr.

Check typos: `python x.py test tidy --extra-checks=spellcheck`
Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo)

Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03 13:29:35 +02:00
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +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
Matthias Krüger
2dbb9be326
Rollup merge of #142964 - GrigorenkoPV:attributes/argless, r=oli-obk
Attribute rework: a parser for single attributes without arguments

Part of rust-lang/rust#131229

r? `@jdonszelmann`

I think code (with comments) speaks for itself.

The only subtlety: now `#[cold]`, `#[no_mangle]`, & `#[track_caller]` do not get thrown away when malformed (i.e. have arguments). This doesn't matter too much (I think), because an error gets emitted either way, so the compilation will not finish.
2025-07-02 19:29:36 +02:00
Pavel Grigorenko
8bb7fdb236 NoArgsAttributeParser: use an assoc const instead 2025-07-02 00:21:12 +03:00
Guillaume Gomez
61bb076459
Rollup merge of #143240 - JonathanBrouwer:object_lifetime_default_parser, r=oli-obk
Port `#[rustc_object_lifetime_default]` to the new attribute parsing …

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

r? `@oli-obk`
cc `@jdonszelmann`
2025-07-01 17:47:04 +02:00
Jonathan Brouwer
1e474c2c6c
Port #[rustc_object_lifetime_default] to the new attribute parsing infrastructure 2025-07-01 16:31:23 +02:00
Jonathan Brouwer
d22ce4c5eb
Fix duplicate help on export_name and others
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01 16:10:07 +02:00
Jonathan Brouwer
149bdde97e
Fix #[must_use = 1] not giving an error
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01 16:10:05 +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
Pavel Grigorenko
187babc35f NoArgsAttributeParser 2025-06-30 23:19:04 +03: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
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
73bcf4c117
make warnings methods on cx so it's easier to emit them elsewhere too 2025-06-23 12:21:44 +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
bors
15c701fbc9 Auto merge of #142794 - tgross35:rollup-iae7okj, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.)
 - rust-lang/rust#142491 (Rework #[cold] attribute parser)
 - rust-lang/rust#142494 (Fix missing docs in `rustc_attr_parsing`)
 - rust-lang/rust#142495 (Better template for `#[repr]` attributes)
 - rust-lang/rust#142497 (Fix random failure when JS code is executed when the whole file was not read yet)
 - rust-lang/rust#142575 (Ensure copy* intrinsics also perform the static self-init checks)
 - rust-lang/rust#142650 (Refactor Translator)
 - rust-lang/rust#142713 (mbe: Refactor transcription)
 - rust-lang/rust#142755 (rustdoc: Remove `FormatRenderer::cache`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-20 23:09:48 +00:00
Pavel Grigorenko
045faa8c5c Port #[may_dangle] to the new attribute system 2025-06-20 22:39:14 +03:00
Jakub Beránek
e7cc4ec8f7
Rollup merge of #142769 - jdonszelmann:remove-useless-new-method, r=tgross35
remove equivalent new method on context

Noticed the two had converged so much they literally became equivalent. So one could go hehe
2025-06-20 20:03:25 +02:00
Jakub Beránek
065a5fb225
Rollup merge of #142715 - folkertdev:fn-align-corrections, r=jdonszelmann
correct template for `#[align]` attribute

Tracking issue: https://github.com/rust-lang/rust/issues/82232
related: https://github.com/rust-lang/rust/pull/142507

I didn't fully understand what `template!` did, clearly. An empty `#[align]` attribute was still rejected later, but without this change it does get suggested in certain cases.

I've also updated some outdated references to `#[repr(align)]` on functions.

r? ``@jdonszelmann``
2025-06-20 20:03:21 +02:00
Trevor Gross
1e2ac532e4
Rollup merge of #142495 - jdonszelmann:better-repr-template, r=oli-obk
Better template for `#[repr]` attributes
2025-06-20 13:36:00 -04:00
Trevor Gross
d2a00eb65f
Rollup merge of #142494 - jdonszelmann:missing-attr-parsing-docs, r=oli-obk
Fix missing docs in `rustc_attr_parsing`
2025-06-20 13:35:59 -04:00
Jana Dönszelmann
b9107a83a1
expected word diagnostic test 2025-06-20 15:06:29 +02: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
75bcc9ca6e
remove equivalent new method on context 2025-06-20 07:50:11 +02:00
Folkert de Vries
eefd598725
correct template for #[align]
it should not suggest just `#[align]`
2025-06-19 13:58:23 +02:00
Jana Dönszelmann
7f49de2cca
fixup missing docs in attr parsing 2025-06-18 14:46:12 +02:00
Jana Dönszelmann
815f0b71c7
better template for repr attributes 2025-06-18 13:48:42 +02: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