-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Move Generics from MethodSig to TraitItem and ImplItem #44766
Changes from all commits
f61394f
e03447d
892e468
bb30144
2095ac1
b43db76
86ae349
14c426d
6936871
60bff8c
4b0f004
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 |
---|---|---|
|
@@ -718,12 +718,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> { | |
_: Span, | ||
node_id: NodeId) { | ||
let rib_kind = match function_kind { | ||
FnKind::ItemFn(_, generics, ..) => { | ||
self.visit_generics(generics); | ||
FnKind::ItemFn(..) => { | ||
ItemRibKind | ||
} | ||
FnKind::Method(_, sig, _, _) => { | ||
self.visit_generics(&sig.generics); | ||
MethodRibKind(!sig.decl.has_self()) | ||
} | ||
FnKind::Closure(_) => ClosureRibKind(node_id), | ||
|
@@ -1880,7 +1878,7 @@ impl<'a> Resolver<'a> { | |
} | ||
TraitItemKind::Method(ref sig, _) => { | ||
let type_parameters = | ||
HasTypeParameters(&sig.generics, | ||
HasTypeParameters(&trait_item.generics, | ||
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 think we'll need to add this type parameter rib to each variant in this match statement because each (this applies to both trait items and impl items) 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. Well, it depends. I would think we just want to rename |
||
MethodRibKind(!sig.decl.has_self())); | ||
this.with_type_parameter_rib(type_parameters, |this| { | ||
visit::walk_trait_item(this, trait_item) | ||
|
@@ -2097,7 +2095,7 @@ impl<'a> Resolver<'a> { | |
// We also need a new scope for the method- | ||
// specific type parameters. | ||
let type_parameters = | ||
HasTypeParameters(&sig.generics, | ||
HasTypeParameters(&impl_item.generics, | ||
MethodRibKind(!sig.decl.has_self())); | ||
this.with_type_parameter_rib(type_parameters, |this| { | ||
visit::walk_impl_item(this, impl_item); | ||
|
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'm worried about whether this change has any side-effects we don't want. I don't think I found a place to add this back in after I deleted it.
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.
Indeed, we will need to add this back somewhere =) I think the problem is that theFnKind
enum has to change. Methods should operate more analogously withItemFn
-- so we should add a&'a Generics
to theMethod
variant, and then when we constructFnKind::Method
(here and here) we can add the data from the trait or impl item respectively. Then we can restore the call tovisit_generics
that occurs here, I suppose.This was wrong.
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.
Well, let me read a bit more into this actually. I think what I said is not wrong but a few more tweaks are likely needed.
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, so I think it's fine to remove the call here -- it is being moved into the
walk_trait_item
andwalk_impl_item
code, effectively.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.
Is this change really okay? If
ItemFn
visits generics, shouldn'tMethod
visit them too?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.
Nope. It happens as part of
visit_trait_item
orvisit_impl_item
, I think.