hax icon indicating copy to clipboard operation
hax copied to clipboard

Engine: name clash for items within trait methods

Open W95Psp opened this issue 1 year ago • 3 comments

In the folllwing snippet, the items A_STRUCT and a_fn yields name clashes.

struct A;
struct B;

impl Clone for A {
   fn clone(&self) -> Self {
      struct A_STRUCT;
      fn a_fn(){};
      A
   }
}
impl Clone for B {
   fn clone(&self) -> Self {
      struct A_STRUCT;
      fn a_fn(){};
      B
   }
}

Open this code snippet in the playground

W95Psp avatar Dec 03 '24 09:12 W95Psp

This was not fixed by #1199

W95Psp avatar Jan 30 '25 17:01 W95Psp

@W95Psp you marked this as high. Is it something you intend to work on this week?

franziskuskiefer avatar Mar 04 '25 15:03 franziskuskiefer

@W95Psp please update

franziskuskiefer avatar Mar 09 '25 13:03 franziskuskiefer

Found this in tls_codec

maximebuyse avatar Jun 16 '25 14:06 maximebuyse

This issue doesn't reproduce on main. The original example hits another unrelated problem though: the fact one cannot impl Clone manually.

The original example is as follows:

struct A;
struct B;

trait Foo {
   fn foo(self) -> Self;
}

impl Foo for A {
   fn foo(self) -> Self {
      struct A_STRUCT;
      fn a_fn(){};
      A
   }
}
impl Foo for B {
   fn foo(self) -> Self {
      struct A_STRUCT;
      fn a_fn(){};
      B
   }
}

Open this code snippet in the playground

This produces no ambiguous name.

However @maximebuyse you say you found something similar in tls_codec? It's likely not exactly the same thing, can you open an issue with a reproducer and close this one when done?

W95Psp avatar Jul 02 '25 15:07 W95Psp

However @maximebuyse you say you found something similar in tls_codec? It's likely not exactly the same thing, can you open an issue with a reproducer and close this one when done?

I need to work on tls_codec again to see if this is still an issue (it's not easy to quickly look for just this issue), so I think we can close, and we'll open a new issue if we have the problem again.

maximebuyse avatar Jul 07 '25 09:07 maximebuyse

Sounds good, let's close then!

W95Psp avatar Jul 07 '25 10:07 W95Psp