@@ -1144,13 +1144,13 @@ impl LateLintPass for GatherNodeLevels {
1144
1144
}
1145
1145
}
1146
1146
1147
- enum CheckLintNameResult < ' a > {
1147
+ enum CheckLintNameResult {
1148
1148
Ok ,
1149
1149
// Lint doesn't exist
1150
1150
NoLint ,
1151
- // The lint is either renamed or removed and a warning was
1152
- // generated in the DiagnosticBuilder
1153
- Mentioned ( DiagnosticBuilder < ' a > )
1151
+ // The lint is either renamed or removed. This is the warning
1152
+ // message.
1153
+ Warning ( String )
1154
1154
}
1155
1155
1156
1156
/// Checks the name of a lint for its existence, and whether it was
@@ -1160,27 +1160,18 @@ enum CheckLintNameResult<'a> {
1160
1160
/// it emits non-fatal warnings and there are *two* lint passes that
1161
1161
/// inspect attributes, this is only run from the late pass to avoid
1162
1162
/// printing duplicate warnings.
1163
- fn check_lint_name < ' a > ( sess : & ' a Session ,
1164
- lint_cx : & LintStore ,
1165
- lint_name : & str ,
1166
- span : Option < Span > ) -> CheckLintNameResult < ' a > {
1163
+ fn check_lint_name ( lint_cx : & LintStore ,
1164
+ lint_name : & str ) -> CheckLintNameResult {
1167
1165
match lint_cx. by_name . get ( lint_name) {
1168
1166
Some ( & Renamed ( ref new_name, _) ) => {
1169
- let warning = format ! ( "lint {} has been renamed to {}" ,
1170
- lint_name, new_name) ;
1171
- let db = match span {
1172
- Some ( span) => sess. struct_span_warn ( span, & warning[ ..] ) ,
1173
- None => sess. struct_warn ( & warning[ ..] ) ,
1174
- } ;
1175
- CheckLintNameResult :: Mentioned ( db)
1167
+ CheckLintNameResult :: Warning (
1168
+ format ! ( "lint {} has been renamed to {}" , lint_name, new_name)
1169
+ )
1176
1170
} ,
1177
1171
Some ( & Removed ( ref reason) ) => {
1178
- let warning = format ! ( "lint {} has been removed: {}" , lint_name, reason) ;
1179
- let db = match span {
1180
- Some ( span) => sess. struct_span_warn ( span, & warning[ ..] ) ,
1181
- None => sess. struct_warn ( & warning[ ..] )
1182
- } ;
1183
- CheckLintNameResult :: Mentioned ( db)
1172
+ CheckLintNameResult :: Warning (
1173
+ format ! ( "lint {} has been removed: {}" , lint_name, reason)
1174
+ )
1184
1175
} ,
1185
1176
None => {
1186
1177
match lint_cx. lint_groups . get ( lint_name) {
@@ -1209,10 +1200,12 @@ fn check_lint_name_attribute(cx: &LateContext, attr: &ast::Attribute) {
1209
1200
continue ;
1210
1201
}
1211
1202
Ok ( ( lint_name, _, span) ) => {
1212
- match check_lint_name ( & cx. tcx . sess , & cx. lints , & lint_name[ ..] , Some ( span) ) {
1203
+ match check_lint_name ( & cx. lints ,
1204
+ & lint_name[ ..] ) {
1213
1205
CheckLintNameResult :: Ok => ( ) ,
1214
- CheckLintNameResult :: Mentioned ( mut db) => {
1215
- db. emit ( ) ;
1206
+ CheckLintNameResult :: Warning ( ref msg) => {
1207
+ cx. span_lint ( builtin:: RENAMED_AND_REMOVED_LINTS ,
1208
+ span, msg) ;
1216
1209
}
1217
1210
CheckLintNameResult :: NoLint => {
1218
1211
cx. span_lint ( builtin:: UNKNOWN_LINTS , span,
@@ -1228,9 +1221,11 @@ fn check_lint_name_attribute(cx: &LateContext, attr: &ast::Attribute) {
1228
1221
// Checks the validity of lint names derived from the command line
1229
1222
fn check_lint_name_cmdline ( sess : & Session , lint_cx : & LintStore ,
1230
1223
lint_name : & str , level : Level ) {
1231
- let db = match check_lint_name ( sess , lint_cx, lint_name, None ) {
1224
+ let db = match check_lint_name ( lint_cx, lint_name) {
1232
1225
CheckLintNameResult :: Ok => None ,
1233
- CheckLintNameResult :: Mentioned ( db) => Some ( db) ,
1226
+ CheckLintNameResult :: Warning ( ref msg) => {
1227
+ Some ( sess. struct_warn ( msg) )
1228
+ } ,
1234
1229
CheckLintNameResult :: NoLint => {
1235
1230
Some ( sess. struct_err ( & format ! ( "unknown lint: `{}`" , lint_name) ) )
1236
1231
}
0 commit comments