@@ -30,7 +30,7 @@ use rustc_middle::{bug, span_bug};
3030use rustc_session:: lint;
3131use rustc_span:: def_id:: LocalDefId ;
3232use rustc_span:: hygiene:: DesugaringKind ;
33- use rustc_span:: symbol:: { kw , sym } ;
33+ use rustc_span:: symbol:: kw ;
3434use rustc_span:: Span ;
3535use rustc_target:: abi:: FieldIdx ;
3636use rustc_trait_selection:: error_reporting:: infer:: need_type_info:: TypeAnnotationNeeded ;
@@ -859,38 +859,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
859859 )
860860 }
861861
862- /// Given a `HirId`, return the `HirId` of the enclosing function, its `FnDecl`, and whether a
863- /// suggestion can be made, `None` otherwise.
862+ /// Given a `HirId`, return the `HirId` of the enclosing function and its `FnDecl`.
864863 pub ( crate ) fn get_fn_decl (
865864 & self ,
866865 blk_id : HirId ,
867- ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > , bool ) > {
866+ ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > ) > {
868867 // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
869868 // `while` before reaching it, as block tail returns are not available in them.
870869 self . tcx . hir ( ) . get_fn_id_for_return_block ( blk_id) . and_then ( |item_id| {
871870 match self . tcx . hir_node ( item_id) {
872871 Node :: Item ( & hir:: Item {
873- ident,
874- kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
875- owner_id,
876- ..
877- } ) => {
878- // This is less than ideal, it will not suggest a return type span on any
879- // method called `main`, regardless of whether it is actually the entry point,
880- // but it will still present it as the reason for the expected type.
881- Some ( ( owner_id. def_id , sig. decl , ident. name != sym:: main) )
882- }
872+ kind : hir:: ItemKind :: Fn ( ref sig, ..) , owner_id, ..
873+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
883874 Node :: TraitItem ( & hir:: TraitItem {
884875 kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
885876 owner_id,
886877 ..
887- } ) => Some ( ( owner_id. def_id , sig. decl , true ) ) ,
888- // FIXME: Suggestable if this is not a trait implementation
878+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
889879 Node :: ImplItem ( & hir:: ImplItem {
890880 kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
891881 owner_id,
892882 ..
893- } ) => Some ( ( owner_id. def_id , sig. decl , false ) ) ,
883+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
894884 Node :: Expr ( & hir:: Expr {
895885 hir_id,
896886 kind : hir:: ExprKind :: Closure ( & hir:: Closure { def_id, kind, fn_decl, .. } ) ,
@@ -901,33 +891,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
901891 // FIXME(async_closures): Implement this.
902892 return None ;
903893 }
904- hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl, true ) ) ,
894+ hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl) ) ,
905895 hir:: ClosureKind :: Coroutine ( hir:: CoroutineKind :: Desugared (
906896 _,
907897 hir:: CoroutineSource :: Fn ,
908898 ) ) => {
909- let ( ident , sig, owner_id) = match self . tcx . parent_hir_node ( hir_id) {
899+ let ( sig, owner_id) = match self . tcx . parent_hir_node ( hir_id) {
910900 Node :: Item ( & hir:: Item {
911- ident,
912901 kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
913902 owner_id,
914903 ..
915- } ) => ( ident , sig, owner_id) ,
904+ } ) => ( sig, owner_id) ,
916905 Node :: TraitItem ( & hir:: TraitItem {
917- ident,
918906 kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
919907 owner_id,
920908 ..
921- } ) => ( ident , sig, owner_id) ,
909+ } ) => ( sig, owner_id) ,
922910 Node :: ImplItem ( & hir:: ImplItem {
923- ident,
924911 kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
925912 owner_id,
926913 ..
927- } ) => ( ident , sig, owner_id) ,
914+ } ) => ( sig, owner_id) ,
928915 _ => return None ,
929916 } ;
930- Some ( ( owner_id. def_id , sig. decl , ident . name != sym :: main ) )
917+ Some ( ( owner_id. def_id , sig. decl ) )
931918 }
932919 _ => None ,
933920 }
0 commit comments