Skip to content

Commit 8dafd33

Browse files
committed
Auto merge of rust-lang#129521 - matthiaskrgr:rollup-uigv77m, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#128596 (stabilize const_fn_floating_point_arithmetic) - rust-lang#129199 (make writes_through_immutable_pointer a hard error) - rust-lang#129246 (Retroactively feature gate `ConstArgKind::Path`) - rust-lang#129290 (Pin `cc` to 1.0.105) - rust-lang#129323 (Implement `ptr::fn_addr_eq`) - rust-lang#129500 (remove invalid `TyCompat` relation for effects) - rust-lang#129501 (panicking: improve hint for Miri's RUST_BACKTRACE behavior) - rust-lang#129505 (interpret: ImmTy: tighten sanity checks in offset logic) - rust-lang#129510 (Fix `elided_named_lifetimes` in code) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c14cf57 + 0fe3746 commit 8dafd33

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

Diff for: core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
// Language features:
194194
// tidy-alphabetical-start
195195
#![cfg_attr(bootstrap, feature(asm_const))]
196+
#![cfg_attr(bootstrap, feature(const_fn_floating_point_arithmetic))]
196197
#![cfg_attr(bootstrap, feature(min_exhaustive_patterns))]
197198
#![feature(abi_unadjusted)]
198199
#![feature(adt_const_params)]
@@ -202,7 +203,6 @@
202203
#![feature(cfg_sanitize)]
203204
#![feature(cfg_target_has_atomic)]
204205
#![feature(cfg_target_has_atomic_equal_alignment)]
205-
#![feature(const_fn_floating_point_arithmetic)]
206206
#![feature(const_for)]
207207
#![feature(const_mut_refs)]
208208
#![feature(const_precise_live_drops)]

Diff for: core/src/marker.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,6 @@ pub mod effects {
10971097
pub trait TyCompat<T: ?Sized> {}
10981098

10991099
impl<T: ?Sized> TyCompat<T> for T {}
1100-
impl<T: ?Sized> TyCompat<T> for Maybe {}
11011100
impl<T: ?Sized> TyCompat<Maybe> for T {}
11021101

11031102
#[lang = "EffectsIntersection"]

Diff for: core/src/ptr/mod.rs

+27
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,33 @@ pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool {
21302130
(p as *const ()) == (q as *const ())
21312131
}
21322132

2133+
/// Compares the *addresses* of the two function pointers for equality.
2134+
///
2135+
/// Function pointers comparisons can have surprising results since
2136+
/// they are never guaranteed to be unique and could vary between different
2137+
/// code generation units. Furthermore, different functions could have the
2138+
/// same address after being merged together.
2139+
///
2140+
/// This is the same as `f == g` but using this function makes clear
2141+
/// that you are aware of these potentially surprising semantics.
2142+
///
2143+
/// # Examples
2144+
///
2145+
/// ```
2146+
/// #![feature(ptr_fn_addr_eq)]
2147+
/// use std::ptr;
2148+
///
2149+
/// fn a() { println!("a"); }
2150+
/// fn b() { println!("b"); }
2151+
/// assert!(!ptr::fn_addr_eq(a as fn(), b as fn()));
2152+
/// ```
2153+
#[unstable(feature = "ptr_fn_addr_eq", issue = "129322")]
2154+
#[inline(always)]
2155+
#[must_use = "function pointer comparison produces a value"]
2156+
pub fn fn_addr_eq<T: FnPtr, U: FnPtr>(f: T, g: U) -> bool {
2157+
f.addr() == g.addr()
2158+
}
2159+
21332160
/// Hash a raw pointer.
21342161
///
21352162
/// This can be used to hash a `&T` reference (which coerces to `*const T` implicitly)

Diff for: std/src/panicking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ fn default_hook(info: &PanicHookInfo<'_>) {
275275
if cfg!(miri) {
276276
let _ = writeln!(
277277
err,
278-
"note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` \
278+
"note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` \
279279
for the environment variable to have an effect"
280280
);
281281
}

0 commit comments

Comments
 (0)