@@ -843,6 +843,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
843
843
let bounds = compute_bounds ( ccx,
844
844
self_param_ty. to_ty ( ccx. tcx ) ,
845
845
bounds. as_slice ( ) ,
846
+ SizedByDefault :: No ,
846
847
it. span ) ;
847
848
848
849
let associated_type_names: Vec < _ > =
@@ -1098,6 +1099,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1098
1099
let bounds = compute_bounds ( ccx,
1099
1100
assoc_ty,
1100
1101
assoc_type_def. bounds . as_slice ( ) ,
1102
+ SizedByDefault :: Yes ,
1101
1103
assoc_type_def. span ) ;
1102
1104
1103
1105
ty:: predicates ( ccx. tcx , assoc_ty, & bounds) . into_iter ( )
@@ -1306,6 +1308,7 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
1306
1308
let bounds = compute_bounds ( this,
1307
1309
param_ty. to_ty ( this. tcx ( ) ) ,
1308
1310
param. bounds [ ] ,
1311
+ SizedByDefault :: Yes ,
1309
1312
param. span ) ;
1310
1313
let default = match param. default {
1311
1314
None => None ,
@@ -1342,29 +1345,35 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
1342
1345
def
1343
1346
}
1344
1347
1348
+ enum SizedByDefault { Yes , No }
1349
+
1345
1350
/// Translate the AST's notion of ty param bounds (which are an enum consisting of a newtyped Ty or
1346
1351
/// a region) to ty's notion of ty param bounds, which can either be user-defined traits, or the
1347
1352
/// built-in trait (formerly known as kind): Send.
1348
1353
fn compute_bounds < ' tcx , AC > ( this : & AC ,
1349
1354
param_ty : ty:: Ty < ' tcx > ,
1350
1355
ast_bounds : & [ ast:: TyParamBound ] ,
1356
+ sized_by_default : SizedByDefault ,
1351
1357
span : Span )
1352
1358
-> ty:: ParamBounds < ' tcx >
1353
- where AC : AstConv < ' tcx > {
1359
+ where AC : AstConv < ' tcx >
1360
+ {
1354
1361
let mut param_bounds = conv_param_bounds ( this,
1355
1362
span,
1356
1363
param_ty,
1357
1364
ast_bounds) ;
1358
1365
1359
- add_unsized_bound ( this,
1360
- & mut param_bounds. builtin_bounds ,
1361
- ast_bounds,
1362
- span) ;
1366
+ if let SizedByDefault :: Yes = sized_by_default {
1367
+ add_unsized_bound ( this,
1368
+ & mut param_bounds. builtin_bounds ,
1369
+ ast_bounds,
1370
+ span) ;
1363
1371
1364
- check_bounds_compatible ( this. tcx ( ) ,
1365
- param_ty,
1366
- & param_bounds,
1367
- span) ;
1372
+ check_bounds_compatible ( this. tcx ( ) ,
1373
+ param_ty,
1374
+ & param_bounds,
1375
+ span) ;
1376
+ }
1368
1377
1369
1378
param_bounds. trait_bounds . sort_by ( |a, b| a. def_id ( ) . cmp ( & b. def_id ( ) ) ) ;
1370
1379
0 commit comments