Skip to content

Commit 1d9d30f

Browse files
committed
Consistently use the DiagCtxtHandle of HirTyLowerer instead of the one of TyCtxt
They are not the same.
1 parent f5d3fe2 commit 1d9d30f

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
309309
false => "`?Sized`",
310310
};
311311
// There was a `?Trait` bound, but it was neither `?Sized` nor `experimental_default_bounds`.
312-
tcx.dcx().span_err(
312+
self.dcx().span_err(
313313
unbound.span,
314314
format!(
315315
"relaxing a default bound only does something for {}; \
@@ -810,15 +810,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
810810
// `resolve_bound_vars`, since we'd need to introduce those as elided
811811
// bound vars on the where clause too.
812812
if bound.has_bound_vars() {
813-
return Err(self.tcx().dcx().emit_err(
814-
errors::AssociatedItemTraitUninferredGenericParams {
815-
span,
816-
inferred_sugg: Some(span.with_hi(item_segment.ident.span.lo())),
817-
bound: format!("{}::", tcx.anonymize_bound_vars(bound).skip_binder(),),
818-
mpart_sugg: None,
819-
what: "function",
820-
},
821-
));
813+
return Err(self.dcx().emit_err(errors::AssociatedItemTraitUninferredGenericParams {
814+
span,
815+
inferred_sugg: Some(span.with_hi(item_segment.ident.span.lo())),
816+
bound: format!("{}::", tcx.anonymize_bound_vars(bound).skip_binder(),),
817+
mpart_sugg: None,
818+
what: "function",
819+
}));
822820
}
823821

824822
let trait_def_id = bound.def_id();

compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
3535
_ => tcx.hir_span(hir_id),
3636
};
3737
struct_span_code_err!(
38-
tcx.dcx(),
38+
dcx,
3939
span,
4040
E0781,
4141
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers"

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
132132
if references_self {
133133
// With trait alias and type alias combined, type resolver
134134
// may not be able to catch all illegal `Self` usages (issue 139082)
135-
let guar = tcx.dcx().emit_err(SelfInTypeAlias { span });
135+
let guar = self.dcx().emit_err(SelfInTypeAlias { span });
136136
b.term = replace_dummy_self_with_error(tcx, b.term, guar);
137137
}
138138
}

compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
103103
// In case there is an associated type with the same name
104104
// Add the suggestion to this error
105105
if let Some(mut sugg) =
106-
tcx.dcx().steal_non_err(self_ty.span, StashKey::AssociatedTypeSuggestion)
106+
self.dcx().steal_non_err(self_ty.span, StashKey::AssociatedTypeSuggestion)
107107
&& let Suggestions::Enabled(ref mut s1) = diag.suggestions
108108
&& let Suggestions::Enabled(ref mut s2) = sugg.suggestions
109109
{

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
12021202
)? {
12031203
LoweredAssoc::Term(def_id, args) => {
12041204
if !tcx.associated_item(def_id).is_type_const_capable(tcx) {
1205-
let mut err = tcx.dcx().struct_span_err(
1205+
let mut err = self.dcx().struct_span_err(
12061206
span,
12071207
"use of trait associated const without `#[type_const]`",
12081208
);
@@ -2323,7 +2323,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23232323
if tcx.features().generic_const_parameter_types()
23242324
&& (anon_const_type.has_free_regions() || anon_const_type.has_erased_regions())
23252325
{
2326-
let e = tcx.dcx().span_err(
2326+
let e = self.dcx().span_err(
23272327
const_arg.span(),
23282328
"anonymous constants with lifetimes in their type are not yet supported",
23292329
);
@@ -2334,7 +2334,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23342334
// use this type to feed the `type_of` and query results must not contain inference
23352335
// variables otherwise we will ICE.
23362336
if anon_const_type.has_non_region_infer() {
2337-
let e = tcx.dcx().span_err(
2337+
let e = self.dcx().span_err(
23382338
const_arg.span(),
23392339
"anonymous constants with inferred types are not yet supported",
23402340
);
@@ -2344,7 +2344,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23442344
// We error when the type contains unsubstituted generics since we do not currently
23452345
// give the anon const any of the generics from the parent.
23462346
if anon_const_type.has_non_region_param() {
2347-
let e = tcx.dcx().span_err(
2347+
let e = self.dcx().span_err(
23482348
const_arg.span(),
23492349
"anonymous constants referencing generics are not yet supported",
23502350
);

0 commit comments

Comments
 (0)