Skip to content

Commit 018c5c9

Browse files
committed
Make 'overlapping_inherent_impls' lint a hard error
1 parent 5309a3e commit 018c5c9

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/librustc_typeck/coherence/inherent_impls_overlap.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
1212
use rustc::hir;
1313
use rustc::hir::itemlikevisit::ItemLikeVisitor;
14-
use rustc::lint;
1514
use rustc::traits::{self, Reveal};
1615
use rustc::ty::{self, TyCtxt};
1716

@@ -53,12 +52,16 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
5352

5453
for &item2 in &impl_items2[..] {
5554
if (name, namespace) == name_and_namespace(item2) {
56-
let msg = format!("duplicate definitions with name `{}`", name);
57-
let node_id = self.tcx.hir.as_local_node_id(item1).unwrap();
58-
self.tcx.sess.add_lint(lint::builtin::OVERLAPPING_INHERENT_IMPLS,
59-
node_id,
60-
self.tcx.span_of_impl(item1).unwrap(),
61-
msg);
55+
struct_span_err!(self.tcx.sess,
56+
self.tcx.span_of_impl(item1).unwrap(),
57+
E0592,
58+
"duplicate definitions with name `{}`",
59+
name)
60+
.span_label(self.tcx.span_of_impl(item1).unwrap(),
61+
&format!("duplicate definitions for `{}`", name))
62+
.span_label(self.tcx.span_of_impl(item2).unwrap(),
63+
&format!("other definition for `{}`", name))
64+
.emit();
6265
}
6366
}
6467
}

0 commit comments

Comments
 (0)