Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

declaration of non-object-safe trait object type should be invalid #21953

Copy link
Copy link
@mandel59

Description

@mandel59
Issue body actions
trait A {
    fn foo(&self, _x: &Self);
}

impl A for () {
    fn foo(&self, _x: &Self) {}
}

fn main() {                                                 
    let _x: &A;
}

This code passes, while the codes like let x = &() as &A; cause compile error because the trait A is not object-safe. 0255-object-safety

Is there any reason for type &A to exist? If not, the declaration of variables of type &A should be invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsArea: 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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.