-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start using pattern types in libcore
- Loading branch information
Showing
12 changed files
with
130 additions
and
24 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
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
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
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 @@ | ||
#![feature(pattern_types, pattern_type_macro, structural_match)] | ||
|
||
use std::marker::StructuralPartialEq; | ||
use std::pat::pattern_type; | ||
|
||
struct Thing(pattern_type!(u32 is 1..)); | ||
|
||
impl StructuralPartialEq for Thing {} | ||
impl Eq for Thing {} | ||
impl PartialEq for Thing { | ||
fn eq(&self, other: &Thing) -> bool { | ||
todo!() | ||
} | ||
} | ||
|
||
const TWO: Thing = Thing(unsafe { std::mem::transmute(2_u32) }); | ||
|
||
const _: () = match TWO { | ||
TWO => {} | ||
_ => unreachable!(), | ||
}; | ||
|
||
fn main() {} |
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,20 @@ | ||
error[E0405]: cannot find trait `StructuralPartialEq` in this scope | ||
--> $DIR/matching.rs:7:6 | ||
| | ||
LL | impl StructuralPartialEq for Thing {} | ||
| ^^^^^^^^^^^^^^^^^^^ not found in this scope | ||
| | ||
help: consider importing this trait | ||
| | ||
LL + use std::marker::StructuralPartialEq; | ||
| | ||
|
||
error[E0405]: cannot find trait `StructuralEq` in this scope | ||
--> $DIR/matching.rs:8:6 | ||
| | ||
LL | impl StructuralEq for Thing {} | ||
| ^^^^^^^^^^^^ not found in this scope | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0405`. |