@@ -15,7 +15,8 @@ import util::ppaux::region_to_str;
15
15
import util:: ppaux:: vstore_to_str;
16
16
import util:: ppaux:: { ty_to_str, tys_to_str, ty_constr_to_str} ;
17
17
import syntax:: print:: pprust:: * ;
18
-
18
+ import middle:: lint:: { get_warning_level, vecs_not_implicitly_copyable,
19
+ ignore} ;
19
20
export ty_vid, region_vid, vid;
20
21
export br_hashmap;
21
22
export is_instantiable;
@@ -218,6 +219,7 @@ type ctxt =
218
219
@{ diag : syntax:: diagnostic:: span_handler ,
219
220
interner : hashmap < intern_key , t_box > ,
220
221
mut next_id : uint ,
222
+ vecs_implicitly_copyable : bool ,
221
223
cstore : metadata:: cstore:: cstore ,
222
224
sess : session:: session ,
223
225
def_map : resolve:: def_map ,
@@ -497,9 +499,13 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
497
499
hash_type_structure ( k. struct ) +
498
500
option:: map_default ( k. o_def_id , 0 u, ast_util:: hash_def)
499
501
} , { |& & a, & & b| a == b} ) ;
502
+ let vecs_implicitly_copyable =
503
+ get_warning_level ( s. warning_settings . default_settings ,
504
+ vecs_not_implicitly_copyable) == ignore;
500
505
@{ diag: s. diagnostic ( ) ,
501
506
interner: interner,
502
507
mut next_id: 0 u,
508
+ vecs_implicitly_copyable: vecs_implicitly_copyable,
503
509
cstore: s. cstore ,
504
510
sess: s,
505
511
def_map: dm,
@@ -1459,8 +1465,12 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
1459
1465
// Scalar and unique types are sendable
1460
1466
ty_nil | ty_bot | ty_bool | ty_int( _) | ty_uint( _) | ty_float( _) |
1461
1467
ty_ptr( _) { kind_implicitly_sendable( ) | kind_const( ) }
1462
- // FIXME: this *shouldn't* be implicitly copyable (#2450)
1463
- ty_str { kind_implicitly_sendable( ) | kind_const( ) }
1468
+ // Implicit copyability of strs is configurable
1469
+ ty_str {
1470
+ if cx. vecs_implicitly_copyable {
1471
+ kind_implicitly_sendable( ) | kind_const( )
1472
+ } else { kind_sendable( ) | kind_const( ) }
1473
+ }
1464
1474
ty_fn( f) { proto_kind( f. proto) }
1465
1475
1466
1476
// Those with refcounts raise noncopyable to copyable,
@@ -1485,8 +1495,13 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
1485
1495
ty_uniq( tm) {
1486
1496
remove_implicit( remove_const( type_kind( cx, tm. ty) , tm) )
1487
1497
}
1488
- // FIXME: Vectors *shouldn't* be implicitly copyable but are (#2450)
1489
- ty_vec( tm) { remove_const( mutable_type_kind( cx, tm) , tm) }
1498
+ // Implicit copyability of vecs is configurable
1499
+ ty_vec( tm) {
1500
+ let k = if cx. vecs_implicitly_copyable {
1501
+ mutable_type_kind( cx, tm)
1502
+ } else { remove_implicit( type_kind( cx, tm. ty) ) } ;
1503
+ remove_const( k, tm)
1504
+ }
1490
1505
1491
1506
// Slice and refcounted evecs are copyable; uniques and interiors
1492
1507
// depend on the their contained type, but aren't implicitly copyable.
0 commit comments