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:
Nicholas Nethercote 2023-12-18 22:21:37 +11:00
parent 472ea06999
commit 02ed790631
8 changed files with 13 additions and 13 deletions

View File

@ -109,7 +109,7 @@ enum ConstraintOrRegister {
impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, span: &[Span], instance: Instance<'_>, _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>) { fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, span: &[Span], instance: Instance<'_>, _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>) {
if options.contains(InlineAsmOptions::MAY_UNWIND) { if options.contains(InlineAsmOptions::MAY_UNWIND) {
self.sess() self.sess().dcx()
.create_err(UnwindingInlineAsm { span: span[0] }) .create_err(UnwindingInlineAsm { span: span[0] })
.emit(); .emit();
return; return;

View File

@ -80,7 +80,7 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
let span = cx.tcx let span = cx.tcx
.get_attr(instance.def_id(), sym::target_feature) .get_attr(instance.def_id(), sym::target_feature)
.map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span); .map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span);
cx.tcx.sess.create_err(TiedTargetFeatures { cx.tcx.dcx().create_err(TiedTargetFeatures {
features: features.join(", "), features: features.join(", "),
span, span,
}) })

View File

@ -24,7 +24,7 @@ fn set_global_alignment<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, gv: LValue<'gcc>
match Align::from_bits(min) { match Align::from_bits(min) {
Ok(min) => align = align.max(min), Ok(min) => align = align.max(min),
Err(err) => { Err(err) => {
cx.sess().emit_err(InvalidMinimumAlignment { err: err.to_string() }); cx.sess().dcx().emit_err(InvalidMinimumAlignment { err: err.to_string() });
} }
} }
} }

View File

@ -500,9 +500,9 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
#[inline] #[inline]
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err { if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
self.sess().emit_fatal(respan(span, err.into_diagnostic())) self.tcx.dcx().emit_fatal(respan(span, err.into_diagnostic()))
} else { } else {
self.tcx.sess.emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err }) self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
} }
} }
} }
@ -518,7 +518,7 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
fn_abi_request: FnAbiRequest<'tcx>, fn_abi_request: FnAbiRequest<'tcx>,
) -> ! { ) -> ! {
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
self.sess().emit_fatal(respan(span, err)) self.tcx.dcx().emit_fatal(respan(span, err))
} else { } else {
match fn_abi_request { match fn_abi_request {
FnAbiRequest::OfFnPtr { sig, extra_args } => { FnAbiRequest::OfFnPtr { sig, extra_args } => {

View File

@ -52,7 +52,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
Some(c @ ('+' | '-')) => c, Some(c @ ('+' | '-')) => c,
Some(_) => { Some(_) => {
if diagnostics { if diagnostics {
sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s }); sess.dcx().emit_warning(UnknownCTargetFeaturePrefix { feature: s });
} }
return None; return None;
} }
@ -79,7 +79,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
else { else {
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None } UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
}; };
sess.emit_warning(unknown_feature); sess.dcx().emit_warning(unknown_feature);
} }
if diagnostics { if diagnostics {
@ -114,7 +114,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
if diagnostics { if diagnostics {
if let Some(f) = check_tied_features(sess, &featsmap) { if let Some(f) = check_tied_features(sess, &featsmap) {
sess.emit_err(TargetFeatureDisableOrEnable { sess.dcx().emit_err(TargetFeatureDisableOrEnable {
features: f, features: f,
span: None, span: None,
missing_features: None, missing_features: None,

View File

@ -262,7 +262,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
_ => bug!(), _ => bug!(),
}, },
None => { None => {
tcx.sess.emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty }); tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty });
return; return;
} }
} }

View File

@ -34,7 +34,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
// macros for error handling: // macros for error handling:
macro_rules! return_error { macro_rules! return_error {
($err:expr) => {{ ($err:expr) => {{
bx.sess().emit_err($err); bx.tcx.dcx().emit_err($err);
return Err(()); return Err(());
}}; }};
} }
@ -390,7 +390,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
) -> Result<RValue<'gcc>, ()> { ) -> Result<RValue<'gcc>, ()> {
macro_rules! return_error { macro_rules! return_error {
($err:expr) => {{ ($err:expr) => {{
bx.sess().emit_err($err); bx.tcx.dcx().emit_err($err);
return Err(()); return Err(());
}}; }};
} }

View File

@ -191,7 +191,7 @@ impl CodegenBackend for GccCodegenBackend {
#[cfg(feature="master")] #[cfg(feature="master")]
gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
if sess.lto() == Lto::Thin { if sess.lto() == Lto::Thin {
sess.emit_warning(LTONotSupported {}); sess.dcx().emit_warning(LTONotSupported {});
} }
#[cfg(not(feature="master"))] #[cfg(not(feature="master"))]