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.
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
Suggest to bind `self.x` to `x` when field `x` may be in format string
Fixesrust-lang/rust#141350
I added the new test in the first commit, and committed the changes in the second one.
r? @fmease
cc @mejrs
`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.
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!
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.
Fixrust-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;
|
```
Fix non-module `parent_module` in stripped cfg diagnostics
Fixesrust-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`.
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.
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`
* 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`
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.
Fix ICE when macro-expanded extern crate shadows std
Fixesrust-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.
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`
```
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.
Fixesrust-lang/rust#151226, rust-lang/rust#151358.
r? @oli-obk
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.