rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

more refined suggestions for functions that return a reference

Open antonilol opened this issue 1 year ago • 3 comments

when typing CustomByteSlice:: (see screenshot below), the first suggestion is to also borrow the result, this is fine normally, but in this case from_bytes already returns a reference (note that the result is not wrong, but does raise a clippy warning)

image

a special case for these unsized newtype wrappers is that they can't be constructed with &StructName(something), so this suggestion (see screenshot below) should not be here (unless this will be supported by rust some time in the future, but then still it is not supported now so should not be suggested as it results in code that has compile errors)

image

antonilol avatar May 29 '24 10:05 antonilol

@rustbot claim

divyaranjan1905 avatar Aug 07 '24 02:08 divyaranjan1905

@Veykril I'd like to take this as my first contribution to rust-analyzer. Do you have a clue about where I might look in the source code for this bug?

divyaranjan1905 avatar Aug 07 '24 02:08 divyaranjan1905

The relevant bits are here https://github.com/rust-lang/rust-analyzer/blob/25d9e05c03e719c108c238c0ee798eeb71ea5928/crates/ide-completion/src/render.rs#L616-L637

Veykril avatar Aug 07 '24 05:08 Veykril

Hey @Veykril , is this still up for grab?

Shourya742 avatar Feb 23 '25 02:02 Shourya742

yes

Veykril avatar Feb 23 '25 06:02 Veykril

@rustbot claim

Shourya742 avatar Feb 23 '25 12:02 Shourya742