Skip to content

Commit 35d6003

Browse files
Normalize xform_ret_ty after constrained, bless tests
1 parent f6eac07 commit 35d6003

File tree

13 files changed

+41
-32
lines changed

13 files changed

+41
-32
lines changed

compiler/rustc_hir_typeck/src/method/probe.rs

+30-8
Original file line numberDiff line numberDiff line change
@@ -1370,15 +1370,22 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
13701370
(xform_self_ty, xform_ret_ty) =
13711371
self.xform_self_ty(probe.item, impl_ty, impl_args);
13721372
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1373-
// FIXME: Weirdly, we normalize the ret ty in this candidate, but no other candidates.
1374-
xform_ret_ty = ocx.normalize(cause, self.param_env, xform_ret_ty);
1375-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1376-
Ok(()) => {}
1373+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1374+
match self.at(cause, self.param_env).eq(
1375+
DefineOpaqueTypes::No,
1376+
xform_self_ty,
1377+
self_ty,
1378+
) {
1379+
Ok(infer_ok) => {
1380+
ocx.register_infer_ok_obligations(infer_ok);
1381+
}
13771382
Err(err) => {
13781383
debug!("--> cannot relate self-types {:?}", err);
13791384
return ProbeResult::NoMatch;
13801385
}
13811386
}
1387+
// FIXME: Weirdly, we normalize the ret ty in this candidate, but no other candidates.
1388+
xform_ret_ty = ocx.normalize(cause, self.param_env, xform_ret_ty);
13821389
// Check whether the impl imposes obligations we have to worry about.
13831390
let impl_def_id = probe.item.container_id(self.tcx);
13841391
let impl_bounds =
@@ -1420,11 +1427,19 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14201427
infer::FnCall,
14211428
poly_trait_ref,
14221429
);
1430+
let trait_ref = ocx.normalize(cause, self.param_env, trait_ref);
14231431
(xform_self_ty, xform_ret_ty) =
14241432
self.xform_self_ty(probe.item, trait_ref.self_ty(), trait_ref.args);
14251433
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1426-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1427-
Ok(()) => {}
1434+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1435+
match self.at(cause, self.param_env).eq(
1436+
DefineOpaqueTypes::No,
1437+
xform_self_ty,
1438+
self_ty,
1439+
) {
1440+
Ok(infer_ok) => {
1441+
ocx.register_infer_ok_obligations(infer_ok);
1442+
}
14281443
Err(err) => {
14291444
debug!("--> cannot relate self-types {:?}", err);
14301445
return ProbeResult::NoMatch;
@@ -1447,8 +1462,15 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14471462
(xform_self_ty, xform_ret_ty) =
14481463
self.xform_self_ty(probe.item, trait_ref.self_ty(), trait_ref.args);
14491464
xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty);
1450-
match ocx.eq_no_opaques(cause, self.param_env, xform_self_ty, self_ty) {
1451-
Ok(()) => {}
1465+
// FIXME: Make this `ocx.eq` once we define opaques more eagerly.
1466+
match self.at(cause, self.param_env).eq(
1467+
DefineOpaqueTypes::No,
1468+
xform_self_ty,
1469+
self_ty,
1470+
) {
1471+
Ok(infer_ok) => {
1472+
ocx.register_infer_ok_obligations(infer_ok);
1473+
}
14521474
Err(err) => {
14531475
debug!("--> cannot relate self-types {:?}", err);
14541476
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 the size for values of type `Node<i32, RcFamily>` cannot be known at compilation time
32+
//~^ ERROR the variant or associated item `new` exists for enum `Node<i32, RcFamily>`, but its trait bounds were not satisfied
3333
}

tests/ui/impl-trait/issues/issue-62742.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::marker::PhantomData;
33
fn _alias_check() {
44
WrongImpl::foo(0i32);
55
//~^ ERROR the trait bound `RawImpl<_>: Raw<_>` is not satisfied
6-
//~| ERROR the trait bound `RawImpl<_>: Raw<_>` is not satisfied
6+
//~| ERROR the function or associated item `foo` exists for struct `SafeImpl<_, RawImpl<_>>`, but its trait bounds were not satisfied
77
WrongImpl::<()>::foo(0i32);
88
//~^ ERROR the trait bound `RawImpl<()>: Raw<()>` is not satisfied
99
//~| ERROR trait bounds were not satisfied

tests/ui/impl-trait/issues/issue-84073.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ where
2929
}
3030

3131
fn main() {
32-
Race::new(|race| race.when()); //~ ERROR overflow assigning `_` to `Option<_>`
32+
Race::new(|race| race.when());
33+
//~^ ERROR the method `when` exists for struct `RaceBuilder<_, Never<_>>`, but its trait bounds were not satisfied
3334
}

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

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

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

2527
fn main() {}

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/nll/issue-57642-higher-ranked-subtype.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ impl<T> Y for fn(T) {
2828
}
2929

3030
fn higher_ranked_region_has_lost_its_binder() {
31-
let x = <fn (&())>::make_g(); //~ ERROR the function
31+
let x = <fn (&())>::make_g();
32+
//~^ ERROR no function or associated item named `make_g` found for fn pointer `for<'a> fn(&'a ())` in the current scope
3233
}
3334

3435
fn magical() {

tests/ui/nll/issue-57642-higher-ranked-subtype.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LL | trait X {
1212
| ^^^^^^^
1313

1414
error[E0599]: no function or associated item named `make_f` found for fn pointer `for<'a> fn(&'a ())` in the current scope
15-
--> $DIR/issue-57642-higher-ranked-subtype.rs:35:25
15+
--> $DIR/issue-57642-higher-ranked-subtype.rs:36:25
1616
|
1717
LL | let x = <fn (&())>::make_f();
1818
| ^^^^^^ function or associated item not found in `fn(&())`

0 commit comments

Comments
 (0)