-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lints unused assoc consts and unused trait with assoc tys
- Loading branch information
Showing
8 changed files
with
222 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//@ check-pass | ||
|
||
#![deny(dead_code)] | ||
|
||
trait UInt: Copy + From<u8> {} | ||
|
||
impl UInt for u16 {} | ||
|
||
trait Int: Copy { | ||
type Unsigned: UInt; | ||
|
||
fn as_unsigned(self) -> Self::Unsigned; | ||
} | ||
|
||
impl Int for i16 { | ||
type Unsigned = u16; | ||
|
||
fn as_unsigned(self) -> u16 { | ||
self as _ | ||
} | ||
} | ||
|
||
fn priv_func<T: Int>(x: u8, y: T) -> (T::Unsigned, T::Unsigned) { | ||
(T::Unsigned::from(x), y.as_unsigned()) | ||
} | ||
|
||
pub fn pub_func(x: u8, y: i16) -> (u16, u16) { | ||
priv_func(x, y) | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![deny(dead_code)] | ||
|
||
trait Trait { | ||
const UNUSED_CONST: i32; //~ ERROR associated constant `UNUSED_CONST` is never used | ||
const USED_CONST: i32; | ||
|
||
fn foo(&self) {} | ||
} | ||
|
||
pub struct T(()); | ||
|
||
impl Trait for T { | ||
const UNUSED_CONST: i32 = 0; | ||
const USED_CONST: i32 = 1; | ||
} | ||
|
||
fn main() { | ||
T(()).foo(); | ||
T::USED_CONST; | ||
} |
Oops, something went wrong.