Skip to content

"struct is never used" when Self is used to name the type #30029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jonas-schievink opened this issue Nov 24, 2015 · 3 comments
Closed

"struct is never used" when Self is used to name the type #30029

jonas-schievink opened this issue Nov 24, 2015 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@jonas-schievink
Copy link
Contributor

struct S;

impl Clone for S {
    fn clone(&self) -> Self { loop{} }
    // Doesn't warn:
    //fn clone(&self) -> S { loop{} }
}

fn main() {}

Prints a warning that S isn't used, but doesn't warn when naming S explicitly.

@Gankra
Copy link
Contributor

Gankra commented Nov 24, 2015

It seems to me that not warning when it's used explicitly in a trait implementation is the real bug here.

@arielb1
Copy link
Contributor

arielb1 commented Nov 24, 2015

@gankro

You can gain access to S via inference guessing.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 25, 2016
@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum
Copy link
Member

Closing in favor of (what I think is) a duplicate: #18290.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

5 participants