rust-lang / rust-lang/rust-clippy

Suggest fix for `borrowed_box` return value

Open
#6,728 0 comments 2 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.