358 Commits

Author SHA1 Message Date
bors 4fbae3e309 Auto merge of #154945 - oli-obk:merge-visitors-def-collector-brg, r=petrochenkov
Merge BuildReducedGraphVisitor into DefPathVisitor

These two visitors run right after each other on the same immutable AST. There's also a hash map for transferring the TyCtxtFeed created in the def collector to the BRG when it visits the same items. There are possibly more avenues for sharing logic, but I want to keep this PR simple.

only opening for perf runs for now. I'm still investigating how to ensure that future changes don't introduce subtle bugs by forgetting that def collection and reduced graph building are one pass now

Best reviewed commit-by-commit. I took a lot of care for making the individual changes reviewable, but all the `Merge *` commits aren't able to compile libcore until the last one.
2026-04-20 23:10:06 +00:00
Oli Scherer 0a714a26a5 Fix use trees 2026-04-20 13:53:15 +02:00
Vadim Petrochenkov 394c7172f4 resolve: Make sure visibilities of import declarations make sense
That they are all ordered inside the module and not more private than the module itself
The `import_decl_vis` logic is reused when reporting `ambiguous_import_visibilities` lint
Some asserts are hardened
Some relevant tests are added
2026-04-20 13:41:33 +03:00
Jonathan Brouwer 5c896555de Rollup merge of #155351 - ujjwalvishwakarma2006:reorg-tests-01, r=Kivooeo
Reorganize tests from `tests/ui/issues/`

The following tests are reorganized in this pull request

| old-name | new-sub-dir | new-name |
|-|-|-|
| `auxiliary/issue-2316-a.rs` | `resolve/auxiliary` | `resolve-conflict-local-vs-glob-import-a.rs` |
| `auxiliary/issue-2316-b.rs` | `resolve/auxiliary` | `resolve-conflict-local-vs-glob-import-b.rs` |
| `issue-2316-c.rs` | `resolve/` | `resolve-conflict-local-vs-glob-import.rs` |
| `issue-28839.rs` | `reborrow/` | `reborrow-mutable-reference.rs` |
| `issue-32008.rs` | `overloaded/` | `subtyping-both-lhs-and-rhs-in-add-impl.rs` |
| `issue-45425.rs` | `higher-ranked/` | `binop-lhs-hrtb-subtyping.rs` |

r? Kivooeo
2026-04-18 19:23:16 +02:00
Stuart Cook 1ff95e018f Rollup merge of #141633 - xizheyin:issue-141350, r=nnethercote
Suggest to bind `self.x` to `x` when field `x` may be in format string

Fixes rust-lang/rust#141350

I added the new test in the first commit, and committed the changes in the second one.

r? @fmease
cc @mejrs
2026-04-17 16:17:49 +10:00
ujjwalVishwakarma2006 bcf86daada Add issue links 2026-04-15 23:50:36 +05:30
ujjwalVishwakarma2006 8c78c33aba Move test files from issues/ to appropriate subdirectories 2026-04-15 23:46:29 +05:30
Esteban Küber b849e10d38 Make span_suggestions always verbose
`span_suggestions` is to provide mutually exclusive suggestions. When it was introduced, we made its behavior be that if a single suggestion is given to it, we present the suggestion inline, otherwise in patch format. Changing this to make all of its uses be verbose, as that is closer in intent of output.
2026-04-15 01:38:14 +00:00
John Kåre Alsaker 6442b48dee Add more robust handling of nested query cycles 2026-04-12 14:38:43 +02:00
mu001999 eb00f7806e Bless other tests 2026-04-09 23:27:38 +08:00
Oli Scherer 9017621ace Use fine grained component-wise span tracking in use trees 2026-04-08 12:37:25 +02:00
Jacob Adam e2461cf2ad Add a regression test for the duplicated crate keyword in path suggestions 2026-04-02 23:59:33 +01:00
xizheyin c4f14ad560 Avoid suggest format string field access for braced paths 2026-04-02 03:25:08 +08:00
Guillaume Gomez e6f17e4bbb Rollup merge of #153834 - N1ark:generic-float-intrinsics, r=tgross35,RalfJung
Merge `fabsf16/32/64/128` into `fabs::<F>`

Following [a small conversation on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Float.20intrinsics/with/521501401) (and because I'd be interested in starting to contribute on Rust), I thought I'd give a try at merging the float intrinsics :)

This PR just merges `fabsf16`, `fabsf32`, `fabsf64`, `fabsf128`, as it felt like an easy first target.

Notes:
- I'm opening the PR for one intrinsic as it's probably easier if the shift is done one intrinsic at a time, but let me know if you'd rather I do several at a time to reduce the number of PRs.
- Currently this PR increases LOCs, despite being an attempt at simplifying the intrinsics/compilers. I believe this increase is a one time thing as I had to define new functions and move some things around, and hopefully future PRs/commits will reduce overall LoCs
- `fabsf32` and `fabsf64` are `#[rustc_intrinsic_const_stable_indirect]`, while `fabsf16` and `fabsf128` aren't; because `f32`/`f64` expect the function to be const, the generic version must be made indirectly stable too. We'd need to check with T-lang this change is ok; the only other intrinsics where there is such a mismatch is `minnum`, `maxnum` and `copysign`.
- I haven't touched libm because I'm not familiar with how it works; any guidance would be welcome!
2026-03-29 00:06:50 +01:00
Yuki Okushi 531631c7ad Make messages more generic 2026-03-28 16:18:11 +09:00
Jonathan Brouwer 7d43ebc519 Rollup merge of #153312 - b-naber:namespaced-crate-names-pt1, r=petrochenkov
Packages as namespaces part 1

Part 1 of https://github.com/rust-lang/rust/pull/152299

r? @petrochenkov
2026-03-23 12:14:52 +01:00
b-naber e844c24122 resolve namespaced crates with open modules 2026-03-21 12:38:17 +00:00
Jonathan Brouwer cc335b236c Rollup merge of #154006 - JonathanBrouwer:doc-compile-err, r=jdonszelmann
attrs: Ignore ExprKind::Err when converting path attr expr to lit

r? @jdonszelmann

Fixes https://github.com/rust-lang/rust/issues/153930
2026-03-17 21:20:03 +01:00
Jonathan Brouwer a5e030602d Rollup merge of #153894 - estebank:issue-129792, r=nnethercote
Point at unit structs on foreign crates in type errors when they are the pattern of a binding

Consts and unit structs in patterns can be confusing if they are mistaken for new bindings. We already provide some context for unit structs and consts that come from the current crate, we now also point at those from foreign crates, and we properly skip cases where the pattern has type parameters which can't be confused with a new binding. So not suggest making a new binding when other suggestions are already emitted, as the likelihood of the other suggestions being what the user intended is higher. Make new binding suggestion verbose.

Fix rust-lang/rust#129792.

```
error[E0308]: mismatched types
 --> fi.rs:8:9
  |
1 | struct percentage;
  | ----------------- unit struct defined here
...
8 |     let percentage = 4i32;
  |         ^^^^^^^^^^   ---- this expression has type `i32`
  |         |
  |         expected `i32`, found `percentage`
  |         `percentage` is interpreted as a unit struct, not a new binding
help: introduce a new binding instead
  |
8 -     let percentage = 4i32;
8 +     let other_percentage = 4i32;
  |
```
2026-03-17 17:51:33 +01:00
Jonathan Brouwer b2a26be751 Rollup merge of #153959 - mu001999-contrib:fix-153848, r=petrochenkov
Fix non-module `parent_module` in stripped cfg diagnostics

Fixes rust-lang/rust#153848

Old `parent_module` is from the `parent_node` in `append_stripped_cfg_item`, it cannot be assumed that it points to a real module. So call `expect_module` on it will cause ICE.

The first commit rename `parent_module` to `parent_scope`, and the second using `get_nearest_non_block_module` to find the nearest `module` of `parent_scope` in `find_cfg_stripped`, which should be the correct `parent_module`.
2026-03-17 17:51:29 +01:00
Jonathan Brouwer de48ea79af Update uitests 2026-03-17 17:30:56 +01:00
ywxt 6a0ce16654 Ignore tests for the parallel frontend 2026-03-17 17:39:59 +08:00
N1ark abb5228ec1 Merge fabsfN into fabs::<F>
Add `bounds::FloatPrimitive`

Exhaustive float pattern match

Fix GCC

use span bugs
2026-03-16 21:49:04 +00:00
mu001999 757f224bce Use nearest non block module as the correct parent module 2026-03-16 22:22:25 +08:00
Esteban Küber 39631fdac1 Point at unit structs on foreign crates in type errors when they are the pattern of a let binding
Consts and unit structs in patterns can be confusing if they are mistaken for new bindings. We already provide some context for unit structs and consts that come from the current crate, we now also point at those from foreign crates, and we properly skip cases where the pattern has type parameters which can't be confused with a new binding. Make new binding suggestion verbose.
2026-03-15 01:50:36 +00:00
Jonathan Brouwer 2d9fde77a8 Rollup merge of #153594 - reddevilmidzy:ui-refactor, r=JohnTitor,Kivooeo
Move some ui tests

> [!NOTE]
> I split the commits to make the review easier and to keep the git history easier to trace.

Renamed issue-xxx tests

`tests/ui/dyn-drop` -> `tests/ui/dyn-keyword`
`tests/ui/missing-trait-bounds` -> `tests/ui/trait-bound/missing-trait-bounds`
`tests/ui/recursion_limit` -> `tests/ui/recursion/recursion_limit`
`tests/ui/version` -> `tests/ui/compile-flags`

Reorganize `tests/ui/empty`
2026-03-09 11:49:26 +01:00
Redddy e63664773c Move some ui tests
* Move dyn-drop to dyn-keyword
* Reorganize `tests/ui/empty` into specific dirs

remove tests/ui/empty/empty-linkname.rs duplicate of tests/ui/error-codes/E0454.rs
* Move `missing-trait-bounds` to `trait-bound/missing-trait-bounds`
* bless traits/missing-trait-bounds tests
* Move `recursion_limit` to `recursion/recursion_limit`
* Move `version` to `compile-flags`
2026-03-09 09:11:06 +00:00
Guillaume Gomez c98094bd32 Remove TyCtxt::node_span_lint usage from rustc_hir_typeck 2026-03-05 23:53:54 +01:00
Jonathan Brouwer ef4cff2ea3 Rollup merge of #153015 - joboet:atomic_alias_generic, r=jhpratt
core: make atomic primitives type aliases of `Atomic<T>`

Tracking issue: https://github.com/rust-lang/rust/issues/130539

This makes `AtomicI32` and friends type aliases of `Atomic<T>` by encoding their alignment requirements via the use of an internal `Storage` associated type. This is also used to encode that `AtomicBool` store a `u8` internally.

Modulo the `Send`/`Sync` implementations, this PR does not move any trait implementations, methods or associated functions – I'll leave that for another PR.
2026-03-02 20:10:34 +01:00
joboet 4d09563d8d bless UI tests referencing atomic primitives 2026-03-02 00:23:24 +01:00
Jonathan Brouwer d0a2fe848d Rollup merge of #153187 - is57primenumber:fix-ice-on-shadowing, r=petrochenkov
Fix ICE when macro-expanded extern crate shadows std

Fixes rust-lang/rust#152895

This PR fixes an ICE that occurs when a macro-expanded `extern crate` shadows a prelude name, which leaves the resolver in an inconsistent state due to `issue_145575_hack`.

I disabled the assertion when the `issue_145575_hack` flag is enabled.
The fix is applied in two locations to cover both cases (whether `is_error_from_last_segment` is true or false).
This approach was inspired by the context and fix discussed in rust-lang/rust#151213.
2026-02-28 12:52:56 +01:00
is57primenumber 54c505fff0 Fix ICE when macro-expanded extern crate shadows std 2026-02-27 22:54:10 +09:00
mu001999 dfd18b7e89 Print path root when printing path 2026-02-26 23:34:41 +08:00
Jonathan Brouwer 51d72725a2 Add regression test 2026-02-22 11:40:27 +01:00
Ozan Kenan Güngör aebafba4bb resolve: do not suggest _ for unresolved imports
`use _` is never valid, so it should not be suggested as a similar name.
2026-02-19 21:24:47 +03:00
Esteban Küber 37684bdfc5 Make all multipart suggestions verbose
The ShowAlways style of suggestions is usually easier to understand than the inline style.
2026-02-18 18:33:35 +00:00
Stuart Cook 77e29b25d0 Rollup merge of #152732 - Kivooeo:add-regression-test-1, r=TaKO8Ki
add regression test for 147958

fixes rust-lang/rust#147958
2026-02-18 17:29:48 +11:00
Esteban Küber 257a415e05 Make suggestion verbose and fix incorrect suggestion usage 2026-02-17 16:51:53 +00:00
Esteban Küber c73b3d20c6 Unify wording of resolve error
Remove "failed to resolve" and use the same format we use in other resolution errors "cannot find `name`".

```
error[E0433]: cannot find `nonexistent` in `existent`
  --> $DIR/custom_attr_multisegment_error.rs:5:13
   |
LL | #[existent::nonexistent]
   |             ^^^^^^^^^^^ could not find `nonexistent` in `existent`
```
2026-02-17 16:51:44 +00:00
Kivooeo e8b0e6b990 add regression test 2026-02-16 22:39:22 +00:00
Stuart Cook 492eb8361e Rollup merge of #152082 - Delta17920:move-tests, r=chenyukang,Kivooeo
Move tests

moved few tests

r? @Kivooeo
2026-02-13 15:19:11 +11:00
Asuna 870fd9070b Add generics info for structs in type info 2026-02-10 13:45:09 +01:00
delta17920 158410457f renamed few tests 2026-02-04 04:45:52 +00:00
delta17920 ddd8f92c8d moved 8 tests to organized locations 2026-02-04 03:33:25 +00:00
delta17920 a7dea5504b rename various regression tests 2026-02-01 04:09:25 +00:00
delta17920 85ae47f83e moved 7 tests to organized locations 2026-01-31 06:44:24 +00:00
Stuart Cook 9108101955 Rollup merge of #151390 - nnethercote:revert, r=petrochenkov
Reintroduce `QueryStackFrame` split.

I tried removing it in rust-lang/rust#151203, to replace it with something simpler. But a couple of fuzzing failures have come up and I don't have a clear picture on how to fix them. So I'm reverting the main part of rust-lang/rust#151203.

This commit also adds the two fuzzing tests.

Fixes rust-lang/rust#151226, rust-lang/rust#151358.

r? @oli-obk
2026-01-27 17:36:36 +11:00
Nicholas Nethercote 0385e26e7d Reintroduce QueryStackFrame split.
I tried removing it in #151203, to replace it with something simpler.
But a couple of fuzzing failures have come up and I don't have a clear
picture on how to fix them. So I'm reverting the main part of #151203.

This commit also adds the two fuzzing tests.

Fixes #151226, #151358.
2026-01-27 09:42:38 +11: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
Takayuki Maeda 4d2f6a0843 fix ICE on inconsistent import resolution with macro-attributed extern crate 2026-01-18 04:34:46 +09:00