mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 05:51:58 +00:00
Don't normalize obligations in WF goal for the new solver
This commit is contained in:
parent
b3f0085376
commit
02b80d2f9c
14
Cargo.lock
14
Cargo.lock
@ -351,7 +351,7 @@ dependencies = [
|
|||||||
"cargo-test-macro",
|
"cargo-test-macro",
|
||||||
"cargo-test-support",
|
"cargo-test-support",
|
||||||
"cargo-util",
|
"cargo-util",
|
||||||
"clap 4.1.3",
|
"clap 4.1.4",
|
||||||
"crates-io",
|
"crates-io",
|
||||||
"curl",
|
"curl",
|
||||||
"curl-sys",
|
"curl-sys",
|
||||||
@ -655,9 +655,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.1.3"
|
version = "4.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8d93d855ce6a0aa87b8473ef9169482f40abaa2e9e0993024c35c902cbd5920"
|
checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"clap_derive 4.1.0",
|
"clap_derive 4.1.0",
|
||||||
@ -675,7 +675,7 @@ version = "4.0.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b"
|
checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 4.1.3",
|
"clap 4.1.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2294,7 +2294,7 @@ name = "jsondoclint"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap 4.1.3",
|
"clap 4.1.4",
|
||||||
"fs-err",
|
"fs-err",
|
||||||
"rustdoc-json-types",
|
"rustdoc-json-types",
|
||||||
"serde",
|
"serde",
|
||||||
@ -2557,7 +2557,7 @@ dependencies = [
|
|||||||
"ammonia",
|
"ammonia",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap 4.1.3",
|
"clap 4.1.4",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
"elasticlunr-rs",
|
"elasticlunr-rs",
|
||||||
"env_logger 0.10.0",
|
"env_logger 0.10.0",
|
||||||
@ -3528,7 +3528,7 @@ dependencies = [
|
|||||||
name = "rustbook"
|
name = "rustbook"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 4.1.3",
|
"clap 4.1.4",
|
||||||
"env_logger 0.7.1",
|
"env_logger 0.7.1",
|
||||||
"mdbook",
|
"mdbook",
|
||||||
]
|
]
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::CRATE_HIR_ID;
|
|
||||||
use rustc_infer::infer::canonical::{Canonical, CanonicalVarKind, CanonicalVarValues};
|
use rustc_infer::infer::canonical::{Canonical, CanonicalVarKind, CanonicalVarValues};
|
||||||
use rustc_infer::infer::canonical::{OriginalQueryValues, QueryRegionConstraints, QueryResponse};
|
use rustc_infer::infer::canonical::{OriginalQueryValues, QueryRegionConstraints, QueryResponse};
|
||||||
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
|
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
|
||||||
@ -380,13 +379,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
|||||||
goal: Goal<'tcx, ty::GenericArg<'tcx>>,
|
goal: Goal<'tcx, ty::GenericArg<'tcx>>,
|
||||||
) -> QueryResult<'tcx> {
|
) -> QueryResult<'tcx> {
|
||||||
self.infcx.probe(|_| {
|
self.infcx.probe(|_| {
|
||||||
match crate::traits::wf::obligations(
|
match crate::traits::wf::unnormalized_obligations(
|
||||||
self.infcx,
|
self.infcx,
|
||||||
goal.param_env,
|
goal.param_env,
|
||||||
CRATE_HIR_ID, // FIXME body id
|
|
||||||
0,
|
|
||||||
goal.predicate,
|
goal.predicate,
|
||||||
DUMMY_SP,
|
|
||||||
) {
|
) {
|
||||||
Some(obligations) => self.evaluate_all_and_make_canonical_response(
|
Some(obligations) => self.evaluate_all_and_make_canonical_response(
|
||||||
obligations.into_iter().map(|o| o.into()).collect(),
|
obligations.into_iter().map(|o| o.into()).collect(),
|
||||||
|
@ -4,8 +4,8 @@ use rustc_hir as hir;
|
|||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
|
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable};
|
||||||
use rustc_span::def_id::{DefId, LocalDefId};
|
use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
|
||||||
use rustc_span::Span;
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
/// Returns the set of obligations needed to make `arg` well-formed.
|
/// Returns the set of obligations needed to make `arg` well-formed.
|
||||||
@ -75,6 +75,34 @@ pub fn obligations<'tcx>(
|
|||||||
Some(result)
|
Some(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Compute the predicates that are required for a type to be well-formed.
|
||||||
|
///
|
||||||
|
/// This is only intended to be used in the new solver, since it does not
|
||||||
|
/// take into account recursion depth or proper error-reporting spans.
|
||||||
|
pub fn unnormalized_obligations<'tcx>(
|
||||||
|
infcx: &InferCtxt<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
|
arg: GenericArg<'tcx>,
|
||||||
|
) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
|
||||||
|
if let ty::GenericArgKind::Lifetime(..) = arg.unpack() {
|
||||||
|
return Some(vec![]);
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_assert_eq!(arg, infcx.resolve_vars_if_possible(arg));
|
||||||
|
|
||||||
|
let mut wf = WfPredicates {
|
||||||
|
tcx: infcx.tcx,
|
||||||
|
param_env,
|
||||||
|
body_id: CRATE_DEF_ID,
|
||||||
|
span: DUMMY_SP,
|
||||||
|
out: vec![],
|
||||||
|
recursion_depth: 0,
|
||||||
|
item: None,
|
||||||
|
};
|
||||||
|
wf.compute(arg);
|
||||||
|
Some(wf.out)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the obligations that make this trait reference
|
/// Returns the obligations that make this trait reference
|
||||||
/// well-formed. For example, if there is a trait `Set` defined like
|
/// well-formed. For example, if there is a trait `Set` defined like
|
||||||
/// `trait Set<K:Eq>`, then the trait reference `Foo: Set<Bar>` is WF
|
/// `trait Set<K:Eq>`, then the trait reference `Foo: Set<Bar>` is WF
|
||||||
|
Loading…
Reference in New Issue
Block a user