@@ -9,7 +9,7 @@ use rustc_hir as hir;
99use rustc_hir:: def:: { CtorOf , DefKind , Res } ;
1010use rustc_hir:: def_id:: DefId ;
1111use rustc_hir:: lang_items:: LangItem ;
12- use rustc_hir:: { ExprKind , GenericArg , HirId , Node , QPath } ;
12+ use rustc_hir:: { ExprKind , GenericArg , HirId , QPath } ;
1313use rustc_hir_analysis:: hir_ty_lowering:: errors:: GenericsArgsErrExtend ;
1414use rustc_hir_analysis:: hir_ty_lowering:: generics:: {
1515 check_generic_arg_count_for_call, lower_generic_args,
@@ -34,7 +34,7 @@ use rustc_middle::{bug, span_bug};
3434use rustc_session:: lint;
3535use rustc_span:: def_id:: LocalDefId ;
3636use rustc_span:: hygiene:: DesugaringKind ;
37- use rustc_span:: symbol:: { kw , sym } ;
37+ use rustc_span:: symbol:: kw ;
3838use rustc_span:: Span ;
3939use rustc_target:: abi:: FieldIdx ;
4040use rustc_trait_selection:: traits:: error_reporting:: TypeErrCtxtExt as _;
@@ -870,84 +870,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
870870 )
871871 }
872872
873- /// Given a `HirId`, return the `HirId` of the enclosing function, its `FnDecl`, and whether a
874- /// suggestion can be made, `None` otherwise.
875- pub fn get_fn_decl (
876- & self ,
877- blk_id : HirId ,
878- ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > , bool ) > {
879- // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
880- // `while` before reaching it, as block tail returns are not available in them.
881- self . tcx . hir ( ) . get_fn_id_for_return_block ( blk_id) . and_then ( |item_id| {
882- match self . tcx . hir_node ( item_id) {
883- Node :: Item ( & hir:: Item {
884- ident,
885- kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
886- owner_id,
887- ..
888- } ) => {
889- // This is less than ideal, it will not suggest a return type span on any
890- // method called `main`, regardless of whether it is actually the entry point,
891- // but it will still present it as the reason for the expected type.
892- Some ( ( owner_id. def_id , sig. decl , ident. name != sym:: main) )
893- }
894- Node :: TraitItem ( & hir:: TraitItem {
895- kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
896- owner_id,
897- ..
898- } ) => Some ( ( owner_id. def_id , sig. decl , true ) ) ,
899- // FIXME: Suggestable if this is not a trait implementation
900- Node :: ImplItem ( & hir:: ImplItem {
901- kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
902- owner_id,
903- ..
904- } ) => Some ( ( owner_id. def_id , sig. decl , false ) ) ,
905- Node :: Expr ( & hir:: Expr {
906- hir_id,
907- kind : hir:: ExprKind :: Closure ( & hir:: Closure { def_id, kind, fn_decl, .. } ) ,
908- ..
909- } ) => {
910- match kind {
911- hir:: ClosureKind :: CoroutineClosure ( _) => {
912- // FIXME(async_closures): Implement this.
913- return None ;
914- }
915- hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl, true ) ) ,
916- hir:: ClosureKind :: Coroutine ( hir:: CoroutineKind :: Desugared (
917- _,
918- hir:: CoroutineSource :: Fn ,
919- ) ) => {
920- let ( ident, sig, owner_id) = match self . tcx . parent_hir_node ( hir_id) {
921- Node :: Item ( & hir:: Item {
922- ident,
923- kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
924- owner_id,
925- ..
926- } ) => ( ident, sig, owner_id) ,
927- Node :: TraitItem ( & hir:: TraitItem {
928- ident,
929- kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
930- owner_id,
931- ..
932- } ) => ( ident, sig, owner_id) ,
933- Node :: ImplItem ( & hir:: ImplItem {
934- ident,
935- kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
936- owner_id,
937- ..
938- } ) => ( ident, sig, owner_id) ,
939- _ => return None ,
940- } ;
941- Some ( ( owner_id. def_id , sig. decl , ident. name != sym:: main) )
942- }
943- _ => None ,
944- }
945- }
946- _ => None ,
947- }
948- } )
949- }
950-
951873 pub ( crate ) fn note_internal_mutation_in_method (
952874 & self ,
953875 err : & mut Diag < ' _ > ,
0 commit comments