about summary refs log tree commit diff
path: root/src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-12-19 12:44:23 +0000
committerbors <bors@rust-lang.org>2022-12-19 12:44:23 +0000
commitb3145fea6a5c9f67cf8ac77f1c9ff9bb84b71c18 (patch)
tree8590419443b04c51ce8a0d4a4bb4722a2286d50f /src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
parent8a6aca35b500841b4af1b4d6ec3392c2a4a9e2e8 (diff)
parent691df70bbcab3a22a961fe4df839857af19f8413 (diff)
downloadrust-b3145fea6a5c9f67cf8ac77f1c9ff9bb84b71c18.tar.gz
rust-b3145fea6a5c9f67cf8ac77f1c9ff9bb84b71c18.zip
Auto merge of #10099 - Niki4tap:null_fn_lints, r=llogiq
Null fn lints

Adds lints to check for code, that assumes nullable `fn()`.

### Lint examples:

`transmute_null_to_fn`:
```rust
error: transmuting a known null pointer into a function pointer
  --> $DIR/transmute_null_to_fn.rs:9:23
   |
LL |         let _: fn() = std::mem::transmute(std::ptr::null::<()>());
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior
   |
   = help: try wrapping your function pointer type in `Option<T>` instead, and using `None` as a null pointer value
```

`fn_null_check`:
```rust
error: function pointer assumed to be nullable, even though it isn't
  --> $DIR/fn_null_check.rs:13:8
   |
LL |     if (fn_ptr as *mut ()).is_null() {}
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: try wrapping your function pointer type in `Option<T>` instead, and using `is_none` to check for null pointer value
```

Closes #1644

---

changelog: Improvement: [`transmuting_null`]: Now detects `const` pointers to all types
[#10099](https://github.com/rust-lang/rust-clippy/pull/10099)
changelog: New lint: [`transmute_null_to_fn`]
[#10099](https://github.com/rust-lang/rust-clippy/pull/10099)
changelog: New lint: [`fn_null_check`]
[#10099](https://github.com/rust-lang/rust-clippy/pull/10099)
<!-- changelog_checked (This is just a flag for me, please don't add it manually) -->
Diffstat (limited to 'src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs')
0 files changed, 0 insertions, 0 deletions