Move hygienic comparison into own function
This commit is contained in:
parent
2218520b8a
commit
9709ef149c
1 changed files with 12 additions and 12 deletions
|
|
@ -33,12 +33,9 @@ impl InherentOverlapChecker<'tcx> {
|
|||
}
|
||||
|
||||
for item1 in impl_items1.in_definition_order() {
|
||||
let collision = impl_items2.filter_by_name_unhygienic(item1.ident.name).any(|item2| {
|
||||
// Symbols and namespace match, compare hygienically.
|
||||
item1.kind.namespace() == item2.kind.namespace()
|
||||
&& item1.ident.normalize_to_macros_2_0()
|
||||
== item2.ident.normalize_to_macros_2_0()
|
||||
});
|
||||
let collision = impl_items2
|
||||
.filter_by_name_unhygienic(item1.ident.name)
|
||||
.any(|item2| self.compare_hygienically(item1, item2));
|
||||
|
||||
if collision {
|
||||
return true;
|
||||
|
|
@ -48,6 +45,12 @@ impl InherentOverlapChecker<'tcx> {
|
|||
false
|
||||
}
|
||||
|
||||
fn compare_hygienically(&self, item1: &'tcx ty::AssocItem, item2: &'tcx ty::AssocItem) -> bool {
|
||||
// Symbols and namespace match, compare hygienically.
|
||||
item1.kind.namespace() == item2.kind.namespace()
|
||||
&& item1.ident.normalize_to_macros_2_0() == item2.ident.normalize_to_macros_2_0()
|
||||
}
|
||||
|
||||
fn check_for_common_items_in_impls(
|
||||
&self,
|
||||
impl1: DefId,
|
||||
|
|
@ -58,12 +61,9 @@ impl InherentOverlapChecker<'tcx> {
|
|||
let impl_items2 = self.tcx.associated_items(impl2);
|
||||
|
||||
for item1 in impl_items1.in_definition_order() {
|
||||
let collision = impl_items2.filter_by_name_unhygienic(item1.ident.name).find(|item2| {
|
||||
// Symbols and namespace match, compare hygienically.
|
||||
item1.kind.namespace() == item2.kind.namespace()
|
||||
&& item1.ident.normalize_to_macros_2_0()
|
||||
== item2.ident.normalize_to_macros_2_0()
|
||||
});
|
||||
let collision = impl_items2
|
||||
.filter_by_name_unhygienic(item1.ident.name)
|
||||
.find(|item2| self.compare_hygienically(item1, item2));
|
||||
|
||||
if let Some(item2) = collision {
|
||||
let name = item1.ident.normalize_to_macros_2_0();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue