@@ -77,7 +77,7 @@ pub struct ForceInline;
77
77
78
78
impl ForceInline {
79
79
pub fn should_run_pass_for_callee < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> bool {
80
- matches ! ( tcx. codegen_fn_attrs( def_id) . inline, InlineAttr :: Force { .. } )
80
+ matches ! ( tcx. codegen_fn_attrs( def_id) . inline, InlineAttr :: Force { .. } | InlineAttr :: Early )
81
81
}
82
82
}
83
83
@@ -195,7 +195,7 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> {
195
195
& self ,
196
196
callee_attrs : & CodegenFnAttrs ,
197
197
) -> Result < ( ) , & ' static str > {
198
- debug_assert_matches ! ( callee_attrs. inline, InlineAttr :: Force { .. } ) ;
198
+ debug_assert_matches ! ( callee_attrs. inline, InlineAttr :: Force { .. } | InlineAttr :: Early ) ;
199
199
Ok ( ( ) )
200
200
}
201
201
@@ -247,23 +247,26 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> {
247
247
248
248
fn on_inline_failure ( & self , callsite : & CallSite < ' tcx > , reason : & ' static str ) {
249
249
let tcx = self . tcx ( ) ;
250
- let InlineAttr :: Force { attr_span, reason : justification } =
251
- tcx. codegen_fn_attrs ( callsite. callee . def_id ( ) ) . inline
252
- else {
253
- bug ! ( "called on item without required inlining" ) ;
254
- } ;
255
-
256
- let call_span = callsite. source_info . span ;
257
- tcx. dcx ( ) . emit_err ( crate :: errors:: ForceInlineFailure {
258
- call_span,
259
- attr_span,
260
- caller_span : tcx. def_span ( self . def_id ) ,
261
- caller : tcx. def_path_str ( self . def_id ) ,
262
- callee_span : tcx. def_span ( callsite. callee . def_id ( ) ) ,
263
- callee : tcx. def_path_str ( callsite. callee . def_id ( ) ) ,
264
- reason,
265
- justification : justification. map ( |sym| crate :: errors:: ForceInlineJustification { sym } ) ,
266
- } ) ;
250
+ match tcx. codegen_fn_attrs ( callsite. callee . def_id ( ) ) . inline {
251
+ InlineAttr :: Early => {
252
+ // Ok, we don't actually mind if this fails.
253
+ }
254
+ InlineAttr :: Force { attr_span, reason : justification } => {
255
+ let call_span = callsite. source_info . span ;
256
+ tcx. dcx ( ) . emit_err ( crate :: errors:: ForceInlineFailure {
257
+ call_span,
258
+ attr_span,
259
+ caller_span : tcx. def_span ( self . def_id ) ,
260
+ caller : tcx. def_path_str ( self . def_id ) ,
261
+ callee_span : tcx. def_span ( callsite. callee . def_id ( ) ) ,
262
+ callee : tcx. def_path_str ( callsite. callee . def_id ( ) ) ,
263
+ reason,
264
+ justification : justification
265
+ . map ( |sym| crate :: errors:: ForceInlineJustification { sym } ) ,
266
+ } ) ;
267
+ }
268
+ _ => bug ! ( "called on item without required inlining" ) ,
269
+ }
267
270
}
268
271
}
269
272
0 commit comments