about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-09-03 15:17:31 +0000
committerbors <bors@rust-lang.org>2019-09-03 15:17:31 +0000
commitb9de4ef89e0e53099a084001b26ec3207c5f8391 (patch)
treea5ebb43454b05a252c93cd59c2ceacc7fd4ec32e /src/test
parent815dec9db156284b4f57a4ec34182ffc89218242 (diff)
parent24e3b1d0d3cfb5fddc91105bb261413566e8b701 (diff)
downloadrust-b9de4ef89e0e53099a084001b26ec3207c5f8391.tar.gz
rust-b9de4ef89e0e53099a084001b26ec3207c5f8391.zip
Auto merge of #64127 - Centril:rollup-dfgb9h8, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #64049 (Emit a single error on if expr with expectation and no else clause)
 - #64056 (Account for arbitrary self types in E0599)
 - #64058 (librustc_errors: Extract sugg/subst handling into method)
 - #64071 (use just one name when parameters and fields are the same)
 - #64104 (Emit error on intrinsic to fn ptr casts)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/if/if-without-else-as-fn-expr.rs6
-rw-r--r--src/test/ui/if/if-without-else-as-fn-expr.stderr83
-rw-r--r--src/test/ui/impl-trait/no-method-suggested-traits.stderr8
-rw-r--r--src/test/ui/issues/issue-50577.rs1
-rw-r--r--src/test/ui/issues/issue-50577.stderr15
-rw-r--r--src/test/ui/reify-intrinsic.rs15
-rw-r--r--src/test/ui/reify-intrinsic.stderr22
-rw-r--r--src/test/ui/self/point-at-arbitrary-self-type-method.rs9
-rw-r--r--src/test/ui/self/point-at-arbitrary-self-type-method.stderr15
-rw-r--r--src/test/ui/self/point-at-arbitrary-self-type-trait-method.rs10
-rw-r--r--src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr18
-rw-r--r--src/test/ui/traits/trait-item-privacy.stderr7
12 files changed, 113 insertions, 96 deletions
diff --git a/src/test/ui/if/if-without-else-as-fn-expr.rs b/src/test/ui/if/if-without-else-as-fn-expr.rs
index 15892de8385..826371be35f 100644
--- a/src/test/ui/if/if-without-else-as-fn-expr.rs
+++ b/src/test/ui/if/if-without-else-as-fn-expr.rs
@@ -3,7 +3,6 @@ fn foo(bar: usize) -> usize {
         return 3;
     }
     //~^^^ ERROR if may be missing an else clause
-    //~| ERROR mismatched types [E0308]
 }
 
 fn foo2(bar: usize) -> usize {
@@ -11,7 +10,6 @@ fn foo2(bar: usize) -> usize {
         return 3;
     };
     //~^^^ ERROR if may be missing an else clause
-    //~| ERROR mismatched types [E0308]
     x
 }
 
@@ -20,7 +18,6 @@ fn foo3(bar: usize) -> usize {
         3
     }
     //~^^^ ERROR if may be missing an else clause
-    //~| ERROR mismatched types [E0308]
 }
 
 fn foo_let(bar: usize) -> usize {
@@ -28,7 +25,6 @@ fn foo_let(bar: usize) -> usize {
         return 3;
     }
     //~^^^ ERROR if may be missing an else clause
-    //~| ERROR mismatched types [E0308]
 }
 
 fn foo2_let(bar: usize) -> usize {
@@ -36,7 +32,6 @@ fn foo2_let(bar: usize) -> usize {
         return 3;
     };
     //~^^^ ERROR if may be missing an else clause
-    //~| ERROR mismatched types [E0308]
     x
 }
 
@@ -45,7 +40,6 @@ fn foo3_let(bar: usize) -> usize {
         3
     }
     //~^^^ ERROR if may be missing an else clause
-    //~| ERROR mismatched types [E0308]
 }
 
 // FIXME(60254): deduplicate first error in favor of second.
diff --git a/src/test/ui/if/if-without-else-as-fn-expr.stderr b/src/test/ui/if/if-without-else-as-fn-expr.stderr
index 06600b1cb9a..b49c2aa6319 100644
--- a/src/test/ui/if/if-without-else-as-fn-expr.stderr
+++ b/src/test/ui/if/if-without-else-as-fn-expr.stderr
@@ -1,14 +1,3 @@
-error[E0308]: mismatched types
-  --> $DIR/if-without-else-as-fn-expr.rs:2:5
-   |
-LL | /     if bar % 5 == 0 {
-LL | |         return 3;
-LL | |     }
-   | |_____^ expected usize, found ()
-   |
-   = note: expected type `usize`
-              found type `()`
-
 error[E0317]: if may be missing an else clause
   --> $DIR/if-without-else-as-fn-expr.rs:2:5
    |
@@ -24,20 +13,8 @@ LL | |     }
    = note: `if` expressions without `else` evaluate to `()`
    = help: consider adding an `else` block that evaluates to the expected type
 
-error[E0308]: mismatched types
-  --> $DIR/if-without-else-as-fn-expr.rs:10:20
-   |
-LL |       let x: usize = if bar % 5 == 0 {
-   |  ____________________^
-LL | |         return 3;
-LL | |     };
-   | |_____^ expected usize, found ()
-   |
-   = note: expected type `usize`
-              found type `()`
-
 error[E0317]: if may be missing an else clause
-  --> $DIR/if-without-else-as-fn-expr.rs:10:20
+  --> $DIR/if-without-else-as-fn-expr.rs:9:20
    |
 LL |       let x: usize = if bar % 5 == 0 {
    |  _________-__________^
@@ -52,19 +29,8 @@ LL | |     };
    = note: `if` expressions without `else` evaluate to `()`
    = help: consider adding an `else` block that evaluates to the expected type
 
-error[E0308]: mismatched types
-  --> $DIR/if-without-else-as-fn-expr.rs:19:5
-   |
-LL | /     if bar % 5 == 0 {
-LL | |         3
-LL | |     }
-   | |_____^ expected usize, found ()
-   |
-   = note: expected type `usize`
-              found type `()`
-
 error[E0317]: if may be missing an else clause
-  --> $DIR/if-without-else-as-fn-expr.rs:19:5
+  --> $DIR/if-without-else-as-fn-expr.rs:17:5
    |
 LL |   fn foo3(bar: usize) -> usize {
    |                          ----- expected `usize` because of this return type
@@ -78,19 +44,8 @@ LL | |     }
    = note: `if` expressions without `else` evaluate to `()`
    = help: consider adding an `else` block that evaluates to the expected type
 
-error[E0308]: mismatched types
-  --> $DIR/if-without-else-as-fn-expr.rs:27:5
-   |
-LL | /     if let 0 = 1 {
-LL | |         return 3;
-LL | |     }
-   | |_____^ expected usize, found ()
-   |
-   = note: expected type `usize`
-              found type `()`
-
 error[E0317]: if may be missing an else clause
-  --> $DIR/if-without-else-as-fn-expr.rs:27:5
+  --> $DIR/if-without-else-as-fn-expr.rs:24:5
    |
 LL |   fn foo_let(bar: usize) -> usize {
    |                             ----- expected `usize` because of this return type
@@ -104,20 +59,8 @@ LL | |     }
    = note: `if` expressions without `else` evaluate to `()`
    = help: consider adding an `else` block that evaluates to the expected type
 
-error[E0308]: mismatched types
-  --> $DIR/if-without-else-as-fn-expr.rs:35:20
-   |
-LL |       let x: usize = if let 0 = 1 {
-   |  ____________________^
-LL | |         return 3;
-LL | |     };
-   | |_____^ expected usize, found ()
-   |
-   = note: expected type `usize`
-              found type `()`
-
 error[E0317]: if may be missing an else clause
-  --> $DIR/if-without-else-as-fn-expr.rs:35:20
+  --> $DIR/if-without-else-as-fn-expr.rs:31:20
    |
 LL |       let x: usize = if let 0 = 1 {
    |  _________-__________^
@@ -132,19 +75,8 @@ LL | |     };
    = note: `if` expressions without `else` evaluate to `()`
    = help: consider adding an `else` block that evaluates to the expected type
 
-error[E0308]: mismatched types
-  --> $DIR/if-without-else-as-fn-expr.rs:44:5
-   |
-LL | /     if let 0 = 1 {
-LL | |         3
-LL | |     }
-   | |_____^ expected usize, found ()
-   |
-   = note: expected type `usize`
-              found type `()`
-
 error[E0317]: if may be missing an else clause
-  --> $DIR/if-without-else-as-fn-expr.rs:44:5
+  --> $DIR/if-without-else-as-fn-expr.rs:39:5
    |
 LL |   fn foo3_let(bar: usize) -> usize {
    |                              ----- expected `usize` because of this return type
@@ -158,7 +90,6 @@ LL | |     }
    = note: `if` expressions without `else` evaluate to `()`
    = help: consider adding an `else` block that evaluates to the expected type
 
-error: aborting due to 12 previous errors
+error: aborting due to 6 previous errors
 
-Some errors have detailed explanations: E0308, E0317.
-For more information about an error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0317`.
diff --git a/src/test/ui/impl-trait/no-method-suggested-traits.stderr b/src/test/ui/impl-trait/no-method-suggested-traits.stderr
index d980d7cccad..002b60f9f25 100644
--- a/src/test/ui/impl-trait/no-method-suggested-traits.stderr
+++ b/src/test/ui/impl-trait/no-method-suggested-traits.stderr
@@ -49,6 +49,14 @@ LL | use foo::Bar;
 error[E0599]: no method named `method` found for type `std::rc::Rc<&mut std::boxed::Box<&char>>` in the current scope
   --> $DIR/no-method-suggested-traits.rs:32:43
    |
+LL |         fn method(&self) {}
+   |            ------
+   |            |
+   |            the method is available for `std::boxed::Box<std::rc::Rc<&mut std::boxed::Box<&char>>>` here
+   |            the method is available for `std::pin::Pin<std::rc::Rc<&mut std::boxed::Box<&char>>>` here
+   |            the method is available for `std::sync::Arc<std::rc::Rc<&mut std::boxed::Box<&char>>>` here
+   |            the method is available for `std::rc::Rc<std::rc::Rc<&mut std::boxed::Box<&char>>>` here
+...
 LL |     std::rc::Rc::new(&mut Box::new(&'a')).method();
    |                                           ^^^^^^
    |
diff --git a/src/test/ui/issues/issue-50577.rs b/src/test/ui/issues/issue-50577.rs
index bf892a8daa2..f0f1dc6c286 100644
--- a/src/test/ui/issues/issue-50577.rs
+++ b/src/test/ui/issues/issue-50577.rs
@@ -2,6 +2,5 @@ fn main() {
     enum Foo {
         Drop = assert_eq!(1, 1)
         //~^ ERROR if may be missing an else clause
-        //~| ERROR mismatched types [E0308]
     }
 }
diff --git a/src/test/ui/issues/issue-50577.stderr b/src/test/ui/issues/issue-50577.stderr
index 413c8c5c80b..0c3ba2ea4f9 100644
--- a/src/test/ui/issues/issue-50577.stderr
+++ b/src/test/ui/issues/issue-50577.stderr
@@ -1,13 +1,3 @@
-error[E0308]: mismatched types
-  --> $DIR/issue-50577.rs:3:16
-   |
-LL |         Drop = assert_eq!(1, 1)
-   |                ^^^^^^^^^^^^^^^^ expected isize, found ()
-   |
-   = note: expected type `isize`
-              found type `()`
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
 error[E0317]: if may be missing an else clause
   --> $DIR/issue-50577.rs:3:16
    |
@@ -23,7 +13,6 @@ LL |         Drop = assert_eq!(1, 1)
    = help: consider adding an `else` block that evaluates to the expected type
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
 
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
-Some errors have detailed explanations: E0308, E0317.
-For more information about an error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0317`.
diff --git a/src/test/ui/reify-intrinsic.rs b/src/test/ui/reify-intrinsic.rs
new file mode 100644
index 00000000000..09baa059e55
--- /dev/null
+++ b/src/test/ui/reify-intrinsic.rs
@@ -0,0 +1,15 @@
+// check-fail
+
+#![feature(intrinsics)]
+
+fn a() {
+    let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute;
+    //~^ ERROR cannot coerce
+}
+
+fn b() {
+    let _ = std::mem::transmute as unsafe extern "rust-intrinsic" fn(isize) -> usize;
+    //~^ ERROR casting
+}
+
+fn main() {}
diff --git a/src/test/ui/reify-intrinsic.stderr b/src/test/ui/reify-intrinsic.stderr
new file mode 100644
index 00000000000..4a1bd77cf7e
--- /dev/null
+++ b/src/test/ui/reify-intrinsic.stderr
@@ -0,0 +1,22 @@
+error[E0308]: cannot coerce intrinsics to function pointers
+  --> $DIR/reify-intrinsic.rs:6:64
+   |
+LL |     let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute;
+   |                                                                ^^^^^^^^^^^^^^^^^^^
+   |                                                                |
+   |                                                                cannot coerce intrinsics to function pointers
+   |                                                                help: use parentheses to call this function: `std::mem::transmute(...)`
+   |
+   = note: expected type `unsafe extern "rust-intrinsic" fn(isize) -> usize`
+              found type `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
+
+error[E0606]: casting `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid
+  --> $DIR/reify-intrinsic.rs:11:13
+   |
+LL |     let _ = std::mem::transmute as unsafe extern "rust-intrinsic" fn(isize) -> usize;
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0308, E0606.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/self/point-at-arbitrary-self-type-method.rs b/src/test/ui/self/point-at-arbitrary-self-type-method.rs
new file mode 100644
index 00000000000..0f7deeacad2
--- /dev/null
+++ b/src/test/ui/self/point-at-arbitrary-self-type-method.rs
@@ -0,0 +1,9 @@
+struct A;
+
+impl A {
+    fn foo(self: Box<Self>) {}
+}
+
+fn main() {
+    A.foo(); //~ ERROR E0599
+}
diff --git a/src/test/ui/self/point-at-arbitrary-self-type-method.stderr b/src/test/ui/self/point-at-arbitrary-self-type-method.stderr
new file mode 100644
index 00000000000..06dad7caa67
--- /dev/null
+++ b/src/test/ui/self/point-at-arbitrary-self-type-method.stderr
@@ -0,0 +1,15 @@
+error[E0599]: no method named `foo` found for type `A` in the current scope
+  --> $DIR/point-at-arbitrary-self-type-method.rs:8:7
+   |
+LL | struct A;
+   | --------- method `foo` not found for this
+...
+LL |     fn foo(self: Box<Self>) {}
+   |        --- the method is available for `std::boxed::Box<A>` here
+...
+LL |     A.foo();
+   |       ^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/self/point-at-arbitrary-self-type-trait-method.rs b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.rs
new file mode 100644
index 00000000000..53d99277118
--- /dev/null
+++ b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.rs
@@ -0,0 +1,10 @@
+trait B { fn foo(self: Box<Self>); }
+struct A;
+
+impl B for A {
+    fn foo(self: Box<Self>) {}
+}
+
+fn main() {
+    A.foo() //~ ERROR E0599
+}
diff --git a/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr
new file mode 100644
index 00000000000..90cd3b80745
--- /dev/null
+++ b/src/test/ui/self/point-at-arbitrary-self-type-trait-method.stderr
@@ -0,0 +1,18 @@
+error[E0599]: no method named `foo` found for type `A` in the current scope
+  --> $DIR/point-at-arbitrary-self-type-trait-method.rs:9:7
+   |
+LL | trait B { fn foo(self: Box<Self>); }
+   |              --- the method is available for `std::boxed::Box<A>` here
+LL | struct A;
+   | --------- method `foo` not found for this
+...
+LL |     A.foo()
+   |       ^^^
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+   = note: the following trait defines an item `foo`, perhaps you need to implement it:
+           candidate #1: `B`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/traits/trait-item-privacy.stderr b/src/test/ui/traits/trait-item-privacy.stderr
index de699a69fa8..ce2919c8e77 100644
--- a/src/test/ui/traits/trait-item-privacy.stderr
+++ b/src/test/ui/traits/trait-item-privacy.stderr
@@ -17,6 +17,13 @@ error[E0599]: no method named `b` found for type `S` in the current scope
 LL | struct S;
    | --------- method `b` not found for this
 ...
+LL |         fn b(&self) { }
+   |            -
+   |            |
+   |            the method is available for `std::boxed::Box<S>` here
+   |            the method is available for `std::sync::Arc<S>` here
+   |            the method is available for `std::rc::Rc<S>` here
+...
 LL |     S.b();
    |       ^
    |