Skip to content

Cargo.lock trailing newline removal in 1.38.0 #7254

@est31

Description

@est31

Consider this:

cargo +stable init --bin test_thing
cargo +stable check # to set Cargo.lock
git add . && git commit -m "Initial"
cargo +beta check
git diff

It will show you a difference! One line has been removed at the end of the file. Edit: Note that this only affects simple examples without dependencies. If there is a dependency, the newline behaviour is the same.

As time of writing, Rust beta is 1.38 and Rust stable is 1.37.

This bug may seem insignificant but it's the same "class" of change that #6180 was. In any environment where people use multiple versions of rustc to commit to the same codebase with a checked in Cargo.lock, you might run into situations where unrelated commits change Cargo.lock back and forth because the people just did cargo add. Environment with different versions of rustc can just mean that they haven't ran rustup in a while. #6180 at least had a phase in period.

I think the most likely culprit for this regression is #7070. I see some newline related changes there. cc @alexcrichton

I think that the old behaviour should be retained or at least the files with the trailing newline be kept so that there isn't jitter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions