-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add cfg_version
support
#15533
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
base: master
Are you sure you want to change the base?
Add cfg_version
support
#15533
Changes from all commits
9f416d7
b1d153e
bd6b647
84c3bfd
a99580b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -817,3 +817,144 @@ fn cfg_booleans_rustflags_no_effect() { | |||||||||||||||||||||||
"#]]) | ||||||||||||||||||||||||
.run(); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
#[cargo_test] | ||||||||||||||||||||||||
fn cfg_version() { | ||||||||||||||||||||||||
let p = project() | ||||||||||||||||||||||||
.file( | ||||||||||||||||||||||||
"Cargo.toml", | ||||||||||||||||||||||||
r#" | ||||||||||||||||||||||||
[package] | ||||||||||||||||||||||||
name = "a" | ||||||||||||||||||||||||
edition = "2015" | ||||||||||||||||||||||||
[target.'cfg(version("1.87.0"))'.dependencies] | ||||||||||||||||||||||||
b = { path = 'b' } | ||||||||||||||||||||||||
"#, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
.file("src/lib.rs", "extern crate b;") | ||||||||||||||||||||||||
.file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) | ||||||||||||||||||||||||
.file("b/src/lib.rs", "") | ||||||||||||||||||||||||
.build(); | ||||||||||||||||||||||||
p.cargo("check -v").run(); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
Comment on lines
+821
to
+840
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish we had a way to override the rust version so we could test with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
#[cargo_test] | ||||||||||||||||||||||||
fn cfg_version_short() { | ||||||||||||||||||||||||
let p = project() | ||||||||||||||||||||||||
.file( | ||||||||||||||||||||||||
"Cargo.toml", | ||||||||||||||||||||||||
r#" | ||||||||||||||||||||||||
[package] | ||||||||||||||||||||||||
name = "a" | ||||||||||||||||||||||||
edition = "2015" | ||||||||||||||||||||||||
[target.'cfg(version("1.87"))'.dependencies] | ||||||||||||||||||||||||
b = { path = 'b' } | ||||||||||||||||||||||||
"#, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
.file("src/lib.rs", "extern crate b;") | ||||||||||||||||||||||||
.file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) | ||||||||||||||||||||||||
.file("b/src/lib.rs", "") | ||||||||||||||||||||||||
.build(); | ||||||||||||||||||||||||
p.cargo("check -v").run(); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
#[cargo_test] | ||||||||||||||||||||||||
fn cfg_bad_version() { | ||||||||||||||||||||||||
let p = project() | ||||||||||||||||||||||||
.file( | ||||||||||||||||||||||||
"Cargo.toml", | ||||||||||||||||||||||||
r#" | ||||||||||||||||||||||||
[package] | ||||||||||||||||||||||||
name = "foo" | ||||||||||||||||||||||||
edition = "2015" | ||||||||||||||||||||||||
[target.'cfg(version("1"))'.dependencies] | ||||||||||||||||||||||||
b = { path = 'b' } | ||||||||||||||||||||||||
"#, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
.file("src/lib.rs", "extern crate b;") | ||||||||||||||||||||||||
.file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) | ||||||||||||||||||||||||
.file("b/src/lib.rs", "") | ||||||||||||||||||||||||
.build(); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
p.cargo("check") | ||||||||||||||||||||||||
.with_status(101) | ||||||||||||||||||||||||
.with_stderr_data(str![[r#" | ||||||||||||||||||||||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` | ||||||||||||||||||||||||
Caused by: | ||||||||||||||||||||||||
failed to parse `version("1")` as a cfg expression: invalid Rust cfg version, expected format `version("1.23.4")` or `version("1.23")` | ||||||||||||||||||||||||
"#]]) | ||||||||||||||||||||||||
.run(); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
#[cargo_test] | ||||||||||||||||||||||||
fn cfg_bad_version2() { | ||||||||||||||||||||||||
let p = project() | ||||||||||||||||||||||||
.file( | ||||||||||||||||||||||||
"Cargo.toml", | ||||||||||||||||||||||||
r#" | ||||||||||||||||||||||||
[package] | ||||||||||||||||||||||||
name = "foo" | ||||||||||||||||||||||||
edition = "2015" | ||||||||||||||||||||||||
[target.'cfg(version(1.87.0))'.dependencies] | ||||||||||||||||||||||||
b = { path = 'b' } | ||||||||||||||||||||||||
"#, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
.file("src/lib.rs", "extern crate b;") | ||||||||||||||||||||||||
.file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) | ||||||||||||||||||||||||
.file("b/src/lib.rs", "") | ||||||||||||||||||||||||
.build(); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
p.cargo("check") | ||||||||||||||||||||||||
.with_status(101) | ||||||||||||||||||||||||
.with_stderr_data(str![[r#" | ||||||||||||||||||||||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` | ||||||||||||||||||||||||
Caused by: | ||||||||||||||||||||||||
failed to parse `version(1.87.0)` as a cfg expression: unexpected character `1` in cfg, expected parens, a comma, an identifier, or a string | ||||||||||||||||||||||||
"#]]) | ||||||||||||||||||||||||
.run(); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
#[cargo_test] | ||||||||||||||||||||||||
fn cfg_bad_version3() { | ||||||||||||||||||||||||
let p = project() | ||||||||||||||||||||||||
.file( | ||||||||||||||||||||||||
"Cargo.toml", | ||||||||||||||||||||||||
r#" | ||||||||||||||||||||||||
[package] | ||||||||||||||||||||||||
name = "foo" | ||||||||||||||||||||||||
edition = "2015" | ||||||||||||||||||||||||
[target.'cfg(version = "1.87.0")'.dependencies] | ||||||||||||||||||||||||
b = { path = 'b' } | ||||||||||||||||||||||||
"#, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
.file("src/lib.rs", "extern crate b;") | ||||||||||||||||||||||||
.file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) | ||||||||||||||||||||||||
.file("b/src/lib.rs", "") | ||||||||||||||||||||||||
.build(); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
p.cargo("check") | ||||||||||||||||||||||||
.with_status(101) | ||||||||||||||||||||||||
.with_stderr_data(str![[r#" | ||||||||||||||||||||||||
[LOCKING] 1 package to latest compatible version | ||||||||||||||||||||||||
[CHECKING] foo v0.0.0 ([ROOT]/foo) | ||||||||||||||||||||||||
error[E0463]: can't find crate for `b` | ||||||||||||||||||||||||
--> src/lib.rs:1:1 | ||||||||||||||||||||||||
| | ||||||||||||||||||||||||
1 | extern crate b; | ||||||||||||||||||||||||
| ^^^^^^^^^^^^^^^ can't find crate | ||||||||||||||||||||||||
For more information about this error, try `rustc --explain E0463`. | ||||||||||||||||||||||||
[ERROR] could not compile `foo` (lib) due to 1 previous error | ||||||||||||||||||||||||
Comment on lines
+949
to
+956
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't match on the exact output from rustc because if they change the output it would prevent this test from passing. I think something like the following should be close enough:
Suggested change
|
||||||||||||||||||||||||
"#]]) | ||||||||||||||||||||||||
.run(); | ||||||||||||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.