File tree 3 files changed +48
-4
lines changed
3 files changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -119,11 +119,12 @@ impl ResolveBehavior {
119
119
}
120
120
}
121
121
122
- pub fn to_manifest ( & self ) -> Option < String > {
122
+ pub fn to_manifest ( & self ) -> String {
123
123
match self {
124
- ResolveBehavior :: V1 => None ,
125
- ResolveBehavior :: V2 => Some ( "2" . to_string ( ) ) ,
124
+ ResolveBehavior :: V1 => "1" ,
125
+ ResolveBehavior :: V2 => "2" ,
126
126
}
127
+ . to_owned ( )
127
128
}
128
129
}
129
130
Original file line number Diff line number Diff line change @@ -1342,7 +1342,7 @@ impl TomlManifest {
1342
1342
. unwrap ( )
1343
1343
. clone ( ) ;
1344
1344
package. workspace = None ;
1345
- package. resolver = ws. resolve_behavior ( ) . to_manifest ( ) ;
1345
+ package. resolver = Some ( ws. resolve_behavior ( ) . to_manifest ( ) ) ;
1346
1346
if let Some ( license_file) = & package. license_file {
1347
1347
let license_file = license_file
1348
1348
. as_defined ( )
Original file line number Diff line number Diff line change @@ -2325,3 +2325,46 @@ See [..]
2325
2325
assert ! ( p. root( ) . join( "target/package/foo-0.0.1.crate" ) . is_file( ) ) ;
2326
2326
assert ! ( p. root( ) . join( "target/package/bar-0.0.1.crate" ) . is_file( ) ) ;
2327
2327
}
2328
+
2329
+ #[ cargo_test]
2330
+ fn workspace_overrides_resolver ( ) {
2331
+ let p = project ( )
2332
+ . file (
2333
+ "Cargo.toml" ,
2334
+ r#"
2335
+ [workspace]
2336
+ members = ["bar"]
2337
+ "# ,
2338
+ )
2339
+ . file (
2340
+ "bar/Cargo.toml" ,
2341
+ r#"
2342
+ [package]
2343
+ name = "bar"
2344
+ version = "0.1.0"
2345
+ edition = "2021"
2346
+ "# ,
2347
+ )
2348
+ . file ( "bar/src/lib.rs" , "" )
2349
+ . build ( ) ;
2350
+
2351
+ p. cargo ( "package --no-verify" ) . cwd ( "bar" ) . run ( ) ;
2352
+
2353
+ let f = File :: open ( & p. root ( ) . join ( "target/package/bar-0.1.0.crate" ) ) . unwrap ( ) ;
2354
+ let rewritten_toml = format ! (
2355
+ r#"{}
2356
+ [package]
2357
+ edition = "2021"
2358
+ name = "bar"
2359
+ version = "0.1.0"
2360
+ resolver = "1"
2361
+ "# ,
2362
+ cargo:: core:: package:: MANIFEST_PREAMBLE
2363
+ ) ;
2364
+ validate_crate_contents (
2365
+ f,
2366
+ "bar-0.1.0.crate" ,
2367
+ & [ "Cargo.toml" , "Cargo.toml.orig" , "src/lib.rs" ] ,
2368
+ & [ ( "Cargo.toml" , & rewritten_toml) ] ,
2369
+ ) ;
2370
+ }
You can’t perform that action at this time.
0 commit comments