-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
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 |
---|---|---|
|
@@ -411,7 +411,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |
// Traits always have `Self` as a generic parameter, which means they will not return early | ||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong |
||
return (tcx.mk_args(parent_args), arg_count); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,7 +450,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { | |
// `foo.bar::<u32>(...)` -- the `Self` type here will be the | ||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. This is also wrong |
||
let user_type_annotation = self.probe(|_| { | ||
let user_args = UserArgs { | ||
args: GenericArgs::for_item(self.tcx, pick.item.def_id, |param, _| { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,7 +282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
if !self_ty_name.contains('<') { | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong |
||
let counts = generics.own_counts(); | ||
self_ty_name += &format!( | ||
"<{}>", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1871,7 +1871,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { | |
let generics = self.tcx.generics_of(method); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong |
||
fn_sig.instantiate(self.tcx, args) | ||
} else { | ||
let args = GenericArgs::for_item(self.tcx, method, |param, _| { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,7 +157,7 @@ pub trait Printer<'tcx>: Sized { | |
// If we have any generic arguments to print, we do that | ||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong |
||
let args = generics.own_args_no_defaults(self.tcx(), args); | ||
return self.path_generic_args( | ||
|cx| cx.print_def_path(def_id, parent_args), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,7 +397,7 @@ pub fn object_safety_violations_for_assoc_item( | |
// Associated types can only be object safe if they have `Self: Sized` bounds. | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong |
||
&& !item.is_impl_trait_in_trait() | ||
{ | ||
vec![ObjectSafetyViolation::GAT(item.name, item.ident(tcx).span)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1773,7 +1773,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | |
// If this type is a GAT, and of the GAT args resolve to something new, | ||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong |
||
&& obligation.predicate.args[generics.parent_count..] | ||
.iter() | ||
.any(|&p| p.has_non_region_infer() && self.infcx.shallow_resolve(p) != p) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,7 @@ impl {self_ty_without_ref} {{ | |
&& let ImplItemKind::Fn(sig, _) = item.kind | ||
&& 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 commentThe reason will be displayed to describe this comment to others. Learn more. Hm, this is wrong |
||
&& sig.decl.implicit_self == expected_implicit_self | ||
&& sig.decl.inputs.len() == 1 | ||
&& let Some(imp) = get_parent_as_impl(cx.tcx, item.hir_id()) | ||
|
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!