Skip to content

Commit 95a5481

Browse files
committed
fix(msrv): Error, rather than panic, on rust-version 'x'
Fixes #13768
1 parent f68be76 commit 95a5481

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

crates/cargo-util-schemas/src/core/partial_version.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ enum ErrorKind {
180180
}
181181

182182
fn is_req(value: &str) -> bool {
183+
if value == "x" || value == "X" {
184+
// Checking for wildcard this way in case the `x` appears organically as a string so we
185+
// don't error out about a req when it isn't one
186+
return true;
187+
}
188+
183189
let Some(first) = value.chars().next() else {
184190
return false;
185191
};

tests/testsuite/rust_version.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ fn rust_version_bad_pre_release() {
125125
}
126126

127127
#[cargo_test]
128-
#[should_panic]
129128
fn rust_version_x_wildcard() {
130129
project()
131130
.file(
@@ -150,8 +149,8 @@ fn rust_version_x_wildcard() {
150149
[ERROR] unexpected version requirement, expected a version like \"1.32\"
151150
--> Cargo.toml:7:28
152151
|
153-
7 | rust-version = \"^1.43\"
154-
| ^^^^^^^
152+
7 | rust-version = \"x\"
153+
| ^^^
155154
|
156155
",
157156
)

0 commit comments

Comments
 (0)