Skip to content

Commit 343a359

Browse files
Use ObligationCtxt::new_in_snapshot in satisfied_from_param_env
1 parent f55b002 commit 343a359

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn satisfied_from_param_env<'tcx>(
219219
}
220220

221221
if let Some(Ok(c)) = single_match {
222-
let ocx = ObligationCtxt::new(infcx);
222+
let ocx = ObligationCtxt::new_in_snapshot(infcx);
223223
assert!(ocx.eq(&ObligationCause::dummy(), param_env, c.ty(), ct.ty()).is_ok());
224224
assert!(ocx.eq(&ObligationCause::dummy(), param_env, c, ct).is_ok());
225225
assert!(ocx.select_all_or_error().is_empty());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
pub trait Enumerable {
5+
const N: usize;
6+
}
7+
8+
#[derive(Clone)]
9+
pub struct SymmetricGroup<S>
10+
where
11+
S: Enumerable,
12+
[(); S::N]: Sized,
13+
{
14+
_phantom: std::marker::PhantomData<S>,
15+
}
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// check-pass
2+
3+
#![allow(incomplete_features)]
4+
#![feature(generic_const_exprs)]
5+
6+
use std::marker::PhantomData;
7+
8+
pub trait Bytes {
9+
const BYTES: usize;
10+
}
11+
12+
#[derive(Clone, Debug)]
13+
pub struct Conster<OT>
14+
where
15+
OT: Bytes,
16+
[(); OT::BYTES]: Sized,
17+
{
18+
_offset_type: PhantomData<fn(OT) -> OT>,
19+
}
20+
21+
impl<OT> Conster<OT>
22+
where
23+
OT: Bytes,
24+
[(); OT::BYTES]: Sized,
25+
{
26+
pub fn new() -> Self {
27+
Conster { _offset_type: PhantomData }
28+
}
29+
}
30+
31+
pub fn make_conster<COT>() -> Conster<COT>
32+
where
33+
COT: Bytes,
34+
[(); COT::BYTES]: Sized,
35+
{
36+
Conster::new()
37+
}
38+
39+
fn main() {}

0 commit comments

Comments
 (0)