You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
type alias incorrectly flagged as unused when solely used in impl header #58593
typeT = ();structS<X>(X);implCloneforS<T>{fnclone(&self) -> Self{S(())}}fnmain(){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.
Activity
oli-obk commentedon Feb 20, 2019
Previous instances of related (or possibly the same) problems:
varkor commentedon Mar 29, 2019
I think this is essentially the same problem as #59333 (comment).
istankovic commentedon Oct 20, 2023
Seems to be fixed. Tested with 1.73 and got no warnings.
KaiTomotake commentedon Jan 23, 2026
@rustbot claim
KaiTomotake commentedon Jan 23, 2026
Oops, looks like there was already someone ahead of me.
tests/ui/lint/dead-code/alias-type-used-as-generic-arg-in-impl.rszakrad commentedon Sep 21, 2026
This looks covereed by
tests/ui/lint/dead-code/alias-type-used-as-generic-arg-in-impl.rsadded in #141407 can be closed.