Change:
<!-- [31mICE[0m: Rustc '' 'error: internal compiler error: Got a scalar pair where a scalar was expected', 'error: internal compiler error: Got a scalar pair where a scalar was expected' File: --code: Version information Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details
Regression in nightly-2023-11-09 ping
Good catch, thanks! should fix this.

Discussion:
use rustc_middle::ty::layout::{LayoutCx, LayoutOf, TyAndLayout}; use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt}; use rustc_span::DUMMY_SP; <del> use rustc_target::abi::VariantIdx; </del> <ins> use rustc_target::abi::{Abi, VariantIdx}; </ins> #[instrument(skip(ecx), level = "debug")] fn branches<'tcx>(

// Not all raw pointers are allowed, as we cannot properly test them for // equality at compile-time (see `ptr_guaranteed_cmp`). // However we allow those that are just integers in disguise. <del> // (We could allow wide raw pointers where both sides are integers in the future, // but for now we reject them.) let Ok(val) = ecx.read_scalar(place) else { </del> <ins> // First, get the pointer. Remember it might be wide! let Ok(val) = ecx.read_immediate(place) else { </ins> return Err(ValTreeCreationError::Other); }; <ins> // We could allow wide raw pointers where both sides are integers in the future, // but for now we reject them. if matches!(val.layout.abi, Abi::ScalarPair(..)) { return Err(ValTreeCreationError::Other); } let val = val.to_scalar(); </ins> // We are in the CTFE machine, so ptr-to-int casts will fail. // This can only be `Ok` if `val` already is an integer. let Ok(val) = val.try_to_int() else {

const D: *const [u8; 4] = b"abcd"; <ins> const STR: *const str = "abcd"; </ins> fn main() { match D { D => {} //~ERROR: behave unpredictably //~| previously accepted _ => {} } <ins> match STR { STR => {} //~ERROR: behave unpredictably //~| previously accepted _ => {} } </ins> }

= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861> error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. <del> --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:28:9 </del> <ins> --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:30:9 </ins> | LL |         D => {} |         ^

= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861> <del> error: aborting due to 3 previous errors </del> <ins> error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. --> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:36:9 | LL |         STR => {} |         ^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861> error: aborting due to 4 previous errors </ins>