Commit graph

1469 commits

Author SHA1 Message Date
cyrgani
195b849ea7 remove the explicit error for old rental versions 2026-02-17 20:11:01 +00:00
Stuart Cook
910d4f4c09
Rollup merge of #152206 - tshepang:misc, r=davidtwco
misc doc improvements

These are things I collected as I was looking at code and docs
2026-02-17 13:02:23 +11:00
Stuart Cook
1367126837
Rollup merge of #151783 - mu001999-contrib:impl/final-method, r=fee1-dead
Implement RFC 3678: Final trait methods

Tracking: https://github.com/rust-lang/rust/issues/131179

This PR is based on rust-lang/rust#130802, with some minor changes and conflict resolution.

Futhermore, this PR excludes final methods from the vtable of a dyn Trait.

And some excerpt from the original PR description:
> Implements the surface part of https://github.com/rust-lang/rfcs/pull/3678.
>
> I'm using the word "method" in the title, but in the diagnostics and the feature gate I used "associated function", since that's more accurate.

cc @joshtriplett
2026-02-17 13:02:21 +11:00
Jonathan Brouwer
38cc50b6e4
Rollup merge of #152612 - JonathanBrouwer:rename_to_msg, r=jdonszelmann
Rename `inline_fluent!` to `msg!`

This was the most popular name for the macro as voted in [#t-compiler > Bikeshed the new `inline_fluent!` macro @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Bikeshed.20the.20new.20.60inline_fluent!.60.20macro/near/572751863)
2026-02-14 18:55:38 +01:00
Jonathan Brouwer
8a03b5f3ec
Rollup merge of #152531 - cyrgani:pm-yet-another-cleanup, r=petrochenkov
`proc_macro::bridge`: simplify `ExecutionStrategy` and `DispatcherTrait`

Also includes another tiny cleanup (functions can only have one return type).
2026-02-14 18:55:36 +01:00
Jonathan Brouwer
018a5efcf7
Rename inline_fluent! to msg! 2026-02-14 13:47:52 +01:00
cyrgani
f601b29825 inline SameThread and CrossThread 2026-02-13 11:24:50 +00:00
cyrgani
31053484a7 replace MessagePipe trait with its impl 2026-02-13 11:23:26 +00:00
Jonathan Brouwer
cbc661022e Port #[rustc_diagnostic_item] to the new attribute parsers 2026-02-13 09:46:47 +00:00
mu001999
7077797f52 Parse and lower final for methods
Co-authored-by: Michael Goulet <michael@errs.io>
2026-02-12 15:12:29 +08:00
Matthias Krüger
88eda646f2
Rollup merge of #152431 - oli-obk:limited_stability_attr, r=jdonszelmann
Restrict the set of things that const stability can be applied to

r? @jdonszelmann
2026-02-11 13:48:47 +01:00
Oli Scherer
475b9d9819 Prevent const stability attrs from being applied to macros via the normal attribute logic instead of special cased checks 2026-02-10 09:48:03 +00:00
Keith-Cancel
73a991fb9d Allow provisional mgca syntax of type const <IDENT> = <EXPR> to be reconized.
Revert, but without type const.

Update symbol for feature err, then update suggestion output, and lastly update tests that change because of those.

Update these new tests with the correct syntax, and few existing tests with the new outputs the merge with main added.

Fix for tidyfmt and some errors when manually resolving a merge conflicts.

Update these tests to use update error messages and type const syntax.

Update comments and error message to use new syntax instead of old type_const attribute.

Remove the type_const attribute

update some more tests to use the new syntax.

Update these test cases.

update feature gate test

Change gate logic for `mgca_type_const_syntax` to work also if `min_generic_const_args` is enabled.

Create a new feature gate that checks for the feature before expansion.

Make rustfmt handle the `type const` syntax correctly.

Add a convience method to check if a RhsKind is type const.

Rename `Const` discriminant to `Body` for `ConstItemRhsKind`

Give the `TraitItemKind` flag an enum instead of a simple bool to better describe what the flag is for.

Update formatting for these match statements.

Update clippy test to use type const syntax.

Update test to use type const syntax.

update rustfmt to match ast items.

Update clippy to match ast and hir items.

Few more test cases that used old attribute, instead of 'type const'

Update to match the output from the feature gate checks.

tidyfmt adjustments.

Update the is_type_const, so I can constrain record!(..) in encoder.rs

Update conditional compilation test.

Move the feature gate to after expansion to allow for cfg(...) to work.

Update some more tests to use the new syntax.

Update type const tests in associated-const-bindings to use new syntax.

Don't check based off the attribute, but the item here.

Update some tests outside of the const_generics folder that were using #[type_const]

update the tests in associated consts that use #[type_const] to use type const

Update these mgca tests with the type const syntax.

Add a flag to TraitItemKind for detecting type const for now. Maybe later change ItemConstRhs to have optional consts but that touches a lot more lines of code.

Don't need into for these now that it's a query.

Add is_type_const query to handle foreign def ids.

update this test to use type const syntax.

Fix logic here, we only want to lower if there is expression in this case.

Update built-in macros to use ConstItemRhsKind

Update more instance of the old ConstItemRhs.

Rename ConstItemKind to ConstItemRhsKind, I noticed there is a typed called ConstantItemKind, so add the Rhs to the name to avoid confusion.

Update lower to use ConstItemKind

Add an other helper method to check if the rhs kinda has an expr.

Update item parse to use ConstItemKind enum.

Felt the field name could a be little clear when editing a few other things.

Change the ConstItem struct see know if we have a type const or regular const.

Make sure this syntax is properly feature gated.
2026-02-09 07:59:24 -08:00
Stuart Cook
68f4a99963
Rollup merge of #151887 - scottmcm:homogeneous-try-in-compiler, r=jackh726
Remove some unnecessary `try`-related type annotations

I left a few, like
```rust
let result: Result<_, ModError<'_>> = try {
```
where it felt like seeing it might still be useful for the reader.

Feel free to push back on any of these changes if you think they should be left alone.
2026-02-08 16:58:23 +11:00
Tshepang Mbambo
193bc70101 missing word 2026-02-06 05:26:53 +02:00
Tshepang Mbambo
2a6b9e6bef inline the binding 2026-02-06 05:26:53 +02:00
Jonathan Brouwer
9dab26a9ab
Convert to inline diagnostics in rustc_expand 2026-02-04 16:16:16 +01:00
bors
0c40f5be0c Auto merge of #151929 - camsteffen:lengg, r=BoxyUwU
Use with_capacity in query_key_hash_verify and PlaceholderExpander

Addresses the first two items from https://github.com/rust-lang/rust/issues/137005#issuecomment-2687803558.
2026-02-03 22:20:57 +00:00
mejrs
30ae46fab1 Use rustc_parse's Recovery instead of a boolean 2026-02-02 15:01:32 +01:00
Cameron Steffen
60f567916c Add capacity to PlaceholderExpander 2026-01-31 20:33:16 -06:00
Scott McMurray
f7931c8050 Remove some unnecessary try-related type annotations
I left a few, like
```rust
let result: Result<_, ModError<'_>> = try {
```
where it felt like seeing it might still be useful for the reader.

Feel free to push back on any of these changes if you think seeing the type would be better.
2026-01-30 18:21:19 -08:00
Jamie Hill-Daniel
02bd3e86c0 Use Rustc prefix for rustc attrs in AttributeKind 2026-01-29 14:52:09 +00:00
Jonathan Brouwer
84bb764741
Rollup merge of #151694 - cyrgani:more-pm-cleanup, r=petrochenkov
more `proc_macro` bridge cleanups

Some followups made possible by rust-lang/rust#151505.
2026-01-27 17:00:53 +01:00
Esteban Küber
4a27be6972 Do not mention -Zmacro-backtrace for std macros that are a wrapper around a compiler intrinsic 2026-01-26 17:34:31 +00:00
cyrgani
bf1c3f6a14 move Types from with_api! to Server 2026-01-26 14:10:11 +00:00
Matthias Krüger
996992eced
Rollup merge of #151505 - bjorn3:proc_macro_refactors, r=petrochenkov,Kobzol
Various refactors to the proc_macro bridge

This reduces the amount of types, traits and other abstractions that are involved with the bridge, which should make it easier to understand and modify. This should also help a bit with getting rid of the type marking hack, which is complicating the code a fair bit.

Fixes: rust-lang/rust#139810
2026-01-25 07:43:00 +01:00
bjorn3
e8c48c6895 Fix review comments 2026-01-24 14:44:03 +00:00
bjorn3
8a119c3145 Merge FreeFunctions trait into Server trait
And rename FreeFunctions struct to Methods.
2026-01-24 14:44:03 +00:00
bjorn3
9481890143 Various simplifications after moving all bridge methods to a single type 2026-01-24 14:44:03 +00:00
bjorn3
2f44019470 Move all bridge methods into a single type 2026-01-24 14:44:03 +00:00
Matthias Krüger
ac8e7f2548
Rollup merge of #151516 - mejrs:ignore_nonmeta, r=jdonszelmann,jonathanbrouwer
Do not emit errors on non-metaitem diagnostic attr input

This unblocks porting over diagnostic attributes by properly addressing https://github.com/rust-lang/rust/pull/151056#discussion_r2688179459

r? @JonathanBrouwer
2026-01-24 15:35:10 +01:00
Matthias Krüger
0bb15457de
Rollup merge of #149174 - GrigorenkoPV:const_block_item, r=me,ytmimi
`const` blocks as a `mod` item

Tracking issue: rust-lang/rust#149226

This adds support for writing `const { ... }` as an item in a module. In the current implementation, this is a unique AST item that gets lowered to `const _: () = const { ... };` in HIR.

rustfmt support included.

TODO:
- `pub const { ... }` does not make sense (see rust-lang/rust#147136). Reject it. Should this be rejected by the parser or smth?
- Improve diagnostics (preferably they should not mention the fake `_` ident).
2026-01-24 15:35:08 +01:00
mejrs
215a82c7df Do not emit errors on non-metaitem diagnostic attr input 2026-01-22 23:42:01 +01:00
Mark Rousskov
3dc7a1f33b Bump stage0 2026-01-21 20:03:56 -05:00
Pavel Grigorenko
5eb01938c9 Audit AllowConstBlockItems 2026-01-21 19:36:14 +03:00
Pavel Grigorenko
8439fda014 Sugar for const _: () = 2026-01-21 18:12:21 +03:00
Jonathan Brouwer
0ee7d96253
Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase
This PR was mostly made by search&replacing
2026-01-19 17:39:49 +01:00
Olivier Goffart
f3e73dced1 Supress some lookup errors if a module contains compile_error!
The problem is that when a macro expand to `compile_error!` because
its input is malformed, the actual error message from the
`compile_error!` might be hidden in a long list of other messages about
using items that should have otherwise been generated by the macro.

So suppress error about missing items in that module.

Fixes issue 68838
2026-01-18 14:37:57 +01:00
bors
503745e917 Auto merge of #151210 - matthiaskrgr:rollup-JwDAUuv, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#145354 (Cache derive proc macro expansion with incremental query)
 - rust-lang/rust#151123 (Support primitives in type info reflection)
 - rust-lang/rust#151178 (simplify words initialization using Rc::new_zeroed)
 - rust-lang/rust#151187 (Use `default_field_values` more in `Resolver`)
 - rust-lang/rust#151197 (remove lcnr from compiler review rotation)
 - rust-lang/rust#151203 (Revert `QueryStackFrame` split)

r? @ghost
2026-01-16 16:44:08 +00:00
Felix Rath
8fa2f693bb
Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
Guillaume Gomez
cd7d40d975 Update rustc_attr_parsing::SharedContext::target type from Option<Target> to Target 2026-01-15 15:06:29 +01:00
Jonathan Brouwer
b5dd72d292
Port #[collapse_debuginfo] to the new attribute parsing system 2026-01-11 10:54:45 +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
Matthias Krüger
8add20b77f
Rollup merge of #150026 - Delta17920:fix/150002-macro-concat-bug, r=jdonszelmann
Fix macro_metavar_expr_concat behavior with nested repetitions

**The Bug**: The `${concat(...)}` expression was using the wrong loop index when inside nested repetitions (like optional groups), causing it to get "stuck" on the first element and generate duplicate code.

**The Fix**: Updated `metavar_expr_concat` in `transcribe.rs` to correctly search the repetition stack (`tscx.repeats`) for the target variable instead of blindly using the last index.

**Tests**:
    Added `tests/ui/macros/concat-nested-repetition.rs.`

Fixes rust-lang/rust#150002
2026-01-06 18:43:28 +01:00
Jonathan Brouwer
5590fc034c
Make cfg and cfg_attr trace attributes into early parsed attributes 2026-01-06 09:04:08 +01:00
Jonathan Brouwer
03fb7eeced
Create a rustc_ast representation for parsed attributes 2026-01-06 09:03:35 +01:00
Jonathan Brouwer
7afba2977d
Make attr path symbols rather than idents 2025-12-22 16:26:14 +01:00
delta17920
3566b6775c Fix macro_metavar_expr_concat behavior with nested repetitions 2025-12-18 15:53:39 +00:00
bors
8188f6c808 Auto merge of #149709 - Urgau:overhaul-filenames, r=davidtwco
Overhaul filename handling for cross-compiler consistency

This PR overhauls the way we handle filenames in the compiler and `rmeta` in order to achieve achieve cross-compiler consistency (ie. having the same path no matter if the filename was created in the current compiler session or is coming from `rmeta`).

This is required as some parts of the compiler rely on consistent paths for the soundness of generated code (see rust-lang/rust#148328).

In order to achieved consistency multiple steps are being taken by this PR:
 - by making `RealFileName` immutable
 - by only having `SourceMap::to_real_filename` create `RealFileName`
   - currently `RealFileName` can be created from any `Path` and are remapped afterwards, which creates consistency issue
 - by also making `RealFileName` holds it's working directory, embeddable name and the remapped scopes
   - this removes the need for a `Session`, to know the current(!) scopes and cwd, which is invalid as they may not be equal to the scopes used when creating the filename

In order for `SourceMap::to_real_filename` to know which scopes to apply `FilePathMapping` now takes the current remapping scopes to apply, which makes `FileNameDisplayPreference` and company useless and are removed.

This PR is split-up in multiple commits (unfortunately not atomic), but should help review the changes.

Unblocks https://github.com/rust-lang/rust/pull/147611
Fixes https://github.com/rust-lang/rust/issues/148328
2025-12-13 14:32:09 +00:00
Jacob Pratt
b32845c61a
Rollup merge of #148837 - estebank:let-else, r=Kivooeo
Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`
2025-12-13 00:55:55 -05:00