Skip to content

Commit 7da07d3

Browse files
author
Ariel Ben-Yehuda
committed
---
yaml --- r: 210163 b: refs/heads/try c: 7ae4a8e h: refs/heads/master i: 210161: f739cbc 210159: 69fd5c8 v: v3
1 parent dcd70bb commit 7da07d3

File tree

11 files changed

+285
-192
lines changed

11 files changed

+285
-192
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: bd1f73420ab22faa8087a6cf1618225d09d64f9e
5+
refs/heads/try: 7ae4a8e9f3150f62964151ef54b3da3cd24ee123
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc/metadata/decoder.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ use middle::subst;
3030
use middle::ty::{ImplContainer, TraitContainer};
3131
use middle::ty::{self, Ty};
3232
use middle::astencode::vtable_decoder_helpers;
33+
use util::nodemap::FnvHashMap;
3334

35+
use std::cell::{Cell, RefCell};
3436
use std::collections::HashMap;
3537
use std::hash::{self, Hash, SipHasher};
3638
use std::io::prelude::*;
@@ -420,6 +422,9 @@ pub fn get_trait_def<'tcx>(cdata: Cmd,
420422
generics: generics,
421423
trait_ref: item_trait_ref(item_doc, tcx, cdata),
422424
associated_type_names: associated_type_names,
425+
nonblanket_impls: RefCell::new(FnvHashMap()),
426+
blanket_impls: RefCell::new(vec![]),
427+
flags: Cell::new(ty::TraitFlags::NO_TRAIT_FLAGS)
423428
}
424429
}
425430

branches/try/src/librustc/metadata/encoder.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -974,16 +974,14 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
974974
fn encode_extension_implementations(ecx: &EncodeContext,
975975
rbml_w: &mut Encoder,
976976
trait_def_id: DefId) {
977-
match ecx.tcx.trait_impls.borrow().get(&trait_def_id) {
978-
None => {}
979-
Some(implementations) => {
980-
for &impl_def_id in &*implementations.borrow() {
981-
rbml_w.start_tag(tag_items_data_item_extension_impl);
982-
encode_def_id(rbml_w, impl_def_id);
983-
rbml_w.end_tag();
984-
}
985-
}
986-
}
977+
assert!(ast_util::is_local(trait_def_id));
978+
let def = ty::lookup_trait_def(ecx.tcx, trait_def_id);
979+
980+
def.for_each_impl(ecx.tcx, |impl_def_id| {
981+
rbml_w.start_tag(tag_items_data_item_extension_impl);
982+
encode_def_id(rbml_w, impl_def_id);
983+
rbml_w.end_tag();
984+
});
987985
}
988986

989987
fn encode_stability(rbml_w: &mut Encoder, stab_opt: Option<attr::Stability>) {

branches/try/src/librustc/middle/traits/object_safety.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,18 @@ pub fn is_object_safe<'tcx>(tcx: &ty::ctxt<'tcx>,
5757
-> bool
5858
{
5959
// Because we query yes/no results frequently, we keep a cache:
60-
let cached_result =
61-
tcx.object_safety_cache.borrow().get(&trait_def_id).cloned();
60+
let def = ty::lookup_trait_def(tcx, trait_def_id);
6261

63-
let result =
64-
cached_result.unwrap_or_else(|| {
65-
let result = object_safety_violations(tcx, trait_def_id).is_empty();
62+
let result = def.object_safety().unwrap_or_else(|| {
63+
let result = object_safety_violations(tcx, trait_def_id).is_empty();
6664

67-
// Record just a yes/no result in the cache; this is what is
68-
// queried most frequently. Note that this may overwrite a
69-
// previous result, but always with the same thing.
70-
tcx.object_safety_cache.borrow_mut().insert(trait_def_id, result);
65+
// Record just a yes/no result in the cache; this is what is
66+
// queried most frequently. Note that this may overwrite a
67+
// previous result, but always with the same thing.
68+
def.set_object_safety(result);
7169

72-
result
73-
});
70+
result
71+
});
7472

7573
debug!("is_object_safe({}) = {}", trait_def_id.repr(tcx), result);
7674

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

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,18 +1153,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11531153
{
11541154
debug!("assemble_candidates_from_impls(obligation={})", obligation.repr(self.tcx()));
11551155

1156-
let def_id = obligation.predicate.def_id();
1157-
let all_impls = self.all_impls(def_id);
1158-
for &impl_def_id in &all_impls {
1159-
self.infcx.probe(|snapshot| {
1160-
match self.match_impl(impl_def_id, obligation, snapshot) {
1161-
Ok(_) => {
1156+
let def = ty::lookup_trait_def(self.tcx(), obligation.predicate.def_id());
1157+
1158+
def.for_each_relevant_impl(
1159+
self.tcx(),
1160+
obligation.predicate.0.trait_ref,
1161+
|impl_def_id| {
1162+
self.infcx.probe(|snapshot| {
1163+
if let Ok(_) = self.match_impl(impl_def_id, obligation, snapshot) {
11621164
candidates.vec.push(ImplCandidate(impl_def_id));
11631165
}
1164-
Err(()) => { }
1165-
}
1166-
});
1167-
}
1166+
});
1167+
}
1168+
);
11681169

11691170
Ok(())
11701171
}
@@ -2529,16 +2530,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
25292530
}
25302531
}
25312532

2532-
/// Returns set of all impls for a given trait.
2533-
fn all_impls(&self, trait_def_id: ast::DefId) -> Vec<ast::DefId> {
2534-
ty::populate_implementations_for_trait_if_necessary(self.tcx(), trait_def_id);
2535-
2536-
match self.tcx().trait_impls.borrow().get(&trait_def_id) {
2537-
None => Vec::new(),
2538-
Some(impls) => impls.borrow().clone(),
2539-
}
2540-
}
2541-
25422533
fn closure_trait_ref(&self,
25432534
obligation: &TraitObligation<'tcx>,
25442535
closure_def_id: ast::DefId,

0 commit comments

Comments
 (0)