@@ -1475,29 +1475,6 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspaceBtreeMap {
1475
1475
}
1476
1476
}
1477
1477
1478
- type MaybeWorkspaceLints = MaybeWorkspace < TomlLints , TomlWorkspaceField > ;
1479
-
1480
- impl < ' de > de:: Deserialize < ' de > for MaybeWorkspaceLints {
1481
- fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
1482
- where
1483
- D : de:: Deserializer < ' de > ,
1484
- {
1485
- let value = serde_value:: Value :: deserialize ( deserializer) ?;
1486
-
1487
- if let Ok ( w) = TomlWorkspaceField :: deserialize (
1488
- serde_value:: ValueDeserializer :: < D :: Error > :: new ( value. clone ( ) ) ,
1489
- ) {
1490
- return if w. workspace ( ) {
1491
- Ok ( MaybeWorkspace :: Workspace ( w) )
1492
- } else {
1493
- Err ( de:: Error :: custom ( "`workspace` cannot be false" ) )
1494
- } ;
1495
- }
1496
- TomlLints :: deserialize ( serde_value:: ValueDeserializer :: < D :: Error > :: new ( value) )
1497
- . map ( MaybeWorkspace :: Defined )
1498
- }
1499
- }
1500
-
1501
1478
#[ derive( Deserialize , Serialize , Copy , Clone , Debug ) ]
1502
1479
pub struct TomlWorkspaceField {
1503
1480
#[ serde( deserialize_with = "bool_no_false" ) ]
@@ -2277,7 +2254,7 @@ impl TomlManifest {
2277
2254
2278
2255
let lints =
2279
2256
parse_unstable_lints :: < MaybeWorkspaceLints > ( me. lints . clone ( ) , config, cx. warnings ) ?
2280
- . map ( |mw| mw. resolve ( "lints" , || inherit ( ) ?. lints ( ) ) )
2257
+ . map ( |mw| mw. resolve ( || inherit ( ) ?. lints ( ) ) )
2281
2258
. transpose ( ) ?;
2282
2259
let lints = verify_lints ( lints) ?;
2283
2260
let default = TomlLints :: default ( ) ;
@@ -3521,6 +3498,38 @@ impl fmt::Debug for PathValue {
3521
3498
}
3522
3499
}
3523
3500
3501
+ #[ derive( Deserialize , Serialize , Debug , Clone ) ]
3502
+ #[ serde( expecting = "a map" ) ]
3503
+ pub struct MaybeWorkspaceLints {
3504
+ #[ serde( skip_serializing_if = "is_false" ) ]
3505
+ #[ serde( deserialize_with = "bool_no_false" , default ) ]
3506
+ workspace : bool ,
3507
+ #[ serde( flatten) ]
3508
+ lints : TomlLints ,
3509
+ }
3510
+
3511
+ fn is_false ( b : & bool ) -> bool {
3512
+ !b
3513
+ }
3514
+
3515
+ impl MaybeWorkspaceLints {
3516
+ fn resolve < ' a > (
3517
+ self ,
3518
+ get_ws_inheritable : impl FnOnce ( ) -> CargoResult < TomlLints > ,
3519
+ ) -> CargoResult < TomlLints > {
3520
+ if self . workspace {
3521
+ if !self . lints . is_empty ( ) {
3522
+ anyhow:: bail!( "cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints" ) ;
3523
+ }
3524
+ get_ws_inheritable ( ) . with_context ( || {
3525
+ "error inheriting `lints` from workspace root manifest's `workspace.lints`"
3526
+ } )
3527
+ } else {
3528
+ Ok ( self . lints )
3529
+ }
3530
+ }
3531
+ }
3532
+
3524
3533
pub type TomlLints = BTreeMap < String , TomlToolLints > ;
3525
3534
3526
3535
pub type TomlToolLints = BTreeMap < String , TomlLint > ;
0 commit comments