]> git.lizzy.rs Git - rust.git/commitdiff
Document future incompat lints
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 21 Sep 2020 12:27:14 +0000 (14:27 +0200)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 21 Sep 2020 12:27:14 +0000 (14:27 +0200)
compiler/rustc_session/src/lint/builtin.rs

index 919aaf81ed207adccffd2296ce8cc81d9c51d1f0..966b8f7e5f328b0e31af921ec6fdec7bff3002c8 100644 (file)
     ///     }
     /// }
     /// ```
+    ///
+    /// ### Explanation
+    ///
+    /// Previous versions of Rust allowed function pointers and wide 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.
     pub POINTER_STRUCTURAL_MATCH,
     Allow,
     "pointers are not structural-match",
     ///     }
     /// }
     /// ```
+    ///
+    /// ### Explanation
+    ///
+    /// Previous versions of Rust accepted constants in patterns, even if those constants's types
+    /// did not have `PartialEq` derived. Thus the compiler falls back to runtime execution of
+    /// `PartialEq`, which can report that two constants are not equal even if they are
+    /// bit-equivalent.
     pub NONTRIVIAL_STRUCTURAL_MATCH,
     Warn,
     "constant used in pattern of non-structural-match type and the constant's initializer \