Skip to content

Commit 02b80d2

Browse files
Don't normalize obligations in WF goal for the new solver
1 parent b3f0085 commit 02b80d2

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

Cargo.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ dependencies = [
351351
"cargo-test-macro",
352352
"cargo-test-support",
353353
"cargo-util",
354-
"clap 4.1.3",
354+
"clap 4.1.4",
355355
"crates-io",
356356
"curl",
357357
"curl-sys",
@@ -655,9 +655,9 @@ dependencies = [
655655

656656
[[package]]
657657
name = "clap"
658-
version = "4.1.3"
658+
version = "4.1.4"
659659
source = "registry+https://github.com/rust-lang/crates.io-index"
660-
checksum = "d8d93d855ce6a0aa87b8473ef9169482f40abaa2e9e0993024c35c902cbd5920"
660+
checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76"
661661
dependencies = [
662662
"bitflags",
663663
"clap_derive 4.1.0",
@@ -675,7 +675,7 @@ version = "4.0.7"
675675
source = "registry+https://github.com/rust-lang/crates.io-index"
676676
checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b"
677677
dependencies = [
678-
"clap 4.1.3",
678+
"clap 4.1.4",
679679
]
680680

681681
[[package]]
@@ -2294,7 +2294,7 @@ name = "jsondoclint"
22942294
version = "0.1.0"
22952295
dependencies = [
22962296
"anyhow",
2297-
"clap 4.1.3",
2297+
"clap 4.1.4",
22982298
"fs-err",
22992299
"rustdoc-json-types",
23002300
"serde",
@@ -2557,7 +2557,7 @@ dependencies = [
25572557
"ammonia",
25582558
"anyhow",
25592559
"chrono",
2560-
"clap 4.1.3",
2560+
"clap 4.1.4",
25612561
"clap_complete",
25622562
"elasticlunr-rs",
25632563
"env_logger 0.10.0",
@@ -3528,7 +3528,7 @@ dependencies = [
35283528
name = "rustbook"
35293529
version = "0.1.0"
35303530
dependencies = [
3531-
"clap 4.1.3",
3531+
"clap 4.1.4",
35323532
"env_logger 0.7.1",
35333533
"mdbook",
35343534
]

compiler/rustc_trait_selection/src/solve/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use std::mem;
2121

2222
use rustc_hir::def_id::DefId;
23-
use rustc_hir::CRATE_HIR_ID;
2423
use rustc_infer::infer::canonical::{Canonical, CanonicalVarKind, CanonicalVarValues};
2524
use rustc_infer::infer::canonical::{OriginalQueryValues, QueryRegionConstraints, QueryResponse};
2625
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
@@ -380,13 +379,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
380379
goal: Goal<'tcx, ty::GenericArg<'tcx>>,
381380
) -> QueryResult<'tcx> {
382381
self.infcx.probe(|_| {
383-
match crate::traits::wf::obligations(
382+
match crate::traits::wf::unnormalized_obligations(
384383
self.infcx,
385384
goal.param_env,
386-
CRATE_HIR_ID, // FIXME body id
387-
0,
388385
goal.predicate,
389-
DUMMY_SP,
390386
) {
391387
Some(obligations) => self.evaluate_all_and_make_canonical_response(
392388
obligations.into_iter().map(|o| o.into()).collect(),

compiler/rustc_trait_selection/src/traits/wf.rs

+30-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use rustc_hir as hir;
44
use rustc_hir::lang_items::LangItem;
55
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
66
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable};
7-
use rustc_span::def_id::{DefId, LocalDefId};
8-
use rustc_span::Span;
7+
use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
8+
use rustc_span::{Span, DUMMY_SP};
99

1010
use std::iter;
1111
/// Returns the set of obligations needed to make `arg` well-formed.
@@ -75,6 +75,34 @@ pub fn obligations<'tcx>(
7575
Some(result)
7676
}
7777

78+
/// Compute the predicates that are required for a type to be well-formed.
79+
///
80+
/// This is only intended to be used in the new solver, since it does not
81+
/// take into account recursion depth or proper error-reporting spans.
82+
pub fn unnormalized_obligations<'tcx>(
83+
infcx: &InferCtxt<'tcx>,
84+
param_env: ty::ParamEnv<'tcx>,
85+
arg: GenericArg<'tcx>,
86+
) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
87+
if let ty::GenericArgKind::Lifetime(..) = arg.unpack() {
88+
return Some(vec![]);
89+
}
90+
91+
debug_assert_eq!(arg, infcx.resolve_vars_if_possible(arg));
92+
93+
let mut wf = WfPredicates {
94+
tcx: infcx.tcx,
95+
param_env,
96+
body_id: CRATE_DEF_ID,
97+
span: DUMMY_SP,
98+
out: vec![],
99+
recursion_depth: 0,
100+
item: None,
101+
};
102+
wf.compute(arg);
103+
Some(wf.out)
104+
}
105+
78106
/// Returns the obligations that make this trait reference
79107
/// well-formed. For example, if there is a trait `Set` defined like
80108
/// `trait Set<K:Eq>`, then the trait reference `Foo: Set<Bar>` is WF

0 commit comments

Comments
 (0)