Skip to content

Commit f20fc59

Browse files
authoredJun 13, 2024
Rollup merge of rust-lang#123962 - oli-obk:define_opaque_types5, r=lcnr
change method resolution to constrain hidden types instead of rejecting method candidates Some of these are in probes and may affect inference. This is therefore a breaking change. This allows new code to compile on stable: ```rust trait Trait {} impl Trait for u32 {} struct Bar<T>(T); impl Bar<u32> { fn foo(self) {} } fn foo(x: bool) -> Bar<impl Sized> { if x { let x = foo(false); x.foo(); //^ this used to not find the `foo` method, because while we did equate `x`'s type with possible candidates, we didn't allow opaque type inference while doing so } todo!() } ``` r? `@compiler-errors` fixes rust-lang#121404 cc rust-lang#116652
2 parents 37a826f + 9cf60ee commit f20fc59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+922
-79
lines changed
 

‎compiler/rustc_hir_typeck/src/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
628628
return;
629629
};
630630

631-
let pick = self.confirm_method(
631+
let pick = self.confirm_method_for_diagnostic(
632632
call_expr.span,
633633
callee_expr,
634634
call_expr,

‎compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14181418
let impl_ty = self.normalize(span, tcx.type_of(impl_def_id).instantiate(tcx, args));
14191419
let self_ty = self.normalize(span, self_ty);
14201420
match self.at(&self.misc(span), self.param_env).eq(
1421-
DefineOpaqueTypes::No,
1421+
DefineOpaqueTypes::Yes,
14221422
impl_ty,
14231423
self_ty,
14241424
) {

0 commit comments

Comments
 (0)