-
Notifications
You must be signed in to change notification settings - Fork 759
Allow anonymous template types #575
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
Allow anonymous template types #575
Conversation
We have various assertions that the only way that some template parameter related methods will return `None` is if the template definition is marked opaque. These assertions fail in the presence of test cases with unnamed template types, because we never save an IR item for the template type, and subsequently think that the template definition has no template parameters. The assertions are in fact sound and correct, so it doesn't make sense to remove them. Instead it is more correct to save IR items for the anonymous template types and simply let the template usage analysis prevent them from getting codegen'd. Fixes rust-lang#574
Not sure why rustfmt hasn't caught this before...
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'd say let's drop the last commit for now. r=me on the rest.
src/ir/comp.rs
Outdated
@@ -357,8 +359,8 @@ impl CompInfo { | |||
|
|||
let has_destructor = self.has_destructor || | |||
match self.kind { | |||
CompKind::Union => false, | |||
CompKind::Struct => { | |||
CompKind::Union => false, |
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 don't think these changes are really acceptable in general.
Is this only due to a newer version of rustfmt?
src/ir/module.rs
Outdated
@@ -63,7 +63,7 @@ impl DotAttributes for Module { | |||
_ctx: &BindgenContext, | |||
out: &mut W) | |||
-> io::Result<()> | |||
where W: io::Write, | |||
where W: io::Write |
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.
Also, it's no longer respecting the trailing comma in where clauses?
src/ir/named.rs
Outdated
.or_insert(vec![]) | ||
.push(item); | ||
}, | ||
dependencies.entry(sub_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.
This change seems also wrong to me.
src/main.rs
Outdated
@@ -52,8 +52,8 @@ pub fn main() { | |||
Ok((builder, output, verbose)) => { | |||
|
|||
let builder_result = panic::catch_unwind(|| { | |||
builder.generate().expect("Unable to generate bindings") | |||
}); | |||
builder.generate().expect("Unable to generate bindings") |
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.
This is also way off I believe.
b8cfd9f
to
b7f7850
Compare
Thanks for the review! Dropped the last commit. Yeah, this is latest @bors-servo r+ |
📌 Commit b7f7850 has been approved by |
…and-assertion-failure, r=fitzgen Allow anonymous template types We have various assertions that the only way that some template parameter related methods will return `None` is if the template definition is marked opaque. These assertions fail in the presence of test cases with unnamed template types, because we never save an IR item for the template type, and subsequently think that the template definition has no template parameters. The assertions are in fact sound and correct, so it doesn't make sense to remove them. Instead it is more correct to save IR items for the anonymous template types and simply let the template usage analysis prevent them from getting codegen'd. Fixes #574 r? @emilio
@bors-servo r- |
@bors-servo r=emilio |
📌 Commit b7f7850 has been approved by |
FWIW, filed rust-lang/rustfmt#1376 for the |
☀️ Test successful - status-travis |
We have various assertions that the only way that some template parameter related methods will return
None
is if the template definition is marked opaque. These assertions fail in the presence of test cases with unnamed template types, because we never save an IR item for the template type, and subsequently think that the template definition has no template parameters. The assertions are in fact sound and correct, so it doesn't make sense to remove them. Instead it is more correct to save IR items for the anonymous template types and simply let the template usage analysis prevent them from gettingcodegen'd.
Fixes #574
r? @emilio