Implement fn_def_datum
This commit is contained in:
parent
7c09ad0627
commit
a42e5a14c4
27
Cargo.lock
27
Cargo.lock
|
@ -435,15 +435,15 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-base"
|
name = "chalk-base"
|
||||||
version = "0.10.1-dev"
|
version = "0.10.1-dev"
|
||||||
source = "git+https://github.com/rust-lang/chalk.git?rev=f4977ab4c781e4f3b7fdb9310edbdab6daf56e29#f4977ab4c781e4f3b7fdb9310edbdab6daf56e29"
|
source = "git+https://github.com/jackh726/chalk.git?rev=58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b#58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static 1.4.0",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-derive"
|
name = "chalk-derive"
|
||||||
version = "0.10.1-dev"
|
version = "0.10.1-dev"
|
||||||
source = "git+https://github.com/rust-lang/chalk.git?rev=f4977ab4c781e4f3b7fdb9310edbdab6daf56e29#f4977ab4c781e4f3b7fdb9310edbdab6daf56e29"
|
source = "git+https://github.com/jackh726/chalk.git?rev=58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b#58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.3",
|
"proc-macro2 1.0.3",
|
||||||
"quote 1.0.2",
|
"quote 1.0.2",
|
||||||
|
@ -454,7 +454,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-engine"
|
name = "chalk-engine"
|
||||||
version = "0.10.1-dev"
|
version = "0.10.1-dev"
|
||||||
source = "git+https://github.com/rust-lang/chalk.git?rev=f4977ab4c781e4f3b7fdb9310edbdab6daf56e29#f4977ab4c781e4f3b7fdb9310edbdab6daf56e29"
|
source = "git+https://github.com/jackh726/chalk.git?rev=58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b#58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-base",
|
"chalk-base",
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
|
@ -465,7 +465,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-ir"
|
name = "chalk-ir"
|
||||||
version = "0.10.1-dev"
|
version = "0.10.1-dev"
|
||||||
source = "git+https://github.com/rust-lang/chalk.git?rev=f4977ab4c781e4f3b7fdb9310edbdab6daf56e29#f4977ab4c781e4f3b7fdb9310edbdab6daf56e29"
|
source = "git+https://github.com/jackh726/chalk.git?rev=58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b#58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-base",
|
"chalk-base",
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
|
@ -474,13 +474,13 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-solve"
|
name = "chalk-solve"
|
||||||
version = "0.10.1-dev"
|
version = "0.10.1-dev"
|
||||||
source = "git+https://github.com/rust-lang/chalk.git?rev=f4977ab4c781e4f3b7fdb9310edbdab6daf56e29#f4977ab4c781e4f3b7fdb9310edbdab6daf56e29"
|
source = "git+https://github.com/jackh726/chalk.git?rev=58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b#58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-base",
|
"chalk-base",
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"chalk-engine",
|
"chalk-engine",
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
"ena 0.14.0",
|
"ena",
|
||||||
"itertools 0.9.0",
|
"itertools 0.9.0",
|
||||||
"petgraph",
|
"petgraph",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
@ -1044,15 +1044,6 @@ dependencies = [
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ena"
|
|
||||||
version = "0.13.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36"
|
|
||||||
dependencies = [
|
|
||||||
"log",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ena"
|
name = "ena"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
|
@ -3273,7 +3264,7 @@ dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crossbeam-utils 0.7.2",
|
"crossbeam-utils 0.7.2",
|
||||||
"ena 0.14.0",
|
"ena",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
@ -3729,7 +3720,7 @@ dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crossbeam-utils 0.7.2",
|
"crossbeam-utils 0.7.2",
|
||||||
"ena 0.14.0",
|
"ena",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
|
|
@ -30,7 +30,7 @@ rustc_serialize = { path = "../librustc_serialize" }
|
||||||
rustc_ast = { path = "../librustc_ast" }
|
rustc_ast = { path = "../librustc_ast" }
|
||||||
rustc_span = { path = "../librustc_span" }
|
rustc_span = { path = "../librustc_span" }
|
||||||
byteorder = { version = "1.3" }
|
byteorder = { version = "1.3" }
|
||||||
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "f4977ab4c781e4f3b7fdb9310edbdab6daf56e29" }
|
chalk-ir = { git = "https://github.com/jackh726/chalk.git", rev = "58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b" }
|
||||||
#chalk-ir = "0.10.0"
|
#chalk-ir = "0.10.0"
|
||||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||||
measureme = "0.7.1"
|
measureme = "0.7.1"
|
||||||
|
|
|
@ -19,8 +19,8 @@ rustc_span = { path = "../librustc_span" }
|
||||||
#chalk-ir = "0.10.0"
|
#chalk-ir = "0.10.0"
|
||||||
#chalk-rust-ir = "0.10.0"
|
#chalk-rust-ir = "0.10.0"
|
||||||
#chalk-solve = "0.10.0"
|
#chalk-solve = "0.10.0"
|
||||||
chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "f4977ab4c781e4f3b7fdb9310edbdab6daf56e29" }
|
chalk-solve = { git = "https://github.com/jackh726/chalk.git", rev = "58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b" }
|
||||||
chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "f4977ab4c781e4f3b7fdb9310edbdab6daf56e29" }
|
chalk-ir = { git = "https://github.com/jackh726/chalk.git", rev = "58e5a31f48ddd4b940c682e7079d3e79e6ffaa1b" }
|
||||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||||
rustc_infer = { path = "../librustc_infer" }
|
rustc_infer = { path = "../librustc_infer" }
|
||||||
rustc_trait_selection = { path = "../librustc_trait_selection" }
|
rustc_trait_selection = { path = "../librustc_trait_selection" }
|
||||||
|
|
|
@ -175,9 +175,39 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||||
|
|
||||||
fn fn_def_datum(
|
fn fn_def_datum(
|
||||||
&self,
|
&self,
|
||||||
_fn_def_id: chalk_ir::FnDefId<RustInterner<'tcx>>,
|
fn_def_id: chalk_ir::FnDefId<RustInterner<'tcx>>,
|
||||||
) -> Arc<chalk_solve::rust_ir::FnDefDatum<RustInterner<'tcx>>> {
|
) -> Arc<chalk_solve::rust_ir::FnDefDatum<RustInterner<'tcx>>> {
|
||||||
unimplemented!()
|
let def_id = match fn_def_id.0 {
|
||||||
|
RustDefId::FnDef(def_id) => def_id,
|
||||||
|
_ => bug!("Did not use `FnDef` variant when expecting FnDef."),
|
||||||
|
};
|
||||||
|
let bound_vars = bound_vars_for_item(self.tcx, def_id);
|
||||||
|
let binders = binders_for(&self.interner, bound_vars);
|
||||||
|
|
||||||
|
let predicates = self.tcx.predicates_defined_on(def_id).predicates;
|
||||||
|
let where_clauses: Vec<_> = predicates
|
||||||
|
.into_iter()
|
||||||
|
.map(|(wc, _)| wc.subst(self.tcx, &bound_vars))
|
||||||
|
.filter_map(|wc| LowerInto::<Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>>::lower_into(wc, &self.interner)).collect();
|
||||||
|
|
||||||
|
let sig = self.tcx.fn_sig(def_id);
|
||||||
|
// FIXME(chalk): Why does this have a Binder
|
||||||
|
let argument_types = sig
|
||||||
|
.inputs()
|
||||||
|
.skip_binder()
|
||||||
|
.iter()
|
||||||
|
.map(|t| t.subst(self.tcx, &bound_vars).lower_into(&self.interner))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let return_type =
|
||||||
|
sig.output().skip_binder().subst(self.tcx, &bound_vars).lower_into(&self.interner);
|
||||||
|
|
||||||
|
let bound =
|
||||||
|
chalk_solve::rust_ir::FnDefDatumBound { argument_types, where_clauses, return_type };
|
||||||
|
Arc::new(chalk_solve::rust_ir::FnDefDatum {
|
||||||
|
id: fn_def_id,
|
||||||
|
binders: chalk_ir::Binders::new(binders, bound),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn impl_datum(
|
fn impl_datum(
|
||||||
|
|
|
@ -167,20 +167,11 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
||||||
ty::PredicateKind::Projection(predicate) => predicate.lower_into(interner),
|
ty::PredicateKind::Projection(predicate) => predicate.lower_into(interner),
|
||||||
ty::PredicateKind::WellFormed(arg) => match arg.unpack() {
|
ty::PredicateKind::WellFormed(arg) => match arg.unpack() {
|
||||||
GenericArgKind::Type(ty) => match ty.kind {
|
GenericArgKind::Type(ty) => match ty.kind {
|
||||||
// These types are always WF.
|
// FIXME(chalk): In Chalk, a placeholder is WellFormed if it
|
||||||
ty::Str | ty::Placeholder(..) | ty::Error(_) | ty::Never => {
|
// `FromEnv`. However, when we "lower" Params, we don't update
|
||||||
chalk_ir::GoalData::All(chalk_ir::Goals::new(interner))
|
// the environment.
|
||||||
}
|
ty::Placeholder(..) => chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)),
|
||||||
|
|
||||||
// FIXME(chalk): Well-formed only if ref lifetime outlives type
|
|
||||||
ty::Ref(..) => chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)),
|
|
||||||
|
|
||||||
ty::Param(..) => panic!("No Params expected."),
|
|
||||||
|
|
||||||
// FIXME(chalk) -- ultimately I think this is what we
|
|
||||||
// want to do, and we just have rules for how to prove
|
|
||||||
// `WellFormed` for everything above, instead of
|
|
||||||
// inlining a bit the rules of the proof here.
|
|
||||||
_ => chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed(
|
_ => chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed(
|
||||||
chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
|
chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
|
||||||
)),
|
)),
|
||||||
|
@ -360,9 +351,9 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
FnDef(def_id, _) => apply(
|
FnDef(def_id, substs) => apply(
|
||||||
chalk_ir::TypeName::FnDef(chalk_ir::FnDefId(RustDefId::FnDef(def_id))),
|
chalk_ir::TypeName::FnDef(chalk_ir::FnDefId(RustDefId::FnDef(def_id))),
|
||||||
empty(),
|
substs.lower_into(interner),
|
||||||
),
|
),
|
||||||
FnPtr(sig) => {
|
FnPtr(sig) => {
|
||||||
let (inputs_and_outputs, binders, _named_regions) =
|
let (inputs_and_outputs, binders, _named_regions) =
|
||||||
|
|
|
@ -8,12 +8,9 @@ trait Bar {
|
||||||
|
|
||||||
impl Foo for i32 { }
|
impl Foo for i32 { }
|
||||||
|
|
||||||
// FIXME(chalk): blocked on better handling of builtin traits for non-struct
|
|
||||||
// application types (or a workaround)
|
|
||||||
/*
|
|
||||||
impl Foo for str { }
|
impl Foo for str { }
|
||||||
//^ ERROR the size for values of type `str` cannot be known at compilation time
|
//~^ ERROR the size for values of type `str` cannot be known at compilation time
|
||||||
*/
|
|
||||||
|
|
||||||
// Implicit `T: Sized` bound.
|
// Implicit `T: Sized` bound.
|
||||||
impl<T> Foo for Option<T> { }
|
impl<T> Foo for Option<T> { }
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
|
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||||
|
--> $DIR/impl_wf.rs:11:6
|
||||||
|
|
|
||||||
|
LL | trait Foo: Sized { }
|
||||||
|
| ----- required by this bound in `Foo`
|
||||||
|
...
|
||||||
|
LL | impl Foo for str { }
|
||||||
|
| ^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: the trait `std::marker::Sized` is not implemented for `str`
|
||||||
|
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||||
|
|
||||||
error[E0277]: the trait bound `f32: Foo` is not satisfied
|
error[E0277]: the trait bound `f32: Foo` is not satisfied
|
||||||
--> $DIR/impl_wf.rs:43:6
|
--> $DIR/impl_wf.rs:40:6
|
||||||
|
|
|
|
||||||
LL | trait Baz<U: ?Sized> where U: Foo { }
|
LL | trait Baz<U: ?Sized> where U: Foo { }
|
||||||
| --- required by this bound in `Baz`
|
| --- required by this bound in `Baz`
|
||||||
|
@ -7,6 +19,6 @@ LL | trait Baz<U: ?Sized> where U: Foo { }
|
||||||
LL | impl Baz<f32> for f32 { }
|
LL | impl Baz<f32> for f32 { }
|
||||||
| ^^^^^^^^ the trait `Foo` is not implemented for `f32`
|
| ^^^^^^^^ the trait `Foo` is not implemented for `f32`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -18,11 +18,9 @@ fn main() {
|
||||||
// is expecting a variable of type `i32`. This behavior differs from the
|
// is expecting a variable of type `i32`. This behavior differs from the
|
||||||
// old-style trait solver. I guess this will change, that's why I'm
|
// old-style trait solver. I guess this will change, that's why I'm
|
||||||
// adding that test.
|
// adding that test.
|
||||||
// FIXME(chalk): partially blocked on float/int special casing
|
|
||||||
only_foo(x); //~ ERROR the trait bound `f64: Foo` is not satisfied
|
only_foo(x); //~ ERROR the trait bound `f64: Foo` is not satisfied
|
||||||
|
|
||||||
// Here we have two solutions so we get back the behavior of the old-style
|
// Here we have two solutions so we get back the behavior of the old-style
|
||||||
// trait solver.
|
// trait solver.
|
||||||
// FIXME(chalk): blocked on float/int special casing
|
only_bar(x); //~ ERROR the trait bound `f64: Bar` is not satisfied
|
||||||
//only_bar(x); // ERROR the trait bound `{float}: Bar` is not satisfied
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0277]: the trait bound `f64: Foo` is not satisfied
|
error[E0277]: the trait bound `f64: Foo` is not satisfied
|
||||||
--> $DIR/type_inference.rs:22:5
|
--> $DIR/type_inference.rs:21:5
|
||||||
|
|
|
|
||||||
LL | fn only_foo<T: Foo>(_x: T) { }
|
LL | fn only_foo<T: Foo>(_x: T) { }
|
||||||
| --- required by this bound in `only_foo`
|
| --- required by this bound in `only_foo`
|
||||||
|
@ -7,6 +7,15 @@ LL | fn only_foo<T: Foo>(_x: T) { }
|
||||||
LL | only_foo(x);
|
LL | only_foo(x);
|
||||||
| ^^^^^^^^ the trait `Foo` is not implemented for `f64`
|
| ^^^^^^^^ the trait `Foo` is not implemented for `f64`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0277]: the trait bound `f64: Bar` is not satisfied
|
||||||
|
--> $DIR/type_inference.rs:25:5
|
||||||
|
|
|
||||||
|
LL | fn only_bar<T: Bar>(_x: T) { }
|
||||||
|
| --- required by this bound in `only_bar`
|
||||||
|
...
|
||||||
|
LL | only_bar(x);
|
||||||
|
| ^^^^^^^^ the trait `Bar` is not implemented for `f64`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// FIXME(chalk): should have an error, see below
|
// check-fail
|
||||||
// check-pass
|
|
||||||
// compile-flags: -Z chalk
|
// compile-flags: -Z chalk
|
||||||
|
|
||||||
trait Foo { }
|
trait Foo { }
|
||||||
|
@ -16,17 +15,11 @@ fn main() {
|
||||||
x: 5,
|
x: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME(chalk): blocked on float/int special handling. Needs to know that {float}: !i32
|
let s = S { //~ ERROR the trait bound `f64: Foo` is not satisfied
|
||||||
/*
|
|
||||||
let s = S { // ERROR the trait bound `{float}: Foo` is not satisfied
|
|
||||||
x: 5.0,
|
x: 5.0,
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
// FIXME(chalk): blocked on float/int special handling. Needs to know that {float}: Sized
|
|
||||||
/*
|
|
||||||
let s = S {
|
let s = S {
|
||||||
x: Some(5.0),
|
x: Some(5.0),
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
error[E0277]: the trait bound `f64: Foo` is not satisfied
|
||||||
|
--> $DIR/type_wf.rs:18:13
|
||||||
|
|
|
||||||
|
LL | struct S<T: Foo> {
|
||||||
|
| ---------------- required by `S`
|
||||||
|
...
|
||||||
|
LL | let s = S {
|
||||||
|
| ^ the trait `Foo` is not implemented for `f64`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
|
@ -79,10 +79,9 @@ const WHITELIST: &[&str] = &[
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cc",
|
"cc",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
"chalk-base",
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"chalk-engine",
|
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
"chalk-macros",
|
|
||||||
"cloudabi",
|
"cloudabi",
|
||||||
"cmake",
|
"cmake",
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
|
|
Loading…
Reference in New Issue