Skip to content

Commit d9fec13

Browse files
Normalize xform_ret_ty after constrained
1 parent ff4653a commit d9fec13

File tree

11 files changed

+35
-45
lines changed

11 files changed

+35
-45
lines changed

compiler/rustc_hir_typeck/src/method/probe.rs

+30-8
Original file line numberDiff line numberDiff line change
@@ -1375,15 +1375,22 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
13751375
(xform_self_ty, xform_ret_ty) =
13761376
self.xform_self_ty(probe.item, impl_ty, impl_args);
13771377
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1378-
// FIXME: Weirdly, we normalize the ret ty in this candidate, but no other candidates.
1379-
xform_ret_ty = ocx.normalize(cause, self.param_env, xform_ret_ty);
1380-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1381-
Ok(()) => {}
1378+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1379+
match self.at(cause, self.param_env).eq(
1380+
DefineOpaqueTypes::No,
1381+
xform_self_ty,
1382+
self_ty,
1383+
) {
1384+
Ok(infer_ok) => {
1385+
ocx.register_infer_ok_obligations(infer_ok);
1386+
}
13821387
Err(err) => {
13831388
debug!("--> cannot relate self-types {:?}", err);
13841389
return ProbeResult::NoMatch;
13851390
}
13861391
}
1392+
// FIXME: Weirdly, we normalize the ret ty in this candidate, but no other candidates.
1393+
xform_ret_ty = ocx.normalize(cause, self.param_env, xform_ret_ty);
13871394
// Check whether the impl imposes obligations we have to worry about.
13881395
let impl_def_id = probe.item.container_id(self.tcx);
13891396
let impl_bounds =
@@ -1425,11 +1432,19 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14251432
infer::FnCall,
14261433
poly_trait_ref,
14271434
);
1435+
let trait_ref = ocx.normalize(cause, self.param_env, trait_ref);
14281436
(xform_self_ty, xform_ret_ty) =
14291437
self.xform_self_ty(probe.item, trait_ref.self_ty(), trait_ref.args);
14301438
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1431-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1432-
Ok(()) => {}
1439+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1440+
match self.at(cause, self.param_env).eq(
1441+
DefineOpaqueTypes::No,
1442+
xform_self_ty,
1443+
self_ty,
1444+
) {
1445+
Ok(infer_ok) => {
1446+
ocx.register_infer_ok_obligations(infer_ok);
1447+
}
14331448
Err(err) => {
14341449
debug!("--> cannot relate self-types {:?}", err);
14351450
return ProbeResult::NoMatch;
@@ -1452,8 +1467,15 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14521467
(xform_self_ty, xform_ret_ty) =
14531468
self.xform_self_ty(probe.item, trait_ref.self_ty(), trait_ref.args);
14541469
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1455-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1456-
Ok(()) => {}
1470+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1471+
match self.at(cause, self.param_env).eq(
1472+
DefineOpaqueTypes::No,
1473+
xform_self_ty,
1474+
self_ty,
1475+
) {
1476+
Ok(infer_ok) => {
1477+
ocx.register_infer_ok_obligations(infer_ok);
1478+
}
14571479
Err(err) => {
14581480
debug!("--> cannot relate self-types {:?}", err);
14591481
return ProbeResult::NoMatch;

compiler/rustc_trait_selection/src/traits/engine.rs

-13
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,6 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
129129
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
130130
}
131131

132-
pub fn eq_no_opaques<T: ToTrace<'tcx>>(
133-
&self,
134-
cause: &ObligationCause<'tcx>,
135-
param_env: ty::ParamEnv<'tcx>,
136-
expected: T,
137-
actual: T,
138-
) -> Result<(), TypeError<'tcx>> {
139-
self.infcx
140-
.at(cause, param_env)
141-
.eq(DefineOpaqueTypes::No, expected, actual)
142-
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
143-
}
144-
145132
/// Checks whether `expected` is a subtype of `actual`: `expected <: actual`.
146133
pub fn sub<T: ToTrace<'tcx>>(
147134
&self,

tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ where
2929

3030
fn main() {
3131
let mut list = RcNode::<i32>::new();
32-
//~^ ERROR trait bounds were not satisfied
32+
//~^ ERROR the variant or associated item `new` exists for enum `Node<i32, RcFamily>`, but its trait bounds were not satisfied
3333
}

tests/ui/issues/issue-50264-inner-deref-trait/option-as_deref.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | let _result = &Some(42).as_deref();
66
|
77
= note: the following trait bounds were not satisfied:
88
`{integer}: Deref`
9-
which is required by `<{integer} as Deref>::Target = _`
109

1110
error: aborting due to 1 previous error
1211

tests/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | let _result = &mut Some(42).as_deref_mut();
66
|
77
= note: the following trait bounds were not satisfied:
88
`{integer}: Deref`
9-
which is required by `<{integer} as Deref>::Target = _`
109

1110
error: aborting due to 1 previous error
1211

tests/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | let _result = &Ok(42).as_deref();
66
|
77
= note: the following trait bounds were not satisfied:
88
`{integer}: Deref`
9-
which is required by `<{integer} as Deref>::Target = _`
109

1110
error: aborting due to 1 previous error
1211

tests/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | let _result = &mut Ok(42).as_deref_mut();
66
|
77
= note: the following trait bounds were not satisfied:
88
`{integer}: Deref`
9-
which is required by `<{integer} as Deref>::Target = _`
109

1110
error: aborting due to 1 previous error
1211

tests/ui/nll/issue-57362-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ impl<'a> X for fn(&'a ()) {
1818
}
1919
}
2020

21+
// FIXME(@compiler-errors): This error message is less than helpful.
2122
fn g() {
2223
let x = <fn (&())>::make_g();
2324
//~^ ERROR no function or associated item named `make_g` found for fn pointer `for<'a> fn(&'a ())` in the current scope

tests/ui/nll/issue-57362-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0599]: no function or associated item named `make_g` found for fn pointer `for<'a> fn(&'a ())` in the current scope
2-
--> $DIR/issue-57362-2.rs:22:25
2+
--> $DIR/issue-57362-2.rs:23:25
33
|
44
LL | let x = <fn (&())>::make_g();
55
| ^^^^^^ function or associated item not found in `fn(&())`

tests/ui/resolve/issue-85671.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ check-pass
2+
13
// Some trait with a function that returns a slice:
24
pub trait AsSlice {
35
type Element;
@@ -22,7 +24,6 @@ impl<Cont> A<Cont> {
2224
Self: AsSlice<Element = Coef>,
2325
{
2426
self.as_ref_a().as_ref_a();
25-
//~^ ERROR no method named `as_ref_a` found for struct `A<&[Coef]>` in the current scope
2627
}
2728

2829
pub fn as_ref_a<Coef>(&self) -> A<&[<Self as AsSlice>::Element]>

tests/ui/resolve/issue-85671.stderr

-17
This file was deleted.

0 commit comments

Comments
 (0)