@@ -3,9 +3,7 @@ use std::{fmt, iter, mem};
33use  itertools:: Itertools ; 
44use  rustc_data_structures:: fx:: FxIndexSet ; 
55use  rustc_errors:: codes:: * ; 
6- use  rustc_errors:: { 
7-     Applicability ,  Diag ,  ErrorGuaranteed ,  MultiSpan ,  StashKey ,  a_or_an,  listify,  pluralize, 
8- } ; 
6+ use  rustc_errors:: { Applicability ,  Diag ,  ErrorGuaranteed ,  MultiSpan ,  a_or_an,  listify,  pluralize} ; 
97use  rustc_hir:: def:: { CtorOf ,  DefKind ,  Res } ; 
108use  rustc_hir:: def_id:: DefId ; 
119use  rustc_hir:: intravisit:: Visitor ; 
@@ -2167,62 +2165,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21672165        } 
21682166    } 
21692167
2170-     pub ( super )  fn  collect_unused_stmts_for_coerce_return_ty ( 
2171-         & self , 
2172-         errors_causecode :  Vec < ( Span ,  ObligationCauseCode < ' tcx > ) > , 
2173-     )  { 
2174-         for  ( span,  code)  in  errors_causecode { 
2175-             self . dcx ( ) . try_steal_modify_and_emit_err ( span,  StashKey :: MaybeForgetReturn ,  |err| { 
2176-                 if  let  Some ( fn_sig)  = self . body_fn_sig ( ) 
2177-                     && let  ObligationCauseCode :: WhereClauseInExpr ( _,  _,  binding_hir_id,  ..)  = code
2178-                     && !fn_sig. output ( ) . is_unit ( ) 
2179-                 { 
2180-                     let  mut  block_num = 0 ; 
2181-                     let  mut  found_semi = false ; 
2182-                     for  ( hir_id,  node)  in  self . tcx . hir_parent_iter ( binding_hir_id)  { 
2183-                         // Don't proceed into parent bodies 
2184-                         if  hir_id. owner  != binding_hir_id. owner  { 
2185-                             break ; 
2186-                         } 
2187-                         match  node { 
2188-                             hir:: Node :: Stmt ( stmt)  => { 
2189-                                 if  let  hir:: StmtKind :: Semi ( expr)  = stmt. kind  { 
2190-                                     let  expr_ty = self . typeck_results . borrow ( ) . expr_ty ( expr) ; 
2191-                                     let  return_ty = fn_sig. output ( ) ; 
2192-                                     if  !matches ! ( expr. kind,  hir:: ExprKind :: Ret ( ..) ) 
2193-                                         && self . may_coerce ( expr_ty,  return_ty) 
2194-                                     { 
2195-                                         found_semi = true ; 
2196-                                     } 
2197-                                 } 
2198-                             } 
2199-                             hir:: Node :: Block ( _block)  => { 
2200-                                 if  found_semi { 
2201-                                     block_num += 1 ; 
2202-                                 } 
2203-                             } 
2204-                             hir:: Node :: Item ( item)  => { 
2205-                                 if  let  hir:: ItemKind :: Fn  {  .. }  = item. kind  { 
2206-                                     break ; 
2207-                                 } 
2208-                             } 
2209-                             _ => { } 
2210-                         } 
2211-                     } 
2212-                     if  block_num > 1  && found_semi { 
2213-                         err. span_suggestion_verbose ( 
2214-                             // use the span of the *whole* expr 
2215-                             self . tcx . hir ( ) . span ( binding_hir_id) . shrink_to_lo ( ) , 
2216-                             "you might have meant to return this to infer its type parameters" , 
2217-                             "return " , 
2218-                             Applicability :: MaybeIncorrect , 
2219-                         ) ; 
2220-                     } 
2221-                 } 
2222-             } ) ; 
2223-         } 
2224-     } 
2225- 
22262168    /// Given a vector of fulfillment errors, try to adjust the spans of the 
22272169/// errors to more accurately point at the cause of the failure. 
22282170/// 
0 commit comments