Skip to content

Reduce rust-version to 1.71.1#894

Closed
dahlbaek wants to merge 8 commits intopulldown-cmark:masterfrom
dahlbaek:reduce-rust-version-1-71-1
Closed

Reduce rust-version to 1.71.1#894
dahlbaek wants to merge 8 commits intopulldown-cmark:masterfrom
dahlbaek:reduce-rust-version-1-71-1

Conversation

@dahlbaek
Copy link

@dahlbaek dahlbaek commented May 19, 2024

The only dependency that requires 1.74 is clap.

Since the library seems to compile fine with only 1.71.1, it would be neat for distro packagers and others using old compilers if the rust-version could be reduced to that.

The only dependency that requires 1.74 is clap.
@alerque
Copy link
Contributor

alerque commented May 20, 2024

Can rust-version be set separately under [[bin]] or somehow actually correctly identify the CLI vs. Library MSRV?

@dahlbaek
Copy link
Author

dahlbaek commented May 20, 2024

Hm, there is the option of extracting the lib/bin into separate packages, where the bin package will depend on the lib package. This way, the bin package can specify a "recent" rust-version, and the lib package can put some effort into supporting older versions of rustc. In particular, the clap dependency would probably move into the bin package entirely, and so no change to the locked versions of dependencies would be needed. Doing that might be a bit annoying for downstream users, since either the binary or library would have to change name.

Maybe there's a better way, but not one I know of.

@dahlbaek
Copy link
Author

I suppose one solution would be to extract the lib into its own package (say pulldown-cmark-lib), and then reexport the entire lib package in the bin package.

@dahlbaek
Copy link
Author

dahlbaek commented May 23, 2024

@alerque I put together a proposal that separates the library/binary into distinct crates, only to realise that it was never the binary that was pulling in clap; rather it was criterion, used for the benchmarking suite and specified under dev-dependencies.

Since clap is "just" a dev dependency, I don't think it will actually propagate to any package depending on this package, which means there shouldn't be any concern in terms of packaging until someone wants to actually package this lib/bin itself and therefore want to run the test suite 🤔 let me know what your opinion is as to what should or should not be done.

@Martin1887
Copy link
Collaborator

OK. Please check the failing tests in the automated build.

I don't see as a bad thing separating lib and bin in different crates in this way because the former pulddown-cmark crate can still be used as the lib as before. However, if this is not necessary because the problem is in the dev dependencies, I think a better solution is separating MSRV for use and dev and using the dev MSRV in the Github actions toolchain.

@rhysd
Copy link
Contributor

rhysd commented Jun 4, 2024

clap is just used for fuzzer. How about replacing it with getopts? The getopts crate is already used in src/main.rs. So we can happily remove clap with no additional dependency and reduce the MSRV. It might also be a good idea to downgrade the clap version to match to the reduced MSRV.

@rhysd
Copy link
Contributor

rhysd commented Jun 4, 2024

Hmm, I'm not understanding why clap affects MSRV of this crate actually. clap is only used in the fuzzer.

clap = { version = "4.3", features = ["derive"] }

The fuzzer is not included in pulldown-cmark crate nor pulldown-cmark-escape crate. So it should not affect those crates shipped on crates.io at all. Can't we simply downgrade MSRV to 1.71.1 if only clap crate is the blocker?

I tried to downgrade the version on my local and cargo check didn't complain it.

diff --git a/pulldown-cmark/Cargo.toml b/pulldown-cmark/Cargo.toml
index 42ce426..13527a2 100644
--- a/pulldown-cmark/Cargo.toml
+++ b/pulldown-cmark/Cargo.toml
@@ -11,7 +11,7 @@ repository = "https://github.com/raphlinus/pulldown-cmark"
 keywords = ["markdown", "commonmark"]
 categories = ["text-processing"]
 edition = "2021"
-rust-version = "1.74" # Update README.md and GitHub action when changing this
+rust-version = "1.71.1" # Update README.md and GitHub action when changing this
 readme = "../README.md"
 exclude = [
     "/third_party/**/*",

@dahlbaek
Copy link
Author

dahlbaek commented Jun 7, 2024

I think the issue is that the dev dependency criterion is pulling in clap. It’s not clear to me what the best practice is regarding MSRV and dev dependencies.

@rhysd
Copy link
Contributor

rhysd commented Jun 8, 2024

Does dev-dependency affect rust-version? The rust-version field is for library users. And dev-dependencies are not installed on a user installing the crate. So if my understanding is correct it does not affect.

@ollpu
Copy link
Collaborator

ollpu commented Jun 8, 2024

Recent URLO discussion:

https://users.rust-lang.org/t/rust-version-and-development-dependencies/112608

So I think the MSRV can be lowered. We just need to check that the library compiles with the advertized MSRV in CI. README should be clear that there are two different MSRVs for the library and benchmarking/other tools.

@Martin1887
Copy link
Collaborator

Yes, having two different MSRVs seems the best option.

@rhysd
Copy link
Contributor

rhysd commented Jun 21, 2024

@Martin1887 I created an alternative PR for this issue at #916. Would you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants