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 @@ -3805,7 +3805,6 @@ dependencies = [
"rustc_mir_build",
"rustc_mir_dataflow",
"rustc_mir_transform",
"rustc_monomorphize",
"rustc_parse",
"rustc_passes",
"rustc_pattern_analysis",
Expand Down Expand Up @@ -4384,7 +4383,6 @@ dependencies = [
"rustc_abi",
"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 @@ -37,7 +37,6 @@ rustc_middle = { path = "../rustc_middle" }
rustc_mir_build = { path = "../rustc_mir_build" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_mir_transform = { path = "../rustc_mir_transform" }
rustc_monomorphize = { path = "../rustc_monomorphize" }
rustc_parse = { path = "../rustc_parse" }
rustc_passes = { path = "../rustc_passes" }
rustc_pattern_analysis = { path = "../rustc_pattern_analysis" }
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 @@ -134,7 +134,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
rustc_mir_dataflow::DEFAULT_LOCALE_RESOURCE,
rustc_mir_transform::DEFAULT_LOCALE_RESOURCE,
rustc_monomorphize::DEFAULT_LOCALE_RESOURCE,
rustc_parse::DEFAULT_LOCALE_RESOURCE,
rustc_passes::DEFAULT_LOCALE_RESOURCE,
rustc_pattern_analysis::DEFAULT_LOCALE_RESOURCE,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_monomorphize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ edition = "2024"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }
Expand Down
82 changes: 0 additions & 82 deletions compiler/rustc_monomorphize/messages.ftl

This file was deleted.

109 changes: 82 additions & 27 deletions compiler/rustc_monomorphize/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,55 @@ use rustc_middle::ty::{Instance, Ty};
use rustc_span::{Span, Symbol};

#[derive(Diagnostic)]
#[diag(monomorphize_recursion_limit)]
#[diag("reached the recursion limit while instantiating `{$instance}`")]
pub(crate) struct RecursionLimit<'tcx> {
#[primary_span]
pub span: Span,
pub instance: Instance<'tcx>,
#[note]
#[note("`{$def_path_str}` defined here")]
pub def_span: Span,
pub def_path_str: String,
}

#[derive(Diagnostic)]
#[diag(monomorphize_no_optimized_mir)]
#[diag("missing optimized MIR for `{$instance}` in the crate `{$crate_name}`")]
pub(crate) struct NoOptimizedMir {
#[note]
#[note(
"missing optimized MIR for this item (was the crate `{$crate_name}` compiled with `--emit=metadata`?)"
)]
pub span: Span,
pub crate_name: Symbol,
pub instance: String,
}

#[derive(LintDiagnostic)]
#[diag(monomorphize_large_assignments)]
#[note]
#[diag("moving {$size} bytes")]
#[note(
"the current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = \"...\"]`"
)]
pub(crate) struct LargeAssignmentsLint {
#[label]
#[label("value moved from here")]
pub span: Span,
pub size: u64,
pub limit: u64,
}

#[derive(Diagnostic)]
#[diag(monomorphize_symbol_already_defined)]
#[diag("symbol `{$symbol}` is already defined")]
pub(crate) struct SymbolAlreadyDefined {
#[primary_span]
pub span: Option<Span>,
pub symbol: String,
}

#[derive(Diagnostic)]
#[diag(monomorphize_couldnt_dump_mono_stats)]
#[diag("unexpected error occurred while dumping monomorphization stats: {$error}")]
pub(crate) struct CouldntDumpMonoStats {
pub error: String,
}

#[derive(Diagnostic)]
#[diag(monomorphize_encountered_error_while_instantiating)]
#[diag("the above error was encountered while instantiating `{$kind} {$instance}`")]
pub(crate) struct EncounteredErrorWhileInstantiating<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -56,23 +60,41 @@ pub(crate) struct EncounteredErrorWhileInstantiating<'tcx> {
}

#[derive(Diagnostic)]
#[diag(monomorphize_encountered_error_while_instantiating_global_asm)]
#[diag("the above error was encountered while instantiating `global_asm`")]
pub(crate) struct EncounteredErrorWhileInstantiatingGlobalAsm {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(monomorphize_start_not_found)]
#[help]
#[diag("using `fn main` requires the standard library")]
#[help(
"use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[no_mangle]`"
)]
pub(crate) struct StartNotFound;

#[derive(Diagnostic)]
#[diag(monomorphize_abi_error_disabled_vector_type)]
#[help]
#[diag("this function {$is_call ->
[true] call
*[false] definition
} uses {$is_scalable ->
[true] scalable
*[false] SIMD
} vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
[true] {\" \"}in the caller
*[false] {\"\"}
}")]
#[help(
"consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable=\"{$required_feature}\")]`)"
)]
pub(crate) struct AbiErrorDisabledVectorType<'a> {
#[primary_span]
#[label]
#[label(
"function {$is_call ->
[true] called
*[false] defined
} here"
)]
pub span: Span,
pub required_feature: &'a str,
pub ty: Ty<'a>,
Expand All @@ -83,34 +105,67 @@ pub(crate) struct AbiErrorDisabledVectorType<'a> {
}

#[derive(Diagnostic)]
#[diag(monomorphize_abi_error_unsupported_unsized_parameter)]
#[help]
#[diag(
"this function {$is_call ->
[true] call
*[false] definition
} uses unsized type `{$ty}` which is not supported with the chosen ABI"
)]
#[help("only rustic ABIs support unsized parameters")]
pub(crate) struct AbiErrorUnsupportedUnsizedParameter<'a> {
#[primary_span]
#[label]
#[label(
"function {$is_call ->
[true] called
*[false] defined
} here"
)]
pub span: Span,
pub ty: Ty<'a>,
/// Whether this is a problem at a call site or at a declaration.
pub is_call: bool,
}

#[derive(Diagnostic)]
#[diag(monomorphize_abi_error_unsupported_vector_type)]
#[diag(
"this function {$is_call ->
[true] call
*[false] definition
} uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI"
)]
pub(crate) struct AbiErrorUnsupportedVectorType<'a> {
#[primary_span]
#[label]
#[label(
"function {$is_call ->
[true] called
*[false] defined
} here"
)]
pub span: Span,
pub ty: Ty<'a>,
/// Whether this is a problem at a call site or at a declaration.
pub is_call: bool,
}

#[derive(Diagnostic)]
#[diag(monomorphize_abi_required_target_feature)]
#[help]
#[diag("this function {$is_call ->
[true] call
*[false] definition
} uses ABI \"{$abi}\" which requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
[true] {\" \"}in the caller
*[false] {\"\"}
}")]
#[help(
"consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable=\"{$required_feature}\")]`)"
)]
pub(crate) struct AbiRequiredTargetFeature<'a> {
#[primary_span]
#[label]
#[label(
"function {$is_call ->
[true] called
*[false] defined
} here"
)]
pub span: Span,
pub required_feature: &'a str,
pub abi: &'a str,
Expand All @@ -119,12 +174,12 @@ pub(crate) struct AbiRequiredTargetFeature<'a> {
}

#[derive(Diagnostic)]
#[diag(monomorphize_static_initializer_cyclic)]
#[note]
#[diag("static initializer forms a cycle involving `{$head}`")]
#[note("cyclic static initializers are not supported for target `{$target}`")]
pub(crate) struct StaticInitializerCyclic<'a> {
#[primary_span]
pub span: Span,
#[label]
#[label("part of this cycle")]
pub labels: Vec<Span>,
pub head: &'a str,
pub target: &'a str,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_monomorphize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ mod mono_checks;
mod partitioning;
mod util;

rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

fn custom_coerce_unsize_info<'tcx>(
tcx: TyCtxtAt<'tcx>,
source_ty: Ty<'tcx>,
Expand Down
Loading