Skip to content

Commit 32195ac

Browse files
committed
rename functions
1 parent ff7009a commit 32195ac

File tree

5 files changed

+42
-25
lines changed

5 files changed

+42
-25
lines changed

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl Into<rustc_errors::DiagnosticId> for TypeAnnotationNeeded {
221221
}
222222

223223
/// Information about a constant or a type containing inference variables.
224-
pub struct InferDiagnosticsData {
224+
pub struct InferenceDiagnosticsData {
225225
pub name: String,
226226
pub span: Option<Span>,
227227
pub description: Cow<'static, str>,
@@ -232,11 +232,11 @@ pub struct InferDiagnosticsData {
232232
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
233233
/// Extracts data used by diagnostic for either types or constants
234234
/// which were stuck during inference.
235-
pub fn extract_infer_data(
235+
pub fn extract_inference_diagnostics_data(
236236
&self,
237237
arg: GenericArg<'tcx>,
238238
highlight: Option<ty::print::RegionHighlightMode>,
239-
) -> InferDiagnosticsData {
239+
) -> InferenceDiagnosticsData {
240240
match arg.unpack() {
241241
GenericArgKind::Type(ty) => {
242242
if let ty::Infer(ty::TyVar(ty_vid)) = *ty.kind() {
@@ -266,7 +266,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
266266
};
267267

268268
if name != kw::SelfUpper {
269-
return InferDiagnosticsData {
269+
return InferenceDiagnosticsData {
270270
name: name.to_string(),
271271
span: Some(var_origin.span),
272272
description: "type parameter".into(),
@@ -283,7 +283,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
283283
printer.region_highlight_mode = highlight;
284284
}
285285
let _ = ty.print(printer);
286-
InferDiagnosticsData {
286+
InferenceDiagnosticsData {
287287
name: s,
288288
span: None,
289289
description: ty.prefix_string(),
@@ -317,7 +317,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
317317
(None, None)
318318
};
319319

320-
return InferDiagnosticsData {
320+
return InferenceDiagnosticsData {
321321
name: name.to_string(),
322322
span: Some(origin.span),
323323
description: "const parameter".into(),
@@ -334,7 +334,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
334334
printer.region_highlight_mode = highlight;
335335
}
336336
let _ = ct.print(printer);
337-
InferDiagnosticsData {
337+
InferenceDiagnosticsData {
338338
name: s,
339339
span: Some(origin.span),
340340
description: "the constant".into(),
@@ -349,16 +349,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
349349
}
350350
}
351351

352-
pub fn need_type_info_err(
352+
pub fn emit_inference_failure_err(
353353
&self,
354354
body_id: Option<hir::BodyId>,
355355
span: Span,
356356
arg: GenericArg<'tcx>,
357357
error_code: TypeAnnotationNeeded,
358358
) -> DiagnosticBuilder<'tcx> {
359-
let ty = self.resolve_vars_if_possible(&arg);
360-
let arg_data = self.extract_infer_data(arg, None);
361-
let kind_str = match ty.unpack() {
359+
let arg = self.resolve_vars_if_possible(&arg);
360+
let arg_data = self.extract_inference_diagnostics_data(arg, None);
361+
let kind_str = match arg.unpack() {
362362
GenericArgKind::Type(_) => "type",
363363
GenericArgKind::Const(_) => "the value",
364364
GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"),
@@ -700,7 +700,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
700700
ty: Ty<'tcx>,
701701
) -> DiagnosticBuilder<'tcx> {
702702
let ty = self.resolve_vars_if_possible(&ty);
703-
let data = self.extract_infer_data(ty.into(), None);
703+
let data = self.extract_inference_diagnostics_data(ty.into(), None);
704704

705705
let mut err = struct_span_err!(
706706
self.tcx.sess,

compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
396396
) -> Option<RegionNameHighlight> {
397397
let mut highlight = RegionHighlightMode::default();
398398
highlight.highlighting_region_vid(needle_fr, counter);
399-
let type_name = self.infcx.extract_infer_data(ty.into(), Some(highlight)).name;
399+
let type_name =
400+
self.infcx.extract_inference_diagnostics_data(ty.into(), Some(highlight)).name;
400401

401402
debug!(
402403
"highlight_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
@@ -645,7 +646,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
645646

646647
let mut highlight = RegionHighlightMode::default();
647648
highlight.highlighting_region_vid(fr, *self.next_region_name.try_borrow().unwrap());
648-
let type_name = self.infcx.extract_infer_data(return_ty.into(), Some(highlight)).name;
649+
let type_name =
650+
self.infcx.extract_inference_diagnostics_data(return_ty.into(), Some(highlight)).name;
649651

650652
let mir_hir_id = tcx.hir().local_def_id_to_hir_id(self.mir_def_id);
651653

@@ -697,7 +699,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
697699

698700
let mut highlight = RegionHighlightMode::default();
699701
highlight.highlighting_region_vid(fr, *self.next_region_name.try_borrow().unwrap());
700-
let type_name = self.infcx.extract_infer_data(yield_ty.into(), Some(highlight)).name;
702+
let type_name =
703+
self.infcx.extract_inference_diagnostics_data(yield_ty.into(), Some(highlight)).name;
701704

702705
let mir_hir_id = tcx.hir().local_def_id_to_hir_id(self.mir_def_id);
703706

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -1512,11 +1512,21 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15121512
// check upstream for type errors and don't add the obligations to
15131513
// begin with in those cases.
15141514
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
1515-
self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0282).emit();
1515+
self.emit_inference_failure_err(
1516+
body_id,
1517+
span,
1518+
self_ty.into(),
1519+
ErrorCode::E0282,
1520+
)
1521+
.emit();
15161522
return;
15171523
}
1518-
let mut err =
1519-
self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0283);
1524+
let mut err = self.emit_inference_failure_err(
1525+
body_id,
1526+
span,
1527+
self_ty.into(),
1528+
ErrorCode::E0283,
1529+
);
15201530
err.note(&format!("cannot satisfy `{}`", predicate));
15211531
if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code {
15221532
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
@@ -1580,7 +1590,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15801590
return;
15811591
}
15821592

1583-
self.need_type_info_err(body_id, span, arg, ErrorCode::E0282)
1593+
self.emit_inference_failure_err(body_id, span, arg, ErrorCode::E0282)
15841594
}
15851595

15861596
ty::PredicateAtom::Subtype(data) => {
@@ -1591,7 +1601,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
15911601
let SubtypePredicate { a_is_expected: _, a, b } = data;
15921602
// both must be type variables, or the other would've been instantiated
15931603
assert!(a.is_ty_var() && b.is_ty_var());
1594-
self.need_type_info_err(body_id, span, a.into(), ErrorCode::E0282)
1604+
self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282)
15951605
}
15961606
ty::PredicateAtom::Projection(data) => {
15971607
let trait_ref = ty::Binder::bind(data).to_poly_trait_ref(self.tcx);
@@ -1602,8 +1612,12 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
16021612
}
16031613
if self_ty.needs_infer() && ty.needs_infer() {
16041614
// We do this for the `foo.collect()?` case to produce a suggestion.
1605-
let mut err =
1606-
self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0284);
1615+
let mut err = self.emit_inference_failure_err(
1616+
body_id,
1617+
span,
1618+
self_ty.into(),
1619+
ErrorCode::E0284,
1620+
);
16071621
err.note(&format!("cannot satisfy `{}`", predicate));
16081622
err
16091623
} else {

compiler/rustc_typeck/src/check/fn_ctxt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2991,7 +2991,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29912991
ty
29922992
} else {
29932993
if !self.is_tainted_by_errors() {
2994-
self.need_type_info_err((**self).body_id, sp, ty.into(), E0282)
2994+
self.emit_inference_failure_err((**self).body_id, sp, ty.into(), E0282)
29952995
.note("type must be known at this point")
29962996
.emit();
29972997
}

compiler/rustc_typeck/src/check/writeback.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
653653
fn report_type_error(&self, t: Ty<'tcx>) {
654654
if !self.tcx.sess.has_errors() {
655655
self.infcx
656-
.need_type_info_err(
656+
.emit_inference_failure_err(
657657
Some(self.body.id()),
658658
self.span.to_span(self.tcx),
659659
t.into(),
@@ -666,7 +666,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
666666
fn report_const_error(&self, c: &'tcx ty::Const<'tcx>) {
667667
if !self.tcx.sess.has_errors() {
668668
self.infcx
669-
.need_type_info_err(
669+
.emit_inference_failure_err(
670670
Some(self.body.id()),
671671
self.span.to_span(self.tcx),
672672
c.into(),

0 commit comments

Comments
 (0)