Use Option::is_some_and
and Result::is_ok_and
in the compiler
This commit is contained in:
parent
70db836922
commit
fb0f74a8c9
87 changed files with 148 additions and 158 deletions
|
@ -961,7 +961,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
|
|||
Some(sugared_span.map_or(attr.span, |span| span.with_hi(attr.span.hi())));
|
||||
}
|
||||
|
||||
if attrs.peek().map_or(false, |next_attr| next_attr.is_doc_comment()) {
|
||||
if attrs.peek().is_some_and(|next_attr| next_attr.is_doc_comment()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
|
|||
// No clue where this argument is coming from.
|
||||
return lint;
|
||||
}
|
||||
if arg_macro.map_or(false, |id| cx.tcx.is_diagnostic_item(sym::format_macro, id)) {
|
||||
if arg_macro.is_some_and(|id| cx.tcx.is_diagnostic_item(sym::format_macro, id)) {
|
||||
// A case of `panic!(format!(..))`.
|
||||
lint.note(fluent::lint_supports_fmt_note);
|
||||
if let Some((open, close, _)) = find_delimiters(cx, arg_span) {
|
||||
|
|
|
@ -677,7 +677,7 @@ pub fn transparent_newtype_field<'a, 'tcx>(
|
|||
let param_env = tcx.param_env(variant.def_id);
|
||||
variant.fields.iter().find(|field| {
|
||||
let field_ty = tcx.type_of(field.did).subst_identity();
|
||||
let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst());
|
||||
let is_zst = tcx.layout_of(param_env.and(field_ty)).is_ok_and(|layout| layout.is_zst());
|
||||
!is_zst
|
||||
})
|
||||
}
|
||||
|
|
|
@ -664,8 +664,8 @@ trait UnusedDelimLint {
|
|||
_ => return,
|
||||
};
|
||||
let keep_space = (
|
||||
left_pos.map_or(false, |s| s >= value.span.lo()),
|
||||
right_pos.map_or(false, |s| s <= value.span.hi()),
|
||||
left_pos.is_some_and(|s| s >= value.span.lo()),
|
||||
right_pos.is_some_and(|s| s <= value.span.hi()),
|
||||
);
|
||||
self.emit_unused_delims(cx, value.span, spans, ctx.into(), keep_space);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue