@@ -77,7 +77,7 @@ pub struct ForceInline;
7777
7878impl ForceInline {
7979 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 )
8181 }
8282}
8383
@@ -195,7 +195,7 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> {
195195 & self ,
196196 callee_attrs : & CodegenFnAttrs ,
197197 ) -> Result < ( ) , & ' static str > {
198- debug_assert_matches ! ( callee_attrs. inline, InlineAttr :: Force { .. } ) ;
198+ debug_assert_matches ! ( callee_attrs. inline, InlineAttr :: Force { .. } | InlineAttr :: Early ) ;
199199 Ok ( ( ) )
200200 }
201201
@@ -247,23 +247,26 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> {
247247
248248 fn on_inline_failure ( & self , callsite : & CallSite < ' tcx > , reason : & ' static str ) {
249249 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+ }
267270 }
268271}
269272
0 commit comments