Remove Session
methods that duplicate DiagCtxt
methods.
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
This commit is contained in:
parent
bfda19d5bd
commit
7e213fe428
@ -47,12 +47,12 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
|
||||
}
|
||||
|
||||
Conv::X86Intr | Conv::RiscvInterrupt { .. } => {
|
||||
sess.fatal(format!("interrupt call conv {c:?} not yet implemented"))
|
||||
sess.dcx().fatal(format!("interrupt call conv {c:?} not yet implemented"))
|
||||
}
|
||||
|
||||
Conv::ArmAapcs => sess.fatal("aapcs call conv not yet implemented"),
|
||||
Conv::ArmAapcs => sess.dcx().fatal("aapcs call conv not yet implemented"),
|
||||
Conv::CCmseNonSecureCall => {
|
||||
sess.fatal("C-cmse-nonsecure-call call conv is not yet implemented");
|
||||
sess.dcx().fatal("C-cmse-nonsecure-call call conv is not yet implemented");
|
||||
}
|
||||
|
||||
Conv::Msp430Intr
|
||||
@ -88,10 +88,10 @@ pub(crate) fn import_function<'tcx>(
|
||||
let sig = get_function_sig(tcx, module.target_config().default_call_conv, inst);
|
||||
match module.declare_function(name, Linkage::Import, &sig) {
|
||||
Ok(func_id) => func_id,
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!(
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!(
|
||||
"attempt to declare `{name}` as function, but it was already declared as static"
|
||||
)),
|
||||
Err(ModuleError::IncompatibleSignature(_, prev_sig, new_sig)) => tcx.sess.fatal(format!(
|
||||
Err(ModuleError::IncompatibleSignature(_, prev_sig, new_sig)) => tcx.dcx().fatal(format!(
|
||||
"attempt to declare `{name}` with signature {new_sig:?}, \
|
||||
but it was already declared with signature {prev_sig:?}"
|
||||
)),
|
||||
@ -181,7 +181,7 @@ fn make_local_place<'tcx>(
|
||||
is_ssa: bool,
|
||||
) -> CPlace<'tcx> {
|
||||
if layout.is_unsized() {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.local_decls[local].source_info.span,
|
||||
"unsized locals are not yet supported",
|
||||
);
|
||||
@ -226,7 +226,7 @@ enum ArgKind<'tcx> {
|
||||
|
||||
// FIXME implement variadics in cranelift
|
||||
if fn_abi.c_variadic {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.span,
|
||||
"Defining variadic functions is not yet supported by Cranelift",
|
||||
);
|
||||
@ -543,7 +543,7 @@ enum CallTarget {
|
||||
// FIXME find a cleaner way to support varargs
|
||||
if fn_sig.c_variadic() {
|
||||
if !matches!(fn_sig.abi(), Abi::C { .. }) {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
source_info.span,
|
||||
format!("Variadic call for non-C abi {:?}", fn_sig.abi()),
|
||||
);
|
||||
@ -555,7 +555,7 @@ enum CallTarget {
|
||||
let ty = fx.bcx.func.dfg.value_type(arg);
|
||||
if !ty.is_int() {
|
||||
// FIXME set %al to upperbound on float args once floats are supported
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
source_info.span,
|
||||
format!("Non int ty {:?} for variadic call", ty),
|
||||
);
|
||||
|
@ -236,13 +236,13 @@ pub(crate) fn verify_func(
|
||||
match cranelift_codegen::verify_function(&func, &flags) {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
tcx.sess.err(format!("{:?}", err));
|
||||
tcx.dcx().err(format!("{:?}", err));
|
||||
let pretty_error = cranelift_codegen::print_errors::pretty_verifier_error(
|
||||
&func,
|
||||
Some(Box::new(writer)),
|
||||
err,
|
||||
);
|
||||
tcx.sess.fatal(format!("cranelift verify error:\n{}", pretty_error));
|
||||
tcx.dcx().fatal(format!("cranelift verify error:\n{}", pretty_error));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -450,7 +450,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
||||
unwind: _,
|
||||
} => {
|
||||
if options.contains(InlineAsmOptions::MAY_UNWIND) {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
source_info.span,
|
||||
"cranelift doesn't support unwinding from inline assembly.",
|
||||
);
|
||||
@ -812,7 +812,7 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
| StatementKind::PlaceMention(..)
|
||||
| StatementKind::AscribeUserType(..) => {}
|
||||
|
||||
StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"),
|
||||
StatementKind::Coverage { .. } => fx.tcx.dcx().fatal("-Zcoverage is unimplemented"),
|
||||
StatementKind::Intrinsic(ref intrinsic) => match &**intrinsic {
|
||||
// We ignore `assume` intrinsics, they are only useful for optimizations
|
||||
NonDivergingIntrinsic::Assume(_) => {}
|
||||
|
@ -465,9 +465,12 @@ impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
#[inline]
|
||||
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
|
||||
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
|
||||
self.0.sess.span_fatal(span, err.to_string())
|
||||
self.0.sess.dcx().span_fatal(span, err.to_string())
|
||||
} else {
|
||||
self.0.sess.span_fatal(span, format!("failed to get layout for `{}`: {}", ty, err))
|
||||
self.0
|
||||
.sess
|
||||
.dcx()
|
||||
.span_fatal(span, format!("failed to get layout for `{}`: {}", ty, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -483,7 +486,7 @@ fn handle_fn_abi_err(
|
||||
fn_abi_request: FnAbiRequest<'tcx>,
|
||||
) -> ! {
|
||||
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
|
||||
self.0.sess.emit_fatal(Spanned { span, node: err })
|
||||
self.0.sess.dcx().emit_fatal(Spanned { span, node: err })
|
||||
} else {
|
||||
match fn_abi_request {
|
||||
FnAbiRequest::OfFnPtr { sig, extra_args } => {
|
||||
|
@ -263,7 +263,7 @@ fn data_id_for_static(
|
||||
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
||||
) {
|
||||
Ok(data_id) => data_id,
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!(
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!(
|
||||
"attempt to declare `{symbol_name}` as static, but it was already declared as function"
|
||||
)),
|
||||
Err(err) => Err::<_, _>(err).unwrap(),
|
||||
@ -311,7 +311,7 @@ fn data_id_for_static(
|
||||
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
||||
) {
|
||||
Ok(data_id) => data_id,
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!(
|
||||
Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!(
|
||||
"attempt to declare `{symbol_name}` as static, but it was already declared as function"
|
||||
)),
|
||||
Err(err) => Err::<_, _>(err).unwrap(),
|
||||
@ -360,7 +360,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
if let Some(names) = section_name.split_once(',') {
|
||||
names
|
||||
} else {
|
||||
tcx.sess.fatal(format!(
|
||||
tcx.dcx().fatal(format!(
|
||||
"#[link_section = \"{}\"] is not valid for macos target: must be segment and section separated by comma",
|
||||
section_name
|
||||
));
|
||||
@ -406,7 +406,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
GlobalAlloc::Static(def_id) => {
|
||||
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL)
|
||||
{
|
||||
tcx.sess.fatal(format!(
|
||||
tcx.dcx().fatal(format!(
|
||||
"Allocation {:?} contains reference to TLS value {:?}",
|
||||
alloc_id, def_id
|
||||
));
|
||||
|
@ -69,7 +69,7 @@ pub(crate) fn join(
|
||||
|
||||
let module_codegen_result = match module_codegen_result {
|
||||
Ok(module_codegen_result) => module_codegen_result,
|
||||
Err(err) => sess.fatal(err),
|
||||
Err(err) => sess.dcx().fatal(err),
|
||||
};
|
||||
let ModuleCodegenResult { module_regular, module_global_asm, existing_work_product } =
|
||||
module_codegen_result;
|
||||
@ -422,7 +422,7 @@ pub(crate) fn run_aot(
|
||||
backend_config.clone(),
|
||||
global_asm_config.clone(),
|
||||
cgu.name(),
|
||||
concurrency_limiter.acquire(tcx.sess.dcx()),
|
||||
concurrency_limiter.acquire(tcx.dcx()),
|
||||
),
|
||||
module_codegen,
|
||||
Some(rustc_middle::dep_graph::hash_result),
|
||||
@ -455,7 +455,7 @@ pub(crate) fn run_aot(
|
||||
"allocator_shim".to_owned(),
|
||||
) {
|
||||
Ok(allocator_module) => Some(allocator_module),
|
||||
Err(err) => tcx.sess.fatal(err),
|
||||
Err(err) => tcx.dcx().fatal(err),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
@ -478,7 +478,7 @@ pub(crate) fn run_aot(
|
||||
let obj = create_compressed_metadata_file(tcx.sess, &metadata, &symbol_name);
|
||||
|
||||
if let Err(err) = std::fs::write(&tmp_file, obj) {
|
||||
tcx.sess.fatal(format!("error writing metadata object file: {}", err));
|
||||
tcx.dcx().fatal(format!("error writing metadata object file: {}", err));
|
||||
}
|
||||
|
||||
(metadata_cgu_name, tmp_file)
|
||||
|
@ -94,11 +94,11 @@ fn create_jit_module(
|
||||
|
||||
pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
||||
if !tcx.sess.opts.output_types.should_codegen() {
|
||||
tcx.sess.fatal("JIT mode doesn't work with `cargo check`");
|
||||
tcx.dcx().fatal("JIT mode doesn't work with `cargo check`");
|
||||
}
|
||||
|
||||
if !tcx.crate_types().contains(&rustc_session::config::CrateType::Executable) {
|
||||
tcx.sess.fatal("can't jit non-executable crate");
|
||||
tcx.dcx().fatal("can't jit non-executable crate");
|
||||
}
|
||||
|
||||
let (mut jit_module, mut cx) = create_jit_module(
|
||||
@ -141,14 +141,14 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
||||
}
|
||||
MonoItem::GlobalAsm(item_id) => {
|
||||
let item = tcx.hir().item(item_id);
|
||||
tcx.sess.span_fatal(item.span, "Global asm is not supported in JIT mode");
|
||||
tcx.dcx().span_fatal(item.span, "Global asm is not supported in JIT mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if !cx.global_asm.is_empty() {
|
||||
tcx.sess.fatal("Inline asm is not supported in JIT mode");
|
||||
tcx.dcx().fatal("Inline asm is not supported in JIT mode");
|
||||
}
|
||||
|
||||
tcx.sess.abort_if_errors();
|
||||
|
@ -47,7 +47,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
|
||||
}
|
||||
InlineAsmOperand::SymFn { anon_const } => {
|
||||
if cfg!(not(feature = "inline_asm_sym")) {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
item.span,
|
||||
"asm! and global_asm! sym operands are not yet supported",
|
||||
);
|
||||
@ -65,7 +65,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
|
||||
}
|
||||
InlineAsmOperand::SymStatic { path: _, def_id } => {
|
||||
if cfg!(not(feature = "inline_asm_sym")) {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
item.span,
|
||||
"asm! and global_asm! sym operands are not yet supported",
|
||||
);
|
||||
|
@ -84,7 +84,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>(
|
||||
InlineAsmOperand::SymFn { ref value } => {
|
||||
if cfg!(not(feature = "inline_asm_sym")) {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_err(span, "asm! and global_asm! sym operands are not yet supported");
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ fn generate_asm_wrapper(&self, asm_name: &str) -> String {
|
||||
}
|
||||
_ => self
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.fatal(format!("Unsupported binary format for inline asm: {binary_format:?}")),
|
||||
}
|
||||
|
||||
@ -563,7 +563,7 @@ fn generate_asm_wrapper(&self, asm_name: &str) -> String {
|
||||
BinaryFormat::Macho | BinaryFormat::Coff => {}
|
||||
_ => self
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.fatal(format!("Unsupported binary format for inline asm: {binary_format:?}")),
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
|
||||
|
||||
_ => {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.warn(format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic));
|
||||
crate::trap::trap_unimplemented(fx, intrinsic);
|
||||
return;
|
||||
|
@ -309,7 +309,7 @@ pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
|
||||
}
|
||||
*/
|
||||
_ => {
|
||||
fx.tcx.sess.warn(format!(
|
||||
fx.tcx.dcx().warn(format!(
|
||||
"unsupported AArch64 llvm intrinsic {}; replacing with trap",
|
||||
intrinsic
|
||||
));
|
||||
|
@ -960,7 +960,9 @@ fn select4(
|
||||
{
|
||||
imm8
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant");
|
||||
fx.tcx
|
||||
.dcx()
|
||||
.span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant");
|
||||
};
|
||||
|
||||
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
|
||||
@ -1011,7 +1013,9 @@ fn select4(
|
||||
{
|
||||
imm8
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant");
|
||||
fx.tcx
|
||||
.dcx()
|
||||
.span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant");
|
||||
};
|
||||
|
||||
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
|
||||
@ -1056,7 +1060,7 @@ fn select4(
|
||||
{
|
||||
imm8
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
span,
|
||||
"Index argument for `_mm_clmulepi64_si128` is not a constant",
|
||||
);
|
||||
@ -1093,7 +1097,7 @@ fn select4(
|
||||
{
|
||||
imm8
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
span,
|
||||
"Index argument for `_mm_aeskeygenassist_si128` is not a constant",
|
||||
);
|
||||
@ -1361,7 +1365,7 @@ fn select4(
|
||||
|
||||
_ => {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.warn(format!("unsupported x86 llvm intrinsic {}; replacing with trap", intrinsic));
|
||||
crate::trap::trap_unimplemented(fx, intrinsic);
|
||||
return;
|
||||
|
@ -37,7 +37,7 @@ fn report_atomic_type_validation_error<'tcx>(
|
||||
span: Span,
|
||||
ty: Ty<'tcx>,
|
||||
) {
|
||||
fx.tcx.sess.span_err(
|
||||
fx.tcx.dcx().span_err(
|
||||
span,
|
||||
format!(
|
||||
"`{}` intrinsic: expected basic integer or raw pointer type, found `{:?}`",
|
||||
@ -785,7 +785,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
return;
|
||||
} else {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_fatal(source_info.span, "128bit atomics not yet supported");
|
||||
}
|
||||
}
|
||||
@ -816,7 +816,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
return;
|
||||
} else {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_fatal(source_info.span, "128bit atomics not yet supported");
|
||||
}
|
||||
}
|
||||
@ -1245,7 +1245,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
|
||||
// FIXME implement variadics in cranelift
|
||||
sym::va_copy | sym::va_arg | sym::va_end => {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
source_info.span,
|
||||
"Defining variadic functions is not yet supported by Cranelift",
|
||||
);
|
||||
@ -1253,7 +1253,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||
|
||||
_ => {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_fatal(source_info.span, format!("unsupported intrinsic {}", intrinsic));
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ fn report_simd_type_validation_error(
|
||||
span: Span,
|
||||
ty: Ty<'_>,
|
||||
) {
|
||||
fx.tcx.sess.span_err(span, format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", intrinsic, ty));
|
||||
fx.tcx.dcx().span_err(span, format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", intrinsic, ty));
|
||||
// Prevent verifier error
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
}
|
||||
@ -192,7 +192,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
.try_into()
|
||||
.unwrap(),
|
||||
_ => {
|
||||
fx.tcx.sess.span_err(
|
||||
fx.tcx.dcx().span_err(
|
||||
span,
|
||||
format!("simd_shuffle index must be an array of `u32`, got `{}`", idx_ty),
|
||||
);
|
||||
@ -278,7 +278,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
{
|
||||
idx_const
|
||||
} else {
|
||||
fx.tcx.sess.span_fatal(span, "Index argument for `simd_insert` is not a constant");
|
||||
fx.tcx.dcx().span_fatal(span, "Index argument for `simd_insert` is not a constant");
|
||||
};
|
||||
|
||||
let idx: u32 = idx_const
|
||||
@ -286,7 +286,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
.unwrap_or_else(|_| panic!("kind not scalar: {:?}", idx_const));
|
||||
let (lane_count, _lane_ty) = base.layout().ty.simd_size_and_type(fx.tcx);
|
||||
if u64::from(idx) >= lane_count {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.span,
|
||||
format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count),
|
||||
);
|
||||
@ -316,7 +316,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
{
|
||||
idx_const
|
||||
} else {
|
||||
fx.tcx.sess.span_warn(span, "Index argument for `simd_extract` is not a constant");
|
||||
fx.tcx.dcx().span_warn(span, "Index argument for `simd_extract` is not a constant");
|
||||
let trap_block = fx.bcx.create_block();
|
||||
let true_ = fx.bcx.ins().iconst(types::I8, 1);
|
||||
let ret_block = fx.get_block(target);
|
||||
@ -334,7 +334,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
.unwrap_or_else(|_| panic!("kind not scalar: {:?}", idx_const));
|
||||
let (lane_count, _lane_ty) = v.layout().ty.simd_size_and_type(fx.tcx);
|
||||
if u64::from(idx) >= lane_count {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
fx.mir.span,
|
||||
format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count),
|
||||
);
|
||||
@ -859,7 +859,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
match lane_ty.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {}
|
||||
_ => {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
span,
|
||||
format!(
|
||||
"invalid monomorphization of `simd_bitmask` intrinsic: \
|
||||
@ -899,7 +899,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
|
||||
== Some(expected_bytes) => {}
|
||||
_ => {
|
||||
fx.tcx.sess.span_fatal(
|
||||
fx.tcx.dcx().span_fatal(
|
||||
span,
|
||||
format!(
|
||||
"invalid monomorphization of `simd_bitmask` intrinsic: \
|
||||
@ -1086,7 +1086,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||
}
|
||||
|
||||
_ => {
|
||||
fx.tcx.sess.span_err(span, format!("Unknown SIMD intrinsic {}", intrinsic));
|
||||
fx.tcx.dcx().span_err(span, format!("Unknown SIMD intrinsic {}", intrinsic));
|
||||
// Prevent verifier error
|
||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||
return;
|
||||
|
19
src/lib.rs
19
src/lib.rs
@ -177,13 +177,15 @@ fn init(&self, sess: &Session) {
|
||||
use rustc_session::config::Lto;
|
||||
match sess.lto() {
|
||||
Lto::No | Lto::ThinLocal => {}
|
||||
Lto::Thin | Lto::Fat => sess.warn("LTO is not supported. You may get a linker error."),
|
||||
Lto::Thin | Lto::Fat => {
|
||||
sess.dcx().warn("LTO is not supported. You may get a linker error.")
|
||||
}
|
||||
}
|
||||
|
||||
let mut config = self.config.borrow_mut();
|
||||
if config.is_none() {
|
||||
let new_config = BackendConfig::from_opts(&sess.opts.cg.llvm_args)
|
||||
.unwrap_or_else(|err| sess.fatal(err));
|
||||
.unwrap_or_else(|err| sess.dcx().fatal(err));
|
||||
*config = Some(new_config);
|
||||
}
|
||||
}
|
||||
@ -211,7 +213,7 @@ fn codegen_crate(
|
||||
driver::jit::run_jit(tcx, config);
|
||||
|
||||
#[cfg(not(feature = "jit"))]
|
||||
tcx.sess.fatal("jit support was disabled when compiling rustc_codegen_cranelift");
|
||||
tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,7 +245,7 @@ fn link(
|
||||
fn target_triple(sess: &Session) -> target_lexicon::Triple {
|
||||
match sess.target.llvm_target.parse() {
|
||||
Ok(triple) => triple,
|
||||
Err(err) => sess.fatal(format!("target not recognized: {}", err)),
|
||||
Err(err) => sess.dcx().fatal(format!("target not recognized: {}", err)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,17 +312,18 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn isa::Tar
|
||||
Some(value) => {
|
||||
let mut builder =
|
||||
cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| {
|
||||
sess.fatal(format!("can't compile for {}: {}", target_triple, err));
|
||||
sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err));
|
||||
});
|
||||
if let Err(_) = builder.enable(value) {
|
||||
sess.fatal("the specified target cpu isn't currently supported by Cranelift.");
|
||||
sess.dcx()
|
||||
.fatal("the specified target cpu isn't currently supported by Cranelift.");
|
||||
}
|
||||
builder
|
||||
}
|
||||
None => {
|
||||
let mut builder =
|
||||
cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| {
|
||||
sess.fatal(format!("can't compile for {}: {}", target_triple, err));
|
||||
sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err));
|
||||
});
|
||||
if target_triple.architecture == target_lexicon::Architecture::X86_64 {
|
||||
// Don't use "haswell" as the default, as it implies `has_lzcnt`.
|
||||
@ -333,7 +336,7 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn isa::Tar
|
||||
|
||||
match isa_builder.finish(flags) {
|
||||
Ok(target_isa) => target_isa,
|
||||
Err(err) => sess.fatal(format!("failed to build TargetIsa: {}", err)),
|
||||
Err(err) => sess.dcx().fatal(format!("failed to build TargetIsa: {}", err)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ fn create_entry_fn(
|
||||
let cmain_func_id = match m.declare_function(entry_name, Linkage::Export, &cmain_sig) {
|
||||
Ok(func_id) => func_id,
|
||||
Err(err) => {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.fatal(format!("entry symbol `{entry_name}` declared multiple times: {err}"));
|
||||
}
|
||||
};
|
||||
@ -171,7 +171,7 @@ fn create_entry_fn(
|
||||
}
|
||||
|
||||
if let Err(err) = m.define_function(cmain_func_id, &mut ctx) {
|
||||
tcx.sess.fatal(format!("entry symbol `{entry_name}` defined multiple times: {err}"));
|
||||
tcx.dcx().fatal(format!("entry symbol `{entry_name}` defined multiple times: {err}"));
|
||||
}
|
||||
|
||||
unwind_context.add_function(cmain_func_id, &ctx, m.isa());
|
||||
|
@ -397,7 +397,7 @@ pub(crate) fn new_stack_slot(
|
||||
|
||||
if layout.size.bytes() >= u64::from(u32::MAX - 16) {
|
||||
fx.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.fatal(format!("values of type {} are too big to store on the stack", layout.ty));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user