|
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 |
@@ -342,25 +343,32 @@ impl LintStore { |
342 | 343 | sess.emit_err(UnsupportedGroup { lint_group: crate::WARNINGS.name_lower() }); |
343 | 344 | return; |
344 | 345 | } |
345 | | - let lint_name = lint_name.to_string(); |
346 | 346 | match self.check_lint_name(lint_name_only, tool_name, registered_tools) { |
347 | | - CheckLintNameResult::Warning(msg, _) => { |
348 | | - sess.emit_warning(CheckNameWarning { |
349 | | - msg, |
| 347 | + CheckLintNameResult::Renamed(replace) => { |
| 348 | + sess.emit_warning(CheckNameRenamed { |
| 349 | + lint_name, |
| 350 | + replace: &replace, |
| 351 | + sub: RequestedLevel { level, lint_name }, |
| 352 | + }); |
| 353 | + } |
| 354 | + CheckLintNameResult::Removed(reason) => { |
| 355 | + sess.emit_warning(CheckNameRemoved { |
| 356 | + lint_name, |
| 357 | + reason: &reason, |
350 | 358 | sub: RequestedLevel { level, lint_name }, |
351 | 359 | }); |
352 | 360 | } |
353 | 361 | CheckLintNameResult::NoLint(suggestion) => { |
354 | 362 | sess.emit_err(CheckNameUnknown { |
355 | | - lint_name: lint_name.clone(), |
| 363 | + lint_name, |
356 | 364 | suggestion, |
357 | 365 | sub: RequestedLevel { level, lint_name }, |
358 | 366 | }); |
359 | 367 | } |
360 | 368 | CheckLintNameResult::Tool(Err((Some(_), new_name))) => { |
361 | 369 | sess.emit_warning(CheckNameDeprecated { |
362 | | - lint_name: lint_name.clone(), |
363 | | - new_name, |
| 370 | + lint_name, |
| 371 | + new_name: &new_name, |
364 | 372 | sub: RequestedLevel { level, lint_name }, |
365 | 373 | }); |
366 | 374 | } |
@@ -445,14 +453,8 @@ impl LintStore { |
445 | 453 | } |
446 | 454 | } |
447 | 455 | 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 | | - ), |
| 456 | + Some(Renamed(new_name, _)) => CheckLintNameResult::Renamed(new_name.to_string()), |
| 457 | + Some(Removed(reason)) => CheckLintNameResult::Removed(reason.to_string()), |
456 | 458 | None => match self.lint_groups.get(&*complete_name) { |
457 | 459 | // If neither the lint, nor the lint group exists check if there is a `clippy::` |
458 | 460 | // variant of this lint |
|
0 commit comments