Skip to content

Commit

Permalink
Unrolled build for rust-lang#118253
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#118253 - dtolnay:issomeand, r=compiler-errors

Replace `option.map(cond) == Some(true)` with `option.is_some_and(cond)`

Requested by `@fmease` in rust-lang#118226 (review).

There is also a much larger number of `option.map_or(false, cond)` that can be changed separately if someone wants.

r? fmease
  • Loading branch information
rust-timer authored Nov 25, 2023
2 parents fad6bb8 + 8cc7073 commit 76c187a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/scripts/rustc-clif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/scripts/rustdoc-clif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
16 changes: 6 additions & 10 deletions compiler/rustc_lint/src/non_fmt_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 76c187a

Please sign in to comment.