Commit 56e1808
committed
refactor: reorganize_definitions: use the fallback/C ABI instead of Rust
Both sites now use `Abi::FALLBACK` (= `Abi::C { unwind: false }`).
`Regression test: `test_reorganize_implicit_extern`
(`tests/snapshots/reorganize_implicit_extern.rs`); on pre-fix code its
implicit-`extern` declaration fails to merge with the `extern "C"` duplicate,
producing an `extern "Rust"` block and a spurious `compute_1` rename.
`reorganize_definitions.rs:843-847` and `:1779-1782` both do:
```rust
let abi = m.abi.and_then(|abi| abi::lookup(&abi.symbol.as_str())).unwrap_or(Abi::Rust);
```
Rust's default ABI for `extern {}` blocks is `"C"` (rustc's own lowering uses
`Abi::FALLBACK`, which is `Abi::C`). Consequences:
- An implicit `extern { fn foo(); }` block never dedups against an
`extern "C" { fn foo(); }` declaration — the ABI-mismatch `continue` at
`:2144` in `find_foreign_item` skips it.
- Worse, its items are re-emitted by `into_items` via
`mk().extern_(Abi::Rust)` (`:1990`), silently changing the declared ABI of
foreign functions.
Latent only because transpiled code usually writes `extern "C"` explicitly.
Fix: fall back to `Abi::C { unwind: false }` (or `Abi::FALLBACK`).1 parent fae12b7 commit 56e1808
2 files changed
Lines changed: 9 additions & 10 deletions
File tree
- c2rust-refactor
- src/transform
- tests/snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
881 | 881 | | |
882 | 882 | | |
883 | 883 | | |
| 884 | + | |
| 885 | + | |
884 | 886 | | |
885 | 887 | | |
886 | 888 | | |
887 | | - | |
| 889 | + | |
888 | 890 | | |
889 | 891 | | |
890 | 892 | | |
| |||
1847 | 1849 | | |
1848 | 1850 | | |
1849 | 1851 | | |
| 1852 | + | |
| 1853 | + | |
1850 | 1854 | | |
1851 | 1855 | | |
1852 | 1856 | | |
1853 | | - | |
| 1857 | + | |
1854 | 1858 | | |
1855 | 1859 | | |
1856 | 1860 | | |
| |||
Lines changed: 3 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 26 | + | |
32 | 27 | | |
33 | 28 | | |
34 | | - | |
| 29 | + | |
35 | 30 | | |
36 | 31 | | |
37 | 32 | | |
| |||
0 commit comments