Auto merge of #59540 - Zoxc:the-arena-2, r=michaelwoerister
Use arenas to avoid Lrc in queries #1 Based on https://github.com/rust-lang/rust/pull/59536.
This commit is contained in:
commit
cfeb9171b1
23 changed files with 107 additions and 89 deletions
|
|
@ -36,7 +36,6 @@ use rustc::ty::{self, TyCtxt, InferConst};
|
|||
use rustc::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::subst::{Kind, UnpackedKind};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc::mir::interpret::ConstValue;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
|
|
@ -677,7 +676,7 @@ crate fn evaluate_goal<'a, 'tcx>(
|
|||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
goal: ChalkCanonicalGoal<'tcx>
|
||||
) -> Result<
|
||||
Lrc<Canonical<'tcx, QueryResponse<'tcx, ()>>>,
|
||||
&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>,
|
||||
traits::query::NoSolution
|
||||
> {
|
||||
use crate::lowering::Lower;
|
||||
|
|
@ -718,6 +717,6 @@ crate fn evaluate_goal<'a, 'tcx>(
|
|||
|
||||
debug!("evaluate_goal: solution = {:?}", solution);
|
||||
|
||||
solution.map(|ok| Ok(Lrc::new(ok)))
|
||||
.unwrap_or(Err(traits::query::NoSolution))
|
||||
solution.map(|ok| Ok(&*tcx.arena.alloc(ok)))
|
||||
.unwrap_or(Err(traits::query::NoSolution))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use rustc::ty::query::Providers;
|
|||
use rustc::ty::subst::{Subst, InternalSubsts};
|
||||
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use syntax::source_map::{Span, DUMMY_SP};
|
||||
|
||||
crate fn provide(p: &mut Providers<'_>) {
|
||||
|
|
@ -21,7 +20,7 @@ crate fn provide(p: &mut Providers<'_>) {
|
|||
fn dropck_outlives<'tcx>(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonical_goal: CanonicalTyGoal<'tcx>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, NoSolution> {
|
||||
debug!("dropck_outlives(goal={:#?})", canonical_goal);
|
||||
|
||||
tcx.infer_ctxt().enter_with_canonical(
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ use smallvec::{SmallVec, smallvec};
|
|||
use syntax::source_map::DUMMY_SP;
|
||||
use rustc::traits::FulfillmentContext;
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
||||
crate fn provide(p: &mut Providers<'_>) {
|
||||
*p = Providers {
|
||||
implied_outlives_bounds,
|
||||
|
|
@ -28,7 +26,7 @@ fn implied_outlives_bounds<'tcx>(
|
|||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
goal: CanonicalTyGoal<'tcx>,
|
||||
) -> Result<
|
||||
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>>,
|
||||
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
|
||||
NoSolution,
|
||||
> {
|
||||
tcx.infer_ctxt()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use rustc::traits::query::{normalize::NormalizationResult, CanonicalProjectionGo
|
|||
use rustc::traits::{self, ObligationCause, SelectionContext, TraitEngineExt};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::{ParamEnvAnd, TyCtxt};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::sync::atomic::Ordering;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
|
|
@ -18,7 +17,7 @@ crate fn provide(p: &mut Providers<'_>) {
|
|||
fn normalize_projection_ty<'tcx>(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
goal: CanonicalProjectionGoal<'tcx>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution> {
|
||||
debug!("normalize_provider(goal={:#?})", goal);
|
||||
|
||||
tcx.sess
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ use rustc::ty::subst::{Kind, Subst, UserSubsts, UserSelfTy};
|
|||
use rustc::ty::{
|
||||
FnSig, Lift, ParamEnv, ParamEnvAnd, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable, Variance,
|
||||
};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::fmt;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ crate fn provide(p: &mut Providers<'_>) {
|
|||
fn type_op_ascribe_user_type<'tcx>(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, AscribeUserType<'tcx>>>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, ()>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
||||
tcx.infer_ctxt()
|
||||
.enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| {
|
||||
let (
|
||||
|
|
@ -170,7 +169,7 @@ impl AscribeUserTypeCx<'me, 'gcx, 'tcx> {
|
|||
fn type_op_eq<'tcx>(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Eq<'tcx>>>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, ()>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
||||
tcx.infer_ctxt()
|
||||
.enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| {
|
||||
let (param_env, Eq { a, b }) = key.into_parts();
|
||||
|
|
@ -200,7 +199,7 @@ where
|
|||
fn type_op_normalize_ty(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Ty<'tcx>>>>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, NoSolution> {
|
||||
tcx.infer_ctxt()
|
||||
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
|
||||
}
|
||||
|
|
@ -208,7 +207,7 @@ fn type_op_normalize_ty(
|
|||
fn type_op_normalize_predicate(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Predicate<'tcx>>>>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, Predicate<'tcx>>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, Predicate<'tcx>>>, NoSolution> {
|
||||
tcx.infer_ctxt()
|
||||
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
|
||||
}
|
||||
|
|
@ -216,7 +215,7 @@ fn type_op_normalize_predicate(
|
|||
fn type_op_normalize_fn_sig(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<FnSig<'tcx>>>>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, FnSig<'tcx>>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, FnSig<'tcx>>>, NoSolution> {
|
||||
tcx.infer_ctxt()
|
||||
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
|
||||
}
|
||||
|
|
@ -224,7 +223,7 @@ fn type_op_normalize_fn_sig(
|
|||
fn type_op_normalize_poly_fn_sig(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<PolyFnSig<'tcx>>>>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, PolyFnSig<'tcx>>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, PolyFnSig<'tcx>>>, NoSolution> {
|
||||
tcx.infer_ctxt()
|
||||
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
|
||||
}
|
||||
|
|
@ -232,7 +231,7 @@ fn type_op_normalize_poly_fn_sig(
|
|||
fn type_op_subtype<'tcx>(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Subtype<'tcx>>>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, ()>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
||||
tcx.infer_ctxt()
|
||||
.enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| {
|
||||
let (param_env, Subtype { sub, sup }) = key.into_parts();
|
||||
|
|
@ -246,7 +245,7 @@ fn type_op_subtype<'tcx>(
|
|||
fn type_op_prove_predicate<'tcx>(
|
||||
tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
|
||||
) -> Result<Lrc<Canonical<'tcx, QueryResponse<'tcx, ()>>>, NoSolution> {
|
||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
||||
tcx.infer_ctxt()
|
||||
.enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| {
|
||||
let (param_env, ProvePredicate { predicate }) = key.into_parts();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue