-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assign correct types to struct-like enum variant constructors
Before, the type was just the enum type itself, which caused an assertion failure in iter_variant in trans::base. r=brson Closes #4229
- Loading branch information
1 parent
cf768ce
commit 499a587
Showing
3 changed files
with
29 additions
and
2 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,11 @@ | ||
enum Animal { | ||
Dog (~str, float), | ||
Cat { name: ~str, weight: float } | ||
} | ||
|
||
fn main() { | ||
let mut a: Animal = Dog(~"Cocoa", 37.2); | ||
a = Cat{ name: ~"Spotty", weight: 2.7 }; | ||
// permuting the fields should work too | ||
let c = Cat { weight: 3.1, name: ~"Spreckles" }; | ||
} |