Skip to content

Commit 2e15053

Browse files
committed
Rename DiagnosticMode as DiagMode.
1 parent e1fc5ad commit 2e15053

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
@@ -185,7 +185,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
185185
&candidates,
186186
if instead { Instead::Yes } else { Instead::No },
187187
found_use,
188-
DiagnosticMode::Normal,
188+
DiagMode::Normal,
189189
path,
190190
"",
191191
);
@@ -720,7 +720,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
720720
&import_suggestions,
721721
Instead::No,
722722
FoundUse::Yes,
723-
DiagnosticMode::Pattern,
723+
DiagMode::Pattern,
724724
vec![],
725725
"",
726726
);
@@ -1441,7 +1441,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14411441
&import_suggestions,
14421442
Instead::No,
14431443
found_use,
1444-
DiagnosticMode::Normal,
1444+
DiagMode::Normal,
14451445
vec![],
14461446
"",
14471447
);
@@ -1754,7 +1754,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17541754
&import_suggestions,
17551755
Instead::Yes,
17561756
FoundUse::Yes,
1757-
DiagnosticMode::Import,
1757+
DiagMode::Import,
17581758
vec![],
17591759
"",
17601760
);
@@ -2675,7 +2675,7 @@ enum FoundUse {
26752675
}
26762676

26772677
/// Whether a binding is part of a pattern or a use statement. Used for diagnostics.
2678-
pub(crate) enum DiagnosticMode {
2678+
pub(crate) enum DiagMode {
26792679
Normal,
26802680
/// The binding is part of a pattern
26812681
Pattern,
@@ -2689,7 +2689,7 @@ pub(crate) fn import_candidates(
26892689
// This is `None` if all placement locations are inside expansions
26902690
use_placement_span: Option<Span>,
26912691
candidates: &[ImportSuggestion],
2692-
mode: DiagnosticMode,
2692+
mode: DiagMode,
26932693
append: &str,
26942694
) {
26952695
show_candidates(
@@ -2717,7 +2717,7 @@ fn show_candidates(
27172717
candidates: &[ImportSuggestion],
27182718
instead: Instead,
27192719
found_use: FoundUse,
2720-
mode: DiagnosticMode,
2720+
mode: DiagMode,
27212721
path: Vec<Segment>,
27222722
append: &str,
27232723
) -> bool {
@@ -2778,7 +2778,7 @@ fn show_candidates(
27782778
};
27792779

27802780
let instead = if let Instead::Yes = instead { " instead" } else { "" };
2781-
let mut msg = if let DiagnosticMode::Pattern = mode {
2781+
let mut msg = if let DiagMode::Pattern = mode {
27822782
format!(
27832783
"if you meant to match on {kind}{instead}{name}, use the full path in the pattern",
27842784
)
@@ -2792,7 +2792,7 @@ fn show_candidates(
27922792

27932793
if let Some(span) = use_placement_span {
27942794
let (add_use, trailing) = match mode {
2795-
DiagnosticMode::Pattern => {
2795+
DiagMode::Pattern => {
27962796
err.span_suggestions(
27972797
span,
27982798
msg,
@@ -2801,14 +2801,14 @@ fn show_candidates(
28012801
);
28022802
return true;
28032803
}
2804-
DiagnosticMode::Import => ("", ""),
2805-
DiagnosticMode::Normal => ("use ", ";\n"),
2804+
DiagMode::Import => ("", ""),
2805+
DiagMode::Normal => ("use ", ";\n"),
28062806
};
28072807
for candidate in &mut accessible_path_strings {
28082808
// produce an additional newline to separate the new use statement
28092809
// from the directly following item.
28102810
let additional_newline = if let FoundUse::No = found_use
2811-
&& let DiagnosticMode::Normal = mode
2811+
&& let DiagMode::Normal = mode
28122812
{
28132813
"\n"
28142814
} else {
@@ -2849,16 +2849,13 @@ fn show_candidates(
28492849
err.help(msg);
28502850
}
28512851
true
2852-
} else if !(inaccessible_path_strings.is_empty() || matches!(mode, DiagnosticMode::Import)) {
2853-
let prefix = if let DiagnosticMode::Pattern = mode {
2854-
"you might have meant to match on "
2855-
} else {
2856-
""
2857-
};
2852+
} else if !(inaccessible_path_strings.is_empty() || matches!(mode, DiagMode::Import)) {
2853+
let prefix =
2854+
if let DiagMode::Pattern = mode { "you might have meant to match on " } else { "" };
28582855
if let [(name, descr, def_id, note, _)] = &inaccessible_path_strings[..] {
28592856
let msg = format!(
28602857
"{prefix}{descr} `{name}`{} exists but is inaccessible",
2861-
if let DiagnosticMode::Pattern = mode { ", which" } else { "" }
2858+
if let DiagMode::Pattern = mode { ", which" } else { "" }
28622859
);
28632860

28642861
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)