Skip to content

FP: expected H, found H with equally named structs  #16292

@matthiaskrgr

Description

@matthiaskrgr
// check-pass
// tests/ui/imports/import-after-macro-expand-11.rs

#[derive(Debug)]
struct H;

mod p {
    use super::*;

    // this struct confuses RA
    #[derive(Clone)]
    struct H;

    mod t {
        use super::*;

        fn f() {
           let h: crate::p::H = H;
        }
    }
}

fn main() {}

edition 2015

while this compiles with rustc, rust analyze throws an error:

warning: unused import: `super::*`
 --> src/main.rs:8:9
  |
8 |     use super::*;
  |         ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `h`
  --> src/main.rs:18:16
   |
18 |            let h: crate::p::H = H;
   |                ^ help: if this is intentional, prefix it with an underscore: `_h`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: function `f` is never used
  --> src/main.rs:17:12
   |
17 |         fn f() {
   |            ^
   |
   = note: `#[warn(dead_code)]` on by default

warning: `bar` (bin "bar") generated 3 warnings (run `cargo fix --bin "bar"` to apply 2 suggestions)
processing crate: bar, module: /tmp/bar/src/main.rs
Diagnostic { code: RustcHardError("E0308"), message: "expected H, found H", range: FileRange { file_id: FileId(11), range: 273..274 }, severity: Error, unused: false, experimental: true, fixes: None, main_node: None }

diagnostic scan complete

Error: diagnostic error detected

rust-analyzer 1.77.0-nightly (595bc6f 2024-01-05)

Metadata

Metadata

Assignees

No one assigned

    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