Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
74648b5
First attempt at fixing #20591
tbelaire Apr 25, 2015
168615f
Now passing in the ImportResolver to check_conflict...
tbelaire Apr 25, 2015
69a5c37
Maybe it works
tbelaire Apr 25, 2015
5c05278
Fixed types, and slimmed down code
tbelaire Apr 25, 2015
372c69d
Fixed test text
tbelaire Apr 27, 2015
db9d018
Fixed some nits
tbelaire May 1, 2015
efb3872
Fix use of UFCS syntax to call methods on associated types.
quantheory May 7, 2015
51a1e83
doc: Remove mention of 30 minute intro
brson May 8, 2015
7d9e605
Add error explanation for E0317.
meqif May 10, 2015
c0412bc
Fix documentation URL in diagnostic message.
meqif May 10, 2015
f3a3684
Add error explanation for E0154.
meqif May 10, 2015
e7fa00a
Add error explanation for E0259.
meqif May 10, 2015
60ec4ab
Add error explanation for E0260.
meqif May 10, 2015
bff1707
Fixed one textual mistake and one casing error.
michal-czardybon May 8, 2015
ef03055
Improve wording in error explanation.
meqif May 11, 2015
aa529ef
Add missing keyword in `extern crate` declarations.
meqif May 11, 2015
52efe55
Handle overflow properly in core::slice
lilyball May 11, 2015
e1e34e9
Reintroduce non-null assumptions in core::slice iterators
lilyball May 11, 2015
f2614f5
Avoid returning a slice with a null pointer from Iter.as_slice()
lilyball May 11, 2015
d13f765
Make mention of `if` more generic
frewsxcv May 12, 2015
8bcb3cb
rustc::metadata: use u64 for DefId's instead of strings.
eddyb May 12, 2015
aeb92ba
rustc: rename ty::populate_implementations_for_type_if_necessary to m…
eddyb May 12, 2015
592165f
Fix ty::populate_implementations_for_trait_if_necessary to load the t…
eddyb May 12, 2015
75cd8f9
rustc_typeck: remove the "preload all impls ever" workaround in coher…
eddyb May 12, 2015
93c21c7
Correct claims about &T's Copyness.
Ms2ger May 12, 2015
feac9f1
Auto merge of #24818 - tbelaire:double-import, r=nrc
bors May 12, 2015
a5cac55
Add wait and waitpid to libc.
mfs May 12, 2015
1d1570a
Add regression test for #18075
May 11, 2015
23300a3
Add regression test for #20413
May 12, 2015
67dfc17
Auto merge of #25323 - eddyb:coherent-coherence, r=pnkfelix
bors May 12, 2015
6faa8d6
Add a link to the error index to the main doc page.
michaelsproul May 12, 2015
0ad2026
Auto merge of #25171 - quantheory:associated_time_long_paths, r=nikom…
bors May 12, 2015
2a5a320
Auto merge of #25300 - kballard:core-slice-overflow, r=Gankro
bors May 12, 2015
e780fb2
TRPL: Borrow and AsRef
steveklabnik Apr 30, 2015
12dc6ee
Rollup merge of #24996 - steveklabnik:gh24163, r=aturon
Manishearth May 12, 2015
bea12a9
Rollup merge of #25220 - brson:doc1, r=steveklabnik
Manishearth May 12, 2015
e91d272
Rollup merge of #25221 - michal-czardybon:master, r=steveklabnik
Manishearth May 12, 2015
bb15c47
Rollup merge of #25267 - meqif:explain_e0317, r=alexcrichton
Manishearth May 12, 2015
e216057
Rollup merge of #25322 - frewsxcv:patch-23, r=steveklabnik
Manishearth May 12, 2015
78cf0f8
Rollup merge of #25327 - Ms2ger:copy-ref, r=pnkfelix
Manishearth May 12, 2015
866991e
Rollup merge of #25329 - jooert:tests, r=alexcrichton
Manishearth May 12, 2015
210f4b9
Rollup merge of #25330 - mfs:add-wait-waitpid, r=alexcrichton
Manishearth May 12, 2015
3981481
Rollup merge of #25331 - michaelsproul:err-idx-doc-link, r=Manishearth
Manishearth May 12, 2015
2581565
Rollup merge of #25335 - nikomatsakis:updates-to-reference-manual, r=…
Manishearth May 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix ty::populate_implementations_for_trait_if_necessary to load the t…
…rait's impls from all the crates.
  • Loading branch information
eddyb committed May 12, 2015
commit 592165fb17fb78e7aa1cfd054ddfdfe9401e92d7
1 change: 1 addition & 0 deletions src/librustc/metadata/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ pub const tag_item_impl_vtables: usize = 0x7e;

pub const tag_impls: usize = 0x109; // top-level only
pub const tag_impls_impl: usize = 0x7f;
pub const tag_impls_impl_trait_def_id: usize = 0x8d;

pub const tag_items_data_item_inherent_impl: usize = 0x80;
pub const tag_items_data_item_extension_impl: usize = 0x81;
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,12 @@ pub fn each_inherent_implementation_for_type<F>(cstore: &cstore::CStore,

pub fn each_implementation_for_trait<F>(cstore: &cstore::CStore,
def_id: ast::DefId,
callback: F) where
mut callback: F) where
F: FnMut(ast::DefId),
{
let cdata = cstore.get_crate_data(def_id.krate);
decoder::each_implementation_for_trait(&*cdata, def_id.node, callback)
cstore.iter_crate_data(|_, cdata| {
decoder::each_implementation_for_trait(cdata, def_id, &mut callback)
})
}

/// If the given def ID describes an item belonging to a trait (either a
Expand Down
50 changes: 41 additions & 9 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,22 @@ pub fn translate_def_id(cdata: Cmd, did: ast::DefId) -> ast::DefId {
}
}

// Translate a DefId from the current compilation environment to a DefId
// for an external crate.
fn reverse_translate_def_id(cdata: Cmd, did: ast::DefId) -> Option<ast::DefId> {
if did.krate == cdata.cnum {
return Some(ast::DefId { krate: ast::LOCAL_CRATE, node: did.node });
}

for (&local, &global) in &cdata.cnum_map {
if global == did.krate {
return Some(ast::DefId { krate: local, node: did.node });
}
}

None
}

pub fn each_impl<F>(cdata: Cmd, mut callback: F) where
F: FnMut(ast::DefId),
{
Expand Down Expand Up @@ -1355,19 +1371,35 @@ pub fn each_inherent_implementation_for_type<F>(cdata: Cmd,
}

pub fn each_implementation_for_trait<F>(cdata: Cmd,
id: ast::NodeId,
def_id: ast::DefId,
mut callback: F) where
F: FnMut(ast::DefId),
{
let item_doc = lookup_item(id, cdata.data());
if cdata.cnum == def_id.krate {
let item_doc = lookup_item(def_id.node, cdata.data());
let _ = reader::tagged_docs(item_doc,
tag_items_data_item_extension_impl,
|impl_doc| {
callback(item_def_id(impl_doc, cdata));
true
});
return;
}

let _ = reader::tagged_docs(item_doc,
tag_items_data_item_extension_impl,
|impl_doc| {
let implementation_def_id = item_def_id(impl_doc, cdata);
callback(implementation_def_id);
true
});
// Do a reverse lookup beforehand to avoid touching the crate_num
// hash map in the loop below.
if let Some(crate_local_did) = reverse_translate_def_id(cdata, def_id) {
let def_id_u64 = def_to_u64(crate_local_did);

let impls_doc = reader::get_doc(rbml::Doc::new(cdata.data()), tag_impls);
let _ = reader::tagged_docs(impls_doc, tag_impls_impl, |impl_doc| {
let impl_trait = reader::get_doc(impl_doc, tag_impls_impl_trait_def_id);
if reader::doc_as_u64(impl_trait) == def_id_u64 {
callback(item_def_id(impl_doc, cdata));
}
true
});
}
}

pub fn get_trait_of_item(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
Expand Down
1 change: 1 addition & 0 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,7 @@ impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for ImplVisitor<'a, 'b, 'c, 'tcx> {
def_id.krate != ast::LOCAL_CRATE {
self.rbml_w.start_tag(tag_impls_impl);
encode_def_id(self.rbml_w, local_def(item.id));
self.rbml_w.wr_tagged_u64(tag_impls_impl_trait_def_id, def_to_u64(def_id));
self.rbml_w.end_tag();
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2564,9 +2564,11 @@ impl<'tcx> TraitDef<'tcx> {
tcx: &ctxt<'tcx>,
impl_def_id: DefId,
impl_trait_ref: TraitRef<'tcx>) {
debug!("TraitDef::record_impl for {}, from {}",
self.repr(tcx), impl_trait_ref.repr(tcx));

// We don't want to borrow_mut after we already populated all impls,
// so check if an impl is present with an immutable borrow first.

if let Some(sty) = fast_reject::simplify_type(tcx,
impl_trait_ref.self_ty(), false) {
if let Some(is) = self.nonblanket_impls.borrow().get(&sty) {
Expand Down Expand Up @@ -6366,18 +6368,18 @@ pub fn populate_inherent_implementations_for_type_if_necessary(tcx: &ctxt,

/// Populates the type context with all the implementations for the given
/// trait if necessary.
pub fn populate_implementations_for_trait_if_necessary(
tcx: &ctxt,
trait_id: ast::DefId) {
pub fn populate_implementations_for_trait_if_necessary(tcx: &ctxt, trait_id: ast::DefId) {
if trait_id.krate == LOCAL_CRATE {
return
}

let def = lookup_trait_def(tcx, trait_id);
if def.flags.get().intersects(TraitFlags::IMPLS_VALID) {
return
return;
}

debug!("populate_implementations_for_trait_if_necessary: searching for {}", def.repr(tcx));

if csearch::is_defaulted_trait(&tcx.sess.cstore, trait_id) {
record_trait_has_default_impl(tcx, trait_id);
}
Expand Down