@@ -30,7 +30,7 @@ use rustc_middle::{bug, span_bug};
30
30
use rustc_session:: lint;
31
31
use rustc_span:: def_id:: LocalDefId ;
32
32
use rustc_span:: hygiene:: DesugaringKind ;
33
- use rustc_span:: symbol:: { kw , sym } ;
33
+ use rustc_span:: symbol:: kw ;
34
34
use rustc_span:: Span ;
35
35
use rustc_target:: abi:: FieldIdx ;
36
36
use rustc_trait_selection:: error_reporting:: infer:: need_type_info:: TypeAnnotationNeeded ;
@@ -859,38 +859,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
859
859
)
860
860
}
861
861
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`.
864
863
pub ( crate ) fn get_fn_decl (
865
864
& self ,
866
865
blk_id : HirId ,
867
- ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > , bool ) > {
866
+ ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > ) > {
868
867
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
869
868
// `while` before reaching it, as block tail returns are not available in them.
870
869
self . tcx . hir ( ) . get_fn_id_for_return_block ( blk_id) . and_then ( |item_id| {
871
870
match self . tcx . hir_node ( item_id) {
872
871
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 ) ) ,
883
874
Node :: TraitItem ( & hir:: TraitItem {
884
875
kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
885
876
owner_id,
886
877
..
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 ) ) ,
889
879
Node :: ImplItem ( & hir:: ImplItem {
890
880
kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
891
881
owner_id,
892
882
..
893
- } ) => Some ( ( owner_id. def_id , sig. decl , false ) ) ,
883
+ } ) => Some ( ( owner_id. def_id , sig. decl ) ) ,
894
884
Node :: Expr ( & hir:: Expr {
895
885
hir_id,
896
886
kind : hir:: ExprKind :: Closure ( & hir:: Closure { def_id, kind, fn_decl, .. } ) ,
@@ -901,33 +891,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
901
891
// FIXME(async_closures): Implement this.
902
892
return None ;
903
893
}
904
- hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl, true ) ) ,
894
+ hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl) ) ,
905
895
hir:: ClosureKind :: Coroutine ( hir:: CoroutineKind :: Desugared (
906
896
_,
907
897
hir:: CoroutineSource :: Fn ,
908
898
) ) => {
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) {
910
900
Node :: Item ( & hir:: Item {
911
- ident,
912
901
kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
913
902
owner_id,
914
903
..
915
- } ) => ( ident , sig, owner_id) ,
904
+ } ) => ( sig, owner_id) ,
916
905
Node :: TraitItem ( & hir:: TraitItem {
917
- ident,
918
906
kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
919
907
owner_id,
920
908
..
921
- } ) => ( ident , sig, owner_id) ,
909
+ } ) => ( sig, owner_id) ,
922
910
Node :: ImplItem ( & hir:: ImplItem {
923
- ident,
924
911
kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
925
912
owner_id,
926
913
..
927
- } ) => ( ident , sig, owner_id) ,
914
+ } ) => ( sig, owner_id) ,
928
915
_ => return None ,
929
916
} ;
930
- Some ( ( owner_id. def_id , sig. decl , ident . name != sym :: main ) )
917
+ Some ( ( owner_id. def_id , sig. decl ) )
931
918
}
932
919
_ => None ,
933
920
}
0 commit comments