diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-09-09 01:35:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-09 01:35:20 +0200 |
| commit | 1083833b3ed12319d345b3c63b6473ae27eba64c (patch) | |
| tree | 65232997d60ce4fd62fc33de7dd7c4c5500d72d6 /src | |
| parent | d45faff0bf5fb2634757e6b7326c7a7a1de3ab1b (diff) | |
| parent | ee55c1f1d2c427fecedd68e28a7dc4e6c68738b5 (diff) | |
Rollup merge of #76401 - JulianKnodt:i68366, r=lcnr
Add help note to unconstrained const parameter Resolves #68366, since it is currently intended behaviour. If demonstrating `T -> U` is injective, there should be an additional word that it is not **yet** supported. r? @lcnr
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-68366.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-68366.stderr | 21 |
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`. |
