Skip to content
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

type alias incorrectly flagged as unused when solely used in impl header #58593

Open
pnkfelix opened this issue Feb 20, 2019 · 3 comments
Open
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

Consider the following code (play):

type T = ();

struct S<X>(X); 

impl Clone for S<T> { fn clone(&self) -> Self { S(()) } }

fn main() {
    let s = S(());
    drop(s.clone());
}

Today this emits the following warning diagnostic:

warning: type alias is never used: `T`
 --> src/main.rs:1:1
  |
1 | type T = ();
  | ^^^^^^^^^^^^
  |
  = note: #[warn(dead_code)] on by default

But that type alias is not dead code. It is used in the impl Clone for S<T> { ... }, as one can see by trying to recompile the code after commenting out the type alias.

@pnkfelix pnkfelix added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Feb 20, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Feb 20, 2019

Previous instances of related (or possibly the same) problems:

@varkor varkor self-assigned this Mar 28, 2019
@varkor
Copy link
Member

varkor commented Mar 29, 2019

I think this is essentially the same problem as #59333 (comment).

@varkor varkor removed their assignment Jun 10, 2019
@istankovic
Copy link
Contributor

Seems to be fixed. Tested with 1.73 and got no warnings.

@oli-obk oli-obk added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants