@@ -572,8 +572,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
572
572
let b = & trait_bounds[ 0 ] ;
573
573
let span = b. trait_ref . path . span ;
574
574
struct_span_err ! ( self . tcx( ) . sess, span, E0225 ,
575
- "only Send/Sync traits can be used as additional traits in a trait object" )
576
- . span_label ( span, "non-Send/Sync additional trait" )
575
+ "only auto traits can be used as additional traits in a trait object" )
576
+ . span_label ( span, "non-auto additional trait" )
577
577
. emit ( ) ;
578
578
}
579
579
@@ -1311,27 +1311,10 @@ fn split_auto_traits<'a, 'b, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
1311
1311
-> ( Vec < DefId > , Vec < & ' b hir:: PolyTraitRef > )
1312
1312
{
1313
1313
let ( auto_traits, trait_bounds) : ( Vec < _ > , _ ) = trait_bounds. iter ( ) . partition ( |bound| {
1314
+ // Checks whether `trait_did` is an auto trait and adds it to `auto_traits` if so.
1314
1315
match bound. trait_ref . path . def {
1315
- Def :: Trait ( trait_did) => {
1316
- // Checks whether `trait_did` refers to one of the builtin
1317
- // traits, like `Send`, and adds it to `auto_traits` if so.
1318
- if Some ( trait_did) == tcx. lang_items ( ) . send_trait ( ) ||
1319
- Some ( trait_did) == tcx. lang_items ( ) . sync_trait ( ) {
1320
- let segments = & bound. trait_ref . path . segments ;
1321
- segments[ segments. len ( ) - 1 ] . with_parameters ( |parameters| {
1322
- if !parameters. types . is_empty ( ) {
1323
- check_type_argument_count ( tcx, bound. trait_ref . path . span ,
1324
- parameters. types . len ( ) , & [ ] ) ;
1325
- }
1326
- if !parameters. lifetimes . is_empty ( ) {
1327
- report_lifetime_number_error ( tcx, bound. trait_ref . path . span ,
1328
- parameters. lifetimes . len ( ) , 0 ) ;
1329
- }
1330
- } ) ;
1331
- true
1332
- } else {
1333
- false
1334
- }
1316
+ Def :: Trait ( trait_did) if tcx. trait_is_auto ( trait_did) => {
1317
+ true
1335
1318
}
1336
1319
_ => false
1337
1320
}
0 commit comments