summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unnecessary_lazy_eval.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/unnecessary_lazy_eval.fixed')
-rw-r--r--src/tools/clippy/tests/ui/unnecessary_lazy_eval.fixed21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/unnecessary_lazy_eval.fixed b/src/tools/clippy/tests/ui/unnecessary_lazy_eval.fixed
index eed817968..ce4a82e02 100644
--- a/src/tools/clippy/tests/ui/unnecessary_lazy_eval.fixed
+++ b/src/tools/clippy/tests/ui/unnecessary_lazy_eval.fixed
@@ -1,9 +1,13 @@
// run-rustfix
+// aux-build: proc_macro_with_span.rs
#![warn(clippy::unnecessary_lazy_evaluations)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::bind_instead_of_map)]
#![allow(clippy::map_identity)]
+extern crate proc_macro_with_span;
+use proc_macro_with_span::with_span;
+
struct Deep(Option<usize>);
#[derive(Copy, Clone)]
@@ -21,6 +25,14 @@ fn some_call<T: Default>() -> T {
T::default()
}
+struct Issue9427(i32);
+
+impl Drop for Issue9427 {
+ fn drop(&mut self) {
+ println!("{}", self.0);
+ }
+}
+
fn main() {
let astronomers_pi = 10;
let ext_arr: [usize; 1] = [2];
@@ -73,6 +85,9 @@ fn main() {
let _ = deep.0.or_else(|| some_call());
let _ = opt.ok_or_else(|| ext_arr[0]);
+ // Should not lint - bool
+ let _ = (0 == 1).then(|| Issue9427(0)); // Issue9427 has a significant drop
+
// should not lint, bind_instead_of_map takes priority
let _ = Some(10).and_then(|idx| Some(ext_arr[idx]));
let _ = Some(10).and_then(|idx| Some(idx));
@@ -130,3 +145,9 @@ fn main() {
let _: Result<usize, usize> = res.and_then(|x| Err(x));
let _: Result<usize, usize> = res.or_else(|err| Ok(err));
}
+
+#[allow(unused)]
+fn issue9485() {
+ // should not lint, is in proc macro
+ with_span!(span Some(42).unwrap_or_else(|| 2););
+}