diff options
| author | kyoto7250 <50972773+kyoto7250@users.noreply.github.com> | 2024-08-09 00:22:30 +0900 |
|---|---|---|
| committer | kyoto7250 <50972773+kyoto7250@users.noreply.github.com> | 2024-08-09 00:48:38 +0900 |
| commit | c2ed04be16d4e23e4511726c7fb1da87de93fd62 (patch) | |
| tree | 47065bab7c0e9d4ab871a7b492ab399ca24a0bde /tests | |
| parent | b1e87922c18fb49e69ce491abe77affbf343ae85 (diff) | |
| download | rust-c2ed04be16d4e23e4511726c7fb1da87de93fd62.tar.gz rust-c2ed04be16d4e23e4511726c7fb1da87de93fd62.zip | |
check the def_id with using diagnostic_item in unnecessary_min_or_max lint
https://github.com/rust-lang/rust-clippy/issues/13191
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/unnecessary_min_or_max.fixed | 29 | ||||
| -rw-r--r-- | tests/ui/unnecessary_min_or_max.rs | 29 |
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/ui/unnecessary_min_or_max.fixed b/tests/ui/unnecessary_min_or_max.fixed index 392f6dd1fee..1f3e131516c 100644 --- a/tests/ui/unnecessary_min_or_max.fixed +++ b/tests/ui/unnecessary_min_or_max.fixed @@ -65,3 +65,32 @@ fn random_u32() -> u32 { // random number generator 0 } + +struct Issue13191 { + min: u16, + max: u16, +} + +impl Issue13191 { + fn new() -> Self { + Self { min: 0, max: 0 } + } + + fn min(mut self, value: u16) -> Self { + self.min = value; + self + } + + fn max(mut self, value: u16) -> Self { + self.max = value; + self + } +} + +fn issue_13191() { + // should not fixed + Issue13191::new().min(0); + + // should not fixed + Issue13191::new().max(0); +} diff --git a/tests/ui/unnecessary_min_or_max.rs b/tests/ui/unnecessary_min_or_max.rs index b03755e6d23..58356b9d49e 100644 --- a/tests/ui/unnecessary_min_or_max.rs +++ b/tests/ui/unnecessary_min_or_max.rs @@ -65,3 +65,32 @@ fn random_u32() -> u32 { // random number generator 0 } + +struct Issue13191 { + min: u16, + max: u16, +} + +impl Issue13191 { + fn new() -> Self { + Self { min: 0, max: 0 } + } + + fn min(mut self, value: u16) -> Self { + self.min = value; + self + } + + fn max(mut self, value: u16) -> Self { + self.max = value; + self + } +} + +fn issue_13191() { + // should not fixed + Issue13191::new().min(0); + + // should not fixed + Issue13191::new().max(0); +} |
