mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Use .map() to modify data inside Options instead of using .and_then(|x| Some(y)) (clippy::option_and_then_some)
This commit is contained in:
parent
07168f9cdc
commit
569676b9b0
@ -415,9 +415,9 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
|
||||
super::ReferenceOutlivesReferent(ty) => {
|
||||
tcx.lift(&ty).map(super::ReferenceOutlivesReferent)
|
||||
}
|
||||
super::ObjectTypeBound(ty, r) => tcx
|
||||
.lift(&ty)
|
||||
.and_then(|ty| tcx.lift(&r).and_then(|r| Some(super::ObjectTypeBound(ty, r)))),
|
||||
super::ObjectTypeBound(ty, r) => {
|
||||
tcx.lift(&ty).and_then(|ty| tcx.lift(&r).map(|r| super::ObjectTypeBound(ty, r)))
|
||||
}
|
||||
super::ObjectCastObligation(ty) => tcx.lift(&ty).map(super::ObjectCastObligation),
|
||||
super::Coercion { source, target } => {
|
||||
Some(super::Coercion { source: tcx.lift(&source)?, target: tcx.lift(&target)? })
|
||||
|
@ -37,7 +37,7 @@ impl<'a> Parser<'a> {
|
||||
let inner_parse_policy = InnerAttributeParsePolicy::NotPermitted {
|
||||
reason: inner_error_reason,
|
||||
saw_doc_comment: just_parsed_doc_comment,
|
||||
prev_attr_sp: attrs.last().and_then(|a| Some(a.span)),
|
||||
prev_attr_sp: attrs.last().map(|a| a.span),
|
||||
};
|
||||
let attr = self.parse_attribute_with_inner_parse_policy(inner_parse_policy)?;
|
||||
attrs.push(attr);
|
||||
|
@ -1551,21 +1551,18 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
|
||||
let method_names = pcx.candidate_method_names();
|
||||
pcx.allow_similar_names = false;
|
||||
let applicable_close_candidates: Vec<ty::AssocItem> =
|
||||
method_names
|
||||
.iter()
|
||||
.filter_map(|&method_name| {
|
||||
pcx.reset();
|
||||
pcx.method_name = Some(method_name);
|
||||
pcx.assemble_inherent_candidates();
|
||||
pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)
|
||||
.map_or(None, |_| {
|
||||
pcx.pick_core()
|
||||
.and_then(|pick| pick.ok())
|
||||
.and_then(|pick| Some(pick.item))
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let applicable_close_candidates: Vec<ty::AssocItem> = method_names
|
||||
.iter()
|
||||
.filter_map(|&method_name| {
|
||||
pcx.reset();
|
||||
pcx.method_name = Some(method_name);
|
||||
pcx.assemble_inherent_candidates();
|
||||
pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)
|
||||
.map_or(None, |_| {
|
||||
pcx.pick_core().and_then(|pick| pick.ok()).map(|pick| pick.item)
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
if applicable_close_candidates.is_empty() {
|
||||
Ok(None)
|
||||
|
@ -121,9 +121,7 @@ pub fn external_generic_args(
|
||||
let args: Vec<_> = substs
|
||||
.iter()
|
||||
.filter_map(|kind| match kind.unpack() {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
lt.clean(cx).and_then(|lt| Some(GenericArg::Lifetime(lt)))
|
||||
}
|
||||
GenericArgKind::Lifetime(lt) => lt.clean(cx).map(|lt| GenericArg::Lifetime(lt)),
|
||||
GenericArgKind::Type(_) if skip_self => {
|
||||
skip_self = false;
|
||||
None
|
||||
|
Loading…
Reference in New Issue
Block a user