Skip to content

Commit 023d1b9

Browse files
committed
Tweak CheckLintNameResult::Tool.
The `String` only makes sense alongside the `&'a [LintId]`, so this commit moves it inside the `Option`, avoiding the need for a `String::new` in one place.
1 parent cd3528f commit 023d1b9

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

compiler/rustc_lint/src/context.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub enum CheckLintNameResult<'a> {
131131
/// compiled with the tool and therefore the lint was never
132132
/// added to the `LintStore`. Otherwise the `LintId` will be
133133
/// returned as if it where a rustc lint.
134-
Tool(Result<&'a [LintId], (Option<&'a [LintId]>, String)>),
134+
Tool(Result<&'a [LintId], Option<(&'a [LintId], String)>>),
135135
}
136136

137137
impl LintStore {
@@ -384,7 +384,7 @@ impl LintStore {
384384
} else {
385385
// 2. The tool isn't currently running, so no lints will be registered.
386386
// To avoid giving a false positive, ignore all unknown lints.
387-
CheckLintNameResult::Tool(Err((None, String::new())))
387+
CheckLintNameResult::Tool(Err(None))
388388
};
389389
}
390390
Some(LintGroup { lint_ids, .. }) => {
@@ -411,7 +411,7 @@ impl LintStore {
411411
return if *silent {
412412
CheckLintNameResult::Ok(lint_ids)
413413
} else {
414-
CheckLintNameResult::Tool(Err((Some(lint_ids), (*name).to_string())))
414+
CheckLintNameResult::Tool(Err(Some((lint_ids, (*name).to_string()))))
415415
};
416416
}
417417
CheckLintNameResult::Ok(lint_ids)
@@ -473,16 +473,17 @@ impl LintStore {
473473
if let Some(LintAlias { name, silent }) = depr {
474474
let LintGroup { lint_ids, .. } = self.lint_groups.get(name).unwrap();
475475
return if *silent {
476-
CheckLintNameResult::Tool(Err((Some(lint_ids), complete_name)))
476+
// njn: factor
477+
CheckLintNameResult::Tool(Err(Some((lint_ids, complete_name))))
477478
} else {
478-
CheckLintNameResult::Tool(Err((Some(lint_ids), (*name).to_string())))
479+
CheckLintNameResult::Tool(Err(Some((lint_ids, (*name).to_string()))))
479480
};
480481
}
481-
CheckLintNameResult::Tool(Err((Some(lint_ids), complete_name)))
482+
CheckLintNameResult::Tool(Err(Some((lint_ids, complete_name))))
482483
}
483484
},
484485
Some(Id(id)) => {
485-
CheckLintNameResult::Tool(Err((Some(slice::from_ref(id)), complete_name)))
486+
CheckLintNameResult::Tool(Err(Some((slice::from_ref(id), complete_name))))
486487
}
487488
Some(other) => {
488489
debug!("got renamed lint {:?}", other);

compiler/rustc_lint/src/levels.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
591591
let lint = UnknownLintFromCommandLine { name, suggestion, requested_level };
592592
self.emit_lint(UNKNOWN_LINTS, lint);
593593
}
594-
CheckLintNameResult::Tool(Err((Some(_), ref replace))) => {
594+
CheckLintNameResult::Tool(Err(Some((_, ref replace)))) => {
595595
let name = lint_name.clone();
596596
let requested_level = RequestedLevel { level, lint_name };
597597
let lint = DeprecatedLintNameFromCommandLine { name, replace, requested_level };
@@ -919,7 +919,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
919919
);
920920
}
921921
}
922-
Err((Some(ids), ref new_lint_name)) => {
922+
Err(Some((ids, ref new_lint_name))) => {
923923
let lint = builtin::RENAMED_AND_REMOVED_LINTS;
924924
self.emit_span_lint(
925925
lint,
@@ -946,8 +946,8 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
946946
);
947947
}
948948
}
949-
Err((None, _)) => {
950-
// If Tool(Err(None, _)) is returned, then either the lint does not
949+
Err(None) => {
950+
// If Tool(Err(None)) is returned, then either the lint does not
951951
// exist in the tool or the code was not compiled with the tool and
952952
// therefore the lint was never added to the `LintStore`. To detect
953953
// this is the responsibility of the lint tool.

0 commit comments

Comments
 (0)