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 @@ -2509,12 +2509,15 @@ pub fn type_is_enum(ty: t) -> bool {
25092509// constructors
25102510pub fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
25112511 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
25182521 }
25192522}
25202523
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