-
Notifications
You must be signed in to change notification settings - Fork 14k
Add and use generics.is_empty(), rather than checking generics' params vec
#123929
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
Conversation
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
compiler-errors
left a comment
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.
Yeah, after a self-review it's kind of certain there are more places where it's wrong to use this than right.
| let gat_generics = tcx.generics_of(gat_def_id); | ||
| // FIXME(jackh726): we can also warn in the more general case | ||
| if gat_generics.params.is_empty() { | ||
| if gat_generics.is_empty() { |
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.
Oops, this is wrong!
| // type of `foo` (possibly adjusted), but we don't want to | ||
| // include that. We want just the `[_, u32]` part. | ||
| if !args.is_empty() && !generics.params.is_empty() { | ||
| if !args.is_empty() && !generics.is_empty() { |
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 also wrong
| // here and so associated type bindings will be handled regardless of whether there are any | ||
| // non-`Self` generic parameters. | ||
| if generics.params.is_empty() { | ||
| if generics.is_empty() { |
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 wrong
| if let Adt(def, _) = self_ty.kind() { | ||
| let generics = self.tcx.generics_of(def.did()); | ||
| if !generics.params.is_empty() { | ||
| if !generics.is_empty() { |
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 wrong
| assert_eq!(args.len(), generics.parent_count); | ||
|
|
||
| let xform_fn_sig = if generics.params.is_empty() { | ||
| let xform_fn_sig = if generics.is_empty() { |
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 wrong
| // on top of the same path, but without its own generics. | ||
| _ => { | ||
| if !generics.params.is_empty() && args.len() >= generics.count() { | ||
| if !generics.is_empty() && args.len() >= generics.count() { |
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 wrong
| ty::AssocKind::Type => { | ||
| if !tcx.features().generic_associated_types_extended | ||
| && !tcx.generics_of(item.def_id).params.is_empty() | ||
| && !tcx.generics_of(item.def_id).is_empty() |
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 wrong
| // that means that we must have newly inferred something about the GAT. | ||
| // We should give up in that case. | ||
| if !generics.params.is_empty() | ||
| if !generics.is_empty() |
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 wrong
| && let FnRetTy::Return(ret) = sig.decl.output | ||
| && is_nameable_in_impl_trait(ret) | ||
| && cx.tcx.generics_of(item_did).params.is_empty() | ||
| && cx.tcx.generics_of(item_did).is_empty() |
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.
Hm, this is wrong
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
I guess you have decided to not proceed with this change, right?. I was suggesting something like an |
|
@spastorino: feel free to do the change yourself -- you can use the comments above to figure out where we care about is_own_empty vs is_empty. |
…iler-errors Add and use generics.is_empty() and generics.is_own_empty, rather than using generics' attributes r? `@compiler-errors` Related to rust-lang#123929
r? spastorino