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
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4262,7 +4262,6 @@ dependencies = [
"rustc_error_messages",
"rustc_errors",
"rustc_feature",
"rustc_fluent_macro",
"rustc_graphviz",
"rustc_hashes",
"rustc_hir",
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 @@ -121,7 +121,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
rustc_errors::DEFAULT_LOCALE_RESOURCE,
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
rustc_lint::DEFAULT_LOCALE_RESOURCE,
rustc_middle::DEFAULT_LOCALE_RESOURCE,
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_passes::DEFAULT_LOCALE_RESOURCE,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_graphviz = { path = "../rustc_graphviz" }
rustc_hashes = { path = "../rustc_hashes" }
rustc_hir = { path = "../rustc_hir" }
Expand Down
133 changes: 0 additions & 133 deletions compiler/rustc_middle/messages.ftl

This file was deleted.

66 changes: 36 additions & 30 deletions compiler/rustc_middle/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use rustc_span::{Span, Symbol};
use crate::ty::{Instance, Ty};

#[derive(Diagnostic)]
#[diag(middle_drop_check_overflow, code = E0320)]
#[note]
#[diag("overflow while adding drop-check rules for `{$ty}`", code = E0320)]
#[note("overflowed on `{$overflow_ty}`")]
pub(crate) struct DropCheckOverflow<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -19,33 +19,33 @@ pub(crate) struct DropCheckOverflow<'tcx> {
}

#[derive(Diagnostic)]
#[diag(middle_failed_writing_file)]
#[diag("failed to write file {$path}: {$error}\"")]
pub(crate) struct FailedWritingFile<'a> {
pub path: &'a Path,
pub error: io::Error,
}

#[derive(Diagnostic)]
#[diag(middle_opaque_hidden_type_mismatch)]
#[diag("concrete type differs from previous defining opaque type use")]
pub(crate) struct OpaqueHiddenTypeMismatch<'tcx> {
pub self_ty: Ty<'tcx>,
pub other_ty: Ty<'tcx>,
#[primary_span]
#[label]
#[label("expected `{$self_ty}`, got `{$other_ty}`")]
pub other_span: Span,
#[subdiagnostic]
pub sub: TypeMismatchReason,
}

#[derive(Diagnostic)]
#[diag(middle_unsupported_union)]
#[diag("we don't support unions yet: '{$ty_name}'")]
pub struct UnsupportedUnion {
pub ty_name: String,
}

// FIXME(autodiff): I should get used somewhere
#[derive(Diagnostic)]
#[diag(middle_autodiff_unsafe_inner_const_ref)]
#[diag("reading from a `Duplicated` const {$ty} is unsafe")]
pub struct AutodiffUnsafeInnerConstRef<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -54,21 +54,23 @@ pub struct AutodiffUnsafeInnerConstRef<'tcx> {

#[derive(Subdiagnostic)]
pub enum TypeMismatchReason {
#[label(middle_conflict_types)]
#[label("this expression supplies two conflicting concrete types for the same opaque type")]
ConflictType {
#[primary_span]
span: Span,
},
#[note(middle_previous_use_here)]
#[note("previous use here")]
PreviousUse {
#[primary_span]
span: Span,
},
}

#[derive(Diagnostic)]
#[diag(middle_recursion_limit_reached)]
#[help]
#[diag("reached the recursion limit finding the struct tail for `{$ty}`")]
#[help(
"consider increasing the recursion limit by adding a `#![recursion_limit = \"{$suggested_limit}\"]`"
)]
pub(crate) struct RecursionLimitReached<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -77,31 +79,35 @@ pub(crate) struct RecursionLimitReached<'tcx> {
}

#[derive(Diagnostic)]
#[diag(middle_const_eval_non_int)]
#[diag("constant evaluation of enum discriminant resulted in non-integer")]
pub(crate) struct ConstEvalNonIntError {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(middle_strict_coherence_needs_negative_coherence)]
#[diag(
"to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled"
)]
pub(crate) struct StrictCoherenceNeedsNegativeCoherence {
#[primary_span]
pub span: Span,
#[label]
#[label("due to this attribute")]
pub attr_span: Option<Span>,
}

#[derive(Diagnostic)]
#[diag(middle_requires_lang_item)]
#[diag("requires `{$name}` lang_item")]
pub(crate) struct RequiresLangItem {
#[primary_span]
pub span: Span,
pub name: Symbol,
}

#[derive(Diagnostic)]
#[diag(middle_const_not_used_in_type_alias)]
#[diag(
"const parameter `{$ct}` is part of concrete type but not used in parameter list for the `impl Trait` type alias"
)]
pub(super) struct ConstNotUsedTraitAlias {
pub ct: String,
#[primary_span]
Expand Down Expand Up @@ -133,41 +139,41 @@ impl fmt::Debug for CustomSubdiagnostic<'_> {

#[derive(Diagnostic)]
pub enum LayoutError<'tcx> {
#[diag(middle_layout_unknown)]
#[diag("the type `{$ty}` has an unknown layout")]
Unknown { ty: Ty<'tcx> },

#[diag(middle_layout_too_generic)]
#[diag("the type `{$ty}` does not have a fixed layout")]
TooGeneric { ty: Ty<'tcx> },

#[diag(middle_layout_size_overflow)]
#[diag("values of the type `{$ty}` are too big for the target architecture")]
Overflow { ty: Ty<'tcx> },

#[diag(middle_layout_simd_too_many)]
#[diag("the SIMD type `{$ty}` has more elements than the limit {$max_lanes}")]
SimdTooManyLanes { ty: Ty<'tcx>, max_lanes: u64 },

#[diag(middle_layout_simd_zero_length)]
#[diag("the SIMD type `{$ty}` has zero elements")]
SimdZeroLength { ty: Ty<'tcx> },

#[diag(middle_layout_normalization_failure)]
#[diag("unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized")]
NormalizationFailure { ty: Ty<'tcx>, failure_ty: String },

#[diag(middle_layout_cycle)]
#[diag("a cycle occurred during layout computation")]
Cycle,

#[diag(middle_layout_references_error)]
#[diag("the type has an unknown layout")]
ReferencesError,
}

#[derive(Diagnostic)]
#[diag(middle_erroneous_constant)]
#[diag("erroneous constant encountered")]
pub(crate) struct ErroneousConstant {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(middle_type_length_limit)]
#[help(middle_consider_type_length_limit)]
#[diag("reached the type-length limit while instantiating `{$instance}`")]
#[help("consider adding a `#![type_length_limit=\"{$type_length}\"]` attribute to your crate")]
pub(crate) struct TypeLengthLimit<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -176,16 +182,16 @@ pub(crate) struct TypeLengthLimit<'tcx> {
}

#[derive(Diagnostic)]
#[diag(middle_max_num_nodes_in_valtree)]
#[diag("maximum number of nodes exceeded in constant {$global_const_id}")]
pub(crate) struct MaxNumNodesInValtree {
#[primary_span]
pub span: Span,
pub global_const_id: String,
}

#[derive(Diagnostic)]
#[diag(middle_invalid_const_in_valtree)]
#[note]
#[diag("constant {$global_const_id} cannot be used as pattern")]
#[note("constants that reference mutable or external memory cannot be used as patterns")]
pub(crate) struct InvalidConstInValtree {
#[primary_span]
pub span: Span,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,3 @@ pub mod dep_graph;

// Allows macros to refer to this crate as `::rustc_middle`
extern crate self as rustc_middle;

rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
19 changes: 14 additions & 5 deletions compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::num::NonZero;

use rustc_ast::NodeId;
use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintBuffer};
use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintBuffer, inline_fluent};
use rustc_feature::GateIssue;
use rustc_hir::attrs::{DeprecatedSince, Deprecation};
use rustc_hir::def_id::{DefId, LocalDefId};
Expand Down Expand Up @@ -103,7 +103,7 @@ fn deprecation_lint(is_in_effect: bool) -> &'static Lint {

#[derive(Subdiagnostic)]
#[suggestion(
middle_deprecated_suggestion,
"replace the use of the deprecated {$kind}",
code = "{suggestion}",
style = "verbose",
applicability = "machine-applicable"
Expand All @@ -128,10 +128,19 @@ pub struct Deprecated {
impl<'a, G: EmissionGuarantee> rustc_errors::LintDiagnostic<'a, G> for Deprecated {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
diag.primary_message(match &self.since_kind {
DeprecatedSinceKind::InEffect => crate::fluent_generated::middle_deprecated,
DeprecatedSinceKind::InFuture => crate::fluent_generated::middle_deprecated_in_future,
DeprecatedSinceKind::InEffect => inline_fluent!("use of deprecated {$kind} `{$path}`{$has_note ->
[true] : {$note}
*[other] {\"\"}
}"),
DeprecatedSinceKind::InFuture => inline_fluent!("use of {$kind} `{$path}` that will be deprecated in a future Rust version{$has_note ->
[true] : {$note}
*[other] {\"\"}
}"),
DeprecatedSinceKind::InVersion(_) => {
crate::fluent_generated::middle_deprecated_in_version
inline_fluent!("use of {$kind} `{$path}` that will be deprecated in future version {$version}{$has_note ->
[true] : {$note}
*[other] {\"\"}
}")
}
});
diag.arg("kind", self.kind);
Expand Down
Loading