Skip to content

Commit fa01389

Browse files
committed
hygiene: Fix identifier comparison in impl overlap check
1 parent 89573b3 commit fa01389

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/librustc_typeck/coherence/inherent_impls_overlap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
2525

2626
let name_and_namespace = |def_id| {
2727
let item = self.tcx.associated_item(def_id);
28-
(item.ident, Namespace::from(item.kind))
28+
(item.ident.modern(), Namespace::from(item.kind))
2929
};
3030

3131
let impl_items1 = self.tcx.associated_item_def_ids(impl1);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(decl_macro)]
2+
3+
struct X;
4+
5+
macro_rules! define_f_legacy { () => {
6+
fn f() {}
7+
}}
8+
macro define_g_modern() {
9+
fn g() {}
10+
}
11+
12+
impl X {
13+
fn f() {} //~ ERROR duplicate definitions with name `f`
14+
fn g() {} // OK
15+
}
16+
impl X {
17+
define_f_legacy!();
18+
}
19+
impl X {
20+
define_g_modern!();
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0592]: duplicate definitions with name `f`
2+
--> $DIR/specialization-overlap-hygiene.rs:13:4
3+
|
4+
LL | fn f() {}
5+
| --------- other definition for `f`
6+
...
7+
LL | fn f() {}
8+
| ^^^^^^^^^ duplicate definitions for `f`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0592`.

0 commit comments

Comments
 (0)