Skip to content

Feature Request: Diagnostic to replace trailing return <val>; with just <val> #10970

@izik1

Description

@izik1

Example:

#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Id(pub i32);

pub fn path(next: &[Id], width: usize, u: Id, v: Id) -> Vec<Id> {
    let mut u = u;
    let mut path = vec![];
    while u != v {
        u = next[u.0 as usize * width + v.0 as usize];
        path.push(u);
    }
    return<|> path;
}

->

#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Id(pub i32);

pub fn path(next: &[Id], width: usize, u: Id, v: Id) -> Vec<Id> {
    let mut u = u;
    let mut path = vec![];
    while u != v {
        u = next[u.0 as usize * width + v.0 as usize];
        path.push(u);
    }
    <|>path
}

(not actually too sure where to put the cursor)

If this does get picked up at some point: edge-case warning: the trailing semi might not exist.

I'd honestly be interested in doing this myself

Metadata

Metadata

Assignees

Labels

A-diagnosticsdiagnostics / error reportingC-featureCategory: feature requestE-has-instructionsIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right now

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions