forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
9 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
src/test/ui/existential_types/issue-53678-generator-and-const-fn.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// check-pass | ||
|
||
#![feature(const_fn, generators, generator_trait, existential_type)] | ||
|
||
use std::ops::Generator; | ||
|
||
existential type GenOnce<Y, R>: Generator<Yield = Y, Return = R>; | ||
|
||
const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> { | ||
move || { | ||
yield yielding; | ||
|
||
return returning; | ||
} | ||
} | ||
|
||
const FOO: GenOnce<usize, usize> = const_generator(10, 100); | ||
|
||
fn main() {} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// check-pass | ||
|
||
#![feature(existential_type)] | ||
|
||
existential type Debuggable: core::fmt::Debug; | ||
|
||
static mut TEST: Option<Debuggable> = None; | ||
|
||
fn main() { | ||
unsafe { TEST = Some(foo()) } | ||
} | ||
|
||
fn foo() -> Debuggable { | ||
0u32 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#![feature(existential_type)] | ||
|
||
trait IterBits { | ||
type BitsIter: Iterator<Item = u8>; | ||
fn iter_bits(self, n: u8) -> Self::BitsIter; | ||
} | ||
|
||
existential type IterBitsIter<T, E, I>: std::iter::Iterator<Item = I>; | ||
//~^ ERROR could not find defining uses | ||
|
||
impl<T, E> IterBits for T | ||
where | ||
T: std::ops::Shr<Output = T> | ||
+ std::ops::BitAnd<T, Output = T> | ||
+ std::convert::From<u8> | ||
+ std::convert::TryInto<u8, Error = E>, | ||
E: std::fmt::Debug, | ||
{ | ||
type BitsIter = IterBitsIter<T, E, u8>; | ||
fn iter_bits(self, n: u8) -> Self::BitsIter { | ||
//~^ ERROR type parameter `E` is part of concrete type but not used | ||
(0u8..n) | ||
.rev() | ||
.map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0601]: `main` function not found in crate `issue_60564` | ||
| | ||
= note: consider adding a `main` function to `$DIR/issue-60564.rs` | ||
|
||
error: type parameter `E` is part of concrete type but not used in parameter list for existential type | ||
--> $DIR/issue-60564.rs:20:49 | ||
| | ||
LL | fn iter_bits(self, n: u8) -> Self::BitsIter { | ||
| _________________________________________________^ | ||
LL | | | ||
LL | | (0u8..n) | ||
LL | | .rev() | ||
LL | | .map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) | ||
LL | | } | ||
| |_____^ | ||
|
||
error: could not find defining uses | ||
--> $DIR/issue-60564.rs:8:1 | ||
| | ||
LL | existential type IterBitsIter<T, E, I>: std::iter::Iterator<Item = I>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0601`. |