@@ -45,7 +45,7 @@ use rustc_hir::intravisit::{self, Visitor};
45
45
use rustc_hir:: Expr ;
46
46
use rustc_hir_analysis:: astconv:: AstConv ;
47
47
use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
48
- use rustc_infer:: infer:: { Coercion , InferOk , InferResult , TyCtxtInferExt } ;
48
+ use rustc_infer:: infer:: { Coercion , InferOk , InferResult } ;
49
49
use rustc_infer:: traits:: Obligation ;
50
50
use rustc_middle:: lint:: in_external_macro;
51
51
use rustc_middle:: ty:: adjustment:: {
@@ -1565,9 +1565,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1565
1565
&& let hir:: ExprKind :: Loop ( loop_blk, ..) = expression. kind {
1566
1566
intravisit:: walk_block ( & mut visitor, loop_blk) ;
1567
1567
}
1568
- if let Some ( expr) = expression {
1569
- self . note_result_coercion ( fcx, & mut err, expr, expected, found) ;
1570
- }
1571
1568
}
1572
1569
ObligationCauseCode :: ReturnValue ( id) => {
1573
1570
err = self . report_return_mismatched_types (
@@ -1584,9 +1581,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1584
1581
let id = fcx. tcx . hir ( ) . parent_id ( id) ;
1585
1582
unsized_return = self . is_return_ty_unsized ( fcx, id) ;
1586
1583
}
1587
- if let Some ( expr) = expression {
1588
- self . note_result_coercion ( fcx, & mut err, expr, expected, found) ;
1589
- }
1590
1584
}
1591
1585
_ => {
1592
1586
err = fcx. err_ctxt ( ) . report_mismatched_types (
@@ -1626,44 +1620,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1626
1620
}
1627
1621
}
1628
1622
1629
- fn note_result_coercion (
1630
- & self ,
1631
- fcx : & FnCtxt < ' _ , ' tcx > ,
1632
- err : & mut Diagnostic ,
1633
- expr : & hir:: Expr < ' tcx > ,
1634
- expected : Ty < ' tcx > ,
1635
- found : Ty < ' tcx > ,
1636
- ) {
1637
- let ty:: Adt ( e, substs_e) = expected. kind ( ) else { return ; } ;
1638
- let ty:: Adt ( f, substs_f) = found. kind ( ) else { return ; } ;
1639
- if e. did ( ) != f. did ( ) {
1640
- return ;
1641
- }
1642
- if Some ( e. did ( ) ) != fcx. tcx . get_diagnostic_item ( sym:: Result ) {
1643
- return ;
1644
- }
1645
- let e = substs_e. type_at ( 1 ) ;
1646
- let f = substs_f. type_at ( 1 ) ;
1647
- if fcx
1648
- . infcx
1649
- . type_implements_trait (
1650
- fcx. tcx . get_diagnostic_item ( sym:: Into ) . unwrap ( ) ,
1651
- [ fcx. tcx . erase_regions ( f) , fcx. tcx . erase_regions ( e) ] ,
1652
- fcx. param_env ,
1653
- )
1654
- . must_apply_modulo_regions ( )
1655
- {
1656
- err. multipart_suggestion (
1657
- "you can rely on the implicit conversion that `?` does to transform the error type" ,
1658
- vec ! [
1659
- ( expr. span. shrink_to_lo( ) , "Ok(" . to_string( ) ) ,
1660
- ( expr. span. shrink_to_hi( ) , "?)" . to_string( ) ) ,
1661
- ] ,
1662
- Applicability :: MaybeIncorrect ,
1663
- ) ;
1664
- }
1665
- }
1666
-
1667
1623
fn note_unreachable_loop_return (
1668
1624
& self ,
1669
1625
err : & mut Diagnostic ,
0 commit comments