Commit graph

22991 commits

Author SHA1 Message Date
Asuna
5c057ad896 Remove their own TypeId from type info for primitives 2026-01-15 22:58:39 +01:00
reddevilmidzy
77b2a196fb cleaned up some tests
merge privacy/privacy-sanity-2 with privacy/privacy-sanity.rs

Add comment to generics/type-args-on-module-in-bound.rs

Add comment to array-slice-vec/closure-in-array-eln.rs

Add comment to array-slice-vec/return-in-array-len.rs

Merge for-loop-while/break-outside-loop-2.rs with
for-loop-while/break-outside-loop.rs

Add comment to macros/column-macro-collision.rs

Add comment to privacy/private-extern-fn-visibility.rs

Add comment to mismatched_types/vec-hashset-type-mismatch.rs

Merge std-sync-right-kind-impls-2.rs with std-sync-right-kind-impls.rs

Add comment to array-slice-vec/slice-of-multi-ref.rs

Add comment to mismatched_types\vec-hashset-type-mismatch.rs

Add comment to derives/derive-hygiene-struct-builder.rs

Add comment to label/undeclared-label-span.rs

Add comment to label\undeclared-label-span.rs

Add comment to mismatched_types/array-repeat-unit-struct.rs
2026-01-16 06:50:34 +09:00
reddevilmidzy
559e672489 move some tests 2026-01-16 06:50:21 +09:00
Esteban Küber
9750d22c17 Silence unused type param and inference errors on struct parse error 2026-01-15 21:16:48 +00:00
bors
22c74ba918 Auto merge of #151056 - mejrs:do_not_recommend, r=JonathanBrouwer
Port `diagnostic::do_not_recommend` to new attr parsing

r? @jdonszelmann
2026-01-15 19:35:19 +00:00
Maja Kądziołka
a28b279357 Make some mir-opt tests more resilient 2026-01-15 17:33:39 +01:00
Maja Kądziołka
940a48966f non-exhaustive-match.rs: actually test what the comments say 2026-01-15 17:32:45 +01:00
Maja Kądziołka
4e090078b4 capture-enums.rs: get rid of feature gate noise 2026-01-15 17:24:35 +01:00
Maja Kądziołka
8536979cdb Move some match edge case tests
While these test cases were inspired by issue 137467, they aren't
directly related, and better fit into match-edge-cases_2.rs
2026-01-15 17:22:58 +01:00
Shoyu Vanilla
08362d3e51 fix: Do not delay E0107 when there exists an assoc ty with the same name 2026-01-16 00:35:10 +09:00
Stuart Cook
256722639d
Rollup merge of #151130 - diesel2, r=lqd
resolve: Downgrade `ambiguous_glob_imports` to warn-by-default

But still keep it report-in-deps, as decided in https://github.com/rust-lang/rust/issues/149845#issuecomment-3750423840.

This will need to be reverted after ~February 27 2026, when Rust 1.95 branches out from the main branch.

Closes https://github.com/rust-lang/rust/issues/149845.
2026-01-15 21:39:04 +11:00
Stuart Cook
9682509bdb
Rollup merge of #150979 - typeck-pat, r=lcnr
Avoid ICEs after bad patterns, for the other syntactic variants

This PR introduces changes equivalent to the ones in rust-lang/rust#126320, but also for struct and tuple patterns, instead of tuple struct patterns only.

Fixes rust-lang/rust#150507.
2026-01-15 21:39:03 +11:00
Stuart Cook
eafe40e05c
Rollup merge of #150846 - thir-hir-id, r=lcnr
include `HirId`s directly in the THIR, not wrapped in `LintLevel`s

Occurrences of `LintLevel` in the THIR were always `LintLevel::Explicit`, containing a `HirId`, so we don't need to make it possible to put `LintLevel::Inherited` there. Removing the unused case where `HirId`s aren't present in the THIR slightly simplifies diagnostics/lints/tools that want to map from the THIR back to the HIR, e.g. rust-lang/rust#145569.

Since `LintLevel` is no longer present in the THIR, I've moved it in the second commit to live in `rustc_mir_build`; that's where it's actually used. I'm not sure exactly where exactly it should live there, but I put it in the `builder::scope` module since it's used by `Builder::in_scope` for determining when to introduce source scopes.

r? lcnr as the reviewer of rust-lang/rust#145569, since this was discussed there
2026-01-15 21:39:02 +11:00
Vadim Petrochenkov
cd05071ec4 resolve: Downgrade ambiguous_glob_imports to warn-by-default
But still keep it report-in-deps.

To revert after ~February 27 2026, when Rust 1.95 branches out from the main branch.
2026-01-15 13:02:20 +03:00
Stuart Cook
d87e654be9
Rollup merge of #151145 - reduce-rustdoc-flakyness, r=jieyouxu
Reduce rustdoc GUI flakyness, take 2

Fixes https://github.com/rust-lang/rust/issues/151006 (hopefully).

Seems like https://github.com/rust-lang/rust/pull/151053 did not fix the flakyness issue, so here is another take on this issue.

r? @jieyouxu
2026-01-15 14:10:21 +11:00
Jieyou Xu
cd79ff2e2c
Revert "avoid phi node for pointers flowing into Vec appends #130998"
This reverts PR <https://github.com/rust-lang/rust/pull/130998> because
the added test seems to be flaky / non-deterministic, and has been
failing in unrelated PRs during merge CI.
2026-01-15 09:37:16 +08:00
dianne
36d37fd11b THIR: directly contain HirIds, not LintLevels 2026-01-14 14:25:21 -08:00
Guillaume Gomez
4bacdf7b8b Reduce rustdoc GUI flakyness, take 2 2026-01-14 22:47:53 +01:00
Jonathan Brouwer
00501de1c8
Rollup merge of #151099 - issue-84327-2, r=fmease
Recover parse gracefully from `<const N>`

When a const param doesn't have a `: Type`, recover the parser state and provide a structured suggestion. This not only provides guidance on what was missing, but it also makes subsuequent errors to be emitted that would otherwise be silenced.

```
error: expected `:`, found `>`
  --> $DIR/incorrect-const-param.rs:26:16
   |
LL | impl<T, const N> From<[T; N]> for VecWrapper<T>
   |                ^ expected `:`
   |
help: you might have meant to write the type of the const parameter here
   |
LL | impl<T, const N: /* Type */> From<[T; N]> for VecWrapper<T>
   |                ++++++++++++
```

r? @fmease

Follow up to rust-lang/rust#151077. Fix rust-lang/rust#84327.
2026-01-14 22:30:00 +01:00
Jonathan Brouwer
46d4bbf6df
Rollup merge of #150971 - disallow-eii-in-statement-position, r=wafflelapkin
Disallow eii in statement position

With how v2 macros resolve, and the name resolution of `super` works, I realized with @WaffleLapkin that there's actually no way to consistently expand EIIs in statement position.

r? @WaffleLapkin
2026-01-14 22:29:58 +01:00
Jonathan Brouwer
27e6ef9f6d
Rollup merge of #150962 - rm/feed_const_ty, r=BoxyUwU
Remove `FeedConstTy` and provide ty when lowering const arg

r? @BoxyUwU

edit: BoxyUwU

`FeedConstTy` currently only provides the expected type of a const argument *sometimes* (e.g. previously array lengths did not do this). This causes problems with mGCA's directly represented const arguments which always need to know their expected type.
2026-01-14 22:29:57 +01:00
Jonathan Brouwer
6cdcef5454
Rollup merge of #150939 - impasse, r=estebank
resolve: Relax some asserts in glob overwriting and add tests

Fixes https://github.com/rust-lang/rust/issues/150927.
Fixes https://github.com/rust-lang/rust/issues/150928.
Fixes https://github.com/rust-lang/rust/issues/150929.
Fixes https://github.com/rust-lang/rust/issues/150976.
Fixes https://github.com/rust-lang/rust/issues/150977.
Fixes https://github.com/rust-lang/rust/issues/151008.
Fixes https://github.com/rust-lang/rust/issues/151037.
Fixes https://github.com/rust-lang/rust-clippy/issues/16398.
r? @yaahc
2026-01-14 22:29:57 +01:00
Jonathan Brouwer
9ef76797ea
Rollup merge of #150590 - ident-kw-ice, r=petrochenkov
Don't try to recover keyword as non-keyword identifier

Fixes rust-lang/rust#149692.

On beta after rust-lang/rust#146978, we ICE on

```rs
macro_rules! m {
    ($id:item()) => {}
}

m!(Self());
```

where `Self` in the macro invocation is a keyword not a "normal" identifier, while attempting to recover an missing keyword before an identifier. Except, `Self` *is* a keyword, so trying to parse that as a non-reserved identifier expectedly fails.

I suspect rust-lang/rust#146978 merely unmasked a possible code path to hit this case; this logic has been so for a good while. Previously, on stable, the error message looks something like

```rs
error: expected identifier, found keyword `Self`
 --> src/lib.rs:5:4
  |
5 | m!(Self());
  |    ^^^^ expected identifier, found keyword

error: missing `fn` or `struct` for function or struct definition
 --> src/lib.rs:5:4
  |
2 |     ($id:item()) => {}
  |      -------- while parsing argument for this `item` macro fragment
...
5 | m!(Self());
  |    ^^^^
  |
help: if you meant to call a macro, try
  |
5 | m!(Self!());
  |        +
```

I considered restoring this diagnostic, but I'm not super convinced it's worth the complexity (and to me, it's not super clear what the user actually intended here).
2026-01-14 22:29:56 +01:00
Jonathan Brouwer
e04af73628
Rollup merge of #150586 - intra-doc-assoc-alias, r=GuillaumeGomez
rustdoc: Fix intra-doc link bugs involving type aliases and associated items

This PR:
- Add support for linking to fields of variants behind a type alias.
- Correctly resolve links to fields and variants behind a type alias to the alias's version of the docs.
- Refactor some intra-doc links code to make it simpler.
- Add tests for the status quo of linking to associated items behind aliases.

Future steps:
- Nail down the rules of when inherent and trait impls are inlined into an alias's docs, and when impls on the alias appear for the aliased type.
- Adjust the resolutions of intra-doc links, through aliases, to associated items based on these rules.

r? @GuillaumeGomez
2026-01-14 22:29:55 +01:00
Jonathan Brouwer
a496d1de66
Rollup merge of #150585 - issue-149559, r=petrochenkov
Add a context-consistency check before emitting redundant generic-argument suggestions

Fixes rust-lang/rust#149559

Add a context-consistency check before emitting redundant generic-argument suggestions. If the redundant argument spans come from mixed hygiene contexts (e.g., macro definition + macro callsite), we skip the suggestion to avoid malformed `shrink_to_hi().to(...)` spans and potential ICEs.
2026-01-14 22:29:55 +01:00
Guillaume Gomez
c341745970 Add regression test for #151028 2026-01-14 21:52:30 +01:00
Maja Kądziołka
1028c7a66a Avoid ICEs after bad patterns, for the other syntactic variants 2026-01-14 20:54:27 +01:00
Asuna
79ec275e2d Support primitives in type info reflection
Support {bool,char,int,uint,float,str} primitive types for feature
`type_info` reflection.
2026-01-14 19:15:39 +01:00
Esteban Küber
92db7b2b5a Recover parse gracefully from <const N>
When a const param doesn't have a `: Type`, recover the parser state and provide a structured suggestion. This not only provides guidance on what was missing, but it also makes subsuequent errors to be emitted that would otherwise be silenced.

```
error: expected `:`, found `>`
  --> $DIR/incorrect-const-param.rs:26:16
   |
LL | impl<T, const N> From<[T; N]> for VecWrapper<T>
   |                ^ expected `:`
   |
help: you might have meant to write the type of the const parameter here
   |
LL | impl<T, const N: /* Type */> From<[T; N]> for VecWrapper<T>
   |                ++++++++++++
```
2026-01-14 17:56:31 +00:00
Vadim Petrochenkov
83c5f2c194 resolve: Relax one more assert in glob overwriting and add a test
Also avoid losing some glob ambiguities when re-fetching globs
2026-01-14 19:58:40 +03:00
Vadim Petrochenkov
1c3841b372 Add a test for issue 150977 2026-01-14 19:58:40 +03:00
Vadim Petrochenkov
81ef42d5b7 resolve: Consistently use old decls before new decls in interfaces
The opposite ordering was a consistent source of confusion during debuggingю
`report_conflict` actually used an incorrect order due to similar confusion.
2026-01-14 19:58:33 +03:00
Vadim Petrochenkov
8b52c73b3e resolve: Relax some asserts in glob overwriting and add tests 2026-01-14 19:57:21 +03:00
bors
86a49fd71f Auto merge of #130998 - the8472:bail-before-memcpy, r=nnethercote
avoid phi node for pointers flowing into Vec appends

Elide temporary allocations in patterns like `vec.append(slice.to_vec())`

related discussion: https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/nocapture.20and.20allocation.20elimination
2026-01-14 16:36:26 +00:00
mu001999
12b4b72715 Add test for issue 151048 2026-01-14 20:59:41 +08:00
mu001999
37f20b7631 Bless tests 2026-01-14 20:59:41 +08:00
dianqk
5769006794
Run dummy_span.rs test with SimplifyComparisonIntegral 2026-01-14 18:57:17 +08:00
Jonathan Brouwer
db10879fd1
Rollup merge of #151096 - rm-providers-deref, r=oli-obk
Remove `Deref`/`DerefMut` impl for `Providers`.

It's described as a "backwards compatibility hack to keep the diff small". Removing it requires only a modest amount of churn, and the resulting code is clearer without the invisible derefs.

r? @oli-obk
2026-01-14 11:05:42 +01:00
Jonathan Brouwer
18c62b5d44
Rollup merge of #151077 - issue-84327, r=fmease
Recognize potential `impl<const N: usize>` to `impl<N>` mistake

When encountering code like `impl<N> Bar<N> for [u8; N]`, suggest `impl<const N: Type> Bar<N> for [u8; N]` as a possibility.

```
error[E0423]: expected value, found type parameter `T`
  --> $DIR/issue-69654.rs:5:25
   |
LL | impl<T> Bar<T> for [u8; T] {}
   |      -                  ^ not a value
   |      |
   |      found this type parameter
   |
help: you might have meant to write a const parameter here
   |
LL | impl<const T: Type> Bar<T> for [u8; T] {}
   |      +++++  ++++++
```

Addresses "case 3" from rust-lang/rust#84327.
2026-01-14 11:05:41 +01:00
Jonathan Brouwer
b431a5e685
Rollup merge of #151067 - ui_test_no_should_fail, r=lqd
Avoid should-fail in two ui tests and a codegen-llvm test

`should-fail` is only meant for testing the compiletest framework itself. It checks that the test runner itself panicked.

With this there are still a bunch of rustdoc-html tests that use it due to this test suite not supporting anything like `//@ doc-fail`.
2026-01-14 11:05:40 +01:00
Jonathan Brouwer
cbcd1c3eef
Rollup merge of #151036 - issue-151026, r=mati865
Better handle when trying to iterate on a `Range` of a type that isn't `Step`

Mention when a trait bound corresponds to an unstable trait.

Mention `Range` when `Step` bound is unment, and explain that only some std types impl `Iterator` for `Range`.

CC rust-lang/rust#151026
2026-01-14 11:05:40 +01:00
Jonathan Brouwer
95ea4c5699
Rollup merge of #150723 - move_pal_error, r=@tgross35
std: move `errno` and related functions into `sys::io`

Part of rust-lang/rust#117276.

Currently, `errno` and related functions like `decode_error_kind` are split across `sys::pal` and `sys::pal::os`. This PR moves all of them into a new module inside `sys::io`.
2026-01-14 11:05:38 +01:00
Nicholas Nethercote
3aa31788b5 Remove Deref/DerefMut impl for Providers.
It's described as a "backwards compatibility hack to keep the diff
small". Removing it requires only a modest amount of churn, and the
resulting code is clearer without the invisible derefs.
2026-01-14 15:55:59 +11:00
Esteban Küber
15d8e9ea66 Recognize potential impl<const N: usize> to impl<N> mistake
When encountering code like `impl<N> Bar<N> for [u8; N]`, suggest `impl<const N: Type> Bar<N> for [u8; N]` as a possibility.

```
error[E0423]: expected value, found type parameter `T`
  --> $DIR/issue-69654.rs:5:25
   |
LL | impl<T> Bar<T> for [u8; T] {}
   |      -                  ^ not a value
   |      |
   |      found this type parameter
   |
help: you might have meant to write a const parameter here
   |
LL | impl<const T: /* Type */> Bar<T> for [u8; T] {}
   |      +++++  ++++++++++++
```
2026-01-13 23:47:35 +00:00
Guillaume Gomez
3adbd3ae4e
Rollup merge of #151055 - mgca-arr, r=BoxyUwU
Emit error instead of delayed bug when meeting mismatch type for const array

r? BoxyUwU

resolve: rust-lang/rust#151024

cc: https://github.com/rust-lang/rust/pull/150869
2026-01-13 23:39:13 +01:00
Guillaume Gomez
860e60a786
Rollup merge of #151053 - reduce-gui-test-flakyness, r=jieyouxu
Reduce flakyness for `tests/rustdoc-gui/notable-trait.goml`

Fixes https://github.com/rust-lang/rust/issues/151006 (hopefully).

Instead of asserting right away, it waits for the element count to be the one expected.

r? @jieyouxu
2026-01-13 23:39:13 +01:00
Guillaume Gomez
5b7fc2fcc7
Rollup merge of #151052 - add-test-ice-in-resolve, r=Kivooeo
ui: add regression test for macro resolution ICE (issue #150711)

Added a new test in `test/ui/resolve` for a macro
resolution scenario that previously caused an ICE.

Files added:
- `tests/ui/resolve/decl-macro-use-no-ice.rs`
- `tests/ui/resolve/decl-macro-use-no-ice.stderr`

Fixes rust-lang/rust#150711

r? @matthiaskrgr
r? @petrochenkov
2026-01-13 23:39:12 +01:00
Guillaume Gomez
a8e3ce50b9
Rollup merge of #151031 - reflect-arrays, r=oli-obk
Support arrays in type reflection

Tracking issue: rust-lang/rust#146922

This PR adds support for inspecting arrays `[T; N]` through type reflection. It does so by adding `TypeKind::Array` and the `Array` struct:

```rust
pub struct Array {
    pub element_ty: TypeId,
    pub len: usize,
}
```

This can be used to inspect arrays like so:

```rust
match const { Type::of::<[u16; 4]>() }.kind {
    TypeKind::Array(array) => {
        assert_eq!(array.element_ty, TypeId::of::<u16>());
        assert_eq!(array.len, 4);
    }
    _ => unreachable!(),
}
```

r? @oli-obk
2026-01-13 23:39:11 +01:00
Guillaume Gomez
93dc648735
Rollup merge of #151019 - type-of-unsized, r=oli-obk
Make `Type::of` support unsized types

Tracking issue: rust-lang/rust#146922
Fixes rust-lang/rust#151018

`Type::of` is a utility function for getting type reflection information, and internally just calls `TypeId::of::<T>().info()`. `Type::of` does not support unsized types like `str` and `[u8]` because it is missing a `?Sized` bound. I believe this is an oversight rather than an intentional decision, as `TypeId::of` _does_ support unsized types and `Type::size` is an `Option` to support types without sizes.

This PR adds a `?Sized` bound to `Type::of` and extends the `dump.rs` test to ensure unsized types work in the future.

r? @oli-obk
2026-01-13 23:39:11 +01:00
Guillaume Gomez
0d3692a437
Rollup merge of #150915 - eii-regression-test-149983, r=kivooeo
Regression test for type params on eii

Somewhere along the line I fixed this one with my other PRs. This just adds the regression tests

Closes rust-lang/rust#149983
2026-01-13 23:39:10 +01:00