-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
HIR - Move Generics from MethodSig to TraitItem and ImplItem #44852
Changes from all commits
26395e4
a9924c6
ea6b18e
ad16f9c
540d08b
037aa16
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 |
---|---|---|
|
@@ -568,15 +568,11 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
let num_trait_m_type_params = trait_m_generics.types.len(); | ||
if num_impl_m_type_params != num_trait_m_type_params { | ||
let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap(); | ||
let span = match tcx.hir.expect_impl_item(impl_m_node_id).node { | ||
ImplItemKind::Method(ref impl_m_sig, _) => { | ||
if impl_m_sig.generics.is_parameterized() { | ||
impl_m_sig.generics.span | ||
} else { | ||
impl_m_span | ||
} | ||
} | ||
_ => bug!("{:?} is not a method", impl_m), | ||
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. Is it still a bug if this isn't a method? If so, we should add the match back in. The match was taken out because technically all impl items have generics now, not just methods. 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 don't think it has to be a bug -- this code is currently only used for methods, I believe, but I expect we'll be using it or something similar for all trait/impl items before we are done. |
||
let impl_m_item = tcx.hir.expect_impl_item(impl_m_node_id); | ||
let span = if impl_m_item.generics.is_parameterized() { | ||
impl_m_item.generics.span | ||
} else { | ||
impl_m_span | ||
}; | ||
|
||
let mut err = struct_span_err!(tcx.sess, | ||
|
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.
Note that this is a removal. If you trace the code up to the usages of
walk_fn
, I don't see where else this is used. I think it should be alright, but it's worth noting the consequences of this change.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.
I'll try to do a look to get a feel for whether there will be impact -- but as we said before, really this call is just moving into
visit_trait_item
andvisit_impl_item
, so it's not like it's a pure removal.