about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-09 00:08:13 +0000
committerbors <bors@rust-lang.org>2020-09-09 00:08:13 +0000
commit90782cb50ba6d1f2ea97cf74a3b06eca6bef8b59 (patch)
tree8c6c6063d8b622a8bc8078688bfc4c8137c9c33a /src/test
parent5099914a16a215794ad243df0cc7a05d91d168e0 (diff)
parent389321a41e61666fd68982570983c3061ab3047e (diff)
Auto merge of #76502 - Dylan-DPC:rollup-2c4zz0t, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #76162 (Make duration_since documentation more clear)
 - #76355 (remove public visibility previously needed for rustfmt)
 - #76374 (Improve ayu doc source line number contrast)
 - #76379 (rustbuild: Remove `Mode::Codegen`)
 - #76389 (Fix HashMap visualizers in Visual Studio (Code))
 - #76396 (Fix typo in tracking issue template)
 - #76401 (Add help note to unconstrained const parameter)
 - #76402 (Update linker-plugin-lto.md to contain up to rust 1.46)
 - #76403 (Fix documentation for TyCtxt::all_impls)
 - #76498 (Update cargo)

Failed merges:

 - #76458 (Add drain_filter method to HashMap and HashSet)

r? `@ghost`
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/const-generics/issues/issue-68366.rs18
-rw-r--r--src/test/ui/const-generics/issues/issue-68366.stderr21
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/issues/issue-68366.rs b/src/test/ui/const-generics/issues/issue-68366.rs
new file mode 100644
index 00000000000..a06b99d6645
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-68366.rs
@@ -0,0 +1,18 @@
+// Checks that const expressions have a useful note explaining why they can't be evaluated.
+// The note should relate to the fact that it cannot be shown forall N that it maps 1-1 to a new
+// type.
+
+#![feature(const_generics)]
+#![allow(incomplete_features)]
+
+struct Collatz<const N: Option<usize>>;
+
+impl <const N: usize> Collatz<{Some(N)}> {}
+//~^ ERROR the const parameter
+
+struct Foo;
+
+impl<const N: usize> Foo {}
+//~^ ERROR the const parameter
+
+fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-68366.stderr b/src/test/ui/const-generics/issues/issue-68366.stderr
new file mode 100644
index 00000000000..bba16f42153
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-68366.stderr
@@ -0,0 +1,21 @@
+error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
+  --> $DIR/issue-68366.rs:10:13
+   |
+LL | impl <const N: usize> Collatz<{Some(N)}> {}
+   |             ^ unconstrained const parameter
+   |
+   = note: expressions using a const parameter must map each value to a distinct output value
+   = note: proving the result of expressions other than the parameter are unique is not supported
+
+error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
+  --> $DIR/issue-68366.rs:15:12
+   |
+LL | impl<const N: usize> Foo {}
+   |            ^ unconstrained const parameter
+   |
+   = note: expressions using a const parameter must map each value to a distinct output value
+   = note: proving the result of expressions other than the parameter are unique is not supported
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0207`.