1
1
use crate :: build:: expr:: as_place:: PlaceBuilder ;
2
2
use crate :: build:: scope:: DropKind ;
3
+ use hir:: def_id:: LOCAL_CRATE ;
3
4
use itertools:: Itertools ;
4
5
use rustc_apfloat:: ieee:: { Double , Half , Quad , Single } ;
5
6
use rustc_apfloat:: Float ;
@@ -21,9 +22,9 @@ use rustc_middle::query::TyCtxtAt;
21
22
use rustc_middle:: thir:: { self , ExprId , LintLevel , LocalVarId , Param , ParamId , PatKind , Thir } ;
22
23
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
23
24
use rustc_span:: symbol:: sym;
24
- use rustc_span:: Span ;
25
25
use rustc_span:: Symbol ;
26
- use rustc_target:: abi:: FieldIdx ;
26
+ use rustc_span:: { Span , DUMMY_SP } ;
27
+ use rustc_target:: abi:: { FieldIdx , VariantIdx } ;
27
28
use rustc_target:: spec:: abi:: Abi ;
28
29
29
30
use super :: lints;
@@ -510,6 +511,33 @@ fn construct_fn<'tcx>(
510
511
coroutine,
511
512
) ;
512
513
514
+ if tcx. sess . is_nightly_build ( )
515
+ && tcx. crate_name ( LOCAL_CRATE ) . as_str ( ) == "version_check"
516
+ && tcx. item_name ( fn_def. into ( ) ) . as_str ( ) == "supports_feature"
517
+ && fn_sig. inputs ( ) . len ( ) == 1
518
+ && let Some ( ref_arg) = fn_sig. inputs ( ) [ 0 ] . builtin_deref ( false )
519
+ && ref_arg. ty . is_str ( )
520
+ && let ty:: Adt ( adt, args) = return_ty. kind ( )
521
+ && tcx. lang_items ( ) . option_type ( ) == Some ( adt. did ( ) )
522
+ && args[ 0 ] . expect_ty ( ) . is_bool ( )
523
+ {
524
+ let block = START_BLOCK ;
525
+ let source_info = builder. source_info ( DUMMY_SP ) ;
526
+
527
+ builder. local_decls . push ( LocalDecl :: with_source_info ( fn_sig. inputs ( ) [ 0 ] , source_info) ) ;
528
+ builder. cfg . push_assign (
529
+ block,
530
+ source_info,
531
+ Place :: return_place ( ) ,
532
+ Rvalue :: Aggregate (
533
+ Box :: new ( AggregateKind :: Adt ( adt. did ( ) , VariantIdx :: ZERO , args, None , None ) ) ,
534
+ Default :: default ( ) ,
535
+ ) ,
536
+ ) ;
537
+ builder. cfg . terminate ( block, source_info, TerminatorKind :: Return ) ;
538
+ return builder. finish ( ) ;
539
+ }
540
+
513
541
let call_site_scope =
514
542
region:: Scope { id : body_id. hir_id . local_id , data : region:: ScopeData :: CallSite } ;
515
543
let arg_scope =
0 commit comments