Skip to content

Commit 48291cf

Browse files
Moved some short functions back into fn_ctxt.rs
1 parent 21751fa commit 48291cf

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

compiler/rustc_typeck/src/check/fn_ctxt.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use rustc_middle::hir::map::blocks::FnLikeNode;
1111
use rustc_middle::ty::fold::TypeFoldable;
1212
use rustc_middle::ty::subst::GenericArgKind;
1313
use rustc_middle::ty::{self, Const, Ty, TyCtxt};
14+
use rustc_session::Session;
1415
use rustc_span::{self, Span};
16+
use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
1517

1618
use std::cell::{Cell, RefCell};
1719
use std::ops::Deref;
@@ -104,8 +106,6 @@ pub struct FnCtxt<'a, 'tcx> {
104106
pub(super) inh: &'a Inherited<'a, 'tcx>,
105107
}
106108

107-
// FIXME: This impl is for functions which access the (private) `err_count_on_creation` field.
108-
// It looks like that field will be changed soon and so this solution may end up being temporary.
109109
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
110110
pub fn new(
111111
inh: &'a Inherited<'a, 'tcx>,
@@ -132,6 +132,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
132132
inh,
133133
}
134134
}
135+
136+
pub fn cause(&self, span: Span, code: ObligationCauseCode<'tcx>) -> ObligationCause<'tcx> {
137+
ObligationCause::new(span, self.body_id, code)
138+
}
139+
140+
pub fn misc(&self, span: Span) -> ObligationCause<'tcx> {
141+
self.cause(span, ObligationCauseCode::MiscObligation)
142+
}
143+
144+
pub fn sess(&self) -> &Session {
145+
&self.tcx.sess
146+
}
147+
135148
pub fn errors_reported_since_creation(&self) -> bool {
136149
self.tcx.sess.err_count() > self.err_count_on_creation
137150
}

compiler/rustc_typeck/src/check/fn_ctxt_impl.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ use std::mem::replace;
5454
use std::slice;
5555

5656
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
57-
pub fn sess(&self) -> &Session {
58-
&self.tcx.sess
59-
}
6057

6158
/// Produces warning on the given node, if the current point in the
6259
/// function is unreachable, and there hasn't been another warning.
@@ -90,14 +87,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9087
}
9188
}
9289

93-
pub fn cause(&self, span: Span, code: ObligationCauseCode<'tcx>) -> ObligationCause<'tcx> {
94-
ObligationCause::new(span, self.body_id, code)
95-
}
96-
97-
pub fn misc(&self, span: Span) -> ObligationCause<'tcx> {
98-
self.cause(span, ObligationCauseCode::MiscObligation)
99-
}
100-
10190
/// Resolves type and const variables in `ty` if possible. Unlike the infcx
10291
/// version (resolve_vars_if_possible), this version will
10392
/// also select obligations if it seems useful, in an effort

0 commit comments

Comments
 (0)