derive breaks "ambiguous name" diagnostic if there is a level of indirection #81887
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
A-resolve
Area: Name/path resolution done by `rustc_resolve` specifically
C-bug
Category: This is a bug.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Hello. I've noticed a strange behaviour where rust-analyzer and rustc would disagree what was wrong with my code. Turns out neither of them were right, I've had an "ambiguous name" problem however both rustc and rust-analyzer resolved the type anyway and they chose a different type to disambiguate into.
I've managed to make this minimal reproduction.
I can either remove the derives or remove the indirection through the
c
module and the problem will go away.I expected to get a "
Foo
is ambiguous" error, instead i get an error for one of the usages ofFoo
which doesn't match the resolved type ofFoo
.As a side-note, at least for rustc the resolved type seems to be dependent on the lexical order of the module/type definitions (not reexports), if that helps at all.
I get the same result on both nightly and stable, locally and on the playground. I found these issues #56593 and #62769 which sound similar but the problem there seems to be the opposite - "type doesn't resolve when it should" (in the presence of derive) instead of here "type resolves when it shouldn't".
The text was updated successfully, but these errors were encountered: