-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor the way methods are stored in ast::ImplItem/TraitItem. #23265
Conversation
caae538
to
ad05505
Compare
@@ -13,7 +13,7 @@ fn main() { | |||
pub struct A; //~ ERROR: visibility has no effect | |||
pub enum B {} //~ ERROR: visibility has no effect | |||
pub trait C { //~ ERROR: visibility has no effect | |||
pub fn foo(&self) {} //~ ERROR: visibility has no effect | |||
fn foo(&self) {} |
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.
Why remove these privacy tests - are they no longer checked - that seems bad
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.
They are parse errors now - I guess I should move them to parse-fail
tests.
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.
Ok, I think it's a good idea to move the tests rather than removing
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've added two parse-fail tests. I hope they're enough.
f608bae
to
def8023
Compare
LGTM, r+, but I'll leave it for @nikomatsakis to make it official in case he has any thoughts about the AST design. |
def8023
to
4fdacbb
Compare
…thod into MethodTraitItem.
4fdacbb
to
9da9185
Compare
I've been wanting to do similar cleanup and consolidation forever. Nice. |
The end result is that common fields (id, name, attributes, etc.) are stored in now-structures `ImplItem` and `TraitItem`. The signature of a method is no longer duplicated between methods with a body (default/impl) and those without, they now share `MethodSig`. This is also a [breaking-change] because of minor bugfixes and changes to syntax extensions: * `pub fn` methods in a trait no longer parse - remove the `pub`, it has no meaning anymore * `MacResult::make_methods` is now `make_impl_items` and the return type has changed accordingly * `quote_method` is gone, because `P<ast::Method>` doesn't exist and it couldn't represent a full method anyways - could be replaced by `quote_impl_item`/`quote_trait_item` in the future, but I do hope we realize how silly that combinatorial macro expansion is and settle on a single `quote` macro + some type hints - or just no types at all (only token-trees) r? @nikomatsakis This is necessary (hopefully also sufficient) for associated constants.
This fixes several use cases that were broken after rust-lang#23265 landed.
This fixes several use cases that were broken after rust-lang#23265 landed.
The end result is that common fields (id, name, attributes, etc.) are stored in now-structures
ImplItem
andTraitItem
.The signature of a method is no longer duplicated between methods with a body (default/impl) and those without, they now share
MethodSig
.This is also a [breaking-change] because of minor bugfixes and changes to syntax extensions:
pub fn
methods in a trait no longer parse - remove thepub
, it has no meaning anymoreMacResult::make_methods
is nowmake_impl_items
and the return type has changed accordinglyquote_method
is gone, becauseP<ast::Method>
doesn't exist and it couldn't represent a full method anyways - could be replaced byquote_impl_item
/quote_trait_item
in the future, but I do hope we realize how silly that combinatorial macro expansion is and settle on a singlequote
macro + some type hints - or just no types at all (only token-trees)r? @nikomatsakis This is necessary (hopefully also sufficient) for associated constants.