|
1 |
| -use crate::utils::{ |
2 |
| - is_type_diagnostic_item, match_qpath, paths, return_ty, snippet, |
3 |
| - span_lint_and_then, |
4 |
| -}; |
| 1 | +use crate::utils::{is_type_diagnostic_item, match_qpath, paths, return_ty, snippet, span_lint_and_then}; |
5 | 2 | use if_chain::if_chain;
|
6 | 3 | use rustc_errors::Applicability;
|
7 | 4 | use rustc_hir::intravisit::{FnKind, Visitor};
|
@@ -104,17 +101,20 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWrap {
|
104 | 101 | move |diag| {
|
105 | 102 | diag.multipart_suggestion(
|
106 | 103 | "factor this out to",
|
107 |
| - suggs.into_iter().chain({ |
108 |
| - let inner_ty = return_ty(cx, hir_id) |
109 |
| - .walk() |
110 |
| - .skip(1) // skip `std::option::Option` or `std::result::Result` |
111 |
| - .take(1) // take the first outermost inner type |
112 |
| - .filter_map(|inner| match inner.unpack() { |
113 |
| - GenericArgKind::Type(inner_ty) => Some(inner_ty.to_string()), |
114 |
| - _ => None, |
115 |
| - }); |
116 |
| - inner_ty.map(|inner_ty| (fn_decl.output.span(), inner_ty)) |
117 |
| - }).collect(), |
| 104 | + suggs |
| 105 | + .into_iter() |
| 106 | + .chain({ |
| 107 | + let inner_ty = return_ty(cx, hir_id) |
| 108 | + .walk() |
| 109 | + .skip(1) // skip `std::option::Option` or `std::result::Result` |
| 110 | + .take(1) // take the first outermost inner type |
| 111 | + .filter_map(|inner| match inner.unpack() { |
| 112 | + GenericArgKind::Type(inner_ty) => Some(inner_ty.to_string()), |
| 113 | + _ => None, |
| 114 | + }); |
| 115 | + inner_ty.map(|inner_ty| (fn_decl.output.span(), inner_ty)) |
| 116 | + }) |
| 117 | + .collect(), |
118 | 118 | Applicability::MachineApplicable,
|
119 | 119 | );
|
120 | 120 | },
|
|
0 commit comments