posixutils-rs icon indicating copy to clipboard operation
posixutils-rs copied to clipboard

Minimum Supported Rust Version = 1.77.0

Open fox0 opened this issue 1 year ago • 8 comments

https://github.com/rustcoreutils/posixutils-rs/issues/304

fox0 avatar Oct 13 '24 03:10 fox0

LGTM. @andrewliebenow, any comments?

jgarzik avatar Oct 13 '24 04:10 jgarzik

Does not actually build on 1.77.0:

❯ git log -1
commit 1faed3d083e229fc520240b82cfdf3e47a07e631 (HEAD, fox0/msrv)
Author: fox0 <[email protected]>
Date:   Sun Oct 13 10:55:36 2024 +0700

    MSRV = 1.77.0

❯ cargo msrv find --include-all-patch-releases --log-target stdout --no-check-feedback --no-user-output | rg --fixed-strings -- 'found minimal-compatible toolchain'
2024-10-13T04:16:26.875219Z  INFO cargo_msrv::sub_command::find: found minimal-compatible toolchain toolchain=1.80.0-x86_64-unknown-linux-gnu

We either need to add the changes that were in my PR, or bump the version to 1.80.0. Your reasoning made sense to me: it probably isn't worth making too many changes just for the purpose of backwards compatibility. I just think it would be good to start checking/tracking MSRV, so that developers don't accidentally increase the minimum Rust version needed without knowing that they're doing that. I'd also suggest that a CI run is added to ensure that the project actually builds with whatever MSRV is advertised in the Cargo.toml files. I'm not sure how to do that.

@fox0 my PR also added a clippy.toml configuration file. This will help developers catch some MSRV violations sooner (ideally before a PR is submitted), because Clippy knows when some APIs were added, etc.

https://github.com/andrewliebenow/posixutils-rs/commit/680fe5704faabb0d770cc1655d8afb852c0a9cf4#diff-f3dbfb2563c3490394f44c26b51837018e79a79e75fd31e89b19e943a38317ea

andrewliebenow avatar Oct 13 '24 04:10 andrewliebenow

It looks like using a specific toolchain version might be as simple as adding this step to the GitHub workflow:

- uses: dtolnay/[email protected]

See https://github.com/tauri-apps/plugins-workspace/blob/495cbf721f820e8e2b17cad7d0b38503c83572cd/.github/workflows/msrv-check.yml

https://github.com/dtolnay/rust-toolchain

andrewliebenow avatar Oct 13 '24 04:10 andrewliebenow

$ cargo +1.77.0 b
   Compiling glob v0.3.1
error[E0716]: temporary value dropped while borrowed
   --> ftw/src/lib.rs:799:42
    |
797 |         let dir_fd = match dir {
    |             ------ borrow later stored here
798 |             HybridDir::Owned(dir) => dir.file_descriptor(),
799 |             HybridDir::Deferred(dir) => &dir.open_file_descriptor(),
    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^-
    |                                          |                        |
    |                                          |                        temporary value is freed at the end of this statement
    |                                          creates a temporary value which is freed while still in use
    |
    = note: consider using a `let` binding to create a longer lived value

error[E0716]: temporary value dropped while borrowed
   --> ftw/src/lib.rs:826:62
    |
823 |                         let prev_dir = match second_last_index {
    |                             -------- borrow later stored here
...
826 |                                 HybridDir::Deferred(dir) => &dir.open_file_descriptor(),
    |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^-
    |                                                              |                        |
    |                                                              |                        temporary value is freed at the end of this statement
    |                                                              creates a temporary value which is freed while still in use
    |
    = note: consider using a `let` binding to create a longer lived value

error[E0716]: temporary value dropped while borrowed
   --> ftw/src/lib.rs:964:46
    |
961 |         let prev_dir = match second_last_index {
    |             -------- borrow later stored here
...
964 |                 HybridDir::Deferred(dir) => &dir.open_file_descriptor(),
    |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^-
    |                                              |                        |
    |                                              |                        temporary value is freed at the end of this statement
    |                                              creates a temporary value which is freed while still in use
    |
    = note: consider using a `let` binding to create a longer lived value

For more information about this error, try `rustc --explain E0716`.
error: could not compile `ftw` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...

fox0 avatar Oct 13 '24 04:10 fox0

@fox0, that's correct, please see https://github.com/rustcoreutils/posixutils-rs/pull/305 for all changes needed to build on 1.77.0. @jgarzik wasn't interested in losing the Default derives here:

https://github.com/rustcoreutils/posixutils-rs/pull/305/files#diff-d3ee6b1816f74129bed2e897b393939cd0b0c10a35a619e360abd92eea24106b

So I would suggest bumping the MSRV to 1.80.0, and also adding:

- uses: dtolnay/[email protected]

to the GitHub workflow.

andrewliebenow avatar Oct 13 '24 04:10 andrewliebenow

I am not allowed to make edits to ftw.

fox0 avatar Oct 13 '24 04:10 fox0

Okay, so my suggestion would be to edit your PR and change the version to 1.80.0.

andrewliebenow avatar Oct 13 '24 05:10 andrewliebenow

Okay, so my suggestion would be to edit your PR and change the version to 1.80.0.

Agree

jgarzik avatar Oct 13 '24 05:10 jgarzik