Skip to content

Commit 4e3e915

Browse files
Revert "Rollup merge of rust-lang#135914 - compiler-errors:vanquish-query-norm, r=jackh726"
This reverts commit 556d901, reversing changes made to be15391.
1 parent 8231e85 commit 4e3e915

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use rustc_span::{DUMMY_SP, Span};
66
use tracing::{debug, instrument};
77

88
use crate::traits::query::NoSolution;
9-
use crate::traits::{ObligationCause, ObligationCtxt};
9+
use crate::traits::query::normalize::QueryNormalizeExt;
10+
use crate::traits::{Normalized, ObligationCause, ObligationCtxt};
1011

1112
/// This returns true if the type `ty` is "trivial" for
1213
/// dropck-outlives -- that is, if it doesn't require any types to
@@ -171,31 +172,26 @@ pub fn compute_dropck_outlives_inner<'tcx>(
171172
// do not themselves define a destructor", more or less. We have
172173
// to push them onto the stack to be expanded.
173174
for ty in constraints.dtorck_types.drain(..) {
174-
let normalized_ty = ocx.normalize(&cause, param_env, ty);
175+
let Normalized { value: ty, obligations } =
176+
ocx.infcx.at(&cause, param_env).query_normalize(ty)?;
177+
ocx.register_obligations(obligations);
175178

176-
let errors = ocx.select_where_possible();
177-
if !errors.is_empty() {
178-
debug!("failed to normalize dtorck type: {ty} ~> {errors:#?}");
179-
return Err(NoSolution);
180-
}
181-
182-
let normalized_ty = ocx.infcx.resolve_vars_if_possible(normalized_ty);
183-
debug!("dropck_outlives: ty from dtorck_types = {:?}", normalized_ty);
179+
debug!("dropck_outlives: ty from dtorck_types = {:?}", ty);
184180

185-
match normalized_ty.kind() {
181+
match ty.kind() {
186182
// All parameters live for the duration of the
187183
// function.
188184
ty::Param(..) => {}
189185

190186
// A projection that we couldn't resolve - it
191187
// might have a destructor.
192188
ty::Alias(..) => {
193-
result.kinds.push(normalized_ty.into());
189+
result.kinds.push(ty.into());
194190
}
195191

196192
_ => {
197-
if ty_set.insert(normalized_ty) {
198-
ty_stack.push((normalized_ty, depth + 1));
193+
if ty_set.insert(ty) {
194+
ty_stack.push((ty, depth + 1));
199195
}
200196
}
201197
}

compiler/rustc_traits/src/type_op.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ use rustc_middle::query::Providers;
66
use rustc_middle::traits::query::NoSolution;
77
use rustc_middle::ty::{Clause, FnSig, ParamEnvAnd, PolyFnSig, Ty, TyCtxt, TypeFoldable};
88
use rustc_trait_selection::infer::InferCtxtBuilderExt;
9+
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
910
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{
1011
AscribeUserType, type_op_ascribe_user_type_with_span,
1112
};
1213
use rustc_trait_selection::traits::query::type_op::normalize::Normalize;
1314
use rustc_trait_selection::traits::query::type_op::prove_predicate::ProvePredicate;
14-
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
15+
use rustc_trait_selection::traits::{Normalized, Obligation, ObligationCause, ObligationCtxt};
1516

1617
pub(crate) fn provide(p: &mut Providers) {
1718
*p = Providers {
@@ -42,7 +43,10 @@ where
4243
T: fmt::Debug + TypeFoldable<TyCtxt<'tcx>>,
4344
{
4445
let (param_env, Normalize { value }) = key.into_parts();
45-
Ok(ocx.normalize(&ObligationCause::dummy(), param_env, value))
46+
let Normalized { value, obligations } =
47+
ocx.infcx.at(&ObligationCause::dummy(), param_env).query_normalize(value)?;
48+
ocx.register_obligations(obligations);
49+
Ok(value)
4650
}
4751

4852
fn type_op_normalize_ty<'tcx>(

tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ fn main() {
4343
}
4444

4545
foo(bar, "string", |s| s.len() == 5);
46-
//~^ ERROR implementation of `Parser` is not general enough
47-
//~| ERROR implementation of `Parser` is not general enough
46+
//~^ ERROR implementation of `FnOnce` is not general enough
47+
//~| ERROR implementation of `FnOnce` is not general enough
4848
foo(baz, "string", |s| s.0.len() == 5);
49-
//~^ ERROR implementation of `Parser` is not general enough
50-
//~| ERROR implementation of `Parser` is not general enough
49+
//~^ ERROR implementation of `FnOnce` is not general enough
50+
//~| ERROR implementation of `FnOnce` is not general enough
5151
}

tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
error: implementation of `Parser` is not general enough
1+
error: implementation of `FnOnce` is not general enough
22
--> $DIR/issue-71955.rs:45:5
33
|
44
LL | foo(bar, "string", |s| s.len() == 5);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Parser` is not general enough
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
66
|
7-
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`...
8-
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1`
7+
= note: closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`...
8+
= note: ...but it actually implements `FnOnce<(&&'2 str,)>`, for some specific lifetime `'2`
99

10-
error: implementation of `Parser` is not general enough
10+
error: implementation of `FnOnce` is not general enough
1111
--> $DIR/issue-71955.rs:45:5
1212
|
1313
LL | foo(bar, "string", |s| s.len() == 5);
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Parser` is not general enough
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
1515
|
16-
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`...
17-
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1`
16+
= note: closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`...
17+
= note: ...but it actually implements `FnOnce<(&&'2 str,)>`, for some specific lifetime `'2`
1818
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1919

20-
error: implementation of `Parser` is not general enough
20+
error: implementation of `FnOnce` is not general enough
2121
--> $DIR/issue-71955.rs:48:5
2222
|
2323
LL | foo(baz, "string", |s| s.0.len() == 5);
24-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Parser` is not general enough
24+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
2525
|
26-
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`...
27-
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1`
26+
= note: closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`...
27+
= note: ...but it actually implements `FnOnce<(&Wrapper<'2>,)>`, for some specific lifetime `'2`
2828

29-
error: implementation of `Parser` is not general enough
29+
error: implementation of `FnOnce` is not general enough
3030
--> $DIR/issue-71955.rs:48:5
3131
|
3232
LL | foo(baz, "string", |s| s.0.len() == 5);
33-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Parser` is not general enough
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
3434
|
35-
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`...
36-
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1`
35+
= note: closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`...
36+
= note: ...but it actually implements `FnOnce<(&Wrapper<'2>,)>`, for some specific lifetime `'2`
3737
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3838

3939
error: aborting due to 4 previous errors

0 commit comments

Comments
 (0)