derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

Re-exporting std traits confuses Rust Analyzer

Open TheLostLambda opened this issue 1 year ago • 4 comments

I'm not sure if this is just a configuration issue on my end, but rust-analyzer seems convinced that the only version of traits like Display or Into come from this library.

This has been particularly annoying when I've gone to import one of these traits automatically, but it only suggests importing the derive_more version. I'd rather not have imports from derive_more in the modules I'm not using it, so I've been having to manually import things every time this clash happens.

A couple of examples — first from a diagnostic: image It should be noted that the file that error is coming from doesn't mention or import derive_more anywhere. It's just a carry-over from other modules in the crate using it.

And the annoying no-correct-import case: image

I'm not sure if there is a clever way around this, but if not, I'd honestly prefer to have to separately import the trait from std!

What do others think / what was the rationale for re-exporting those std traits to begin with?

TheLostLambda avatar Apr 23 '24 22:04 TheLostLambda

Oh, importantly this is the 1.0.0-beta.6 — I think this is a change introduced by 1.0.0?

TheLostLambda avatar Apr 23 '24 22:04 TheLostLambda

That does seem like quite a bad side-effect of the change. @tyranron what do you think about this. Can you think of a reason to address this? I remember some colleagues complaining about this same issue.

JelteF avatar Apr 23 '24 22:04 JelteF

This sounds related to this rust-analyzer issue. https://github.com/rust-lang/rust-analyzer/issues/11698

We do mark these reexported traits as doc(hidden). So probably the best is to fix this rust-analyzer issue.

JelteF avatar Apr 23 '24 22:04 JelteF

@JelteF yup, I agree that this should be rather fixed on the rust-analyzer side.

tyranron avatar Apr 24 '24 09:04 tyranron