Replace option.map(cond) == Some(true)
with option.is_some_and(cond)
This commit is contained in:
parent
beebcdeb6f
commit
8cc7073d64
@ -27,7 +27,7 @@ fn main() {
|
||||
args.push(codegen_backend_arg);
|
||||
}
|
||||
if !passed_args.iter().any(|arg| {
|
||||
arg == "--sysroot" || arg.to_str().map(|s| s.starts_with("--sysroot=")) == Some(true)
|
||||
arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot="))
|
||||
}) {
|
||||
args.push(OsString::from("--sysroot"));
|
||||
args.push(OsString::from(sysroot.to_str().unwrap()));
|
||||
|
@ -27,7 +27,7 @@ fn main() {
|
||||
args.push(codegen_backend_arg);
|
||||
}
|
||||
if !passed_args.iter().any(|arg| {
|
||||
arg == "--sysroot" || arg.to_str().map(|s| s.starts_with("--sysroot=")) == Some(true)
|
||||
arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot="))
|
||||
}) {
|
||||
args.push(OsString::from("--sysroot"));
|
||||
args.push(OsString::from(sysroot.to_str().unwrap()));
|
||||
|
@ -135,7 +135,7 @@ pub(crate) fn matches_codepattern(a: &str, b: &str) -> bool {
|
||||
|
||||
/// Advances the given peekable `Iterator` until it reaches a non-whitespace character.
|
||||
fn scan_for_non_ws_or_end<I: Iterator<Item = char>>(iter: &mut Peekable<I>) {
|
||||
while iter.peek().copied().map(rustc_lexer::is_whitespace) == Some(true) {
|
||||
while iter.peek().copied().is_some_and(rustc_lexer::is_whitespace) {
|
||||
iter.next();
|
||||
}
|
||||
}
|
||||
|
@ -2293,12 +2293,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let clone_trait =
|
||||
self.tcx.require_lang_item(LangItem::Clone, Some(segment.ident.span));
|
||||
if args.is_empty()
|
||||
&& self.typeck_results.borrow().type_dependent_def_id(expr.hir_id).map(
|
||||
|did| {
|
||||
&& self
|
||||
.typeck_results
|
||||
.borrow()
|
||||
.type_dependent_def_id(expr.hir_id)
|
||||
.is_some_and(|did| {
|
||||
let ai = self.tcx.associated_item(did);
|
||||
ai.trait_container(self.tcx) == Some(clone_trait)
|
||||
},
|
||||
) == Some(true)
|
||||
})
|
||||
&& segment.ident.name == sym::clone
|
||||
{
|
||||
// If this expression had a clone call when suggesting borrowing
|
||||
|
@ -161,7 +161,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
&& self
|
||||
.tcx()
|
||||
.opt_associated_item(scope_def_id.to_def_id())
|
||||
.map(|i| i.fn_has_self_parameter)
|
||||
== Some(true)
|
||||
.is_some_and(|i| i.fn_has_self_parameter)
|
||||
}
|
||||
}
|
||||
|
@ -154,17 +154,13 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
|
||||
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let suggest_display = is_str
|
||||
|| cx
|
||||
.tcx
|
||||
.get_diagnostic_item(sym::Display)
|
||||
.map(|t| infcx.type_implements_trait(t, [ty], cx.param_env).may_apply())
|
||||
== Some(true);
|
||||
|| cx.tcx.get_diagnostic_item(sym::Display).is_some_and(|t| {
|
||||
infcx.type_implements_trait(t, [ty], cx.param_env).may_apply()
|
||||
});
|
||||
let suggest_debug = !suggest_display
|
||||
&& cx
|
||||
.tcx
|
||||
.get_diagnostic_item(sym::Debug)
|
||||
.map(|t| infcx.type_implements_trait(t, [ty], cx.param_env).may_apply())
|
||||
== Some(true);
|
||||
&& cx.tcx.get_diagnostic_item(sym::Debug).is_some_and(|t| {
|
||||
infcx.type_implements_trait(t, [ty], cx.param_env).may_apply()
|
||||
});
|
||||
|
||||
let suggest_panic_any = !is_str && panic == sym::std_panic_macro;
|
||||
|
||||
|
@ -596,8 +596,10 @@ fn extra_info_tags<'a, 'tcx: 'a>(
|
||||
|
||||
// The "rustc_private" crates are permanently unstable so it makes no sense
|
||||
// to render "unstable" everywhere.
|
||||
if item.stability(tcx).as_ref().map(|s| s.is_unstable() && s.feature != sym::rustc_private)
|
||||
== Some(true)
|
||||
if item
|
||||
.stability(tcx)
|
||||
.as_ref()
|
||||
.is_some_and(|s| s.is_unstable() && s.feature != sym::rustc_private)
|
||||
{
|
||||
write!(f, "{}", tag_html("unstable", "", "Experimental"))?;
|
||||
}
|
||||
|
@ -632,7 +632,7 @@ fn iter_header_extra(
|
||||
it(None, directive, 0);
|
||||
}
|
||||
|
||||
let comment = if testfile.extension().map(|e| e == "rs") == Some(true) { "//" } else { "#" };
|
||||
let comment = if testfile.extension().is_some_and(|e| e == "rs") { "//" } else { "#" };
|
||||
|
||||
let mut rdr = BufReader::new(rdr);
|
||||
let mut ln = String::new();
|
||||
|
Loading…
x
Reference in New Issue
Block a user