|
17 | 17 | use self::TargetLint::*; |
18 | 18 |
|
19 | 19 | use crate::errors::{ |
20 | | - CheckNameDeprecated, CheckNameUnknown, CheckNameUnknownTool, CheckNameWarning, RequestedLevel, |
21 | | - UnsupportedGroup, |
| 20 | + CheckNameDeprecated, CheckNameRemoved, CheckNameRenamed, CheckNameUnknown, |
| 21 | + CheckNameUnknownTool, RequestedLevel, UnsupportedGroup, |
22 | 22 | }; |
23 | 23 | use crate::levels::LintLevelsBuilder; |
24 | 24 | use crate::passes::{EarlyLintPassObject, LateLintPassObject}; |
@@ -124,9 +124,10 @@ pub enum CheckLintNameResult<'a> { |
124 | 124 | NoLint(Option<Symbol>), |
125 | 125 | /// The lint refers to a tool that has not been registered. |
126 | 126 | NoTool, |
127 | | - /// The lint is either renamed or removed. This is the warning |
128 | | - /// message, and an optional new name (`None` if removed). |
129 | | - Warning(String, Option<String>), |
| 127 | + /// The lint has been renamed to a new name. |
| 128 | + Renamed(String), |
| 129 | + /// The lint has been removed due to the given reason. |
| 130 | + Removed(String), |
130 | 131 | /// The lint is from a tool. If the Option is None, then either |
131 | 132 | /// the lint does not exist in the tool or the code was not |
132 | 133 | /// compiled with the tool and therefore the lint was never |
@@ -344,9 +345,17 @@ impl LintStore { |
344 | 345 | } |
345 | 346 | let lint_name = lint_name.to_string(); |
346 | 347 | match self.check_lint_name(lint_name_only, tool_name, registered_tools) { |
347 | | - CheckLintNameResult::Warning(msg, _) => { |
348 | | - sess.emit_warning(CheckNameWarning { |
349 | | - msg, |
| 348 | + CheckLintNameResult::Renamed(replace) => { |
| 349 | + sess.emit_warning(CheckNameRenamed { |
| 350 | + lint_name: lint_name.clone(), |
| 351 | + replace, |
| 352 | + sub: RequestedLevel { level, lint_name }, |
| 353 | + }); |
| 354 | + } |
| 355 | + CheckLintNameResult::Removed(reason) => { |
| 356 | + sess.emit_warning(CheckNameRemoved { |
| 357 | + lint_name: lint_name.clone(), |
| 358 | + reason, |
350 | 359 | sub: RequestedLevel { level, lint_name }, |
351 | 360 | }); |
352 | 361 | } |
@@ -445,14 +454,8 @@ impl LintStore { |
445 | 454 | } |
446 | 455 | } |
447 | 456 | match self.by_name.get(&complete_name) { |
448 | | - Some(Renamed(new_name, _)) => CheckLintNameResult::Warning( |
449 | | - format!("lint `{complete_name}` has been renamed to `{new_name}`"), |
450 | | - Some(new_name.to_owned()), |
451 | | - ), |
452 | | - Some(Removed(reason)) => CheckLintNameResult::Warning( |
453 | | - format!("lint `{complete_name}` has been removed: {reason}"), |
454 | | - None, |
455 | | - ), |
| 457 | + Some(Renamed(new_name, _)) => CheckLintNameResult::Renamed(new_name.to_string()), |
| 458 | + Some(Removed(reason)) => CheckLintNameResult::Removed(reason.to_string()), |
456 | 459 | None => match self.lint_groups.get(&*complete_name) { |
457 | 460 | // If neither the lint, nor the lint group exists check if there is a `clippy::` |
458 | 461 | // variant of this lint |
|
0 commit comments