Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3796,7 +3796,6 @@ dependencies = [
"rustc_mir_transform",
"rustc_parse",
"rustc_passes",
"rustc_pattern_analysis",
"rustc_public",
"rustc_resolve",
"rustc_session",
Expand Down Expand Up @@ -4451,7 +4450,6 @@ dependencies = [
"rustc_arena",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
"rustc_hir",
"rustc_index",
"rustc_macros",
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ rustc_mir_build = { path = "../rustc_mir_build" }
rustc_mir_transform = { path = "../rustc_mir_transform" }
rustc_parse = { path = "../rustc_parse" }
rustc_passes = { path = "../rustc_passes" }
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
rustc_public = { path = "../rustc_public", features = ["rustc_internal"] }
rustc_resolve = { path = "../rustc_resolve" }
rustc_session = { path = "../rustc_session" }
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_passes::DEFAULT_LOCALE_RESOURCE,
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
// tidy-alphabetical-end
];
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_pattern_analysis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ rustc_apfloat = "0.2.0"
rustc_arena = { path = "../rustc_arena", optional = true }
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
rustc_errors = { path = "../rustc_errors", optional = true }
rustc_fluent_macro = { path = "../rustc_fluent_macro", optional = true }
rustc_hir = { path = "../rustc_hir", optional = true }
rustc_index = { path = "../rustc_index", default-features = false }
rustc_macros = { path = "../rustc_macros", optional = true }
Expand All @@ -36,7 +35,6 @@ rustc = [
"dep:rustc_arena",
"dep:rustc_data_structures",
"dep:rustc_errors",
"dep:rustc_fluent_macro",
"dep:rustc_hir",
"dep:rustc_macros",
"dep:rustc_middle",
Expand Down
31 changes: 0 additions & 31 deletions compiler/rustc_pattern_analysis/messages.ftl

This file was deleted.

61 changes: 41 additions & 20 deletions compiler/rustc_pattern_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ use rustc_span::Span;
use crate::rustc::{RustcPatCtxt, WitnessPat};

#[derive(Subdiagnostic)]
#[label(pattern_analysis_uncovered)]
#[label(
"{$count ->
[1] pattern `{$witness_1}`
[2] patterns `{$witness_1}` and `{$witness_2}`
[3] patterns `{$witness_1}`, `{$witness_2}` and `{$witness_3}`
*[other] patterns `{$witness_1}`, `{$witness_2}`, `{$witness_3}` and {$remainder} more
} not covered"
)]
pub struct Uncovered {
#[primary_span]
span: Span,
Expand Down Expand Up @@ -40,10 +47,10 @@ impl Uncovered {
}

#[derive(LintDiagnostic)]
#[diag(pattern_analysis_overlapping_range_endpoints)]
#[note]
#[diag("multiple patterns overlap on their endpoints")]
#[note("you likely meant to write mutually exclusive ranges")]
pub struct OverlappingRangeEndpoints {
#[label]
#[label("... with this range")]
pub range: Span,
#[subdiagnostic]
pub overlap: Vec<Overlap>,
Expand All @@ -66,10 +73,14 @@ impl Subdiagnostic for Overlap {
}

#[derive(LintDiagnostic)]
#[diag(pattern_analysis_excluside_range_missing_max)]
#[diag("exclusive range missing `{$max}`")]
pub struct ExclusiveRangeMissingMax {
#[label]
#[suggestion(code = "{suggestion}", applicability = "maybe-incorrect")]
#[label("this range doesn't match `{$max}` because `..` is an exclusive range")]
#[suggestion(
"use an inclusive range instead",
code = "{suggestion}",
applicability = "maybe-incorrect"
)]
/// This is an exclusive range that looks like `lo..max` (i.e. doesn't match `max`).
pub first_range: Span,
/// Suggest `lo..=max` instead.
Expand All @@ -78,10 +89,14 @@ pub struct ExclusiveRangeMissingMax {
}

#[derive(LintDiagnostic)]
#[diag(pattern_analysis_excluside_range_missing_gap)]
#[diag("multiple ranges are one apart")]
pub struct ExclusiveRangeMissingGap {
#[label]
#[suggestion(code = "{suggestion}", applicability = "maybe-incorrect")]
#[label("this range doesn't match `{$gap}` because `..` is an exclusive range")]
#[suggestion(
"use an inclusive range instead",
code = "{suggestion}",
applicability = "maybe-incorrect"
)]
/// This is an exclusive range that looks like `lo..gap` (i.e. doesn't match `gap`).
pub first_range: Span,
pub gap: String, // a printed pattern
Expand Down Expand Up @@ -113,35 +128,41 @@ impl Subdiagnostic for GappedRange {
}

#[derive(LintDiagnostic)]
#[diag(pattern_analysis_non_exhaustive_omitted_pattern)]
#[help]
#[note]
#[diag("some variants are not matched explicitly")]
#[help("ensure that all variants are matched explicitly by adding the suggested match arms")]
#[note(
"the matched value is of type `{$scrut_ty}` and the `non_exhaustive_omitted_patterns` attribute was found"
)]
pub(crate) struct NonExhaustiveOmittedPattern<'tcx> {
pub scrut_ty: Ty<'tcx>,
#[subdiagnostic]
pub uncovered: Uncovered,
}

#[derive(LintDiagnostic)]
#[diag(pattern_analysis_non_exhaustive_omitted_pattern_lint_on_arm)]
#[help]
#[diag("the lint level must be set on the whole match")]
#[help("it no longer has any effect to set the lint level on an individual match arm")]
pub(crate) struct NonExhaustiveOmittedPatternLintOnArm {
#[label]
#[label("remove this attribute")]
pub lint_span: Span,
#[suggestion(code = "#[{lint_level}({lint_name})]\n", applicability = "maybe-incorrect")]
#[suggestion(
"set the lint level on the whole match",
code = "#[{lint_level}({lint_name})]\n",
applicability = "maybe-incorrect"
)]
pub suggest_lint_on_match: Option<Span>,
pub lint_level: &'static str,
pub lint_name: &'static str,
}

#[derive(Diagnostic)]
#[diag(pattern_analysis_mixed_deref_pattern_constructors)]
#[diag("mix of deref patterns and normal constructors")]
pub(crate) struct MixedDerefPatternConstructors<'tcx> {
#[primary_span]
pub spans: Vec<Span>,
pub smart_pointer_ty: Ty<'tcx>,
#[label(pattern_analysis_deref_pattern_label)]
#[label("matches on the result of dereferencing `{$smart_pointer_ty}`")]
pub deref_pattern_label: Span,
#[label(pattern_analysis_normal_constructor_label)]
#[label("matches directly on `{$smart_pointer_ty}`")]
pub normal_constructor_label: Span,
}
3 changes: 0 additions & 3 deletions compiler/rustc_pattern_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ pub mod pat_column;
pub mod rustc;
pub mod usefulness;

#[cfg(feature = "rustc")]
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

use std::fmt;

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