rust-clippy/tests/ui/default_instead_of_iter_empty.rs
kyoto7250 2bb8c45026 feat(lint): add default_iter_empty
Update description in clippy_lints/src/default_iter_empty.rs

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>

Update clippy_lints/src/default_iter_empty.rs

Co-authored-by: Alex Macleod <alex@macleod.io>

Update clippy_lints/src/default_iter_empty.rs

Co-authored-by: Alex Macleod <alex@macleod.io>

renamed default_iter_empty to default_instead_of_iter_empty

Avoid duplicate messages

add tests for regression

rewrite 'Why is this bad?'

cargo dev fmt

delete default_iter_empty lint in renamed_lint.rs

rewrite a message in the suggestion

cargo dev update_lints --check
2022-06-17 21:34:36 +09:00

21 lines
520 B
Rust

// run-rustfix
#![warn(clippy::default_instead_of_iter_empty)]
#![allow(dead_code)]
use std::collections::HashMap;
#[derive(Default)]
struct Iter {
iter: std::iter::Empty<usize>,
}
fn main() {
// Do lint.
let _ = std::iter::Empty::<usize>::default();
let _ = std::iter::Empty::<HashMap<usize, usize>>::default();
let _foo: std::iter::Empty<usize> = std::iter::Empty::default();
// Do not lint.
let _ = Vec::<usize>::default();
let _ = String::default();
let _ = Iter::default();
}