@@ -2316,6 +2316,34 @@ impl TomlManifest {
2316
2316
. map ( |mw| mw. resolve ( "lints" , || inherit ( ) ?. lints ( ) ) )
2317
2317
. transpose ( ) ?;
2318
2318
verify_lints ( lints. as_ref ( ) , & features) ?;
2319
+ let default = TomlLints :: default ( ) ;
2320
+ let mut rustflags = lints
2321
+ . as_ref ( )
2322
+ . unwrap_or ( & default)
2323
+ . iter ( )
2324
+ . flat_map ( |( tool, lints) | {
2325
+ lints. iter ( ) . map ( move |( name, config) | {
2326
+ let flag = config. level ( ) . flag ( ) ;
2327
+ let option = if tool == "rust" {
2328
+ format ! ( "{flag}={name}" )
2329
+ } else {
2330
+ format ! ( "{flag}={tool}::{name}" )
2331
+ } ;
2332
+ (
2333
+ config. priority ( ) ,
2334
+ // Since the most common group will be `all`, put it last so people are more
2335
+ // likely to notice that they need to use `priority`.
2336
+ std:: cmp:: Reverse ( name) ,
2337
+ option,
2338
+ )
2339
+ } )
2340
+ } )
2341
+ . collect :: < Vec < _ > > ( ) ;
2342
+ rustflags. sort ( ) ;
2343
+ let rustflags = rustflags
2344
+ . into_iter ( )
2345
+ . map ( |( _, _, option) | option)
2346
+ . collect :: < Vec < _ > > ( ) ;
2319
2347
2320
2348
let mut target: BTreeMap < String , TomlPlatform > = BTreeMap :: new ( ) ;
2321
2349
for ( name, platform) in me. target . iter ( ) . flatten ( ) {
@@ -2639,6 +2667,7 @@ impl TomlManifest {
2639
2667
Rc :: new ( resolved_toml) ,
2640
2668
package. metabuild . clone ( ) . map ( |sov| sov. 0 ) ,
2641
2669
resolve_behavior,
2670
+ rustflags,
2642
2671
) ;
2643
2672
if package. license_file . is_some ( ) && package. license . is_some ( ) {
2644
2673
manifest. warnings_mut ( ) . add_warning (
@@ -3490,6 +3519,22 @@ pub enum TomlLint {
3490
3519
Config ( TomlLintConfig ) ,
3491
3520
}
3492
3521
3522
+ impl TomlLint {
3523
+ fn level ( & self ) -> TomlLintLevel {
3524
+ match self {
3525
+ Self :: Level ( level) => * level,
3526
+ Self :: Config ( config) => config. level ,
3527
+ }
3528
+ }
3529
+
3530
+ fn priority ( & self ) -> i8 {
3531
+ match self {
3532
+ Self :: Level ( _) => 0 ,
3533
+ Self :: Config ( config) => config. priority ,
3534
+ }
3535
+ }
3536
+ }
3537
+
3493
3538
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
3494
3539
#[ serde( rename_all = "kebab-case" ) ]
3495
3540
pub struct TomlLintConfig {
@@ -3506,3 +3551,14 @@ pub enum TomlLintLevel {
3506
3551
Warn ,
3507
3552
Allow ,
3508
3553
}
3554
+
3555
+ impl TomlLintLevel {
3556
+ fn flag ( & self ) -> & ' static str {
3557
+ match self {
3558
+ Self :: Forbid => "--forbid" ,
3559
+ Self :: Deny => "--deny" ,
3560
+ Self :: Warn => "--warn" ,
3561
+ Self :: Allow => "--allow" ,
3562
+ }
3563
+ }
3564
+ }
0 commit comments