about summary refs log tree commit diff
path: root/src/test/ui/const-generics/const_evaluatable_checked
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2021-02-02 16:01:39 -0500
committerGitHub <noreply@github.com>2021-02-02 16:01:39 -0500
commit3aed8b17a89e5ed856eeb5a877cf298761aee757 (patch)
tree6c2e2d61124250b596b55d5c676de8b49473b640 /src/test/ui/const-generics/const_evaluatable_checked
parent76be6bb4de596ad24c62dd52baeb0cb56c8937ae (diff)
parent65256717f2b3a6cb2d4f84e834941d7433ff5e15 (diff)
downloadrust-3aed8b17a89e5ed856eeb5a877cf298761aee757.tar.gz
rust-3aed8b17a89e5ed856eeb5a877cf298761aee757.zip
Rollup merge of #81544 - JulianKnodt:sat_where, r=lcnr
Add better diagnostic for unbounded Abst. Const

~~In the case where a generic abst. const requires a trivial where bound: `where TypeWithConst<const_fn(N)>: ,`,
instead of requiring a where bound, just check that only consts are being substituted in to skip over where check.~~

~~This is pretty sketchy, but I think it works. Presumably, if there is checking for type bounds added later, it can first check nested requirements, and see if they're satisfied by the current `ParamEnv`.~~

Changed the diagnostic to add a better example, which is more practical than what was previously proposed.

r? ```@lcnr```
Diffstat (limited to 'src/test/ui/const-generics/const_evaluatable_checked')
-rw-r--r--src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr8
-rw-r--r--src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr b/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr
index 8a298b47fff..92547ca4796 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr
+++ b/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr
@@ -4,7 +4,7 @@ error: unconstrained generic constant
 LL |     let _ = const_evaluatable_lib::test1::<T>();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-help: consider adding a `where` bound for this expression
+help: try adding a `where` bound using this expression: where [u8; std::mem::size_of::<T>() - 1]: Sized
   --> $DIR/auxiliary/const_evaluatable_lib.rs:6:10
    |
 LL |     [u8; std::mem::size_of::<T>() - 1]: Sized,
@@ -16,7 +16,7 @@ error: unconstrained generic constant
 LL |     let _ = const_evaluatable_lib::test1::<T>();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-help: consider adding a `where` bound for this expression
+help: try adding a `where` bound using this expression: where [u8; std::mem::size_of::<T>() - 1]: Sized
   --> $DIR/auxiliary/const_evaluatable_lib.rs:4:27
    |
 LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
@@ -28,7 +28,7 @@ error: unconstrained generic constant
 LL |     let _ = const_evaluatable_lib::test1::<T>();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-help: consider adding a `where` bound for this expression
+help: try adding a `where` bound using this expression: where [u8; std::mem::size_of::<T>() - 1]: Sized
   --> $DIR/auxiliary/const_evaluatable_lib.rs:6:10
    |
 LL |     [u8; std::mem::size_of::<T>() - 1]: Sized,
@@ -40,7 +40,7 @@ error: unconstrained generic constant
 LL |     let _ = const_evaluatable_lib::test1::<T>();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-help: consider adding a `where` bound for this expression
+help: try adding a `where` bound using this expression: where [u8; std::mem::size_of::<T>() - 1]: Sized
   --> $DIR/auxiliary/const_evaluatable_lib.rs:4:27
    |
 LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr b/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr
index 1f6dddb04e5..00efb610004 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr
+++ b/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr
@@ -4,7 +4,7 @@ error: unconstrained generic constant
 LL |     [0; size_of::<Foo<T>>()]
    |         ^^^^^^^^^^^^^^^^^^^
    |
-help: consider adding a `where` bound for this expression
+help: try adding a `where` bound using this expression: where [u8; size_of::<Foo<T>>()]: Sized
   --> $DIR/different-fn.rs:10:9
    |
 LL |     [0; size_of::<Foo<T>>()]