-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #65652 - skinny121:const_infer_leak, r=eddyb
Fix `canonicalize_const_var` leaking inference variables Fixes #61338 Fixes #61516 Fixes #62536 Fixes #64087 Fixes #64863 Fixes #65623 I added regression tests for all these issues apart from #64863, which is very similar to #61338. r? @varkor
- Loading branch information
Showing
6 changed files
with
68 additions
and
1 deletion.
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,14 @@ | ||
// revisions:rpass1 | ||
|
||
#![feature(const_generics)] | ||
|
||
struct Struct<T>(T); | ||
|
||
impl<T, const N: usize> Struct<[T; N]> { | ||
fn f() {} | ||
fn g() { Self::f(); } | ||
} | ||
|
||
fn main() { | ||
Struct::<[u32; 3]>::g(); | ||
} |
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,16 @@ | ||
// revisions:rpass1 | ||
|
||
#![feature(const_generics)] | ||
|
||
struct FakeArray<T, const N: usize>(T); | ||
|
||
impl<T, const N: usize> FakeArray<T, { N }> { | ||
fn len(&self) -> usize { | ||
N | ||
} | ||
} | ||
|
||
fn main() { | ||
let fa = FakeArray::<u32, { 32 }>(1); | ||
assert_eq!(fa.len(), 32); | ||
} |
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,12 @@ | ||
// revisions:cfail1 | ||
#![feature(const_generics)] | ||
//[cfail1]~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash | ||
|
||
struct S<T, const N: usize>([T; N]); | ||
|
||
fn f<T, const N: usize>(x: T) -> S<T, {N}> { panic!() } | ||
|
||
fn main() { | ||
f(0u8); | ||
//[cfail1]~^ ERROR type annotations needed | ||
} |
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,11 @@ | ||
// revisions:cfail1 | ||
#![feature(const_generics)] | ||
//[cfail1]~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash | ||
|
||
fn combinator<T, const S: usize>() -> [T; S] {} | ||
//[cfail1]~^ ERROR mismatched types | ||
|
||
fn main() { | ||
combinator().into_iter(); | ||
//[cfail1]~^ ERROR type annotations needed | ||
} |
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,14 @@ | ||
// revisions:rpass1 | ||
#![feature(const_generics)] | ||
|
||
pub struct Foo<T, const N: usize>([T; 0]); | ||
|
||
impl<T, const N: usize> Foo<T, {N}> { | ||
pub fn new() -> Self { | ||
Foo([]) | ||
} | ||
} | ||
|
||
fn main() { | ||
let _: Foo<u32, 0> = Foo::new(); | ||
} |