From 343a359109a48f4ece657831bf0331e22d108800 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 30 Jan 2023 19:04:55 +0000 Subject: Use ObligationCtxt::new_in_snapshot in satisfied_from_param_env --- ...t-item-with-associated-const-in-where-clause.rs | 17 ++++++++++ .../single-satisfied-ConstEvaluatable-in-probe.rs | 39 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/rustdoc/document-item-with-associated-const-in-where-clause.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/single-satisfied-ConstEvaluatable-in-probe.rs (limited to 'tests') 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 +where + S: Enumerable, + [(); S::N]: Sized, +{ + _phantom: std::marker::PhantomData, +} + +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 +where + OT: Bytes, + [(); OT::BYTES]: Sized, +{ + _offset_type: PhantomData OT>, +} + +impl Conster +where + OT: Bytes, + [(); OT::BYTES]: Sized, +{ + pub fn new() -> Self { + Conster { _offset_type: PhantomData } + } +} + +pub fn make_conster() -> Conster +where + COT: Bytes, + [(); COT::BYTES]: Sized, +{ + Conster::new() +} + +fn main() {} -- cgit 1.4.1-3-g733a5