-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Optimize msrv calls (again) #17355
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
base: master
Are you sure you want to change the base?
Optimize msrv calls (again) #17355
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,9 @@ pub fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, receiver: &hir::Expr<'_ | |
| && let self_ty = args.type_at(0) | ||
| && let (deref_self_ty, deref_count, _) = peel_and_count_ty_refs(self_ty) | ||
| && deref_count >= 1 | ||
| && specializes_tostring(cx, deref_self_ty) | ||
| // Since Rust 1.82, the specialized `ToString` is properly called | ||
| && !msrv.meets(cx, msrvs::SPECIALIZED_TO_STRING_FOR_REFS) | ||
|
Comment on lines
+22
to
24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't touch this one. The |
||
| && specializes_tostring(cx, deref_self_ty) | ||
| { | ||
| span_lint_and_then( | ||
| cx, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,9 +29,9 @@ pub(super) fn check<'tcx>( | |
| && let ExprKind::Path(qpath) = path.kind | ||
| && let Res::Def(DefKind::Ctor(_, _), _) = cx.qpath_res(&qpath, path.hir_id) | ||
| && let ExprKind::Closure(closure) = acc.kind | ||
| && let Some(args_snip) = closure.fn_arg_span.and_then(|fn_arg_span| fn_arg_span.get_text(cx)) | ||
| && msrv.meets(cx, msrvs::ITERATOR_TRY_FOLD) | ||
| && !is_from_proc_macro(cx, expr) | ||
|
Comment on lines
+32
to
34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't move this one. Taking a snippet for a suggestions should happen after the everything else. |
||
| && let Some(args_snip) = closure.fn_arg_span.and_then(|fn_arg_span| fn_arg_span.get_text(cx)) | ||
| { | ||
| let init_snip = rest | ||
| .is_empty() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,9 +33,9 @@ pub(super) fn check<'tcx>( | |
| (false, true) => lhs, | ||
| _ => return, | ||
| } | ||
| && let Some(scrutinee_snip) = scrutinee.span.get_text(cx) | ||
| && msrv.meets(cx, msrvs::MATCHES_MACRO) | ||
| && !is_from_proc_macro(cx, expr) | ||
|
Comment on lines
+36
to
38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't move this one as it's a snippet. |
||
| && let Some(scrutinee_snip) = scrutinee.span.get_text(cx) | ||
| { | ||
| // Normalize the char using `map` so `join` doesn't use `Display`, if we don't then | ||
| // something like `r"\"` will become `'\'`, which is of course invalid | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only partially correct.
Msrv::meetsonly slow if the crate has aclippy::msrvattribute which is becoming less common ever sinceCargo.tomlgot themsrvfield. This slowness could even be mostly fixed if it were an unavoidable issue.The biggest issue with it is that it's just not a good filter. The MSRV being set to whatever the current version is very common and makes this filter out nothing. Even for (actively developed) crates which set an MSRV, it's not usually more than a couple years old. This not only makes most checks not filter anything out, but the total number of ineffective filters grows over time.
View changes since the review