Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 3 deletions clippy_lints/src/attrs/deprecated_cfg_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{Attribute, DEPRECATED_CFG_ATTR, DEPRECATED_CLIPPY_CFG_ATTR, unnecess
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::msrvs::{self, MsrvStack};
use clippy_utils::sym;
use rustc_ast::AttrStyle;
use rustc_ast::{AttrStyle, MetaItemInner};
use rustc_errors::Applicability;
use rustc_lint::EarlyContext;

Expand Down Expand Up @@ -53,7 +53,7 @@ pub(super) fn check_clippy(cx: &EarlyContext<'_>, attr: &Attribute) {
if attr.has_name(sym::cfg)
&& let Some(list) = attr.meta_item_list()
{
for item in list.iter().filter_map(|item| item.meta_item()) {
for item in list.iter().filter_map(MetaItemInner::meta_item) {
check_deprecated_cfg_recursively(cx, item);
}
}
Expand All @@ -63,7 +63,7 @@ fn check_deprecated_cfg_recursively(cx: &EarlyContext<'_>, attr: &rustc_ast::Met
if let Some(ident) = attr.ident() {
if matches!(ident.name, sym::any | sym::all | sym::not) {
let Some(list) = attr.meta_item_list() else { return };
for item in list.iter().filter_map(|item| item.meta_item()) {
for item in list.iter().filter_map(MetaItemInner::meta_item) {
check_deprecated_cfg_recursively(cx, item);
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/definition_in_module_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use rustc_ast::ast::{self, Inline, ItemKind, ModKind};
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext as _};
use rustc_session::impl_lint_pass;
use rustc_span::{FileName, SourceFile, sym};
use std::path::Path;

declare_clippy_lint! {
/// ### What it does
Expand Down Expand Up @@ -153,7 +154,7 @@ fn has_macro_export(item: &ast::Item) -> bool {
fn is_mod_rs(file: &SourceFile) -> bool {
if let FileName::Real(name) = &file.name {
name.local_path()
.and_then(|p| p.file_name())
.and_then(Path::file_name)
.is_some_and(|n| n == "mod.rs")
} else {
false
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
if from_subs.len() != to_subs.len() {
return true;
}
for (from_arg, to_arg) in to_subs.iter().zip(from_subs) {
for (from_arg, to_arg) in from_subs.iter().zip(to_subs) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol. Having a lint specifically for this kind of from_* <-> to_* bug might be nice..

match (from_arg.kind(), to_arg.kind()) {
(GenericArgKind::Lifetime(from_region), GenericArgKind::Lifetime(to_region)) => {
if check_region(from_region, to_region) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/infinite_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn is_never_return(ret_ty: FnRetTy<'_>) -> bool {
bounds,
..
}) => {
if let Some(trait_ref) = bounds.iter().find_map(|b| b.trait_ref())
if let Some(trait_ref) = bounds.iter().find_map(hir::GenericBound::trait_ref)
&& let Some(segment) = trait_ref
.path
.segments
Expand Down
21 changes: 21 additions & 0 deletions tests/ui/eta.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -687,3 +687,24 @@ mod issue_13094 {
.collect()
}
}

// https://github.com/rust-lang/rust-clippy/issues/14215
fn early_bound_region_in_adt() {
use std::marker::PhantomData;

struct Guard<'a, S> {
_data: PhantomData<&'a S>,
}

impl<S> Guard<'_, S> {
fn do_something(_this: &mut Self) {}
}

fn takes_guard_fn<S, F>(_func: F)
where
F: FnOnce(&mut Guard<S>),
{
}

takes_guard_fn::<i32, _>(|s| Guard::do_something(s));
}
21 changes: 21 additions & 0 deletions tests/ui/eta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,3 +687,24 @@ mod issue_13094 {
.collect()
}
}

// https://github.com/rust-lang/rust-clippy/issues/14215
fn early_bound_region_in_adt() {
use std::marker::PhantomData;

struct Guard<'a, S> {
_data: PhantomData<&'a S>,
}

impl<S> Guard<'_, S> {
fn do_something(_this: &mut Self) {}
}

fn takes_guard_fn<S, F>(_func: F)
where
F: FnOnce(&mut Guard<S>),
{
}

takes_guard_fn::<i32, _>(|s| Guard::do_something(s));
}