Commit d63535c
authored
transpile: Avoid some identity transmutes for function pointers (#1510)
I noticed that in some cases, a transmute would be added between a K&R
style function declaration using `()` as the parameters, and a full type
with `(void)` as the parameters. Since both of those are translated to
the same Rust type, you'd end up with pointless transmute. This PR gates
the transmute to only happen if the two Rust types actually differ.File tree
2 files changed
+36
-22
lines changed- c2rust-transpile
- src/translator
- tests/snapshots
2 files changed
+36
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3495 | 3495 | | |
3496 | 3496 | | |
3497 | 3497 | | |
3498 | | - | |
3499 | | - | |
3500 | | - | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
3501 | 3502 | | |
3502 | | - | |
3503 | | - | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
3504 | 3506 | | |
3505 | 3507 | | |
3506 | 3508 | | |
| |||
4406 | 4408 | | |
4407 | 4409 | | |
4408 | 4410 | | |
4409 | | - | |
4410 | | - | |
4411 | | - | |
4412 | | - | |
4413 | | - | |
4414 | | - | |
| 4411 | + | |
| 4412 | + | |
| 4413 | + | |
| 4414 | + | |
| 4415 | + | |
| 4416 | + | |
| 4417 | + | |
| 4418 | + | |
| 4419 | + | |
| 4420 | + | |
| 4421 | + | |
| 4422 | + | |
| 4423 | + | |
| 4424 | + | |
| 4425 | + | |
| 4426 | + | |
| 4427 | + | |
| 4428 | + | |
| 4429 | + | |
| 4430 | + | |
4415 | 4431 | | |
4416 | | - | |
| 4432 | + | |
4417 | 4433 | | |
4418 | | - | |
4419 | | - | |
4420 | | - | |
4421 | | - | |
4422 | | - | |
4423 | | - | |
| 4434 | + | |
| 4435 | + | |
| 4436 | + | |
| 4437 | + | |
| 4438 | + | |
| 4439 | + | |
4424 | 4440 | | |
4425 | 4441 | | |
4426 | 4442 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 47 | + | |
| 48 | + | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
| |||
0 commit comments