]> git.lizzy.rs Git - rust.git/commitdiff
Moved some short functions back into fn_ctxt.rs
authorNicholas-Baron <nicholas.baron.ten@gmail.com>
Sun, 11 Oct 2020 22:59:41 +0000 (15:59 -0700)
committerNicholas-Baron <nicholas.baron.ten@gmail.com>
Sun, 11 Oct 2020 23:10:42 +0000 (16:10 -0700)
compiler/rustc_typeck/src/check/fn_ctxt.rs
compiler/rustc_typeck/src/check/fn_ctxt_impl.rs

index 48c17170c9677902e4927a268a16f0e2593db0e2..dff54cae4df95c7323cf01f6f02ea90a557ed736 100644 (file)
@@ -11,7 +11,9 @@
 use rustc_middle::ty::fold::TypeFoldable;
 use rustc_middle::ty::subst::GenericArgKind;
 use rustc_middle::ty::{self, Const, Ty, TyCtxt};
+use rustc_session::Session;
 use rustc_span::{self, Span};
+use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
 
 use std::cell::{Cell, RefCell};
 use std::ops::Deref;
@@ -104,8 +106,6 @@ pub struct FnCtxt<'a, 'tcx> {
     pub(super) inh: &'a Inherited<'a, 'tcx>,
 }
 
-// FIXME: This impl is for functions which access the (private) `err_count_on_creation` field.
-// It looks like that field will be changed soon and so this solution may end up being temporary.
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     pub fn new(
         inh: &'a Inherited<'a, 'tcx>,
@@ -132,6 +132,19 @@ pub fn new(
             inh,
         }
     }
+
+    pub fn cause(&self, span: Span, code: ObligationCauseCode<'tcx>) -> ObligationCause<'tcx> {
+        ObligationCause::new(span, self.body_id, code)
+    }
+
+    pub fn misc(&self, span: Span) -> ObligationCause<'tcx> {
+        self.cause(span, ObligationCauseCode::MiscObligation)
+    }
+
+    pub fn sess(&self) -> &Session {
+        &self.tcx.sess
+    }
+
     pub fn errors_reported_since_creation(&self) -> bool {
         self.tcx.sess.err_count() > self.err_count_on_creation
     }
index 4a9172a0e25b5fa1dab6b33e4d94f90ab400a4ba..17ced624e4b7254a8029d0464e60ad393beb4c6f 100644 (file)
@@ -54,9 +54,6 @@
 use std::slice;
 
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
-    pub fn sess(&self) -> &Session {
-        &self.tcx.sess
-    }
 
     /// Produces warning on the given node, if the current point in the
     /// function is unreachable, and there hasn't been another warning.
@@ -90,14 +87,6 @@ pub(super) fn warn_if_unreachable(&self, id: hir::HirId, span: Span, kind: &str)
         }
     }
 
-    pub fn cause(&self, span: Span, code: ObligationCauseCode<'tcx>) -> ObligationCause<'tcx> {
-        ObligationCause::new(span, self.body_id, code)
-    }
-
-    pub fn misc(&self, span: Span) -> ObligationCause<'tcx> {
-        self.cause(span, ObligationCauseCode::MiscObligation)
-    }
-
     /// Resolves type and const variables in `ty` if possible. Unlike the infcx
     /// version (resolve_vars_if_possible), this version will
     /// also select obligations if it seems useful, in an effort