diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-06-05 18:21:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-05 18:21:11 +0200 |
| commit | 69a8c139f1d7c97dc8b9bc0086e042fa6c79a389 (patch) | |
| tree | 9f6e8ec6da52cc8395050c4508e852036ebc5108 /tests/ui/patchable-function-entry/patchable-function-entry-flags.rs | |
| parent | db8aca48129d86b2623e3ac8cbcf2902d4d313ad (diff) | |
| parent | f67a0eb2b72294f108051381cbc833c295aadad9 (diff) | |
| download | rust-69a8c139f1d7c97dc8b9bc0086e042fa6c79a389.tar.gz rust-69a8c139f1d7c97dc8b9bc0086e042fa6c79a389.zip | |
Rollup merge of #124840 - bvanjoi:fix-124490, r=petrochenkov
resolve: mark it undetermined if single import is not has any bindings
- Fixes #124490
- Fixes #125013
This issue arises from incorrect resolution updates, for example:
```rust
mod a {
pub mod b {
pub mod c {}
}
}
use a::*;
use b::c;
use c as b;
fn main() {}
```
1. In the first loop, binding `(root, b)` is refer to `root::a::b` due to `use a::*`.
1. However, binding `(root, c)` isn't defined by `use b::c` during this stage because `use c as b` falls under the `single_imports` of `(root, b)`, where the `imported_module` hasn't been computed yet. This results in marking the `path_res` for `b` as `Indeterminate`.
2. Then, the `imported_module` for `use c as b` will be recorded.
2. In the second loop, `use b::c` will be processed again:
1. Firstly, it attempts to find the `path_res` for `(root, b)`.
2. It will iterate through the `single_imports` of `use b::c`, encounter `use c as b`, attempt to resolve `c` in `root`, and ultimately return `Err(Undetermined)`, thus passing the iterator.
3. Use the binding `(root, b)` -> `root::a::b` introduced by `use a::*` and ultimately return `root::a::b` as the `path_res` of `b`.
4. Then define the binding `(root, c)` -> `root::a::b::c`.
3. Then process `use c as b`, update the resolution for `(root, b)` to refer to `root::a::b::c`, ultimately causing inconsistency.
In my view, step `2.2` has an issue where it should exit early, similar to the behavior when there's no `imported_module`. Therefore, I've added an attribute called `indeterminate` to `ImportData`. This will help us handle only those single imports that have at least one determined binding.
r? ``@petrochenkov``
Diffstat (limited to 'tests/ui/patchable-function-entry/patchable-function-entry-flags.rs')
0 files changed, 0 insertions, 0 deletions
