Skip to content

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

Closed
@ShoyuVanilla

Description

@ShoyuVanilla
// ./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`

Metadata

Metadata

Assignees

Labels

A-nameresname, path and module resolutionC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions