Convert to inline diagnostics in rustc_monomorphize
This commit is contained in:
parent
55407b8cdb
commit
d457ffd4f4
7 changed files with 82 additions and 116 deletions
|
|
@ -3805,7 +3805,6 @@ dependencies = [
|
|||
"rustc_mir_build",
|
||||
"rustc_mir_dataflow",
|
||||
"rustc_mir_transform",
|
||||
"rustc_monomorphize",
|
||||
"rustc_parse",
|
||||
"rustc_passes",
|
||||
"rustc_pattern_analysis",
|
||||
|
|
@ -4384,7 +4383,6 @@ dependencies = [
|
|||
"rustc_abi",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_fluent_macro",
|
||||
"rustc_hir",
|
||||
"rustc_index",
|
||||
"rustc_macros",
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
monomorphize_abi_error_disabled_vector_type =
|
||||
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] {""}
|
||||
}
|
||||
.label = function {$is_call ->
|
||||
[true] called
|
||||
*[false] defined
|
||||
} here
|
||||
.help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`)
|
||||
|
||||
monomorphize_abi_error_unsupported_unsized_parameter =
|
||||
this function {$is_call ->
|
||||
[true] call
|
||||
*[false] definition
|
||||
} uses unsized type `{$ty}` which is not supported with the chosen ABI
|
||||
.label = function {$is_call ->
|
||||
[true] called
|
||||
*[false] defined
|
||||
} here
|
||||
.help = only rustic ABIs support unsized parameters
|
||||
|
||||
monomorphize_abi_error_unsupported_vector_type =
|
||||
this function {$is_call ->
|
||||
[true] call
|
||||
*[false] definition
|
||||
} uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI
|
||||
.label = function {$is_call ->
|
||||
[true] called
|
||||
*[false] defined
|
||||
} here
|
||||
|
||||
monomorphize_abi_required_target_feature =
|
||||
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] {""}
|
||||
}
|
||||
.label = function {$is_call ->
|
||||
[true] called
|
||||
*[false] defined
|
||||
} here
|
||||
.help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`)
|
||||
|
||||
monomorphize_couldnt_dump_mono_stats =
|
||||
unexpected error occurred while dumping monomorphization stats: {$error}
|
||||
|
||||
monomorphize_encountered_error_while_instantiating =
|
||||
the above error was encountered while instantiating `{$kind} {$instance}`
|
||||
|
||||
monomorphize_encountered_error_while_instantiating_global_asm =
|
||||
the above error was encountered while instantiating `global_asm`
|
||||
|
||||
monomorphize_large_assignments =
|
||||
moving {$size} bytes
|
||||
.label = value moved from here
|
||||
.note = the current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
|
||||
|
||||
monomorphize_no_optimized_mir =
|
||||
missing optimized MIR for `{$instance}` in the crate `{$crate_name}`
|
||||
.note = missing optimized MIR for this item (was the crate `{$crate_name}` compiled with `--emit=metadata`?)
|
||||
|
||||
monomorphize_recursion_limit =
|
||||
reached the recursion limit while instantiating `{$instance}`
|
||||
.note = `{$def_path_str}` defined here
|
||||
|
||||
monomorphize_start_not_found = 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]`
|
||||
|
||||
monomorphize_static_initializer_cyclic = static initializer forms a cycle involving `{$head}`
|
||||
.label = part of this cycle
|
||||
.note = cyclic static initializers are not supported for target `{$target}`
|
||||
|
||||
monomorphize_symbol_already_defined = symbol `{$symbol}` is already defined
|
||||
|
|
@ -3,37 +3,41 @@ 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>,
|
||||
|
|
@ -41,13 +45,13 @@ pub(crate) struct SymbolAlreadyDefined {
|
|||
}
|
||||
|
||||
#[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,
|
||||
|
|
@ -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>,
|
||||
|
|
@ -83,11 +105,21 @@ 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.
|
||||
|
|
@ -95,10 +127,20 @@ pub(crate) struct AbiErrorUnsupportedUnsizedParameter<'a> {
|
|||
}
|
||||
|
||||
#[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.
|
||||
|
|
@ -106,11 +148,24 @@ pub(crate) struct AbiErrorUnsupportedVectorType<'a> {
|
|||
}
|
||||
|
||||
#[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,
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue