@@ -45,15 +45,7 @@ impl<'tcx> MirPass<'tcx> for Inline {
45
45
return enabled;
46
46
}
47
47
48
- match sess. mir_opt_level ( ) {
49
- 0 | 1 => false ,
50
- 2 => {
51
- ( sess. opts . optimize == OptLevel :: Default
52
- || sess. opts . optimize == OptLevel :: Aggressive )
53
- && sess. opts . incremental == None
54
- }
55
- _ => true ,
56
- }
48
+ sess. mir_opt_level ( ) > 0
57
49
}
58
50
59
51
fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
@@ -341,7 +333,23 @@ impl<'tcx> Inliner<'tcx> {
341
333
) -> Result < ( ) , & ' static str > {
342
334
match callee_attrs. inline {
343
335
InlineAttr :: Never => return Err ( "never inline hint" ) ,
344
- InlineAttr :: Always | InlineAttr :: Hint => { }
336
+ InlineAttr :: Always => { }
337
+ InlineAttr :: Hint => match self . tcx . sess . mir_opt_level ( ) {
338
+ 0 | 1 => return Err ( "at mir-opt-level=1, only #[inline(always)] is inlined" ) ,
339
+ 2 if self . tcx . sess . opts . optimize != OptLevel :: Default
340
+ && self . tcx . sess . opts . optimize != OptLevel :: Aggressive =>
341
+ {
342
+ return Err (
343
+ "at mir-opt-level=2, only #[inline(always)] is inlined when opt-level<2" ,
344
+ ) ;
345
+ }
346
+ 2 if self . tcx . sess . opts . incremental != None => {
347
+ return Err (
348
+ "at mir-opt-level=2, only #[inline(always)] is inlined when incremental compilation is enabled" ,
349
+ ) ;
350
+ }
351
+ _ => { }
352
+ } ,
345
353
InlineAttr :: None => {
346
354
if self . tcx . sess . mir_opt_level ( ) <= 2 {
347
355
return Err ( "at mir-opt-level=2, only #[inline] is inlined" ) ;
0 commit comments