summary refs log tree commit diff
path: root/compiler/rustc_session/src
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-09-21 14:27:14 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-09-21 14:27:14 +0200
commitf7eceef653c791ee9f5eef7728c50295d6808e14 (patch)
tree1d4737e1363f5441ccc202a6b7b233581cd67f8d /compiler/rustc_session/src
parentadf98ab2dc6b3d8332873d41f3371a839b4e9df1 (diff)
downloadrust-f7eceef653c791ee9f5eef7728c50295d6808e14.tar.gz
rust-f7eceef653c791ee9f5eef7728c50295d6808e14.zip
Document future incompat lints
Diffstat (limited to 'compiler/rustc_session/src')
-rw-r--r--compiler/rustc_session/src/lint/builtin.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/lint/builtin.rs b/compiler/rustc_session/src/lint/builtin.rs
index 919aaf81ed2..966b8f7e5f3 100644
--- a/compiler/rustc_session/src/lint/builtin.rs
+++ b/compiler/rustc_session/src/lint/builtin.rs
@@ -2207,6 +2207,16 @@ declare_lint! {
     ///     }
     /// }
     /// ```
+    ///
+    /// ### 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",
@@ -2246,6 +2256,13 @@ declare_lint! {
     ///     }
     /// }
     /// ```
+    ///
+    /// ### 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 \