File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -1105,6 +1105,41 @@ impl LintPass for UnnecessaryParens {
1105
1105
}
1106
1106
}
1107
1107
1108
+ declare_lint ! ( UNNECESSARY_IMPORT_BRACES , Allow ,
1109
+ "unnecessary braces around an imported item" )
1110
+
1111
+ pub struct UnnecessaryImportBraces ;
1112
+
1113
+ impl LintPass for UnnecessaryImportBraces {
1114
+ fn get_lints ( & self ) -> LintArray {
1115
+ lint_array ! ( UNNECESSARY_IMPORT_BRACES )
1116
+ }
1117
+
1118
+ fn check_view_item ( & mut self , cx : & Context , view_item : & ast:: ViewItem ) {
1119
+ match view_item. node {
1120
+ ast:: ViewItemUse ( ref view_path) => {
1121
+ match view_path. node {
1122
+ ast:: ViewPathList ( _, ref items, _) => {
1123
+ if items. len ( ) == 1 {
1124
+ match items[ 0 ] . node {
1125
+ ast:: PathListIdent { ref name, ..} => {
1126
+ let m = format ! ( "braces around {} is unnecessary" ,
1127
+ token:: get_ident( * name) . get( ) ) ;
1128
+ cx. span_lint ( UNNECESSARY_IMPORT_BRACES , view_item. span ,
1129
+ m. as_slice ( ) ) ;
1130
+ } ,
1131
+ _ => ( )
1132
+ }
1133
+ }
1134
+ }
1135
+ _ => ( )
1136
+ }
1137
+ } ,
1138
+ _ => ( )
1139
+ }
1140
+ }
1141
+ }
1142
+
1108
1143
declare_lint ! ( UNUSED_UNSAFE , Warn ,
1109
1144
"unnecessary use of an `unsafe` block" )
1110
1145
Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ impl LintStore {
183
183
NonSnakeCase ,
184
184
NonUppercaseStatics ,
185
185
UnnecessaryParens ,
186
+ UnnecessaryImportBraces ,
186
187
UnusedUnsafe ,
187
188
UnsafeBlock ,
188
189
UnusedMut ,
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ #![ deny( unnecessary_import_braces) ]
12
+ #![ allow( dead_code) ]
13
+ #![ allow( unused_imports) ]
14
+
15
+ use test:: { A } ; //~ ERROR braces around A is unnecessary
16
+
17
+ mod test {
18
+ pub struct A ;
19
+ }
20
+
21
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments