about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-12-20 00:50:46 +0000
committerbors <bors@rust-lang.org>2020-12-20 00:50:46 +0000
commit0c11b93f5a8914a40f619b0a1663baafe029d427 (patch)
treee771970ae158f785df8990ab57e8371219ca3114 /src/test/ui
parentc1d58436614ad522e4db9113ac56d90ec4a95448 (diff)
parent806c7281ec1905423aa4569d79940b59efc1905a (diff)
downloadrust-0c11b93f5a8914a40f619b0a1663baafe029d427.tar.gz
rust-0c11b93f5a8914a40f619b0a1663baafe029d427.zip
Auto merge of #79635 - lcnr:const-eval-idk, r=oli-obk
const_evaluatable_checked: fix occurs check

fixes #79615

this is kind of a hack because we use `TypeRelation` for both the `Generalizer` and the `ConstInferUnifier` but i am not sure if there is a useful way to disentangle this without unnecessarily duplicating some code.

The error in the added test is kind of unavoidable until we erase the unused substs of `ConstKind::Unevaluated`. We talked a bit about this in the cg lazy norm meeting (https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/lazy_normalization_consts)
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/const-generics/occurs-check/unused-substs-5.rs20
-rw-r--r--src/test/ui/const-generics/occurs-check/unused-substs-5.stderr12
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-5.rs b/src/test/ui/const-generics/occurs-check/unused-substs-5.rs
new file mode 100644
index 00000000000..e5d487d89b9
--- /dev/null
+++ b/src/test/ui/const-generics/occurs-check/unused-substs-5.rs
@@ -0,0 +1,20 @@
+#![feature(const_generics, const_evaluatable_checked)]
+#![allow(incomplete_features)]
+
+// `N + 1` also depends on `T` here even if it doesn't use it.
+fn q<T, const N: usize>(_: T) -> [u8; N + 1] {
+    todo!()
+}
+
+fn supplier<T>() -> T {
+    todo!()
+}
+
+fn catch_me<const N: usize>() where [u8; N + 1]: Default {
+    let mut x = supplier();
+    x = q::<_, N>(x); //~ ERROR mismatched types
+}
+
+fn main() {
+    catch_me::<3>();
+}
diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-5.stderr b/src/test/ui/const-generics/occurs-check/unused-substs-5.stderr
new file mode 100644
index 00000000000..239569dab09
--- /dev/null
+++ b/src/test/ui/const-generics/occurs-check/unused-substs-5.stderr
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/unused-substs-5.rs:15:9
+   |
+LL |     x = q::<_, N>(x);
+   |         ^^^^^^^^^^^^
+   |         |
+   |         cyclic type of infinite size
+   |         help: try using a conversion method: `q::<_, N>(x).to_vec()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.