push_impls_of_trait is not needed, use map
This commit is contained in:
parent
199e0cd804
commit
e644ca0d6a
@ -38,16 +38,18 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
|||||||
// check_for_overlapping_impls_of_trait() check, since that
|
// check_for_overlapping_impls_of_trait() check, since that
|
||||||
// check can populate this table further with impls from other
|
// check can populate this table further with impls from other
|
||||||
// crates.
|
// crates.
|
||||||
let trait_def_ids: Vec<ast::DefId> =
|
let trait_def_ids: Vec<(ast::DefId, Vec<ast::DefId>)> =
|
||||||
self.tcx.trait_impls.borrow().keys().map(|&d| d).collect();
|
self.tcx.trait_impls.borrow().iter().map(|(&k, v)|
|
||||||
|
(k, v.borrow().clone())).collect();
|
||||||
|
|
||||||
for trait_def_id in trait_def_ids.iter() {
|
for &(trait_def_id, ref impls) in trait_def_ids.iter() {
|
||||||
self.check_for_overlapping_impls_of_trait(*trait_def_id);
|
self.check_for_overlapping_impls_of_trait(trait_def_id, impls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_for_overlapping_impls_of_trait(&self,
|
fn check_for_overlapping_impls_of_trait(&self,
|
||||||
trait_def_id: ast::DefId)
|
trait_def_id: ast::DefId,
|
||||||
|
trait_impls: &Vec<ast::DefId>)
|
||||||
{
|
{
|
||||||
debug!("check_for_overlapping_impls_of_trait(trait_def_id={})",
|
debug!("check_for_overlapping_impls_of_trait(trait_def_id={})",
|
||||||
trait_def_id.repr(self.tcx));
|
trait_def_id.repr(self.tcx));
|
||||||
@ -57,17 +59,14 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
|||||||
ty::populate_implementations_for_trait_if_necessary(self.tcx,
|
ty::populate_implementations_for_trait_if_necessary(self.tcx,
|
||||||
trait_def_id);
|
trait_def_id);
|
||||||
|
|
||||||
let mut impls = Vec::new();
|
for (i, &impl1_def_id) in trait_impls.iter().enumerate() {
|
||||||
self.push_impls_of_trait(trait_def_id, &mut impls);
|
|
||||||
|
|
||||||
for (i, &impl1_def_id) in impls.iter().enumerate() {
|
|
||||||
if impl1_def_id.krate != ast::LOCAL_CRATE {
|
if impl1_def_id.krate != ast::LOCAL_CRATE {
|
||||||
// we don't need to check impls if both are external;
|
// we don't need to check impls if both are external;
|
||||||
// that's the other crate's job.
|
// that's the other crate's job.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for &impl2_def_id in impls.slice_from(i+1).iter() {
|
for &impl2_def_id in trait_impls.slice_from(i+1).iter() {
|
||||||
self.check_if_impls_overlap(trait_def_id,
|
self.check_if_impls_overlap(trait_def_id,
|
||||||
impl1_def_id,
|
impl1_def_id,
|
||||||
impl2_def_id);
|
impl2_def_id);
|
||||||
@ -108,15 +107,6 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_impls_of_trait(&self,
|
|
||||||
trait_def_id: ast::DefId,
|
|
||||||
out: &mut Vec<ast::DefId>) {
|
|
||||||
match self.tcx.trait_impls.borrow().get(&trait_def_id) {
|
|
||||||
Some(impls) => { out.push_all(impls.borrow().as_slice()); }
|
|
||||||
None => { /* no impls */ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn span_of_impl(&self, impl_did: ast::DefId) -> Span {
|
fn span_of_impl(&self, impl_did: ast::DefId) -> Span {
|
||||||
assert_eq!(impl_did.krate, ast::LOCAL_CRATE);
|
assert_eq!(impl_did.krate, ast::LOCAL_CRATE);
|
||||||
self.tcx.map.span(impl_did.node)
|
self.tcx.map.span(impl_did.node)
|
||||||
|
Loading…
Reference in New Issue
Block a user