-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Better attribute and metaitem encapsulation throughout the compiler #34842
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ use std::rc::Rc; | |
use std::u32; | ||
use syntax::abi::Abi; | ||
use syntax::ast::{self, NodeId, Name, CRATE_NODE_ID, CrateNum}; | ||
use syntax::attr; | ||
use syntax::attr::{self,AttrMetaMethods,AttributeMethods}; | ||
use errors::Handler; | ||
use syntax; | ||
use syntax_pos::BytePos; | ||
|
@@ -1431,31 +1431,28 @@ fn encode_item_index(rbml_w: &mut Encoder, index: IndexData) { | |
} | ||
|
||
fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) { | ||
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 wonder why this doesn't use auto-derived serialization. |
||
match mi.node { | ||
ast::MetaItemKind::Word(ref name) => { | ||
if mi.is_word() { | ||
let name = mi.name(); | ||
rbml_w.start_tag(tag_meta_item_word); | ||
rbml_w.wr_tagged_str(tag_meta_item_name, name); | ||
rbml_w.wr_tagged_str(tag_meta_item_name, &name); | ||
rbml_w.end_tag(); | ||
} | ||
ast::MetaItemKind::NameValue(ref name, ref value) => { | ||
match value.node { | ||
ast::LitKind::Str(ref value, _) => { | ||
rbml_w.start_tag(tag_meta_item_name_value); | ||
rbml_w.wr_tagged_str(tag_meta_item_name, name); | ||
rbml_w.wr_tagged_str(tag_meta_item_value, value); | ||
rbml_w.end_tag(); | ||
} | ||
_ => {/* FIXME (#623): encode other variants */ } | ||
} | ||
} | ||
ast::MetaItemKind::List(ref name, ref items) => { | ||
} else if mi.is_value_str() { | ||
let name = mi.name(); | ||
/* FIXME (#623): support other literal kinds */ | ||
let value = mi.value_str().unwrap(); | ||
rbml_w.start_tag(tag_meta_item_name_value); | ||
rbml_w.wr_tagged_str(tag_meta_item_name, &name); | ||
rbml_w.wr_tagged_str(tag_meta_item_value, &value); | ||
rbml_w.end_tag(); | ||
} else { // it must be a list | ||
let name = mi.name(); | ||
let items = mi.meta_item_list().unwrap(); | ||
rbml_w.start_tag(tag_meta_item_list); | ||
rbml_w.wr_tagged_str(tag_meta_item_name, name); | ||
rbml_w.wr_tagged_str(tag_meta_item_name, &name); | ||
for inner_item in items { | ||
encode_meta_item(rbml_w, &inner_item); | ||
} | ||
rbml_w.end_tag(); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -1464,7 +1461,7 @@ fn encode_attributes(rbml_w: &mut Encoder, attrs: &[ast::Attribute]) { | |
for attr in attrs { | ||
rbml_w.start_tag(tag_attribute); | ||
rbml_w.wr_tagged_u8(tag_attribute_is_sugared_doc, attr.node.is_sugared_doc as u8); | ||
encode_meta_item(rbml_w, &attr.node.value); | ||
encode_meta_item(rbml_w, attr.meta()); | ||
rbml_w.end_tag(); | ||
} | ||
rbml_w.end_tag(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 find the name
meta
to be not useful, maybe you should rename it? (Could be a follow-up PR).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.
Do you have name suggestions?
value()
?meta_item()
(which is dangerously close tometa_item_list()
?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.
inner()
ormeta_item()
seem good