Open
Description
I tried this code (https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8c1861ee7e07799c5897f37f0aa2f849):
fn main() {
mod foo {
use super::*;
fn foobar() {
bar();
}
}
fn bar () {}
}
This fails to compile:
error[E0425]: cannot find function `bar` in this scope
--> src/main.rs:6:13
|
6 | bar();
| ^^^ not found in this scope
warning: unused import: `super::*`
--> src/main.rs:3:13
|
3 | use super::*;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
rustc --version --verbose
:
rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0
Also reproduces on current nightly (as of 2020-11-21).
I suspect that what's going on is that use super::*
doesn't actually resolve to the scope inside fn main
, but instead the surrounding scope fn main
is itself in.
I tried to search around other issues to find whether this is expected.
This is a super weird special case. It seems plausible (at least to me) that use super::*
from a module inside a function should bring other items local to that function into scope.