File tree 2 files changed +16
-6
lines changed
2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -2509,12 +2509,15 @@ pub fn type_is_enum(ty: t) -> bool {
2509
2509
// constructors
2510
2510
pub fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
2511
2511
match get(ty).sty {
2512
- ty_enum(did, _) => {
2513
- let variants = enum_variants(cx, did);
2514
- let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u);
2515
- return !some_n_ary;
2516
- }
2517
- _ => return false
2512
+ ty_enum(did, _) => {
2513
+ let variants = enum_variants(cx, did);
2514
+ if variants.len() == 0 {
2515
+ false
2516
+ } else {
2517
+ variants.all(|v| v.args.len() == 0)
2518
+ }
2519
+ }
2520
+ _ => false
2518
2521
}
2519
2522
}
2520
2523
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