rust
rust copied to clipboard
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 I'm not very certain that this new lint is done right as a builtin lint. I appreciate any guidance on how to improve the code.
- Add test for issue #47446
- Implement the new lint
mixed_export_name_and_no_mangleas a builtin lint (not sure if that is the right way to go) - Add suggestion how to fix it
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
#[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.
Fixes rust-lang/rust#47446
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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:
@rustbot author: the review is finished, PR author should check the comments and take action accordingly@rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
The job mingw-check failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#16 2.668 Building wheels for collected packages: reuse
#16 2.669 Building wheel for reuse (pyproject.toml): started
#16 2.918 Building wheel for reuse (pyproject.toml): finished with status 'done'
#16 2.919 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132715 sha256=dfa09868353292d98f811d3efdb0d54d07389e808efc71d68e3b93c514bf8bec
#16 2.919 Stored in directory: /tmp/pip-ephem-wheel-cache-s7fulklw/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#16 2.922 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#16 3.310 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#16 3.310 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#16 DONE 3.4s
---
finished in 13.667 seconds
##[endgroup]
Build completed successfully in 0:00:46
+ git reset --hard HEAD~1
HEAD is now at 9f0fbbf0 Merge aa419ee4e8a3348663dc27c816eac1016031edf2 into f4966590d8edd5f493a1aab04016b94a75494329
##[group]Building bootstrap
Finished `dev` profile [unoptimized] target(s) in 0.08s
##[endgroup]
cargo:warning=GNU compiler is not supported for this target
---
error: cannot find attribute `suggestion` in this scope
--> compiler/rustc_lint/src/lints.rs:3072:7
|
3072 | #[suggestion(style = "verbose", code = "", applicability = "machine-applicable")]
Checking rustc_ty_utils v0.0.0 (/checkout/compiler/rustc_ty_utils)
Checking rustc_ty_utils v0.0.0 (/checkout/compiler/rustc_ty_utils)
error[E0277]: the trait bound `for<'a> BuiltinMixedExportNameAndNoMangle: LintDiagnostic<'a, ()>` is not satisfied
|
|
3079 | cx.emit_span_lint(MIXED_EXPORT_NAME_AND_NO_MANGLE, span_export_name, decorate);
| -------------- required by a bound introduced by this call ^^^^^^^^ the trait `for<'a> LintDiagnostic<'a, ()>` is not implemented for `BuiltinMixedExportNameAndNoMangle`
note: required by a bound in `LintContext::emit_span_lint`
--> compiler/rustc_lint/src/context.rs:583:25
|
|
579 | fn emit_span_lint<S: Into<MultiSpan>>(
...
...
583 | decorator: impl for<'a> LintDiagnostic<'a, ()>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `LintContext::emit_span_lint`
Checking rustc_privacy v0.0.0 (/checkout/compiler/rustc_privacy)
Checking rustc_hir_analysis v0.0.0 (/checkout/compiler/rustc_hir_analysis)
For more information about this error, try `rustc --explain E0277`.
error: could not compile `rustc_lint` (lib) due to 5 previous errors
@Urgau Do you know why all these lints are prefixed by Builtin? Aren't all the lints in the compiler built-in by definition?
Do you know why all these lints are prefixed by
Builtin? Aren't all the lints in the compiler built-in by definition?
It's probably a prefix for the lints defined inside compiler/rustc_lint/src/builtin.rs.
Lints outside of that file don't seems to have it at least.
The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:20950f2ccee3dff53a038adf5c1cf05231c0b30772617126a5f6478a66316a29cba9aead69f7bb0004886d32c1f8e6287542cf6d25130711c82d16a66201d4fe:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
+ | ^^^^^^^^^^^^
+ = note: `#[warn(mixed_export_name_and_no_mangle)]` on by default
+ help: remove the `no_mangle` attribute
+ |
+ LL - #[no_mangle]
+
73 error[E0787]: the `asm!` macro is not allowed in naked functions
74 --> $DIR/naked-functions.rs:13:5
75 |
---
To only update this specific test, also pass `--test-args asm/naked-functions.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/asm/naked-functions.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/asm/naked-functions" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/asm/naked-functions/auxiliary"
--- stderr -------------------------------
--- stderr -------------------------------
error: the `in` operand cannot be used with `naked_asm!`
|
|
LL | naked_asm!("/* {0} */", in(reg) a)
| ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it
error: the `in` operand cannot be used with `naked_asm!`
|
|
LL | in(reg) a,
| ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it
error: the `noreturn` option cannot be used with `naked_asm!`
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:88:32
|
|
LL | naked_asm!("", options(noreturn));
| ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly
error: the `nomem` option cannot be used with `naked_asm!`
|
|
LL | naked_asm!("", options(nomem, preserves_flags));
| ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly
error: the `preserves_flags` option cannot be used with `naked_asm!`
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:106:35
|
|
LL | naked_asm!("", options(nomem, preserves_flags));
| ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly
error: the `readonly` option cannot be used with `naked_asm!`
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:113:28
|
|
LL | naked_asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly
error: the `nostack` option cannot be used with `naked_asm!`
|
|
LL | naked_asm!("", options(readonly, nostack), options(pure));
| ^^^^^^^ the `nostack` option is not meaningful for global-scoped inline assembly
error: the `pure` option cannot be used with `naked_asm!`
|
|
LL | naked_asm!("", options(readonly, nostack), options(pure));
| ^^^^ the `pure` option is not meaningful for global-scoped inline assembly
error: the `may_unwind` option cannot be used with `naked_asm!`
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:121:28
|
LL | naked_asm!("", options(may_unwind));
---
error[E0787]: the `asm!` macro is not allowed in naked functions
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:13:5
|
LL | asm!("", options(raw));
| ^^^^^^^^^^^^^^^^^^^^^^ consider using the `naked_asm!` macro instead
error: patterns not allowed in naked function parameters
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:25:5
|
LL | mut a: u32,
LL | mut a: u32,
| ^^^^^
error: patterns not allowed in naked function parameters
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:27:5
|
LL | &b: &i32,
error: patterns not allowed in naked function parameters
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:29:6
|
|
LL | (None | Some(_)): Option<std::ptr::NonNull<u8>>,
error: patterns not allowed in naked function parameters
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:31:5
|
|
LL | P { x, y }: P,
error: referencing function parameters is not allowed in naked functions
##[error] --> /checkout/tests/ui/asm/naked-functions.rs:40:5
|
|
LL | a + 1
| ^
|
= help: follow the calling convention in asm block to use parameters
error[E0787]: naked functions must contain a single `naked_asm!` invocation
|
|
LL | pub unsafe extern "C" fn inc(a: u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | //~^ ERROR naked functions must contain a single `naked_asm!` invocation
LL | a + 1
| ----- not allowed in naked functions
error[E0787]: naked functions must contain a single `naked_asm!` invocation
|
|
LL | pub unsafe extern "C" fn inc_closure(a: u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | //~^ ERROR naked functions must contain a single `naked_asm!` invocation
LL | (|| a + 1)()
| ------------ not allowed in naked functions
error[E0787]: naked functions must contain a single `naked_asm!` invocation
|
LL | pub unsafe extern "C" fn unsupported_operands() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | //~^ ERROR naked functions must contain a single `naked_asm!` invocation
LL | let mut a = 0usize;
| ------------------- not allowed in naked functions
LL | let mut b = 0usize;
| ------------------- not allowed in naked functions
LL | let mut c = 0usize;
| ------------------- not allowed in naked functions
LL | let mut d = 0usize;
| ------------------- not allowed in naked functions
LL | let mut e = 0usize;
| ------------------- not allowed in naked functions
error[E0787]: naked functions must contain a single `naked_asm!` invocation
|
LL | pub extern "C" fn missing_assembly() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0787]: naked functions must contain a single `naked_asm!` invocation
|
LL | pub extern "C" fn too_many_asm_blocks() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
---
| ^
|
= help: follow the calling convention in asm block to use parameters
error[E0787]: naked functions must contain a single `naked_asm!` invocation
|
LL | pub extern "C" fn inner(y: usize) -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | //~^ ERROR naked functions must contain a single `naked_asm!` invocation
LL | *&y
| --- not allowed in naked functions
warning: Rust ABI is unsupported in naked functions
##[warning] --> /checkout/tests/ui/asm/naked-functions.rs:126:1
|
|
LL | pub unsafe fn default_abi() {
|
= note: `#[warn(undefined_naked_function_abi)]` on by default
warning: Rust ABI is unsupported in naked functions
---
---- [ui] tests/ui/attributes/mixed_export_name_and_no_mangle.rs stdout ----
error: ui test compiled successfully!
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle/auxiliary"
--- stderr -------------------------------
warning: the attribute `export_name` may not be used in combination with `no_mangle`
##[warning] --> /checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs:4:1
|
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 --bless. Feel free to apply either, as you prefer, to relevant cases like that "naked" function.
The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:c32c805632780b5c1de330e3f44561b336c2efe163bc0990acb392390157a8e1d9f855d75914a239aa40c49d77f4a837247d05d2f8d46f554b98e1f46712a3e3:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
To only update this specific test, also pass `--test-args attributes/mixed_export_name_and_no_mangle.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle/auxiliary"
--- stderr -------------------------------
error: the attribute `export_name` may not be used in combination with `no_mangle`
##[error] --> /checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs:5:1
|
The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:c32c805632780b5c1de330e3f44561b336c2efe163bc0990acb392390157a8e1d9f855d75914a239aa40c49d77f4a837247d05d2f8d46f554b98e1f46712a3e3:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
failures:
---- [ui] tests/ui/attributes/mixed_export_name_and_no_mangle.rs stdout ----
error: /checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs:5: unexpected error: '5:1: 5:23: the attribute `export_name` may not be used in combination with `no_mangle` [mixed_export_name_and_no_mangle]'
error: 1 unexpected errors found, 0 expected errors not found
status: exit status: 1
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle/auxiliary"
--- unexpected errors (from JSON output) ---
--- unexpected errors (from JSON output) ---
ERROR line 5: 5:1: 5:23: the attribute `export_name` may not be used in combination with `no_mangle` [mixed_export_name_and_no_mangle]
thread '[ui] tests/ui/attributes/mixed_export_name_and_no_mangle.rs' panicked at src/tools/compiletest/src/runtest.rs:768:13:
errors differ from expected
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:c32c805632780b5c1de330e3f44561b336c2efe163bc0990acb392390157a8e1d9f855d75914a239aa40c49d77f4a837247d05d2f8d46f554b98e1f46712a3e3:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
Downloaded boml v0.3.1
Compiling boml v0.3.1
Compiling y v0.1.0 (/checkout/compiler/rustc_codegen_gcc/build_system)
Finished `release` profile [optimized] target(s) in 3.84s
Running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-codegen/x86_64-unknown-linux-gnu/release/y test --use-system-gcc --use-backend gcc --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc --release --mini-tests --std-tests`
Using system GCC
[BUILD] example
[AOT] mini_core_hello_world
/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc/mini_core_hello_world
abc
---
compiler/rustc_lint/src/builtin.rs - builtin::MIXED_EXPORT_NAME_AND_NO_MANGLE (line 3045)
test result: FAILED. 99 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.48s
error: doctest failed, to rerun pass `-p rustc_lint --doc`
local time: Mon Oct 14 07:35:47 UTC 2024
network time: Mon, 14 Oct 2024 07:35:47 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
Now the tests run all green and I have cleaned up the other test that used both no_mangle and export_name and simply removed the no_mangle in tests/ui/asm/naked-functions.rs.
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 codegen_fn_attrs function in compiler/rustc_codegen_ssa/src/codegen_attrs.rs.
You can look at the check_link_name_xor_ordinal function for inspiration: https://github.com/rust-lang/rust/blob/f6648f252a05a0a46c865d7ec836b46290613bf9/compiler/rustc_codegen_ssa/src/codegen_attrs.rs#L648
As well as TyCtxt::emit_node_span_lint for emitting the lint.
You will also need to move the lint definition into the rustc_lint_defs crate and import that crate in rustc_codegen_ssa.
@rustbot author
Thanks @Urgau for the guidance, I will refactor the code accordingly. The provided example seems pretty helpful to figure things out.
The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:c32c805632780b5c1de330e3f44561b336c2efe163bc0990acb392390157a8e1d9f855d75914a239aa40c49d77f4a837247d05d2f8d46f554b98e1f46712a3e3:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
---- [ui] tests/ui/attributes/mixed_export_name_and_no_mangle.rs stdout ----
error: ui test compiled successfully!
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle/auxiliary"
--- stderr -------------------------------
warning: unknown lint: `mixed_export_name_and_no_mangle`
##[warning] --> /checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs:1:9
|
@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 LintDiagnostic struct, that is now not anymore present.
If I did got this right then I will adjust the introduced error output expectation to fix the build error: https://github.com/rust-lang/rust/actions/runs/11332684748/job/31515339659?pr=131558#step:26:3779
Reminder, don't forget to use the rustbot review commands.
The job mingw-check failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#16 2.873 Building wheels for collected packages: reuse
#16 2.874 Building wheel for reuse (pyproject.toml): started
#16 3.117 Building wheel for reuse (pyproject.toml): finished with status 'done'
#16 3.118 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132720 sha256=026f3bb0f1aa8090b861fd0a0939cb1a782396d84c8aab7875096557d637a0f6
#16 3.118 Stored in directory: /tmp/pip-ephem-wheel-cache-acb335wx/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#16 3.121 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#16 3.499 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#16 3.500 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#16 DONE 3.6s
---
Checking rustc_lint v0.0.0 (/checkout/compiler/rustc_lint)
Checking rustc_ty_utils v0.0.0 (/checkout/compiler/rustc_ty_utils)
Checking rustc_privacy v0.0.0 (/checkout/compiler/rustc_privacy)
Checking rustc_codegen_ssa v0.0.0 (/checkout/compiler/rustc_codegen_ssa)
error[E0412]: cannot find type `LinterStateMixedExportNameAndNoMangle` in this scope
|
|
793 | impl LinterStateMixedExportNameAndNoMangle {
error[E0422]: cannot find struct, variant or union type `BuiltinMixedExportNameAndNoMangle` in module `errors`
|
|
819 | errors::BuiltinMixedExportNameAndNoMangle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `MixedExportNameAndNoMangle`
::: compiler/rustc_codegen_ssa/src/errors.rs:1098:1
|
|
1098 | pub(crate) struct MixedExportNameAndNoMangle {
| -------------------------------------------- similarly named struct `MixedExportNameAndNoMangle` defined here
Checking rustc_mir_build v0.0.0 (/checkout/compiler/rustc_mir_build)
Checking rustc_mir_build v0.0.0 (/checkout/compiler/rustc_mir_build)
error[E0433]: failed to resolve: use of undeclared type `LinterStateMixedExportNameAndNoMangle`
|
|
80 | let mut mixed_export_name_no_mangle_linter = LinterStateMixedExportNameAndNoMangle::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `LinterStateMixedExportNameAndNoMangle`
Some errors have detailed explanations: E0412, E0422, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `rustc_codegen_ssa` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
@rustbot review
@Urgau is happy with the state of this PR so triggering an FCP since that's what there is precedent for when adding a new lint.
cc @rust-lang/lang for visibility, this seems within t-compiler's remit but just in case you disagree
@rfcbot fcp merge
Team member @davidtwco has proposed to merge this. The next step is review by the rest of the tagged team members:
- [ ] @Aaron1011
- [x] @cjgillot
- [x] @compiler-errors
- [x] @davidtwco
- [x] @eddyb
- [x] @estebank
- [x] @jackh726
- [x] @lcnr
- [x] @matthewjasper
- [x] @nagisa
- [x] @oli-obk
- [x] @petrochenkov
- [x] @pnkfelix
- [ ] @wesleywiser
Concerns:
- ~~unjustified-new-lint~~ resolved by https://github.com/rust-lang/rust/pull/131558#issuecomment--1846995236
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
I don't mind this lint landing right now, but I can imagine a future where both attributes on the same function make quite some sense: symbol aliases. That way we might end up with well-specified behaviour for multiple #[export_name] attributes and #[no_mangle] being a simple alias for #[export_name=function_name!()]. From what I can tell this lint can be simply deprecated/disabled once such future behaviour materializes.
@nagisa symbol alias sounds interesting, then also multiple #[export_name] attributes must be supported, and #[no_mangle] would become a shortcut just as you described it.
Is there already an RFC or any tracking issue for this?
I guess I found the pre-RFC: https://internals.rust-lang.org/t/pre-rfc-defining-function-aliases/11424
This already fits into the existing UNUSED_ATTRIBUTES lint because #[no_mangle] is unused in this situation.
I don't think every tiny possible niche issue needs a separate lint.
@rfcbot concern unjustified-new-lint
The unused attribute lint sounds also reasonable.
Would it then be possible to indicate how to fix it and elaborate on the details as well?
I refactored according to the suggestions, but now the test fails as if the lint is not emitted at all anymore. Probably I just miss something, on the registration part.
The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:c32c805632780b5c1de330e3f44561b336c2efe163bc0990acb392390157a8e1d9f855d75914a239aa40c49d77f4a837247d05d2f8d46f554b98e1f46712a3e3:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
---- [ui] tests/ui/attributes/mixed_export_name_and_no_mangle.rs stdout ----
diff of stderr:
- warning: the `#[no_mangle]` attribute may not be used in combination with `#[export_name]`
- |
- LL | #[no_mangle]
- | ^^^^^^^^^^^^ `#[no_mangle]` is ignored
- |
- |
- note: `#[export_name = "foo"]` takes precedence
- |
- LL | #[export_name = "foo"]
- | ^^^^^^^^^^^^^^^^^^^^^^
- = note: `#[warn(unused_attributes)]` on by default
---
2 //@ run-rustfix
3 //@ check-pass
4
+ #[no_mangle]
+ //~^ WARN the `#[no_mangle]` attribute may not be used in combination with `#[export_name]`
5 #[export_name = "foo"]
7
The actual fixed differed from the expected fixed.
The actual fixed differed from the expected fixed.
Actual fixed saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle/mixed_export_name_and_no_mangle.fixed
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args attributes/mixed_export_name_and_no_mangle.rs`
error: 2 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle/auxiliary"
stderr: none
Does this work with the new unsafe attributes as well? For reference
@CryZe good question, I'm going to add a test for it, but I suspect it doesn't.
@CryZe it works for #[unsafe(no_mangle)] but,
The error message I would want should be this:
warning: the `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]`
But instead the attribute does not have the unsafe() surrounding, so it is
warning: the `#[no_mangle]` attribute may not be used in combination with `#[export_name]`
But with showing the spans this might be somehow confusing.
Where is the unsafe attribute handled anyways?
The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:c32c805632780b5c1de330e3f44561b336c2efe163bc0990acb392390157a8e1d9f855d75914a239aa40c49d77f4a837247d05d2f8d46f554b98e1f46712a3e3:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
19 LL - #[no_mangle]
20 |
21
- warning: the `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]`
+ warning: the `#[no_mangle]` attribute may not be used in combination with `#[export_name]`
24 |
25 LL | #[unsafe(no_mangle)]
- | ^^^^^^^^^^^^^^^^^^^^ #[unsafe(no_mangle)]` is ignored
+ | ^^^^^^^^^^^^^^^^^^^^ `#[no_mangle]` is ignored
27 |
28 note: `#[export_name]` takes precedence
30 |
30 |
31 LL | #[export_name = "baz"]
32 | ^^^^^^^^^^^^^^^^^^^^^^
- help: remove the #[unsafe(no_mangle)]` attribute
+ help: remove the `#[no_mangle]` attribute
34 |
35 LL - #[unsafe(no_mangle)]
37
38 warning: 2 warnings emitted
+
---
To only update this specific test, also pass `--test-args attributes/mixed_export_name_and_no_mangle.rs`
error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/attributes/mixed_export_name_and_no_mangle.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/attributes/mixed_export_name_and_no_mangle/auxiliary"
--- stderr -------------------------------
--- stderr -------------------------------
warning: the `#[no_mangle]` attribute may not be used in combination with `#[export_name]`
|
LL | #[no_mangle]
| ^^^^^^^^^^^^ `#[no_mangle]` is ignored
|
|
note: `#[export_name]` takes precedence
|
LL | #[export_name = "foo"]
| ^^^^^^^^^^^^^^^^^^^^^^
note: the lint level is defined here
---
|
LL - #[no_mangle]
|
warning: the `#[no_mangle]` attribute may not be used in combination with `#[export_name]`
|
LL | #[unsafe(no_mangle)]
| ^^^^^^^^^^^^^^^^^^^^ `#[no_mangle]` is ignored
|
|
note: `#[export_name]` takes precedence
|
|
LL | #[export_name = "baz"]
help: remove the `#[no_mangle]` attribute
|
|
LL - #[unsafe(no_mangle)]
warning: 2 warnings emitted
------------------------------------------