@@ -31,7 +31,7 @@ use rustc_middle::{bug, span_bug};
31
31
use rustc_session:: lint;
32
32
use rustc_span:: def_id:: LocalDefId ;
33
33
use rustc_span:: hygiene:: DesugaringKind ;
34
- use rustc_span:: symbol:: { kw , sym } ;
34
+ use rustc_span:: symbol:: kw ;
35
35
use rustc_span:: Span ;
36
36
use rustc_target:: abi:: FieldIdx ;
37
37
use rustc_trait_selection:: error_reporting:: infer:: need_type_info:: TypeAnnotationNeeded ;
@@ -895,38 +895,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
895
895
)
896
896
}
897
897
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 > ) > {
904
900
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
905
901
// `while` before reaching it, as block tail returns are not available in them.
906
902
self . tcx . hir ( ) . get_fn_id_for_return_block ( blk_id) . and_then ( |item_id| {
907
903
match self . tcx . hir_node ( item_id) {
908
904
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 ) ) ,
919
907
Node :: TraitItem ( & hir:: TraitItem {
920
908
kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
921
909
owner_id,
922
910
..
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 ) ) ,
925
912
Node :: ImplItem ( & hir:: ImplItem {
926
913
kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
927
914
owner_id,
928
915
..
929
- } ) => Some ( ( owner_id. def_id , sig. decl , false ) ) ,
916
+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
930
917
Node :: Expr ( & hir:: Expr {
931
918
hir_id,
932
919
kind : hir:: ExprKind :: Closure ( & hir:: Closure { def_id, kind, fn_decl, .. } ) ,
@@ -937,33 +924,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
937
924
// FIXME(async_closures): Implement this.
938
925
return None ;
939
926
}
940
- hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl, true ) ) ,
927
+ hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl) ) ,
941
928
hir:: ClosureKind :: Coroutine ( hir:: CoroutineKind :: Desugared (
942
929
_,
943
930
hir:: CoroutineSource :: Fn ,
944
931
) ) => {
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) {
946
933
Node :: Item ( & hir:: Item {
947
- ident,
948
934
kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
949
935
owner_id,
950
936
..
951
- } ) => ( ident , sig, owner_id) ,
937
+ } ) => ( sig, owner_id) ,
952
938
Node :: TraitItem ( & hir:: TraitItem {
953
- ident,
954
939
kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
955
940
owner_id,
956
941
..
957
- } ) => ( ident , sig, owner_id) ,
942
+ } ) => ( sig, owner_id) ,
958
943
Node :: ImplItem ( & hir:: ImplItem {
959
- ident,
960
944
kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
961
945
owner_id,
962
946
..
963
- } ) => ( ident , sig, owner_id) ,
947
+ } ) => ( sig, owner_id) ,
964
948
_ => return None ,
965
949
} ;
966
- Some ( ( owner_id. def_id , sig. decl , ident . name != sym :: main ) )
950
+ Some ( ( owner_id. def_id , sig. decl ) )
967
951
}
968
952
_ => None ,
969
953
}
0 commit comments