Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Chalk #72936

Merged
merged 15 commits into from
Jun 21, 2020
Merged
82 changes: 20 additions & 62 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ dependencies = [

[[package]]
name = "chalk-derive"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d4620afad4d4d9e63f915cfa10c930b7a3c9c3ca5cd88dd771ff8e5bf04ea10"
checksum = "5b9bd01eab87277d973183a1d2e56bace1c11f8242c52c20636fb7dddf343ac9"
dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
Expand All @@ -446,58 +446,35 @@ dependencies = [

[[package]]
name = "chalk-engine"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ca6e5cef10197789da0b4ec310eda58da4c55530613b2323432642a97372735"
checksum = "6c7a637c3d17ed555aef16e16952a5d1e127bd55178cc30be22afeb92da90c7d"
dependencies = [
"chalk-macros",
"chalk-derive",
"chalk-ir",
"rustc-hash",
]

[[package]]
name = "chalk-ir"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d45df5fb6328527f976e8a32c9e1c9970084d937ebe93d0d34f5bbf4231cb956"
checksum = "595e5735ded16c3f3dc348f7b15bbb2521a0080b1863cac38ad5271589944670"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-macros",
]

[[package]]
name = "chalk-macros"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e4782d108e420a1fcf94d8a919cf248db33c5071678e87d9c2d4f20ed1feb32"
dependencies = [
"lazy_static",
]

[[package]]
name = "chalk-rust-ir"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0ec96dbe0ab5fdbadfca4179ec2e1d35f0439c3b53a74988b1aec239c63eb08"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-ir",
"chalk-macros",
]

[[package]]
name = "chalk-solve"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfb99fa9530f0e101475fb60adc931f51bdea05b4642a48928b814d7f0141a6b"
checksum = "5d9d938139db425867a30cc0cfec0269406d8238d0571d829041eaa7a8455d11"
dependencies = [
"chalk-derive",
"chalk-engine",
"chalk-ir",
"chalk-macros",
"chalk-rust-ir",
"ena 0.13.1",
"ena",
"itertools 0.9.0",
"petgraph",
"rustc-hash",
Expand Down Expand Up @@ -1061,15 +1038,6 @@ dependencies = [
"strum_macros",
]

[[package]]
name = "ena"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36"
dependencies = [
"log",
]

[[package]]
name = "ena"
version = "0.14.0"
Expand Down Expand Up @@ -1181,9 +1149,9 @@ dependencies = [

[[package]]
name = "fixedbitset"
version = "0.1.9"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"

[[package]]
name = "flate2"
Expand Down Expand Up @@ -2370,12 +2338,6 @@ dependencies = [
"vcpkg",
]

[[package]]
name = "ordermap"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"

[[package]]
name = "ordslice"
version = "0.3.0"
Expand Down Expand Up @@ -2546,12 +2508,12 @@ dependencies = [

[[package]]
name = "petgraph"
version = "0.4.13"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
dependencies = [
"fixedbitset",
"ordermap",
"indexmap",
]

[[package]]
Expand Down Expand Up @@ -3296,7 +3258,7 @@ dependencies = [
"bitflags",
"cfg-if",
"crossbeam-utils 0.7.2",
"ena 0.14.0",
"ena",
"indexmap",
"jobserver",
"lazy_static",
Expand Down Expand Up @@ -3499,12 +3461,9 @@ dependencies = [

[[package]]
name = "rustc-hash"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
dependencies = [
"byteorder",
]
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"

[[package]]
name = "rustc-main"
Expand Down Expand Up @@ -3755,7 +3714,7 @@ dependencies = [
"bitflags",
"cfg-if",
"crossbeam-utils 0.7.2",
"ena 0.14.0",
"ena",
"indexmap",
"jobserver",
"lazy_static",
Expand Down Expand Up @@ -4373,7 +4332,6 @@ name = "rustc_traits"
version = "0.0.0"
dependencies = [
"chalk-ir",
"chalk-rust-ir",
"chalk-solve",
"log",
"rustc_ast",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ crossbeam-utils = { version = "0.7", features = ["nightly"] }
stable_deref_trait = "1.0.0"
rayon = { version = "0.3.0", package = "rustc-rayon" }
rayon-core = { version = "0.3.0", package = "rustc-rayon-core" }
rustc-hash = "1.0.1"
rustc-hash = "1.1.0"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
rustc_index = { path = "../librustc_index", package = "rustc_index" }
bitflags = "1.2.1"
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rustc_serialize = { path = "../librustc_serialize" }
rustc_ast = { path = "../librustc_ast" }
rustc_span = { path = "../librustc_span" }
byteorder = { version = "1.3" }
chalk-ir = "0.10.0"
chalk-ir = "0.11.0"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
measureme = "0.7.1"
rustc_session = { path = "../librustc_session" }
94 changes: 44 additions & 50 deletions src/librustc_middle/traits/chalk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
//! its name suggest, is to provide an abstraction boundary for creating
//! interned Chalk types.

use chalk_ir::{GoalData, Parameter};

use rustc_middle::mir::Mutability;
use rustc_middle::mir::interpret::ConstValue;
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};

use rustc_hir::def_id::DefId;

Expand All @@ -19,27 +17,6 @@ use std::cmp::Ordering;
use std::fmt;
use std::hash::{Hash, Hasher};

/// Since Chalk doesn't have full support for all Rust builtin types yet, we
/// need to use an enum here, rather than just `DefId`.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum RustDefId {
Adt(DefId),
Str,
Never,
Slice,
Array,
Ref(Mutability),
RawPtr,

Trait(DefId),

Impl(DefId),

FnDef(DefId),

AssocTy(DefId),
}

#[derive(Copy, Clone)]
pub struct RustInterner<'tcx> {
pub tcx: TyCtxt<'tcx>,
Expand Down Expand Up @@ -86,16 +63,19 @@ impl fmt::Debug for RustInterner<'_> {
impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
type InternedType = Box<chalk_ir::TyData<Self>>;
type InternedLifetime = Box<chalk_ir::LifetimeData<Self>>;
type InternedParameter = Box<chalk_ir::ParameterData<Self>>;
type InternedConst = Box<chalk_ir::ConstData<Self>>;
type InternedConcreteConst = ConstValue<'tcx>;
type InternedGenericArg = Box<chalk_ir::GenericArgData<Self>>;
type InternedGoal = Box<chalk_ir::GoalData<Self>>;
type InternedGoals = Vec<chalk_ir::Goal<Self>>;
type InternedSubstitution = Vec<chalk_ir::Parameter<Self>>;
type InternedSubstitution = Vec<chalk_ir::GenericArg<Self>>;
type InternedProgramClause = Box<chalk_ir::ProgramClauseData<Self>>;
type InternedProgramClauses = Vec<chalk_ir::ProgramClause<Self>>;
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
type InternedParameterKinds = Vec<chalk_ir::ParameterKind<()>>;
type InternedCanonicalVarKinds = Vec<chalk_ir::ParameterKind<chalk_ir::UniverseIndex>>;
type DefId = RustDefId;
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
type DefId = DefId;
type InternedAdtId = &'tcx AdtDef;
type Identifier = ();

fn debug_program_clause_implication(
Expand Down Expand Up @@ -209,25 +189,39 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
&lifetime
}

fn intern_parameter(
fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
Box::new(constant)
}

fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
&constant
}

fn const_eq(
&self,
parameter: chalk_ir::ParameterData<Self>,
) -> Self::InternedParameter {
Box::new(parameter)
_ty: &Self::InternedType,
c1: &Self::InternedConcreteConst,
c2: &Self::InternedConcreteConst,
) -> bool {
c1 == c2
}

fn intern_generic_arg(&self, data: chalk_ir::GenericArgData<Self>) -> Self::InternedGenericArg {
Box::new(data)
}

fn parameter_data<'a>(
fn generic_arg_data<'a>(
&self,
parameter: &'a Self::InternedParameter,
) -> &'a chalk_ir::ParameterData<Self> {
&parameter
data: &'a Self::InternedGenericArg,
) -> &'a chalk_ir::GenericArgData<Self> {
&data
}

fn intern_goal(&self, goal: GoalData<Self>) -> Self::InternedGoal {
fn intern_goal(&self, goal: chalk_ir::GoalData<Self>) -> Self::InternedGoal {
Box::new(goal)
}

fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> {
fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a chalk_ir::GoalData<Self> {
&goal
}

Expand All @@ -244,15 +238,15 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {

fn intern_substitution<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::Parameter<Self>, E>>,
data: impl IntoIterator<Item = Result<chalk_ir::GenericArg<Self>, E>>,
) -> Result<Self::InternedSubstitution, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}

fn substitution_data<'a>(
&self,
substitution: &'a Self::InternedSubstitution,
) -> &'a [Parameter<Self>] {
) -> &'a [chalk_ir::GenericArg<Self>] {
substitution
}

Expand Down Expand Up @@ -298,31 +292,31 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
clauses
}

fn intern_parameter_kinds<E>(
fn intern_generic_arg_kinds<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<()>, E>>,
) -> Result<Self::InternedParameterKinds, E> {
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
) -> Result<Self::InternedVariableKinds, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}

fn parameter_kinds_data<'a>(
fn variable_kinds_data<'a>(
&self,
parameter_kinds: &'a Self::InternedParameterKinds,
) -> &'a [chalk_ir::ParameterKind<()>] {
parameter_kinds: &'a Self::InternedVariableKinds,
) -> &'a [chalk_ir::VariableKind<Self>] {
parameter_kinds
}

fn intern_canonical_var_kinds<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<chalk_ir::UniverseIndex>, E>>,
data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>,
) -> Result<Self::InternedCanonicalVarKinds, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}

fn canonical_var_kinds_data<'a>(
&self,
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
) -> &'a [chalk_ir::ParameterKind<chalk_ir::UniverseIndex>] {
) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
canonical_var_kinds
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_middle/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ pub use self::ObligationCauseCode::*;
pub use self::SelectionError::*;

pub use self::chalk::{
ChalkEnvironmentAndGoal, ChalkEnvironmentClause, RustDefId as ChalkRustDefId,
RustInterner as ChalkRustInterner,
ChalkEnvironmentAndGoal, ChalkEnvironmentClause, RustInterner as ChalkRustInterner,
};

/// Depending on the stage of compilation, we want projection to be
Expand Down
Loading