Skip to content

Commit 36a1068

Browse files
Make rustc build with new chalk
1 parent 6de5f62 commit 36a1068

File tree

6 files changed

+20
-113
lines changed

6 files changed

+20
-113
lines changed

compiler/rustc_traits/src/chalk/db.rs

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
142142
Some(CoerceUnsized)
143143
} else if lang_items.dispatch_from_dyn_trait() == Some(def_id) {
144144
Some(DispatchFromDyn)
145+
} else if lang_items.tuple_trait() == Some(def_id) {
146+
Some(Tuple)
145147
} else {
146148
None
147149
};
@@ -570,6 +572,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
570572
CoerceUnsized => lang_items.coerce_unsized_trait(),
571573
DiscriminantKind => lang_items.discriminant_kind_trait(),
572574
DispatchFromDyn => lang_items.dispatch_from_dyn_trait(),
575+
Tuple => lang_items.tuple_trait(),
573576
};
574577
def_id.map(chalk_ir::TraitId)
575578
}

compiler/rustc_traits/src/chalk/lowering.rs

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

src/test/ui/chalkify/closure.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// known-bug: unknown
2-
// FIXME(chalk): Chalk needs support for the Tuple trait
31
// compile-flags: -Z chalk
42

53
fn main() -> () {
@@ -26,7 +24,7 @@ fn main() -> () {
2624
let mut c = b;
2725

2826
c();
29-
b(); // FIXME: reenable when this is fixed ~ ERROR
27+
b(); //~ ERROR
3028

3129
// FIXME(chalk): this doesn't quite work
3230
/*

src/test/ui/chalkify/closure.stderr

+15-73
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,22 @@
1-
error[E0277]: `()` is not a tuple
2-
--> $DIR/closure.rs:7:5
3-
|
4-
LL | t();
5-
| ^^^ the trait `Tuple` is not implemented for `()`
6-
|
7-
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
8-
|
9-
LL | fn main() -> () where (): Tuple {
10-
| +++++++++++++++
11-
12-
error[E0277]: `()` is not a tuple
13-
--> $DIR/closure.rs:13:5
14-
|
15-
LL | b();
16-
| ^^^ the trait `Tuple` is not implemented for `()`
17-
|
18-
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
19-
|
20-
LL | fn main() -> () where (): Tuple {
21-
| +++++++++++++++
22-
23-
error[E0277]: `()` is not a tuple
24-
--> $DIR/closure.rs:17:5
25-
|
26-
LL | c();
27-
| ^^^ the trait `Tuple` is not implemented for `()`
28-
|
29-
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
30-
|
31-
LL | fn main() -> () where (): Tuple {
32-
| +++++++++++++++
33-
34-
error[E0277]: `()` is not a tuple
35-
--> $DIR/closure.rs:18:5
1+
error[E0382]: borrow of moved value: `b`
2+
--> $DIR/closure.rs:27:5
363
|
4+
LL | let mut c = b;
5+
| - value moved here
6+
...
377
LL | b();
38-
| ^^^ the trait `Tuple` is not implemented for `()`
39-
|
40-
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
41-
|
42-
LL | fn main() -> () where (): Tuple {
43-
| +++++++++++++++
44-
45-
error[E0277]: `()` is not a tuple
46-
--> $DIR/closure.rs:24:5
47-
|
48-
LL | b();
49-
| ^^^ the trait `Tuple` is not implemented for `()`
50-
|
51-
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
52-
|
53-
LL | fn main() -> () where (): Tuple {
54-
| +++++++++++++++
55-
56-
error[E0277]: `()` is not a tuple
57-
--> $DIR/closure.rs:28:5
58-
|
59-
LL | c();
60-
| ^^^ the trait `Tuple` is not implemented for `()`
61-
|
62-
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
63-
|
64-
LL | fn main() -> () where (): Tuple {
65-
| +++++++++++++++
66-
67-
error[E0277]: `()` is not a tuple
68-
--> $DIR/closure.rs:29:5
8+
| ^ value borrowed here after move
699
|
70-
LL | b(); // FIXME: reenable when this is fixed ~ ERROR
71-
| ^^^ the trait `Tuple` is not implemented for `()`
10+
note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment
11+
--> $DIR/closure.rs:20:9
7212
|
73-
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
13+
LL | a = 1;
14+
| ^
15+
help: consider mutably borrowing `b`
7416
|
75-
LL | fn main() -> () where (): Tuple {
76-
| +++++++++++++++
17+
LL | let mut c = &mut b;
18+
| ++++
7719

78-
error: aborting due to 7 previous errors
20+
error: aborting due to previous error
7921

80-
For more information about this error, try `rustc --explain E0277`.
22+
For more information about this error, try `rustc --explain E0382`.

src/test/ui/chalkify/trait-objects.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// known-bug: unknown
2-
// FIXME(chalk): Chalk needs support for the Tuple trait
1+
// check-pass
32
// compile-flags: -Z chalk
43

54
use std::fmt::Display;

src/test/ui/chalkify/trait-objects.stderr

-32
This file was deleted.

0 commit comments

Comments
 (0)