about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-09-26 10:28:15 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-09-26 10:28:15 +0200
commit32195ac8f4271b8a05923859baa1d3411408effb (patch)
tree03fd2ba529dd85edc1fbf63a7628dfdac65536a6
parentff7009a4d279c1e5ce1248ca373b91678ad6709c (diff)
downloadrust-32195ac8f4271b8a05923859baa1d3411408effb.tar.gz
rust-32195ac8f4271b8a05923859baa1d3411408effb.zip
rename functions
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs24
-rw-r--r--compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs9
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs28
-rw-r--r--compiler/rustc_typeck/src/check/fn_ctxt.rs2
-rw-r--r--compiler/rustc_typeck/src/check/writeback.rs4
5 files changed, 42 insertions, 25 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
index ce249404e8e..6302139c27d 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
@@ -221,7 +221,7 @@ impl Into<rustc_errors::DiagnosticId> for TypeAnnotationNeeded {
 }
 
 /// Information about a constant or a type containing inference variables.
-pub struct InferDiagnosticsData {
+pub struct InferenceDiagnosticsData {
     pub name: String,
     pub span: Option<Span>,
     pub description: Cow<'static, str>,
@@ -232,11 +232,11 @@ pub struct InferDiagnosticsData {
 impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     /// Extracts data used by diagnostic for either types or constants
     /// which were stuck during inference.
-    pub fn extract_infer_data(
+    pub fn extract_inference_diagnostics_data(
         &self,
         arg: GenericArg<'tcx>,
         highlight: Option<ty::print::RegionHighlightMode>,
-    ) -> InferDiagnosticsData {
+    ) -> InferenceDiagnosticsData {
         match arg.unpack() {
             GenericArgKind::Type(ty) => {
                 if let ty::Infer(ty::TyVar(ty_vid)) = *ty.kind() {
@@ -266,7 +266,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                             };
 
                         if name != kw::SelfUpper {
-                            return InferDiagnosticsData {
+                            return InferenceDiagnosticsData {
                                 name: name.to_string(),
                                 span: Some(var_origin.span),
                                 description: "type parameter".into(),
@@ -283,7 +283,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                     printer.region_highlight_mode = highlight;
                 }
                 let _ = ty.print(printer);
-                InferDiagnosticsData {
+                InferenceDiagnosticsData {
                     name: s,
                     span: None,
                     description: ty.prefix_string(),
@@ -317,7 +317,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                                 (None, None)
                             };
 
-                        return InferDiagnosticsData {
+                        return InferenceDiagnosticsData {
                             name: name.to_string(),
                             span: Some(origin.span),
                             description: "const parameter".into(),
@@ -334,7 +334,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                         printer.region_highlight_mode = highlight;
                     }
                     let _ = ct.print(printer);
-                    InferDiagnosticsData {
+                    InferenceDiagnosticsData {
                         name: s,
                         span: Some(origin.span),
                         description: "the constant".into(),
@@ -349,16 +349,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
         }
     }
 
-    pub fn need_type_info_err(
+    pub fn emit_inference_failure_err(
         &self,
         body_id: Option<hir::BodyId>,
         span: Span,
         arg: GenericArg<'tcx>,
         error_code: TypeAnnotationNeeded,
     ) -> DiagnosticBuilder<'tcx> {
-        let ty = self.resolve_vars_if_possible(&arg);
-        let arg_data = self.extract_infer_data(arg, None);
-        let kind_str = match ty.unpack() {
+        let arg = self.resolve_vars_if_possible(&arg);
+        let arg_data = self.extract_inference_diagnostics_data(arg, None);
+        let kind_str = match arg.unpack() {
             GenericArgKind::Type(_) => "type",
             GenericArgKind::Const(_) => "the value",
             GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"),
@@ -700,7 +700,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
         ty: Ty<'tcx>,
     ) -> DiagnosticBuilder<'tcx> {
         let ty = self.resolve_vars_if_possible(&ty);
-        let data = self.extract_infer_data(ty.into(), None);
+        let data = self.extract_inference_diagnostics_data(ty.into(), None);
 
         let mut err = struct_span_err!(
             self.tcx.sess,
diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs
index 86e8675afb2..5f64eb3dba8 100644
--- a/compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs
+++ b/compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs
@@ -396,7 +396,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
     ) -> Option<RegionNameHighlight> {
         let mut highlight = RegionHighlightMode::default();
         highlight.highlighting_region_vid(needle_fr, counter);
-        let type_name = self.infcx.extract_infer_data(ty.into(), Some(highlight)).name;
+        let type_name =
+            self.infcx.extract_inference_diagnostics_data(ty.into(), Some(highlight)).name;
 
         debug!(
             "highlight_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
@@ -645,7 +646,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
 
         let mut highlight = RegionHighlightMode::default();
         highlight.highlighting_region_vid(fr, *self.next_region_name.try_borrow().unwrap());
-        let type_name = self.infcx.extract_infer_data(return_ty.into(), Some(highlight)).name;
+        let type_name =
+            self.infcx.extract_inference_diagnostics_data(return_ty.into(), Some(highlight)).name;
 
         let mir_hir_id = tcx.hir().local_def_id_to_hir_id(self.mir_def_id);
 
@@ -697,7 +699,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
 
         let mut highlight = RegionHighlightMode::default();
         highlight.highlighting_region_vid(fr, *self.next_region_name.try_borrow().unwrap());
-        let type_name = self.infcx.extract_infer_data(yield_ty.into(), Some(highlight)).name;
+        let type_name =
+            self.infcx.extract_inference_diagnostics_data(yield_ty.into(), Some(highlight)).name;
 
         let mir_hir_id = tcx.hir().local_def_id_to_hir_id(self.mir_def_id);
 
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
index 4cc9a1ecdc8..1b234a1535c 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
@@ -1512,11 +1512,21 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
                 // check upstream for type errors and don't add the obligations to
                 // begin with in those cases.
                 if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
-                    self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0282).emit();
+                    self.emit_inference_failure_err(
+                        body_id,
+                        span,
+                        self_ty.into(),
+                        ErrorCode::E0282,
+                    )
+                    .emit();
                     return;
                 }
-                let mut err =
-                    self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0283);
+                let mut err = self.emit_inference_failure_err(
+                    body_id,
+                    span,
+                    self_ty.into(),
+                    ErrorCode::E0283,
+                );
                 err.note(&format!("cannot satisfy `{}`", predicate));
                 if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code {
                     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> {
                     return;
                 }
 
-                self.need_type_info_err(body_id, span, arg, ErrorCode::E0282)
+                self.emit_inference_failure_err(body_id, span, arg, ErrorCode::E0282)
             }
 
             ty::PredicateAtom::Subtype(data) => {
@@ -1591,7 +1601,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
                 let SubtypePredicate { a_is_expected: _, a, b } = data;
                 // both must be type variables, or the other would've been instantiated
                 assert!(a.is_ty_var() && b.is_ty_var());
-                self.need_type_info_err(body_id, span, a.into(), ErrorCode::E0282)
+                self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282)
             }
             ty::PredicateAtom::Projection(data) => {
                 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> {
                 }
                 if self_ty.needs_infer() && ty.needs_infer() {
                     // We do this for the `foo.collect()?` case to produce a suggestion.
-                    let mut err =
-                        self.need_type_info_err(body_id, span, self_ty.into(), ErrorCode::E0284);
+                    let mut err = self.emit_inference_failure_err(
+                        body_id,
+                        span,
+                        self_ty.into(),
+                        ErrorCode::E0284,
+                    );
                     err.note(&format!("cannot satisfy `{}`", predicate));
                     err
                 } else {
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt.rs b/compiler/rustc_typeck/src/check/fn_ctxt.rs
index 31010753474..79d6c7dbfda 100644
--- a/compiler/rustc_typeck/src/check/fn_ctxt.rs
+++ b/compiler/rustc_typeck/src/check/fn_ctxt.rs
@@ -2991,7 +2991,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             ty
         } else {
             if !self.is_tainted_by_errors() {
-                self.need_type_info_err((**self).body_id, sp, ty.into(), E0282)
+                self.emit_inference_failure_err((**self).body_id, sp, ty.into(), E0282)
                     .note("type must be known at this point")
                     .emit();
             }
diff --git a/compiler/rustc_typeck/src/check/writeback.rs b/compiler/rustc_typeck/src/check/writeback.rs
index ccff9b5cdb4..6fd7277a1c3 100644
--- a/compiler/rustc_typeck/src/check/writeback.rs
+++ b/compiler/rustc_typeck/src/check/writeback.rs
@@ -653,7 +653,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
     fn report_type_error(&self, t: Ty<'tcx>) {
         if !self.tcx.sess.has_errors() {
             self.infcx
-                .need_type_info_err(
+                .emit_inference_failure_err(
                     Some(self.body.id()),
                     self.span.to_span(self.tcx),
                     t.into(),
@@ -666,7 +666,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
     fn report_const_error(&self, c: &'tcx ty::Const<'tcx>) {
         if !self.tcx.sess.has_errors() {
             self.infcx
-                .need_type_info_err(
+                .emit_inference_failure_err(
                     Some(self.body.id()),
                     self.span.to_span(self.tcx),
                     c.into(),