Commit graph

53442 commits

Author SHA1 Message Date
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
Stuart Cook
55277add61
Rollup merge of #150443 - estebank:long-diff-markers, r=jackh726
Support long diff conflict markers

git can be configured to use more than 7 characters for conflict markers, and jj automatically uses longer conflict markers when the text contains any char sequence that could be confused with conflict markers. Ensure that we only point at markers that are consistent with the start marker's length.

Ensure that we only consider char sequences at the beginning of a line as a diff marker.

Fix https://github.com/rust-lang/rust/issues/150352.
2026-02-08 16:58:23 +11:00
Stuart Cook
1992e7111d
Rollup merge of #152284 - Zalathar:bogus-thir-let, r=nnethercote
Avoid a bogus THIR span for `let x = offset_of!(..)`

The code that creates spans for THIR `let` statements was doing span endpoint manipulation without checking for inclusion/context, resulting in bogus spans observed in https://github.com/rust-lang/rust/pull/151693.

The incorrect spans are easiest to observe with `-Zunpretty=thir-tree`, but they also cause strange user-facing diagnostics for irrefutable let-else.
2026-02-08 12:54:00 +11:00
Jonathan Brouwer
4230c3ab25
Rollup merge of #152300 - jdonszelmann:port-rustc-regions, r=JonathanBrouwer
Port `rustc_regions` to the new attribute parser

r? @JonathanBrouwer
2026-02-07 19:34:51 +01:00
Jonathan Brouwer
f8580ec1dd
Rollup merge of #152288 - JonathanBrouwer:one_accepter_per_attr, r=jdonszelmann
Allow only a single accepter per attribute

This is what we discussed last thursday, that we don't need to support this.

r? @jdonszelmann
2026-02-07 19:34:50 +01:00
Jonathan Brouwer
725eb60ded
Rollup merge of #152261 - fmease:has-own-self, r=BoxyUwU
Introduce helper `ty::Generics::has_own_self`

The pattern `generics.has_self && generics.parent.is_none()` only occurs 5 times in rustc+rustdoc at the time of writing but I keep getting reminded/annoyed that there doesn't exist a nice wrapper fn that abstracts it & immediately clarifies the intent. Most recently that happened when working on my open PR RUST-129543 in which I add yet another occurrence of it ([via](ae8c0a5a46/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs (L1771-L1773))).

For context, `generics.has_self` indicates that there is a `Self` type parameter (at position 0) in the "oldest" / "root" generic parameter list in the chain of generic parameter lists (rephrased: it's true if the chain *as a whole* has a `Self` type parameter). `has_own_self` on the other hand indicates that the `own_params` contain a `Self` type parameter which is sometimes needed for offsetting the own parameters or arguments.
2026-02-07 19:34:50 +01:00
Jonathan Brouwer
f35d734d3f
Remove rustc_fluent_macro 2026-02-07 19:34:21 +01:00
Jonathan Brouwer
c814f76c06
Convert to inline diagnostics in rustc_lint 2026-02-07 19:34:21 +01:00
Jana Dönszelmann
cf1a784f3f
Port rustc_regions to the new attribute parser 2026-02-07 17:24:40 +01:00
bors
c7f5f3e0d5 Auto merge of #152294 - JonathanBrouwer:rollup-ygNTxe8, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#149960 (add `unreachable_cfg_select_predicates` lint)
 - rust-lang/rust#152168 (Port `rustc_intrinsic_const_stable_indirect` and `rustc_intrinsic` to the new attribute parser)
 - rust-lang/rust#152289 (Also duplicate `#[expect]` attribute in `#[derive]`-ed code)
2026-02-07 15:20:28 +00:00
Jonathan Brouwer
fced23053c
Rollup merge of #152289 - Urgau:expect-in-derive-150553, r=jdonszelmann
Also duplicate `#[expect]` attribute in `#[derive]`-ed code

This PR updates our derive logic to also duplicate any `#[expect]` attribute in the `#[derive]`-ed code, as we already do for all the other lint attribute (`#[allow]`, `#[warn]`, `#[deny]`, ...).

The original and duplicated attribute share the same attribute id, which due to the way [`check_expectations`](56aaf58ec0/compiler/rustc_lint/src/expect.rs (L28-L46)) is implemented makes the expectation fulfilled if the lint is either trigger in the original code or the derived code.

This was discussed by T-lang in https://github.com/rust-lang/rust/issues/150553#issuecomment-3780810363.

cc @rust-lang/lang-ops (in case you want to do an FCP)
Fixes rust-lang/rust#150553
2026-02-07 16:04:41 +01:00
Jonathan Brouwer
6e7f929f7c
Rollup merge of #152168 - jdonszelmann:port-rustc-intrinsic-const-stable-indirect, r=jonathanbrouwer
Port `rustc_intrinsic_const_stable_indirect` and `rustc_intrinsic` to the new attribute parser

r? @JonathanBrouwer
2026-02-07 16:04:41 +01:00
Jonathan Brouwer
972a53167c
Rollup merge of #149960 - folkertdev:cfg-select-unreachable-lint, r=JonathanBrouwer
add `unreachable_cfg_select_predicates` lint

tracking issue: https://github.com/rust-lang/rust/issues/115585

Split out from https://github.com/rust-lang/rust/pull/149783. This lint is emitted on branches of a `cfg_select!` that are statically known to be unreachable. The lint is only emitted when the feature is enabled, so this change specifically does not need an FCP, and the lint will be stabilized alongside the feature (see https://github.com/rust-lang/rust/pull/149783#issuecomment-3648000286).
2026-02-07 16:04:40 +01:00
Urgau
2407f47903 Also duplicate #[expect] attribute in #[derive]-ed code 2026-02-07 14:29:40 +01:00
Jonathan Brouwer
fd7ff90f70
Allow only a single accepter per attribute 2026-02-07 14:28:12 +01:00
Jana Dönszelmann
c42a581d2f
Port rustc_intrinsic_const_stable_indirect to the new attribute parser 2026-02-07 14:12:56 +01:00
Jana Dönszelmann
9249e9f78a
Port rustc_intrinsic to the new attribute parser 2026-02-07 14:12:56 +01:00
Zalathar
cc3fdc637a Avoid a bogus THIR span for let x = offset_of!(..) 2026-02-07 23:41:24 +11:00
Jonathan Brouwer
ae9d2d9395
Rollup merge of #152199 - nnethercote:rm-rustc_query_system-cache, r=Zalathar
Move `rustc_query_system::cache`.

It only defines two types, `Cache` and `WithDepNode`. Neither has anything much to do with queries -- they use `DepNodeIndex`, that's all.

This commit moves the module into `rustc_middle`, to where they are used. It also renames the extremely non-descriptive `Cache` as `WithDepNodeCache`.

r? @Zalathar
2026-02-07 13:06:36 +01:00
Jonathan Brouwer
828b9c2cdf
Rollup merge of #152235 - JonathanBrouwer:convert_parse, r=JonathanBrouwer
Convert to inline diagnostics in `rustc_parse`

This was the most annoying one by far, had to make a few changes to the representation of two errors (no user-facing changes tho), these changes are in separate commits for clarity :)

For https://github.com/rust-lang/rust/issues/151366
r? @jdonszelmann
2026-02-07 13:06:34 +01:00
Jonathan Brouwer
00dd7dbe57
Allow more capitalized words 2026-02-07 10:31:36 +01:00
Jonathan Brouwer
c5587ca919
Split parse_inner_attr errors by case 2026-02-07 10:30:42 +01:00
Jonathan Brouwer
cda9b8c157
Split ComparisonOrShiftInterpretedAsGenericSugg 2026-02-07 10:30:42 +01:00
Jonathan Brouwer
9a114c686f
Convert to inline diagnostics in rustc_parse 2026-02-07 10:30:40 +01:00
Jonathan Brouwer
5e476baeab
Rollup merge of #152265 - lapla-cogito:tytuple_agg, r=Zalathar
Use `.map.collect` to aggregate in `.to_ty` of tuples

Since rust-lang/rust#48994 might have been resolved, we can address the FIXME.
2026-02-07 09:41:08 +01:00
Jonathan Brouwer
723eb92a31
Rollup merge of #152252 - JonathanBrouwer:port-tidy-checks, r=jdonszelmann
Convert diagnostic style checks

For https://github.com/rust-lang/rust/issues/151366

r? @jdonszelmann
2026-02-07 09:41:07 +01:00
Jonathan Brouwer
defc1d7a95
Rollup merge of #150949 - Bryntet:port_symbol_mangler_attrs, r=jdonszelmann,JonathanBrouwer
Port symbol mangler attrs

Tracking issue: rust-lang/rust#131229

@JonathanBrouwer could you run perf on this?
2026-02-07 09:41:07 +01:00
Jonathan Brouwer
d7c812cb57
Rollup merge of #146900 - taiki-e:avr-target-feature, r=workingjubilee
Add avr_target_feature

This adds the following unstable target features (tracking issue: https://github.com/rust-lang/rust/issues/146889):

- The following two are particularly important for properly supporting inline assembly:
  - `tinyencoding`: AVR has devices that reduce the number of registers, similar to RISC-V's RV32E. This feature is necessary to support inline assembly in such devices. (see also https://github.com/rust-lang/rust/pull/146901)
  - `lowbytefirst`: AVR's memory access is per 8-bit, and when writing 16-bit ports, the bytes must be written in a specific order. This order depends on devices, making this feature necessary to write proper inline assembly for such use cases. (see also 2a528760bf)
- The followings help recognizing whether specific instructions are available:
  - `addsubiw`
  - `break`
  - `eijmpcall`
  - `elpm`
  - `elpmx`
  - `ijmpcall`
  - `jmpcall`
  - `lpm`
  - `lpmx`
  - `movw`
  - `mul`
  - `rmw`
  - `spm`
  - `spmx`

  Of these, all except `addsubiw`, `break`, `ijmpcall`, `lpm`, `rmw`, `spm`, and `spmx` have [corresponding conditional codes in avr-libc](https://github.com/search?q=repo%3Aavrdudes%2Favr-libc+%2F__AVR_HAVE_%2F&type=code&p=1). LLVM also has `des` feature, but I excluded it from this PR because [DES](https://en.wikipedia.org/wiki/Data_Encryption_Standard) is insecure.

- Report future-incompatible warning (https://github.com/rust-lang/rust/issues/116344) for -C target-feature=-sram and -C target-cpu=<device_without_sram> cases because SRAM is minimum requirement for non-assembly language in both avr-gcc and LLVM.
  - See https://github.com/rust-lang/rust/pull/146900#issuecomment-3323558005 for details.

LLVM also has `smallstack`, `wrappingrjmp`, and `memmappedregs` features, but I skipped them because they didn't seem to belong to either of the above categories, but I might have missed something.

(The feature names are match with [definitions in LLVM](https://github.com/llvm/llvm-project/blob/llvmorg-21.1.0/llvm/lib/Target/AVR/AVRDevices.td).)

cc @Patryk27 @Rahix
r? workingjubilee

@rustbot label +O-AVR +A-target-feature
2026-02-07 09:41:06 +01:00
Jonathan Brouwer
edd43c9e1f
Fix existing messages in the diag structs 2026-02-07 09:11:34 +01:00
Jonathan Brouwer
ca9c227700
Check style of messages in rustc_macros 2026-02-07 09:09:23 +01:00
lapla
b5cd820ef4
Use .map.collect to aggregate in .to_ty of tuples 2026-02-07 16:49:06 +09:00
Nicholas Nethercote
b49ab57d6b Rename Cache as WithDepNodeCache.
Because `Cache` is unhelpfully vague.
2026-02-07 14:14:16 +11:00
Nicholas Nethercote
b29a9b6920 Move rustc_query_system::cache to rustc_middle::traits. 2026-02-07 14:06:46 +11:00
Folkert de Vries
a6bd7cc54e
make the lint more sophisticated 2026-02-07 02:19:43 +01:00
Folkert de Vries
8aea4b1775
add unreachable_cfg_select_predicates lint
This is emitted on branches of a `cfg_select!` that are statically known
to be unreachable.
2026-02-07 02:19:42 +01:00
Edvin Bryntesson
10f0c2d579
Port #[rustc_symbol_name] and #[rustc_def_path] to attr parser 2026-02-07 01:43:00 +01:00
Jonathan Brouwer
98ae26c830
Rollup merge of #152234 - BoxyUwU:dont_strip_const_blocks, r=oli-obk
Dont strip const blocks in array lengths

r? oli-obk

mGCA now handles const blocks by *always* handling them during `lower_expr_to_const_arg_direct` instead of *sometimes* stripping them out at parse time. This is just generally a lot clearer/nicer but also means parsing isn't lossy which is just straight up wrong.

We now use `MgcaDisambiguation::Direct` for const blocks because we "directly" represent a const block as `hir::ConstArgKind::Anon` :> The only time that an anon const for const generics uses `MgcaDisambiguation::AnonConst` is for unbraced literals.

Once we properly support literals in `hir::ConstArgKind` (see rust-lang/rust#152139 rust-lang/rust#152001) then `MgcaDisambiguation` can be renamed to `AnonConstKind` with `TypeSystem` and `NonTypeSystem` variants. We can also get rid of `mgca_direct_lit_hack`. I expect this to be a very nice cleanup :)

Fixes rust-lang/rustfmt#6788

The diff relating to passing spans around is to avoid a bunch of mGCA diagnostics changing from  `const {}` to `{}`. I'm not entirely sure why this was happening.

cc @rust-lang/rustfmt

How do I run the tests in the rustfmt repo from here? `x test rustfmt` only seems to run like 100 tests and doesn't result in a `target/issue-6788.rs` getting created. I've verified locally that this formats correctly though
2026-02-07 01:18:54 +01:00
Jonathan Brouwer
a66d0f8598
Rollup merge of #152186 - GuillaumeGomez:inline-diag-rustc_const_eval, r=JonathanBrouwer
Convert to inline diagnostics in `rustc_const_eval`

Part of rust-lang/rust#151366.

r? @JonathanBrouwer
2026-02-07 01:18:53 +01:00
Jonathan Brouwer
4fa1cdb455
Rollup merge of #152126 - GuillaumeGomez:inline-diag-rustc_mir_build, r=JonathanBrouwer
Convert to inline diagnostics in `rustc_mir_build`

Part of https://github.com/rust-lang/rust/issues/151366.

r? @JonathanBrouwer
2026-02-07 01:18:53 +01:00
León Orell Valerian Liehr
5ea37f7add
Introduce helper ty::Generics::has_own_self 2026-02-06 23:45:57 +01:00
Guillaume Gomez
c6829020b0 Convert to inline diagnostics in rustc_const_eval 2026-02-06 22:55:58 +01:00
Guillaume Gomez
885a8081c4 Convert to inline diagnostics in rustc_mir_build 2026-02-06 22:21:27 +01:00
Boxy
a86cfbbaab keep const blocks around 2026-02-06 19:36:39 +00:00
bors
efc9e1b50c Auto merge of #152239 - JonathanBrouwer:rollup-2BolGX5, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#152129 (MGCA: require #[type_const] on free consts too)
 - rust-lang/rust#152139 (mGCA: Support directly represented negated literals)
 - rust-lang/rust#152189 (Convert to inline diagnostics in `rustc_passes`)
2026-02-06 18:42:38 +00:00
Jonathan Brouwer
ce8d09b268
Rollup merge of #152189 - JonathanBrouwer:convert_passes, r=lqd
Convert to inline diagnostics in `rustc_passes`

For https://github.com/rust-lang/rust/issues/151366
r? @jdonszelmann
2026-02-06 18:04:41 +01:00
Jonathan Brouwer
30bbeae0a5
Rollup merge of #152139 - khyperia:mgca-negative-literals, r=BoxyUwU
mGCA: Support directly represented negated literals

fixes rust-lang/rust#152123

PatExprKind already awkwardly tacks on a `negated: bool` for the same purpose:

8bccf1224d/compiler/rustc_hir/src/hir.rs (L1954-L1959)

perhaps one day we should indeed do that FIXME...

r? @BoxyUwU
2026-02-06 18:04:40 +01:00
khyperia
e6f5b97152 MGCA: require #[type_const] on free consts too 2026-02-06 15:35:18 +01:00
Jonathan Brouwer
a9b4c7cfc9
Rollup merge of #152000 - lapla-cogito:ice_151027, r=BoxyUwU
Fix ICE in normalizing inherent associated consts with `#[type_const]`

Fixes rust-lang/rust#151027
Fixes rust-lang/rust#138089
Fixes rust-lang/rust#138226
Fixes rust-lang/rust#150960

When an inherent associated const is marked with `#[type_const]`, its generics expect args in the format `[Self, own_params...]`, similar to inherent associated types. However, HIR typeck's `instantiate_value_path` was constructing args in the regular associated const format `[impl_params..., own_params...]`. This mismatch caused ICEs when the `args` were later used in contexts expecting the IAC format, such as user type annotations and `borrowck`'s type ascription.
2026-02-06 15:33:40 +01:00
Jonathan Brouwer
9f0eba2a06
Rollup merge of #151590 - folkertdev:cmse-unwrap-transparent, r=davidtwco
cmse: don't use `BackendRepr` when checking return type

tracking issue: https://github.com/rust-lang/rust/issues/81391
tracking issue: https://github.com/rust-lang/rust/issues/75835

r? davidtwco
cc @RalfJung

context: https://github.com/rust-lang/rfcs/pull/3884#discussion_r2715791429

I believe this is more reliable, and no longer relies on `BackendRepr`. I also added a test specifically for using `repr(Rust)`.
2026-02-06 15:33:38 +01:00
khyperia
54a9be469a mGCA: Support directly represented negated literals 2026-02-06 14:04:55 +01:00