difftastic icon indicating copy to clipboard operation
difftastic copied to clipboard

Rust: making function a method handled poorly

Open sftse opened this issue 2 years ago • 2 comments

before

impl X {
    fn x() {}
}

fn y() {
    match () {
        _ => y(),
    };
}

after

impl X {
    fn x() {}

    fn y() {
        match () {
            _ => X::y(),
        };
    }
}

Freshly built off master

sftse avatar Nov 24 '23 13:11 sftse

Screenshot from 2023-11-26 15-40-07

I think it would be better here if the fn on line 2 of the second file was highlighted, rather than the fn on line 4.

Showing impl X as red/green is kinda unavoidable, as difftastic is taking the view that the y function is largely unchanged and the impl is changed, because the y function is bigger.

This is also a good example of where highlighting moves would help, but we have #508 for that.

Wilfred avatar Nov 26 '23 15:11 Wilfred

Wouldn't the optimal diff be not to highlight fn x() {} and only highlight X:: and the moved }? You mentioned some limitations around highlighting impl X but I don't understand why any fn should be highlighted in this diff.

sftse avatar Nov 29 '23 11:11 sftse