Skip to content

Commit 85aa98d

Browse files
Normalize xform_ret_ty after constrained
1 parent 814d844 commit 85aa98d

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
@@ -1374,15 +1374,22 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
13741374
(xform_self_ty, xform_ret_ty) =
13751375
self.xform_self_ty(probe.item, impl_ty, impl_args);
13761376
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1377-
// FIXME: Weirdly, we normalize the ret ty in this candidate, but no other candidates.
1378-
xform_ret_ty = ocx.normalize(cause, self.param_env, xform_ret_ty);
1379-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1380-
Ok(()) => {}
1377+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1378+
match self.at(cause, self.param_env).eq(
1379+
DefineOpaqueTypes::No,
1380+
xform_self_ty,
1381+
self_ty,
1382+
) {
1383+
Ok(infer_ok) => {
1384+
ocx.register_infer_ok_obligations(infer_ok);
1385+
}
13811386
Err(err) => {
13821387
debug!("--> cannot relate self-types {:?}", err);
13831388
return ProbeResult::NoMatch;
13841389
}
13851390
}
1391+
// FIXME: Weirdly, we normalize the ret ty in this candidate, but no other candidates.
1392+
xform_ret_ty = ocx.normalize(cause, self.param_env, xform_ret_ty);
13861393
// Check whether the impl imposes obligations we have to worry about.
13871394
let impl_def_id = probe.item.container_id(self.tcx);
13881395
let impl_bounds =
@@ -1424,11 +1431,19 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14241431
infer::FnCall,
14251432
poly_trait_ref,
14261433
);
1434+
let trait_ref = ocx.normalize(cause, self.param_env, trait_ref);
14271435
(xform_self_ty, xform_ret_ty) =
14281436
self.xform_self_ty(probe.item, trait_ref.self_ty(), trait_ref.args);
14291437
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1430-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1431-
Ok(()) => {}
1438+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1439+
match self.at(cause, self.param_env).eq(
1440+
DefineOpaqueTypes::No,
1441+
xform_self_ty,
1442+
self_ty,
1443+
) {
1444+
Ok(infer_ok) => {
1445+
ocx.register_infer_ok_obligations(infer_ok);
1446+
}
14321447
Err(err) => {
14331448
debug!("--> cannot relate self-types {:?}", err);
14341449
return ProbeResult::NoMatch;
@@ -1451,8 +1466,15 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14511466
(xform_self_ty, xform_ret_ty) =
14521467
self.xform_self_ty(probe.item, trait_ref.self_ty(), trait_ref.args);
14531468
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1454-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1455-
Ok(()) => {}
1469+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1470+
match self.at(cause, self.param_env).eq(
1471+
DefineOpaqueTypes::No,
1472+
xform_self_ty,
1473+
self_ty,
1474+
) {
1475+
Ok(infer_ok) => {
1476+
ocx.register_infer_ok_obligations(infer_ok);
1477+
}
14561478
Err(err) => {
14571479
debug!("--> cannot relate self-types {:?}", err);
14581480
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/issues/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/issues/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)