Skip to content

Commit 7e52358

Browse files
committed
---
yaml --- r: 185751 b: refs/heads/auto c: d215411 h: refs/heads/master i: 185749: b87c6d5 185747: 639c8b6 185743: 22cc06c v: v3
1 parent a670eb2 commit 7e52358

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 1e3ed61d8273377544e40bdbbdf8391b51571293
13+
refs/heads/auto: d215411911c2f6e5a68a12686c930352f68d2031
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/traits/select.rs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -824,24 +824,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
824824
stack,
825825
&mut candidates));
826826
}
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-
839827
Some(bound @ ty::BoundSized) => {
840828
// Sized and Copy are always automatically computed.
841829
try!(self.assemble_builtin_bound_candidates(bound, stack, &mut candidates));
842830
}
843831

844-
None => {
832+
_ => {
845833
// For the time being, we ignore user-defined impls for builtin-bounds, other than
846834
// `Copy`.
847835
// (And unboxed candidates only apply to the Fn/FnMut/etc traits.)
@@ -1149,8 +1137,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11491137
});
11501138
}
11511139

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+
}
11541148
}
11551149

11561150
Ok(())
@@ -1179,6 +1173,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11791173

11801174
let poly_trait_ref = match self_ty.sty {
11811175
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+
11821188
data.principal_trait_ref_with_self_ty(self.tcx(), self_ty)
11831189
}
11841190
ty::ty_infer(ty::TyVar(_)) => {
@@ -1622,13 +1628,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16221628
ty::ty_bare_fn(..) |
16231629
ty::ty_str |
16241630
ty::ty_err |
1631+
ty::ty_param(..) |
16251632
ty::ty_char => {
16261633
Vec::new()
16271634
}
16281635

16291636
ty::ty_trait(..) |
16301637
ty::ty_projection(..) |
1631-
ty::ty_param(..) |
16321638
ty::ty_infer(..) => {
16331639
self.tcx().sess.bug(
16341640
&format!(

branches/auto/src/librustc/middle/ty.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6007,7 +6007,10 @@ pub fn trait_default_impl(tcx: &ctxt, trait_def_id: DefId) -> Option<ast::DefId>
60076007
}
60086008

60096009
pub fn trait_has_default_impl(tcx: &ctxt, trait_def_id: DefId) -> bool {
6010-
tcx.default_trait_impls.borrow().contains_key(&trait_def_id)
6010+
match tcx.lang_items.to_builtin_kind(trait_def_id) {
6011+
Some(BoundSend) | Some(BoundSync) => true,
6012+
_ => tcx.default_trait_impls.borrow().contains_key(&trait_def_id)
6013+
}
60116014
}
60126015

60136016
/// Records a trait-to-implementation mapping.

branches/auto/src/librustc_resolve/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
29892989
// check for imports shadowing primitive types
29902990
if let ast::ViewPathSimple(ident, _) = view_path.node {
29912991
match self.def_map.borrow().get(&item.id) {
2992-
Some(&DefTy(..)) | Some(&DefStruct(..)) | Some(&DefTrait(..)) | None => {
2992+
Some(&DefTy(..)) | Some(&DefStruct(..)) | Some(&DefaultImpl(..)) | None => {
29932993
self.check_if_primitive_type_name(ident.name, item.span);
29942994
}
29952995
_ => {}

0 commit comments

Comments
 (0)