Skip to content

Commit c166ee1

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rustup
2 parents 2285535 + b829d53 commit c166ee1

File tree

101 files changed

+1201
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1201
-308
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6071,6 +6071,7 @@ Released 2018-09-13
60716071
[`unnecessary_literal_bound`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_bound
60726072
[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
60736073
[`unnecessary_map_on_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_on_constructor
6074+
[`unnecessary_map_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
60746075
[`unnecessary_min_or_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_or_max
60756076
[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
60766077
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,10 @@ harness = false
6969
[[test]]
7070
name = "dogfood"
7171
harness = false
72+
73+
# quine-mc_cluskey makes up a significant part of the runtime in dogfood
74+
# due to the number of conditions in the clippy_lints crate
75+
# and enabling optimizations for that specific dependency helps a bit
76+
# without increasing total build times.
77+
[profile.dev.package.quine-mc_cluskey]
78+
opt-level = 3

clippy_dev/src/new_lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
470470
});
471471

472472
// Find both the last lint declaration (declare_clippy_lint!) and the lint pass impl
473-
while let Some(LintDeclSearchResult { content, .. }) = iter.find(|result| result.token == TokenKind::Ident) {
473+
while let Some(LintDeclSearchResult { content, .. }) = iter.find(|result| result.token_kind == TokenKind::Ident) {
474474
let mut iter = iter
475475
.by_ref()
476476
.filter(|t| !matches!(t.token_kind, TokenKind::Whitespace | TokenKind::LineComment { .. }));
@@ -480,7 +480,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
480480
// matches `!{`
481481
match_tokens!(iter, Bang OpenBrace);
482482
if let Some(LintDeclSearchResult { range, .. }) =
483-
iter.find(|result| result.token == TokenKind::CloseBrace)
483+
iter.find(|result| result.token_kind == TokenKind::CloseBrace)
484484
{
485485
last_decl_curly_offset = Some(range.end);
486486
}

clippy_dev/src/setup/vscode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn delete_vs_task_file(path: &Path) -> bool {
8484
/// It may fail silently.
8585
fn try_delete_vs_directory_if_empty() {
8686
let path = Path::new(VSCODE_DIR);
87-
if path.read_dir().map_or(false, |mut iter| iter.next().is_none()) {
87+
if path.read_dir().is_ok_and(|mut iter| iter.next().is_none()) {
8888
// The directory is empty. We just try to delete it but allow a silence
8989
// fail as an empty `.vscode` directory is still valid
9090
let _silence_result = fs::remove_dir(path);

clippy_lints/src/attrs/useless_attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, item: &Item, attrs: &[Attribute]) {
1616
return;
1717
}
1818
if let Some(lint_list) = &attr.meta_item_list() {
19-
if attr.ident().map_or(false, |ident| is_lint_level(ident.name, attr.id)) {
19+
if attr.ident().is_some_and(|ident| is_lint_level(ident.name, attr.id)) {
2020
for lint in lint_list {
2121
match item.kind {
2222
ItemKind::Use(..) => {

clippy_lints/src/attrs/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
5050
block
5151
.expr
5252
.as_ref()
53-
.map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
53+
.is_some_and(|e| is_relevant_expr(cx, typeck_results, e)),
5454
|stmt| match &stmt.kind {
5555
StmtKind::Let(_) => true,
5656
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
@@ -60,7 +60,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
6060
}
6161

6262
fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool {
63-
if macro_backtrace(expr.span).last().map_or(false, |macro_call| {
63+
if macro_backtrace(expr.span).last().is_some_and(|macro_call| {
6464
is_panic(cx, macro_call.def_id) || cx.tcx.item_name(macro_call.def_id) == sym::unreachable
6565
}) {
6666
return false;

clippy_lints/src/bool_assert_comparison.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
6060
trait_id,
6161
)
6262
})
63-
.map_or(false, |assoc_item| {
64-
let proj = Ty::new_projection_from_args(cx.tcx, assoc_item.def_id, cx.tcx.mk_args_trait(ty, []));
63+
.is_some_and(|assoc_item| {
64+
let proj = Ty::new_projection(cx.tcx, assoc_item.def_id, cx.tcx.mk_args_trait(ty, []));
6565
let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj);
6666

6767
nty.is_bool()

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,5 +667,5 @@ fn implements_ord(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
667667
let ty = cx.typeck_results().expr_ty(expr);
668668
cx.tcx
669669
.get_diagnostic_item(sym::Ord)
670-
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
670+
.is_some_and(|id| implements_trait(cx, ty, id, &[]))
671671
}

clippy_lints/src/box_default.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl LateLintPass<'_> for BoxDefault {
4545
// And that method is `new`
4646
&& seg.ident.name == sym::new
4747
// And the call is that of a `Box` method
48-
&& path_def_id(cx, ty).map_or(false, |id| Some(id) == cx.tcx.lang_items().owned_box())
48+
&& path_def_id(cx, ty).is_some_and(|id| Some(id) == cx.tcx.lang_items().owned_box())
4949
// And the single argument to the call is another function call
5050
// This is the `T::default()` (or default equivalent) of `Box::new(T::default())`
5151
&& let ExprKind::Call(arg_path, _) = arg.kind
@@ -83,9 +83,9 @@ fn is_plain_default(cx: &LateContext<'_>, arg_path: &Expr<'_>) -> bool {
8383
}
8484

8585
fn is_local_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>, ref_expr: &Expr<'_>) -> bool {
86-
macro_backtrace(expr.span).next().map_or(false, |call| {
87-
cx.tcx.is_diagnostic_item(sym::vec_macro, call.def_id) && call.span.eq_ctxt(ref_expr.span)
88-
})
86+
macro_backtrace(expr.span)
87+
.next()
88+
.is_some_and(|call| cx.tcx.is_diagnostic_item(sym::vec_macro, call.def_id) && call.span.eq_ctxt(ref_expr.span))
8989
}
9090

9191
#[derive(Default)]

clippy_lints/src/casts/unnecessary_cast.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ pub(super) fn check<'tcx>(
159159
// The same is true if the expression encompassing the cast expression is a unary
160160
// expression or an addressof expression.
161161
let needs_block = matches!(cast_expr.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..))
162-
|| get_parent_expr(cx, expr)
163-
.map_or(false, |e| matches!(e.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..)));
162+
|| get_parent_expr(cx, expr).is_some_and(|e| matches!(e.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..)));
164163

165164
span_lint_and_sugg(
166165
cx,

0 commit comments

Comments
 (0)