Skip to content

Commit

Permalink
hygiene: Fix identifier comparison in impl overlap check
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Mar 21, 2019
1 parent 89573b3 commit fa01389
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc_typeck/coherence/inherent_impls_overlap.rs
Expand Up @@ -25,7 +25,7 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {

let name_and_namespace = |def_id| {
let item = self.tcx.associated_item(def_id);
(item.ident, Namespace::from(item.kind))
(item.ident.modern(), Namespace::from(item.kind))
};

let impl_items1 = self.tcx.associated_item_def_ids(impl1);
Expand Down
23 changes: 23 additions & 0 deletions src/test/ui/specialization/specialization-overlap-hygiene.rs
@@ -0,0 +1,23 @@
#![feature(decl_macro)]

struct X;

macro_rules! define_f_legacy { () => {
fn f() {}
}}
macro define_g_modern() {
fn g() {}
}

impl X {
fn f() {} //~ ERROR duplicate definitions with name `f`
fn g() {} // OK
}
impl X {
define_f_legacy!();
}
impl X {
define_g_modern!();
}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/specialization/specialization-overlap-hygiene.stderr
@@ -0,0 +1,12 @@
error[E0592]: duplicate definitions with name `f`
--> $DIR/specialization-overlap-hygiene.rs:13:4
|
LL | fn f() {}
| --------- other definition for `f`
...
LL | fn f() {}
| ^^^^^^^^^ duplicate definitions for `f`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0592`.

0 comments on commit fa01389

Please sign in to comment.