about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-10-25 22:59:49 +0200
committerGitHub <noreply@github.com>2021-10-25 22:59:49 +0200
commit26e9a719f230815b2c535777c466030c696c9d89 (patch)
tree34a8ed3d3f98baa429bc0fc81d300c80e6812780 /src/test
parentd35ecb949e9d516fb319e41b2d33f103764d1a11 (diff)
parent0199a81304fe7cf07f0d2c718a4243f47c1620ea (diff)
Rollup merge of #90266 - b-naber:uneval_substs, r=lcnr
Prevent duplicate caller bounds candidates by exposing default substs in Unevaluated

Fixes https://github.com/rust-lang/rust/issues/89334

The changes introduced in https://github.com/rust-lang/rust/pull/87280 allowed for "duplicate" caller bounds candidates to be assembled that only differed in their default substs having been "exposed" or not and resulted in an ambiguity error during trait selection. To fix this we expose the defaults substs during the creation of the ParamEnv.

r? `@lcnr`
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/const-generics/expose-default-substs-param-env.rs9
-rw-r--r--src/test/ui/const-generics/issues/issue-89334.rs16
2 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/expose-default-substs-param-env.rs b/src/test/ui/const-generics/expose-default-substs-param-env.rs
new file mode 100644
index 00000000000..e40c93116af
--- /dev/null
+++ b/src/test/ui/const-generics/expose-default-substs-param-env.rs
@@ -0,0 +1,9 @@
+// build-pass
+
+#![feature(generic_const_exprs)]
+#![allow(unused_braces, incomplete_features)]
+
+pub trait Foo<const N: usize> {}
+pub trait Bar: Foo<{ 1 }> { }
+
+fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-89334.rs b/src/test/ui/const-generics/issues/issue-89334.rs
new file mode 100644
index 00000000000..b15b7428cdd
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-89334.rs
@@ -0,0 +1,16 @@
+// build-pass
+
+#![feature(generic_const_exprs)]
+#![allow(unused_braces, incomplete_features)]
+
+pub trait AnotherTrait{
+    const ARRAY_SIZE: usize;
+}
+pub trait Shard<T: AnotherTrait>:
+    AsMut<[[u8; T::ARRAY_SIZE]]>
+where
+    [(); T::ARRAY_SIZE]: Sized
+{
+}
+
+fn main() {}