Use nearest non block module as the correct parent module

This commit is contained in:
mu001999
2026-03-16 22:22:25 +08:00
parent 2d419b597c
commit 757f224bce
3 changed files with 32 additions and 0 deletions
@@ -3097,6 +3097,8 @@ pub(crate) fn find_cfg_stripped(&self, err: &mut Diag<'_>, segment: &Symbol, mod
continue;
}
let parent_module = self.get_nearest_non_block_module(parent_scope).def_id();
fn comes_from_same_module_for_glob(
r: &Resolver<'_, '_>,
parent_module: DefId,
+9
View File
@@ -0,0 +1,9 @@
//@ edition: 2015
pub(in a) mod aa { //~ ERROR cannot find module or crate `a` in the crate root
}
mod test {
#[cfg(test)]
use super::a;
}
fn main() {}
@@ -0,0 +1,21 @@
error[E0433]: cannot find module or crate `a` in the crate root
--> $DIR/pub-in-path-153848.rs:3:8
|
LL | pub(in a) mod aa {
| ^ use of unresolved module or unlinked crate `a`
|
note: found an item that was configured out
--> $DIR/pub-in-path-153848.rs:7:16
|
LL | #[cfg(test)]
| ---- the item is gated here
LL | use super::a;
| ^
help: you might be missing a crate named `a`, add it to your project and import it in your code
|
LL + extern crate a;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0433`.