Skip to content

Rollup of 4 pull requests #133047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ad3f3c7
Skip locking span interner for some syntax context checks
Alexendoo Jul 25, 2024
6205bcf
Add match-based manual try to clippy::question_mark
GnomedDev Nov 1, 2024
139bb25
Avoid linting for closures with inferred return types
GnomedDev Nov 2, 2024
a0b7681
fix: `identity_op` suggestions use correct parenthesis
hcbarker Nov 3, 2024
6d738f6
Fix parens getting removed for non-associative operators
hcbarker Nov 3, 2024
1b7239d
Fixing a missed check for needs_parenthesis in division
hcbarker Nov 5, 2024
6ced8c3
Merge commit 'f712eb5cdccd121d0569af12f20e6a0fabe4364d' into clippy-s…
flip1995 Nov 7, 2024
ef0f1ca
Remove check for duplicate parenthesis
hcbarker Nov 8, 2024
c21c781
Clippy: cfg out validate_diag on release builds
flip1995 Nov 8, 2024
8cfb959
fix: `identity_op` suggestions use correct parenthesis (#13647)
Jarcho Nov 9, 2024
223bffd
Fix `large_include_file` lint being triggered all the time by doc com…
GuillaumeGomez Nov 9, 2024
4f0e46b
Fix `large_include_file` lint being triggered all the time by doc com…
Manishearth Nov 9, 2024
353f8e1
ensure that all publicly reachable const fn have const stability info
RalfJung Nov 2, 2024
f58088b
Add match-based manual try to clippy::question_mark (#13627)
y21 Nov 10, 2024
da93d78
Add Unicode block-drawing compiler output support
estebank Jun 17, 2024
e2962cc
Auto merge of #126597 - estebank:unicode-output, r=fmease
bors Nov 11, 2024
e5b1cae
Consolidate type system const evaluation under `traits::evaluate_const`
BoxyUwU Nov 12, 2024
2285535
Rollup merge of #132541 - RalfJung:const-stable-extern-crate, r=compi…
matthiaskrgr Nov 12, 2024
89210d7
new lint `unnecessary_map_or`
Jacherr Nov 9, 2023
b829d53
New lint: `unnecessary_map_or` (#11796)
Centri3 Nov 13, 2024
1d2f911
Fix handling of footnote reference in footnote definition
GuillaumeGomez Nov 14, 2024
052d40a
Add regression test for #131946
GuillaumeGomez Nov 14, 2024
c166ee1
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Nov 14, 2024
99ef369
Bump nightly version -> 2024-11-14
flip1995 Nov 14, 2024
786fbd6
Rustup (#13687)
flip1995 Nov 14, 2024
32500aa
rustdoc-search: case-sensitive only when capitals are used
notriddle Nov 14, 2024
35c3b25
Merge commit '786fbd6d683933cd0e567fdcd25d449a69b4320c' into clippy-s…
flip1995 Nov 14, 2024
e158303
Rollup merge of #128197 - Alexendoo:span-ctxt, r=davidtwco
matthiaskrgr Nov 14, 2024
dd61213
Rollup merge of #133040 - GuillaumeGomez:footnote-ref-in-def, r=notri…
matthiaskrgr Nov 14, 2024
8912909
Rollup merge of #133043 - notriddle:master, r=fmease
matthiaskrgr Nov 14, 2024
d6a9ded
Rollup merge of #133046 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,6 @@ impl Span {
!self.is_dummy() && sm.is_span_accessible(self)
}

/// Returns `true` if this span comes from any kind of macro, desugaring or inlining.
#[inline]
pub fn from_expansion(self) -> bool {
!self.ctxt().is_root()
}

/// Returns `true` if `span` originates in a derive-macro's expansion.
pub fn in_derive_expansion(self) -> bool {
matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _))
Expand Down
14 changes: 11 additions & 3 deletions compiler/rustc_span/src/span_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ impl Span {
}
}

/// Returns `true` if this span comes from any kind of macro, desugaring or inlining.
#[inline]
pub fn from_expansion(self) -> bool {
// If the span is fully inferred then ctxt > MAX_CTXT
self.inline_ctxt().map_or(true, |ctxt| !ctxt.is_root())
}

/// Returns `true` if this is a dummy span with any hygienic context.
#[inline]
pub fn is_dummy(self) -> bool {
Expand Down Expand Up @@ -370,9 +377,10 @@ impl Span {
pub fn eq_ctxt(self, other: Span) -> bool {
match (self.inline_ctxt(), other.inline_ctxt()) {
(Ok(ctxt1), Ok(ctxt2)) => ctxt1 == ctxt2,
(Ok(ctxt), Err(index)) | (Err(index), Ok(ctxt)) => {
with_span_interner(|interner| ctxt == interner.spans[index].ctxt)
}
// If `inline_ctxt` returns `Ok` the context is <= MAX_CTXT.
// If it returns `Err` the span is fully interned and the context is > MAX_CTXT.
// As these do not overlap an `Ok` and `Err` result cannot have an equal context.
(Ok(_), Err(_)) | (Err(_), Ok(_)) => false,
(Err(index1), Err(index2)) => with_span_interner(|interner| {
interner.spans[index1].ctxt == interner.spans[index2].ctxt
}),
Expand Down
60 changes: 34 additions & 26 deletions src/librustdoc/html/markdown/footnotes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Markdown footnote handling.
use std::fmt::Write as _;

use pulldown_cmark::{Event, Tag, TagEnd, html};
use pulldown_cmark::{CowStr, Event, Tag, TagEnd, html};
use rustc_data_structures::fx::FxIndexMap;

use super::SpannedEvent;
Expand All @@ -21,7 +21,7 @@ struct FootnoteDef<'a> {
id: usize,
}

impl<'a, 'b, I> Footnotes<'a, 'b, I> {
impl<'a, 'b, I: Iterator<Item = SpannedEvent<'a>>> Footnotes<'a, 'b, I> {
pub(super) fn new(iter: I, existing_footnotes: &'b mut usize) -> Self {
Footnotes { inner: iter, footnotes: FxIndexMap::default(), existing_footnotes }
}
Expand All @@ -34,31 +34,50 @@ impl<'a, 'b, I> Footnotes<'a, 'b, I> {
// Don't allow changing the ID of existing entrys, but allow changing the contents.
(content, *id)
}

fn handle_footnote_reference(&mut self, reference: &CowStr<'a>) -> Event<'a> {
// When we see a reference (to a footnote we may not know) the definition of,
// reserve a number for it, and emit a link to that number.
let (_, id) = self.get_entry(reference);
let reference = format!(
"<sup id=\"fnref{0}\"><a href=\"#fn{0}\">{1}</a></sup>",
id,
// Although the ID count is for the whole page, the footnote reference
// are local to the item so we make this ID "local" when displayed.
id - *self.existing_footnotes
);
Event::Html(reference.into())
}

fn collect_footnote_def(&mut self) -> Vec<Event<'a>> {
let mut content = Vec::new();
while let Some((event, _)) = self.inner.next() {
match event {
Event::End(TagEnd::FootnoteDefinition) => break,
Event::FootnoteReference(ref reference) => {
content.push(self.handle_footnote_reference(reference));
}
event => content.push(event),
}
}
content
}
}

impl<'a, 'b, I: Iterator<Item = SpannedEvent<'a>>> Iterator for Footnotes<'a, 'b, I> {
type Item = SpannedEvent<'a>;

fn next(&mut self) -> Option<Self::Item> {
loop {
match self.inner.next() {
let next = self.inner.next();
match next {
Some((Event::FootnoteReference(ref reference), range)) => {
// When we see a reference (to a footnote we may not know) the definition of,
// reserve a number for it, and emit a link to that number.
let (_, id) = self.get_entry(reference);
let reference = format!(
"<sup id=\"fnref{0}\"><a href=\"#fn{0}\">{1}</a></sup>",
id,
// Although the ID count is for the whole page, the footnote reference
// are local to the item so we make this ID "local" when displayed.
id - *self.existing_footnotes
);
return Some((Event::Html(reference.into()), range));
return Some((self.handle_footnote_reference(reference), range));
}
Some((Event::Start(Tag::FootnoteDefinition(def)), _)) => {
// When we see a footnote definition, collect the assocated content, and store
// that for rendering later.
let content = collect_footnote_def(&mut self.inner);
let content = self.collect_footnote_def();
let (entry_content, _) = self.get_entry(&def);
*entry_content = content;
}
Expand All @@ -80,17 +99,6 @@ impl<'a, 'b, I: Iterator<Item = SpannedEvent<'a>>> Iterator for Footnotes<'a, 'b
}
}

fn collect_footnote_def<'a>(events: impl Iterator<Item = SpannedEvent<'a>>) -> Vec<Event<'a>> {
let mut content = Vec::new();
for (event, _) in events {
if let Event::End(TagEnd::FootnoteDefinition) = event {
break;
}
content.push(event);
}
content
}

fn render_footnotes_defs(mut footnotes: Vec<FootnoteDef<'_>>) -> String {
let mut ret = String::from("<div class=\"footnotes\"><hr><ol>");

Expand Down
11 changes: 7 additions & 4 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,7 @@ class DocSearch {
const sortResults = async(results, typeInfo, preferredCrate) => {
const userQuery = parsedQuery.userQuery;
const normalizedUserQuery = parsedQuery.userQuery.toLowerCase();
const isMixedCase = normalizedUserQuery !== userQuery;
const result_list = [];
for (const result of results.values()) {
result.item = this.searchIndex[result.id];
Expand All @@ -2511,10 +2512,12 @@ class DocSearch {
let a, b;

// sort by exact case-sensitive match
a = (aaa.item.name !== userQuery);
b = (bbb.item.name !== userQuery);
if (a !== b) {
return a - b;
if (isMixedCase) {
a = (aaa.item.name !== userQuery);
b = (bbb.item.name !== userQuery);
if (a !== b) {
return a - b;
}
}

// sort by exact match with regard to the last word (mismatch goes later)
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6071,6 +6071,7 @@ Released 2018-09-13
[`unnecessary_literal_bound`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_bound
[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
[`unnecessary_map_on_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_on_constructor
[`unnecessary_map_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
[`unnecessary_min_or_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_or_max
[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_dev/src/setup/vscode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn delete_vs_task_file(path: &Path) -> bool {
/// It may fail silently.
fn try_delete_vs_directory_if_empty() {
let path = Path::new(VSCODE_DIR);
if path.read_dir().map_or(false, |mut iter| iter.next().is_none()) {
if path.read_dir().is_ok_and(|mut iter| iter.next().is_none()) {
// The directory is empty. We just try to delete it but allow a silence
// fail as an empty `.vscode` directory is still valid
let _silence_result = fs::remove_dir(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, item: &Item, attrs: &[Attribute]) {
return;
}
if let Some(lint_list) = &attr.meta_item_list() {
if attr.ident().map_or(false, |ident| is_lint_level(ident.name, attr.id)) {
if attr.ident().is_some_and(|ident| is_lint_level(ident.name, attr.id)) {
for lint in lint_list {
match item.kind {
ItemKind::Use(..) => {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/attrs/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
block
.expr
.as_ref()
.map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
.is_some_and(|e| is_relevant_expr(cx, typeck_results, e)),
|stmt| match &stmt.kind {
StmtKind::Let(_) => true,
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
Expand All @@ -60,7 +60,7 @@ fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_
}

fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool {
if macro_backtrace(expr.span).last().map_or(false, |macro_call| {
if macro_backtrace(expr.span).last().is_some_and(|macro_call| {
is_panic(cx, macro_call.def_id) || cx.tcx.item_name(macro_call.def_id) == sym::unreachable
}) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
trait_id,
)
})
.map_or(false, |assoc_item| {
let proj = Ty::new_projection_from_args(cx.tcx, assoc_item.def_id, cx.tcx.mk_args_trait(ty, []));
.is_some_and(|assoc_item| {
let proj = Ty::new_projection(cx.tcx, assoc_item.def_id, cx.tcx.mk_args_trait(ty, []));
let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj);

nty.is_bool()
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,5 +667,5 @@ fn implements_ord(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
let ty = cx.typeck_results().expr_ty(expr);
cx.tcx
.get_diagnostic_item(sym::Ord)
.map_or(false, |id| implements_trait(cx, ty, id, &[]))
.is_some_and(|id| implements_trait(cx, ty, id, &[]))
}
8 changes: 4 additions & 4 deletions src/tools/clippy/clippy_lints/src/box_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl LateLintPass<'_> for BoxDefault {
// And that method is `new`
&& seg.ident.name == sym::new
// And the call is that of a `Box` method
&& path_def_id(cx, ty).map_or(false, |id| Some(id) == cx.tcx.lang_items().owned_box())
&& path_def_id(cx, ty).is_some_and(|id| Some(id) == cx.tcx.lang_items().owned_box())
// And the single argument to the call is another function call
// This is the `T::default()` (or default equivalent) of `Box::new(T::default())`
&& let ExprKind::Call(arg_path, _) = arg.kind
Expand Down Expand Up @@ -83,9 +83,9 @@ fn is_plain_default(cx: &LateContext<'_>, arg_path: &Expr<'_>) -> bool {
}

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

#[derive(Default)]
Expand Down
3 changes: 1 addition & 2 deletions src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ pub(super) fn check<'tcx>(
// The same is true if the expression encompassing the cast expression is a unary
// expression or an addressof expression.
let needs_block = matches!(cast_expr.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..))
|| get_parent_expr(cx, expr)
.map_or(false, |e| matches!(e.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..)));
|| get_parent_expr(cx, expr).is_some_and(|e| matches!(e.kind, ExprKind::Unary(..) | ExprKind::AddrOf(..)));

span_lint_and_sugg(
cx,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/comparison_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
let is_ord = cx
.tcx
.get_diagnostic_item(sym::Ord)
.map_or(false, |id| implements_trait(cx, ty, id, &[]));
.is_some_and(|id| implements_trait(cx, ty, id, &[]));

if !is_ord {
return;
Expand Down
16 changes: 6 additions & 10 deletions src/tools/clippy/clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn eq_binding_names(s: &Stmt<'_>, names: &[(HirId, Symbol)]) -> bool {
let mut i = 0usize;
let mut res = true;
l.pat.each_binding_or_first(&mut |_, _, _, name| {
if names.get(i).map_or(false, |&(_, n)| n == name.name) {
if names.get(i).is_some_and(|&(_, n)| n == name.name) {
i += 1;
} else {
res = false;
Expand Down Expand Up @@ -389,12 +389,10 @@ fn eq_stmts(
let new_bindings = &moved_bindings[old_count..];
blocks
.iter()
.all(|b| get_stmt(b).map_or(false, |s| eq_binding_names(s, new_bindings)))
.all(|b| get_stmt(b).is_some_and(|s| eq_binding_names(s, new_bindings)))
} else {
true
}) && blocks
.iter()
.all(|b| get_stmt(b).map_or(false, |s| eq.eq_stmt(s, stmt)))
}) && blocks.iter().all(|b| get_stmt(b).is_some_and(|s| eq.eq_stmt(s, stmt)))
}

#[expect(clippy::too_many_lines)]
Expand Down Expand Up @@ -451,9 +449,7 @@ fn scan_block_for_eq<'tcx>(
// x + 50
let expr_hash_eq = if let Some(e) = block.expr {
let hash = hash_expr(cx, e);
blocks
.iter()
.all(|b| b.expr.map_or(false, |e| hash_expr(cx, e) == hash))
blocks.iter().all(|b| b.expr.is_some_and(|e| hash_expr(cx, e) == hash))
} else {
blocks.iter().all(|b| b.expr.is_none())
};
Expand Down Expand Up @@ -514,7 +510,7 @@ fn scan_block_for_eq<'tcx>(
});
if let Some(e) = block.expr {
for block in blocks {
if block.expr.map_or(false, |expr| !eq.eq_expr(expr, e)) {
if block.expr.is_some_and(|expr| !eq.eq_expr(expr, e)) {
moved_locals.truncate(moved_locals_at_start);
return BlockEq {
start_end_eq,
Expand All @@ -533,7 +529,7 @@ fn scan_block_for_eq<'tcx>(
}

fn check_for_warn_of_moved_symbol(cx: &LateContext<'_>, symbols: &[(HirId, Symbol)], if_expr: &Expr<'_>) -> bool {
get_enclosing_block(cx, if_expr.hir_id).map_or(false, |block| {
get_enclosing_block(cx, if_expr.hir_id).is_some_and(|block| {
let ignore_span = block.span.shrink_to_lo().to(if_expr.span);

symbols
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
crate::methods::UNNECESSARY_JOIN_INFO,
crate::methods::UNNECESSARY_LAZY_EVALUATIONS_INFO,
crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO,
crate::methods::UNNECESSARY_MAP_OR_INFO,
crate::methods::UNNECESSARY_MIN_OR_MAX_INFO,
crate::methods::UNNECESSARY_RESULT_MAP_OR_ELSE_INFO,
crate::methods::UNNECESSARY_SORT_BY_INFO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,6 @@ impl<'tcx> From<Ty<'tcx>> for ExplicitTyBound {

impl<'tcx> From<Option<Ty<'tcx>>> for ExplicitTyBound {
fn from(v: Option<Ty<'tcx>>) -> Self {
Self(v.map_or(false, Ty::is_numeric))
Self(v.is_some_and(Ty::is_numeric))
}
}
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/derivable_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn is_path_self(e: &Expr<'_>) -> bool {
fn contains_trait_object(ty: Ty<'_>) -> bool {
match ty.kind() {
ty::Ref(_, ty, _) => contains_trait_object(*ty),
ty::Adt(def, args) => def.is_box() && args[0].as_type().map_or(false, contains_trait_object),
ty::Adt(def, args) => def.is_box() && args[0].as_type().is_some_and(contains_trait_object),
ty::Dynamic(..) => true,
_ => false,
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
// there's a Copy impl for any instance of the adt.
if !is_copy(cx, ty) {
if ty_subs.non_erasable_generics().next().is_some() {
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).is_some_and(|impls| {
impls.iter().any(|&id| {
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
if ty_adt.did() == adt.did())
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/doc/missing_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn check(
),
_ => (),
}
if !headers.panics && panic_info.map_or(false, |el| !el.1) {
if !headers.panics && panic_info.is_some_and(|el| !el.1) {
span_lint_and_note(
cx,
MISSING_PANICS_DOC,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/drop_forget_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
MEM_FORGET,
Cow::Owned(format!(
"usage of `mem::forget` on {}",
if arg_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) {
if arg_ty.ty_adt_def().is_some_and(|def| def.has_dtor(cx.tcx)) {
"`Drop` type"
} else {
"type with `Drop` fields"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ fn check_clousure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tc
{
span_lint_and_then(cx, REDUNDANT_CLOSURE, expr.span, "redundant closure", |diag| {
if let Some(mut snippet) = snippet_opt(cx, callee.span) {
if path_to_local(callee).map_or(false, |l| {
if path_to_local(callee).is_some_and(|l| {
// FIXME: Do we really need this `local_used_in` check?
// Isn't it checking something like... `callee(callee)`?
// If somehow this check is needed, add some test for it,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn raw_ptr_arg(cx: &LateContext<'_>, arg: &hir::Param<'_>) -> Option<HirId> {
}

fn check_arg(cx: &LateContext<'_>, raw_ptrs: &HirIdSet, arg: &hir::Expr<'_>) {
if path_to_local(arg).map_or(false, |id| raw_ptrs.contains(&id)) {
if path_to_local(arg).is_some_and(|id| raw_ptrs.contains(&id)) {
span_lint(
cx,
NOT_UNSAFE_PTR_ARG_DEREF,
Expand Down
Loading
Loading