@@ -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,28 @@ 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.
898+ /// Given a `HirId`, return the `HirId` of the enclosing function and its `FnDecl`.
900899 pub ( crate ) fn get_fn_decl (
901900 & self ,
902901 blk_id : HirId ,
903- ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > , bool ) > {
902+ ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > ) > {
904903 // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
905904 // `while` before reaching it, as block tail returns are not available in them.
906905 self . tcx . hir ( ) . get_fn_id_for_return_block ( blk_id) . and_then ( |item_id| {
907906 match self . tcx . hir_node ( item_id) {
908907 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- }
908+ kind : hir:: ItemKind :: Fn ( ref sig, ..) , owner_id, ..
909+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
919910 Node :: TraitItem ( & hir:: TraitItem {
920911 kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
921912 owner_id,
922913 ..
923- } ) => Some ( ( owner_id. def_id , sig. decl , true ) ) ,
924- // FIXME: Suggestable if this is not a trait implementation
914+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
925915 Node :: ImplItem ( & hir:: ImplItem {
926916 kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
927917 owner_id,
928918 ..
929- } ) => Some ( ( owner_id. def_id , sig. decl , false ) ) ,
919+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
930920 Node :: Expr ( & hir:: Expr {
931921 hir_id,
932922 kind : hir:: ExprKind :: Closure ( & hir:: Closure { def_id, kind, fn_decl, .. } ) ,
@@ -937,33 +927,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
937927 // FIXME(async_closures): Implement this.
938928 return None ;
939929 }
940- hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl, true ) ) ,
930+ hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl) ) ,
941931 hir:: ClosureKind :: Coroutine ( hir:: CoroutineKind :: Desugared (
942932 _,
943933 hir:: CoroutineSource :: Fn ,
944934 ) ) => {
945- let ( ident , sig, owner_id) = match self . tcx . parent_hir_node ( hir_id) {
935+ let ( sig, owner_id) = match self . tcx . parent_hir_node ( hir_id) {
946936 Node :: Item ( & hir:: Item {
947- ident,
948937 kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
949938 owner_id,
950939 ..
951- } ) => ( ident , sig, owner_id) ,
940+ } ) => ( sig, owner_id) ,
952941 Node :: TraitItem ( & hir:: TraitItem {
953- ident,
954942 kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
955943 owner_id,
956944 ..
957- } ) => ( ident , sig, owner_id) ,
945+ } ) => ( sig, owner_id) ,
958946 Node :: ImplItem ( & hir:: ImplItem {
959- ident,
960947 kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
961948 owner_id,
962949 ..
963- } ) => ( ident , sig, owner_id) ,
950+ } ) => ( sig, owner_id) ,
964951 _ => return None ,
965952 } ;
966- Some ( ( owner_id. def_id , sig. decl , ident . name != sym :: main ) )
953+ Some ( ( owner_id. def_id , sig. decl ) )
967954 }
968955 _ => None ,
969956 }
0 commit comments