This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
compiler/rustc_session/src/lint Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -2207,6 +2207,16 @@ declare_lint! {
2207
2207
/// }
2208
2208
/// }
2209
2209
/// ```
2210
+ ///
2211
+ /// ### Explanation
2212
+ ///
2213
+ /// Previous versions of Rust allowed function pointers and wide raw pointers in patterns.
2214
+ /// While these work in many cases as expected by users, it is possible that due to
2215
+ /// optimizations pointers are "not equal to themselves" or pointers to different functions
2216
+ /// compare as equal during runtime. This is because LLVM optimizations can deduplicate
2217
+ /// functions if their bodies are the same, thus also making pointers to these functions point
2218
+ /// to the same location. Additionally functions may get duplicated if they are instantiated
2219
+ /// in different crates and not deduplicated again via LTO.
2210
2220
pub POINTER_STRUCTURAL_MATCH ,
2211
2221
Allow ,
2212
2222
"pointers are not structural-match" ,
@@ -2246,6 +2256,13 @@ declare_lint! {
2246
2256
/// }
2247
2257
/// }
2248
2258
/// ```
2259
+ ///
2260
+ /// ### Explanation
2261
+ ///
2262
+ /// Previous versions of Rust accepted constants in patterns, even if those constants's types
2263
+ /// did not have `PartialEq` derived. Thus the compiler falls back to runtime execution of
2264
+ /// `PartialEq`, which can report that two constants are not equal even if they are
2265
+ /// bit-equivalent.
2249
2266
pub NONTRIVIAL_STRUCTURAL_MATCH ,
2250
2267
Warn ,
2251
2268
"constant used in pattern of non-structural-match type and the constant's initializer \
You can’t perform that action at this time.
0 commit comments