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

fix(toml): Don't warn on unset Edition if only 2015 is compatible #13533

Merged
merged 1 commit into from
Mar 5, 2024
Merged
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
24 changes: 14 additions & 10 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,16 +616,20 @@ pub fn to_real_manifest(
let default_edition = Edition::default();
let latest_edition = Edition::LATEST_STABLE;

let tip = if msrv_edition == default_edition {
String::new()
} else if msrv_edition == latest_edition {
format!(" while the latest is {latest_edition}")
} else {
format!(" while {msrv_edition} is compatible with `rust-version`")
};
warnings.push(format!(
"no edition set: defaulting to the {default_edition} edition{tip}",
));
// We're trying to help the user who might assume they are using a new edition,
// so if they can't use a new edition, don't bother to tell them to set it.
// This also avoids having to worry about whether `package.edition` is compatible with
// their MSRV.
if msrv_edition != default_edition {
let tip = if msrv_edition == latest_edition {
format!(" while the latest is {latest_edition}")
} else {
format!(" while {msrv_edition} is compatible with `rust-version`")
};
warnings.push(format!(
"no edition set: defaulting to the {default_edition} edition{tip}",
));
}
default_edition
};
// Add these lines if start a new unstable edition.
Expand Down
1 change: 0 additions & 1 deletion tests/testsuite/edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ fn unset_edition_works_with_no_newer_compatible_edition() {
p.cargo("check -v")
.with_stderr(
"\
[WARNING] no edition set: defaulting to the 2015 edition
[CHECKING] foo [..]
[RUNNING] `rustc [..] --edition=2015 [..]`
[FINISHED] [..]
Expand Down