Skip to content

Conversation

@fitzgen
Copy link
Member

@fitzgen fitzgen commented Apr 17, 2017

See each commit message for details. bce1330 is the big correctness fix for a bug we were hitting in stylo.

r? @emilio

fitzgen added 8 commits April 17, 2017 16:01
We have a couple knobs to turn for item resolution, such as whether we keep
going through type references and type aliases. It makes sense to have a single,
easy place to configure these knobs.
This commit adds a bunch of debug logging to the template type parameters
analysis. I've essentially adding this same code and then never committed it,
like three or four different times. Because I keep re-writing it, I think it is
worth keeping around in a more permanent fashion.
This commit makes the test-one.sh script log the input header as well as the
emitted bindings to stdout.
In stylo bindings generation, we were hitting bugs where the analysis saw a
template type parameter behind a type ref to a type alias, and this was then
used as an argument to a template instantiation. Because of the indirection, the
analysis got confused and ignored the template argument because it was "not" a
named template type, and therefore we didn't care about its usage.

This commit makes sure that we keep resolving through type references and
aliases to find the inner named template type parameter to add to the current
item's usage set.

Fixes rust-lang#638.
…nctions

The method was getting fairly large, and it is a little easier to read if we
break it down into smaller parts.
It had some incorrectness where there was a difference between the abstract
`self_template_param_usage` and `template_param_usage` functions. In reality,
they are different cases of the same function. The comment was misleading in
that it implied that we run both on the same IR item, when in fact we will only
run one or the other. I've tried to make it more clear in the new version of the
comment.
The trait is all about accessing template parameters, and is also implemented
for things that are not template declarations or definitions, but do end up
using template parameters one way or another. The new name makes more sense.
@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Awesome :)

src/ir/named.rs Outdated
// parameters, but we can push the issue down the line to them.
Some(&TypeKind::TemplateInstantiation(ref inst))
if !self.whitelisted_items.contains(&inst.template_definition()) => {
debug!(" instantiation of blacklisted template, uses all template \
Copy link
Contributor

Choose a reason for hiding this comment

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

These should probably be trace!, but no big deal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is trace! a lower level than debug!? If so, then yes I can definitely do that

These logs are pretty loud, so let's knock em down a log level.
@fitzgen
Copy link
Member Author

fitzgen commented Apr 17, 2017

Thanks for the review! Just pushed a new commit going debug! => log! in the template analysis.

@bors-servo r=emilio

@bors-servo
Copy link

📌 Commit 9689db6 has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 9689db6 with merge 65f672c...

bors-servo pushed a commit that referenced this pull request Apr 17, 2017
More fixes for Stylo

See each commit message for details. bce1330 is the big correctness fix for a bug we were hitting in stylo.

r? @emilio
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: emilio
Pushing 65f672c to master...

@bors-servo bors-servo merged commit 9689db6 into rust-lang:master Apr 17, 2017
@fitzgen fitzgen deleted the stylo-stuff branch April 17, 2017 23:52
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