about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2019-08-12 19:00:47 +0300
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2019-08-19 18:57:09 +0300
commitcb6650047b883fc70ecfd5d25f3e83a975aa66fc (patch)
tree25d3179ce2d9d30bcf8ff42546bd8d03cff49bed /src
parentf4aa00b71dbb7433c408ff111c58c81788dc879f (diff)
downloadrust-cb6650047b883fc70ecfd5d25f3e83a975aa66fc.tar.gz
rust-cb6650047b883fc70ecfd5d25f3e83a975aa66fc.zip
test: add test from #61041.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/consts/too_generic_eval_ice.rs13
-rw-r--r--src/test/ui/consts/too_generic_eval_ice.stderr47
2 files changed, 60 insertions, 0 deletions
diff --git a/src/test/ui/consts/too_generic_eval_ice.rs b/src/test/ui/consts/too_generic_eval_ice.rs
new file mode 100644
index 00000000000..7a299169bc4
--- /dev/null
+++ b/src/test/ui/consts/too_generic_eval_ice.rs
@@ -0,0 +1,13 @@
+pub struct Foo<A, B>(A, B);
+
+impl<A, B> Foo<A, B> {
+    const HOST_SIZE: usize = std::mem::size_of::<B>();
+
+    pub fn crash() -> bool {
+        [5; Self::HOST_SIZE] == [6; 0] //~ ERROR no associated item named `HOST_SIZE`
+        //~^ the size for values of type `A` cannot be known
+        //~| the size for values of type `B` cannot be known
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr
new file mode 100644
index 00000000000..eef79421270
--- /dev/null
+++ b/src/test/ui/consts/too_generic_eval_ice.stderr
@@ -0,0 +1,47 @@
+error[E0599]: no associated item named `HOST_SIZE` found for type `Foo<A, B>` in the current scope
+  --> $DIR/too_generic_eval_ice.rs:7:19
+   |
+LL | pub struct Foo<A, B>(A, B);
+   | --------------------------- associated item `HOST_SIZE` not found for this
+...
+LL |         [5; Self::HOST_SIZE] == [6; 0]
+   |                   ^^^^^^^^^ associated item not found in `Foo<A, B>`
+   |
+   = note: the method `HOST_SIZE` exists but the following trait bounds were not satisfied:
+           `A : std::marker::Sized`
+           `B : std::marker::Sized`
+
+error[E0277]: the size for values of type `A` cannot be known at compilation time
+  --> $DIR/too_generic_eval_ice.rs:7:13
+   |
+LL |         [5; Self::HOST_SIZE] == [6; 0]
+   |             ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `std::marker::Sized` is not implemented for `A`
+   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+   = help: consider adding a `where A: std::marker::Sized` bound
+note: required by `Foo`
+  --> $DIR/too_generic_eval_ice.rs:1:1
+   |
+LL | pub struct Foo<A, B>(A, B);
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0277]: the size for values of type `B` cannot be known at compilation time
+  --> $DIR/too_generic_eval_ice.rs:7:13
+   |
+LL |         [5; Self::HOST_SIZE] == [6; 0]
+   |             ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `std::marker::Sized` is not implemented for `B`
+   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+   = help: consider adding a `where B: std::marker::Sized` bound
+note: required by `Foo`
+  --> $DIR/too_generic_eval_ice.rs:1:1
+   |
+LL | pub struct Foo<A, B>(A, B);
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0277, E0599.
+For more information about an error, try `rustc --explain E0277`.