patterns: reject raw pointers that are not just integers
This commit is contained in:
parent
3089c315b1
commit
bec88ad4aa
10 changed files with 92 additions and 32 deletions
|
@ -2217,13 +2217,14 @@ declare_lint! {
|
|||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// Previous versions of Rust allowed function pointers and wide raw pointers in patterns.
|
||||
/// Previous versions of Rust allowed function pointers and all raw pointers in patterns.
|
||||
/// While these work in many cases as expected by users, it is possible that due to
|
||||
/// optimizations pointers are "not equal to themselves" or pointers to different functions
|
||||
/// compare as equal during runtime. This is because LLVM optimizations can deduplicate
|
||||
/// functions if their bodies are the same, thus also making pointers to these functions point
|
||||
/// to the same location. Additionally functions may get duplicated if they are instantiated
|
||||
/// in different crates and not deduplicated again via LTO.
|
||||
/// in different crates and not deduplicated again via LTO. Pointer identity for memory
|
||||
/// created by `const` is similarly unreliable.
|
||||
pub POINTER_STRUCTURAL_MATCH,
|
||||
Allow,
|
||||
"pointers are not structural-match",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue