Skip to content

Invalid suggestion for wrapping unnamable types, uses function name as module #144319

@lolbinarycat

Description

@lolbinarycat

Code

pub fn main() { struct Foo(bool); struct Bar(Foo); _ = Bar(false); }

Current output

error[E0308]: mismatched types --> src/main.rs:5:13 | 5 | _ = Bar(false); | --- ^^^^^ expected `Foo`, found `bool` | | | arguments to this struct are incorrect | note: tuple struct defined here --> src/main.rs:3:12 | 3 | struct Bar(Foo); | ^^^ help: try wrapping the expression in `main::Foo` | 5 | _ = Bar(main::Foo(false)); | ++++++++++ + For more information about this error, try `rustc --explain E0308`.

Desired output

error[E0308]: mismatched types --> src/main.rs:5:13 | 5 | _ = Bar(false); | --- ^^^^^ expected `Foo`, found `bool` | | | arguments to this struct are incorrect | note: tuple struct defined here --> src/main.rs:3:12 | 3 | struct Bar(Foo); | ^^^ help: try wrapping the expression in `main::Foo` | 5 | _ = Bar(Foo(false)); | ++++ + For more information about this error, try `rustc --explain E0308`.

Rationale and extra context

No response

Other cases

Rust Version

1.90.0-nightly (2025-07-21 9748d87dc70a9a6725c5)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions