File tree 2 files changed +19
-6
lines changed
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -1072,12 +1072,17 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
1072
1072
// Enums lower to the lowest of their variants.
1073
1073
ty_enum ( did, tps) {
1074
1074
let mut lowest = kind_sendable;
1075
- for variant in * enum_variants ( cx, did) {
1076
- for aty in variant. args {
1077
- // Perform any type parameter substitutions.
1078
- let arg_ty = substitute_type_params ( cx, tps, aty) ;
1079
- lowest = lower_kind ( lowest, type_kind ( cx, arg_ty) ) ;
1080
- if lowest == kind_noncopyable { break ; }
1075
+ let variants = enum_variants ( cx, did) ;
1076
+ if vec:: len ( * variants) == 0 u {
1077
+ lowest = kind_noncopyable;
1078
+ } else {
1079
+ for variant in * variants {
1080
+ for aty in variant. args {
1081
+ // Perform any type parameter substitutions.
1082
+ let arg_ty = substitute_type_params ( cx, tps, aty) ;
1083
+ lowest = lower_kind ( lowest, type_kind ( cx, arg_ty) ) ;
1084
+ if lowest == kind_noncopyable { break ; }
1085
+ }
1081
1086
}
1082
1087
}
1083
1088
lowest
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ let x : * [ int ] = ptr:: addr_of ( [ 1 , 2 , 3 ] ) ;
3
+ let y : * libc:: c_void = x as * libc:: c_void ;
4
+ unsafe {
5
+ let _z = * y;
6
+ //!^ ERROR copying a noncopyable value
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments