Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --No user code, just trying to compile my project. The is <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --:
Do you mind checking if this still ICEs on the most recent nightly?
I just did that now, and it looks like the issue is fixed on the latest nightly. (sorry should have tried that in first place!)
That's weird, because I can repro it (cross-compiling for from linux if it matters).
on the latest nightly?
yep: Also the version of winit from the report () is not the latest . I'm working on bisecting and reducing now
Wait, this actually ICEs on stable too and I didn't notice because rustc emitted a bunch of errors after the ICE (?!)
I've reduced it down to this (which is no longer macOS or aarch64 dependent): (The assignment to was of course something more reasonable in the original code, but now I can't seem to replace it without making the ICE go away) This failed to compile without ICE on 1.69: Regression in () searched nightlies: from nightly-2023-03-06 to nightly-2023-04-19 regressed nightly: nightly-2023-04-15 searched commit range: regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.6.6</summaryHost triple: x86_64-unknown-linux-gnu Reproduce with: </details label regression-from-stable-to-stable
Whoops, I seemed to have caused it I'll look into it!
WG-prioritization assigning priority (). label -I-prioritize +P-medium

Discussion:
// Fudge the receiver, so we can do new inference on it. let possible_rcvr_ty = possible_rcvr_ty.fold_with(&mut fudger); let method = self <del> .lookup_method( </del> <ins> .lookup_method_for_diagnostic( </ins> possible_rcvr_ty, segment, DUMMY_SP, call_expr, binding, <del> args, </del> ) .ok()?; // Unify the method signature with our incompatible arg, to

let Some(rcvr_ty) = self.node_ty_opt(rcvr.hir_id) else { continue; }; let rcvr_ty = rcvr_ty.fold_with(&mut fudger); let Ok(method) = <del> self.lookup_method(rcvr_ty, segment, DUMMY_SP, parent_expr, rcvr, args) </del> <ins> self.lookup_method_for_diagnostic(rcvr_ty, segment, DUMMY_SP, parent_expr, rcvr) </ins> else { continue; }; let ideal_rcvr_ty = rcvr_ty.fold_with(&mut fudger); let ideal_method = self <del> .lookup_method(ideal_rcvr_ty, segment, DUMMY_SP, parent_expr, rcvr, args) </del> <ins> .lookup_method_for_diagnostic(ideal_rcvr_ty, segment, DUMMY_SP, parent_expr, rcvr) </ins> .ok() .and_then(|method| { let _ = self.at(&ObligationCause::dummy(), self.param_env)

span: Span, self_expr: &'tcx hir::Expr<'tcx>, call_expr: &'tcx hir::Expr<'tcx>, <ins> skip_record_for_diagnostics: bool, </ins> } impl<'a, 'tcx> Deref for ConfirmContext<'a, 'tcx> {

let mut confirm_cx = ConfirmContext::new(self, span, self_expr, call_expr); confirm_cx.confirm(unadjusted_self_ty, pick, segment) } <ins> pub fn confirm_method_for_diagnostic( &self, span: Span, self_expr: &'tcx hir::Expr<'tcx>, call_expr: &'tcx hir::Expr<'tcx>, unadjusted_self_ty: Ty<'tcx>, pick: &probe::Pick<'tcx>, segment: &hir::PathSegment<'_>, ) -> ConfirmResult<'tcx> { let mut confirm_cx = ConfirmContext::new(self, span, self_expr, call_expr); confirm_cx.skip_record_for_diagnostics = true; confirm_cx.confirm(unadjusted_self_ty, pick, segment) } </ins> } impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {

self_expr: &'tcx hir::Expr<'tcx>, call_expr: &'tcx hir::Expr<'tcx>, ) -> ConfirmContext<'a, 'tcx> { <del> ConfirmContext { fcx, span, self_expr, call_expr } </del> <ins> ConfirmContext { fcx, span, self_expr, call_expr, skip_record_for_diagnostics: false } </ins> } fn confirm(

self.register_predicates(autoderef.into_obligations()); // Write out the final adjustments. <del> self.apply_adjustments(self.self_expr, adjustments); </del> <ins> if !self.skip_record_for_diagnostics { self.apply_adjustments(self.self_expr, adjustments); } </ins> target }

}); debug!("instantiate_method_substs: user_type_annotation={:?}", user_type_annotation); <del> self.fcx.write_user_type_annotation(self.call_expr.hir_id, user_type_annotation); </del> <ins> if !self.skip_record_for_diagnostics { self.fcx.write_user_type_annotation(self.call_expr.hir_id, user_type_annotation); } </ins> } self.normalize(self.span, substs)

Ok(result.callee) } <ins> pub fn lookup_method_for_diagnostic( &self, self_ty: Ty<'tcx>, segment: &hir::PathSegment<'_>, span: Span, call_expr: &'tcx hir::Expr<'tcx>, self_expr: &'tcx hir::Expr<'tcx>, ) -> Result<MethodCallee<'tcx>, MethodError<'tcx>> { let pick = self.lookup_probe_for_diagnostic( segment.ident, self_ty, call_expr, ProbeScope::TraitsInScope, None, )?; Ok(self .confirm_method_for_diagnostic(span, self_expr, call_expr, self_ty, &pick, segment) .callee) } </ins> #[instrument(level = "debug", skip(self, call_expr))] pub fn lookup_probe( &self,

<ins> pub trait NSWindow: Sized { fn frame(self) -> () { unimplemented!() } fn setFrame_display_(self, display: ()) {} } impl NSWindow for () {} pub struct NSRect {} use std::ops::Deref; struct MainThreadSafe<T = ()>(T); impl<T> Deref for MainThreadSafe<T> { type Target = T; fn deref(&self) -> &T { unimplemented!() } } fn main() { || { let ns_window = MainThreadSafe(()); // Don't record adjustments twice for `*ns_window` (*ns_window).frame(); ns_window.setFrame_display_(0); //~^ ERROR mismatched types }; } </ins>

<ins> error[E0308]: mismatched types --> $DIR/dont-record-adjustments-when-pointing-at-arg.rs:26:37 | LL |         ns_window.setFrame_display_(0); |                   ----------------- ^ expected `()`, found integer |                   | |                   arguments to this method are incorrect | note: method defined here --> $DIR/dont-record-adjustments-when-pointing-at-arg.rs:5:8 | LL |     fn setFrame_display_(self, display: ()) {} |        ^^^^^^^^^^^^^^^^^       ----------- error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>