-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Suggest using block for extern "abi" fn
with no body
#98827
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
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
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.
Lets run a perfbot and see if spans in extern are reasonably cheap addition.
error: `extern` functions without bodies must go in `extern` blocks | ||
--> $DIR/not-in-block.rs:3:1 | ||
| | ||
LL | extern fn none_fn(x: bool) -> i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: wrap in an `extern` block | ||
| | ||
LL | extern { fn none_fn(x: bool) -> 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.
Wording suggestion: I would largely follow the messaging of non-extern functions for the error message, only adapting a help message to be specific to extern. Among other reasons to do so is just plain sharing of the effort on this diagnostic between the two types of functions. Today that reads as:
error: free function without a body
--> src/lib.rs:1:1
|
1 | fn banana();
| ^^^^^^^^^^^-
| |
| help: provide a definition for the function: `{ <body> }`
Regardless of whether this item has an extern
or not, it is pretty hard to tell what the intent really was. Did they mean to declare something? Did they make a genuine mistake? The current wording does a great job at not assuming a specific problem. Another thing I’d like to see improved is explaining what is the effect of wrapping the item in an extern
block. That way somebody seeing the message for the first time won’t need to go searching for the documentation describing what and why. With that in mind… maybe something like this?
error: `extern` functions without bodies must go in `extern` blocks | |
--> $DIR/not-in-block.rs:3:1 | |
| | |
LL | extern fn none_fn(x: bool) -> i32; | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| | |
help: wrap in an `extern` block | |
| | |
LL | extern { fn none_fn(x: bool) -> i32; } | |
| ~~~~~~~~ + | |
error: free function without a body | |
--> $DIR/not-in-block.rs:3:1 | |
| | |
LL | extern fn none_fn(x: bool) -> i32; | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| | |
help: use an `extern` block in order to declare an externally defined function | |
| | |
LL | extern { fn none_fn(x: bool) -> i32; } | |
| ~~~~~~~~ + |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 6ff30d72cdfe6fb0b5a9db25e4380f0bde5411af with merge bcd60280e79a3ae4298f75261dee911e1466f6be... |
☀️ Try build successful - checks-actions |
Queued bcd60280e79a3ae4298f75261dee911e1466f6be with parent 495b216, future comparison URL. |
Finished benchmarking commit (bcd60280e79a3ae4298f75261dee911e1466f6be): comparison url. Instruction count
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Footnotes |
6ff30d7
to
50e5059
Compare
Updated the diagnostic messages. Perf result is unfortunate, not sure if it's Ok to land like this, if it's possible to get the better errors without the perf overhead, or how to decide if it's worth it. @rustbot ready |
@nnethercote I wonder what your take is here. Do you think there might be a better place to keep the |
The performance regressions are very small and on only a couple of benchmarks. I wouldn't worry about it. |
d016d08
to
e83554b
Compare
This comment has been minimized.
This comment has been minimized.
e83554b
to
02fb345
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
@bors retry |
@aDotInTheVoid: 🔑 Insufficient privileges: not in try users |
@bors r+ |
📌 Commit 02fb345 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (e78e747): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
I'm pretty sure those perf results are just noise, based on (a) how they differ to the pre-merge CI perf run, and (b) similar kinds of results in other PRs lately. |
…=nagisa Suggest using block for `extern "abi" fn` with no body `@rustbot` modify labels: +A-diagnostics
@rustbot modify labels: +A-diagnostics