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
d51db05d7e
commit
99472c7049
298 changed files with 1806 additions and 2064 deletions
|
@ -276,7 +276,7 @@ fn error(
|
|||
sub: GenericConstantTooComplexSub,
|
||||
root_span: Span,
|
||||
) -> Result<!, ErrorGuaranteed> {
|
||||
let reported = tcx.sess.emit_err(GenericConstantTooComplex {
|
||||
let reported = tcx.dcx().emit_err(GenericConstantTooComplex {
|
||||
span: root_span,
|
||||
maybe_supported: None,
|
||||
sub,
|
||||
|
@ -290,7 +290,7 @@ fn maybe_supported_error(
|
|||
sub: GenericConstantTooComplexSub,
|
||||
root_span: Span,
|
||||
) -> Result<!, ErrorGuaranteed> {
|
||||
let reported = tcx.sess.emit_err(GenericConstantTooComplex {
|
||||
let reported = tcx.dcx().emit_err(GenericConstantTooComplex {
|
||||
span: root_span,
|
||||
maybe_supported: Some(()),
|
||||
sub,
|
||||
|
|
|
@ -79,7 +79,7 @@ fn resolve_associated_item<'tcx>(
|
|||
let vtbl = match tcx.codegen_select_candidate((param_env, trait_ref)) {
|
||||
Ok(vtbl) => vtbl,
|
||||
Err(CodegenObligationError::Ambiguity) => {
|
||||
let reported = tcx.sess.span_delayed_bug(
|
||||
let reported = tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(trait_item_id),
|
||||
format!(
|
||||
"encountered ambiguity selecting `{trait_ref:?}` during codegen, presuming due to \
|
||||
|
@ -171,7 +171,7 @@ fn resolve_associated_item<'tcx>(
|
|||
|
||||
// Any final impl is required to define all associated items.
|
||||
if !leaf_def.item.defaultness(tcx).has_value() {
|
||||
let guard = tcx.sess.span_delayed_bug(
|
||||
let guard = tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(leaf_def.item.def_id),
|
||||
"missing value for assoc item in impl",
|
||||
);
|
||||
|
@ -241,7 +241,7 @@ fn resolve_associated_item<'tcx>(
|
|||
args: rcvr_args,
|
||||
})
|
||||
} else {
|
||||
tcx.sess.emit_fatal(UnexpectedFnPtrAssociatedItem {
|
||||
tcx.dcx().emit_fatal(UnexpectedFnPtrAssociatedItem {
|
||||
span: tcx.def_span(trait_item_id),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ fn univariant_uninterned<'tcx>(
|
|||
let dl = cx.data_layout();
|
||||
let pack = repr.pack;
|
||||
if pack.is_some() && repr.align.is_some() {
|
||||
cx.tcx.sess.span_delayed_bug(DUMMY_SP, "struct cannot be packed and aligned");
|
||||
cx.tcx.dcx().span_delayed_bug(DUMMY_SP, "struct cannot be packed and aligned");
|
||||
return Err(cx.tcx.arena.alloc(LayoutError::Unknown(ty)));
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ fn layout_of_uncached<'tcx>(
|
|||
ty::Adt(def, args) if def.repr().simd() => {
|
||||
if !def.is_struct() {
|
||||
// Should have yielded E0517 by now.
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"#[repr(simd)] was applied to an ADT that is not a struct",
|
||||
);
|
||||
|
@ -364,7 +364,7 @@ fn layout_of_uncached<'tcx>(
|
|||
// SIMD vectors with zero fields are not supported.
|
||||
// (should be caught by typeck)
|
||||
if fields.is_empty() {
|
||||
tcx.sess.emit_fatal(ZeroLengthSimdType { ty })
|
||||
tcx.dcx().emit_fatal(ZeroLengthSimdType { ty })
|
||||
}
|
||||
|
||||
// Type of the first ADT field:
|
||||
|
@ -374,7 +374,7 @@ fn layout_of_uncached<'tcx>(
|
|||
// (should be caught by typeck)
|
||||
for fi in fields {
|
||||
if fi.ty(tcx, args) != f0_ty {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"#[repr(simd)] was applied to an ADT with heterogeneous field type",
|
||||
);
|
||||
|
@ -395,7 +395,7 @@ fn layout_of_uncached<'tcx>(
|
|||
// SIMD vectors with multiple array fields are not supported:
|
||||
// Can't be caught by typeck with a generic simd type.
|
||||
if def.non_enum_variant().fields.len() != 1 {
|
||||
tcx.sess.emit_fatal(MultipleArrayFieldsSimdType { ty });
|
||||
tcx.dcx().emit_fatal(MultipleArrayFieldsSimdType { ty });
|
||||
}
|
||||
|
||||
// Extract the number of elements from the layout of the array field:
|
||||
|
@ -415,9 +415,9 @@ fn layout_of_uncached<'tcx>(
|
|||
//
|
||||
// Can't be caught in typeck if the array length is generic.
|
||||
if e_len == 0 {
|
||||
tcx.sess.emit_fatal(ZeroLengthSimdType { ty });
|
||||
tcx.dcx().emit_fatal(ZeroLengthSimdType { ty });
|
||||
} else if e_len > MAX_SIMD_LANES {
|
||||
tcx.sess.emit_fatal(OversizedSimdType { ty, max_lanes: MAX_SIMD_LANES });
|
||||
tcx.dcx().emit_fatal(OversizedSimdType { ty, max_lanes: MAX_SIMD_LANES });
|
||||
}
|
||||
|
||||
// Compute the ABI of the element type:
|
||||
|
@ -425,7 +425,7 @@ fn layout_of_uncached<'tcx>(
|
|||
let Abi::Scalar(e_abi) = e_ly.abi else {
|
||||
// This error isn't caught in typeck, e.g., if
|
||||
// the element type of the vector is generic.
|
||||
tcx.sess.emit_fatal(NonPrimitiveSimdType { ty, e_ty });
|
||||
tcx.dcx().emit_fatal(NonPrimitiveSimdType { ty, e_ty });
|
||||
};
|
||||
|
||||
// Compute the size and alignment of the vector:
|
||||
|
@ -485,7 +485,7 @@ fn layout_of_uncached<'tcx>(
|
|||
|
||||
if def.is_union() {
|
||||
if def.repr().pack.is_some() && def.repr().align.is_some() {
|
||||
cx.tcx.sess.span_delayed_bug(
|
||||
cx.tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(def.did()),
|
||||
"union cannot be packed and aligned",
|
||||
);
|
||||
|
|
|
@ -116,7 +116,7 @@ where
|
|||
if !self.recursion_limit.value_within_limit(level) {
|
||||
// Not having a `Span` isn't great. But there's hopefully some other
|
||||
// recursion limit error as well.
|
||||
tcx.sess.emit_err(NeedsDropOverflow { query_ty: self.query_ty });
|
||||
tcx.dcx().emit_err(NeedsDropOverflow { query_ty: self.query_ty });
|
||||
return Some(Err(AlwaysRequiresDrop));
|
||||
}
|
||||
|
||||
|
|
|
@ -181,14 +181,14 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
|
|||
}
|
||||
}
|
||||
Err(NotUniqueParam::NotParam(arg)) => {
|
||||
self.tcx.sess.emit_err(NotParam {
|
||||
self.tcx.dcx().emit_err(NotParam {
|
||||
arg,
|
||||
span: self.span(),
|
||||
opaque_span: self.tcx.def_span(alias_ty.def_id),
|
||||
});
|
||||
}
|
||||
Err(NotUniqueParam::DuplicateParam(arg)) => {
|
||||
self.tcx.sess.emit_err(DuplicateArg {
|
||||
self.tcx.dcx().emit_err(DuplicateArg {
|
||||
arg,
|
||||
span: self.span(),
|
||||
opaque_span: self.tcx.def_span(alias_ty.def_id),
|
||||
|
@ -238,7 +238,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
|
|||
.instantiate(self.tcx, impl_args)
|
||||
.visit_with(self);
|
||||
} else {
|
||||
self.tcx.sess.span_delayed_bug(
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
self.tcx.def_span(assoc.def_id),
|
||||
"item had incorrect args",
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue