@@ -15,9 +15,9 @@ use rustc_hir::OwnerId;
15
15
use rustc_middle:: ty:: query:: Providers ;
16
16
use rustc_middle:: ty:: TyCtxt ;
17
17
use rustc_span:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
18
- use rustc_span:: symbol:: { kw :: Empty , sym, Symbol } ;
18
+ use rustc_span:: symbol:: { sym, Symbol } ;
19
19
20
- use crate :: errors:: { DuplicateDiagnosticItem , DuplicateDiagnosticItemInCrate } ;
20
+ use crate :: errors:: DuplicateDiagnosticItemInCrate ;
21
21
22
22
fn observe_item < ' tcx > ( tcx : TyCtxt < ' tcx > , diagnostic_items : & mut DiagnosticItems , owner : OwnerId ) {
23
23
let attrs = tcx. hir ( ) . attrs ( owner. into ( ) ) ;
@@ -42,20 +42,16 @@ fn report_duplicate_item(
42
42
original_def_id : DefId ,
43
43
item_def_id : DefId ,
44
44
) {
45
- let ( orig_span, orig_crate_name, have_orig_crate_name) = match original_def_id. as_local ( ) {
46
- Some ( local_original) => ( Some ( tcx. def_span ( local_original) ) , Empty , None ) ,
47
- None => ( None , tcx. crate_name ( original_def_id. krate ) , Some ( ( ) ) ) ,
48
- } ;
49
- match tcx. hir ( ) . span_if_local ( item_def_id) {
50
- Some ( span) => tcx. sess . emit_err ( DuplicateDiagnosticItem { span, name } ) ,
51
- None => tcx. sess . emit_err ( DuplicateDiagnosticItemInCrate {
52
- span : orig_span,
53
- orig_crate_name,
54
- have_orig_crate_name,
55
- crate_name : tcx. crate_name ( item_def_id. krate ) ,
56
- name,
57
- } ) ,
58
- } ;
45
+ let orig_span = tcx. hir ( ) . span_if_local ( original_def_id) ;
46
+ let duplicate_span = tcx. hir ( ) . span_if_local ( item_def_id) ;
47
+ tcx. sess . emit_err ( DuplicateDiagnosticItemInCrate {
48
+ duplicate_span,
49
+ orig_span,
50
+ crate_name : tcx. crate_name ( item_def_id. krate ) ,
51
+ orig_crate_name : tcx. crate_name ( original_def_id. krate ) ,
52
+ different_crates : ( item_def_id. krate != original_def_id. krate ) . then_some ( ( ) ) ,
53
+ name,
54
+ } ) ;
59
55
}
60
56
61
57
/// Extract the first `rustc_diagnostic_item = "$name"` out of a list of attributes.
0 commit comments