mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Run rustfmt
This commit is contained in:
parent
c775856727
commit
a433d4690e
@ -1,7 +1,4 @@
|
|||||||
use crate::utils::{
|
use crate::utils::{is_type_diagnostic_item, match_qpath, paths, return_ty, snippet, span_lint_and_then};
|
||||||
is_type_diagnostic_item, match_qpath, paths, return_ty, snippet,
|
|
||||||
span_lint_and_then,
|
|
||||||
};
|
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::intravisit::{FnKind, Visitor};
|
use rustc_hir::intravisit::{FnKind, Visitor};
|
||||||
@ -104,17 +101,20 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWrap {
|
|||||||
move |diag| {
|
move |diag| {
|
||||||
diag.multipart_suggestion(
|
diag.multipart_suggestion(
|
||||||
"factor this out to",
|
"factor this out to",
|
||||||
suggs.into_iter().chain({
|
suggs
|
||||||
let inner_ty = return_ty(cx, hir_id)
|
.into_iter()
|
||||||
.walk()
|
.chain({
|
||||||
.skip(1) // skip `std::option::Option` or `std::result::Result`
|
let inner_ty = return_ty(cx, hir_id)
|
||||||
.take(1) // take the first outermost inner type
|
.walk()
|
||||||
.filter_map(|inner| match inner.unpack() {
|
.skip(1) // skip `std::option::Option` or `std::result::Result`
|
||||||
GenericArgKind::Type(inner_ty) => Some(inner_ty.to_string()),
|
.take(1) // take the first outermost inner type
|
||||||
_ => None,
|
.filter_map(|inner| match inner.unpack() {
|
||||||
});
|
GenericArgKind::Type(inner_ty) => Some(inner_ty.to_string()),
|
||||||
inner_ty.map(|inner_ty| (fn_decl.output.span(), inner_ty))
|
_ => None,
|
||||||
}).collect(),
|
});
|
||||||
|
inner_ty.map(|inner_ty| (fn_decl.output.span(), inner_ty))
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user