@@ -2316,6 +2316,34 @@ impl TomlManifest {
23162316 . map ( |mw| mw. resolve ( "lints" , || inherit ( ) ?. lints ( ) ) )
23172317 . transpose ( ) ?;
23182318 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 < _ > > ( ) ;
23192347
23202348 let mut target: BTreeMap < String , TomlPlatform > = BTreeMap :: new ( ) ;
23212349 for ( name, platform) in me. target . iter ( ) . flatten ( ) {
@@ -2639,6 +2667,7 @@ impl TomlManifest {
26392667 Rc :: new ( resolved_toml) ,
26402668 package. metabuild . clone ( ) . map ( |sov| sov. 0 ) ,
26412669 resolve_behavior,
2670+ rustflags,
26422671 ) ;
26432672 if package. license_file . is_some ( ) && package. license . is_some ( ) {
26442673 manifest. warnings_mut ( ) . add_warning (
@@ -3490,6 +3519,22 @@ pub enum TomlLint {
34903519 Config ( TomlLintConfig ) ,
34913520}
34923521
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+
34933538#[ derive( Serialize , Deserialize , Debug , Clone ) ]
34943539#[ serde( rename_all = "kebab-case" ) ]
34953540pub struct TomlLintConfig {
@@ -3506,3 +3551,14 @@ pub enum TomlLintLevel {
35063551 Warn ,
35073552 Allow ,
35083553}
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