11use crate :: build:: expr:: as_place:: PlaceBuilder ;
22use crate :: build:: scope:: DropKind ;
3+ use hir:: def_id:: LOCAL_CRATE ;
34use itertools:: Itertools ;
45use rustc_apfloat:: ieee:: { Double , Half , Quad , Single } ;
56use rustc_apfloat:: Float ;
@@ -21,9 +22,9 @@ use rustc_middle::query::TyCtxtAt;
2122use rustc_middle:: thir:: { self , ExprId , LintLevel , LocalVarId , Param , ParamId , PatKind , Thir } ;
2223use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
2324use rustc_span:: symbol:: sym;
24- use rustc_span:: Span ;
2525use rustc_span:: Symbol ;
26- use rustc_target:: abi:: FieldIdx ;
26+ use rustc_span:: { Span , DUMMY_SP } ;
27+ use rustc_target:: abi:: { FieldIdx , VariantIdx } ;
2728use rustc_target:: spec:: abi:: Abi ;
2829
2930use super :: lints;
@@ -510,6 +511,33 @@ fn construct_fn<'tcx>(
510511 coroutine,
511512 ) ;
512513
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+
513541 let call_site_scope =
514542 region:: Scope { id : body_id. hir_id . local_id , data : region:: ScopeData :: CallSite } ;
515543 let arg_scope =
0 commit comments