forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconst-fn-cycle.rs
More file actions
29 lines (24 loc) · 823 Bytes
/
const-fn-cycle.rs
File metadata and controls
29 lines (24 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Discovered in https://github.com/rust-lang/rust/issues/112602.
//! This caused a cycle error, which made no sense.
//! Removing the `const` part of the `many` function would make the
//! test pass again.
//! The issue was that we were running const qualif checks on
//! `const fn`s, but never using them. During const qualif checks we tend
//! to end up revealing opaque types (the RPIT in `many`'s return type),
//! which can quickly lead to cycles.
// check-pass
pub struct Parser<H>(H);
impl<H, T> Parser<H>
where
H: for<'a> Fn(&'a str) -> T,
{
pub const fn new(handler: H) -> Parser<H> {
Parser(handler)
}
pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> {
Parser::new(|_| unimplemented!())
}
}
fn main() {
println!("Hello, world!");
}