use and_then/flat_map for map().flatten()
This commit is contained in:
parent
ac229c2819
commit
5a07e33d2c
5 changed files with 7 additions and 10 deletions
|
@ -378,8 +378,7 @@ pub(crate) fn get_dllimport<'tcx>(
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Option<&'tcx DllImport> {
|
) -> Option<&'tcx DllImport> {
|
||||||
tcx.native_library(id)
|
tcx.native_library(id)
|
||||||
.map(|lib| lib.dll_imports.iter().find(|di| di.name.as_str() == name))
|
.and_then(|lib| lib.dll_imports.iter().find(|di| di.name.as_str() == name))
|
||||||
.flatten()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_mingw_gnu_toolchain(target: &Target) -> bool {
|
pub(crate) fn is_mingw_gnu_toolchain(target: &Target) -> bool {
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl<'tcx> ValTree<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64> {
|
pub fn try_to_target_usize(self, tcx: TyCtxt<'tcx>) -> Option<u64> {
|
||||||
self.try_to_scalar_int().map(|s| s.try_to_target_usize(tcx).ok()).flatten()
|
self.try_to_scalar_int().and_then(|s| s.try_to_target_usize(tcx).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the values inside the ValTree as a slice of bytes. This only works for
|
/// Get the values inside the ValTree as a slice of bytes. This only works for
|
||||||
|
|
|
@ -62,21 +62,21 @@ pub fn as_constant_inner<'tcx>(
|
||||||
Constant { span, user_ty: None, literal }
|
Constant { span, user_ty: None, literal }
|
||||||
}
|
}
|
||||||
ExprKind::NonHirLiteral { lit, ref user_ty } => {
|
ExprKind::NonHirLiteral { lit, ref user_ty } => {
|
||||||
let user_ty = user_ty.as_ref().map(push_cuta).flatten();
|
let user_ty = user_ty.as_ref().and_then(push_cuta);
|
||||||
|
|
||||||
let literal = ConstantKind::Val(ConstValue::Scalar(Scalar::Int(lit)), ty);
|
let literal = ConstantKind::Val(ConstValue::Scalar(Scalar::Int(lit)), ty);
|
||||||
|
|
||||||
Constant { span, user_ty, literal }
|
Constant { span, user_ty, literal }
|
||||||
}
|
}
|
||||||
ExprKind::ZstLiteral { ref user_ty } => {
|
ExprKind::ZstLiteral { ref user_ty } => {
|
||||||
let user_ty = user_ty.as_ref().map(push_cuta).flatten();
|
let user_ty = user_ty.as_ref().and_then(push_cuta);
|
||||||
|
|
||||||
let literal = ConstantKind::Val(ConstValue::ZeroSized, ty);
|
let literal = ConstantKind::Val(ConstValue::ZeroSized, ty);
|
||||||
|
|
||||||
Constant { span, user_ty, literal }
|
Constant { span, user_ty, literal }
|
||||||
}
|
}
|
||||||
ExprKind::NamedConst { def_id, substs, ref user_ty } => {
|
ExprKind::NamedConst { def_id, substs, ref user_ty } => {
|
||||||
let user_ty = user_ty.as_ref().map(push_cuta).flatten();
|
let user_ty = user_ty.as_ref().and_then(push_cuta);
|
||||||
|
|
||||||
let uneval = mir::UnevaluatedConst::new(ty::WithOptConstParam::unknown(def_id), substs);
|
let uneval = mir::UnevaluatedConst::new(ty::WithOptConstParam::unknown(def_id), substs);
|
||||||
let literal = ConstantKind::Unevaluated(uneval, ty);
|
let literal = ConstantKind::Unevaluated(uneval, ty);
|
||||||
|
|
|
@ -911,7 +911,7 @@ mod parse {
|
||||||
let mut seen_instruction_threshold = false;
|
let mut seen_instruction_threshold = false;
|
||||||
let mut seen_skip_entry = false;
|
let mut seen_skip_entry = false;
|
||||||
let mut seen_skip_exit = false;
|
let mut seen_skip_exit = false;
|
||||||
for option in v.into_iter().map(|v| v.split(',')).flatten() {
|
for option in v.into_iter().flat_map(|v| v.split(',')) {
|
||||||
match option {
|
match option {
|
||||||
"always" if !seen_always && !seen_never => {
|
"always" if !seen_always && !seen_never => {
|
||||||
options.always = true;
|
options.always = true;
|
||||||
|
|
|
@ -110,8 +110,6 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
|
||||||
body_id: LocalDefId,
|
body_id: LocalDefId,
|
||||||
tys: FxIndexSet<Ty<'tcx>>,
|
tys: FxIndexSet<Ty<'tcx>>,
|
||||||
) -> Bounds<'a, 'tcx> {
|
) -> Bounds<'a, 'tcx> {
|
||||||
tys.into_iter()
|
tys.into_iter().flat_map(move |ty| self.implied_outlives_bounds(param_env, body_id, ty))
|
||||||
.map(move |ty| self.implied_outlives_bounds(param_env, body_id, ty))
|
|
||||||
.flatten()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue