about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-06 09:31:27 +0000
committerbors <bors@rust-lang.org>2020-01-06 09:31:27 +0000
commita80e63f3fa77792e848e3b248acf4c0acda2e310 (patch)
tree6e9574bac0128d5184af68d208b2ee8d9e98e416 /src/test/ui
parent33640f0e03af2fb31ce380d5389d5545f24ce29a (diff)
parent34716a31db9371501fe98100a7aa1566f37c1d23 (diff)
downloadrust-a80e63f3fa77792e848e3b248acf4c0acda2e310.tar.gz
rust-a80e63f3fa77792e848e3b248acf4c0acda2e310.zip
Auto merge of #67917 - Dylan-DPC:rollup-id05y91, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #67800 (Fix ICE involving calling `Instance.ty` during const evaluation)
 - #67873 (change remove to have a PartialEq bound)
 - #67897 (Use `as_deref()` to replace `as_ref().map(...)`)
 - #67906 (Silence `TooGeneric` error)
 - #67912 (macros: typo fix)
 - #67915 (Use Self instead of $type)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/const-generics/array-size-in-generic-struct-param.rs23
-rw-r--r--src/test/ui/const-generics/array-size-in-generic-struct-param.stderr8
-rw-r--r--src/test/ui/issues/issue-8460.rs4
-rw-r--r--src/test/ui/mir/issue-67639-normalization-ice.rs34
4 files changed, 67 insertions, 2 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
new file mode 100644
index 00000000000..f3be7b56db5
--- /dev/null
+++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.rs
@@ -0,0 +1,23 @@
+// 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
+
+#[derive(PartialEq, Eq)]
+struct Config {
+    arr_size: usize,
+}
+
+struct B<const CFG: Config> {
+    arr: [u8; CFG.arr_size], // ok
+}
+
+const C: Config = Config { arr_size: 5 };
+
+fn main() {
+    let b = B::<C> { arr: [1, 2, 3, 4, 5] };
+    assert_eq!(b.arr.len(), 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
new file mode 100644
index 00000000000..274f9769702
--- /dev/null
+++ b/src/test/ui/const-generics/array-size-in-generic-struct-param.stderr
@@ -0,0 +1,8 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/array-size-in-generic-struct-param.rs:3:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
diff --git a/src/test/ui/issues/issue-8460.rs b/src/test/ui/issues/issue-8460.rs
index b7fc564a9b5..3fd576a8d35 100644
--- a/src/test/ui/issues/issue-8460.rs
+++ b/src/test/ui/issues/issue-8460.rs
@@ -11,8 +11,8 @@ trait Int {
 }
 macro_rules! doit {
     ($($t:ident)*) => ($(impl Int for $t {
-        fn zero() -> $t { 0 }
-        fn one() -> $t { 1 }
+        fn zero() -> Self { 0 }
+        fn one() -> Self { 1 }
     })*)
 }
 doit! { i8 i16 i32 i64 isize }
diff --git a/src/test/ui/mir/issue-67639-normalization-ice.rs b/src/test/ui/mir/issue-67639-normalization-ice.rs
new file mode 100644
index 00000000000..21851a72525
--- /dev/null
+++ b/src/test/ui/mir/issue-67639-normalization-ice.rs
@@ -0,0 +1,34 @@
+// compile-flags: -Z mir-opt-level=3
+// build-pass
+
+// This used to ICE in const-prop due
+// to an empty ParamEnv being used during normalization
+// of a generic type
+
+
+fn main() {
+    join_all::<u32>();
+}
+
+trait Foo {
+    type Item;
+}
+
+impl Foo for u32 {
+    type Item = u8;
+}
+
+trait Bar {
+    type Item2;
+}
+
+impl Bar for u8 {
+    type Item2 = u64;
+}
+
+fn join_all<I>()
+where I: Foo,
+    I::Item: Bar
+{
+    Vec::<<I::Item as Bar>::Item2>::new(); // ICE occurs processing this line
+}