-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Lint on combining #[no_mangle]
and #[export_name]
#131558
Lint on combining #[no_mangle]
and #[export_name]
#131558
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @TaKO8Ki (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
f6d8242
to
aa419ee
Compare
This comment has been minimized.
This comment has been minimized.
#[no_mangle]
and #[export_name]
@Urgau Do you know why all these lints are prefixed by |
It's probably a prefix for the lints defined inside Lints outside of that file don't seems to have it at least. |
This comment has been minimized.
This comment has been minimized.
Ah, I see. Mm, great, in tests/ui/asm/naked-functions.rs we find this gem: #[export_name = "exported_function_name"]
#[link_section = ".custom_section"]
#[no_mangle]
#[naked]
pub unsafe extern "C" fn compatible_ffi_attributes_1() {
naked_asm!("", options(raw));
} @sassman Thank you for PRing this lint! It looks like you will have to fix a few cases of it in our test suite as well, and |
8c2d9ca
to
a7989cb
Compare
This comment has been minimized.
This comment has been minimized.
ff86482
to
1f849df
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Now the tests run all green and I have cleaned up the other test that used both Please let me know if there is anything that I can do further. |
I think this check is miss-placed, I think it should be with the others codegen attributes handling in the You can look at the
As well as @rustbot author |
Thanks @Urgau for the guidance, I will refactor the code accordingly. |
This comment has been minimized.
This comment has been minimized.
@Urgau I have refactored the code, but just to be sure I get things right, with this approach we won't have "named" lints that a user can allow or deny anymore or am I missing something? In the previous commit the lint was tied to the If I did got this right then I will adjust the introduced error output expectation to fix the build error: |
Reminder, don't forget to use the |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
This comment has been minimized.
This comment has been minimized.
commit suggestion of not always pretty printing Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
8f4622d
to
7951d19
Compare
@rustbot review |
@bors r+ |
…together-with-export-name, r=Urgau Lint on combining `#[no_mangle]` and `#[export_name]` This is my very first contribution to the compiler, even though I read the [chapter about lints](https://rustc-dev-guide.rust-lang.org/diagnostics.html) I'm not very certain that this ~~new lint is done right as a builtin lint~~ PR is right. I appreciate any guidance on how to improve the code. - Add test for issue rust-lang#47446 - ~~Implement the new lint `mixed_export_name_and_no_mangle` as a builtin lint (not sure if that is the right way to go)~~ Extend `unused_attributes` lint - Add suggestion how to fix it <details> <summary>Old proposed new lint</summary> > The `mixed_export_name_and_no_mangle` lint detects usage of both `#[export_name]` and `#[no_mangle]` on the same item which results on `#[no_mangle]` being ignored. > > *warn-by-default* > > ### Example > > ```rust > #[no_mangle] // ignored > #[export_name = "foo"] // takes precedences > pub fn bar() {} > ``` > > ### Explanation > > The compiler will not respect the `#[no_mangle]` attribute when generating the symbol name for the function, as the `#[export_name]` attribute takes precedence. This can lead to confusion and is unnecessary. </details>
…together-with-export-name, r=Urgau Lint on combining `#[no_mangle]` and `#[export_name]` This is my very first contribution to the compiler, even though I read the [chapter about lints](https://rustc-dev-guide.rust-lang.org/diagnostics.html) I'm not very certain that this ~~new lint is done right as a builtin lint~~ PR is right. I appreciate any guidance on how to improve the code. - Add test for issue rust-lang#47446 - ~~Implement the new lint `mixed_export_name_and_no_mangle` as a builtin lint (not sure if that is the right way to go)~~ Extend `unused_attributes` lint - Add suggestion how to fix it <details> <summary>Old proposed new lint</summary> > The `mixed_export_name_and_no_mangle` lint detects usage of both `#[export_name]` and `#[no_mangle]` on the same item which results on `#[no_mangle]` being ignored. > > *warn-by-default* > > ### Example > > ```rust > #[no_mangle] // ignored > #[export_name = "foo"] // takes precedences > pub fn bar() {} > ``` > > ### Explanation > > The compiler will not respect the `#[no_mangle]` attribute when generating the symbol name for the function, as the `#[export_name]` attribute takes precedence. This can lead to confusion and is unnecessary. </details>
Rollup of 10 pull requests Successful merges: - rust-lang#131558 (Lint on combining `#[no_mangle]` and `#[export_name]`) - rust-lang#133122 (Add unpolished, experimental support for AFIDT (async fn in dyn trait)) - rust-lang#133184 (wasi/fs: Improve stopping condition for <ReadDir as Iterator>::next) - rust-lang#133456 (Add licenses + Run `cargo update`) - rust-lang#133472 (Run TLS destructors for wasm32-wasip1-threads) - rust-lang#133853 (use vendor sources by default on dist tarballs) - rust-lang#133946 (coverage: Prefer to visit nodes whose predecessors have been visited) - rust-lang#134010 (fix ICE on type error in promoted) - rust-lang#134029 (coverage: Use a query to find counters/expressions that must be zero) - rust-lang#134071 (Configure renovatebot) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 10 pull requests Successful merges: - rust-lang#131558 (Lint on combining `#[no_mangle]` and `#[export_name]`) - rust-lang#133184 (wasi/fs: Improve stopping condition for <ReadDir as Iterator>::next) - rust-lang#133456 (Add licenses + Run `cargo update`) - rust-lang#133472 (Run TLS destructors for wasm32-wasip1-threads) - rust-lang#133853 (use vendor sources by default on dist tarballs) - rust-lang#133946 (coverage: Prefer to visit nodes whose predecessors have been visited) - rust-lang#134010 (fix ICE on type error in promoted) - rust-lang#134029 (coverage: Use a query to find counters/expressions that must be zero) - rust-lang#134071 (Configure renovatebot) - rust-lang#134102 (Miscellaneous fixes for nix-dev-shell) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131558 - sassman:feat/warnin-for-no-mangle-together-with-export-name, r=Urgau Lint on combining `#[no_mangle]` and `#[export_name]` This is my very first contribution to the compiler, even though I read the [chapter about lints](https://rustc-dev-guide.rust-lang.org/diagnostics.html) I'm not very certain that this ~~new lint is done right as a builtin lint~~ PR is right. I appreciate any guidance on how to improve the code. - Add test for issue rust-lang#47446 - ~~Implement the new lint `mixed_export_name_and_no_mangle` as a builtin lint (not sure if that is the right way to go)~~ Extend `unused_attributes` lint - Add suggestion how to fix it <details> <summary>Old proposed new lint</summary> > The `mixed_export_name_and_no_mangle` lint detects usage of both `#[export_name]` and `#[no_mangle]` on the same item which results on `#[no_mangle]` being ignored. > > *warn-by-default* > > ### Example > > ```rust > #[no_mangle] // ignored > #[export_name = "foo"] // takes precedences > pub fn bar() {} > ``` > > ### Explanation > > The compiler will not respect the `#[no_mangle]` attribute when generating the symbol name for the function, as the `#[export_name]` attribute takes precedence. This can lead to confusion and is unnecessary. </details>
@rust-timer build 79254c6 |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (79254c6): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -3.0%, secondary -0.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 2.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (secondary -0.0%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 767.346s -> 766.133s (-0.16%) |
This is my very first contribution to the compiler, even though I read the chapter about lints I'm not very certain that this
new lint is done right as a builtin lintPR is right. I appreciate any guidance on how to improve the code.Implement the new lintExtendmixed_export_name_and_no_mangle
as a builtin lint (not sure if that is the right way to go)unused_attributes
lintOld proposed new lint
Fixes #47446