Rollup merge of #149479 - reddevilmidzy:E0591, r=chenyukang
Fix indent in E0591.md It currently looks like this. <img width="1389" height="595" alt="image" src="https://github.com/user-attachments/assets/5336eebd-42a6-43c6-9127-9278cd82a9c2" /> https://doc.rust-lang.org/nightly/error_codes/E0591.html So I can't run it, and the copied code has `#` in front.
This commit is contained in:
commit
6900946597
2 changed files with 12 additions and 12 deletions
|
|
@ -62,14 +62,14 @@ This pattern should be rewritten. There are a few possible ways to do this:
|
|||
and do the cast in the fn body (the preferred option)
|
||||
- cast the fn item of a fn pointer before calling transmute, as shown here:
|
||||
|
||||
```
|
||||
# extern "C" fn foo(_: Box<i32>) {}
|
||||
# use std::mem::transmute;
|
||||
# unsafe {
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_));
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too
|
||||
# }
|
||||
```
|
||||
```
|
||||
# extern "C" fn foo(_: Box<i32>) {}
|
||||
# use std::mem::transmute;
|
||||
# unsafe {
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_));
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too
|
||||
# }
|
||||
```
|
||||
|
||||
The same applies to transmutes to `*mut fn()`, which were observed in practice.
|
||||
Note though that use of this type is generally incorrect.
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ This pattern should be rewritten. There are a few possible ways to do this:
|
|||
and do the cast in the fn body (the preferred option)
|
||||
- cast the fn item of a fn pointer before calling transmute, as shown here:
|
||||
|
||||
```
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_));
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too
|
||||
```
|
||||
```
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_));
|
||||
let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too
|
||||
```
|
||||
|
||||
The same applies to transmutes to `*mut fn()`, which were observed in practice.
|
||||
Note though that use of this type is generally incorrect.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue