rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.17k stars 1.58k forks source link

more refined suggestions for functions that return a reference #17310

Open antonilol opened 4 months ago

antonilol commented 4 months ago

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

divyaranjan1905 commented 2 months ago

@rustbot claim

divyaranjan1905 commented 2 months ago

@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?

Veykril commented 2 months ago

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