Skip to content

"note: the trait cannot require ..." printed twice for object-safety violations #20692

Closed
@huonw

Description

@huonw
trait Array: Sized {}

fn f<T: Array>(x: &T) {
    let _ = x as &Array;
}

fn main() {}
<anon>:4:13: 4:14 error: cannot convert to a trait object because trait `Array` is not object-safe [E0038]
<anon>:4     let _ = x as &Array;
                     ^
<anon>:4:13: 4:14 note: the trait cannot require that `Self : Sized`
<anon>:4     let _ = x as &Array;
                     ^
<anon>:4:13: 4:14 note: the trait cannot require that `Self : Sized`
<anon>:4     let _ = x as &Array;
                     ^

Preferably the note would only be printed once, otherwise it's just a bit confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions