summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/len_zero.fixed4
-rw-r--r--tests/ui/len_zero.rs4
-rw-r--r--tests/ui/len_zero.stderr16
3 files changed, 22 insertions, 2 deletions
diff --git a/tests/ui/len_zero.fixed b/tests/ui/len_zero.fixed
index 34b2021df45..2c22abd7e4b 100644
--- a/tests/ui/len_zero.fixed
+++ b/tests/ui/len_zero.fixed
@@ -176,6 +176,10 @@ fn main() {
// No error; `HasWrongIsEmpty` does not have `.is_empty()`.
println!("Or this!");
}
+
+ // issue #10529
+ (!has_is_empty.is_empty()).then(|| println!("This can happen."));
+ (has_is_empty.is_empty()).then(|| println!("Or this!"));
}
fn test_slice(b: &[u8]) {
diff --git a/tests/ui/len_zero.rs b/tests/ui/len_zero.rs
index c83ae2ac553..a011ff97644 100644
--- a/tests/ui/len_zero.rs
+++ b/tests/ui/len_zero.rs
@@ -176,6 +176,10 @@ fn main() {
// No error; `HasWrongIsEmpty` does not have `.is_empty()`.
println!("Or this!");
}
+
+ // issue #10529
+ (has_is_empty.len() > 0).then(|| println!("This can happen."));
+ (has_is_empty.len() == 0).then(|| println!("Or this!"));
}
fn test_slice(b: &[u8]) {
diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr
index b6f13780253..396cfb75fb6 100644
--- a/tests/ui/len_zero.stderr
+++ b/tests/ui/len_zero.stderr
@@ -123,10 +123,22 @@ LL | if with_is_empty.len() == 0 {
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()`
error: length comparison to zero
- --> $DIR/len_zero.rs:182:8
+ --> $DIR/len_zero.rs:181:6
+ |
+LL | (has_is_empty.len() > 0).then(|| println!("This can happen."));
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
+
+error: length comparison to zero
+ --> $DIR/len_zero.rs:182:6
+ |
+LL | (has_is_empty.len() == 0).then(|| println!("Or this!"));
+ | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
+
+error: length comparison to zero
+ --> $DIR/len_zero.rs:186:8
|
LL | if b.len() != 0 {}
| ^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!b.is_empty()`
-error: aborting due to 21 previous errors
+error: aborting due to 23 previous errors