Skip to content

Commit fe09475

Browse files
authored
Rollup merge of rust-lang#63096 - Centril:existential-type-add-tests, r=varkor
Add tests for some `existential_type` ICEs Fix rust-lang#53678 Fix rust-lang#60407 Fix rust-lang#60564 rust-lang#54899 will need some minimization before it can be added. r? @varkor
2 parents 5cddc0a + a54dd23 commit fe09475

9 files changed

+85
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// check-pass
2+
3+
#![feature(const_fn, generators, generator_trait, existential_type)]
4+
5+
use std::ops::Generator;
6+
7+
existential type GenOnce<Y, R>: Generator<Yield = Y, Return = R>;
8+
9+
const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> {
10+
move || {
11+
yield yielding;
12+
13+
return returning;
14+
}
15+
}
16+
17+
const FOO: GenOnce<usize, usize> = const_generator(10, 100);
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// check-pass
2+
3+
#![feature(existential_type)]
4+
5+
existential type Debuggable: core::fmt::Debug;
6+
7+
static mut TEST: Option<Debuggable> = None;
8+
9+
fn main() {
10+
unsafe { TEST = Some(foo()) }
11+
}
12+
13+
fn foo() -> Debuggable {
14+
0u32
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![feature(existential_type)]
2+
3+
trait IterBits {
4+
type BitsIter: Iterator<Item = u8>;
5+
fn iter_bits(self, n: u8) -> Self::BitsIter;
6+
}
7+
8+
existential type IterBitsIter<T, E, I>: std::iter::Iterator<Item = I>;
9+
//~^ ERROR could not find defining uses
10+
11+
impl<T, E> IterBits for T
12+
where
13+
T: std::ops::Shr<Output = T>
14+
+ std::ops::BitAnd<T, Output = T>
15+
+ std::convert::From<u8>
16+
+ std::convert::TryInto<u8, Error = E>,
17+
E: std::fmt::Debug,
18+
{
19+
type BitsIter = IterBitsIter<T, E, u8>;
20+
fn iter_bits(self, n: u8) -> Self::BitsIter {
21+
//~^ ERROR type parameter `E` is part of concrete type but not used
22+
(0u8..n)
23+
.rev()
24+
.map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap())
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0601]: `main` function not found in crate `issue_60564`
2+
|
3+
= note: consider adding a `main` function to `$DIR/issue-60564.rs`
4+
5+
error: type parameter `E` is part of concrete type but not used in parameter list for existential type
6+
--> $DIR/issue-60564.rs:20:49
7+
|
8+
LL | fn iter_bits(self, n: u8) -> Self::BitsIter {
9+
| _________________________________________________^
10+
LL | |
11+
LL | | (0u8..n)
12+
LL | | .rev()
13+
LL | | .map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap())
14+
LL | | }
15+
| |_____^
16+
17+
error: could not find defining uses
18+
--> $DIR/issue-60564.rs:8:1
19+
|
20+
LL | existential type IterBitsIter<T, E, I>: std::iter::Iterator<Item = I>;
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
23+
error: aborting due to 3 previous errors
24+
25+
For more information about this error, try `rustc --explain E0601`.

0 commit comments

Comments
 (0)