mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
![]() fix(resolve): update shadowed_glob more precision - Fixes #109153 - Fixes #109962 ## Why does it panic? We use #109153 as an illustration. The process of `resolve_imports` is: | Iter | resolve | resolution of **`(Mod(root), Ident(bar) in type ns)`** | | - | - | - | | 0 | `use foo::*` | `binding` -> foo::bar, `shallowed_glob` -> `None` | | 1 | `use bar::bar` | `binding` -> foo::bar::bar, `shallowed_glob` -> foo::bar | | 2 | `use bar::*` | `binding` -> foo::bar::bar, `shallowed_glob` -> foo::bar::bar::bar | So during `finalize_import`, the `root::bar` in `use bar::bar` had been pointed to `foo::bar::bar::bar`, which is different from the `initial_module` valued of `foo::bar`, therefore, the panic had been triggered. ## Try to solve it ~I think #109153 should check-pass rather than throw an ambiguous error. Following this idea, there are two ways to solve this problem:~ ~1. Give up the `initial_module` and update `import.imported_module` after each resolution update. However, I think this method may have too much impact.~ ~2. Do not update the `shadowed_glob` when it is defined.~ ~To be honest, I am not sure if this is the right way to solve this ICE. Perhaps there is a better resolution.~ Edit: we had made the `resolution.shadowed_glob` update more detailed. r? `@petrochenkov` |
||
---|---|---|
.. | ||
assembly | ||
auxiliary | ||
codegen | ||
codegen-units | ||
debuginfo | ||
incremental | ||
mir-opt | ||
pretty | ||
run-make | ||
run-make-fulldeps | ||
run-pass-valgrind | ||
rustdoc | ||
rustdoc-gui | ||
rustdoc-js | ||
rustdoc-js-std | ||
rustdoc-json | ||
rustdoc-ui | ||
ui | ||
ui-fulldeps | ||
COMPILER_TESTS.md |