forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests for const-generic IATs
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
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,23 @@ | ||
// Regression test for issue #109759. | ||
// check-pass | ||
|
||
#![feature(inherent_associated_types)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Foo; | ||
|
||
struct Bar<const X: usize>([(); X]); | ||
|
||
impl<const X: usize> Bar<X> { | ||
pub fn new() -> Self { | ||
Self([(); X]) | ||
} | ||
} | ||
|
||
impl Foo { | ||
type Bar<const X: usize> = Bar<X>; | ||
} | ||
|
||
fn main() { | ||
let _ = Foo::Bar::<10>::new(); | ||
} |
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,28 @@ | ||
// check-pass | ||
|
||
#![feature(inherent_associated_types, generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Parent<const O: usize>; | ||
|
||
impl<const O: usize> Parent<O> { | ||
type Mapping<const I: usize> = Store<{ O + I }> | ||
where | ||
[(); O + I]: | ||
; | ||
} | ||
|
||
struct Store<const N: usize>; | ||
|
||
impl<const N: usize> Store<N> { | ||
const REIFIED: usize = N; | ||
|
||
fn reify() -> usize { | ||
N | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = Parent::<2>::Mapping::<{ 12 * 2 }>::REIFIED; | ||
let _ = Parent::<1>::Mapping::<{ 2 * 5 }>::reify(); | ||
} |