diff options
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/attributes.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/archive.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/write.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/intrinsic.rs | 34 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/mono_item.rs | 1 |
8 files changed, 41 insertions, 36 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 481741bb127..3cc33b83434 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -82,7 +82,7 @@ pub fn sanitize_attrs<'ll>( let mte_feature = features.iter().map(|s| &s[..]).rfind(|n| ["+mte", "-mte"].contains(&&n[..])); if let None | Some("-mte") = mte_feature { - cx.tcx.sess.emit_err(SanitizerMemtagRequiresMte); + cx.tcx.dcx().emit_err(SanitizerMemtagRequiresMte); } attrs.push(llvm::AttributeKind::SanitizeMemTag.create_attr(cx.llcx)); @@ -444,7 +444,7 @@ pub fn from_fn_attrs<'ll, 'tcx>( .next() .map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span); cx.tcx - .sess + .dcx() .create_err(TargetFeatureDisableOrEnable { features: f, span: Some(span), diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index cf47c94a81f..67bc86e4c90 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -99,7 +99,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> { fn build(mut self: Box<Self>, output: &Path) -> bool { match self.build_with_llvm(output) { Ok(any_members) => any_members, - Err(e) => self.sess.emit_fatal(ArchiveBuildFailure { error: e }), + Err(e) => self.sess.dcx().emit_fatal(ArchiveBuildFailure { error: e }), } } } @@ -175,7 +175,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder { match std::fs::write(&def_file_path, def_file_content) { Ok(_) => {} Err(e) => { - sess.emit_fatal(ErrorWritingDEFFile { error: e }); + sess.dcx().emit_fatal(ErrorWritingDEFFile { error: e }); } }; @@ -217,14 +217,14 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder { match dlltool_cmd.output() { Err(e) => { - sess.emit_fatal(ErrorCallingDllTool { + sess.dcx().emit_fatal(ErrorCallingDllTool { dlltool_path: dlltool.to_string_lossy(), error: e, }); } // dlltool returns '0' on failure, so check for error output instead. Ok(output) if !output.stderr.is_empty() => { - sess.emit_fatal(DlltoolFailImportLibrary { + sess.dcx().emit_fatal(DlltoolFailImportLibrary { dlltool_path: dlltool.to_string_lossy(), dlltool_args: dlltool_cmd .get_args() @@ -282,7 +282,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder { }; if result == crate::llvm::LLVMRustResult::Failure { - sess.emit_fatal(ErrorCreatingImportLibrary { + sess.dcx().emit_fatal(ErrorCreatingImportLibrary { lib_name, error: llvm::last_error().unwrap_or("unknown LLVM error".to_string()), }); @@ -354,7 +354,7 @@ impl<'a> LlvmArchiveBuilder<'a> { let kind = kind .parse::<ArchiveKind>() .map_err(|_| kind) - .unwrap_or_else(|kind| self.sess.emit_fatal(UnknownArchiveKind { kind })); + .unwrap_or_else(|kind| self.sess.dcx().emit_fatal(UnknownArchiveKind { kind })); let mut additions = mem::take(&mut self.additions); let mut strings = Vec::new(); diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 75f99f964d0..c607533a08e 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -126,7 +126,7 @@ pub fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTargetMach tcx.backend_optimization_level(()), tcx.global_backend_features(()), )(config) - .unwrap_or_else(|err| llvm_err(tcx.sess.dcx(), err).raise()) + .unwrap_or_else(|err| llvm_err(tcx.dcx(), err).raise()) } pub fn to_llvm_opt_settings( @@ -245,12 +245,12 @@ pub fn target_machine_factory( match sess.opts.debuginfo_compression { rustc_session::config::DebugInfoCompression::Zlib => { if !unsafe { LLVMRustLLVMHasZlibCompressionForDebugSymbols() } { - sess.emit_warning(UnknownCompression { algorithm: "zlib" }); + sess.dcx().emit_warning(UnknownCompression { algorithm: "zlib" }); } } rustc_session::config::DebugInfoCompression::Zstd => { if !unsafe { LLVMRustLLVMHasZstdCompressionForDebugSymbols() } { - sess.emit_warning(UnknownCompression { algorithm: "zstd" }); + sess.dcx().emit_warning(UnknownCompression { algorithm: "zstd" }); } } rustc_session::config::DebugInfoCompression::None => {} diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 77e893c815f..ec2fb2c6e54 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -131,10 +131,10 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align: Ok(min) => align = align.max(min), Err(err) => match err { AlignFromBytesError::NotPowerOfTwo(align) => { - cx.sess().emit_err(InvalidMinimumAlignmentNotPowerOfTwo { align }); + cx.sess().dcx().emit_err(InvalidMinimumAlignmentNotPowerOfTwo { align }); } AlignFromBytesError::TooLarge(align) => { - cx.sess().emit_err(InvalidMinimumAlignmentTooLarge { align }); + cx.sess().dcx().emit_err(InvalidMinimumAlignmentTooLarge { align }); } }, } @@ -169,7 +169,7 @@ fn check_and_apply_linkage<'ll, 'tcx>( let mut real_name = "_rust_extern_with_linkage_".to_string(); real_name.push_str(sym); let g2 = cx.define_global(&real_name, llty).unwrap_or_else(|| { - cx.sess().emit_fatal(SymbolAlreadyDefined { + cx.sess().dcx().emit_fatal(SymbolAlreadyDefined { span: cx.tcx.def_span(def_id), symbol_name: sym, }) diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 3053c4e0daa..1d1b6e6148d 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -1014,9 +1014,9 @@ impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'_, 'tcx> { #[inline] fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err { - self.sess().emit_fatal(Spanned { span, node: err.into_diagnostic() }) + self.tcx.dcx().emit_fatal(Spanned { span, node: err.into_diagnostic() }) } else { - self.tcx.sess.emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err }) + self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err }) } } } @@ -1032,7 +1032,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> { fn_abi_request: FnAbiRequest<'tcx>, ) -> ! { if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { - self.sess().emit_fatal(Spanned { span, node: err }) + self.tcx.dcx().emit_fatal(Spanned { span, node: err }) } else { match fn_abi_request { FnAbiRequest::OfFnPtr { sig, extra_args } => { diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 58e68a64907..6043a8ebded 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -285,7 +285,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { _ => bug!(), }, None => { - tcx.sess.emit_err(InvalidMonomorphization::BasicIntegerType { + tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty, @@ -921,7 +921,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( ) -> Result<&'ll Value, ()> { macro_rules! return_error { ($diag: expr) => {{ - bx.sess().emit_err($diag); + bx.sess().dcx().emit_err($diag); return Err(()); }}; } @@ -1059,7 +1059,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( .map(|(arg_idx, val)| { let idx = val.unwrap_leaf().try_to_i32().unwrap(); if idx >= i32::try_from(total_len).unwrap() { - bx.sess().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds { + bx.sess().dcx().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds { span, name, arg_idx: arg_idx as u64, @@ -1118,20 +1118,24 @@ fn generic_simd_intrinsic<'ll, 'tcx>( let val = bx.const_get_elt(vector, i as u64); match bx.const_to_opt_u128(val, true) { None => { - bx.sess().emit_err(InvalidMonomorphization::ShuffleIndexNotConstant { - span, - name, - arg_idx, - }); + bx.sess().dcx().emit_err( + InvalidMonomorphization::ShuffleIndexNotConstant { + span, + name, + arg_idx, + }, + ); None } Some(idx) if idx >= total_len => { - bx.sess().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds { - span, - name, - arg_idx, - total_len, - }); + bx.sess().dcx().emit_err( + InvalidMonomorphization::ShuffleIndexOutOfBounds { + span, + name, + arg_idx, + total_len, + }, + ); None } Some(idx) => Some(bx.const_i32(idx as i32)), @@ -1276,7 +1280,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( ) -> Result<&'ll Value, ()> { macro_rules! return_error { ($diag: expr) => {{ - bx.sess().emit_err($diag); + bx.sess().dcx().emit_err($diag); return Err(()); }}; } diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 08519723eba..03b79a143cc 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -529,7 +529,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str Some(c @ ('+' | '-')) => c, Some(_) => { if diagnostics { - sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s }); + sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s }); } return None; } @@ -557,12 +557,12 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str } else { UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None } }; - sess.emit_warning(unknown_feature); + sess.dcx().emit_warning(unknown_feature); } else if feature_state .is_some_and(|(_name, feature_gate)| !feature_gate.is_stable()) { // An unstable feature. Warn about using it. - sess.emit_warning(UnstableCTargetFeature { feature }); + sess.dcx().emit_warning(UnstableCTargetFeature { feature }); } } @@ -598,7 +598,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str features.extend(feats); if diagnostics && let Some(f) = check_tied_features(sess, &featsmap) { - sess.emit_err(TargetFeatureDisableOrEnable { + sess.dcx().emit_err(TargetFeatureDisableOrEnable { features: f, span: None, missing_features: None, diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index 01e82339664..f796ce0990f 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -26,6 +26,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'_, 'tcx> { let g = self.define_global(symbol_name, llty).unwrap_or_else(|| { self.sess() + .dcx() .emit_fatal(SymbolAlreadyDefined { span: self.tcx.def_span(def_id), symbol_name }) }); |
