Skip to content

Commit 827f87c

Browse files
authored
Unrolled build for #152070
Rollup merge of #152070 - JonathanBrouwer:convert_pattern_analysis, r=jdonszelmann Convert to inline diagnostics in `rustc_pattern_analysis` For #151366 r? @jdonszelmann
2 parents 0a13b43 + 67c6cd9 commit 827f87c

File tree

7 files changed

+41
-60
lines changed

7 files changed

+41
-60
lines changed

‎Cargo.lock‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,7 +3796,6 @@ dependencies = [
37963796
"rustc_mir_transform",
37973797
"rustc_parse",
37983798
"rustc_passes",
3799-
"rustc_pattern_analysis",
38003799
"rustc_public",
38013800
"rustc_resolve",
38023801
"rustc_session",
@@ -4451,7 +4450,6 @@ dependencies = [
44514450
"rustc_arena",
44524451
"rustc_data_structures",
44534452
"rustc_errors",
4454-
"rustc_fluent_macro",
44554453
"rustc_hir",
44564454
"rustc_index",
44574455
"rustc_macros",

‎compiler/rustc_driver_impl/Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ rustc_mir_build = { path = "../rustc_mir_build" }
3333
rustc_mir_transform = { path = "../rustc_mir_transform" }
3434
rustc_parse = { path = "../rustc_parse" }
3535
rustc_passes = { path = "../rustc_passes" }
36-
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
3736
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
3837
rustc_resolve = { path = "../rustc_resolve" }
3938
rustc_session = { path = "../rustc_session" }

‎compiler/rustc_driver_impl/src/lib.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
125125
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
126126
rustc_parse::DEFAULT_LOCALE_RESOURCE,
127127
rustc_passes::DEFAULT_LOCALE_RESOURCE,
128-
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
129128
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
130129
// tidy-alphabetical-end
131130
];

‎compiler/rustc_pattern_analysis/Cargo.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ rustc_apfloat = "0.2.0"
1111
rustc_arena = { path = "../rustc_arena", optional = true }
1212
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
1313
rustc_errors = { path = "../rustc_errors", optional = true }
14-
rustc_fluent_macro = { path = "../rustc_fluent_macro", optional = true }
1514
rustc_hir = { path = "../rustc_hir", optional = true }
1615
rustc_index = { path = "../rustc_index", default-features = false }
1716
rustc_macros = { path = "../rustc_macros", optional = true }
@@ -36,7 +35,6 @@ rustc = [
3635
"dep:rustc_arena",
3736
"dep:rustc_data_structures",
3837
"dep:rustc_errors",
39-
"dep:rustc_fluent_macro",
4038
"dep:rustc_hir",
4139
"dep:rustc_macros",
4240
"dep:rustc_middle",

‎compiler/rustc_pattern_analysis/messages.ftl‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎compiler/rustc_pattern_analysis/src/errors.rs‎

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ use rustc_span::Span;
66
use crate::rustc::{RustcPatCtxt, WitnessPat};
77

88
#[derive(Subdiagnostic)]
9-
#[label(pattern_analysis_uncovered)]
9+
#[label(
10+
"{$count ->
11+
[1] pattern `{$witness_1}`
12+
[2] patterns `{$witness_1}` and `{$witness_2}`
13+
[3] patterns `{$witness_1}`, `{$witness_2}` and `{$witness_3}`
14+
*[other] patterns `{$witness_1}`, `{$witness_2}`, `{$witness_3}` and {$remainder} more
15+
} not covered"
16+
)]
1017
pub struct Uncovered {
1118
#[primary_span]
1219
span: Span,
@@ -40,10 +47,10 @@ impl Uncovered {
4047
}
4148

4249
#[derive(LintDiagnostic)]
43-
#[diag(pattern_analysis_overlapping_range_endpoints)]
44-
#[note]
50+
#[diag("multiple patterns overlap on their endpoints")]
51+
#[note("you likely meant to write mutually exclusive ranges")]
4552
pub struct OverlappingRangeEndpoints {
46-
#[label]
53+
#[label("... with this range")]
4754
pub range: Span,
4855
#[subdiagnostic]
4956
pub overlap: Vec<Overlap>,
@@ -66,10 +73,14 @@ impl Subdiagnostic for Overlap {
6673
}
6774

6875
#[derive(LintDiagnostic)]
69-
#[diag(pattern_analysis_excluside_range_missing_max)]
76+
#[diag("exclusive range missing `{$max}`")]
7077
pub struct ExclusiveRangeMissingMax {
71-
#[label]
72-
#[suggestion(code = "{suggestion}", applicability = "maybe-incorrect")]
78+
#[label("this range doesn't match `{$max}` because `..` is an exclusive range")]
79+
#[suggestion(
80+
"use an inclusive range instead",
81+
code = "{suggestion}",
82+
applicability = "maybe-incorrect"
83+
)]
7384
/// This is an exclusive range that looks like `lo..max` (i.e. doesn't match `max`).
7485
pub first_range: Span,
7586
/// Suggest `lo..=max` instead.
@@ -78,10 +89,14 @@ pub struct ExclusiveRangeMissingMax {
7889
}
7990

8091
#[derive(LintDiagnostic)]
81-
#[diag(pattern_analysis_excluside_range_missing_gap)]
92+
#[diag("multiple ranges are one apart")]
8293
pub struct ExclusiveRangeMissingGap {
83-
#[label]
84-
#[suggestion(code = "{suggestion}", applicability = "maybe-incorrect")]
94+
#[label("this range doesn't match `{$gap}` because `..` is an exclusive range")]
95+
#[suggestion(
96+
"use an inclusive range instead",
97+
code = "{suggestion}",
98+
applicability = "maybe-incorrect"
99+
)]
85100
/// This is an exclusive range that looks like `lo..gap` (i.e. doesn't match `gap`).
86101
pub first_range: Span,
87102
pub gap: String, // a printed pattern
@@ -113,35 +128,41 @@ impl Subdiagnostic for GappedRange {
113128
}
114129

115130
#[derive(LintDiagnostic)]
116-
#[diag(pattern_analysis_non_exhaustive_omitted_pattern)]
117-
#[help]
118-
#[note]
131+
#[diag("some variants are not matched explicitly")]
132+
#[help("ensure that all variants are matched explicitly by adding the suggested match arms")]
133+
#[note(
134+
"the matched value is of type `{$scrut_ty}` and the `non_exhaustive_omitted_patterns` attribute was found"
135+
)]
119136
pub(crate) struct NonExhaustiveOmittedPattern<'tcx> {
120137
pub scrut_ty: Ty<'tcx>,
121138
#[subdiagnostic]
122139
pub uncovered: Uncovered,
123140
}
124141

125142
#[derive(LintDiagnostic)]
126-
#[diag(pattern_analysis_non_exhaustive_omitted_pattern_lint_on_arm)]
127-
#[help]
143+
#[diag("the lint level must be set on the whole match")]
144+
#[help("it no longer has any effect to set the lint level on an individual match arm")]
128145
pub(crate) struct NonExhaustiveOmittedPatternLintOnArm {
129-
#[label]
146+
#[label("remove this attribute")]
130147
pub lint_span: Span,
131-
#[suggestion(code = "#[{lint_level}({lint_name})]\n", applicability = "maybe-incorrect")]
148+
#[suggestion(
149+
"set the lint level on the whole match",
150+
code = "#[{lint_level}({lint_name})]\n",
151+
applicability = "maybe-incorrect"
152+
)]
132153
pub suggest_lint_on_match: Option<Span>,
133154
pub lint_level: &'static str,
134155
pub lint_name: &'static str,
135156
}
136157

137158
#[derive(Diagnostic)]
138-
#[diag(pattern_analysis_mixed_deref_pattern_constructors)]
159+
#[diag("mix of deref patterns and normal constructors")]
139160
pub(crate) struct MixedDerefPatternConstructors<'tcx> {
140161
#[primary_span]
141162
pub spans: Vec<Span>,
142163
pub smart_pointer_ty: Ty<'tcx>,
143-
#[label(pattern_analysis_deref_pattern_label)]
164+
#[label("matches on the result of dereferencing `{$smart_pointer_ty}`")]
144165
pub deref_pattern_label: Span,
145-
#[label(pattern_analysis_normal_constructor_label)]
166+
#[label("matches directly on `{$smart_pointer_ty}`")]
146167
pub normal_constructor_label: Span,
147168
}

‎compiler/rustc_pattern_analysis/src/lib.rs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ pub mod pat_column;
1919
pub mod rustc;
2020
pub mod usefulness;
2121

22-
#[cfg(feature = "rustc")]
23-
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
24-
2522
use std::fmt;
2623

2724
pub use rustc_index::{Idx, IndexVec}; // re-exported to avoid rustc_index version issues

0 commit comments

Comments
 (0)