mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Use builtin types for Never, Array, and FnDef
This commit is contained in:
parent
6aa2e9d978
commit
7c09ad0627
@ -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),
|
||||
|
@ -168,35 +168,6 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> 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<RustInterner<'tcx>> 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<RustInterner<'tcx>> 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<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||
}
|
||||
}
|
||||
|
||||
Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(),
|
||||
FnDef(_) | Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(),
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
@ -420,8 +387,6 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> 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<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||
}
|
||||
}
|
||||
}
|
||||
Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(),
|
||||
FnDef(_) | Trait(_) | Impl(_) | AssocTy(_) | Opaque(_) => panic!(),
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
|
@ -311,10 +311,22 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> 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<RustInterner<'tcx>>> 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<RustInterner<'tcx>>> 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))
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user