@@ -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 _;
@@ -865,84 +865,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
865865 )
866866 }
867867
868- /// Given a `HirId`, return the `HirId` of the enclosing function, its `FnDecl`, and whether a
869- /// suggestion can be made, `None` otherwise.
870- pub fn get_fn_decl (
871- & self ,
872- blk_id : HirId ,
873- ) -> Option < ( LocalDefId , & ' tcx hir:: FnDecl < ' tcx > , bool ) > {
874- // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
875- // `while` before reaching it, as block tail returns are not available in them.
876- self . tcx . hir ( ) . get_fn_id_for_return_block ( blk_id) . and_then ( |item_id| {
877- match self . tcx . hir_node ( item_id) {
878- Node :: Item ( & hir:: Item {
879- ident,
880- kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
881- owner_id,
882- ..
883- } ) => {
884- // This is less than ideal, it will not suggest a return type span on any
885- // method called `main`, regardless of whether it is actually the entry point,
886- // but it will still present it as the reason for the expected type.
887- Some ( ( owner_id. def_id , sig. decl , ident. name != sym:: main) )
888- }
889- Node :: TraitItem ( & hir:: TraitItem {
890- kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
891- owner_id,
892- ..
893- } ) => Some ( ( owner_id. def_id , sig. decl , true ) ) ,
894- // FIXME: Suggestable if this is not a trait implementation
895- Node :: ImplItem ( & hir:: ImplItem {
896- kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
897- owner_id,
898- ..
899- } ) => Some ( ( owner_id. def_id , sig. decl , false ) ) ,
900- Node :: Expr ( & hir:: Expr {
901- hir_id,
902- kind : hir:: ExprKind :: Closure ( & hir:: Closure { def_id, kind, fn_decl, .. } ) ,
903- ..
904- } ) => {
905- match kind {
906- hir:: ClosureKind :: CoroutineClosure ( _) => {
907- // FIXME(async_closures): Implement this.
908- return None ;
909- }
910- hir:: ClosureKind :: Closure => Some ( ( def_id, fn_decl, true ) ) ,
911- hir:: ClosureKind :: Coroutine ( hir:: CoroutineKind :: Desugared (
912- _,
913- hir:: CoroutineSource :: Fn ,
914- ) ) => {
915- let ( ident, sig, owner_id) = match self . tcx . parent_hir_node ( hir_id) {
916- Node :: Item ( & hir:: Item {
917- ident,
918- kind : hir:: ItemKind :: Fn ( ref sig, ..) ,
919- owner_id,
920- ..
921- } ) => ( ident, sig, owner_id) ,
922- Node :: TraitItem ( & hir:: TraitItem {
923- ident,
924- kind : hir:: TraitItemKind :: Fn ( ref sig, ..) ,
925- owner_id,
926- ..
927- } ) => ( ident, sig, owner_id) ,
928- Node :: ImplItem ( & hir:: ImplItem {
929- ident,
930- kind : hir:: ImplItemKind :: Fn ( ref sig, ..) ,
931- owner_id,
932- ..
933- } ) => ( ident, sig, owner_id) ,
934- _ => return None ,
935- } ;
936- Some ( ( owner_id. def_id , sig. decl , ident. name != sym:: main) )
937- }
938- _ => None ,
939- }
940- }
941- _ => None ,
942- }
943- } )
944- }
945-
946868 pub ( crate ) fn note_internal_mutation_in_method (
947869 & self ,
948870 err : & mut Diag < ' _ > ,
0 commit comments