Apparently inconsistent treatment of local impls for functions and named and unnamed consts #21691
-
|
This code compiles (albeit with warnings). However, If I'm not doing mistakes, it seems that Is there any reason the other impls are ignored or is it a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
It is intended for performance issues, as searching through all bodies would seriously regress the perf. You could find multiple places we are collecting declarations/impls inside bodies only for anonymous consts: Actually, rustc isn't so happy with those cases either so there is a clippy lint for it. You would see the lint for |
Beta Was this translation helpful? Give feedback.
-
|
As @ShoyuVanilla said, this is a deliberate behavior we're not going to change. rustc now even warns on this, partly because rust-analyzer cannot work with this. |
Beta Was this translation helpful? Give feedback.
It is intended for performance issues, as searching through all bodies would seriously regress the perf.
You could find multiple places we are collecting declarations/impls inside bodies only for anonymous consts:
https://github.com/search?q=repo%3Arust-lang%2Frust-analyzer%20unnamed_consts&type=code
Actually, rustc isn't so happy with those cases either so there is a clippy lint for it. You would see the lint for
impl Testfor the first two cases of your example code, but for the last case.