@@ -31,7 +31,7 @@ use rustc_middle::{bug, span_bug};
3131use rustc_session:: lint;
3232use rustc_span:: def_id:: LocalDefId ;
3333use rustc_span:: hygiene:: DesugaringKind ;
34- use rustc_span:: symbol:: { kw , sym } ;
34+ use rustc_span:: symbol:: kw ;
3535use rustc_span:: Span ;
3636use rustc_target:: abi:: FieldIdx ;
3737use rustc_trait_selection:: error_reporting:: infer:: need_type_info:: TypeAnnotationNeeded ;
@@ -895,38 +895,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
895895 )
896896 }
897897
898- /// Given a `HirId`, return the `HirId` of the enclosing function, its `FnDecl`, and whether a
899- /// suggestion can be made, `None` otherwise.
900- pub fn get_fn_decl (
901- & self ,
902- blk_id : HirId ,
903- ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > , bool ) > {
898+ /// Given a `HirId`, return the `HirId` of the enclosing function and its `FnDecl`.
899+ pub fn get_fn_decl ( & self , blk_id : HirId ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > ) > {
904900 // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
905901 // `while` before reaching it, as block tail returns are not available in them.
906902 self . tcx . hir ( ) . get_fn_id_for_return_block ( blk_id) . and_then ( |item_id| {
907903 match self . tcx . hir_node ( item_id) {
908904 Node :: Item ( & hir:: Item {
909- ident,
910- kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
911- owner_id,
912- ..
913- } ) => {
914- // This is less than ideal, it will not suggest a return type span on any
915- // method called `main`, regardless of whether it is actually the entry point,
916- // but it will still present it as the reason for the expected type.
917- Some ( ( owner_id. def_id , sig. decl , ident. name != sym:: main) )
918- }
905+ kind : hir:: ItemKind :: Fn ( ref sig, ..) , owner_id, ..
906+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
919907 Node :: TraitItem ( & hir:: TraitItem {
920908 kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
921909 owner_id,
922910 ..
923- } ) => Some ( ( owner_id. def_id , sig. decl , true ) ) ,
924- // FIXME: Suggestable if this is not a trait implementation
911+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
925912 Node :: ImplItem ( & hir:: ImplItem {
926913 kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
927914 owner_id,
928915 ..
929- } ) => Some ( ( owner_id. def_id , sig. decl , false ) ) ,
916+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
930917 Node :: Expr ( & hir:: Expr {
931918 hir_id,
932919 kind : hir:: ExprKind :: Closure ( & hir:: Closure { def_id, kind, fn_decl, .. } ) ,
@@ -937,33 +924,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
937924 // FIXME(async_closures): Implement this.
938925 return None ;
939926 }
940- hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl, true ) ) ,
927+ hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl) ) ,
941928 hir:: ClosureKind :: Coroutine ( hir:: CoroutineKind :: Desugared (
942929 _,
943930 hir:: CoroutineSource :: Fn ,
944931 ) ) => {
945- let ( ident , sig, owner_id) = match self . tcx . parent_hir_node ( hir_id) {
932+ let ( sig, owner_id) = match self . tcx . parent_hir_node ( hir_id) {
946933 Node :: Item ( & hir:: Item {
947- ident,
948934 kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
949935 owner_id,
950936 ..
951- } ) => ( ident , sig, owner_id) ,
937+ } ) => ( sig, owner_id) ,
952938 Node :: TraitItem ( & hir:: TraitItem {
953- ident,
954939 kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
955940 owner_id,
956941 ..
957- } ) => ( ident , sig, owner_id) ,
942+ } ) => ( sig, owner_id) ,
958943 Node :: ImplItem ( & hir:: ImplItem {
959- ident,
960944 kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
961945 owner_id,
962946 ..
963- } ) => ( ident , sig, owner_id) ,
947+ } ) => ( sig, owner_id) ,
964948 _ => return None ,
965949 } ;
966- Some ( ( owner_id. def_id , sig. decl , ident . name != sym :: main ) )
950+ Some ( ( owner_id. def_id , sig. decl ) )
967951 }
968952 _ => None ,
969953 }
0 commit comments