Skip to content
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

Assign def ids and build the module graph during expansion #36601

Merged
merged 7 commits into from
Sep 28, 2016

Conversation

jseyfried
Copy link
Contributor

@jseyfried jseyfried commented Sep 20, 2016

Groundwork for macro modularization (cc #35896).
r? @nrc

// does this attribute list contain "macro_use"?
fn contains_macro_use(&mut self, attrs: &[ast::Attribute]) -> bool {
for attr in attrs {
if attr.check_name("macro_escape") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macro_escape is ancient! (5bf385b)
Can be removed now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c.f. #36603

Copy link
Contributor

@petrochenkov petrochenkov Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, I haven't noticed it's span_warn and not span_err, even the variable is named err...

@nrc
Copy link
Member

nrc commented Sep 20, 2016

r = me, once the deps land.

@bors
Copy link
Contributor

bors commented Sep 22, 2016

☔ The latest upstream changes (presumably #36551) made this pull request unmergeable. Please resolve the merge conflicts.

@jseyfried jseyfried force-pushed the build_reduced_graph_in_expansion branch 7 times, most recently from 08f131e to 105cc1e Compare September 24, 2016 03:59
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate bäz; //~ ERROR non-ascii idents
extern crate core as bäz; //~ ERROR non-ascii idents
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this PR, we load extern crates (in BuildReducedGraphVisitor) before checking for non-ascii idents (in the gated feature checking pass).

@jseyfried
Copy link
Contributor Author

@nrc I added three more commits -- r?

@jseyfried jseyfried force-pushed the build_reduced_graph_in_expansion branch 5 times, most recently from 1dff614 to 0594531 Compare September 26, 2016 05:25
@@ -27,7 +27,7 @@ pub struct DefCollector<'a> {
hir_crate: Option<&'a hir::Crate>,
definitions: &'a mut Definitions,
parent_def: Option<DefIndex>,
pub visit_macro_invoc: Option<&'a mut FnMut(NodeId, DefIndex)>,
pub visit_macro_invoc: Option<&'a mut FnMut(NodeId, DefIndex, bool /* const_integer */)>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say it would be better to have a struct than a tuple at this point (esp with a bool with comment). However, given that this field only ever seems to have one instantiation, it might just be over-abstracted. Could it be changed to a flag with a method rather than an optional closure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could refactor the closure into a user-defined trait object (e.g. Option<&'a mut MacroInvocationVisitor>, where MacroInvocationVisitor is a trait with method fn visit_invoc(id: NodeId, def_index: DefIndex, const_integer: bool)).

The invocation visiting code needs to be in resolve, so we need a trait object of some sort.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a closure is as good as a trait object, but probably better to take a struct rather than a 3-tuple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point -- amended accordingly.

@@ -27,13 +27,15 @@ use syntax::util::lev_distance::find_best_match_for_name;
pub struct ExpansionData<'a> {
pub module: Module<'a>,
def_index: DefIndex,
const_integer: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment explaining what const_integer means please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jseyfried jseyfried force-pushed the build_reduced_graph_in_expansion branch 2 times, most recently from a21377c to 3aa46c3 Compare September 26, 2016 23:27
@bors
Copy link
Contributor

bors commented Sep 27, 2016

☔ The latest upstream changes (presumably #36678) made this pull request unmergeable. Please resolve the merge conflicts.

@nrc
Copy link
Member

nrc commented Sep 27, 2016

@bors: r+

@bors
Copy link
Contributor

bors commented Sep 27, 2016

📌 Commit dfa69be has been approved by nrc

@bors
Copy link
Contributor

bors commented Sep 27, 2016

⌛ Testing commit dfa69be with merge a059cb2...

bors added a commit that referenced this pull request Sep 27, 2016
Assign def ids and build the module graph during expansion

r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants