@@ -11,14 +11,14 @@ use rustc_errors::Applicability;
1111use rustc_hir:: {
1212 Block , Expr , ExprKind , ImplItem , ImplItemKind , Item , ItemKind , StmtKind , TraitFn , TraitItem , TraitItemKind ,
1313} ;
14- use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintContext } ;
14+ use rustc_lint:: { EarlyContext , EarlyLintPass , LateContext , LateLintPass , Level , LintContext } ;
1515use rustc_middle:: lint:: in_external_macro;
1616use rustc_middle:: ty;
1717use rustc_semver:: RustcVersion ;
1818use rustc_session:: { declare_lint_pass, declare_tool_lint, impl_lint_pass} ;
1919use rustc_span:: source_map:: Span ;
20- use rustc_span:: sym;
2120use rustc_span:: symbol:: Symbol ;
21+ use rustc_span:: { sym, DUMMY_SP } ;
2222use semver:: Version ;
2323
2424static UNIX_SYSTEMS : & [ & str ] = & [
@@ -303,6 +303,26 @@ declare_lint_pass!(Attributes => [
303303] ) ;
304304
305305impl < ' 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+
306326 fn check_attribute ( & mut self , cx : & LateContext < ' tcx > , attr : & ' tcx Attribute ) {
307327 if let Some ( items) = & attr. meta_item_list ( ) {
308328 if let Some ( ident) = attr. ident ( ) {
@@ -441,9 +461,9 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, name: Symbol, items: &[NestedMe
441461 cx,
442462 BLANKET_CLIPPY_RESTRICTION_LINTS ,
443463 lint. span ( ) ,
444- "restriction lints are not meant to be all enabled" ,
464+ "`clippy:: restriction` is not meant to be enabled as a group " ,
445465 None ,
446- "try enabling only the lints you really need" ,
466+ "enable the restriction lints you need individually " ,
447467 ) ;
448468 }
449469 }
0 commit comments