-
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 #80551 - lcnr:const-arg-wildcard, r=varkor
support pattern as const parents in type_of nice to know that there's still stuff about rust i didn't know about 😆 fixes #80531 r? `@varkor`
- Loading branch information
Showing
5 changed files
with
127 additions
and
11 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
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 @@ | ||
// check-pass | ||
enum ConstGenericEnum<const N: usize> { | ||
Foo([i32; N]), | ||
Bar, | ||
} | ||
|
||
fn foo<const N: usize>(val: &ConstGenericEnum<N>) { | ||
if let ConstGenericEnum::<N>::Foo(field, ..) = val {} | ||
} | ||
|
||
fn bar<const N: usize>(val: &ConstGenericEnum<N>) { | ||
match val { | ||
ConstGenericEnum::<N>::Foo(field, ..) => (), | ||
ConstGenericEnum::<N>::Bar => (), | ||
} | ||
} | ||
|
||
fn main() { | ||
match ConstGenericEnum::Bar { | ||
ConstGenericEnum::<3>::Foo(field, ..) => (), | ||
ConstGenericEnum::<3>::Bar => (), | ||
} | ||
} |
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,10 @@ | ||
// check-pass | ||
enum Generic<const N: usize> { | ||
Variant, | ||
} | ||
|
||
fn main() { | ||
match todo!() { | ||
Generic::<0usize>::Variant => todo!() | ||
} | ||
} |
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,43 @@ | ||
// check-pass | ||
struct Foo<const N: usize>; | ||
|
||
fn bindingp() { | ||
match Foo { | ||
mut x @ Foo::<3> => { | ||
let ref mut _x @ Foo::<3> = x; | ||
} | ||
} | ||
} | ||
|
||
struct Bar<const N: usize> { | ||
field: Foo<N>, | ||
} | ||
|
||
fn structp() { | ||
match todo!() { | ||
Bar::<3> { | ||
field: Foo::<3>, | ||
} => (), | ||
} | ||
} | ||
|
||
struct Baz<const N: usize>(Foo<N>); | ||
|
||
fn tuplestructp() { | ||
match Baz(Foo) { | ||
Baz::<3>(Foo::<3>) => (), | ||
} | ||
} | ||
|
||
impl<const N: usize> Baz<N> { | ||
const ASSOC: usize = 3; | ||
} | ||
|
||
fn pathp() { | ||
match 3 { | ||
Baz::<3>::ASSOC => (), | ||
_ => (), | ||
} | ||
} | ||
|
||
fn main() {} |