about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-24 08:32:10 +0000
committerbors <bors@rust-lang.org>2020-01-24 08:32:10 +0000
commitdee12bb2b7d75cce8fc8f21b5d7ea0da920df5e5 (patch)
tree3f0255955f4d43f524452b720ab33e6e64825836 /src/test
parent62f227b3f822a27bd603acede9137bfb49ca8b68 (diff)
parent7f8a61d96c5a628ffb88304eb84a85140479ecad (diff)
downloadrust-dee12bb2b7d75cce8fc8f21b5d7ea0da920df5e5.tar.gz
rust-dee12bb2b7d75cce8fc8f21b5d7ea0da920df5e5.zip
Auto merge of #68506 - tmandry:rollup-kz9d33v, r=tmandry
Rollup of 7 pull requests

Successful merges:

 - #68424 (Suggest borrowing `Vec<NonCopy>` in for loop)
 - #68438 (Account for non-types in substs for opaque type error messages)
 - #68469 (Avoid overflow in `std::iter::Skip::count`)
 - #68473 (Enable ASan on Fuchsia)
 - #68479 (Implement `unused_parens` for block return values)
 - #68483 (Add my (@flip1995) name to .mailmap)
 - #68500 (Clear out std, not std tools)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/iterators/skip-count-overflow.rs8
-rw-r--r--src/test/ui/lint/lint-unnecessary-parens.rs7
-rw-r--r--src/test/ui/lint/lint-unnecessary-parens.stderr36
-rw-r--r--src/test/ui/suggestions/for-i-in-vec.fixed15
-rw-r--r--src/test/ui/suggestions/for-i-in-vec.rs15
-rw-r--r--src/test/ui/suggestions/for-i-in-vec.stderr12
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs13
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr14
8 files changed, 108 insertions, 12 deletions
diff --git a/src/test/ui/iterators/skip-count-overflow.rs b/src/test/ui/iterators/skip-count-overflow.rs
new file mode 100644
index 00000000000..d8efc948664
--- /dev/null
+++ b/src/test/ui/iterators/skip-count-overflow.rs
@@ -0,0 +1,8 @@
+// run-pass
+// only-32bit too impatient for 2⁶⁴ items
+// compile-flags: -C overflow-checks -C opt-level=3
+
+fn main() {
+    let i = (0..usize::max_value()).chain(0..10).skip(usize::max_value());
+    assert_eq!(i.count(), 10);
+}
diff --git a/src/test/ui/lint/lint-unnecessary-parens.rs b/src/test/ui/lint/lint-unnecessary-parens.rs
index 12ffb6d3c66..4e8339a8e6b 100644
--- a/src/test/ui/lint/lint-unnecessary-parens.rs
+++ b/src/test/ui/lint/lint-unnecessary-parens.rs
@@ -17,6 +17,13 @@ fn unused_parens_around_return_type() -> (u32) { //~ ERROR unnecessary parenthes
     panic!()
 }
 
+fn unused_parens_around_block_return() -> u32 {
+    let foo = {
+        (5) //~ ERROR unnecessary parentheses around block return value
+    };
+    (5) //~ ERROR unnecessary parentheses around block return value
+}
+
 trait Trait {
     fn test(&self);
 }
diff --git a/src/test/ui/lint/lint-unnecessary-parens.stderr b/src/test/ui/lint/lint-unnecessary-parens.stderr
index 541ae7aa4b5..ea58220d20c 100644
--- a/src/test/ui/lint/lint-unnecessary-parens.stderr
+++ b/src/test/ui/lint/lint-unnecessary-parens.stderr
@@ -22,26 +22,38 @@ error: unnecessary parentheses around type
 LL | fn unused_parens_around_return_type() -> (u32) {
    |                                          ^^^^^ help: remove these parentheses
 
+error: unnecessary parentheses around block return value
+  --> $DIR/lint-unnecessary-parens.rs:22:9
+   |
+LL |         (5)
+   |         ^^^ help: remove these parentheses
+
+error: unnecessary parentheses around block return value
+  --> $DIR/lint-unnecessary-parens.rs:24:5
+   |
+LL |     (5)
+   |     ^^^ help: remove these parentheses
+
 error: unnecessary parentheses around function argument
-  --> $DIR/lint-unnecessary-parens.rs:36:9
+  --> $DIR/lint-unnecessary-parens.rs:43:9
    |
 LL |     bar((true));
    |         ^^^^^^ help: remove these parentheses
 
 error: unnecessary parentheses around `if` condition
-  --> $DIR/lint-unnecessary-parens.rs:38:8
+  --> $DIR/lint-unnecessary-parens.rs:45:8
    |
 LL |     if (true) {}
    |        ^^^^^^ help: remove these parentheses
 
 error: unnecessary parentheses around `while` condition
-  --> $DIR/lint-unnecessary-parens.rs:39:11
+  --> $DIR/lint-unnecessary-parens.rs:46:11
    |
 LL |     while (true) {}
    |           ^^^^^^ help: remove these parentheses
 
 warning: denote infinite loops with `loop { ... }`
-  --> $DIR/lint-unnecessary-parens.rs:39:5
+  --> $DIR/lint-unnecessary-parens.rs:46:5
    |
 LL |     while (true) {}
    |     ^^^^^^^^^^^^ help: use `loop`
@@ -49,46 +61,46 @@ LL |     while (true) {}
    = note: `#[warn(while_true)]` on by default
 
 error: unnecessary parentheses around `match` head expression
-  --> $DIR/lint-unnecessary-parens.rs:41:11
+  --> $DIR/lint-unnecessary-parens.rs:48:11
    |
 LL |     match (true) {
    |           ^^^^^^ help: remove these parentheses
 
 error: unnecessary parentheses around `let` head expression
-  --> $DIR/lint-unnecessary-parens.rs:44:16
+  --> $DIR/lint-unnecessary-parens.rs:51:16
    |
 LL |     if let 1 = (1) {}
    |                ^^^ help: remove these parentheses
 
 error: unnecessary parentheses around `let` head expression
-  --> $DIR/lint-unnecessary-parens.rs:45:19
+  --> $DIR/lint-unnecessary-parens.rs:52:19
    |
 LL |     while let 1 = (2) {}
    |                   ^^^ help: remove these parentheses
 
 error: unnecessary parentheses around method argument
-  --> $DIR/lint-unnecessary-parens.rs:59:24
+  --> $DIR/lint-unnecessary-parens.rs:66:24
    |
 LL |     X { y: false }.foo((true));
    |                        ^^^^^^ help: remove these parentheses
 
 error: unnecessary parentheses around assigned value
-  --> $DIR/lint-unnecessary-parens.rs:61:18
+  --> $DIR/lint-unnecessary-parens.rs:68:18
    |
 LL |     let mut _a = (0);
    |                  ^^^ help: remove these parentheses
 
 error: unnecessary parentheses around assigned value
-  --> $DIR/lint-unnecessary-parens.rs:62:10
+  --> $DIR/lint-unnecessary-parens.rs:69:10
    |
 LL |     _a = (0);
    |          ^^^ help: remove these parentheses
 
 error: unnecessary parentheses around assigned value
-  --> $DIR/lint-unnecessary-parens.rs:63:11
+  --> $DIR/lint-unnecessary-parens.rs:70:11
    |
 LL |     _a += (1);
    |           ^^^ help: remove these parentheses
 
-error: aborting due to 13 previous errors
+error: aborting due to 15 previous errors
 
diff --git a/src/test/ui/suggestions/for-i-in-vec.fixed b/src/test/ui/suggestions/for-i-in-vec.fixed
new file mode 100644
index 00000000000..ec7358bd08a
--- /dev/null
+++ b/src/test/ui/suggestions/for-i-in-vec.fixed
@@ -0,0 +1,15 @@
+// run-rustfix
+#![allow(dead_code)]
+
+struct Foo {
+    v: Vec<u32>,
+}
+
+impl Foo {
+    fn bar(&self) {
+        for _ in &self.v { //~ ERROR cannot move out of `self.v` which is behind a shared reference
+        }
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/for-i-in-vec.rs b/src/test/ui/suggestions/for-i-in-vec.rs
new file mode 100644
index 00000000000..304fe8cc81f
--- /dev/null
+++ b/src/test/ui/suggestions/for-i-in-vec.rs
@@ -0,0 +1,15 @@
+// run-rustfix
+#![allow(dead_code)]
+
+struct Foo {
+    v: Vec<u32>,
+}
+
+impl Foo {
+    fn bar(&self) {
+        for _ in self.v { //~ ERROR cannot move out of `self.v` which is behind a shared reference
+        }
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/for-i-in-vec.stderr b/src/test/ui/suggestions/for-i-in-vec.stderr
new file mode 100644
index 00000000000..576a7cc2f60
--- /dev/null
+++ b/src/test/ui/suggestions/for-i-in-vec.stderr
@@ -0,0 +1,12 @@
+error[E0507]: cannot move out of `self.v` which is behind a shared reference
+  --> $DIR/for-i-in-vec.rs:10:18
+   |
+LL |         for _ in self.v {
+   |                  ^^^^^^
+   |                  |
+   |                  move occurs because `self.v` has type `std::vec::Vec<u32>`, which does not implement the `Copy` trait
+   |                  help: consider iterating over a slice of the `Vec<_>`'s content: `&self.v`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs
new file mode 100644
index 00000000000..d00f8d7a901
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs
@@ -0,0 +1,13 @@
+// Regression test for issue #68368
+// Ensures that we don't ICE when emitting an error
+// for a non-defining use when lifetimes are involved
+
+#![feature(type_alias_impl_trait)]
+trait Trait<T> {}
+type Alias<'a, U> = impl Trait<U>; //~ ERROR could not find defining uses
+fn f<'a>() -> Alias<'a, ()> {}
+//~^ ERROR defining opaque type use does not fully define opaque type: generic parameter `U`
+
+fn main() {}
+
+impl Trait<()> for () {}
diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr
new file mode 100644
index 00000000000..b585942406f
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr
@@ -0,0 +1,14 @@
+error: defining opaque type use does not fully define opaque type: generic parameter `U` is specified as concrete type `()`
+  --> $DIR/issue-68368-non-defining-use.rs:8:1
+   |
+LL | fn f<'a>() -> Alias<'a, ()> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: could not find defining uses
+  --> $DIR/issue-68368-non-defining-use.rs:7:1
+   |
+LL | type Alias<'a, U> = impl Trait<U>;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+