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
|
@ -195,7 +195,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
|
|||
};
|
||||
|
||||
let error_response = |ecx: &mut EvalCtxt<'_, 'tcx>, reason| {
|
||||
let guar = tcx.sess.span_delayed_bug(tcx.def_span(assoc_def.item.def_id), reason);
|
||||
let guar = tcx.dcx().span_delayed_bug(tcx.def_span(assoc_def.item.def_id), reason);
|
||||
let error_term = match assoc_def.item.kind {
|
||||
ty::AssocKind::Const => ty::Const::new_error(
|
||||
tcx,
|
||||
|
@ -286,7 +286,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
|
|||
ecx: &mut EvalCtxt<'_, 'tcx>,
|
||||
goal: Goal<'tcx, Self>,
|
||||
) -> QueryResult<'tcx> {
|
||||
ecx.tcx().sess.span_delayed_bug(
|
||||
ecx.tcx().dcx().span_delayed_bug(
|
||||
ecx.tcx().def_span(goal.predicate.def_id()),
|
||||
"associated types not allowed on auto traits",
|
||||
);
|
||||
|
|
|
@ -787,7 +787,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
Ok(None) => {
|
||||
let tcx = self.tcx;
|
||||
let reported =
|
||||
tcx.sess.emit_err(UnableToConstructConstantValue {
|
||||
tcx.dcx().emit_err(UnableToConstructConstantValue {
|
||||
span: tcx.def_span(unevaluated.def),
|
||||
unevaluated: unevaluated,
|
||||
});
|
||||
|
|
|
@ -65,7 +65,7 @@ pub fn is_const_evaluatable<'tcx>(
|
|||
// FIXME(generic_const_exprs): we have a `ConstKind::Expr` which is fully concrete, but
|
||||
// currently it is not possible to evaluate `ConstKind::Expr` so we are unable to tell if it
|
||||
// is evaluatable or not. For now we just ICE until this is implemented.
|
||||
Err(NotConstEvaluatable::Error(tcx.sess.span_delayed_bug(
|
||||
Err(NotConstEvaluatable::Error(tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
"evaluating `ConstKind::Expr` is not currently supported",
|
||||
)))
|
||||
|
@ -74,7 +74,7 @@ pub fn is_const_evaluatable<'tcx>(
|
|||
let concrete = infcx.const_eval_resolve(param_env, uv, Some(span));
|
||||
match concrete {
|
||||
Err(ErrorHandled::TooGeneric(_)) => {
|
||||
Err(NotConstEvaluatable::Error(infcx.tcx.sess.span_delayed_bug(
|
||||
Err(NotConstEvaluatable::Error(infcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
"Missing value for constant, but no error reported?",
|
||||
)))
|
||||
|
@ -116,7 +116,7 @@ pub fn is_const_evaluatable<'tcx>(
|
|||
param_env,
|
||||
) =>
|
||||
{
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_fatal(
|
||||
// Slightly better span than just using `span` alone
|
||||
if span == rustc_span::DUMMY_SP { tcx.def_span(uv.def) } else { span },
|
||||
|
@ -138,7 +138,7 @@ pub fn is_const_evaluatable<'tcx>(
|
|||
} else if uv.has_non_region_param() {
|
||||
NotConstEvaluatable::MentionsParam
|
||||
} else {
|
||||
let guar = infcx.tcx.sess.span_delayed_bug(
|
||||
let guar = infcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
"Missing value for constant, but no error reported?",
|
||||
);
|
||||
|
|
|
@ -141,7 +141,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
|||
let found_str = args_str(&found_args, &expected_args);
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0593,
|
||||
"{} is expected to take {}, but it takes {}",
|
||||
|
|
|
@ -434,9 +434,9 @@ impl<'tcx> OnUnimplementedDirective {
|
|||
} else {
|
||||
let cond = item_iter
|
||||
.next()
|
||||
.ok_or_else(|| tcx.sess.emit_err(EmptyOnClauseInOnUnimplemented { span }))?
|
||||
.ok_or_else(|| tcx.dcx().emit_err(EmptyOnClauseInOnUnimplemented { span }))?
|
||||
.meta_item()
|
||||
.ok_or_else(|| tcx.sess.emit_err(InvalidOnClauseInOnUnimplemented { span }))?;
|
||||
.ok_or_else(|| tcx.dcx().emit_err(InvalidOnClauseInOnUnimplemented { span }))?;
|
||||
attr::eval_condition(cond, &tcx.sess.parse_sess, Some(tcx.features()), &mut |cfg| {
|
||||
if let Some(value) = cfg.value
|
||||
&& let Err(guar) = parse_value(value, cfg.span)
|
||||
|
@ -528,7 +528,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||
);
|
||||
} else {
|
||||
// nothing found
|
||||
tcx.sess.emit_err(NoValueInOnUnimplemented { span: item.span() });
|
||||
tcx.dcx().emit_err(NoValueInOnUnimplemented { span: item.span() });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -689,7 +689,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||
Ok(None)
|
||||
} else {
|
||||
let reported = tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_delayed_bug(DUMMY_SP, "of_item: neither meta_item_list nor value_str");
|
||||
return Err(reported);
|
||||
};
|
||||
|
@ -829,7 +829,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
|||
);
|
||||
} else {
|
||||
result = Err(struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
self.span,
|
||||
E0230,
|
||||
"there is no parameter `{}` on {}",
|
||||
|
@ -848,7 +848,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
|||
// `{:1}` and `{}` are not to be used
|
||||
Position::ArgumentIs(..) | Position::ArgumentImplicitlyIs(_) => {
|
||||
let reported = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
self.span,
|
||||
E0231,
|
||||
"only named substitution parameters are allowed"
|
||||
|
|
|
@ -2001,7 +2001,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
_ => "function",
|
||||
};
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0631,
|
||||
"type mismatch in {argument_kind} arguments",
|
||||
|
|
|
@ -228,7 +228,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
self.tcx.sess.span_delayed_bug(DUMMY_SP, "expected fulfillment errors")
|
||||
self.dcx().span_delayed_bug(DUMMY_SP, "expected fulfillment errors")
|
||||
}
|
||||
|
||||
/// Reports that an overflow has occurred and halts compilation. We
|
||||
|
@ -281,7 +281,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
pred_str = cx.into_buffer();
|
||||
}
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0275,
|
||||
"overflow evaluating the requirement `{}`",
|
||||
|
@ -386,7 +386,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let mut span = obligation.cause.span;
|
||||
// FIXME: statically guarantee this by tainting after the diagnostic is emitted
|
||||
self.set_tainted_by_errors(
|
||||
tcx.sess.span_delayed_bug(span, "`report_selection_error` did not emit an error"),
|
||||
tcx.dcx().span_delayed_bug(span, "`report_selection_error` did not emit an error"),
|
||||
);
|
||||
|
||||
let mut err = match *error {
|
||||
|
@ -525,7 +525,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
(err_msg, None)
|
||||
};
|
||||
|
||||
let mut err = struct_span_err!(self.tcx.sess, span, E0277, "{}", err_msg);
|
||||
let mut err = struct_span_err!(self.dcx(), span, E0277, "{}", err_msg);
|
||||
|
||||
let mut suggested = false;
|
||||
if is_try_conversion {
|
||||
|
@ -824,7 +824,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
if self.next_trait_solver() {
|
||||
// FIXME: we'll need a better message which takes into account
|
||||
// which bounds actually failed to hold.
|
||||
self.tcx.sess.struct_span_err(
|
||||
self.dcx().struct_span_err(
|
||||
span,
|
||||
format!("the type `{ty}` is not well-formed"),
|
||||
)
|
||||
|
@ -873,7 +873,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
),
|
||||
|
||||
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
|
||||
let mut diag = self.tcx.sess.struct_span_err(
|
||||
let mut diag = self.dcx().struct_span_err(
|
||||
span,
|
||||
format!("the constant `{ct}` is not of type `{ty}`"),
|
||||
);
|
||||
|
@ -1237,7 +1237,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
ty::Float(_) => {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0741,
|
||||
"`{ty}` is forbidden as the type of a const generic parameter",
|
||||
|
@ -1245,7 +1245,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
ty::FnPtr(_) => {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0741,
|
||||
"using function pointers as const generic parameters is forbidden",
|
||||
|
@ -1253,7 +1253,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
ty::RawPtr(_) => {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0741,
|
||||
"using raw pointers as const generic parameters is forbidden",
|
||||
|
@ -1262,7 +1262,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
ty::Adt(def, _) => {
|
||||
// We should probably see if we're *allowed* to derive `ConstParamTy` on the type...
|
||||
let mut diag = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0741,
|
||||
"`{ty}` must implement `ConstParamTy` to be used as the type of a const generic parameter",
|
||||
|
@ -1294,7 +1294,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
_ => {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0741,
|
||||
"`{ty}` can't be used as a const parameter type",
|
||||
|
@ -1731,7 +1731,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
cx.into_buffer()
|
||||
}))
|
||||
});
|
||||
let mut diag = struct_span_err!(self.tcx.sess, obligation.cause.span, E0271, "{msg}");
|
||||
let mut diag = struct_span_err!(self.dcx(), obligation.cause.span, E0271, "{msg}");
|
||||
|
||||
let secondary_span = (|| {
|
||||
let ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) =
|
||||
|
@ -2419,7 +2419,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
)
|
||||
} else {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0283,
|
||||
"type annotations needed: cannot satisfy `{}`",
|
||||
|
@ -2522,7 +2522,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
// Replace the more general E0283 with a more specific error
|
||||
err.cancel();
|
||||
err = self.tcx.sess.struct_span_err_with_code(
|
||||
err = self.dcx().struct_span_err_with_code(
|
||||
span,
|
||||
format!(
|
||||
"cannot {verb} associated {noun} on trait without specifying the \
|
||||
|
@ -2663,7 +2663,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
} else {
|
||||
// If we can't find a substitution, just print a generic error
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0284,
|
||||
"type annotations needed: cannot satisfy `{}`",
|
||||
|
@ -2691,7 +2691,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
} else {
|
||||
// If we can't find a substitution, just print a generic error
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0284,
|
||||
"type annotations needed: cannot satisfy `{}`",
|
||||
|
@ -2706,7 +2706,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
return;
|
||||
}
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.dcx(),
|
||||
span,
|
||||
E0284,
|
||||
"type annotations needed: cannot satisfy `{}`",
|
||||
|
@ -3367,7 +3367,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
self.tcx.sess.create_err(err)
|
||||
self.dcx().create_err(err)
|
||||
}
|
||||
|
||||
fn report_type_parameter_mismatch_cyclic_type_error(
|
||||
|
@ -3405,7 +3405,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
format!("`{}`", self.tcx.def_path_debug_str(def_id))
|
||||
}
|
||||
};
|
||||
let mut err = self.tcx.sess.struct_span_err(
|
||||
let mut err = self.dcx().struct_span_err(
|
||||
obligation.cause.span,
|
||||
format!("cannot check whether the hidden type of {name} satisfies auto traits"),
|
||||
);
|
||||
|
@ -3423,8 +3423,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
if let Some(diag) =
|
||||
self.tcx.sess.dcx().steal_diagnostic(self.tcx.def_span(def_id), StashKey::Cycle)
|
||||
if let Some(diag) = self.dcx().steal_diagnostic(self.tcx.def_span(def_id), StashKey::Cycle)
|
||||
{
|
||||
diag.cancel();
|
||||
}
|
||||
|
@ -3547,8 +3546,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
) -> Option<DiagnosticBuilder<'tcx>> {
|
||||
if !self.tcx.features().generic_const_exprs {
|
||||
let mut err = self
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.struct_span_err(span, "constant expression depends on a generic parameter");
|
||||
// FIXME(const_generics): we should suggest to the user how they can resolve this
|
||||
// issue. However, this is currently not actually possible
|
||||
|
@ -3565,7 +3563,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(ct)) => match ct.kind() {
|
||||
ty::ConstKind::Unevaluated(uv) => {
|
||||
let mut err =
|
||||
self.tcx.sess.struct_span_err(span, "unconstrained generic constant");
|
||||
self.dcx().struct_span_err(span, "unconstrained generic constant");
|
||||
let const_span = self.tcx.def_span(uv.def);
|
||||
match self.tcx.sess.source_map().span_to_snippet(const_span) {
|
||||
Ok(snippet) => err.help(format!(
|
||||
|
@ -3577,8 +3575,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
ty::ConstKind::Expr(_) => {
|
||||
let err = self
|
||||
.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.struct_span_err(span, format!("unconstrained generic constant `{ct}`"));
|
||||
Some(err)
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ pub fn all_fields_implement_trait<'tcx>(
|
|||
// between expected and found const-generic types. Don't report an
|
||||
// additional copy error here, since it's not typically useful.
|
||||
if !normalization_errors.is_empty() || ty.references_error() {
|
||||
tcx.sess.span_delayed_bug(field_span, format!("couldn't normalize struct field `{unnormalized_ty}` when checking {tr} implementation", tr = tcx.def_path_str(trait_def_id)));
|
||||
tcx.dcx().span_delayed_bug(field_span, format!("couldn't normalize struct field `{unnormalized_ty}` when checking {tr} implementation", tr = tcx.def_path_str(trait_def_id)));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ fn do_normalize_predicates<'tcx>(
|
|||
// the normalized predicates.
|
||||
let errors = infcx.resolve_regions(&outlives_env);
|
||||
if !errors.is_empty() {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("failed region resolution while normalizing {elaborated_env:?}: {errors:?}"),
|
||||
);
|
||||
|
|
|
@ -508,7 +508,7 @@ fn virtual_call_violations_for_method<'tcx>(
|
|||
Ok(layout) => Some(layout.abi),
|
||||
Err(err) => {
|
||||
// #78372
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(method.def_id),
|
||||
format!("error: {err}\n while computing layout for type {ty:?}"),
|
||||
);
|
||||
|
@ -524,7 +524,7 @@ fn virtual_call_violations_for_method<'tcx>(
|
|||
match abi_of_ty(unit_receiver_ty) {
|
||||
Some(Abi::Scalar(..)) => (),
|
||||
abi => {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(method.def_id),
|
||||
format!(
|
||||
"receiver when `Self = ()` should have a Scalar ABI; found {abi:?}"
|
||||
|
@ -542,7 +542,7 @@ fn virtual_call_violations_for_method<'tcx>(
|
|||
match abi_of_ty(trait_object_receiver) {
|
||||
Some(Abi::ScalarPair(..)) => (),
|
||||
abi => {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(method.def_id),
|
||||
format!(
|
||||
"receiver when `Self = {trait_object_ty}` should have a ScalarPair ABI; found {abi:?}"
|
||||
|
@ -594,7 +594,7 @@ fn virtual_call_violations_for_method<'tcx>(
|
|||
// would already have reported an error at the definition of the
|
||||
// auto trait.
|
||||
if pred_trait_ref.args.len() != 1 {
|
||||
tcx.sess.dcx().span_delayed_bug(span, "auto traits cannot have generic parameters");
|
||||
tcx.dcx().span_delayed_bug(span, "auto traits cannot have generic parameters");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
|
|||
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
self.tcx.sess.span_delayed_bug(
|
||||
self.dcx().span_delayed_bug(
|
||||
span,
|
||||
"implied_outlives_bounds failed to solve obligations from instantiation",
|
||||
);
|
||||
|
|
|
@ -1369,7 +1369,7 @@ pub fn normalize_inherent_projection<'a, 'b, 'tcx>(
|
|||
|
||||
if !tcx.recursion_limit().value_within_limit(depth) {
|
||||
// Halt compilation because it is important that overflows never be masked.
|
||||
tcx.sess.emit_fatal(InherentProjectionNormalizationOverflow {
|
||||
tcx.dcx().emit_fatal(InherentProjectionNormalizationOverflow {
|
||||
span: cause.span,
|
||||
ty: alias_ty.to_string(),
|
||||
});
|
||||
|
@ -1471,7 +1471,7 @@ pub fn compute_inherent_assoc_ty_args<'a, 'b, 'tcx>(
|
|||
match selcx.infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, impl_ty, self_ty) {
|
||||
Ok(mut ok) => obligations.append(&mut ok.obligations),
|
||||
Err(_) => {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
cause.span,
|
||||
format!(
|
||||
"{self_ty:?} was a subtype of {impl_ty:?} during selection but now it is not"
|
||||
|
@ -1983,7 +1983,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
|||
ImplSource::Builtin(BuiltinImplSource::TraitUpcasting { .. }, _)
|
||||
| ImplSource::Builtin(BuiltinImplSource::TupleUnsizing, _) => {
|
||||
// These traits have no associated types.
|
||||
selcx.tcx().sess.span_delayed_bug(
|
||||
selcx.tcx().dcx().span_delayed_bug(
|
||||
obligation.cause.span,
|
||||
format!("Cannot project an associated type from `{impl_source:?}`"),
|
||||
);
|
||||
|
|
|
@ -237,7 +237,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
|
|||
// By the time this code runs, all type variables ought to
|
||||
// be fully resolved.
|
||||
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("upvar_tys for closure not found. Expected capture information for closure {ty}",),
|
||||
);
|
||||
|
@ -286,7 +286,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
|
|||
if !args.is_valid() {
|
||||
// By the time this code runs, all type variables ought to
|
||||
// be fully resolved.
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("upvar_tys for coroutine not found. Expected capture information for coroutine {ty}",),
|
||||
);
|
||||
|
|
|
@ -292,7 +292,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
|
|||
// Rustdoc normalizes possibly not well-formed types, so only
|
||||
// treat this as a bug if we're not in rustdoc.
|
||||
if !tcx.sess.opts.actually_rustdoc {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("unexpected ambiguity: {c_data:?} {result:?}"),
|
||||
);
|
||||
|
|
|
@ -82,13 +82,13 @@ where
|
|||
let value = infcx.commit_if_ok(|_| {
|
||||
let ocx = ObligationCtxt::new(infcx);
|
||||
let value = op(&ocx).map_err(|_| {
|
||||
infcx.tcx.sess.span_delayed_bug(span, format!("error performing operation: {name}"))
|
||||
infcx.dcx().span_delayed_bug(span, format!("error performing operation: {name}"))
|
||||
})?;
|
||||
let errors = ocx.select_all_or_error();
|
||||
if errors.is_empty() {
|
||||
Ok(value)
|
||||
} else {
|
||||
Err(infcx.tcx.sess.span_delayed_bug(
|
||||
Err(infcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("errors selecting obligation during MIR typeck: {errors:?}"),
|
||||
))
|
||||
|
|
|
@ -159,7 +159,7 @@ where
|
|||
let mut region_constraints = QueryRegionConstraints::default();
|
||||
let (output, error_info, mut obligations, _) =
|
||||
Q::fully_perform_into(self, infcx, &mut region_constraints).map_err(|_| {
|
||||
infcx.tcx.sess.span_delayed_bug(span, format!("error performing {self:?}"))
|
||||
infcx.dcx().span_delayed_bug(span, format!("error performing {self:?}"))
|
||||
})?;
|
||||
|
||||
// Typically, instantiating NLL query results does not
|
||||
|
@ -188,7 +188,7 @@ where
|
|||
}
|
||||
}
|
||||
if !progress {
|
||||
return Err(infcx.tcx.sess.span_delayed_bug(
|
||||
return Err(infcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("ambiguity processing {obligations:?} from {self:?}"),
|
||||
));
|
||||
|
|
|
@ -964,7 +964,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|impl_def_id| {
|
||||
if let Some(old_impl_def_id) = relevant_impl {
|
||||
self.tcx()
|
||||
.sess
|
||||
.dcx()
|
||||
.struct_span_err(
|
||||
self.tcx().def_span(impl_def_id),
|
||||
"multiple drop impls found",
|
||||
|
|
|
@ -558,7 +558,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let defs: &ty::Generics = tcx.generics_of(assoc_type);
|
||||
|
||||
if !defs.params.is_empty() && !tcx.features().generic_associated_types_extended {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
obligation.cause.span,
|
||||
"GATs in trait object shouldn't have been considered",
|
||||
);
|
||||
|
|
|
@ -2426,7 +2426,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||
// the placeholder trait ref may fail due the Generalizer relation
|
||||
// raising a CyclicalTy error due to a sub_root_var relation
|
||||
// for a variable being generalized...
|
||||
let guar = self.infcx.tcx.sess.span_delayed_bug(
|
||||
let guar = self.infcx.dcx().span_delayed_bug(
|
||||
obligation.cause.span,
|
||||
format!(
|
||||
"Impl {impl_def_id:?} was matchable against {obligation:?} but now is not"
|
||||
|
|
|
@ -202,7 +202,7 @@ fn fulfill_implication<'tcx>(
|
|||
{
|
||||
Ok(source_trait_ref) => source_trait_ref,
|
||||
Err(_errors) => {
|
||||
infcx.tcx.sess.span_delayed_bug(
|
||||
infcx.dcx().span_delayed_bug(
|
||||
infcx.tcx.def_span(source_impl),
|
||||
format!("failed to fully normalize {source_trait_ref}"),
|
||||
);
|
||||
|
@ -345,7 +345,7 @@ fn report_negative_positive_conflict<'tcx>(
|
|||
positive_impl_def_id: DefId,
|
||||
sg: &mut specialization_graph::Graph,
|
||||
) {
|
||||
let mut err = tcx.sess.create_err(NegativePositiveConflict {
|
||||
let mut err = tcx.dcx().create_err(NegativePositiveConflict {
|
||||
impl_span: tcx.def_span(local_impl_def_id),
|
||||
trait_desc: overlap.trait_ref,
|
||||
self_ty: overlap.self_ty,
|
||||
|
@ -426,13 +426,13 @@ fn report_conflicting_impls<'tcx>(
|
|||
let reported = if overlap.with_impl.is_local()
|
||||
|| tcx.orphan_check_impl(impl_def_id).is_ok()
|
||||
{
|
||||
let mut err = tcx.sess.struct_span_err(impl_span, msg);
|
||||
let mut err = tcx.dcx().struct_span_err(impl_span, msg);
|
||||
err.code(error_code!(E0119));
|
||||
decorate(tcx, &overlap, impl_span, &mut err);
|
||||
Some(err.emit())
|
||||
} else {
|
||||
Some(
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(impl_span, "impl should have failed the orphan check"),
|
||||
)
|
||||
};
|
||||
|
|
|
@ -135,7 +135,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for Search<'tcx> {
|
|||
bug!("unexpected type during structural-match checking: {:?}", ty);
|
||||
}
|
||||
ty::Error(_) => {
|
||||
self.tcx.sess.span_delayed_bug(self.span, "ty::Error in structural-match check");
|
||||
self.tcx.dcx().span_delayed_bug(self.span, "ty::Error in structural-match check");
|
||||
// We still want to check other types after encountering an error,
|
||||
// as this may still emit relevant errors.
|
||||
return ControlFlow::Continue(());
|
||||
|
|
|
@ -195,7 +195,7 @@ fn dump_vtable_entries<'tcx>(
|
|||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
entries: &[VtblEntry<'tcx>],
|
||||
) {
|
||||
tcx.sess.emit_err(DumpVTableEntries { span: sp, trait_ref, entries: format!("{entries:#?}") });
|
||||
tcx.dcx().emit_err(DumpVTableEntries { span: sp, trait_ref, entries: format!("{entries:#?}") });
|
||||
}
|
||||
|
||||
fn has_own_existential_vtable_entries(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue