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.
Rollup merge of rust-lang#72061 - lcnr:const-inference-test, r=eddyb
add regression tests for stalled_on const vars closes rust-lang#70180 Afaict this has been fixed sometime after rust-lang#70213 `trait_ref_type_vars` correctly adds const infers and I did not find any remaining `FIXME`s which correspond to this issue. https://github.com/rust-lang/rust/blob/7c59a81a5fcbaaca311f744cd7c68d99bfbb05d3/src/librustc_trait_selection/traits/fulfill.rs#L555-L557 Added both examples from the issue as regression tests and renamed `trait_ref_type_vars` -> `trait_ref_infer_vars`. r? @eddyb
- Loading branch information
Showing
3 changed files
with
74 additions
and
4 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
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,35 @@ | ||
// build-pass | ||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
|
||
pub fn works() { | ||
let array/*: [_; _]*/ = default_array(); | ||
let _: [_; 4] = array; | ||
Foo::foo(&array); | ||
} | ||
|
||
pub fn didnt_work() { | ||
let array/*: [_; _]*/ = default_array(); | ||
Foo::foo(&array); | ||
let _: [_; 4] = array; | ||
} | ||
|
||
trait Foo { | ||
fn foo(&self) {} | ||
} | ||
|
||
impl Foo for [i32; 4] {} | ||
impl Foo for [i64; 8] {} | ||
|
||
// Only needed because `[_; _]` is not valid type syntax. | ||
fn default_array<T, const N: usize>() -> [T; N] | ||
where | ||
[T; N]: Default, | ||
{ | ||
Default::default() | ||
} | ||
|
||
fn main() { | ||
works(); | ||
didnt_work(); | ||
} |
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,35 @@ | ||
// build-pass | ||
#![feature(const_generics)] | ||
#![allow(incomplete_features)] | ||
|
||
fn works() { | ||
let array/*: [u8; _]*/ = default_byte_array(); | ||
let _: [_; 4] = array; | ||
Foo::foo(&array); | ||
} | ||
|
||
fn didnt_work() { | ||
let array/*: [u8; _]*/ = default_byte_array(); | ||
Foo::foo(&array); | ||
let _: [_; 4] = array; | ||
} | ||
|
||
trait Foo<T> { | ||
fn foo(&self) {} | ||
} | ||
|
||
impl Foo<i32> for [u8; 4] {} | ||
impl Foo<i64> for [u8; 8] {} | ||
|
||
// Only needed because `[u8; _]` is not valid type syntax. | ||
fn default_byte_array<const N: usize>() -> [u8; N] | ||
where | ||
[u8; N]: Default, | ||
{ | ||
Default::default() | ||
} | ||
|
||
fn main() { | ||
works(); | ||
didnt_work(); | ||
} |