@@ -11,7 +11,9 @@ use rustc_middle::hir::map::blocks::FnLikeNode;
11
11
use rustc_middle:: ty:: fold:: TypeFoldable ;
12
12
use rustc_middle:: ty:: subst:: GenericArgKind ;
13
13
use rustc_middle:: ty:: { self , Const , Ty , TyCtxt } ;
14
+ use rustc_session:: Session ;
14
15
use rustc_span:: { self , Span } ;
16
+ use rustc_trait_selection:: traits:: { ObligationCause , ObligationCauseCode } ;
15
17
16
18
use std:: cell:: { Cell , RefCell } ;
17
19
use std:: ops:: Deref ;
@@ -104,8 +106,6 @@ pub struct FnCtxt<'a, 'tcx> {
104
106
pub ( super ) inh : & ' a Inherited < ' a , ' tcx > ,
105
107
}
106
108
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.
109
109
impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
110
110
pub fn new (
111
111
inh : & ' a Inherited < ' a , ' tcx > ,
@@ -132,6 +132,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
132
132
inh,
133
133
}
134
134
}
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
+
135
148
pub fn errors_reported_since_creation ( & self ) -> bool {
136
149
self . tcx . sess . err_count ( ) > self . err_count_on_creation
137
150
}
0 commit comments