-
Notifications
You must be signed in to change notification settings - Fork 13.9k
clippy fixes and code simplification #148211
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
Open
hkBst
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
hkBst:clippy-fix-13
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,20 +94,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
|
|
||
| let find_param_matching = |matches: &dyn Fn(ParamTerm) -> bool| { | ||
| predicate_args.iter().find_map(|arg| { | ||
| arg.walk().find_map(|arg| { | ||
| if let ty::GenericArgKind::Type(ty) = arg.kind() | ||
| && let ty::Param(param_ty) = *ty.kind() | ||
| && matches(ParamTerm::Ty(param_ty)) | ||
| { | ||
| Some(arg) | ||
| } else if let ty::GenericArgKind::Const(ct) = arg.kind() | ||
| && let ty::ConstKind::Param(param_ct) = ct.kind() | ||
| && matches(ParamTerm::Const(param_ct)) | ||
| arg.walk().find(|arg| match arg.kind() { | ||
| ty::GenericArgKind::Type(ty) if let ty::Param(param_ty) = ty.kind() => { | ||
| matches(ParamTerm::Ty(*param_ty)) | ||
| } | ||
| ty::GenericArgKind::Const(ct) | ||
| if let ty::ConstKind::Param(param_ct) = ct.kind() => | ||
| { | ||
| Some(arg) | ||
| } else { | ||
| None | ||
| matches(ParamTerm::Const(param_ct)) | ||
| } | ||
| _ => false, | ||
| }) | ||
| }) | ||
| }; | ||
|
|
@@ -162,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| .into_iter() | ||
| .flatten() | ||
| { | ||
| if self.point_at_path_if_possible(error, def_id, param, &qpath) { | ||
| if self.point_at_path_if_possible(error, def_id, param, qpath) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
@@ -194,7 +190,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| args, | ||
| ) => { | ||
| if let Some(param) = predicate_self_type_to_point_at | ||
| && self.point_at_path_if_possible(error, callee_def_id, param, &qpath) | ||
| && self.point_at_path_if_possible(error, callee_def_id, param, qpath) | ||
| { | ||
| return true; | ||
| } | ||
|
|
@@ -225,7 +221,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| .into_iter() | ||
| .flatten() | ||
| { | ||
| if self.point_at_path_if_possible(error, callee_def_id, param, &qpath) { | ||
| if self.point_at_path_if_possible(error, callee_def_id, param, qpath) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
@@ -544,10 +540,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| } | ||
|
|
||
| /// - `blame_specific_*` means that the function will recursively traverse the expression, | ||
| /// looking for the most-specific-possible span to blame. | ||
| /// looking for the most-specific-possible span to blame. | ||
| /// | ||
| /// - `point_at_*` means that the function will only go "one level", pointing at the specific | ||
| /// expression mentioned. | ||
| /// expression mentioned. | ||
| /// | ||
| /// `blame_specific_arg_if_possible` will find the most-specific expression anywhere inside | ||
| /// the provided function call expression, and mark it as responsible for the fulfillment | ||
|
|
@@ -607,9 +603,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| /** | ||
| * Recursively searches for the most-specific blameable expression. | ||
| * For example, if you have a chain of constraints like: | ||
| * - want `Vec<i32>: Copy` | ||
| * - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>` | ||
| * - because `(Option<Vec<i32>, bool)` needs `Option<Vec<i32>>: Copy` because `impl <A: Copy, B: Copy> Copy for (A, B)` | ||
| * - want `Vec<i32>: Copy` | ||
| * - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>` | ||
| * - because `(Option<Vec<i32>, bool)` needs `Option<Vec<i32>>: Copy` because `impl <A: Copy, B: Copy> Copy for (A, B)` | ||
| * | ||
| * then if you pass in `(Some(vec![1, 2, 3]), false)`, this helper `point_at_specific_expr_if_possible` | ||
| * will find the expression `vec![1, 2, 3]` as the "most blameable" reason for this missing constraint. | ||
| * | ||
|
|
@@ -747,9 +744,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
|
|
||
| /// Drills into `expr` to arrive at the equivalent location of `find_generic_param` in `in_ty`. | ||
| /// For example, given | ||
| /// - expr: `(Some(vec![1, 2, 3]), false)` | ||
| /// - param: `T` | ||
| /// - in_ty: `(Option<Vec<T>, bool)` | ||
| /// - expr: `(Some(vec![1, 2, 3]), false)` | ||
| /// - param: `T` | ||
| /// - in_ty: `(Option<Vec<T>, bool)` | ||
|
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. ditto |
||
| /// | ||
| /// we would drill until we arrive at `vec![1, 2, 3]`. | ||
| /// | ||
| /// If successful, we return `Ok(refined_expr)`. If unsuccessful, we return `Err(partially_refined_expr`), | ||
|
|
@@ -1017,7 +1015,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
| .variant_with_id(variant_def_id) | ||
| .fields | ||
| .iter() | ||
| .map(|field| field.ty(self.tcx, *in_ty_adt_generic_args)) | ||
| .map(|field| field.ty(self.tcx, in_ty_adt_generic_args)) | ||
| .enumerate() | ||
| .filter(|(_index, field_type)| find_param_in_ty((*field_type).into(), param)), | ||
| ) else { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A single space indent here seems worse.
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.
Very well, I will revert such changes.