mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
replace some usages of [Span]FatalError with error-specific types
This commit is contained in:
parent
137f20c112
commit
40f44736e8
@ -11,6 +11,10 @@ monomorphize_consider_type_length_limit =
|
|||||||
|
|
||||||
monomorphize_fatal_error = {$error_message}
|
monomorphize_fatal_error = {$error_message}
|
||||||
|
|
||||||
|
monomorphize_unknown_partition_strategy = unknown partitioning strategy
|
||||||
|
|
||||||
|
monomorphize_symbol_already_defined = symbol `{$symbol}` is already defined
|
||||||
|
|
||||||
monomorphize_unused_generic_params = item has unused generic parameters
|
monomorphize_unused_generic_params = item has unused generic parameters
|
||||||
|
|
||||||
monomorphize_large_assignments =
|
monomorphize_large_assignments =
|
||||||
|
@ -39,14 +39,6 @@ pub struct FatalError {
|
|||||||
pub error_message: String,
|
pub error_message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
|
||||||
#[diag(monomorphize::fatal_error)]
|
|
||||||
pub struct SpanFatalError {
|
|
||||||
#[primary_span]
|
|
||||||
pub span: Span,
|
|
||||||
pub error_message: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct UnusedGenericParams {
|
pub struct UnusedGenericParams {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub param_spans: Vec<Span>,
|
pub param_spans: Vec<Span>,
|
||||||
@ -79,3 +71,15 @@ pub struct LargeAssignmentsLint {
|
|||||||
pub size: u64,
|
pub size: u64,
|
||||||
pub limit: u64,
|
pub limit: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[diag(monomorphize::unknown_partition_strategy)]
|
||||||
|
pub struct UnknownPartitionStrategy;
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[diag(monomorphize::symbol_already_defined)]
|
||||||
|
pub struct SymbolAlreadyDefined {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Option<Span>,
|
||||||
|
pub symbol: String,
|
||||||
|
}
|
||||||
|
@ -108,7 +108,7 @@ use rustc_span::symbol::Symbol;
|
|||||||
|
|
||||||
use crate::collector::InliningMap;
|
use crate::collector::InliningMap;
|
||||||
use crate::collector::{self, MonoItemCollectionMode};
|
use crate::collector::{self, MonoItemCollectionMode};
|
||||||
use crate::errors::{FatalError, SpanFatalError};
|
use crate::errors::{SymbolAlreadyDefined, UnknownPartitionStrategy};
|
||||||
|
|
||||||
pub struct PartitioningCx<'a, 'tcx> {
|
pub struct PartitioningCx<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
@ -151,8 +151,7 @@ fn get_partitioner<'tcx>(tcx: TyCtxt<'tcx>) -> Box<dyn Partitioner<'tcx>> {
|
|||||||
match strategy {
|
match strategy {
|
||||||
"default" => Box::new(default::DefaultPartitioning),
|
"default" => Box::new(default::DefaultPartitioning),
|
||||||
_ => {
|
_ => {
|
||||||
let error_message = "unknown partitioning strategy".to_string();
|
tcx.sess.emit_fatal(UnknownPartitionStrategy);
|
||||||
tcx.sess.emit_fatal(FatalError { error_message: error_message.clone() });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,13 +334,7 @@ where
|
|||||||
(span1, span2) => span1.or(span2),
|
(span1, span2) => span1.or(span2),
|
||||||
};
|
};
|
||||||
|
|
||||||
let error_message = format!("symbol `{}` is already defined", sym1);
|
tcx.sess.emit_fatal(SymbolAlreadyDefined { span, symbol: sym1.to_string() });
|
||||||
|
|
||||||
if let Some(span) = span {
|
|
||||||
tcx.sess.emit_fatal(SpanFatalError { span, error_message: error_message.clone() });
|
|
||||||
} else {
|
|
||||||
tcx.sess.emit_fatal(FatalError { error_message: error_message.clone() });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user