File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -2499,12 +2499,15 @@ pub fn type_is_enum(ty: t) -> bool {
2499
2499
// constructors
2500
2500
pub fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
2501
2501
match get(ty).sty {
2502
- ty_enum(did, _) => {
2503
- let variants = enum_variants(cx, did);
2504
- let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u);
2505
- return !some_n_ary;
2506
- }
2507
- _ => return false
2502
+ ty_enum(did, _) => {
2503
+ let variants = enum_variants(cx, did);
2504
+ if variants.len() == 0 {
2505
+ false
2506
+ } else {
2507
+ variants.all(|v| v.args.len() == 0)
2508
+ }
2509
+ }
2510
+ _ => false
2508
2511
}
2509
2512
}
2510
2513
Original file line number Diff line number Diff line change
1
+ enum E { }
2
+
3
+ fn f ( e : E ) {
4
+ println ( ( e as int ) . to_str ( ) ) ; //~ ERROR non-scalar cast
5
+ }
6
+
7
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments