@@ -11,14 +11,14 @@ use rustc_errors::Applicability;
11
11
use rustc_hir:: {
12
12
Block , Expr , ExprKind , ImplItem , ImplItemKind , Item , ItemKind , StmtKind , TraitFn , TraitItem , TraitItemKind ,
13
13
} ;
14
- use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintContext } ;
14
+ use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , Level , LintContext } ;
15
15
use rustc_middle:: lint:: in_external_macro;
16
16
use rustc_middle:: ty;
17
17
use rustc_semver:: RustcVersion ;
18
18
use rustc_session:: { declare_lint_pass, declare_tool_lint, impl_lint_pass} ;
19
19
use rustc_span:: source_map:: Span ;
20
- use rustc_span:: sym;
21
20
use rustc_span:: symbol:: Symbol ;
21
+ use rustc_span:: { sym, DUMMY_SP } ;
22
22
use semver:: Version ;
23
23
24
24
static UNIX_SYSTEMS : & [ & str ] = & [
@@ -303,6 +303,26 @@ declare_lint_pass!(Attributes => [
303
303
] ) ;
304
304
305
305
impl < ' tcx > LateLintPass < ' tcx > for Attributes {
306
+ fn check_crate ( & mut self , cx : & LateContext < ' tcx > ) {
307
+ for ( name, level) in & cx. sess ( ) . opts . lint_opts {
308
+ if name == "clippy::restriction" && * level > Level :: Allow {
309
+ span_lint_and_then (
310
+ cx,
311
+ BLANKET_CLIPPY_RESTRICTION_LINTS ,
312
+ DUMMY_SP ,
313
+ "`clippy::restriction` is not meant to be enabled as a group" ,
314
+ |diag| {
315
+ diag. note ( format ! (
316
+ "because of the command line `--{} clippy::restriction`" ,
317
+ level. as_str( )
318
+ ) ) ;
319
+ diag. help ( "enable the restriction lints you need individually" ) ;
320
+ } ,
321
+ ) ;
322
+ }
323
+ }
324
+ }
325
+
306
326
fn check_attribute ( & mut self , cx : & LateContext < ' tcx > , attr : & ' tcx Attribute ) {
307
327
if let Some ( items) = & attr. meta_item_list ( ) {
308
328
if let Some ( ident) = attr. ident ( ) {
@@ -441,9 +461,9 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, name: Symbol, items: &[NestedMe
441
461
cx,
442
462
BLANKET_CLIPPY_RESTRICTION_LINTS ,
443
463
lint. span ( ) ,
444
- "restriction lints are not meant to be all enabled" ,
464
+ "`clippy:: restriction` is not meant to be enabled as a group " ,
445
465
None ,
446
- "try enabling only the lints you really need" ,
466
+ "enable the restriction lints you need individually " ,
447
467
) ;
448
468
}
449
469
}
0 commit comments