Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Switch to edition 2021 #946

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.16.0-beta.24"
authors = ["Martijn Gribnau <garm@ilumeo.com>"]
description = "Find your minimum supported Rust version (MSRV)!"
license = "Apache-2.0 OR MIT"
edition = "2018"
edition = "2021"
repository = "https://github.com/foresterre/cargo-msrv"

keywords = ["msrv", "rust-version", "toolchain", "find", "minimum"]
Expand Down
31 changes: 31 additions & 0 deletions src/external_command/rustup_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,37 @@ impl RustupCommand {
self.command.stdout(self.stdout);
self.command.stderr(self.stderr);

// todo:
// cwd: Some(
// "/home/a/cargo-msrv/tests/fixtures/1.35.0",
// ),
// however:
// error: failed to parse manifest at `/home/a/cargo-msrv/Cargo.toml
// whaaat?
// -> Turns out, if I copy the fixtures outside of cargo-msrv it works fine
// -> For some reason, the cwd is getting overwritten.
// -> I checked the edition notes, but they do not mention a change
//
// It happens in all these places:
// - running cargo test (in some integration tests in the tests directory, ... where edition of test crate < cargo-msrv's (or top level Cargo.toml)
// - running cargo run -- msrv --manifest-path tests/fixtures/1.35.0, ... where edition of test crate < cargo-msrv's (or top level Cargo.toml)
// - running cargo msrv (after installing the version which uses edition 2021), ... where edition crate < cargo-msrv's (or top level Cargo.toml)
// -> ... where edition crate < cargo-msrv's (or top level Cargo.toml)
// -> -> Running rustup run <toolchain> <cargo cmd> with cwd = (an inner crate within an outer crate) just reads the outer crate it seems
// -> -> But this only seems to happen from edition 2021 forward
// -> -> Didn't see anything about this in the Cargo changelog or edition notes...
//
// Whether it is a smart thing to add crates within crates (which aren't part of the workspace), 🤷
// But it used to work...
//
// -> Confirmed with 'cargo new --lib outer && cd outer && cargo new --lib inner' and setting inner edition to 2018
// -> Then running cargo msrv inside 'inner'
//
// When using cargo-msrv 0.15.1 (latest on crates.io), and testing the above, it seems like it
// used to work for tests, not normal runs...?
// TODO: remove dbg
dbg!(&self.command);

let child = self.command.spawn().map_err(|error| IoError {
error,
source: IoErrorSource::SpawnProcess(cmd.to_owned()),
Expand Down
9 changes: 9 additions & 0 deletions src/sub_command/find/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ fn bisect_find_only_last() {
let cmd = Find::new(&index, runner);
let mut context = create_test_context();
context.search_method = SearchMethod::Bisect;
// necessary currently, otherwise our own cargo manifest edition is used (ugh),
// which now is 2021, i.e. >= 1.56, and that breaks the tests
context.rust_releases.minimum_rust_version = Some(BareVersion::ThreeComponents(1, 37, 0));

let found = cmd.run(&context, reporter.get()).unwrap();
assert_eq!(found, semver::Version::new(1, 56, 0));
Expand Down Expand Up @@ -83,6 +86,9 @@ fn bisect_find_all_compatible() {
let cmd = Find::new(&index, runner);
let mut ctx = create_test_context();
ctx.search_method = SearchMethod::Bisect;
// necessary currently, otherwise our own cargo manifest edition is used (ugh),
// which now is 2021, i.e. >= 1.56, and that breaks the tests
ctx.rust_releases.minimum_rust_version = Some(BareVersion::ThreeComponents(1, 52, 0));

let found = cmd.run(&ctx, reporter.get()).unwrap();
assert_eq!(found, semver::Version::new(1, 52, 0));
Expand Down Expand Up @@ -116,6 +122,9 @@ fn bisect_none_compatible() {
let cmd = Find::new(&index, runner);
let mut ctx = create_test_context();
ctx.search_method = SearchMethod::Bisect;
// necessary currently, otherwise our own cargo manifest edition is used (ugh),
// which now is 2021, i.e. >= 1.56, and that breaks the tests
ctx.rust_releases.minimum_rust_version = Some(BareVersion::ThreeComponents(1, 52, 0));

let result = cmd.run(&ctx, reporter.get());
assert!(result.is_err());
Expand Down
Loading