rust/compiler/rustc_lint/src
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
..
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
array_into_iter.rs Link to edition guide instead of issues for 2021 lints. 2021-08-09 17:45:01 +02:00
builtin.rs Auto merge of #86492 - hyd-dev:no-mangle-method, r=petrochenkov 2021-08-13 19:47:03 +00:00
context.rs Use a multipart suggestion for the parentheses 2021-08-03 21:23:29 +02:00
early.rs Add additional missing lint handling logic 2021-07-17 23:03:58 -05:00
internal.rs Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk 2021-07-13 15:06:10 +00:00
late.rs Add inferred args to typeck 2021-07-25 07:28:51 +00:00
levels.rs Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa 2021-08-01 09:15:15 +00:00
lib.rs Warn on inert attributes used on bang macro invocation 2021-07-19 17:49:28 -05:00
methods.rs Fix doctest 2020-10-26 18:19:49 -04:00
non_ascii_idents.rs Stablize non_ascii_idents feature. 2021-04-08 02:52:00 +08:00
non_fmt_panic.rs Silence non_fmt_panic from external macros. 2021-08-12 14:33:30 +02:00
nonstandard_style.rs Adjust #[no_mangle]-related checks and lints for impl items 2021-08-12 17:11:44 +08:00
noop_method_call.rs Warn in doc test 2021-03-03 11:23:33 +01:00
passes.rs Add inferred args to typeck 2021-07-25 07:28:51 +00:00
redundant_semicolon.rs Lint on redundant trailing semicolon after item 2020-12-29 16:30:02 -05:00
tests.rs Update to last upstream version 2021-07-08 17:14:28 +02:00
traits.rs feat(rustc_lint): add dyn_drop 2021-07-18 07:55:57 -07:00
types.rs clippy::useless_format 2021-07-25 12:26:03 +02:00
unused.rs Apply review suggestion 2021-07-31 06:21:52 +09:00