@@ -843,6 +843,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
843843 let bounds = compute_bounds ( ccx,
844844 self_param_ty. to_ty ( ccx. tcx ) ,
845845 bounds. as_slice ( ) ,
846+ SizedByDefault :: No ,
846847 it. span ) ;
847848
848849 let associated_type_names: Vec < _ > =
@@ -1098,6 +1099,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
10981099 let bounds = compute_bounds ( ccx,
10991100 assoc_ty,
11001101 assoc_type_def. bounds . as_slice ( ) ,
1102+ SizedByDefault :: Yes ,
11011103 assoc_type_def. span ) ;
11021104
11031105 ty:: predicates ( ccx. tcx , assoc_ty, & bounds) . into_iter ( )
@@ -1306,6 +1308,7 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
13061308 let bounds = compute_bounds ( this,
13071309 param_ty. to_ty ( this. tcx ( ) ) ,
13081310 param. bounds [ ] ,
1311+ SizedByDefault :: Yes ,
13091312 param. span ) ;
13101313 let default = match param. default {
13111314 None => None ,
@@ -1342,29 +1345,35 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
13421345 def
13431346}
13441347
1348+ enum SizedByDefault { Yes , No }
1349+
13451350/// Translate the AST's notion of ty param bounds (which are an enum consisting of a newtyped Ty or
13461351/// a region) to ty's notion of ty param bounds, which can either be user-defined traits, or the
13471352/// built-in trait (formerly known as kind): Send.
13481353fn compute_bounds < ' tcx , AC > ( this : & AC ,
13491354 param_ty : ty:: Ty < ' tcx > ,
13501355 ast_bounds : & [ ast:: TyParamBound ] ,
1356+ sized_by_default : SizedByDefault ,
13511357 span : Span )
13521358 -> ty:: ParamBounds < ' tcx >
1353- where AC : AstConv < ' tcx > {
1359+ where AC : AstConv < ' tcx >
1360+ {
13541361 let mut param_bounds = conv_param_bounds ( this,
13551362 span,
13561363 param_ty,
13571364 ast_bounds) ;
13581365
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) ;
13631371
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+ }
13681377
13691378 param_bounds. trait_bounds . sort_by ( |a, b| a. def_id ( ) . cmp ( & b. def_id ( ) ) ) ;
13701379
0 commit comments