@@ -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,28 @@ 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.
898
+ /// Given a `HirId`, return the `HirId` of the enclosing function and its `FnDecl`.
900
899
pub ( crate ) fn get_fn_decl (
901
900
& self ,
902
901
blk_id : HirId ,
903
- ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > , bool ) > {
902
+ ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > ) > {
904
903
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
905
904
// `while` before reaching it, as block tail returns are not available in them.
906
905
self . tcx . hir ( ) . get_fn_id_for_return_block ( blk_id) . and_then ( |item_id| {
907
906
match self . tcx . hir_node ( item_id) {
908
907
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 ) ) ,
919
910
Node :: TraitItem ( & hir:: TraitItem {
920
911
kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
921
912
owner_id,
922
913
..
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 ) ) ,
925
915
Node :: ImplItem ( & hir:: ImplItem {
926
916
kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
927
917
owner_id,
928
918
..
929
- } ) => Some ( ( owner_id. def_id , sig. decl , false ) ) ,
919
+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
930
920
Node :: Expr ( & hir:: Expr {
931
921
hir_id,
932
922
kind : hir:: ExprKind :: Closure ( & hir:: Closure { def_id, kind, fn_decl, .. } ) ,
@@ -937,33 +927,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
937
927
// FIXME(async_closures): Implement this.
938
928
return None ;
939
929
}
940
- hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl, true ) ) ,
930
+ hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl) ) ,
941
931
hir:: ClosureKind :: Coroutine ( hir:: CoroutineKind :: Desugared (
942
932
_,
943
933
hir:: CoroutineSource :: Fn ,
944
934
) ) => {
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) {
946
936
Node :: Item ( & hir:: Item {
947
- ident,
948
937
kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
949
938
owner_id,
950
939
..
951
- } ) => ( ident , sig, owner_id) ,
940
+ } ) => ( sig, owner_id) ,
952
941
Node :: TraitItem ( & hir:: TraitItem {
953
- ident,
954
942
kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
955
943
owner_id,
956
944
..
957
- } ) => ( ident , sig, owner_id) ,
945
+ } ) => ( sig, owner_id) ,
958
946
Node :: ImplItem ( & hir:: ImplItem {
959
- ident,
960
947
kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
961
948
owner_id,
962
949
..
963
- } ) => ( ident , sig, owner_id) ,
950
+ } ) => ( sig, owner_id) ,
964
951
_ => return None ,
965
952
} ;
966
- Some ( ( owner_id. def_id , sig. decl , ident . name != sym :: main ) )
953
+ Some ( ( owner_id. def_id , sig. decl ) )
967
954
}
968
955
_ => None ,
969
956
}
0 commit comments