rust-lang / rust-lang/rust-clippy
Suggest fix for `borrowed_box` return value
Open
Nobody has claimed this yet.
C-enhancement
E-medium
L-suggestion
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
It would be nice if borrowed_box suggested a fix for the returned value in addition to the function signature.
Example from #6723:
pub trait Inner{}
pub struct Wrapper(Box<dyn Inner>);
pub unsafe fn get_inner(wrapper: *mut Wrapper) -> &'static Box<dyn Inner> {
&(*wrapper).0
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin at the existing borrowed_box lint and its signature suggestion, then trace how the returned expression in the provided example is diagnosed. Add coverage for a suggested fix on the returned value and verify it against the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100