diff options
| author | bors <bors@rust-lang.org> | 2019-03-21 20:22:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-03-21 20:22:07 +0000 |
| commit | 94fd0458951a4ff91c03366445f0e2e93b86bd2f (patch) | |
| tree | fa876044ee130714250bb3400c6a8b2b4d32c8a3 /src | |
| parent | 89573b3c8b629507130b1ec8beeaf550fdc0e046 (diff) | |
| parent | fa013896f76d105f302316099f5073487576db41 (diff) | |
| download | rust-94fd0458951a4ff91c03366445f0e2e93b86bd2f.tar.gz rust-94fd0458951a4ff91c03366445f0e2e93b86bd2f.zip | |
Auto merge of #58948 - petrochenkov:overlap, r=cramertj
hygiene: Fix identifier comparison in impl overlap check Fixes https://github.com/rust-lang/rust/issues/58942
Diffstat (limited to 'src')
3 files changed, 36 insertions, 1 deletions
diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 832c172e97c..d0156db32e9 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -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); diff --git a/src/test/ui/specialization/specialization-overlap-hygiene.rs b/src/test/ui/specialization/specialization-overlap-hygiene.rs new file mode 100644 index 00000000000..93e7c83253e --- /dev/null +++ b/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() {} diff --git a/src/test/ui/specialization/specialization-overlap-hygiene.stderr b/src/test/ui/specialization/specialization-overlap-hygiene.stderr new file mode 100644 index 00000000000..6adf16de462 --- /dev/null +++ b/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`. |
