Skip to content

Commit d0e9bab

Browse files
committed
Rename DiagnosticMode as DiagMode.
1 parent 573267c commit d0e9bab

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
188188
&candidates,
189189
if instead { Instead::Yes } else { Instead::No },
190190
found_use,
191-
DiagnosticMode::Normal,
191+
DiagMode::Normal,
192192
path,
193193
"",
194194
);
@@ -723,7 +723,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
723723
&import_suggestions,
724724
Instead::No,
725725
FoundUse::Yes,
726-
DiagnosticMode::Pattern,
726+
DiagMode::Pattern,
727727
vec![],
728728
"",
729729
);
@@ -1444,7 +1444,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14441444
&import_suggestions,
14451445
Instead::No,
14461446
found_use,
1447-
DiagnosticMode::Normal,
1447+
DiagMode::Normal,
14481448
vec![],
14491449
"",
14501450
);
@@ -1775,7 +1775,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17751775
&import_suggestions,
17761776
Instead::Yes,
17771777
FoundUse::Yes,
1778-
DiagnosticMode::Import,
1778+
DiagMode::Import,
17791779
vec![],
17801780
"",
17811781
);
@@ -2696,7 +2696,7 @@ enum FoundUse {
26962696
}
26972697

26982698
/// Whether a binding is part of a pattern or a use statement. Used for diagnostics.
2699-
pub(crate) enum DiagnosticMode {
2699+
pub(crate) enum DiagMode {
27002700
Normal,
27012701
/// The binding is part of a pattern
27022702
Pattern,
@@ -2710,7 +2710,7 @@ pub(crate) fn import_candidates(
27102710
// This is `None` if all placement locations are inside expansions
27112711
use_placement_span: Option<Span>,
27122712
candidates: &[ImportSuggestion],
2713-
mode: DiagnosticMode,
2713+
mode: DiagMode,
27142714
append: &str,
27152715
) {
27162716
show_candidates(
@@ -2738,7 +2738,7 @@ fn show_candidates(
27382738
candidates: &[ImportSuggestion],
27392739
instead: Instead,
27402740
found_use: FoundUse,
2741-
mode: DiagnosticMode,
2741+
mode: DiagMode,
27422742
path: Vec<Segment>,
27432743
append: &str,
27442744
) -> bool {
@@ -2799,7 +2799,7 @@ fn show_candidates(
27992799
};
28002800

28012801
let instead = if let Instead::Yes = instead { " instead" } else { "" };
2802-
let mut msg = if let DiagnosticMode::Pattern = mode {
2802+
let mut msg = if let DiagMode::Pattern = mode {
28032803
format!(
28042804
"if you meant to match on {kind}{instead}{name}, use the full path in the pattern",
28052805
)
@@ -2813,7 +2813,7 @@ fn show_candidates(
28132813

28142814
if let Some(span) = use_placement_span {
28152815
let (add_use, trailing) = match mode {
2816-
DiagnosticMode::Pattern => {
2816+
DiagMode::Pattern => {
28172817
err.span_suggestions(
28182818
span,
28192819
msg,
@@ -2822,14 +2822,14 @@ fn show_candidates(
28222822
);
28232823
return true;
28242824
}
2825-
DiagnosticMode::Import => ("", ""),
2826-
DiagnosticMode::Normal => ("use ", ";\n"),
2825+
DiagMode::Import => ("", ""),
2826+
DiagMode::Normal => ("use ", ";\n"),
28272827
};
28282828
for candidate in &mut accessible_path_strings {
28292829
// produce an additional newline to separate the new use statement
28302830
// from the directly following item.
28312831
let additional_newline = if let FoundUse::No = found_use
2832-
&& let DiagnosticMode::Normal = mode
2832+
&& let DiagMode::Normal = mode
28332833
{
28342834
"\n"
28352835
} else {
@@ -2870,16 +2870,13 @@ fn show_candidates(
28702870
err.help(msg);
28712871
}
28722872
true
2873-
} else if !(inaccessible_path_strings.is_empty() || matches!(mode, DiagnosticMode::Import)) {
2874-
let prefix = if let DiagnosticMode::Pattern = mode {
2875-
"you might have meant to match on "
2876-
} else {
2877-
""
2878-
};
2873+
} else if !(inaccessible_path_strings.is_empty() || matches!(mode, DiagMode::Import)) {
2874+
let prefix =
2875+
if let DiagMode::Pattern = mode { "you might have meant to match on " } else { "" };
28792876
if let [(name, descr, def_id, note, _)] = &inaccessible_path_strings[..] {
28802877
let msg = format!(
28812878
"{prefix}{descr} `{name}`{} exists but is inaccessible",
2882-
if let DiagnosticMode::Pattern = mode { ", which" } else { "" }
2879+
if let DiagMode::Pattern = mode { ", which" } else { "" }
28832880
);
28842881

28852882
if let Some(local_def_id) = def_id.and_then(|did| did.as_local()) {

compiler/rustc_resolve/src/imports.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! A bunch of methods and structures more or less related to resolving imports.
22
3-
use crate::diagnostics::{import_candidates, DiagnosticMode, Suggestion};
3+
use crate::diagnostics::{import_candidates, DiagMode, Suggestion};
44
use crate::errors::{
55
CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS, CannotBeReexportedPrivate,
66
CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates,
@@ -716,7 +716,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
716716
&mut diag,
717717
Some(err.span),
718718
candidates,
719-
DiagnosticMode::Import,
719+
DiagMode::Import,
720720
(source != target)
721721
.then(|| format!(" as {target}"))
722722
.as_deref()
@@ -728,7 +728,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
728728
&mut diag,
729729
None,
730730
candidates,
731-
DiagnosticMode::Normal,
731+
DiagMode::Normal,
732732
(source != target)
733733
.then(|| format!(" as {target}"))
734734
.as_deref()

0 commit comments

Comments
 (0)