@@ -824,24 +824,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
824
824
stack,
825
825
& mut candidates) ) ;
826
826
}
827
- Some ( bound @ ty:: BoundSend ) |
828
- Some ( bound @ ty:: BoundSync ) => {
829
- // Ideally, we shouldn't sepcial case Send/Sync. This will be unified
830
- // as soon as default trait implementations for these traits land.
831
- try!( self . assemble_candidates_from_impls ( obligation, & mut candidates) ) ;
832
-
833
- // No explicit impls were declared for this type, consider the fallback rules.
834
- if candidates. vec . is_empty ( ) && !candidates. ambiguous {
835
- try!( self . assemble_builtin_bound_candidates ( bound, stack, & mut candidates) ) ;
836
- }
837
- }
838
-
839
827
Some ( bound @ ty:: BoundSized ) => {
840
828
// Sized and Copy are always automatically computed.
841
829
try!( self . assemble_builtin_bound_candidates ( bound, stack, & mut candidates) ) ;
842
830
}
843
831
844
- None => {
832
+ _ => {
845
833
// For the time being, we ignore user-defined impls for builtin-bounds, other than
846
834
// `Copy`.
847
835
// (And unboxed candidates only apply to the Fn/FnMut/etc traits.)
@@ -1149,8 +1137,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1149
1137
} ) ;
1150
1138
}
1151
1139
1152
- if ty:: trait_has_default_impl ( self . tcx ( ) , def_id) {
1153
- candidates. vec . push ( DefaultImplCandidate ( def_id. clone ( ) ) )
1140
+ match self_ty. sty {
1141
+ ty:: ty_infer( ty:: TyVar ( _) ) |
1142
+ ty:: ty_trait( ..) => { } ,
1143
+ _ => {
1144
+ if ty:: trait_has_default_impl ( self . tcx ( ) , def_id) {
1145
+ candidates. vec . push ( DefaultImplCandidate ( def_id. clone ( ) ) )
1146
+ }
1147
+ }
1154
1148
}
1155
1149
1156
1150
Ok ( ( ) )
@@ -1179,6 +1173,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1179
1173
1180
1174
let poly_trait_ref = match self_ty. sty {
1181
1175
ty:: ty_trait( ref data) => {
1176
+ match self . tcx ( ) . lang_items . to_builtin_kind ( obligation. predicate . def_id ( ) ) {
1177
+ Some ( bound @ ty:: BoundSend ) | Some ( bound @ ty:: BoundSync ) => {
1178
+ if data. bounds . builtin_bounds . contains ( & bound) {
1179
+ debug ! ( "assemble_candidates_from_object_ty: matched builtin bound, \
1180
+ pushing candidate") ;
1181
+ candidates. vec . push ( BuiltinCandidate ( bound) ) ;
1182
+ return ;
1183
+ }
1184
+ }
1185
+ _ => { }
1186
+ }
1187
+
1182
1188
data. principal_trait_ref_with_self_ty ( self . tcx ( ) , self_ty)
1183
1189
}
1184
1190
ty:: ty_infer( ty:: TyVar ( _) ) => {
@@ -1622,13 +1628,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1622
1628
ty:: ty_bare_fn( ..) |
1623
1629
ty:: ty_str |
1624
1630
ty:: ty_err |
1631
+ ty:: ty_param( ..) |
1625
1632
ty:: ty_char => {
1626
1633
Vec :: new ( )
1627
1634
}
1628
1635
1629
1636
ty:: ty_trait( ..) |
1630
1637
ty:: ty_projection( ..) |
1631
- ty:: ty_param( ..) |
1632
1638
ty:: ty_infer( ..) => {
1633
1639
self . tcx ( ) . sess . bug (
1634
1640
& format ! (
0 commit comments