Change:
<!-- [31mICE[0m: Rustc '' 'thread 'rustc' panicked at 'coerceborrowedpointer had no error'', 'thread 'rustc' panicked at 'coerceborrowedpointer had no error'' File: --auto-reduced (treereduce-rust): &lt;details&lt;summary&lt;strongoriginal code&lt;/strong&lt;/summary&lt;poriginal: </p</detailsVersion 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<!-- query stack: [typeck] type-checking [analysis] running analysis passes on this crate --
Regression in there are no individual builds of the commits yet tho :sweat_smile:
I would guess cc

Discussion:
return None; }; <del> if new_ty.references_error() { return None; } </del> self.state.steps.push((self.state.cur_ty, kind)); debug!( "autoderef stage #{:?} is {:?} from {:?}",

debug!("overloaded_deref_ty({:?})", ty); let tcx = self.infcx.tcx; <ins> if ty.references_error() { return None; } </ins> // <ty as Deref> let trait_ref = ty::TraitRef::new(tcx, tcx.lang_items().deref_trait()?, [ty]); let cause = traits::ObligationCause::misc(self.span, self.body_id);

let receiver_ty = sig.inputs()[0]; let receiver_ty = wfcx.normalize(span, None, receiver_ty); <ins> // If the receiver already has errors reported, consider it valid to avoid // unnecessary errors (#58712). if receiver_ty.references_error() { return Ok(()); } </ins> if tcx.features().arbitrary_self_types { if !receiver_is_valid(wfcx, span, receiver_ty, self_ty, true) { // Report error; `arbitrary_self_types` was enabled.

} } else { debug!("receiver_is_valid: type `{:?}` does not deref to `{:?}`", receiver_ty, self_ty); <del> // If the receiver already has errors reported due to it, consider it valid to avoid // unnecessary errors (#58712). return receiver_ty.references_error(); </del> <ins> return false; </ins> } }

<del> // Regression test for an ICE: https://github.com/rust-lang/rust/issues/120884 </del> <ins> // Test that we don't ICE for coercions with type errors. </ins> // We still need to properly go through coercions between types with errors instead of // shortcutting and returning success, because we need the adjustments for building the MIR. pub fn has_error() -> TypeError {} //~^ ERROR cannot find type `TypeError` in this scope <ins> // https://github.com/rust-lang/rust/issues/120884 // Casting a function item to a data pointer in valid in HIR, but invalid in MIR. // We need an adjustment (ReifyFnPointer) to insert a cast from the function item // to a function pointer as a separate MIR statement. </ins> pub fn cast() -> *const u8 { <del> // Casting a function item to a data pointer in valid in HIR, but invalid in MIR. // We need an adjustment (ReifyFnPointer) to insert a cast from the function item // to a function pointer as a separate MIR statement. </del> has_error as *const u8 } <ins> // https://github.com/rust-lang/rust/issues/120945 // This one ICEd, because we skipped the builtin deref from `&TypeError` to `TypeError`. pub fn autoderef_source(e: &TypeError) { //~^ ERROR cannot find type `TypeError` in this scope autoderef_target(e) } pub fn autoderef_target(_: &TypeError) {} //~^ ERROR cannot find type `TypeError` in this scope </ins> fn main() {}

LL | pub fn has_error() -> TypeError {} |                       ^^^^^^^^^ not found in this scope <del> error: aborting due to 1 previous error </del> <ins> error[E0412]: cannot find type `TypeError` in this scope --> $DIR/type-errors.rs:18:29 | LL | pub fn autoderef_source(e: &TypeError) { |                             ^^^^^^^^^ not found in this scope error[E0412]: cannot find type `TypeError` in this scope --> $DIR/type-errors.rs:23:29 | LL | pub fn autoderef_target(_: &TypeError) {} |                             ^^^^^^^^^ not found in this scope error: aborting due to 3 previous errors </ins> For more information about this error, try `rustc --explain E0412`.