@@ -355,7 +355,7 @@ pub struct TomlManifest {
355
355
patch : Option < BTreeMap < String , BTreeMap < String , TomlDependency > > > ,
356
356
workspace : Option < TomlWorkspace > ,
357
357
badges : Option < MaybeWorkspaceBtreeMap > ,
358
- lints : Option < MaybeWorkspaceLints > ,
358
+ lints : Option < toml :: Value > ,
359
359
}
360
360
361
361
#[ derive( Deserialize , Serialize , Clone , Debug , Default ) ]
@@ -1440,7 +1440,7 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspaceLints {
1440
1440
Err ( de:: Error :: custom ( "`workspace` cannot be false" ) )
1441
1441
} ;
1442
1442
}
1443
- BTreeMap :: deserialize ( serde_value:: ValueDeserializer :: < D :: Error > :: new ( value) )
1443
+ TomlLints :: deserialize ( serde_value:: ValueDeserializer :: < D :: Error > :: new ( value) )
1444
1444
. map ( MaybeWorkspace :: Defined )
1445
1445
}
1446
1446
}
@@ -1531,7 +1531,7 @@ pub struct TomlWorkspace {
1531
1531
// Properties that can be inherited by members.
1532
1532
package : Option < InheritableFields > ,
1533
1533
dependencies : Option < BTreeMap < String , TomlDependency > > ,
1534
- lints : Option < TomlLints > ,
1534
+ lints : Option < toml :: Value > ,
1535
1535
1536
1536
// Note that this field must come last due to the way toml serialization
1537
1537
// works which requires tables to be emitted after all values.
@@ -2045,7 +2045,8 @@ impl TomlManifest {
2045
2045
let mut inheritable = toml_config. package . clone ( ) . unwrap_or_default ( ) ;
2046
2046
inheritable. update_ws_path ( package_root. to_path_buf ( ) ) ;
2047
2047
inheritable. update_deps ( toml_config. dependencies . clone ( ) ) ;
2048
- let lints = verify_lints ( toml_config. lints . clone ( ) , & features, config) ?;
2048
+ let lints = parse_unstable_lints ( toml_config. lints . clone ( ) , & features, config) ?;
2049
+ let lints = verify_lints ( lints) ?;
2049
2050
inheritable. update_lints ( lints) ;
2050
2051
if let Some ( ws_deps) = & inheritable. dependencies {
2051
2052
for ( name, dep) in ws_deps {
@@ -2310,12 +2311,11 @@ impl TomlManifest {
2310
2311
& inherit_cell,
2311
2312
) ?;
2312
2313
2313
- let lints = me
2314
- . lints
2315
- . clone ( )
2316
- . map ( |mw| mw. resolve ( "lints" , || inherit ( ) ?. lints ( ) ) )
2317
- . transpose ( ) ?;
2318
- let lints = verify_lints ( lints. clone ( ) , & features, config) ?;
2314
+ let lints =
2315
+ parse_unstable_lints :: < MaybeWorkspaceLints > ( me. lints . clone ( ) , & features, config) ?
2316
+ . map ( |mw| mw. resolve ( "lints" , || inherit ( ) ?. lints ( ) ) )
2317
+ . transpose ( ) ?;
2318
+ let lints = verify_lints ( lints) ?;
2319
2319
let default = TomlLints :: default ( ) ;
2320
2320
let mut rustflags = lints
2321
2321
. as_ref ( )
@@ -2642,7 +2642,8 @@ impl TomlManifest {
2642
2642
. badges
2643
2643
. as_ref ( )
2644
2644
. map ( |_| MaybeWorkspace :: Defined ( metadata. badges . clone ( ) ) ) ,
2645
- lints : lints. map ( |lints| MaybeWorkspace :: Defined ( lints) ) ,
2645
+ lints : lints
2646
+ . map ( |lints| toml:: Value :: try_from ( MaybeWorkspaceLints :: Defined ( lints) ) . unwrap ( ) ) ,
2646
2647
} ;
2647
2648
let mut manifest = Manifest :: new (
2648
2649
summary,
@@ -2773,7 +2774,8 @@ impl TomlManifest {
2773
2774
let mut inheritable = toml_config. package . clone ( ) . unwrap_or_default ( ) ;
2774
2775
inheritable. update_ws_path ( root. to_path_buf ( ) ) ;
2775
2776
inheritable. update_deps ( toml_config. dependencies . clone ( ) ) ;
2776
- let lints = verify_lints ( toml_config. lints . clone ( ) , & features, config) ?;
2777
+ let lints = parse_unstable_lints ( toml_config. lints . clone ( ) , & features, config) ?;
2778
+ let lints = verify_lints ( lints) ?;
2777
2779
inheritable. update_lints ( lints) ;
2778
2780
let ws_root_config = WorkspaceRootConfig :: new (
2779
2781
root,
@@ -2919,18 +2921,24 @@ impl TomlManifest {
2919
2921
}
2920
2922
}
2921
2923
2922
- fn verify_lints (
2923
- lints : Option < TomlLints > ,
2924
+ fn parse_unstable_lints < T : Deserialize < ' static > > (
2925
+ lints : Option < toml :: Value > ,
2924
2926
features : & Features ,
2925
2927
config : & Config ,
2926
- ) -> CargoResult < Option < TomlLints > > {
2928
+ ) -> CargoResult < Option < T > > {
2927
2929
let Some ( lints) = lints else { return Ok ( None ) ; } ;
2928
2930
2929
- if let Err ( err ) = features. require ( Feature :: lints ( ) ) {
2930
- let _ = config. shell ( ) . warn ( err ) ;
2931
+ if let Err ( unstable_err ) = features. require ( Feature :: lints ( ) ) {
2932
+ let _ = config. shell ( ) . warn ( unstable_err ) ;
2931
2933
return Ok ( None ) ;
2932
2934
}
2933
2935
2936
+ lints. try_into ( ) . map ( Some ) . map_err ( |err| err. into ( ) )
2937
+ }
2938
+
2939
+ fn verify_lints ( lints : Option < TomlLints > ) -> CargoResult < Option < TomlLints > > {
2940
+ let Some ( lints) = lints else { return Ok ( None ) ; } ;
2941
+
2934
2942
for ( tool, lints) in & lints {
2935
2943
let supported = [ "rust" , "clippy" , "rustdoc" ] ;
2936
2944
if !supported. contains ( & tool. as_str ( ) ) {
0 commit comments