1
1
use crate :: namespace:: Namespace ;
2
2
use rustc:: traits:: { self , IntercrateMode } ;
3
- use rustc:: ty:: TyCtxt ;
3
+ use rustc:: ty:: { AssocItem , TyCtxt } ;
4
4
use rustc_errors:: struct_span_err;
5
5
use rustc_hir as hir;
6
6
use rustc_hir:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
@@ -23,32 +23,30 @@ impl InherentOverlapChecker<'tcx> {
23
23
impl2 : DefId ,
24
24
overlap : traits:: OverlapResult < ' _ > ,
25
25
) {
26
- let name_and_namespace = |def_id| {
27
- let item = self . tcx . associated_item ( def_id) ;
28
- ( item. ident . modern ( ) , Namespace :: from ( item. kind ) )
29
- } ;
26
+ let name_and_namespace =
27
+ |assoc : & AssocItem | ( assoc. ident . modern ( ) , Namespace :: from ( assoc. kind ) ) ;
30
28
31
- let impl_items1 = self . tcx . associated_item_def_ids ( impl1) ;
32
- let impl_items2 = self . tcx . associated_item_def_ids ( impl2) ;
29
+ let impl_items1 = self . tcx . associated_items ( impl1) ;
30
+ let impl_items2 = self . tcx . associated_items ( impl2) ;
33
31
34
- for & item1 in & impl_items1[ ..] {
32
+ for item1 in & impl_items1[ ..] {
35
33
let ( name, namespace) = name_and_namespace ( item1) ;
36
34
37
- for & item2 in & impl_items2[ ..] {
35
+ for item2 in & impl_items2[ ..] {
38
36
if ( name, namespace) == name_and_namespace ( item2) {
39
37
let mut err = struct_span_err ! (
40
38
self . tcx. sess,
41
- self . tcx. span_of_impl( item1) . unwrap( ) ,
39
+ self . tcx. span_of_impl( item1. def_id ) . unwrap( ) ,
42
40
E0592 ,
43
41
"duplicate definitions with name `{}`" ,
44
42
name
45
43
) ;
46
44
err. span_label (
47
- self . tcx . span_of_impl ( item1) . unwrap ( ) ,
45
+ self . tcx . span_of_impl ( item1. def_id ) . unwrap ( ) ,
48
46
format ! ( "duplicate definitions for `{}`" , name) ,
49
47
) ;
50
48
err. span_label (
51
- self . tcx . span_of_impl ( item2) . unwrap ( ) ,
49
+ self . tcx . span_of_impl ( item2. def_id ) . unwrap ( ) ,
52
50
format ! ( "other definition for `{}`" , name) ,
53
51
) ;
54
52
0 commit comments