Skip to content

Bad error message trying to use Box as a tuple struct #22488

Closed
@ghost

Description

struct U <T> {
  wtf: Option<Box<U<T>>>
}
fn main() {
 U{ wtf: Some(Box(U{ wtf: None })) };
}
<anon>:5:19: 5:33 error: mismatched types:
 expected `core::ptr::Unique<_>`,
    found `U<_>`
(expected struct `core::ptr::Unique`,
    found struct `U`) [E0308]
<anon>:5  U{ wtf: Some(Box(U{ wtf: None })) };
                           ^~~~~~~~~~~~~~
<anon>:5:15: 5:34 error: mismatched types:
 expected `Box<U<_>>`,
    found `alloc::boxed::Box<_>`
(expected box,
    found struct `alloc::boxed::Box`) [E0308]
<anon>:5  U{ wtf: Some(Box(U{ wtf: None })) };
                       ^~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
playpen: application terminated with error code 101

Could someone change the bad title? I am not good for english.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`A-type-systemArea: Type systemC-bugCategory: This is a bug.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions