rust/src/test/ui/auxiliary
bors 5a19ffe1c2 Auto merge of #86492 - hyd-dev:no-mangle-method, r=petrochenkov
Associated functions that contain extern indicator or have `#[rustc_std_internal_symbol]` are reachable

Previously these fails to link with ``undefined reference to `foo'``:

<details>
<summary>Example 1</summary>

```rs
struct AssocFn;

impl AssocFn {
    #[no_mangle]
    fn foo() {}
}

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f1244afcdd26e2a28445f6e82ca46b50))
</details>

<details>
<summary>Example 2</summary>

```rs
#![crate_name = "lib"]
#![crate_type = "lib"]

struct AssocFn;

impl AssocFn {
    #[no_mangle]
    fn foo() {}
}
```
```rs
extern crate lib;

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
</details>

But I believe they should link successfully, because this works:
<details>

```rs
#[no_mangle]
fn foo() {}

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=789b3f283ee6126f53939429103ed98d))
</details>

This PR fixes the problem, by adding associated functions that have "custom linkage" to `reachable_set`, just like normal functions.

I haven't tested whether #76211 and [Miri](https://github.com/rust-lang/miri/issues/1837) are fixed by this PR yet, but I'm submitting this anyway since this fixes the examples above.

I added a `run-pass` test that combines my two examples above, but I'm not sure if that's the right way to test this. Maybe I should add / modify an existing codegen test (`src/test/codegen/export-no-mangle.rs`?) instead?
2021-08-13 19:47:03 +00:00
..
augmented_assignments.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
blind-item-mixed-crate-use-item-foo.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
blind-item-mixed-crate-use-item-foo2.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
changing-crates-a1.rs Remove licenses 2018-12-25 21:08:33 -07:00
changing-crates-a2.rs Remove licenses 2018-12-25 21:08:33 -07:00
changing-crates-b.rs Remove licenses 2018-12-25 21:08:33 -07:00
check_static_recursion_foreign_helper.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
cond_plugin.rs Stabilize fn-like proc macros in expression, pattern and statement positions 2020-05-03 19:24:41 +03:00
crate-method-reexport-grrrrrrr2.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
debuginfo-lto-aux.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
default-ty-param-cross-crate-crate.rs Remove double trailing newlines 2019-04-22 16:57:01 +01:00
define-macro.rs Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00
edition-kw-macro-2015.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
edition-kw-macro-2018.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
empty-struct.rs Remove licenses 2018-12-25 21:08:33 -07:00
extern-statics.rs Update tests for extern block linting 2021-01-13 07:49:16 -05:00
fancy-panic.rs Silence non_fmt_panic from external macros. 2021-08-12 14:33:30 +02:00
hello_macro.rs Stabilize fn-like proc macros in expression, pattern and statement positions 2020-05-03 19:24:41 +03:00
impl_privacy_xc_1.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
impl_privacy_xc_2.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
inline_dtor.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
inner_static.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
issue-72470-lib.rs Add regression test for issue #72470 2020-10-04 07:54:02 -04:00
issue-76387.rs Bump LLVM for DeadArgElim fix 2020-10-22 18:37:03 -04:00
kinds_in_metadata.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
legacy-const-generics.rs Add #[rustc_legacy_const_generics] 2021-02-23 17:25:55 +00:00
link-cfg-works-transitive-dylib.rs Update tests for extern block linting 2021-01-13 07:49:16 -05:00
link-cfg-works-transitive-rlib.rs Update tests for extern block linting 2021-01-13 07:49:16 -05:00
linkage1.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
llvm_pr32379.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
lto-duplicate-symbols1.rs Update code to account for extern ABI requirement 2021-01-13 07:49:45 -05:00
lto-duplicate-symbols2.rs Update code to account for extern ABI requirement 2021-01-13 07:49:45 -05:00
lto-rustc-loads-linker-plugin.rs Store LLVM bitcode in object files, not compressed 2020-04-29 11:57:26 -07:00
msvc-data-only-lib.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
nested_item.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
no-mangle-associated-fn.rs Adjust #[no_mangle]-related checks and lints for impl items 2021-08-12 17:11:44 +08:00
noexporttypelib.rs Remove licenses 2018-12-25 21:08:33 -07:00
orphan-check-diagnostics.rs Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00
proc_macro_def.rs Stabilize fn-like proc macros in expression, pattern and statement positions 2020-05-03 19:24:41 +03:00
pub-and-stability.rs Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00
reachable-unnameable-items.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
reexport-should-still-link.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
removing-extern-crate.rs Remove licenses 2018-12-25 21:08:33 -07:00
rustc-rust-log-aux.rs Test building of libraries with rustc logging enabled 2020-10-29 00:00:00 +00:00
stability-cfg2.rs Require issue = "none" over issue = "0" in unstable attributes 2019-12-21 13:16:18 +02:00
svh-a-base.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
svh-b.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
typeid-intrinsic-aux1.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
typeid-intrinsic-aux2.rs tests: Move run-pass tests without naming conflicts to ui 2019-07-27 18:56:16 +03:00
using-target-feature-unstable.rs Remove MMX from Rust 2020-09-20 15:13:11 +02:00
weak-lang-items.rs Remove licenses 2018-12-25 21:08:33 -07:00
xc-private-method-lib.rs Moved issue tests to subdirs and normalised names. 2019-03-14 01:00:49 +00:00