Skip to content
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

Local nameres fails in the include!ed within the mod block #18314

Closed
ShoyuVanilla opened this issue Oct 17, 2024 · 0 comments · Fixed by #18361
Closed

Local nameres fails in the include!ed within the mod block #18314

ShoyuVanilla opened this issue Oct 17, 2024 · 0 comments · Fixed by #18361
Assignees
Labels
A-nameres name, path and module resolution C-bug Category: bug

Comments

@ShoyuVanilla
Copy link
Member

ShoyuVanilla commented Oct 17, 2024

// ./src/lib.rs
mod bar {
    include!("foo.rs");
}

// ./src/foo.rs
pub struct Foo;

impl Foo {}
  // ^^^ rust analyzer cannot find definition for `Foo`

The above code compiles fine in rustc.

If I trigger code action on Foo, r-a suggests to "Qualify as bar::Foo"(or import it) but the resulting code makes compile error

pub struct Foo;

impl bar::Foo {}
  // ^^^ error[E0433]: failed to resolve: use of undeclared crate or module `bar`

If I include foo.rs outside the mod block, it works fine

// ./src/lib.rs
include!("foo.rs");

// ./src/foo.rs
pub struct Foo;

impl Foo {}
  // ^^^ Recognized as `struct Foo`
@ShoyuVanilla ShoyuVanilla added the C-bug Category: bug label Oct 17, 2024
@ShoyuVanilla ShoyuVanilla self-assigned this Oct 17, 2024
@ShoyuVanilla ShoyuVanilla added the A-nameres name, path and module resolution label Oct 17, 2024
@bors bors closed this as completed in 487152b Oct 21, 2024
lnicola pushed a commit to lnicola/rust that referenced this issue Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-nameres name, path and module resolution C-bug Category: bug
Projects
None yet
1 participant