diff --git a/src/librustc_middle/traits/chalk.rs b/src/librustc_middle/traits/chalk.rs index a97b6a3ea36..ec32bcf8a0b 100644 --- a/src/librustc_middle/traits/chalk.rs +++ b/src/librustc_middle/traits/chalk.rs @@ -21,10 +21,8 @@ use std::hash::{Hash, Hasher}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum RustDefId { Adt(DefId), - Never, - Array, - FnDef(DefId), + FnDef(DefId), Trait(DefId), Impl(DefId), AssocTy(DefId), diff --git a/src/librustc_traits/chalk/db.rs b/src/librustc_traits/chalk/db.rs index 15125c33f1f..367c5980279 100644 --- a/src/librustc_traits/chalk/db.rs +++ b/src/librustc_traits/chalk/db.rs @@ -168,35 +168,6 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t }); struct_datum } - RustDefId::Array => { - return Arc::new(chalk_solve::rust_ir::AdtDatum { - id: struct_id, - binders: chalk_ir::Binders::new( - chalk_ir::VariableKinds::from( - &self.interner, - Some(chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General)), - ), - chalk_solve::rust_ir::AdtDatumBound { - fields: vec![], - where_clauses: vec![], - }, - ), - flags: chalk_solve::rust_ir::AdtFlags { upstream: false, fundamental: false }, - }); - } - RustDefId::Never | RustDefId::FnDef(_) => { - return Arc::new(chalk_solve::rust_ir::AdtDatum { - id: struct_id, - binders: chalk_ir::Binders::new( - chalk_ir::VariableKinds::new(&self.interner), - chalk_solve::rust_ir::AdtDatumBound { - fields: vec![], - where_clauses: vec![], - }, - ), - flags: chalk_solve::rust_ir::AdtFlags { upstream: false, fundamental: false }, - }); - } v => bug!("Used not struct variant ({:?}) when expecting struct variant.", v), } @@ -287,8 +258,6 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t // FIXME(chalk): this match can be removed when builtin types supported match struct_id.0 { RustDefId::Adt(_) => {} - RustDefId::Never => return false, - RustDefId::Array => return false, _ => bug!("Did not use `Adt` variant when expecting adt."), } let adt_def_id: DefId = match struct_id.0 { @@ -385,8 +354,6 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t chalk_ir::TypeName::Adt(chalk_ir::AdtId(rust_def_id)) => { use rustc_middle::traits::ChalkRustDefId::*; match rust_def_id { - Never | Array | FnDef(_) => Some(true), - Adt(adt_def_id) => { let adt_def = self.tcx.adt_def(adt_def_id); match adt_def.adt_kind() { @@ -402,7 +369,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t } } - Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(), + FnDef(_) | Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(), } } _ => None, @@ -420,8 +387,6 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t chalk_ir::TypeName::Adt(chalk_ir::AdtId(rust_def_id)) => { use rustc_middle::traits::ChalkRustDefId::*; match rust_def_id { - Never => Some(false), - FnDef(_) | Array => Some(true), Adt(adt_def_id) => { let adt_def = self.tcx.adt_def(adt_def_id); match adt_def.adt_kind() { @@ -436,7 +401,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t } } } - Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(), + FnDef(_) | Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(), } } _ => None, diff --git a/src/librustc_traits/chalk/lowering.rs b/src/librustc_traits/chalk/lowering.rs index 01b7d0208e7..e4483843dd0 100644 --- a/src/librustc_traits/chalk/lowering.rs +++ b/src/librustc_traits/chalk/lowering.rs @@ -311,10 +311,22 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { Foreign(_def_id) => unimplemented!(), Str => apply(chalk_ir::TypeName::Str, empty()), Array(ty, _) => apply( - struct_ty(RustDefId::Array), - chalk_ir::Substitution::from1( + chalk_ir::TypeName::Array, + chalk_ir::Substitution::from( interner, - chalk_ir::GenericArgData::Ty(ty.lower_into(interner)).intern(interner), + &[ + chalk_ir::GenericArgData::Ty(ty.lower_into(interner)).intern(interner), + chalk_ir::GenericArgData::Const( + chalk_ir::ConstData { + ty: apply(chalk_ir::TypeName::Tuple(0), empty()), + value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { + interned: 0, + }), + } + .intern(interner), + ) + .intern(interner), + ], ), ), Slice(ty) => apply( @@ -348,7 +360,10 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { ), ) } - FnDef(def_id, _) => apply(struct_ty(RustDefId::FnDef(def_id)), empty()), + FnDef(def_id, _) => apply( + chalk_ir::TypeName::FnDef(chalk_ir::FnDefId(RustDefId::FnDef(def_id))), + empty(), + ), FnPtr(sig) => { let (inputs_and_outputs, binders, _named_regions) = collect_bound_vars(interner, interner.tcx, &sig.inputs_and_output()); @@ -371,7 +386,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { Closure(_def_id, _) => unimplemented!(), Generator(_def_id, _substs, _) => unimplemented!(), GeneratorWitness(_) => unimplemented!(), - Never => apply(struct_ty(RustDefId::Never), empty()), + Never => apply(chalk_ir::TypeName::Never, empty()), Tuple(substs) => { apply(chalk_ir::TypeName::Tuple(substs.len()), substs.lower_into(interner)) } diff --git a/src/librustc_traits/chalk/mod.rs b/src/librustc_traits/chalk/mod.rs index bfaa161f7aa..f33ec3a9fb9 100644 --- a/src/librustc_traits/chalk/mod.rs +++ b/src/librustc_traits/chalk/mod.rs @@ -108,9 +108,6 @@ crate fn evaluate_goal<'tcx>( TyData::Apply(_application_ty) => match _application_ty.name { chalk_ir::TypeName::Adt(_struct_id) => match _struct_id.0 { RustDefId::Adt(_) => unimplemented!(), - RustDefId::Never => unimplemented!(), - RustDefId::Array => unimplemented!(), - RustDefId::FnDef(_) => unimplemented!(), _ => panic!("Unexpected struct id"), }, chalk_ir::TypeName::Scalar(scalar) => match scalar {