-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE: inconsistent resolution for an import
#124490
Comments
also crashes with just |
Regression in nightly-2023-07-01 commit[0] 2023-06-29: Auto merge of #112682 - spastorino:new-rpitit-21, r=compiler-errors I suspect this is #112086 |
slightly more minimal (ordering is irrelevant) |
more reduced: mod a {
pub mod b {
pub mod c {}
}
}
use a::*;
use b::c;
use c as b;
fn main() {} |
resolve: mark it undetermined if single import is not has any bindings - Fixes rust-lang#124490 - Fixes rust-lang#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`
resolve: mark it undetermined if single import is not has any bindings - Fixes rust-lang#124490 - Fixes rust-lang#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`
Rollup merge of rust-lang#124840 - bvanjoi:fix-124490, r=petrochenkov resolve: mark it undetermined if single import is not has any bindings - Fixes rust-lang#124490 - Fixes rust-lang#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``
Again, the original example still crashes. |
mark binding undetermined if target name exist and not obtained - Fixes rust-lang#124490 - Fixes rust-lang#125013 Following up on rust-lang#124840, I think handling only `target_bindings` is sufficient. r? `@petrochenkov`
Rollup merge of rust-lang#126065 - bvanjoi:fix-124490, r=petrochenkov mark binding undetermined if target name exist and not obtained - Fixes rust-lang#124490 - Fixes rust-lang#125013 Following up on rust-lang#124840, I think handling only `target_bindings` is sufficient. r? `@petrochenkov`
auto-reduced (treereduce-rust):
original:
Version information
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zunstable-options --edition=2024
Program output
The text was updated successfully, but these errors were encountered: