Skip to content

Commit 9ce0c79

Browse files
authored
Rollup merge of #112196 - compiler-errors:new-solver-resolv, r=lcnr
Resolve vars in result from `scrape_region_constraints` Since we perform `type_op::Normalize` in the local infcx when the new solver is enabled, vars aren't necessarily resolved, which triggers this ICE: https://github.com/rust-lang/rust/blob/f85ab544dfbbce7448993c490ad16c176339b939/compiler/rustc_infer/src/infer/nll_relate/mod.rs#L481 There are more tests that go from ICE -> pass due to this change, but I just added revisions to a few for CI. r? `@lcnr`
2 parents 129a57a + 979379a commit 9ce0c79

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::traits::ObligationCtxt;
55
use rustc_errors::ErrorGuaranteed;
66
use rustc_infer::infer::region_constraints::RegionConstraintData;
77
use rustc_middle::traits::query::NoSolution;
8+
use rustc_middle::ty::{TyCtxt, TypeFoldable};
89
use rustc_span::source_map::DUMMY_SP;
910
use rustc_span::Span;
1011

@@ -24,9 +25,10 @@ impl<F> CustomTypeOp<F> {
2425
}
2526
}
2627

27-
impl<'tcx, F, R: fmt::Debug> super::TypeOp<'tcx> for CustomTypeOp<F>
28+
impl<'tcx, F, R> super::TypeOp<'tcx> for CustomTypeOp<F>
2829
where
2930
F: FnOnce(&ObligationCtxt<'_, 'tcx>) -> Result<R, NoSolution>,
31+
R: fmt::Debug + TypeFoldable<TyCtxt<'tcx>>,
3032
{
3133
type Output = R;
3234
/// We can't do any custom error reporting for `CustomTypeOp`, so
@@ -57,12 +59,16 @@ impl<F> fmt::Debug for CustomTypeOp<F> {
5759

5860
/// Executes `op` and then scrapes out all the "old style" region
5961
/// constraints that result, creating query-region-constraints.
60-
pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
62+
pub fn scrape_region_constraints<'tcx, Op, R>(
6163
infcx: &InferCtxt<'tcx>,
6264
op: impl FnOnce(&ObligationCtxt<'_, 'tcx>) -> Result<R, NoSolution>,
6365
name: &'static str,
6466
span: Span,
65-
) -> Result<(TypeOpOutput<'tcx, Op>, RegionConstraintData<'tcx>), ErrorGuaranteed> {
67+
) -> Result<(TypeOpOutput<'tcx, Op>, RegionConstraintData<'tcx>), ErrorGuaranteed>
68+
where
69+
R: TypeFoldable<TyCtxt<'tcx>>,
70+
Op: super::TypeOp<'tcx, Output = R>,
71+
{
6672
// During NLL, we expect that nobody will register region
6773
// obligations **except** as part of a custom type op (and, at the
6874
// end of each custom type op, we scrape out the region
@@ -91,6 +97,9 @@ pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
9197
}
9298
})?;
9399

100+
// Next trait solver performs operations locally, and normalize goals should resolve vars.
101+
let value = infcx.resolve_vars_if_possible(value);
102+
94103
let region_obligations = infcx.take_registered_region_obligations();
95104
let region_constraint_data = infcx.take_and_reset_region_constraints();
96105
let region_constraints = query_response::make_query_region_constraints(

tests/ui/issues/issue-13167.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// check-pass
22
// pretty-expanded FIXME #23616
3+
// revisions: current next
4+
//[next] compile-flags: -Ztrait-solver=next
35

46
use std::slice;
57

tests/ui/issues/issue-15734.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-pass
2-
// If `Index` used an associated type for its output, this test would
3-
// work more smoothly.
2+
// revisions: current next
3+
//[next] compile-flags: -Ztrait-solver=next
44

55
use std::ops::Index;
66

tests/ui/nll/issue-53119.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// check-pass
2+
// revisions: current next
3+
//[next] compile-flags: -Ztrait-solver=next
24

35
use std::ops::Deref;
46

0 commit comments

Comments
 (0)