about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2023-01-31 11:46:25 +0900
committerGitHub <noreply@github.com>2023-01-31 11:46:25 +0900
commitf95f835470f1c5b295d2486259e745eb8e859344 (patch)
tree9b745562e3fba358ced07abe7b0b214d1f594a0a /tests
parentfbcaf046cc49b8fcb7af96b64293301be6936fad (diff)
parent343a359109a48f4ece657831bf0331e22d108800 (diff)
downloadrust-f95f835470f1c5b295d2486259e745eb8e859344.tar.gz
rust-f95f835470f1c5b295d2486259e745eb8e859344.zip
Rollup merge of #107479 - compiler-errors:probe-can-call-ocx, r=BoxyUwU
Use `ObligationCtxt::new_in_snapshot` in `satisfied_from_param_env`

We can evaluate nested `ConstEvaluatable` obligations in an evaluation probe, which will ICE if we use `ObligationCtxt::new`.

Fixes #107474
Fixes #106666

r? `@BoxyUwU` but feel free to reassign
cc `@JulianKnodt` who i think added this assertion code

Not sure if the rustdoc test is needed, but can't hurt. They're the same root cause, though.
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc/document-item-with-associated-const-in-where-clause.rs17
-rw-r--r--tests/ui/const-generics/generic_const_exprs/single-satisfied-ConstEvaluatable-in-probe.rs39
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs b/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs
new file mode 100644
index 00000000000..c9408ef3360
--- /dev/null
+++ b/tests/rustdoc/document-item-with-associated-const-in-where-clause.rs
@@ -0,0 +1,17 @@
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+pub trait Enumerable {
+    const N: usize;
+}
+
+#[derive(Clone)]
+pub struct SymmetricGroup<S>
+where
+    S: Enumerable,
+    [(); S::N]: Sized,
+{
+    _phantom: std::marker::PhantomData<S>,
+}
+
+fn main() {}
diff --git a/tests/ui/const-generics/generic_const_exprs/single-satisfied-ConstEvaluatable-in-probe.rs b/tests/ui/const-generics/generic_const_exprs/single-satisfied-ConstEvaluatable-in-probe.rs
new file mode 100644
index 00000000000..0ba0c5a72ef
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/single-satisfied-ConstEvaluatable-in-probe.rs
@@ -0,0 +1,39 @@
+// check-pass
+
+#![allow(incomplete_features)]
+#![feature(generic_const_exprs)]
+
+use std::marker::PhantomData;
+
+pub trait Bytes {
+    const BYTES: usize;
+}
+
+#[derive(Clone, Debug)]
+pub struct Conster<OT>
+where
+    OT: Bytes,
+    [(); OT::BYTES]: Sized,
+{
+    _offset_type: PhantomData<fn(OT) -> OT>,
+}
+
+impl<OT> Conster<OT>
+where
+    OT: Bytes,
+    [(); OT::BYTES]: Sized,
+{
+    pub fn new() -> Self {
+        Conster { _offset_type: PhantomData }
+    }
+}
+
+pub fn make_conster<COT>() -> Conster<COT>
+where
+    COT: Bytes,
+    [(); COT::BYTES]: Sized,
+{
+    Conster::new()
+}
+
+fn main() {}