2 #![feature(let_chains)]
5 clippy::assign_op_pattern,
6 clippy::blocks_in_if_conditions,
7 clippy::let_and_return,
8 clippy::let_unit_value,
9 clippy::nonminimal_bool,
10 clippy::uninlined_format_args
13 use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
16 struct SignificantDrop;
17 impl std::ops::Drop for SignificantDrop {
36 let e = format!("{}", d);
66 format!("{} {}", a, b)
78 let g: usize = if true {
84 // Drop order only matters if both are significant
86 let y = SignificantDrop;
91 let x = SignificantDrop;
94 // types that should be considered insignificant
97 let y = String::new();
99 let y = HashMap::<usize, usize>::new();
100 let y = BTreeMap::<usize, usize>::new();
101 let y = HashSet::<usize>::new();
102 let y = BTreeSet::<usize>::new();
104 let x = SignificantDrop;
107 async fn in_async() -> &'static str {
108 async fn f() -> &'static str {
124 const fn in_const() -> &'static str {
125 const fn f() -> &'static str {
169 // using tuples would be possible, but not always preferable
180 // could match with a smarter heuristic to avoid multiple assignments
198 macro_rules! assign {
213 macro_rules! in_macro {
228 // ignore if-lets - https://github.com/rust-lang/rust-clippy/issues/8613
230 if let Some(n) = Some("v") {
237 if true && let Some(n) = Some("let chains too") {
243 // ignore mut bindings
244 // https://github.com/shepmaster/twox-hash/blob/b169c16d86eb8ea4a296b0acb9d00ca7e3c3005f/src/sixty_four.rs#L88-L93
245 // https://github.com/dtolnay/thiserror/blob/21c26903e29cb92ba1a7ff11e82ae2001646b60d/tests/test_generics.rs#L91-L100
251 // should not move the declaration if `x` has a significant drop, and there
252 // is another binding with a significant drop between it and the first usage
254 let y = SignificantDrop;
259 fn issue8911() -> u32 {
262 _ if { x = 1; false } => return 1,