@@ -5,11 +5,13 @@ extern crate syntax;
5
5
6
6
// Load rustc as a plugin to get macros
7
7
extern crate rustc_driver;
8
- #[ macro_use] extern crate rustc_lint;
9
- #[ macro_use] extern crate rustc_session;
8
+ #[ macro_use]
9
+ extern crate rustc_lint;
10
+ #[ macro_use]
11
+ extern crate rustc_session;
10
12
11
- use rustc_lint:: { EarlyContext , EarlyLintPass , LintArray , LintContext , LintPass , LintId } ;
12
13
use rustc_driver:: plugin:: Registry ;
14
+ use rustc_lint:: { EarlyContext , EarlyLintPass , LintArray , LintContext , LintId , LintPass } ;
13
15
use syntax:: ast;
14
16
declare_tool_lint ! ( pub clippy:: TEST_LINT , Warn , "Warn about stuff" ) ;
15
17
declare_tool_lint ! (
@@ -30,10 +32,14 @@ declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]);
30
32
impl EarlyLintPass for Pass {
31
33
fn check_item ( & mut self , cx : & EarlyContext , it : & ast:: Item ) {
32
34
if it. ident . name . as_str ( ) == "lintme" {
33
- cx. span_lint ( TEST_LINT , it. span , "item is named 'lintme'" ) ;
35
+ cx. lint ( TEST_LINT , |lint| {
36
+ lint. build ( "item is named 'lintme'" ) . set_span ( it. span ) . emit ( )
37
+ } ) ;
34
38
}
35
39
if it. ident . name . as_str ( ) == "lintmetoo" {
36
- cx. span_lint ( TEST_GROUP , it. span , "item is named 'lintmetoo'" ) ;
40
+ cx. lint ( TEST_GROUP , |lint| {
41
+ lint. build ( "item is named 'lintmetoo'" ) . set_span ( it. span ) . emit ( )
42
+ } ) ;
37
43
}
38
44
}
39
45
}
@@ -42,6 +48,10 @@ impl EarlyLintPass for Pass {
42
48
pub fn plugin_registrar ( reg : & mut Registry ) {
43
49
reg. lint_store . register_lints ( & [ & TEST_RUSTC_TOOL_LINT , & TEST_LINT , & TEST_GROUP ] ) ;
44
50
reg. lint_store . register_early_pass ( || box Pass ) ;
45
- reg. lint_store . register_group ( true , "clippy::group" , Some ( "clippy_group" ) ,
46
- vec ! [ LintId :: of( & TEST_LINT ) , LintId :: of( & TEST_GROUP ) ] ) ;
51
+ reg. lint_store . register_group (
52
+ true ,
53
+ "clippy::group" ,
54
+ Some ( "clippy_group" ) ,
55
+ vec ! [ LintId :: of( & TEST_LINT ) , LintId :: of( & TEST_GROUP ) ] ,
56
+ ) ;
47
57
}
0 commit comments