Skip to content

Commit bcf032e

Browse files
committed
test(fix): Show underscore field migration
1 parent aecb40b commit bcf032e

File tree

1 file changed

+162
-0
lines changed

1 file changed

+162
-0
lines changed

tests/testsuite/fix.rs

+162
Original file line numberDiff line numberDiff line change
@@ -2050,6 +2050,168 @@ edition = "2021"
20502050
);
20512051
}
20522052

2053+
#[cargo_test]
2054+
fn migrate_rename_underscore_fields() {
2055+
let p = project()
2056+
.file(
2057+
"Cargo.toml",
2058+
r#"
2059+
cargo-features = ["edition2024"]
2060+
2061+
[workspace.dependencies]
2062+
# Before default_features
2063+
a = {path = "a", default_features = false} # After default_features value
2064+
# After default_features line
2065+
2066+
[package]
2067+
name = "foo"
2068+
edition = "2021"
2069+
2070+
[lib]
2071+
name = "foo"
2072+
# Before crate_type
2073+
crate_type = ["staticlib", "dylib"] # After crate_type value
2074+
# After crate_type line
2075+
2076+
[[example]]
2077+
name = "ex"
2078+
path = "examples/ex.rs"
2079+
# Before crate_type
2080+
crate_type = ["proc-macro"] # After crate_type value
2081+
# After crate_type line
2082+
2083+
# Before dev_dependencies
2084+
[ dev_dependencies ] # After dev_dependencies header
2085+
# After dev_dependencies line
2086+
a = {path = "a", default_features = false}
2087+
# After dev_dependencies table
2088+
2089+
# Before build_dependencies
2090+
[ build_dependencies ] # After build_dependencies header
2091+
# After build_dependencies line
2092+
a = {path = "a", default_features = false}
2093+
# After build_dependencies table
2094+
2095+
# Before dev_dependencies
2096+
[ target.'cfg(any())'.dev_dependencies ] # After dev_dependencies header
2097+
# After dev_dependencies line
2098+
a = {path = "a", default_features = false}
2099+
# After dev_dependencies table
2100+
2101+
# Before build_dependencies
2102+
[ target.'cfg(any())'.build_dependencies ] # After build_dependencies header
2103+
# After build_dependencies line
2104+
a = {path = "a", default_features = false}
2105+
# After build_dependencies table
2106+
"#,
2107+
)
2108+
.file("src/lib.rs", "")
2109+
.file(
2110+
"examples/ex.rs",
2111+
r#"
2112+
fn main() { println!("ex"); }
2113+
"#,
2114+
)
2115+
.file(
2116+
"a/Cargo.toml",
2117+
r#"
2118+
[package]
2119+
name = "a"
2120+
version = "0.0.1"
2121+
edition = "2015"
2122+
"#,
2123+
)
2124+
.file("a/src/lib.rs", "")
2125+
.build();
2126+
2127+
p.cargo("fix --edition --allow-no-vcs")
2128+
.masquerade_as_nightly_cargo(&["edition2024"])
2129+
.with_stderr(
2130+
"\
2131+
[MIGRATING] Cargo.toml from 2021 edition to 2024
2132+
[WARNING] [CWD]/Cargo.toml: `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition
2133+
(in the `foo` package)
2134+
[WARNING] [CWD]/Cargo.toml: `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition
2135+
(in the `a` dependency)
2136+
[WARNING] [CWD]/Cargo.toml: `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition
2137+
(in the `foo` package)
2138+
[WARNING] [CWD]/Cargo.toml: `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition
2139+
(in the `a` dependency)
2140+
[WARNING] [CWD]/Cargo.toml: `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition
2141+
(in the `cfg(any())` platform target)
2142+
[WARNING] [CWD]/Cargo.toml: `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition
2143+
(in the `a` dependency)
2144+
[WARNING] [CWD]/Cargo.toml: `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition
2145+
(in the `cfg(any())` platform target)
2146+
[WARNING] [CWD]/Cargo.toml: `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition
2147+
(in the `a` dependency)
2148+
[WARNING] [CWD]/Cargo.toml: `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
2149+
(in the `foo` library target)
2150+
[WARNING] [CWD]/Cargo.toml: `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
2151+
(in the `ex` example target)
2152+
Locking 2 packages to latest compatible versions
2153+
Checking a v0.0.1 ([CWD]/a)
2154+
[CHECKING] foo v0.0.0 ([CWD])
2155+
[MIGRATING] src/lib.rs from 2021 edition to 2024
2156+
[MIGRATING] examples/ex.rs from 2021 edition to 2024
2157+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
2158+
",
2159+
)
2160+
.run();
2161+
assert_eq!(
2162+
p.read_file("Cargo.toml"),
2163+
r#"
2164+
cargo-features = ["edition2024"]
2165+
2166+
[workspace.dependencies]
2167+
# Before default_features
2168+
a = {path = "a", default_features = false} # After default_features value
2169+
# After default_features line
2170+
2171+
[package]
2172+
name = "foo"
2173+
edition = "2021"
2174+
2175+
[lib]
2176+
name = "foo"
2177+
# Before crate_type
2178+
crate_type = ["staticlib", "dylib"] # After crate_type value
2179+
# After crate_type line
2180+
2181+
[[example]]
2182+
name = "ex"
2183+
path = "examples/ex.rs"
2184+
# Before crate_type
2185+
crate_type = ["proc-macro"] # After crate_type value
2186+
# After crate_type line
2187+
2188+
# Before dev_dependencies
2189+
[ dev_dependencies ] # After dev_dependencies header
2190+
# After dev_dependencies line
2191+
a = {path = "a", default_features = false}
2192+
# After dev_dependencies table
2193+
2194+
# Before build_dependencies
2195+
[ build_dependencies ] # After build_dependencies header
2196+
# After build_dependencies line
2197+
a = {path = "a", default_features = false}
2198+
# After build_dependencies table
2199+
2200+
# Before dev_dependencies
2201+
[ target.'cfg(any())'.dev_dependencies ] # After dev_dependencies header
2202+
# After dev_dependencies line
2203+
a = {path = "a", default_features = false}
2204+
# After dev_dependencies table
2205+
2206+
# Before build_dependencies
2207+
[ target.'cfg(any())'.build_dependencies ] # After build_dependencies header
2208+
# After build_dependencies line
2209+
a = {path = "a", default_features = false}
2210+
# After build_dependencies table
2211+
"#
2212+
);
2213+
}
2214+
20532215
#[cargo_test]
20542216
fn add_feature_for_unused_dep() {
20552217
Package::new("bar", "0.1.0").publish();

0 commit comments

Comments
 (0)