2471 Commits

Author SHA1 Message Date
Matthias Krüger
a262c001f6
Rollup merge of #143171 - fmease:fix-span-of-maybe-const-mod, r=compiler-errors
Fix the span of trait bound modifier `[const]`

r? project-const-traits or anyone
2025-06-29 06:59:33 +02:00
León Orell Valerian Liehr
f77fead002
Fix the span of trait bound modifier [const] 2025-06-29 04:56:28 +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
Matthias Krüger
36c2b011cb
Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-dead
New const traits syntax

This PR only affects the AST and doesn't actually change anything semantically.

All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser

Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error

r? ``@fee1-dead``

cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27 22:13:00 +02:00
Michael Goulet
4e51e67a24 Better recovery 2025-06-26 18:11:14 +00:00
Michael Goulet
e63921262c Make recovery for enum with struct field a bit more accurate 2025-06-26 18:11:14 +00:00
Michael Goulet
94e9973b92 Add Ident::is_non_reserved_ident 2025-06-26 18:11:14 +00:00
Oli Scherer
eb7245a864 Change const trait bound syntax from ~const to [const] 2025-06-26 13:46:45 +00:00
Oli Scherer
18f4cb1110 Extract const boundness parsing out into a method 2025-06-25 08:14:22 +00:00
bors
a17780db7b Auto merge of #142997 - workingjubilee:rollup-6lxec87, r=workingjubilee
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#135731 (Implement parsing of pinned borrows)
 - rust-lang/rust#138780 (Add `#[loop_match]` for improved DFA codegen)
 - rust-lang/rust#142453 (Windows: make `read_dir` stop iterating after the first error is encountered)
 - rust-lang/rust#142633 (Error on invalid signatures for interrupt ABIs)
 - rust-lang/rust#142768 (Avoid a bitcast FFI call in transmuting)
 - rust-lang/rust#142825 (Port `#[track_caller]` to the new attribute system)
 - rust-lang/rust#142844 (Enable short-ice for Windows)
 - rust-lang/rust#142934 (Tweak `-Zmacro-stats` measurement.)
 - rust-lang/rust#142955 (Couple of test suite fixes for cg_clif)
 - rust-lang/rust#142977 (rustdoc: Don't mark `#[target_feature]` functions as ⚠)
 - rust-lang/rust#142980 (Reduce mismatched-lifetime-syntaxes suggestions to MaybeIncorrect)
 - rust-lang/rust#142982 (Corrected spelling mistake in c_str.rs)
 - rust-lang/rust#142983 (Taint body on invalid call ABI)
 - rust-lang/rust#142988 (Update wasm-component-ld to 0.5.14)
 - rust-lang/rust#142993 (Update cargo)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-25 04:05:47 +00: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
4f477427b8
Rollup merge of #135731 - frank-king:feature/pin-borrow, r=eholk,traviscross
Implement parsing of pinned borrows

This PR implements part of #130494.

EDIT: It introduces `&pin mut $place` and `&pin const $place` as sugars for `std::pin::pin!($place)` and its shared reference equivalent, except that `$place` will not be moved when borrowing. The borrow check will be in charge of enforcing places cannot be moved or mutably borrowed since being pinned till dropped.

### Implementation steps:
- [x] parse the `&pin mut $place` and `&pin const $place` syntaxes
- [ ] borrowck of `&pin mut|const`
- [ ] support autoref of `&pin mut|const` when needed
2025-06-24 19:45:29 -07:00
bors
2c2bb995af Auto merge of #140999 - hkBst:update-escaper, r=nnethercote
update to literal-escaper 0.0.4 for better API without `unreachable` and faster string parsing

This is the replacement for just the part of https://github.com/rust-lang/rust/pull/138163 dealing with the changed API of unescape functionality, since that got moved into its own crate.

<del>This uses an unpublished version of literal-escaper (https://github.com/rust-lang/literal-escaper/pull/8).</del>

r? `@nnethercote`
2025-06-25 01:03:30 +00: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
Marijn Schouten
707a6f5463 update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing 2025-06-23 06:36:22 +00:00
Guillaume Gomez
194e58c75c
Rollup merge of #142798 - camsteffen:recover-semi, r=compiler-errors
Don't fail to parse a struct if a semicolon is used to separate fields

The first commit is a small refactor.
2025-06-22 17:35:35 +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
Cameron Steffen
26a6b55717 Recover from semicolon field separator 2025-06-20 15:30:09 -05:00
Cameron Steffen
6809ec1648 Factor out seen_comma variable 2025-06-20 12:45:26 -05:00
Trevor Gross
38600a6640
Rollup merge of #142650 - camsteffen:refactor-translator, r=petrochenkov
Refactor Translator

My main motivation was to simplify the usage of `SilentEmitter` for users like rustfmt. A few refactoring opportunities arose along the way.

* Replace `Translate` trait with `Translator` struct
* Replace `Emitter: Translate` with `Emitter::translator`
* Split `SilentEmitter` into `FatalOnlyEmitter` and `SilentEmitter`
2025-06-20 13:36:01 -04:00
Jana Dönszelmann
b9107a83a1
expected word diagnostic test 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
Cameron Steffen
07b9bb1855 Extract Translator struct 2025-06-19 13:02:04 -05: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
bors
1bb335244c Auto merge of #138165 - jdonszelmann:inline, r=oli-obk
Rewrite `inline` attribute parser to use new infrastructure and improve diagnostics for all parsed attributes

r? `@oli-obk`

This PR:
- creates a new parser for inline attributes
- creates consistent error messages and error codes between attribute parsers; inline and others
- as such changes a few error messages for other attributes to be (in my eyes) much more consistent
- tests ast-lowering lints introduced by rust-lang/rust#138164 since this is now useful for the first time
- Coalesce some useless error codes

Builds on top of rust-lang/rust#138164

Closes rust-lang/rust#137950
2025-06-18 06:25:21 +00:00
Jana Dönszelmann
5ab5f8a24a
make error codes reflect reality better 2025-06-17 23:22:51 +02:00
Jacob Pratt
e95fb09dfb
Rollup merge of #142371 - fee1-dead-contrib:push-xqlkumzurkus, r=petrochenkov
avoid `&mut P<T>` in `visit_expr` etc methods

trying a different way than rust-lang/rust#141636
r? ghost
2025-06-17 23:19:34 +02:00
Jana Dönszelmann
672452d573
use consistent attr errors in all attribute parsers 2025-06-17 23:19:31 +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
Jakub Beránek
d68432a1a9
Rollup merge of #142341 - xizheyin:142311, r=fee1-dead
Don't suggest converting `///` to `//` when expecting `,`

Fixes rust-lang/rust#142311
2025-06-16 19:54:33 +02:00
xizheyin
c63665cd73 Dont suggest converting /// to regular comment when it appears after missing , in list
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-16 23:07:11 +08:00
Deadbeef
96fd9fc2dd use if let guards where possible 2025-06-15 15:46:20 +08:00
Frank King
e627f88f88 Implement pinned borrows, part of pin_ergonomics 2025-06-15 10:21:29 +08:00
Jonathan Brouwer
b131b6f630
Rework how the disallowed qualifier lints are generated
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-13 18:13:34 +02:00
Deadbeef
5f0dd44b3b avoid &mut P<T> in visit_expr etc methods 2025-06-12 17:36:03 +08:00
Matthias Krüger
75c186bf43
Rollup merge of #142261 - folkertdev:unstable-attr-correct-edition, r=compiler-errors
use correct edition when warning for unsafe attributes

fixes https://github.com/rust-lang/rust/issues/142182

If an attribute is re-emitted by a macro, the incorrect edition was used to emit warnings for unsafe attributes.

This logic was introduced in https://github.com/rust-lang/rust/pull/139718

cc `@compiler-errors` `@ehuss`
2025-06-12 03:14:52 +02:00
Lukas Wirth
edc405d383 Add expectation for { when parsing lone coroutine qualifiers 2025-06-11 17:11:58 +02:00
Folkert de Vries
2c8257493d
use correct edition when warning for unsafe attributes
If an attribute is re-emitted by a macro, the incorrect edition was used to emit warnings for unsafe attributes
2025-06-09 21:55:22 +02:00
bjorn3
9223704f4b Remove all unused feature gates from the compiler 2025-06-08 14:50:42 +00:00
Guillaume Gomez
93ca0af08c
Rollup merge of #141603 - nnethercote:reduce-P, r=fee1-dead
Reduce `ast::ptr::P` to a typedef of `Box`

As per the MCP at https://github.com/rust-lang/compiler-team/issues/878.

r? `@fee1-dead`
2025-06-06 23:53:16 +02:00
Josh Stone
af2a85bd75 Ensure stack in Parser::parse_ty
This solve a stack overflow found on Fedora s390x when building
`tests/ui/associated-consts/issue-93775.rs`.
2025-06-04 15:21:30 -07:00
Matthias Krüger
0736a03a78
Rollup merge of #141570 - chenyukang:yukang-fix-eq_unspanned, r=workingjubilee
Fix incorrect eq_unspanned in TokenStream

Fixes rust-lang/rust#141522

r? ``@workingjubilee``

should we remove this function?
since it's used in several places, i'd prefer to keep it.
2025-06-04 16:24:07 +02:00
Matthias Krüger
96531418f8
Rollup merge of #141945 - nnethercote:rm-Path-is_ident, r=compiler-errors
Remove `Path::is_ident`.

It checks that a path has a single segment that matches the given symbol, and that there are zero generic arguments. It has a single use.

We also have `impl PartialEq<Symbol> for Path` which does exactly the same thing *except* it doesn't check for zero generic arguments, which seems like an oversight. It has numerous uses.

This commit removes `Path::is_ident`, adds a test for zero generic arguments to `PartialEq<Symbol> for Path`, and changes the single use of `is_ident` to instead use `==`.

r? `@wesleywiser`
2025-06-03 21:53:38 +02:00
Oli Scherer
5fbdfc3e10
Add iter macro
This adds an `iter!` macro that can be used to create movable
generators.

This also adds a yield_expr feature so the `yield` keyword can be used
within iter! macro bodies. This was needed because several unstable
features each need `yield` expressions, so this allows us to stabilize
them separately from any individual feature.

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
Co-authored-by: Travis Cross <tc@traviscross.com>
2025-06-03 10:52:32 -07:00
Nicholas Nethercote
04391045d0 Remove Path::is_ident.
It checks that a path has a single segment that matches the given
symbol, and that there are zero generic arguments. It has a single use.

We also have `impl PartialEq<Symbol> for Path` which does exactly the
same thing *except* it doesn't check for zero generic arguments, which
seems like an oversight. It has numerous uses.

This commit removes `Path::is_ident`, adds a test for zero generic
arguments to `PartialEq<Symbol> for Path`, and changes the single use of
`is_ident` to instead use `==`.
2025-06-03 15:21:33 +10:00
Jubilee
5e139db47b
Rollup merge of #141077 - chenyukang:yukang-fix-140991-comma, r=wesleywiser
Fix the issue of typo of comma in arm parsing

Fixes #140991

I also checked is it a '/', since it's near from ',' from keyboard.
2025-05-30 13:52:25 -07:00
Matthias Krüger
5fc3f26748
Rollup merge of #141004 - matthewjasper:unicode-before-expansion, r=davidtwco
Report text_direction_codepoint_in_literal when parsing

The lint is now reported in code that gets removed/modified/duplicated by macro expansion, and spans are more accurate so we don't get ICEs from trying to split a span in the middle of a character.

This removes support for lint level attributes for `text_direction_codepoint_in_literal` except at the crate level, I don't think that there's an easy way around this when the lint can be reported on code that's removed by `cfg` or that is only in the input of a macro.

Fixes #140281
2025-05-30 07:01:28 +02:00
Jacob Pratt
0ac0285c3f
Rollup merge of #141675 - nnethercote:ItemKind-field-order, r=fee1-dead
Reorder `ast::ItemKind::{Struct,Enum,Union}` fields.

So they match the order of the parts in the source code, e.g.:
```
struct Foo<T, U> { t: T, u: U }
       <-><----> <------------>
       /   |       \
   ident generics  variant_data
```

r? `@fee1-dead`
2025-05-29 04:49:43 +02:00