@@ -2166,10 +2166,12 @@ pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool { |
|
|
2166 |
2166 |
/// |
2167 |
2167 |
/// This is the same as `f == g`, but using this function makes clear that the potentially |
2168 |
2168 |
/// surprising semantics of function pointer comparison are involved. |
2169 |
|
-/// There are very few guarantees about how functions are compiled and they have no intrinsic |
|
2169 |
+/// |
|
2170 |
+/// There are **very few guarantees** about how functions are compiled and they have no intrinsic |
2170 |
2171 |
/// “identity”; in particular, this comparison: |
2171 |
2172 |
/// |
2172 |
2173 |
/// * May return `true` unexpectedly, in cases where functions are equivalent. |
|
2174 |
+/// |
2173 |
2175 |
/// For example, the following program is likely (but not guaranteed) to print `(true, true)` |
2174 |
2176 |
/// when compiled with optimization: |
2175 |
2177 |
/// |
@@ -2182,6 +2184,7 @@ pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool { |
|
|
2182 |
2184 |
/// ``` |
2183 |
2185 |
/// |
2184 |
2186 |
/// * May return `false` in any case. |
|
2187 |
+/// |
2185 |
2188 |
/// This is particularly likely with generic functions but may happen with any function. |
2186 |
2189 |
/// (From an implementation perspective, this is possible because functions may sometimes be |
2187 |
2190 |
/// processed more than once by the compiler, resulting in duplicate machine code.) |
@@ -2207,7 +2210,6 @@ pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool { |
|
|
2207 |
2210 |
/// ``` |
2208 |
2211 |
/// |
2209 |
2212 |
/// [subtype]: https://doc.rust-lang.org/reference/subtyping.html |
2210 |
|
- |
2211 |
2213 |
#[unstable(feature = "ptr_fn_addr_eq", issue = "129322")] |
2212 |
2214 |
#[inline(always)] |
2213 |
2215 |
#[must_use = "function pointer comparison produces a value"] |