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
|
@ -48,7 +48,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
}
|
||||
|
||||
if unbounds.len() > 1 {
|
||||
tcx.sess.emit_err(errors::MultipleRelaxedDefaultBounds {
|
||||
tcx.dcx().emit_err(errors::MultipleRelaxedDefaultBounds {
|
||||
spans: unbounds.iter().map(|ptr| ptr.span).collect(),
|
||||
});
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
}
|
||||
}
|
||||
// There was a `?Trait` bound, but it was not `?Sized`; warn.
|
||||
tcx.sess.span_warn(
|
||||
tcx.dcx().span_warn(
|
||||
unbound.span,
|
||||
"relaxing a default bound only does something for `?Sized`; \
|
||||
all other traits are not bound by default",
|
||||
|
@ -289,7 +289,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
.expect("missing associated item");
|
||||
|
||||
if !assoc_item.visibility(tcx).is_accessible_from(def_scope, tcx) {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(
|
||||
binding.span,
|
||||
format!("{} `{}` is private", assoc_item.kind, binding.item_name),
|
||||
|
@ -303,7 +303,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
dup_bindings
|
||||
.entry(assoc_item.def_id)
|
||||
.and_modify(|prev_span| {
|
||||
tcx.sess.emit_err(errors::ValueOfAssociatedStructAlreadySpecified {
|
||||
tcx.dcx().emit_err(errors::ValueOfAssociatedStructAlreadySpecified {
|
||||
span: binding.span,
|
||||
prev_span: *prev_span,
|
||||
item_name: binding.item_name,
|
||||
|
@ -332,7 +332,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
.into(),
|
||||
ty::GenericParamDefKind::Type { .. } => {
|
||||
if !emitted_bad_param_err {
|
||||
tcx.sess.emit_err(
|
||||
tcx.dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationIllegalParam::Type {
|
||||
span: path_span,
|
||||
param_span: tcx.def_span(param.def_id),
|
||||
|
@ -352,7 +352,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
}
|
||||
ty::GenericParamDefKind::Const { .. } => {
|
||||
if !emitted_bad_param_err {
|
||||
tcx.sess.emit_err(
|
||||
tcx.dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationIllegalParam::Const {
|
||||
span: path_span,
|
||||
param_span: tcx.def_span(param.def_id),
|
||||
|
@ -385,7 +385,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
{
|
||||
alias_ty
|
||||
} else {
|
||||
return Err(self.tcx().sess.emit_err(
|
||||
return Err(self.tcx().dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationOnNonRpitit {
|
||||
span: binding.span,
|
||||
ty: tcx.liberate_late_bound_regions(assoc_item.def_id, output),
|
||||
|
@ -452,7 +452,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
late_bound_in_ty,
|
||||
|br_name| {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
binding.span,
|
||||
E0582,
|
||||
"binding for associated type `{}` references {}, \
|
||||
|
@ -467,7 +467,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
|
||||
match binding.kind {
|
||||
ConvertedBindingKind::Equality(..) if let ty::AssocKind::Fn = assoc_kind => {
|
||||
return Err(self.tcx().sess.emit_err(
|
||||
return Err(self.tcx().dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationEqualityBound { span: binding.span },
|
||||
));
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
return;
|
||||
}
|
||||
|
||||
self.tcx().sess.emit_err(MissingTypeParams {
|
||||
self.tcx().dcx().emit_err(MissingTypeParams {
|
||||
span,
|
||||
def_span: self.tcx().def_span(def_id),
|
||||
span_snippet: self.tcx().sess.source_map().span_to_snippet(span).ok(),
|
||||
|
@ -94,7 +94,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
if is_impl {
|
||||
let trait_name = self.tcx().def_path_str(trait_def_id);
|
||||
self.tcx().sess.emit_err(ManualImplementation { span, trait_name });
|
||||
self.tcx().dcx().emit_err(ManualImplementation { span, trait_name });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
if is_dummy {
|
||||
err.label = Some(errors::AssocItemNotFoundLabel::NotFound { span });
|
||||
return tcx.sess.emit_err(err);
|
||||
return tcx.dcx().emit_err(err);
|
||||
}
|
||||
|
||||
let all_candidate_names: Vec<_> = all_candidates()
|
||||
|
@ -159,7 +159,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
assoc_kind: assoc_kind_str,
|
||||
suggested_name,
|
||||
});
|
||||
return tcx.sess.emit_err(err);
|
||||
return tcx.dcx().emit_err(err);
|
||||
}
|
||||
|
||||
// If we didn't find a good item in the supertraits (or couldn't get
|
||||
|
@ -224,10 +224,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
assoc_kind: assoc_kind_str,
|
||||
suggested_name,
|
||||
});
|
||||
return tcx.sess.emit_err(err);
|
||||
return tcx.dcx().emit_err(err);
|
||||
}
|
||||
|
||||
let mut err = tcx.sess.create_err(err);
|
||||
let mut err = tcx.dcx().create_err(err);
|
||||
if suggest_constraining_type_param(
|
||||
tcx,
|
||||
generics,
|
||||
|
@ -249,7 +249,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
}
|
||||
return err.emit();
|
||||
}
|
||||
return tcx.sess.emit_err(err);
|
||||
return tcx.dcx().emit_err(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
err.label = Some(errors::AssocItemNotFoundLabel::NotFound { span: assoc_name.span });
|
||||
}
|
||||
|
||||
tcx.sess.emit_err(err)
|
||||
tcx.dcx().emit_err(err)
|
||||
}
|
||||
|
||||
fn complain_about_assoc_kind_mismatch(
|
||||
|
@ -327,7 +327,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
(ident.span, None, assoc_kind, assoc_item.kind)
|
||||
};
|
||||
|
||||
tcx.sess.emit_err(errors::AssocKindMismatch {
|
||||
tcx.dcx().emit_err(errors::AssocKindMismatch {
|
||||
span,
|
||||
expected: super::assoc_kind_str(expected),
|
||||
got: super::assoc_kind_str(got),
|
||||
|
@ -346,7 +346,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
span: Span,
|
||||
) -> ErrorGuaranteed {
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx().sess,
|
||||
self.tcx().dcx(),
|
||||
name.span,
|
||||
E0034,
|
||||
"multiple applicable items in scope"
|
||||
|
@ -445,7 +445,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
};
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
name.span,
|
||||
E0220,
|
||||
"associated type `{name}` not found for `{self_ty}` in the current scope"
|
||||
|
@ -536,7 +536,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
bounds.sort();
|
||||
bounds.dedup();
|
||||
|
||||
let mut err = tcx.sess.struct_span_err(
|
||||
let mut err = tcx.dcx().struct_span_err(
|
||||
name.span,
|
||||
format!("the associated type `{name}` exists for `{self_ty}`, but its trait bounds were not satisfied")
|
||||
);
|
||||
|
@ -697,7 +697,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
trait_bound_spans.sort();
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
trait_bound_spans,
|
||||
E0191,
|
||||
"the value of the associated type{} {} must be specified",
|
||||
|
@ -852,7 +852,7 @@ pub fn prohibit_assoc_ty_binding(
|
|||
span: Span,
|
||||
segment: Option<(&hir::PathSegment<'_>, Span)>,
|
||||
) {
|
||||
tcx.sess.emit_err(AssocTypeBindingNotAllowed {
|
||||
tcx.dcx().emit_err(AssocTypeBindingNotAllowed {
|
||||
span,
|
||||
fn_trait_expansion: if let Some((segment, span)) = segment
|
||||
&& segment.args().parenthesized == hir::GenericArgsParentheses::ParenSugar
|
||||
|
|
|
@ -28,7 +28,7 @@ fn generic_arg_mismatch_err(
|
|||
) -> ErrorGuaranteed {
|
||||
let sess = tcx.sess;
|
||||
let mut err = struct_span_err!(
|
||||
sess,
|
||||
tcx.dcx(),
|
||||
arg.span(),
|
||||
E0747,
|
||||
"{} provided when a {} was expected",
|
||||
|
@ -650,7 +650,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
|
|||
if position == GenericArgPosition::Value
|
||||
&& args.num_lifetime_params() != param_counts.lifetimes
|
||||
{
|
||||
let mut err = struct_span_err!(tcx.sess, span, E0794, "{}", msg);
|
||||
let mut err = struct_span_err!(tcx.dcx(), span, E0794, "{}", msg);
|
||||
err.span_note(span_late, note);
|
||||
err.emit();
|
||||
} else {
|
||||
|
|
|
@ -97,7 +97,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let msg = "trait objects must include the `dyn` keyword";
|
||||
let label = "add `dyn` keyword before this trait";
|
||||
let mut diag =
|
||||
rustc_errors::struct_span_err!(tcx.sess, self_ty.span, E0782, "{}", msg);
|
||||
rustc_errors::struct_span_err!(tcx.dcx(), self_ty.span, E0782, "{}", msg);
|
||||
if self_ty.span.can_be_used_for_suggestions() {
|
||||
diag.multipart_suggestion_verbose(
|
||||
label,
|
||||
|
|
|
@ -564,7 +564,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
&& generics.has_self
|
||||
&& !tcx.has_attr(def_id, sym::const_trait)
|
||||
{
|
||||
let e = tcx.sess.emit_err(crate::errors::ConstBoundForNonConstTrait { span });
|
||||
let e = tcx.dcx().emit_err(crate::errors::ConstBoundForNonConstTrait { span });
|
||||
arg_count.correct =
|
||||
Err(GenericArgCountMismatch { reported: Some(e), invalid_args: vec![] });
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
// since we should have emitten an error for them earlier, and they will
|
||||
// not be well-formed!
|
||||
if polarity == ty::ImplPolarity::Negative {
|
||||
self.tcx().sess.span_delayed_bug(
|
||||
self.tcx().dcx().span_delayed_bug(
|
||||
binding.span,
|
||||
"negative trait bounds should not have bindings",
|
||||
);
|
||||
|
@ -863,7 +863,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
traits: &[String],
|
||||
name: Symbol,
|
||||
) -> ErrorGuaranteed {
|
||||
let mut err = struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type");
|
||||
let mut err = struct_span_err!(self.tcx().dcx(), span, E0223, "ambiguous associated type");
|
||||
if self
|
||||
.tcx()
|
||||
.resolutions(())
|
||||
|
@ -1079,7 +1079,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
let assoc_kind_str = assoc_kind_str(assoc_kind);
|
||||
let ty_param_name = &ty_param_name.to_string();
|
||||
let mut err = tcx.sess.create_err(crate::errors::AmbiguousAssocItem {
|
||||
let mut err = tcx.dcx().create_err(crate::errors::AmbiguousAssocItem {
|
||||
span,
|
||||
assoc_kind: assoc_kind_str,
|
||||
assoc_name,
|
||||
|
@ -1312,7 +1312,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
// trait reference.
|
||||
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
|
||||
// A cycle error occurred, most likely.
|
||||
let guar = tcx.sess.span_delayed_bug(span, "expected cycle error");
|
||||
let guar = tcx.dcx().span_delayed_bug(span, "expected cycle error");
|
||||
return Err(guar);
|
||||
};
|
||||
|
||||
|
@ -1339,10 +1339,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let reported = if variant_resolution.is_some() {
|
||||
// Variant in type position
|
||||
let msg = format!("expected type, found variant `{assoc_ident}`");
|
||||
tcx.sess.span_err(span, msg)
|
||||
tcx.dcx().span_err(span, msg)
|
||||
} else if qself_ty.is_enum() {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
assoc_ident.span,
|
||||
E0599,
|
||||
"no variant named `{}` found for enum `{}`",
|
||||
|
@ -1383,7 +1383,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
} else if let ty::Alias(ty::Opaque, alias_ty) = qself_ty.kind() {
|
||||
// `<impl Trait as OtherTrait>::Assoc` makes no sense.
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(alias_ty.def_id),
|
||||
E0667,
|
||||
"`impl Trait` is not allowed in path parameters"
|
||||
|
@ -1643,7 +1643,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let kind = tcx.def_kind_descr(kind, item);
|
||||
let msg = format!("{kind} `{name}` is private");
|
||||
let def_span = tcx.def_span(item);
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err_with_code(span, msg, rustc_errors::error_code!(E0624))
|
||||
.span_label(span, format!("private {kind}"))
|
||||
.span_label(def_span, format!("{kind} defined here"))
|
||||
|
@ -1878,7 +1878,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let last_span = *arg_spans.last().unwrap();
|
||||
let span: MultiSpan = arg_spans.into();
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx().sess,
|
||||
self.tcx().dcx(),
|
||||
span,
|
||||
E0109,
|
||||
"{kind} arguments are not allowed on {this_type}",
|
||||
|
@ -2199,7 +2199,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
// `AlwaysApplicable` impl needs a `T: ?Sized` bound for
|
||||
// this to compile if we were to normalize here.
|
||||
if forbid_generic && ty.has_param() {
|
||||
let mut err = tcx.sess.struct_span_err(
|
||||
let mut err = tcx.dcx().struct_span_err(
|
||||
path.span,
|
||||
"generic `Self` types are currently not permitted in anonymous constants",
|
||||
);
|
||||
|
@ -2260,7 +2260,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
Res::Err => {
|
||||
let e = self
|
||||
.tcx()
|
||||
.sess
|
||||
.dcx()
|
||||
.span_delayed_bug(path.span, "path with `Res::Err` but no error emitted");
|
||||
self.set_tainted_by_errors(e);
|
||||
Ty::new_error(self.tcx(), e)
|
||||
|
@ -2443,7 +2443,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
} else {
|
||||
(ty, None)
|
||||
};
|
||||
tcx.sess.emit_err(TypeofReservedKeywordUsed { span, ty, opt_sugg });
|
||||
tcx.dcx().emit_err(TypeofReservedKeywordUsed { span, ty, opt_sugg });
|
||||
|
||||
ty
|
||||
}
|
||||
|
@ -2629,7 +2629,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
self.validate_late_bound_regions(late_bound_in_args, late_bound_in_ret, |br_name| {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
decl.output.span(),
|
||||
E0581,
|
||||
"return type references {}, which is not constrained by the fn input types",
|
||||
|
@ -2751,7 +2751,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
// error.
|
||||
let r = derived_region_bounds[0];
|
||||
if derived_region_bounds[1..].iter().any(|r1| r != *r1) {
|
||||
tcx.sess.emit_err(AmbiguousLifetimeBound { span });
|
||||
tcx.dcx().emit_err(AmbiguousLifetimeBound { span });
|
||||
}
|
||||
Some(r)
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let first_trait = ®ular_traits[0];
|
||||
let additional_trait = ®ular_traits[1];
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
additional_trait.bottom().1,
|
||||
E0225,
|
||||
"only auto traits can be used as additional traits in a trait object"
|
||||
|
@ -126,7 +126,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
.find(|&trait_ref| tcx.is_trait_alias(trait_ref))
|
||||
.map(|trait_ref| tcx.def_span(trait_ref));
|
||||
let reported =
|
||||
tcx.sess.emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
|
||||
tcx.dcx().emit_err(TraitObjectDeclaredWithNoTraits { span, trait_alias_span });
|
||||
return Ty::new_error(tcx, reported);
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
if references_self {
|
||||
let def_id = i.bottom().0.def_id();
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
i.bottom().1,
|
||||
E0038,
|
||||
"the {} `{}` cannot be made into an object",
|
||||
|
@ -326,7 +326,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
false
|
||||
});
|
||||
if references_self {
|
||||
let guar = tcx.sess.span_delayed_bug(
|
||||
let guar = tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
"trait object projection bounds reference `Self`",
|
||||
);
|
||||
|
@ -375,7 +375,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
} else {
|
||||
self.re_infer(None, span).unwrap_or_else(|| {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
span,
|
||||
E0228,
|
||||
"the lifetime bound for this object type cannot be deduced \
|
||||
|
|
|
@ -249,7 +249,7 @@ pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Spa
|
|||
Limit(0) => Limit(2),
|
||||
limit => limit * 2,
|
||||
};
|
||||
tcx.sess.emit_err(AutoDerefReachedRecursionLimit {
|
||||
tcx.dcx().emit_err(AutoDerefReachedRecursionLimit {
|
||||
span,
|
||||
ty,
|
||||
suggested_limit,
|
||||
|
|
|
@ -38,7 +38,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
|
|||
Some(true) => (),
|
||||
Some(false) => {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
span,
|
||||
E0570,
|
||||
"`{abi}` is not a supported ABI for the current target",
|
||||
|
@ -59,7 +59,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
|
|||
// This ABI is only allowed on function pointers
|
||||
if abi == Abi::CCmseNonSecureCall {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
span,
|
||||
E0781,
|
||||
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers"
|
||||
|
@ -126,7 +126,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
|||
for field in &def.non_enum_variant().fields {
|
||||
let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args))
|
||||
else {
|
||||
tcx.sess.span_delayed_bug(span, "could not normalize field type");
|
||||
tcx.dcx().span_delayed_bug(span, "could not normalize field type");
|
||||
continue;
|
||||
};
|
||||
|
||||
|
@ -136,7 +136,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
|||
Some(Node::Field(field)) => (field.span, field.ty.span),
|
||||
_ => unreachable!("mir field has to correspond to hir field"),
|
||||
};
|
||||
tcx.sess.emit_err(errors::InvalidUnionField {
|
||||
tcx.dcx().emit_err(errors::InvalidUnionField {
|
||||
field_span,
|
||||
sugg: errors::InvalidUnionFieldSuggestion {
|
||||
lo: ty_span.shrink_to_lo(),
|
||||
|
@ -147,7 +147,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
|||
return false;
|
||||
} else if field_ty.needs_drop(tcx, param_env) {
|
||||
// This should never happen. But we can get here e.g. in case of name resolution errors.
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(span, "we should never accept maybe-dropping union fields");
|
||||
}
|
||||
}
|
||||
|
@ -173,12 +173,12 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
if matches!(tcx.def_kind(def_id), DefKind::Static(_)
|
||||
if tcx.def_kind(tcx.local_parent(def_id)) == DefKind::ForeignMod) =>
|
||||
{
|
||||
tcx.sess.emit_err(errors::TooLargeStatic { span });
|
||||
tcx.dcx().emit_err(errors::TooLargeStatic { span });
|
||||
return;
|
||||
}
|
||||
// Generic statics are rejected, but we still reach this case.
|
||||
Err(e) => {
|
||||
tcx.sess.span_delayed_bug(span, format!("{e:?}"));
|
||||
tcx.dcx().span_delayed_bug(span, format!("{e:?}"));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -201,7 +201,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
||||
let item = tcx.hir().item(id);
|
||||
let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else {
|
||||
tcx.sess.span_delayed_bug(item.span, "expected opaque item");
|
||||
tcx.dcx().span_delayed_bug(item.span, "expected opaque item");
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -310,7 +310,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||
Ok(()) => {}
|
||||
Err(ty_err) => {
|
||||
let ty_err = ty_err.to_string(tcx);
|
||||
return Err(tcx.sess.span_delayed_bug(
|
||||
return Err(tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
|
||||
));
|
||||
|
@ -435,7 +435,7 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
ty::Adt(adt_def, args) => !is_enum_of_nonnullable_ptr(tcx, *adt_def, *args),
|
||||
_ => true,
|
||||
} {
|
||||
tcx.sess.emit_err(LinkageType { span: tcx.def_span(def_id) });
|
||||
tcx.dcx().emit_err(LinkageType { span: tcx.def_span(def_id) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
|||
_ => ("type or const", "types or consts", None),
|
||||
};
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
item.span,
|
||||
E0044,
|
||||
"foreign items may not have {kinds} parameters",
|
||||
|
@ -652,7 +652,7 @@ pub(super) fn check_specialization_validity<'tcx>(
|
|||
if !tcx.is_impl_trait_in_trait(impl_item) {
|
||||
report_forbidden_specialization(tcx, impl_item, parent_impl);
|
||||
} else {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!("parent item: {parent_impl:?} not marked as default"),
|
||||
);
|
||||
|
@ -681,7 +681,7 @@ fn check_impl_items_against_trait<'tcx>(
|
|||
if let [first_item_ref, ..] = impl_item_refs {
|
||||
let first_item_span = tcx.def_span(first_item_ref);
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
first_item_span,
|
||||
E0749,
|
||||
"negative impls cannot have any items"
|
||||
|
@ -700,7 +700,7 @@ fn check_impl_items_against_trait<'tcx>(
|
|||
tcx.associated_item(trait_item_id)
|
||||
} else {
|
||||
// Checked in `associated_item`.
|
||||
tcx.sess.span_delayed_bug(tcx.def_span(impl_item), "missing associated item in trait");
|
||||
tcx.dcx().span_delayed_bug(tcx.def_span(impl_item), "missing associated item in trait");
|
||||
continue;
|
||||
};
|
||||
match ty_impl_item.kind {
|
||||
|
@ -795,7 +795,7 @@ fn check_impl_items_against_trait<'tcx>(
|
|||
"return position `impl Trait` in traits",
|
||||
)
|
||||
};
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(tcx.def_span(def_id), msg)
|
||||
.note(format!(
|
||||
"specialization behaves in inconsistent and \
|
||||
|
@ -833,12 +833,12 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
|||
{
|
||||
let fields = &def.non_enum_variant().fields;
|
||||
if fields.is_empty() {
|
||||
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
return;
|
||||
}
|
||||
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
|
||||
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
|
||||
struct_span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous")
|
||||
struct_span_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
|
||||
.span_label(sp, "SIMD elements must have the same type")
|
||||
.emit();
|
||||
return;
|
||||
|
@ -851,11 +851,11 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
|||
};
|
||||
if let Some(len) = len {
|
||||
if len == 0 {
|
||||
struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
|
||||
return;
|
||||
} else if len > MAX_SIMD_LANES {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0075,
|
||||
"SIMD vector cannot have more than {MAX_SIMD_LANES} elements",
|
||||
|
@ -878,7 +878,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
|
|||
{ /* struct([f32; 4]) is ok */ }
|
||||
_ => {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0077,
|
||||
"SIMD vector element type should be a \
|
||||
|
@ -901,7 +901,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
|||
&& pack as u64 != repr_pack.bytes()
|
||||
{
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0634,
|
||||
"type has conflicting packed representation hints"
|
||||
|
@ -912,7 +912,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
|||
}
|
||||
if repr.align.is_some() {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0587,
|
||||
"type has conflicting packed and align representation hints"
|
||||
|
@ -921,7 +921,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
|
|||
} else {
|
||||
if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
sp,
|
||||
E0588,
|
||||
"packed type cannot transitively contain a `#[repr(align)]` type"
|
||||
|
@ -1111,7 +1111,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
if def.variants().is_empty() {
|
||||
if let Some(attr) = tcx.get_attrs(def_id, sym::repr).next() {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
attr.span,
|
||||
E0084,
|
||||
"unsupported representation for zero-variant enum"
|
||||
|
@ -1150,7 +1150,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
|
||||
if disr_non_unit || (disr_units && has_non_units) {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(def_id),
|
||||
E0732,
|
||||
"`#[repr(inttype)]` must be specified"
|
||||
|
@ -1236,7 +1236,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
|
|||
if discrs[i].1.val == discrs[o].1.val {
|
||||
let err = error.get_or_insert_with(|| {
|
||||
let mut ret = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(adt.did()),
|
||||
E0081,
|
||||
"discriminant value `{}` assigned more than once",
|
||||
|
@ -1302,7 +1302,7 @@ pub(super) fn check_type_params_are_used<'tcx>(
|
|||
&& let ty::GenericParamDefKind::Type { .. } = param.kind
|
||||
{
|
||||
let span = tcx.def_span(param.def_id);
|
||||
struct_span_err!(tcx.sess, span, E0091, "type parameter `{}` is unused", param.name,)
|
||||
struct_span_err!(tcx.dcx(), span, E0091, "type parameter `{}` is unused", param.name,)
|
||||
.span_label(span, "unused type parameter")
|
||||
.emit();
|
||||
}
|
||||
|
@ -1320,7 +1320,7 @@ pub(super) fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalModDefId
|
|||
}
|
||||
|
||||
fn async_opaque_type_cycle_error(tcx: TyCtxt<'_>, span: Span) -> ErrorGuaranteed {
|
||||
struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing")
|
||||
struct_span_err!(tcx.dcx(), span, E0733, "recursion in an `async fn` requires boxing")
|
||||
.span_label(span, "recursive `async fn`")
|
||||
.note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`")
|
||||
.note(
|
||||
|
@ -1342,7 +1342,7 @@ fn opaque_type_cycle_error(
|
|||
opaque_def_id: LocalDefId,
|
||||
span: Span,
|
||||
) -> ErrorGuaranteed {
|
||||
let mut err = struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type");
|
||||
let mut err = struct_span_err!(tcx.dcx(), span, E0720, "cannot resolve opaque type");
|
||||
|
||||
let mut label = false;
|
||||
if let Some((def_id, visitor)) = get_owner_return_paths(tcx, opaque_def_id) {
|
||||
|
|
|
@ -429,7 +429,7 @@ fn compare_asyncness<'tcx>(
|
|||
}
|
||||
_ => {
|
||||
return Err(tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.create_err(crate::errors::AsyncTraitImplShouldBeAsync {
|
||||
span: tcx.def_span(impl_m.def_id),
|
||||
method_name: trait_m.name,
|
||||
|
@ -626,7 +626,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
|||
Ok(()) => {}
|
||||
Err(terr) => {
|
||||
let mut diag = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
cause.span(),
|
||||
E0053,
|
||||
"method `{}` has an incompatible return type for trait",
|
||||
|
@ -759,7 +759,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
|||
remapped_types.insert(def_id, ty::EarlyBinder::bind(ty));
|
||||
}
|
||||
Err(err) => {
|
||||
let reported = tcx.sess.span_delayed_bug(
|
||||
let reported = tcx.dcx().span_delayed_bug(
|
||||
return_span,
|
||||
format!("could not fully resolve: {ty} => {err:?}"),
|
||||
);
|
||||
|
@ -929,7 +929,7 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
|||
self.return_span
|
||||
};
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.struct_span_err(
|
||||
return_span,
|
||||
"return type captures more lifetimes than trait definition",
|
||||
|
@ -943,7 +943,7 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
|||
.emit()
|
||||
}
|
||||
_ => {
|
||||
self.tcx.sess.span_delayed_bug(DUMMY_SP, "should've been able to remap region")
|
||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, "should've been able to remap region")
|
||||
}
|
||||
};
|
||||
return Err(guar);
|
||||
|
@ -973,7 +973,7 @@ fn report_trait_method_mismatch<'tcx>(
|
|||
extract_spans_for_error_reporting(infcx, terr, &cause, impl_m, trait_m);
|
||||
|
||||
let mut diag = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_err_span,
|
||||
E0053,
|
||||
"method `{}` has an incompatible type for trait",
|
||||
|
@ -1134,7 +1134,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
|
|||
}
|
||||
}
|
||||
let reported = tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.create_err(LifetimesOrBoundsMismatchOnTrait {
|
||||
span,
|
||||
item_kind: assoc_item_kind_str(&impl_m),
|
||||
|
@ -1218,7 +1218,7 @@ fn compare_self_type<'tcx>(
|
|||
let self_descr = self_string(impl_m);
|
||||
let impl_m_span = tcx.def_span(impl_m.def_id);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_m_span,
|
||||
E0185,
|
||||
"method `{}` has a `{}` declaration in the impl, but not in the trait",
|
||||
|
@ -1238,7 +1238,7 @@ fn compare_self_type<'tcx>(
|
|||
let self_descr = self_string(trait_m);
|
||||
let impl_m_span = tcx.def_span(impl_m.def_id);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_m_span,
|
||||
E0186,
|
||||
"method `{}` has a `{}` declaration in the trait, but not in the impl",
|
||||
|
@ -1303,7 +1303,7 @@ fn compare_number_of_generics<'tcx>(
|
|||
// inheriting the generics from will also have mismatched arguments, and
|
||||
// we'll report an error for that instead. Delay a bug for safety, though.
|
||||
if trait_.is_impl_trait_in_trait() {
|
||||
return Err(tcx.sess.span_delayed_bug(
|
||||
return Err(tcx.dcx().span_delayed_bug(
|
||||
rustc_span::DUMMY_SP,
|
||||
"errors comparing numbers of generics of trait/impl functions were not emitted",
|
||||
));
|
||||
|
@ -1371,7 +1371,7 @@ fn compare_number_of_generics<'tcx>(
|
|||
let spans = arg_spans(impl_.kind, impl_item.generics);
|
||||
let span = spans.first().copied();
|
||||
|
||||
let mut err = tcx.sess.struct_span_err_with_code(
|
||||
let mut err = tcx.dcx().struct_span_err_with_code(
|
||||
spans,
|
||||
format!(
|
||||
"{} `{}` has {} {kind} parameter{} but its trait \
|
||||
|
@ -1464,7 +1464,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
|||
.unwrap_or_else(|| tcx.def_span(impl_m.def_id));
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_span,
|
||||
E0050,
|
||||
"method `{}` has {} but the declaration in trait `{}` has {}",
|
||||
|
@ -1531,7 +1531,7 @@ fn compare_synthetic_generics<'tcx>(
|
|||
let impl_span = tcx.def_span(impl_def_id);
|
||||
let trait_span = tcx.def_span(trait_def_id);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_span,
|
||||
E0643,
|
||||
"method `{}` has incompatible signature for trait",
|
||||
|
@ -1690,7 +1690,7 @@ fn compare_generic_param_kinds<'tcx>(
|
|||
let param_trait_span = tcx.def_span(param_trait.def_id);
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
param_impl_span,
|
||||
E0053,
|
||||
"{} `{}` has an incompatible generic parameter for trait `{}`",
|
||||
|
@ -1837,7 +1837,7 @@ fn compare_const_predicate_entailment<'tcx>(
|
|||
cause.span = ty.span;
|
||||
|
||||
let mut diag = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
cause.span,
|
||||
E0326,
|
||||
"implemented const `{}` has an incompatible type for trait",
|
||||
|
|
|
@ -153,7 +153,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
|||
trait_m_sig.inputs_and_output,
|
||||
));
|
||||
if !ocx.select_all_or_error().is_empty() {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"encountered errors when checking RPITIT refinement (selection)",
|
||||
);
|
||||
|
@ -165,7 +165,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
|||
);
|
||||
let errors = infcx.resolve_regions(&outlives_env);
|
||||
if !errors.is_empty() {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"encountered errors when checking RPITIT refinement (regions)",
|
||||
);
|
||||
|
@ -173,7 +173,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
|
|||
}
|
||||
// Resolve any lifetime variables that may have been introduced during normalization.
|
||||
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
"encountered errors when checking RPITIT refinement (resolution)",
|
||||
);
|
||||
|
|
|
@ -34,12 +34,12 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
|
|||
match tcx.impl_polarity(drop_impl_did) {
|
||||
ty::ImplPolarity::Positive => {}
|
||||
ty::ImplPolarity::Negative => {
|
||||
return Err(tcx.sess.emit_err(errors::DropImplPolarity::Negative {
|
||||
return Err(tcx.dcx().emit_err(errors::DropImplPolarity::Negative {
|
||||
span: tcx.def_span(drop_impl_did),
|
||||
}));
|
||||
}
|
||||
ty::ImplPolarity::Reservation => {
|
||||
return Err(tcx.sess.emit_err(errors::DropImplPolarity::Reservation {
|
||||
return Err(tcx.dcx().emit_err(errors::DropImplPolarity::Reservation {
|
||||
span: tcx.def_span(drop_impl_did),
|
||||
}));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
|
|||
// already checked by coherence, but compilation may
|
||||
// not have been terminated.
|
||||
let span = tcx.def_span(drop_impl_did);
|
||||
let reported = tcx.sess.span_delayed_bug(
|
||||
let reported = tcx.dcx().span_delayed_bug(
|
||||
span,
|
||||
format!("should have been rejected by coherence check: {dtor_self_type}"),
|
||||
);
|
||||
|
@ -89,7 +89,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
|
|||
let item_span = tcx.def_span(self_type_did);
|
||||
let self_descr = tcx.def_descr(self_type_did);
|
||||
let mut err =
|
||||
struct_span_err!(tcx.sess, drop_impl_span, E0366, "`Drop` impls cannot be specialized");
|
||||
struct_span_err!(tcx.dcx(), drop_impl_span, E0366, "`Drop` impls cannot be specialized");
|
||||
match arg {
|
||||
ty::util::NotUniqueParam::DuplicateParam(arg) => {
|
||||
err.note(format!("`{arg}` is mentioned multiple times"))
|
||||
|
@ -155,7 +155,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
|||
let self_descr = tcx.def_descr(adt_def_id.to_def_id());
|
||||
guar = Some(
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
error.root_obligation.cause.span,
|
||||
E0367,
|
||||
"`Drop` impl requires `{root_predicate}` \
|
||||
|
@ -187,7 +187,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
|||
};
|
||||
guar = Some(
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
error.origin().span(),
|
||||
E0367,
|
||||
"`Drop` impl requires `{outlives}` \
|
||||
|
|
|
@ -96,12 +96,13 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
let main_asyncness = tcx.asyncness(main_def_id);
|
||||
if main_asyncness.is_async() {
|
||||
let asyncness_span = main_fn_asyncness_span(tcx, main_def_id);
|
||||
tcx.sess.emit_err(errors::MainFunctionAsync { span: main_span, asyncness: asyncness_span });
|
||||
tcx.dcx()
|
||||
.emit_err(errors::MainFunctionAsync { span: main_span, asyncness: asyncness_span });
|
||||
error = true;
|
||||
}
|
||||
|
||||
for attr in tcx.get_attrs(main_def_id, sym::track_caller) {
|
||||
tcx.sess.emit_err(errors::TrackCallerOnMain { span: attr.span, annotated: main_span });
|
||||
tcx.dcx().emit_err(errors::TrackCallerOnMain { span: attr.span, annotated: main_span });
|
||||
error = true;
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
&& !tcx.sess.target.is_like_wasm
|
||||
&& !tcx.sess.opts.actually_rustdoc
|
||||
{
|
||||
tcx.sess.emit_err(errors::TargetFeatureOnMain { main: main_span });
|
||||
tcx.dcx().emit_err(errors::TargetFeatureOnMain { main: main_span });
|
||||
error = true;
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
let return_ty = main_fnsig.output();
|
||||
let return_ty_span = main_fn_return_type_span(tcx, main_def_id).unwrap_or(main_span);
|
||||
let Some(return_ty) = return_ty.no_bound_vars() else {
|
||||
tcx.sess.emit_err(errors::MainFunctionReturnTypeGeneric { span: return_ty_span });
|
||||
tcx.dcx().emit_err(errors::MainFunctionReturnTypeGeneric { span: return_ty_span });
|
||||
return;
|
||||
};
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
|
@ -180,14 +181,14 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
|||
let main_fn_predicates = tcx.predicates_of(main_def_id);
|
||||
if main_fn_generics.count() != 0 || !main_fnsig.bound_vars().is_empty() {
|
||||
let generics_param_span = main_fn_generics_params_span(tcx, main_def_id);
|
||||
tcx.sess.emit_err(errors::MainFunctionGenericParameters {
|
||||
tcx.dcx().emit_err(errors::MainFunctionGenericParameters {
|
||||
span: generics_param_span.unwrap_or(main_span),
|
||||
label_span: generics_param_span,
|
||||
});
|
||||
} else if !main_fn_predicates.predicates.is_empty() {
|
||||
// generics may bring in implicit predicates, so we skip this check if generics is present.
|
||||
let generics_where_clauses_span = main_fn_where_clauses_span(tcx, main_def_id);
|
||||
tcx.sess.emit_err(errors::WhereClauseOnMain {
|
||||
tcx.dcx().emit_err(errors::WhereClauseOnMain {
|
||||
span: generics_where_clauses_span.unwrap_or(main_span),
|
||||
generics_span: generics_where_clauses_span,
|
||||
});
|
||||
|
@ -205,25 +206,25 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
|||
if let hir::ItemKind::Fn(sig, generics, _) = &it.kind {
|
||||
let mut error = false;
|
||||
if !generics.params.is_empty() {
|
||||
tcx.sess.emit_err(errors::StartFunctionParameters { span: generics.span });
|
||||
tcx.dcx().emit_err(errors::StartFunctionParameters { span: generics.span });
|
||||
error = true;
|
||||
}
|
||||
if generics.has_where_clause_predicates {
|
||||
tcx.sess.emit_err(errors::StartFunctionWhere {
|
||||
tcx.dcx().emit_err(errors::StartFunctionWhere {
|
||||
span: generics.where_clause_span,
|
||||
});
|
||||
error = true;
|
||||
}
|
||||
if sig.header.asyncness.is_async() {
|
||||
let span = tcx.def_span(it.owner_id);
|
||||
tcx.sess.emit_err(errors::StartAsync { span: span });
|
||||
tcx.dcx().emit_err(errors::StartAsync { span: span });
|
||||
error = true;
|
||||
}
|
||||
|
||||
let attrs = tcx.hir().attrs(start_id);
|
||||
for attr in attrs {
|
||||
if attr.has_name(sym::track_caller) {
|
||||
tcx.sess.emit_err(errors::StartTrackCaller {
|
||||
tcx.dcx().emit_err(errors::StartTrackCaller {
|
||||
span: attr.span,
|
||||
start: start_span,
|
||||
});
|
||||
|
@ -235,7 +236,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
|||
&& !tcx.sess.target.is_like_wasm
|
||||
&& !tcx.sess.opts.actually_rustdoc
|
||||
{
|
||||
tcx.sess.emit_err(errors::StartTargetFeature {
|
||||
tcx.dcx().emit_err(errors::StartTargetFeature {
|
||||
span: attr.span,
|
||||
start: start_span,
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ fn equate_intrinsic_type<'tcx>(
|
|||
(own_counts, generics.span)
|
||||
}
|
||||
_ => {
|
||||
struct_span_err!(tcx.sess, it.span, E0622, "intrinsic must be a function")
|
||||
struct_span_err!(tcx.dcx(), it.span, E0622, "intrinsic must be a function")
|
||||
.span_label(it.span, "expected a function")
|
||||
.emit();
|
||||
return;
|
||||
|
@ -38,7 +38,7 @@ fn equate_intrinsic_type<'tcx>(
|
|||
|
||||
let gen_count_ok = |found: usize, expected: usize, descr: &str| -> bool {
|
||||
if found != expected {
|
||||
tcx.sess.emit_err(WrongNumberOfGenericArgumentsToIntrinsic {
|
||||
tcx.dcx().emit_err(WrongNumberOfGenericArgumentsToIntrinsic {
|
||||
span,
|
||||
found,
|
||||
expected,
|
||||
|
@ -117,7 +117,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: DefId) -> hir
|
|||
};
|
||||
|
||||
if has_safe_attr != is_in_list {
|
||||
tcx.sess.struct_span_err(
|
||||
tcx.dcx().struct_span_err(
|
||||
tcx.def_span(intrinsic_id),
|
||||
DiagnosticMessage::from(format!(
|
||||
"intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `{}`",
|
||||
|
@ -176,7 +176,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
|||
| "umin" => (1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], param(0)),
|
||||
"fence" | "singlethreadfence" => (0, Vec::new(), Ty::new_unit(tcx)),
|
||||
op => {
|
||||
tcx.sess.emit_err(UnrecognizedAtomicOperation { span: it.span, op });
|
||||
tcx.dcx().emit_err(UnrecognizedAtomicOperation { span: it.span, op });
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -460,7 +460,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
|||
}
|
||||
|
||||
other => {
|
||||
tcx.sess.emit_err(UnrecognizedIntrinsicFunction { span: it.span, name: other });
|
||||
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span: it.span, name: other });
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -552,7 +552,7 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
|
|||
sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)),
|
||||
_ => {
|
||||
let msg = format!("unrecognized platform-specific intrinsic function: `{name}`");
|
||||
tcx.sess.struct_span_err(it.span, msg).emit();
|
||||
tcx.dcx().struct_span_err(it.span, msg).emit();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -153,7 +153,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
};
|
||||
let Some(asm_ty) = asm_ty else {
|
||||
let msg = format!("cannot use value of type `{ty}` for inline assembly");
|
||||
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(expr.span, msg);
|
||||
err.note(
|
||||
"only integers, floats, SIMD vectors, pointers and function pointers \
|
||||
can be used as arguments for inline assembly",
|
||||
|
@ -166,7 +166,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
// possibly fail is for SIMD types which don't #[derive(Copy)].
|
||||
if !ty.is_copy_modulo_regions(self.tcx, self.param_env) {
|
||||
let msg = "arguments for inline assembly must be copyable";
|
||||
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(expr.span, msg);
|
||||
err.note(format!("`{ty}` does not implement the Copy trait"));
|
||||
err.emit();
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
if let Some((in_expr, Some(in_asm_ty))) = tied_input {
|
||||
if in_asm_ty != asm_ty {
|
||||
let msg = "incompatible types for asm inout argument";
|
||||
let mut err = self.tcx.sess.struct_span_err(vec![in_expr.span, expr.span], msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(vec![in_expr.span, expr.span], msg);
|
||||
|
||||
let in_expr_ty = (self.get_operand_ty)(in_expr);
|
||||
err.span_label(in_expr.span, format!("type `{in_expr_ty}`"));
|
||||
|
@ -207,7 +207,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
let supported_tys = reg_class.supported_types(asm_arch);
|
||||
let Some((_, feature)) = supported_tys.iter().find(|&&(t, _)| t == asm_ty) else {
|
||||
let msg = format!("type `{ty}` cannot be used with this register class");
|
||||
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(expr.span, msg);
|
||||
let supported_tys: Vec<_> = supported_tys.iter().map(|(t, _)| t.to_string()).collect();
|
||||
err.note(format!(
|
||||
"register class `{}` supports these types: {}",
|
||||
|
@ -234,7 +234,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
if let Some(feature) = feature {
|
||||
if !target_features.contains(feature) {
|
||||
let msg = format!("`{feature}` target feature is not enabled");
|
||||
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
|
||||
let mut err = self.tcx.dcx().struct_span_err(expr.span, msg);
|
||||
err.note(format!(
|
||||
"this is required to use type `{}` with register class `{}`",
|
||||
ty,
|
||||
|
@ -287,7 +287,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
pub fn check_asm(&self, asm: &hir::InlineAsm<'tcx>, enclosing_id: LocalDefId) {
|
||||
let target_features = self.tcx.asm_target_features(enclosing_id.to_def_id());
|
||||
let Some(asm_arch) = self.tcx.sess.asm_arch else {
|
||||
self.tcx.sess.span_delayed_bug(DUMMY_SP, "target architecture does not support asm");
|
||||
self.tcx.dcx().span_delayed_bug(DUMMY_SP, "target architecture does not support asm");
|
||||
return;
|
||||
};
|
||||
for (idx, (op, op_sp)) in asm.operands.iter().enumerate() {
|
||||
|
@ -318,7 +318,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
op.is_clobber(),
|
||||
) {
|
||||
let msg = format!("cannot use register `{}`: {}", reg.name(), msg);
|
||||
self.tcx.sess.struct_span_err(*op_sp, msg).emit();
|
||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
reg_class.name(),
|
||||
feature
|
||||
);
|
||||
self.tcx.sess.struct_span_err(*op_sp, msg).emit();
|
||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
||||
// register isn't enabled, don't do more checks
|
||||
continue;
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
.intersperse(", ")
|
||||
.collect::<String>(),
|
||||
);
|
||||
self.tcx.sess.struct_span_err(*op_sp, msg).emit();
|
||||
self.tcx.dcx().struct_span_err(*op_sp, msg).emit();
|
||||
// register isn't enabled, don't do more checks
|
||||
continue;
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
|
|||
ty::FnDef(..) => {}
|
||||
_ => {
|
||||
let mut err =
|
||||
self.tcx.sess.struct_span_err(*op_sp, "invalid `sym` operand");
|
||||
self.tcx.dcx().struct_span_err(*op_sp, "invalid `sym` operand");
|
||||
err.span_label(
|
||||
self.tcx.def_span(anon_const.def_id),
|
||||
format!("is {} `{}`", ty.kind().article(), ty),
|
||||
|
|
|
@ -144,7 +144,7 @@ fn get_owner_return_paths(
|
|||
// FIXME: Move this to a more appropriate place.
|
||||
pub fn forbid_intrinsic_abi(tcx: TyCtxt<'_>, sp: Span, abi: Abi) {
|
||||
if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = abi {
|
||||
tcx.sess.span_err(sp, "intrinsic must be in `extern \"rust-intrinsic\" { ... }` block");
|
||||
tcx.dcx().span_err(sp, "intrinsic must be in `extern \"rust-intrinsic\" { ... }` block");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
|
|||
let msg = "statics with a custom `#[link_section]` must be a \
|
||||
simple list of bytes on the wasm target with no \
|
||||
extra levels of indirection such as references";
|
||||
tcx.sess.span_err(tcx.def_span(id), msg);
|
||||
tcx.dcx().span_err(tcx.def_span(id), msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ fn report_forbidden_specialization(tcx: TyCtxt<'_>, impl_item: DefId, parent_imp
|
|||
Err(cname) => errors::ImplNotMarkedDefault::Err { span, ident, cname },
|
||||
};
|
||||
|
||||
tcx.sess.emit_err(err);
|
||||
tcx.dcx().emit_err(err);
|
||||
}
|
||||
|
||||
fn missing_items_err(
|
||||
|
@ -240,7 +240,7 @@ fn missing_items_err(
|
|||
}
|
||||
}
|
||||
|
||||
tcx.sess.emit_err(errors::MissingTraitItem {
|
||||
tcx.dcx().emit_err(errors::MissingTraitItem {
|
||||
span: tcx.span_of_impl(impl_def_id.to_def_id()).unwrap(),
|
||||
missing_items_msg,
|
||||
missing_trait_item_label,
|
||||
|
@ -258,7 +258,7 @@ fn missing_items_must_implement_one_of_err(
|
|||
let missing_items_msg =
|
||||
missing_items.iter().map(Ident::to_string).collect::<Vec<_>>().join("`, `");
|
||||
|
||||
tcx.sess.emit_err(errors::MissingOneOfTraitItem {
|
||||
tcx.dcx().emit_err(errors::MissingOneOfTraitItem {
|
||||
span: impl_span,
|
||||
note: annotation_span,
|
||||
missing_items_msg,
|
||||
|
@ -283,7 +283,7 @@ fn default_body_is_unstable(
|
|||
None => none_note = true,
|
||||
};
|
||||
|
||||
let mut err = tcx.sess.create_err(errors::MissingTraitItemUnstable {
|
||||
let mut err = tcx.dcx().create_err(errors::MissingTraitItemUnstable {
|
||||
span: impl_span,
|
||||
some_note,
|
||||
none_note,
|
||||
|
@ -526,7 +526,7 @@ fn bad_variant_count<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>, sp: Span, d
|
|||
spans = start.to_vec();
|
||||
many = Some(*end);
|
||||
}
|
||||
tcx.sess.emit_err(errors::TransparentEnumVariant {
|
||||
tcx.dcx().emit_err(errors::TransparentEnumVariant {
|
||||
span: sp,
|
||||
spans,
|
||||
many,
|
||||
|
@ -545,14 +545,14 @@ fn bad_non_zero_sized_fields<'tcx>(
|
|||
sp: Span,
|
||||
) {
|
||||
if adt.is_enum() {
|
||||
tcx.sess.emit_err(errors::TransparentNonZeroSizedEnum {
|
||||
tcx.dcx().emit_err(errors::TransparentNonZeroSizedEnum {
|
||||
span: sp,
|
||||
spans: field_spans.collect(),
|
||||
field_count,
|
||||
desc: adt.descr(),
|
||||
});
|
||||
} else {
|
||||
tcx.sess.emit_err(errors::TransparentNonZeroSized {
|
||||
tcx.dcx().emit_err(errors::TransparentNonZeroSized {
|
||||
span: sp,
|
||||
spans: field_spans.collect(),
|
||||
field_count,
|
||||
|
@ -616,7 +616,7 @@ pub fn check_function_signature<'tcx>(
|
|||
cause.span = extract_span_for_error_reporting(tcx, err, &cause, local_id);
|
||||
}
|
||||
let failure_code = cause.as_failure_code_diag(err, cause.span, vec![]);
|
||||
let mut diag = tcx.sess.create_err(failure_code);
|
||||
let mut diag = tcx.dcx().create_err(failure_code);
|
||||
err_ctxt.note_type_err(
|
||||
&mut diag,
|
||||
&cause,
|
||||
|
|
|
@ -198,7 +198,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
|||
if let (hir::Defaultness::Default { .. }, true) = (impl_.defaultness, is_auto) {
|
||||
let sp = impl_.of_trait.as_ref().map_or(item.span, |t| t.path.span);
|
||||
let mut err =
|
||||
tcx.sess.struct_span_err(sp, "impls of auto traits cannot be default");
|
||||
tcx.dcx().struct_span_err(sp, "impls of auto traits cannot be default");
|
||||
err.span_labels(impl_.defaultness_span, "default because of this");
|
||||
err.span_label(sp, "auto trait");
|
||||
res = Err(err.emit());
|
||||
|
@ -217,7 +217,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
|
|||
let mut spans = vec![span];
|
||||
spans.extend(impl_.defaultness_span);
|
||||
res = Err(struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
spans,
|
||||
E0750,
|
||||
"negative impls cannot be default impls"
|
||||
|
@ -485,7 +485,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
|
|||
|
||||
if !unsatisfied_bounds.is_empty() {
|
||||
let plural = pluralize!(unsatisfied_bounds.len());
|
||||
let mut err = tcx.sess.struct_span_err(
|
||||
let mut err = tcx.dcx().struct_span_err(
|
||||
gat_item_hir.span,
|
||||
format!("missing required bound{} on `{}`", plural, gat_item_hir.ident),
|
||||
);
|
||||
|
@ -829,7 +829,7 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
|
|||
return;
|
||||
}
|
||||
let sugg = trait_should_be_self.iter().map(|span| (*span, "Self".to_string())).collect();
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(
|
||||
trait_should_be_self,
|
||||
"associated item referring to unboxed trait object for its own trait",
|
||||
|
@ -883,15 +883,15 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
|
|||
} else {
|
||||
let mut diag = match ty.kind() {
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Error(_) => return Ok(()),
|
||||
ty::FnPtr(_) => tcx.sess.struct_span_err(
|
||||
ty::FnPtr(_) => tcx.dcx().struct_span_err(
|
||||
hir_ty.span,
|
||||
"using function pointers as const generic parameters is forbidden",
|
||||
),
|
||||
ty::RawPtr(_) => tcx.sess.struct_span_err(
|
||||
ty::RawPtr(_) => tcx.dcx().struct_span_err(
|
||||
hir_ty.span,
|
||||
"using raw pointers as const generic parameters is forbidden",
|
||||
),
|
||||
_ => tcx.sess.struct_span_err(
|
||||
_ => tcx.dcx().struct_span_err(
|
||||
hir_ty.span,
|
||||
format!("`{}` is forbidden as the type of a const generic parameter", ty),
|
||||
),
|
||||
|
@ -1032,7 +1032,7 @@ fn check_type_defn<'tcx>(
|
|||
let ty = tcx.type_of(variant.tail().did).instantiate_identity();
|
||||
let ty = tcx.erase_regions(ty);
|
||||
if ty.has_infer() {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(item.span, format!("inference variables in {ty:?}"));
|
||||
// Just treat unresolved type expression as if it needs drop.
|
||||
true
|
||||
|
@ -1114,7 +1114,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
|
|||
{
|
||||
for associated_def_id in &*tcx.associated_item_def_ids(def_id) {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(*associated_def_id),
|
||||
E0714,
|
||||
"marker traits cannot have associated items",
|
||||
|
@ -1532,14 +1532,14 @@ fn check_fn_or_method<'tcx>(
|
|||
tcx.require_lang_item(hir::LangItem::Sized, Some(span)),
|
||||
);
|
||||
} else {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
hir_decl.inputs.last().map_or(span, |input| input.span),
|
||||
"functions with the \"rust-call\" ABI must take a single non-self tuple argument",
|
||||
);
|
||||
}
|
||||
// No more inputs other than the `self` type and the tuple type
|
||||
if inputs.next().is_some() {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
hir_decl.inputs.last().map_or(span, |input| input.span),
|
||||
"functions with the \"rust-call\" ABI must take a single non-self tuple argument",
|
||||
);
|
||||
|
@ -1607,7 +1607,7 @@ fn check_method_receiver<'tcx>(
|
|||
}
|
||||
|
||||
fn e0307(tcx: TyCtxt<'_>, span: Span, receiver_ty: Ty<'_>) -> ErrorGuaranteed {
|
||||
struct_span_err!(tcx.sess.dcx(), span, E0307, "invalid `self` parameter type: {receiver_ty}")
|
||||
struct_span_err!(tcx.dcx(), span, E0307, "invalid `self` parameter type: {receiver_ty}")
|
||||
.note("type of `self` must be `Self` or a type that dereferences to it")
|
||||
.help(HELP_FOR_SELF_TYPE)
|
||||
.emit()
|
||||
|
@ -1807,7 +1807,7 @@ fn check_variances_for_type_defn<'tcx>(
|
|||
//
|
||||
// if they aren't in the same order, then the user has written invalid code, and already
|
||||
// got an error about it (or I'm wrong about this)
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
hir_param.span,
|
||||
"hir generics and ty generics in different order",
|
||||
);
|
||||
|
@ -1913,7 +1913,8 @@ fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), Error
|
|||
}
|
||||
|
||||
fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> {
|
||||
let mut err = struct_span_err!(tcx.sess, span, E0392, "parameter `{param_name}` is never used");
|
||||
let mut err =
|
||||
struct_span_err!(tcx.dcx(), span, E0392, "parameter `{param_name}` is never used");
|
||||
err.span_label(span, "unused parameter");
|
||||
err
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
|||
|
||||
let impl_ = tcx.hir().expect_item(impl_did).expect_impl();
|
||||
|
||||
tcx.sess.emit_err(errors::DropImplOnWrongItem { span: impl_.self_ty.span });
|
||||
tcx.dcx().emit_err(errors::DropImplOnWrongItem { span: impl_.self_ty.span });
|
||||
}
|
||||
|
||||
fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
||||
|
@ -90,10 +90,10 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
|||
infringing_fields_error(tcx, fields, LangItem::Copy, impl_did, span);
|
||||
}
|
||||
Err(CopyImplementationError::NotAnAdt) => {
|
||||
tcx.sess.emit_err(errors::CopyImplOnNonAdt { span });
|
||||
tcx.dcx().emit_err(errors::CopyImplOnNonAdt { span });
|
||||
}
|
||||
Err(CopyImplementationError::HasDestructor) => {
|
||||
tcx.sess.emit_err(errors::CopyImplOnTypeWithDtor { span });
|
||||
tcx.dcx().emit_err(errors::CopyImplOnTypeWithDtor { span });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ fn visit_implementation_of_const_param_ty(tcx: TyCtxt<'_>, impl_did: LocalDefId)
|
|||
infringing_fields_error(tcx, fields, LangItem::ConstParamTy, impl_did, span);
|
||||
}
|
||||
Err(ConstParamTyImplementationError::NotAnAdtOrBuiltinAllowed) => {
|
||||
tcx.sess.emit_err(errors::ConstParamTyImplOnNonAdt { span });
|
||||
tcx.dcx().emit_err(errors::ConstParamTyImplOnNonAdt { span });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||
let source_path = tcx.def_path_str(def_a.did());
|
||||
let target_path = tcx.def_path_str(def_b.did());
|
||||
|
||||
tcx.sess.emit_err(errors::DispatchFromDynCoercion {
|
||||
tcx.dcx().emit_err(errors::DispatchFromDynCoercion {
|
||||
span,
|
||||
trait_name: "DispatchFromDyn",
|
||||
note: true,
|
||||
|
@ -185,7 +185,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||
}
|
||||
|
||||
if def_a.repr().c() || def_a.repr().packed() {
|
||||
tcx.sess.emit_err(errors::DispatchFromDynRepr { span });
|
||||
tcx.dcx().emit_err(errors::DispatchFromDynRepr { span });
|
||||
}
|
||||
|
||||
let fields = &def_a.non_enum_variant().fields;
|
||||
|
@ -207,7 +207,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||
infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, ty_a, ty_b)
|
||||
{
|
||||
if ok.obligations.is_empty() {
|
||||
tcx.sess.emit_err(errors::DispatchFromDynZST {
|
||||
tcx.dcx().emit_err(errors::DispatchFromDynZST {
|
||||
span,
|
||||
name: field.name,
|
||||
ty: ty_a,
|
||||
|
@ -222,13 +222,13 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
if coerced_fields.is_empty() {
|
||||
tcx.sess.emit_err(errors::DispatchFromDynSingle {
|
||||
tcx.dcx().emit_err(errors::DispatchFromDynSingle {
|
||||
span,
|
||||
trait_name: "DispatchFromDyn",
|
||||
note: true,
|
||||
});
|
||||
} else if coerced_fields.len() > 1 {
|
||||
tcx.sess.emit_err(errors::DispatchFromDynMulti {
|
||||
tcx.dcx().emit_err(errors::DispatchFromDynMulti {
|
||||
span,
|
||||
coercions_note: true,
|
||||
number: coerced_fields.len(),
|
||||
|
@ -270,7 +270,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.emit_err(errors::CoerceUnsizedMay { span, trait_name: "DispatchFromDyn" });
|
||||
tcx.dcx().emit_err(errors::CoerceUnsizedMay { span, trait_name: "DispatchFromDyn" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||
if def_a != def_b {
|
||||
let source_path = tcx.def_path_str(def_a.did());
|
||||
let target_path = tcx.def_path_str(def_b.did());
|
||||
tcx.sess.emit_err(errors::DispatchFromDynSame {
|
||||
tcx.dcx().emit_err(errors::DispatchFromDynSame {
|
||||
span,
|
||||
trait_name: "CoerceUnsized",
|
||||
note: true,
|
||||
|
@ -419,7 +419,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
if diff_fields.is_empty() {
|
||||
tcx.sess.emit_err(errors::CoerceUnsizedOneField {
|
||||
tcx.dcx().emit_err(errors::CoerceUnsizedOneField {
|
||||
span,
|
||||
trait_name: "CoerceUnsized",
|
||||
note: true,
|
||||
|
@ -433,7 +433,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||
tcx.def_span(impl_did)
|
||||
};
|
||||
|
||||
tcx.sess.emit_err(errors::CoerceUnsizedMulti {
|
||||
tcx.dcx().emit_err(errors::CoerceUnsizedMulti {
|
||||
span,
|
||||
coercions_note: true,
|
||||
number: diff_fields.len(),
|
||||
|
@ -453,7 +453,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||
}
|
||||
|
||||
_ => {
|
||||
tcx.sess.emit_err(errors::DispatchFromDynStruct { span, trait_name: "CoerceUnsized" });
|
||||
tcx.dcx().emit_err(errors::DispatchFromDynStruct { span, trait_name: "CoerceUnsized" });
|
||||
return err_info;
|
||||
}
|
||||
};
|
||||
|
@ -583,7 +583,7 @@ fn infringing_fields_error(
|
|||
});
|
||||
}
|
||||
|
||||
let mut err = tcx.sess.create_err(errors::TraitCannotImplForTy {
|
||||
let mut err = tcx.dcx().create_err(errors::TraitCannotImplForTy {
|
||||
span: impl_span,
|
||||
trait_name,
|
||||
label_spans,
|
||||
|
|
|
@ -62,14 +62,14 @@ impl<'tcx> InherentCollect<'tcx> {
|
|||
|
||||
if !self.tcx.has_attr(ty_def_id, sym::rustc_has_incoherent_inherent_impls) {
|
||||
let impl_span = self.tcx.def_span(impl_def_id);
|
||||
self.tcx.sess.emit_err(errors::InherentTyOutside { span: impl_span });
|
||||
self.tcx.dcx().emit_err(errors::InherentTyOutside { span: impl_span });
|
||||
return;
|
||||
}
|
||||
|
||||
for &impl_item in items {
|
||||
if !self.tcx.has_attr(impl_item, sym::rustc_allow_incoherent_impl) {
|
||||
let impl_span = self.tcx.def_span(impl_def_id);
|
||||
self.tcx.sess.emit_err(errors::InherentTyOutsideRelevant {
|
||||
self.tcx.dcx().emit_err(errors::InherentTyOutsideRelevant {
|
||||
span: impl_span,
|
||||
help_span: self.tcx.def_span(impl_item),
|
||||
});
|
||||
|
@ -84,7 +84,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
|||
}
|
||||
} else {
|
||||
let impl_span = self.tcx.def_span(impl_def_id);
|
||||
self.tcx.sess.emit_err(errors::InherentTyOutsideNew { span: impl_span });
|
||||
self.tcx.dcx().emit_err(errors::InherentTyOutsideNew { span: impl_span });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
|||
for &impl_item in items {
|
||||
if !self.tcx.has_attr(impl_item, sym::rustc_allow_incoherent_impl) {
|
||||
let span = self.tcx.def_span(impl_def_id);
|
||||
self.tcx.sess.emit_err(errors::InherentTyOutsidePrimitive {
|
||||
self.tcx.dcx().emit_err(errors::InherentTyOutsidePrimitive {
|
||||
span,
|
||||
help_span: self.tcx.def_span(impl_item),
|
||||
});
|
||||
|
@ -108,7 +108,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
|||
if let ty::Ref(_, subty, _) = ty.kind() {
|
||||
note = Some(errors::InherentPrimitiveTyNote { subty: *subty });
|
||||
}
|
||||
self.tcx.sess.emit_err(errors::InherentPrimitiveTy { span, note });
|
||||
self.tcx.dcx().emit_err(errors::InherentPrimitiveTy { span, note });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
|||
self.check_def_id(id, self_ty, data.principal_def_id().unwrap());
|
||||
}
|
||||
ty::Dynamic(..) => {
|
||||
self.tcx.sess.emit_err(errors::InherentDyn { span: item_span });
|
||||
self.tcx.dcx().emit_err(errors::InherentDyn { span: item_span });
|
||||
}
|
||||
ty::Bool
|
||||
| ty::Char
|
||||
|
@ -151,7 +151,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
|||
| ty::FnPtr(_)
|
||||
| ty::Tuple(..) => self.check_primitive_impl(id, self_ty),
|
||||
ty::Alias(..) | ty::Param(_) => {
|
||||
self.tcx.sess.emit_err(errors::InherentNominal { span: item_span });
|
||||
self.tcx.dcx().emit_err(errors::InherentNominal { span: item_span });
|
||||
}
|
||||
ty::FnDef(..)
|
||||
| ty::Closure(..)
|
||||
|
|
|
@ -71,7 +71,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
|
|||
Entry::Occupied(entry) => {
|
||||
let former = entry.get();
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.tcx.dcx(),
|
||||
span,
|
||||
E0592,
|
||||
"duplicate definitions with name `{}`",
|
||||
|
@ -106,7 +106,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
|
|||
if let Some(item2) = collision {
|
||||
let name = item1.ident(self.tcx).normalize_to_macros_2_0();
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.tcx.dcx(),
|
||||
self.tcx.def_span(item1.def_id),
|
||||
E0592,
|
||||
"duplicate definitions with name `{}`",
|
||||
|
|
|
@ -46,7 +46,7 @@ fn enforce_trait_manually_implementable(
|
|||
if tcx.trait_def(trait_def_id).deny_explicit_impl {
|
||||
let trait_name = tcx.item_name(trait_def_id);
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
impl_header_span,
|
||||
E0322,
|
||||
"explicit impls for the `{trait_name}` trait are not permitted"
|
||||
|
@ -67,7 +67,7 @@ fn enforce_trait_manually_implementable(
|
|||
tcx.trait_def(trait_def_id).specialization_kind
|
||||
{
|
||||
if !tcx.features().specialization && !tcx.features().min_specialization {
|
||||
tcx.sess.emit_err(errors::SpecializationTrait { span: impl_header_span });
|
||||
tcx.dcx().emit_err(errors::SpecializationTrait { span: impl_header_span });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ fn enforce_empty_impls_for_marker_traits(
|
|||
}
|
||||
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(impl_def_id),
|
||||
E0715,
|
||||
"impls for marker traits cannot contain items"
|
||||
|
@ -174,7 +174,7 @@ fn check_object_overlap<'tcx>(
|
|||
if supertrait_def_ids.any(|d| d == trait_def_id) {
|
||||
let span = tcx.def_span(impl_def_id);
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
span,
|
||||
E0371,
|
||||
"the object type `{}` automatically implements the trait `{}`",
|
||||
|
|
|
@ -260,7 +260,7 @@ fn do_orphan_check_impl<'tcx>(
|
|||
match local_impl {
|
||||
LocalImpl::Allow => {}
|
||||
LocalImpl::Disallow { problematic_kind } => {
|
||||
return Err(tcx.sess.emit_err(errors::TraitsWithDefaultImpl {
|
||||
return Err(tcx.dcx().emit_err(errors::TraitsWithDefaultImpl {
|
||||
span: tcx.def_span(def_id),
|
||||
traits: tcx.def_path_str(trait_def_id),
|
||||
problematic_kind,
|
||||
|
@ -272,13 +272,13 @@ fn do_orphan_check_impl<'tcx>(
|
|||
match nonlocal_impl {
|
||||
NonlocalImpl::Allow => {}
|
||||
NonlocalImpl::DisallowBecauseNonlocal => {
|
||||
return Err(tcx.sess.emit_err(errors::CrossCrateTraitsDefined {
|
||||
return Err(tcx.dcx().emit_err(errors::CrossCrateTraitsDefined {
|
||||
span: tcx.def_span(def_id),
|
||||
traits: tcx.def_path_str(trait_def_id),
|
||||
}));
|
||||
}
|
||||
NonlocalImpl::DisallowOther => {
|
||||
return Err(tcx.sess.emit_err(errors::CrossCrateTraits {
|
||||
return Err(tcx.dcx().emit_err(errors::CrossCrateTraits {
|
||||
span: tcx.def_span(def_id),
|
||||
traits: tcx.def_path_str(trait_def_id),
|
||||
self_ty,
|
||||
|
@ -422,7 +422,7 @@ fn emit_orphan_check_error<'tcx>(
|
|||
sugg,
|
||||
},
|
||||
};
|
||||
tcx.sess.emit_err(err_struct)
|
||||
tcx.dcx().emit_err(err_struct)
|
||||
}
|
||||
traits::OrphanCheckErr::UncoveredTy(param_ty, local_type) => {
|
||||
let mut sp = sp;
|
||||
|
@ -433,13 +433,13 @@ fn emit_orphan_check_error<'tcx>(
|
|||
}
|
||||
|
||||
match local_type {
|
||||
Some(local_type) => tcx.sess.emit_err(errors::TyParamFirstLocal {
|
||||
Some(local_type) => tcx.dcx().emit_err(errors::TyParamFirstLocal {
|
||||
span: sp,
|
||||
note: (),
|
||||
param_ty,
|
||||
local_type,
|
||||
}),
|
||||
None => tcx.sess.emit_err(errors::TyParamSome { span: sp, note: (), param_ty }),
|
||||
None => tcx.dcx().emit_err(errors::TyParamSome { span: sp, note: (), param_ty }),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -453,7 +453,7 @@ fn lint_auto_trait_impl<'tcx>(
|
|||
impl_def_id: LocalDefId,
|
||||
) {
|
||||
if trait_ref.args.len() != 1 {
|
||||
tcx.sess.dcx().span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(impl_def_id),
|
||||
"auto traits cannot have generic parameters",
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
match (trait_def.unsafety, unsafe_attr, impl_.unsafety, impl_.polarity) {
|
||||
(Unsafety::Normal, None, Unsafety::Unsafe, hir::ImplPolarity::Positive) => {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(def_id),
|
||||
E0199,
|
||||
"implementing the trait `{}` is not unsafe",
|
||||
|
@ -36,7 +36,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
|
||||
(Unsafety::Unsafe, _, Unsafety::Normal, hir::ImplPolarity::Positive) => {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(def_id),
|
||||
E0200,
|
||||
"the trait `{}` requires an `unsafe impl` declaration",
|
||||
|
@ -59,7 +59,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
|
||||
(Unsafety::Normal, Some(attr_name), Unsafety::Normal, hir::ImplPolarity::Positive) => {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
tcx.def_span(def_id),
|
||||
E0569,
|
||||
"requires an `unsafe impl` declaration due to `#[{}]` attribute",
|
||||
|
@ -82,7 +82,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
|
||||
(_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative(_)) => {
|
||||
// Reported in AST validation
|
||||
tcx.sess.span_delayed_bug(item.span, "unsafe negative impl");
|
||||
tcx.dcx().span_delayed_bug(item.span, "unsafe negative impl");
|
||||
}
|
||||
(_, _, Unsafety::Normal, hir::ImplPolarity::Negative(_))
|
||||
| (Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive)
|
||||
|
|
|
@ -337,7 +337,7 @@ fn bad_placeholder<'tcx>(
|
|||
let kind = if kind.ends_with('s') { format!("{kind}es") } else { format!("{kind}s") };
|
||||
|
||||
spans.sort();
|
||||
tcx.sess.create_err(errors::PlaceholderNotAllowedItemSignatures { spans, kind })
|
||||
tcx.dcx().create_err(errors::PlaceholderNotAllowedItemSignatures { spans, kind })
|
||||
}
|
||||
|
||||
impl<'tcx> ItemCtxt<'tcx> {
|
||||
|
@ -476,7 +476,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
|
|||
}
|
||||
Ty::new_error(
|
||||
self.tcx(),
|
||||
self.tcx().sess.emit_err(errors::AssociatedTypeTraitUninferredGenericParams {
|
||||
self.tcx().dcx().emit_err(errors::AssociatedTypeTraitUninferredGenericParams {
|
||||
span,
|
||||
inferred_sugg,
|
||||
bound,
|
||||
|
@ -672,7 +672,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
|||
|
||||
hir::TraitItemKind::Const(ty, body_id) => {
|
||||
tcx.ensure().type_of(def_id);
|
||||
if !tcx.sess.dcx().has_stashed_diagnostic(ty.span, StashKey::ItemNoType)
|
||||
if !tcx.dcx().has_stashed_diagnostic(ty.span, StashKey::ItemNoType)
|
||||
&& !(is_suggestable_infer_ty(ty) && body_id.is_some())
|
||||
{
|
||||
// Account for `const C: _;`.
|
||||
|
@ -756,7 +756,7 @@ fn convert_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) {
|
|||
Some(discr)
|
||||
} else {
|
||||
let span = tcx.def_span(variant.def_id);
|
||||
tcx.sess.emit_err(errors::EnumDiscriminantOverflowed {
|
||||
tcx.dcx().emit_err(errors::EnumDiscriminantOverflowed {
|
||||
span,
|
||||
discr: prev_discr.unwrap().to_string(),
|
||||
item_name: tcx.item_name(variant.def_id),
|
||||
|
@ -797,7 +797,7 @@ fn convert_variant(
|
|||
.map(|f| {
|
||||
let dup_span = seen_fields.get(&f.ident.normalize_to_macros_2_0()).cloned();
|
||||
if let Some(prev_span) = dup_span {
|
||||
tcx.sess.emit_err(errors::FieldAlreadyDeclared {
|
||||
tcx.dcx().emit_err(errors::FieldAlreadyDeclared {
|
||||
field_name: f.ident,
|
||||
span: f.span,
|
||||
prev_span,
|
||||
|
@ -905,7 +905,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
|
||||
let paren_sugar = tcx.has_attr(def_id, sym::rustc_paren_sugar);
|
||||
if paren_sugar && !tcx.features().unboxed_closures {
|
||||
tcx.sess.emit_err(errors::ParenSugarAttribute { span: item.span });
|
||||
tcx.dcx().emit_err(errors::ParenSugarAttribute { span: item.span });
|
||||
}
|
||||
|
||||
let is_marker = tcx.has_attr(def_id, sym::marker);
|
||||
|
@ -925,7 +925,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
// and that they are all identifiers
|
||||
.and_then(|attr| match attr.meta_item_list() {
|
||||
Some(items) if items.len() < 2 => {
|
||||
tcx.sess.emit_err(errors::MustImplementOneOfAttribute { span: attr.span });
|
||||
tcx.dcx().emit_err(errors::MustImplementOneOfAttribute { span: attr.span });
|
||||
|
||||
None
|
||||
}
|
||||
|
@ -934,7 +934,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
.map(|item| item.ident().ok_or(item.span()))
|
||||
.collect::<Result<Box<[_]>, _>>()
|
||||
.map_err(|span| {
|
||||
tcx.sess.emit_err(errors::MustBeNameOfAssociatedFunction { span });
|
||||
tcx.dcx().emit_err(errors::MustBeNameOfAssociatedFunction { span });
|
||||
})
|
||||
.ok()
|
||||
.zip(Some(attr.span)),
|
||||
|
@ -950,7 +950,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
match item {
|
||||
Some(item) if matches!(item.kind, hir::AssocItemKind::Fn { .. }) => {
|
||||
if !tcx.defaultness(item.id.owner_id).has_value() {
|
||||
tcx.sess.emit_err(errors::FunctionNotHaveDefaultImplementation {
|
||||
tcx.dcx().emit_err(errors::FunctionNotHaveDefaultImplementation {
|
||||
span: item.span,
|
||||
note_span: attr_span,
|
||||
});
|
||||
|
@ -961,14 +961,14 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
return None;
|
||||
}
|
||||
Some(item) => {
|
||||
tcx.sess.emit_err(errors::MustImplementNotFunction {
|
||||
tcx.dcx().emit_err(errors::MustImplementNotFunction {
|
||||
span: item.span,
|
||||
span_note: errors::MustImplementNotFunctionSpanNote { span: attr_span },
|
||||
note: errors::MustImplementNotFunctionNote {},
|
||||
});
|
||||
}
|
||||
None => {
|
||||
tcx.sess.emit_err(errors::FunctionNotFoundInTrait { span: ident.span });
|
||||
tcx.dcx().emit_err(errors::FunctionNotFoundInTrait { span: ident.span });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -984,7 +984,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
|
||||
for ident in &*list {
|
||||
if let Some(dup) = set.insert(ident.name, ident.span) {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.emit_err(errors::FunctionNamesDuplicated { spans: vec![dup, ident.span] });
|
||||
|
||||
no_dups = false;
|
||||
|
@ -1005,7 +1005,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
&& let Some(lit) = meta.name_value_literal()
|
||||
{
|
||||
if seen_attr {
|
||||
tcx.sess.span_err(meta.span, "duplicated `implement_via_object` meta item");
|
||||
tcx.dcx().span_err(meta.span, "duplicated `implement_via_object` meta item");
|
||||
}
|
||||
seen_attr = true;
|
||||
|
||||
|
@ -1017,7 +1017,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
implement_via_object = false;
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
meta.span,
|
||||
format!(
|
||||
"unknown literal passed to `implement_via_object` attribute: {}",
|
||||
|
@ -1027,14 +1027,14 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
meta.span(),
|
||||
format!("unknown meta item passed to `rustc_deny_explicit_impl` {meta:?}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
if !seen_attr {
|
||||
tcx.sess.span_err(attr.span, "missing `implement_via_object` meta item");
|
||||
tcx.dcx().span_err(attr.span, "missing `implement_via_object` meta item");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1414,7 +1414,7 @@ fn check_impl_constness(
|
|||
}
|
||||
|
||||
let trait_name = tcx.item_name(trait_def_id).to_string();
|
||||
Some(tcx.sess.emit_err(errors::ConstImplForNonConstTrait {
|
||||
Some(tcx.dcx().emit_err(errors::ConstImplForNonConstTrait {
|
||||
trait_ref_span: ast_trait_ref.path.span,
|
||||
trait_name,
|
||||
local_trait_span:
|
||||
|
@ -1435,7 +1435,7 @@ fn impl_polarity(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::ImplPolarity {
|
|||
}) => {
|
||||
if is_rustc_reservation {
|
||||
let span = span.to(of_trait.as_ref().map_or(*span, |t| t.path.span));
|
||||
tcx.sess.span_err(span, "reservation impls can't be negative");
|
||||
tcx.dcx().span_err(span, "reservation impls can't be negative");
|
||||
}
|
||||
ty::ImplPolarity::Negative
|
||||
}
|
||||
|
@ -1445,7 +1445,7 @@ fn impl_polarity(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::ImplPolarity {
|
|||
..
|
||||
}) => {
|
||||
if is_rustc_reservation {
|
||||
tcx.sess.span_err(item.span, "reservation impls can't be inherent");
|
||||
tcx.dcx().span_err(item.span, "reservation impls can't be inherent");
|
||||
}
|
||||
ty::ImplPolarity::Positive
|
||||
}
|
||||
|
@ -1535,7 +1535,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
|||
.source_map()
|
||||
.span_to_snippet(ast_ty.span)
|
||||
.map_or_else(|_| String::new(), |s| format!(" `{s}`"));
|
||||
tcx.sess.emit_err(errors::SIMDFFIHighlyExperimental { span: ast_ty.span, snip });
|
||||
tcx.dcx().emit_err(errors::SIMDFFIHighlyExperimental { span: ast_ty.span, snip });
|
||||
}
|
||||
};
|
||||
for (input, ty) in iter::zip(decl.inputs, fty.inputs().skip_binder()) {
|
||||
|
|
|
@ -283,7 +283,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
);
|
||||
}
|
||||
Defaults::Deny => {
|
||||
tcx.sess.span_err(param.span, TYPE_DEFAULT_NOT_ALLOWED);
|
||||
tcx.dcx().span_err(param.span, TYPE_DEFAULT_NOT_ALLOWED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
// `host` effect params are allowed to have defaults.
|
||||
&& !is_host_effect
|
||||
{
|
||||
tcx.sess.span_err(
|
||||
tcx.dcx().span_err(
|
||||
param.span,
|
||||
"defaults for const parameters are only allowed in \
|
||||
`struct`, `enum`, `type`, or `trait` definitions",
|
||||
|
|
|
@ -335,7 +335,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
// though this may happen when we call `poly_trait_ref_binder_info` with
|
||||
// an (erroneous, #113423) associated return type bound in an impl header.
|
||||
if !supertrait_bound_vars.is_empty() {
|
||||
self.tcx.sess.span_delayed_bug(
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
DUMMY_SP,
|
||||
format!(
|
||||
"found supertrait lifetimes without a binder to append \
|
||||
|
@ -461,7 +461,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
|
||||
if !infer_spans.is_empty() {
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_err(errors::ClosureImplicitHrtb { spans: infer_spans, for_sp });
|
||||
}
|
||||
}
|
||||
|
@ -738,7 +738,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
let parent_id = self.tcx.hir().parent_id(hir_id);
|
||||
if !parent_id.is_owner() {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
self.tcx.dcx(),
|
||||
lifetime.ident.span,
|
||||
E0657,
|
||||
"`impl Trait` can only capture lifetimes bound at the fn or impl level"
|
||||
|
@ -750,7 +750,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
kind: hir::ItemKind::OpaqueTy { .. }, ..
|
||||
}) = self.tcx.hir_node(parent_id)
|
||||
{
|
||||
let mut err = self.tcx.sess.struct_span_err(
|
||||
let mut err = self.tcx.dcx().struct_span_err(
|
||||
lifetime.ident.span,
|
||||
"higher kinded lifetime bounds on nested opaque types are not supported yet",
|
||||
);
|
||||
|
@ -1268,7 +1268,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
let def_span = self.tcx.def_span(param_def_id);
|
||||
let guar = match self.tcx.def_kind(param_def_id) {
|
||||
DefKind::LifetimeParam => {
|
||||
self.tcx.sess.emit_err(errors::CannotCaptureLateBound::Lifetime {
|
||||
self.tcx.dcx().emit_err(errors::CannotCaptureLateBound::Lifetime {
|
||||
use_span,
|
||||
def_span,
|
||||
what,
|
||||
|
@ -1323,7 +1323,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
Scope::Binder {
|
||||
where_bound_origin: Some(hir::PredicateOrigin::ImplTrait), ..
|
||||
} => {
|
||||
self.tcx.sess.emit_err(errors::LateBoundInApit::Lifetime {
|
||||
self.tcx.dcx().emit_err(errors::LateBoundInApit::Lifetime {
|
||||
span: lifetime_ref.ident.span,
|
||||
param_span: self.tcx.def_span(region_def_id),
|
||||
});
|
||||
|
@ -1341,7 +1341,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
self.tcx.sess.span_delayed_bug(
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
lifetime_ref.ident.span,
|
||||
format!("Could not resolve {:?} in scope {:#?}", lifetime_ref, self.scope,),
|
||||
);
|
||||
|
@ -1406,14 +1406,14 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
let def_span = self.tcx.def_span(param_def_id);
|
||||
let guar = match self.tcx.def_kind(param_def_id) {
|
||||
DefKind::ConstParam => {
|
||||
self.tcx.sess.emit_err(errors::CannotCaptureLateBound::Const {
|
||||
self.tcx.dcx().emit_err(errors::CannotCaptureLateBound::Const {
|
||||
use_span,
|
||||
def_span,
|
||||
what,
|
||||
})
|
||||
}
|
||||
DefKind::TyParam => {
|
||||
self.tcx.sess.emit_err(errors::CannotCaptureLateBound::Type {
|
||||
self.tcx.dcx().emit_err(errors::CannotCaptureLateBound::Type {
|
||||
use_span,
|
||||
def_span,
|
||||
what,
|
||||
|
@ -1447,7 +1447,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
Scope::Binder {
|
||||
where_bound_origin: Some(hir::PredicateOrigin::ImplTrait), ..
|
||||
} => {
|
||||
let guar = self.tcx.sess.emit_err(match self.tcx.def_kind(param_def_id) {
|
||||
let guar = self.tcx.dcx().emit_err(match self.tcx.def_kind(param_def_id) {
|
||||
DefKind::TyParam => errors::LateBoundInApit::Type {
|
||||
span: self.tcx.hir().span(hir_id),
|
||||
param_span: self.tcx.def_span(param_def_id),
|
||||
|
@ -1475,7 +1475,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
self.tcx.sess.span_delayed_bug(
|
||||
self.tcx.dcx().span_delayed_bug(
|
||||
self.tcx.hir().span(hir_id),
|
||||
format!("could not resolve {param_def_id:?}"),
|
||||
);
|
||||
|
@ -1705,7 +1705,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
bound_vars
|
||||
} else {
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.span_delayed_bug(binding.ident.span, "bad return type notation here");
|
||||
vec![]
|
||||
};
|
||||
|
@ -2039,7 +2039,7 @@ fn is_late_bound_map(
|
|||
Some(true) => Some(arg),
|
||||
Some(false) => None,
|
||||
None => {
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
*span,
|
||||
format!(
|
||||
"Incorrect generic arg count for alias {alias_def:?}"
|
||||
|
@ -2114,7 +2114,7 @@ pub fn deny_non_region_late_bound(
|
|||
hir::GenericParamKind::Lifetime { .. } => continue,
|
||||
};
|
||||
|
||||
let mut diag = tcx.sess.struct_span_err(
|
||||
let mut diag = tcx.dcx().struct_span_err(
|
||||
param.span,
|
||||
format!("late-bound {what} parameter not allowed on {where_}"),
|
||||
);
|
||||
|
|
|
@ -440,7 +440,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
|||
ItemKind::Impl(hir::Impl { self_ty, .. }) => match self_ty.find_self_aliases() {
|
||||
spans if spans.len() > 0 => {
|
||||
let guar = tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_err(crate::errors::SelfInImplSelf { span: spans.into(), note: () });
|
||||
Ty::new_error(tcx, guar)
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ fn infer_placeholder_type<'a>(
|
|||
// then the user may have written e.g. `const A = 42;`.
|
||||
// In this case, the parser has stashed a diagnostic for
|
||||
// us to improve in typeck so we do that now.
|
||||
match tcx.sess.dcx().steal_diagnostic(span, StashKey::ItemNoType) {
|
||||
match tcx.dcx().steal_diagnostic(span, StashKey::ItemNoType) {
|
||||
Some(mut err) => {
|
||||
if !ty.references_error() {
|
||||
// Only suggest adding `:` if it was missing (and suggested by parsing diagnostic)
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn test_opaque_hidden_types(tcx: TyCtxt<'_>) {
|
|||
if matches!(tcx.def_kind(id.owner_id), DefKind::OpaqueTy) {
|
||||
let type_of = tcx.type_of(id.owner_id).instantiate_identity();
|
||||
|
||||
tcx.sess.emit_err(TypeOf { span: tcx.def_span(id.owner_id), type_of });
|
||||
tcx.dcx().emit_err(TypeOf { span: tcx.def_span(id.owner_id), type_of });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: Local
|
|||
// Account for `type Alias = impl Trait<Foo = impl Trait>;` (#116031)
|
||||
parent_def_id = tcx.local_parent(parent_def_id);
|
||||
}
|
||||
let reported = tcx.sess.emit_err(UnconstrainedOpaqueType {
|
||||
let reported = tcx.dcx().emit_err(UnconstrainedOpaqueType {
|
||||
span: tcx.def_span(def_id),
|
||||
name: tcx.item_name(parent_def_id.to_def_id()),
|
||||
what: match tcx.hir_node(scope) {
|
||||
|
@ -158,7 +158,7 @@ impl TaitConstraintLocator<'_> {
|
|||
}
|
||||
constrained = true;
|
||||
if !self.tcx.opaque_types_defined_by(item_def_id).contains(&self.def_id) {
|
||||
self.tcx.sess.emit_err(TaitForwardCompat {
|
||||
self.tcx.dcx().emit_err(TaitForwardCompat {
|
||||
span: hidden_type.span,
|
||||
item_span: self
|
||||
.tcx
|
||||
|
|
|
@ -28,7 +28,7 @@ fn diagnostic_hir_wf_check<'tcx>(
|
|||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
|
||||
// HIR wfcheck should only ever happen as part of improving an existing error
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.span_delayed_bug(tcx.def_span(def_id), "Performed HIR wfcheck without an existing error!");
|
||||
|
||||
let icx = ItemCtxt::new(tcx, def_id);
|
||||
|
|
|
@ -74,7 +74,7 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
|
|||
if impl_self_ty.references_error() {
|
||||
// Don't complain about unconstrained type params when self ty isn't known due to errors.
|
||||
// (#36836)
|
||||
tcx.sess.span_delayed_bug(
|
||||
tcx.dcx().span_delayed_bug(
|
||||
tcx.def_span(impl_def_id),
|
||||
format!(
|
||||
"potentially unconstrained type parameters weren't evaluated: {impl_self_ty:?}",
|
||||
|
@ -171,7 +171,7 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
|
|||
|
||||
fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol) {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
tcx.dcx(),
|
||||
span,
|
||||
E0207,
|
||||
"the {} parameter `{}` is not constrained by the \
|
||||
|
|
|
@ -135,7 +135,7 @@ fn check_has_items(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node,
|
|||
&& tcx.associated_item_def_ids(impl1_def_id).is_empty()
|
||||
{
|
||||
let base_impl_span = tcx.def_span(impl2_id);
|
||||
tcx.sess.emit_err(errors::EmptySpecialization { span, base_impl_span });
|
||||
tcx.dcx().emit_err(errors::EmptySpecialization { span, base_impl_span });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ fn check_constness(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId, impl2_node: Node,
|
|||
|
||||
if let hir::Constness::Const = impl2_constness {
|
||||
if let hir::Constness::NotConst = impl1_constness {
|
||||
tcx.sess.emit_err(errors::ConstSpecialize { span });
|
||||
tcx.dcx().emit_err(errors::ConstSpecialize { span });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ fn get_impl_args(
|
|||
let _ = ocx.resolve_regions_and_report_errors(impl1_def_id, &outlives_env);
|
||||
let Ok(impl2_args) = infcx.fully_resolve(impl2_args) else {
|
||||
let span = tcx.def_span(impl1_def_id);
|
||||
let guar = tcx.sess.emit_err(SubstsOnOverriddenImpl { span });
|
||||
let guar = tcx.dcx().emit_err(SubstsOnOverriddenImpl { span });
|
||||
return Err(guar);
|
||||
};
|
||||
Ok((impl1_args, impl2_args))
|
||||
|
@ -295,7 +295,7 @@ fn check_duplicate_params<'tcx>(
|
|||
base_params.sort_by_key(|param| param.0);
|
||||
if let (_, [duplicate, ..]) = base_params.partition_dedup() {
|
||||
let param = impl1_args[duplicate.0 as usize];
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(span, format!("specializing impl repeats parameter `{param}`"))
|
||||
.emit();
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ fn check_static_lifetimes<'tcx>(
|
|||
span: Span,
|
||||
) {
|
||||
if tcx.any_free_region_meets(parent_args, |r| r.is_static()) {
|
||||
tcx.sess.emit_err(errors::StaticSpecialize { span });
|
||||
tcx.dcx().emit_err(errors::StaticSpecialize { span });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, clause: ty::Clause<'tcx>, sp
|
|||
trait_specialization_kind(tcx, clause),
|
||||
Some(TraitSpecializationKind::Marker)
|
||||
) {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(
|
||||
span,
|
||||
format!(
|
||||
|
@ -467,7 +467,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, clause: ty::Clause<'tcx>, sp
|
|||
}
|
||||
}
|
||||
ty::ClauseKind::Projection(ty::ProjectionPredicate { projection_ty, term }) => {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(
|
||||
span,
|
||||
format!("cannot specialize on associated type `{projection_ty} == {term}`",),
|
||||
|
@ -485,7 +485,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, clause: ty::Clause<'tcx>, sp
|
|||
// revisited.
|
||||
}
|
||||
_ => {
|
||||
tcx.sess
|
||||
tcx.dcx()
|
||||
.struct_span_err(span, format!("cannot specialize on predicate `{clause}`"))
|
||||
.emit();
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi
|
|||
(true, false) => CONVENTIONS_UNSTABLE,
|
||||
};
|
||||
|
||||
tcx.sess.emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions });
|
||||
tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions });
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
|
|||
pred.sort();
|
||||
|
||||
let span = tcx.def_span(id.owner_id);
|
||||
let mut err = tcx.sess.struct_span_err(span, "rustc_outlives");
|
||||
let mut err = tcx.dcx().struct_span_err(span, "rustc_outlives");
|
||||
for p in pred {
|
||||
err.note(p);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx, '_> {
|
|||
(None, "".to_string(), Some(()))
|
||||
};
|
||||
|
||||
let mut err = self.sess.create_err(errors::PassToVariadicFunction {
|
||||
let mut err = self.sess.dcx().create_err(errors::PassToVariadicFunction {
|
||||
span: self.span,
|
||||
ty: self.ty,
|
||||
cast_ty: self.cast_ty,
|
||||
|
|
|
@ -21,7 +21,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for SizedUnsizedCast<'tcx> {
|
|||
}
|
||||
|
||||
fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx> {
|
||||
let mut err = self.sess.create_err(errors::CastThinPointerToFatPointer {
|
||||
let mut err = self.sess.dcx().create_err(errors::CastThinPointerToFatPointer {
|
||||
span: self.span,
|
||||
expr_ty: self.expr_ty,
|
||||
cast_ty: self.cast_ty.to_owned(),
|
||||
|
|
|
@ -524,7 +524,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
let span = self.path_segment.ident.span;
|
||||
let msg = self.create_error_message();
|
||||
|
||||
self.tcx.sess.struct_span_err_with_code(span, msg, self.code())
|
||||
self.tcx.dcx().struct_span_err_with_code(span, msg, self.code())
|
||||
}
|
||||
|
||||
/// Builds the `expected 1 type argument / supplied 2 type arguments` message.
|
||||
|
|
|
@ -11,7 +11,7 @@ pub fn test_variance(tcx: TyCtxt<'_>) {
|
|||
if matches!(tcx.def_kind(id.owner_id), DefKind::OpaqueTy) {
|
||||
let variances_of = tcx.variances_of(id.owner_id);
|
||||
|
||||
tcx.sess.emit_err(errors::VariancesOf {
|
||||
tcx.dcx().emit_err(errors::VariancesOf {
|
||||
span: tcx.def_span(id.owner_id),
|
||||
variances_of: format!("{variances_of:?}"),
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ pub fn test_variance(tcx: TyCtxt<'_>) {
|
|||
if tcx.has_attr(id.owner_id, sym::rustc_variance) {
|
||||
let variances_of = tcx.variances_of(id.owner_id);
|
||||
|
||||
tcx.sess.emit_err(errors::VariancesOf {
|
||||
tcx.dcx().emit_err(errors::VariancesOf {
|
||||
span: tcx.def_span(id.owner_id),
|
||||
variances_of: format!("{variances_of:?}"),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue