Make rustc build with new chalk

This commit is contained in:
Michael Goulet 2022-11-13 19:53:35 +00:00
parent 6de5f6277e
commit 36a106891a
6 changed files with 21 additions and 114 deletions

View file

@ -142,6 +142,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
Some(CoerceUnsized) Some(CoerceUnsized)
} else if lang_items.dispatch_from_dyn_trait() == Some(def_id) { } else if lang_items.dispatch_from_dyn_trait() == Some(def_id) {
Some(DispatchFromDyn) Some(DispatchFromDyn)
} else if lang_items.tuple_trait() == Some(def_id) {
Some(Tuple)
} else { } else {
None None
}; };
@ -570,6 +572,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
CoerceUnsized => lang_items.coerce_unsized_trait(), CoerceUnsized => lang_items.coerce_unsized_trait(),
DiscriminantKind => lang_items.discriminant_kind_trait(), DiscriminantKind => lang_items.discriminant_kind_trait(),
DispatchFromDyn => lang_items.dispatch_from_dyn_trait(), DispatchFromDyn => lang_items.dispatch_from_dyn_trait(),
Tuple => lang_items.tuple_trait(),
}; };
def_id.map(chalk_ir::TraitId) def_id.map(chalk_ir::TraitId)
} }

View file

@ -507,9 +507,6 @@ impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime<RustInterner<'t
name: ty::BoundRegionKind::BrAnon(p.idx as u32, None), name: ty::BoundRegionKind::BrAnon(p.idx as u32, None),
}), }),
chalk_ir::LifetimeData::Static => return interner.tcx.lifetimes.re_static, chalk_ir::LifetimeData::Static => return interner.tcx.lifetimes.re_static,
chalk_ir::LifetimeData::Empty(_) => {
bug!("Chalk should not have been passed an empty lifetime.")
}
chalk_ir::LifetimeData::Erased => return interner.tcx.lifetimes.re_erased, chalk_ir::LifetimeData::Erased => return interner.tcx.lifetimes.re_erased,
chalk_ir::LifetimeData::Phantom(void, _) => match *void {}, chalk_ir::LifetimeData::Phantom(void, _) => match *void {},
}; };

View file

@ -1,5 +1,3 @@
// known-bug: unknown
// FIXME(chalk): Chalk needs support for the Tuple trait
// compile-flags: -Z chalk // compile-flags: -Z chalk
fn main() -> () { fn main() -> () {
@ -26,7 +24,7 @@ fn main() -> () {
let mut c = b; let mut c = b;
c(); c();
b(); // FIXME: reenable when this is fixed ~ ERROR b(); //~ ERROR
// FIXME(chalk): this doesn't quite work // FIXME(chalk): this doesn't quite work
/* /*

View file

@ -1,80 +1,22 @@
error[E0277]: `()` is not a tuple error[E0382]: borrow of moved value: `b`
--> $DIR/closure.rs:7:5 --> $DIR/closure.rs:27:5
|
LL | t();
| ^^^ the trait `Tuple` is not implemented for `()`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn main() -> () where (): Tuple {
| +++++++++++++++
error[E0277]: `()` is not a tuple
--> $DIR/closure.rs:13:5
| |
LL | let mut c = b;
| - value moved here
...
LL | b(); LL | b();
| ^^^ the trait `Tuple` is not implemented for `()` | ^ value borrowed here after move
| |
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment
--> $DIR/closure.rs:20:9
| |
LL | fn main() -> () where (): Tuple { LL | a = 1;
| +++++++++++++++ | ^
help: consider mutably borrowing `b`
|
LL | let mut c = &mut b;
| ++++
error[E0277]: `()` is not a tuple error: aborting due to previous error
--> $DIR/closure.rs:17:5
|
LL | c();
| ^^^ the trait `Tuple` is not implemented for `()`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn main() -> () where (): Tuple {
| +++++++++++++++
error[E0277]: `()` is not a tuple For more information about this error, try `rustc --explain E0382`.
--> $DIR/closure.rs:18:5
|
LL | b();
| ^^^ the trait `Tuple` is not implemented for `()`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn main() -> () where (): Tuple {
| +++++++++++++++
error[E0277]: `()` is not a tuple
--> $DIR/closure.rs:24:5
|
LL | b();
| ^^^ the trait `Tuple` is not implemented for `()`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn main() -> () where (): Tuple {
| +++++++++++++++
error[E0277]: `()` is not a tuple
--> $DIR/closure.rs:28:5
|
LL | c();
| ^^^ the trait `Tuple` is not implemented for `()`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn main() -> () where (): Tuple {
| +++++++++++++++
error[E0277]: `()` is not a tuple
--> $DIR/closure.rs:29:5
|
LL | b(); // FIXME: reenable when this is fixed ~ ERROR
| ^^^ the trait `Tuple` is not implemented for `()`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn main() -> () where (): Tuple {
| +++++++++++++++
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,5 +1,4 @@
// known-bug: unknown // check-pass
// FIXME(chalk): Chalk needs support for the Tuple trait
// compile-flags: -Z chalk // compile-flags: -Z chalk
use std::fmt::Display; use std::fmt::Display;

View file

@ -1,32 +0,0 @@
error: the type `&dyn Fn(i32) -> _` is not well-formed (chalk)
--> $DIR/trait-objects.rs:11:12
|
LL | let f: &dyn Fn(i32) -> _ = &|x| x + x;
| ^^^^^^^^^^^^^^^^^
error[E0277]: `(i32,)` is not a tuple
--> $DIR/trait-objects.rs:12:5
|
LL | f(2);
| ^^^^ the trait `Tuple` is not implemented for `(i32,)`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn main() where (i32,): Tuple {
| +++++++++++++++++++
error[E0277]: expected a `Fn<(i32,)>` closure, found `dyn Fn(i32) -> i32`
--> $DIR/trait-objects.rs:12:5
|
LL | f(2);
| ^^^^ expected an `Fn<(i32,)>` closure, found `dyn Fn(i32) -> i32`
|
= help: the trait `Fn<(i32,)>` is not implemented for `dyn Fn(i32) -> i32`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn main() where dyn Fn(i32) -> i32: Fn<(i32,)> {
| ++++++++++++++++++++++++++++++++++++
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.