|
36 | 36 | //! ```
|
37 | 37 |
|
38 | 38 | use crate::FnCtxt;
|
39 |
| -use rustc_errors::{ |
40 |
| - struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, |
41 |
| -}; |
| 39 | +use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan}; |
42 | 40 | use rustc_hir as hir;
|
43 | 41 | use rustc_hir::def_id::DefId;
|
44 | 42 | use rustc_hir::intravisit::{self, Visitor};
|
@@ -1740,7 +1738,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
1740 | 1738 | // label pointing out the cause for the type coercion will be wrong
|
1741 | 1739 | // as prior return coercions would not be relevant (#57664).
|
1742 | 1740 | let fn_decl = if let (Some(expr), Some(blk_id)) = (expression, blk_id) {
|
1743 |
| - self.explain_self_literal(fcx, &mut err, expr, expected, found); |
1744 | 1741 | let pointing_at_return_type =
|
1745 | 1742 | fcx.suggest_mismatched_types_on_tail(&mut err, expr, expected, found, blk_id);
|
1746 | 1743 | if let (Some(cond_expr), true, false) = (
|
@@ -1813,60 +1810,6 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
1813 | 1810 | err
|
1814 | 1811 | }
|
1815 | 1812 |
|
1816 |
| - fn explain_self_literal( |
1817 |
| - &self, |
1818 |
| - fcx: &FnCtxt<'_, 'tcx>, |
1819 |
| - err: &mut Diagnostic, |
1820 |
| - expr: &'tcx hir::Expr<'tcx>, |
1821 |
| - expected: Ty<'tcx>, |
1822 |
| - found: Ty<'tcx>, |
1823 |
| - ) { |
1824 |
| - match expr.peel_drop_temps().kind { |
1825 |
| - hir::ExprKind::Struct( |
1826 |
| - hir::QPath::Resolved( |
1827 |
| - None, |
1828 |
| - hir::Path { res: hir::def::Res::SelfTyAlias { alias_to, .. }, span, .. }, |
1829 |
| - ), |
1830 |
| - .., |
1831 |
| - ) |
1832 |
| - | hir::ExprKind::Call( |
1833 |
| - hir::Expr { |
1834 |
| - kind: |
1835 |
| - hir::ExprKind::Path(hir::QPath::Resolved( |
1836 |
| - None, |
1837 |
| - hir::Path { |
1838 |
| - res: hir::def::Res::SelfTyAlias { alias_to, .. }, |
1839 |
| - span, |
1840 |
| - .. |
1841 |
| - }, |
1842 |
| - )), |
1843 |
| - .. |
1844 |
| - }, |
1845 |
| - .., |
1846 |
| - ) => { |
1847 |
| - if let Some(hir::Node::Item(hir::Item { |
1848 |
| - kind: hir::ItemKind::Impl(hir::Impl { self_ty, .. }), |
1849 |
| - .. |
1850 |
| - })) = fcx.tcx.hir().get_if_local(*alias_to) |
1851 |
| - { |
1852 |
| - err.span_label(self_ty.span, "this is the type of the `Self` literal"); |
1853 |
| - } |
1854 |
| - if let ty::Adt(e_def, e_args) = expected.kind() |
1855 |
| - && let ty::Adt(f_def, _f_args) = found.kind() |
1856 |
| - && e_def == f_def |
1857 |
| - { |
1858 |
| - err.span_suggestion_verbose( |
1859 |
| - *span, |
1860 |
| - "use the type name directly", |
1861 |
| - fcx.tcx.value_path_str_with_args(*alias_to, e_args), |
1862 |
| - Applicability::MaybeIncorrect, |
1863 |
| - ); |
1864 |
| - } |
1865 |
| - } |
1866 |
| - _ => {} |
1867 |
| - } |
1868 |
| - } |
1869 |
| - |
1870 | 1813 | /// Checks whether the return type is unsized via an obligation, which makes
|
1871 | 1814 | /// sure we consider `dyn Trait: Sized` where clauses, which are trivially
|
1872 | 1815 | /// false but technically valid for typeck.
|
|
0 commit comments