Skip to content

Imports are order dependent #2232

Open
Open
@matthewjasper

Description

I tried this code (from general experimentation with the compiler):

mod a {
    pub fn f() {}
}

// Compiles if moved below b
mod c {
    use crate::b::{f, g};

    pub fn h() {
        f();
        g();
    }
}

mod b {
    pub use crate::a::f;

    pub fn g() {
        f();
    }
}

I expected to see this happen: Compiles

Instead, this happened: error

<source>:6:20: error: cannot find simple path segment 'f' in this scope
    6 |     use crate::b::{f, g};
      |                    ^
<source>:9:9: error: Cannot find path 'f' in this scope
    9 |         f();
      |         

Meta

  • What version of Rust GCC were you using, git sha if possible.
    gccrs (Compiler-Explorer-Build-gcc-c7b7e297ea4b688ef9fb51a8aee2a8b2af39ac1c-binutils-2.40) 13.0.1 20230417 (experimental)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions