about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-23 00:04:33 +0000
committerbors <bors@rust-lang.org>2020-01-23 00:04:33 +0000
commite23dd6687f7677a715765bff1fe5e63b906cb96b (patch)
tree7bbb599260f76a958a7365f8e535bd418020253c /src/test/ui
parentd1e594f4029c6ac8feb7c2acf9f9e04c1b9c493c (diff)
parentbfac73c0a6786644d0a58a12347839d442be26ac (diff)
Auto merge of #68474 - tmandry:rollup-6gmbet6, r=tmandry
Rollup of 10 pull requests

Successful merges:

 - #67195 ([experiment] Add `-Z no-link` flag)
 - #68253 (add bare metal ARM Cortex-A targets to rustc)
 - #68361 (Unbreak linking with lld 9 on FreeBSD 13.0-CURRENT i386)
 - #68388 (Make `TooGeneric` error in WF checking a proper error)
 - #68409 (Micro-optimize OutputFilenames)
 - #68410 (Export weak symbols used by MemorySanitizer)
 - #68425 (Fix try-op diagnostic in E0277 for methods)
 - #68440 (bootstrap: update clippy subcmd decription)
 - #68441 (pprust: use as_deref)
 - #68462 (librustc_mir: don't allocate vectors where slices will do.)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/const-generics/array-size-in-generic-struct-param.rs7
-rw-r--r--src/test/ui/const-generics/array-size-in-generic-struct-param.stderr20
-rw-r--r--src/test/ui/try-on-option-diagnostics.rs29
-rw-r--r--src/test/ui/try-on-option-diagnostics.stderr28
4 files changed, 78 insertions, 6 deletions
diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs
index f3be7b56db5..d996bf56fcc 100644
--- a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs
+++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs
@@ -1,10 +1,9 @@
-// run-pass
-
 #![feature(const_generics)]
 //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
 
 #[allow(dead_code)]
-struct ArithArrayLen<const N: usize>([u32; 0 + N]); // ok
+struct ArithArrayLen<const N: usize>([u32; 0 + N]);
+//~^ ERROR constant expression depends on a generic parameter
 
 #[derive(PartialEq, Eq)]
 struct Config {
@@ -12,7 +11,7 @@ struct Config {
 }
 
 struct B<const CFG: Config> {
-    arr: [u8; CFG.arr_size], // ok
+    arr: [u8; CFG.arr_size], //~ ERROR constant expression depends on a generic parameter
 }
 
 const C: Config = Config { arr_size: 5 };
diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr b/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr
index 274f9769702..6ae70c493b1 100644
--- a/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr
+++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr
@@ -1,8 +1,26 @@
 warning: the feature `const_generics` is incomplete and may cause the compiler to crash
-  --> $DIR/array-size-in-generic-struct-param.rs:3:12
+  --> $DIR/array-size-in-generic-struct-param.rs:1:12
    |
 LL | #![feature(const_generics)]
    |            ^^^^^^^^^^^^^^
    |
    = note: `#[warn(incomplete_features)]` on by default
 
+error: constant expression depends on a generic parameter
+  --> $DIR/array-size-in-generic-struct-param.rs:5:38
+   |
+LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
+   |                                      ^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: constant expression depends on a generic parameter
+  --> $DIR/array-size-in-generic-struct-param.rs:14:5
+   |
+LL |     arr: [u8; CFG.arr_size],
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this may fail depending on what value the parameter takes
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/try-on-option-diagnostics.rs b/src/test/ui/try-on-option-diagnostics.rs
index 65d5e29ec2f..63d17414c31 100644
--- a/src/test/ui/try-on-option-diagnostics.rs
+++ b/src/test/ui/try-on-option-diagnostics.rs
@@ -16,3 +16,32 @@ fn a_closure() -> u32 {
     };
     a_closure()
 }
+
+fn a_method() -> u32 {
+    struct S;
+
+    impl S {
+        fn a_method() {
+            let x: Option<u32> = None;
+            x?; //~ ERROR the `?` operator
+        }
+    }
+
+    S::a_method();
+    22
+}
+
+fn a_trait_method() -> u32 {
+    struct S;
+    trait T {
+        fn a_trait_method() {
+            let x: Option<u32> = None;
+            x?; //~ ERROR the `?` operator
+        }
+    }
+
+    impl T for S { }
+
+    S::a_trait_method();
+    22
+}
diff --git a/src/test/ui/try-on-option-diagnostics.stderr b/src/test/ui/try-on-option-diagnostics.stderr
index ce3aca39fb8..c9dc3f1b879 100644
--- a/src/test/ui/try-on-option-diagnostics.stderr
+++ b/src/test/ui/try-on-option-diagnostics.stderr
@@ -27,6 +27,32 @@ LL | |     };
    = help: the trait `std::ops::Try` is not implemented for `{integer}`
    = note: required by `std::ops::Try::from_error`
 
-error: aborting due to 2 previous errors
+error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
+  --> $DIR/try-on-option-diagnostics.rs:26:13
+   |
+LL | /         fn a_method() {
+LL | |             let x: Option<u32> = None;
+LL | |             x?;
+   | |             ^^ cannot use the `?` operator in a method that returns `()`
+LL | |         }
+   | |_________- this function should return `Result` or `Option` to accept `?`
+   |
+   = help: the trait `std::ops::Try` is not implemented for `()`
+   = note: required by `std::ops::Try::from_error`
+
+error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `std::ops::Try`)
+  --> $DIR/try-on-option-diagnostics.rs:39:13
+   |
+LL | /         fn a_trait_method() {
+LL | |             let x: Option<u32> = None;
+LL | |             x?;
+   | |             ^^ cannot use the `?` operator in a trait method that returns `()`
+LL | |         }
+   | |_________- this function should return `Result` or `Option` to accept `?`
+   |
+   = help: the trait `std::ops::Try` is not implemented for `()`
+   = note: required by `std::ops::Try::from_error`
+
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0277`.