@@ -108,8 +108,13 @@ impl LintLevelSets {
108
108
}
109
109
}
110
110
111
- // Ensure that we never exceed the `--cap-lints` argument.
112
- level = cmp:: min ( level, self . lint_cap ) ;
111
+ // Ensure that we never exceed the `--cap-lints` argument
112
+ // unless the source is a --force-warn
113
+ level = if let LintLevelSource :: CommandLine ( _, Level :: ForceWarn ) = src {
114
+ level
115
+ } else {
116
+ cmp:: min ( level, self . lint_cap )
117
+ } ;
113
118
114
119
if let Some ( driver_level) = sess. driver_lint_caps . get ( & LintId :: of ( lint) ) {
115
120
// Ensure that we never exceed driver level.
@@ -257,22 +262,14 @@ pub fn struct_lint_level<'s, 'd>(
257
262
} else {
258
263
sess. struct_allow ( "" )
259
264
}
260
- } else if is_force_warn {
261
- let mut err = if let Some ( span) = span {
262
- sess. struct_span_warn ( span, "" )
263
- } else {
264
- sess. struct_warn ( "" )
265
- } ;
266
- // Ensure force-warn warns even if the diagnostic has
267
- // been canceled for reasons like `--cap-lints`
268
- err. level = rustc_errors:: Level :: Warning ;
269
- err
270
265
} else {
271
266
return ;
272
267
}
273
268
}
274
- ( Level :: Warn | Level :: ForceWarn , Some ( span) ) => sess. struct_span_warn ( span, "" ) ,
275
- ( Level :: Warn | Level :: ForceWarn , None ) => sess. struct_warn ( "" ) ,
269
+ ( Level :: Warn , Some ( span) ) => sess. struct_span_warn ( span, "" ) ,
270
+ ( Level :: Warn , None ) => sess. struct_warn ( "" ) ,
271
+ ( Level :: ForceWarn , Some ( span) ) => sess. struct_span_force_warn ( span, "" ) ,
272
+ ( Level :: ForceWarn , None ) => sess. struct_force_warn ( "" ) ,
276
273
( Level :: Deny | Level :: Forbid , Some ( span) ) => sess. struct_span_err ( span, "" ) ,
277
274
( Level :: Deny | Level :: Forbid , None ) => sess. struct_err ( "" ) ,
278
275
} ;
0 commit comments