-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add E0044 and E0071 error explanations #26431
Conversation
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
``` | ||
"##, | ||
|
||
E0045: r##" |
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 not an explanation of non-extern "C"
variadic functions.
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 understand. Isn't it about just extern function ?
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.
rust/src/librustc_typeck/diagnostics.rs
Line 1470 in 40d19bf
E0045, // variadic function must have C calling convention |
E0045 is about non-foreign functions with variadic params
☔ The latest upstream changes (presumably #26428) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @Manishearth |
extern { fn some_func<T>(); } | ||
``` | ||
|
||
Just remove the type parameter to make this code works: |
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.
"To make this code work"
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.
You should also have more advice here. "Removing the type parameter" won't make this code work, because now you need concrete types here.
Something along the lines of manually putting in the versions that you need (manual monomorphization) is what we want here
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 understand what you mean here. You want to say something like:
extern { fn some_func<i32>(); }
?
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.
That doesn't do anything.
extern { fn some_func_i32(); }
is what I mean
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.
Yes, that's an example, no ? What do you want me to add ?
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.
Well, the current example would likely break any code using generics. You should change the advice to not recommend "just removing the type parameter".
Something like "to fix this, replace the type parameter with the specializations that you need"
Examples would be:
extern {
fn some_func_i32(x: i32);
fn some_func_f64(x: f64);
}
over fn some_func<T>(x: T)
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.
Oh okay ! Pfiouuuu... Took me a while to get it. I change it !
@Manishearth: I updated it. Sorry for taking this long to get it... |
About the E0071, the error can occurs in others places:
But it doesn't throw the error code. Is that normal ? |
No, that should probably be fixed to use the same error code uniformly. |
Okay, I'll create a PR then. |
30f7459
to
d148036
Compare
☔ The latest upstream changes (presumably #26503) made this pull request unmergeable. Please resolve the merge conflicts. |
@Manishearth: Are we good here ? |
Example of erroneous code: | ||
|
||
``` | ||
enum Foo { f }; |
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.
capitalize f
throughout this example
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'll create a "complete" name instead of just "f".
Updated ! |
@bors r+ |
📌 Commit 4c2587c has been approved by |
@bors rollup |
⌛ Testing commit 4c2587c with merge 067b254... |
💔 Test failed - auto-linux-64-nopt-t |
extern { fn some_func_i32(x: i32); } | ||
extern { fn some_func_i64(x: i64); } | ||
``` | ||
|
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.
You're missing an end of string here, currently E0045 and its message are included in E0044's message!
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.
Oh crap ! Bad rebase...
Fixed. |
@bors r+ rollup |
📌 Commit 3c98781 has been approved by |
Part of #24407.
cc @michaelsproul