]> git.lizzy.rs Git - rust.git/commitdiff
Make rustc build with new chalk
authorMichael Goulet <michael@errs.io>
Sun, 13 Nov 2022 19:53:35 +0000 (19:53 +0000)
committerMichael Goulet <michael@errs.io>
Sun, 13 Nov 2022 19:53:44 +0000 (19:53 +0000)
compiler/rustc_traits/src/chalk/db.rs
compiler/rustc_traits/src/chalk/lowering.rs
src/test/ui/chalkify/closure.rs
src/test/ui/chalkify/closure.stderr
src/test/ui/chalkify/trait-objects.rs
src/test/ui/chalkify/trait-objects.stderr [deleted file]

index 07f92299f72b43326f5195dd87fbe87e9ae704de..d15707e5ceddb694b16f2fc4aee5d90bbca99d7d 100644 (file)
@@ -142,6 +142,8 @@ fn trait_datum(
             Some(CoerceUnsized)
         } else if lang_items.dispatch_from_dyn_trait() == Some(def_id) {
             Some(DispatchFromDyn)
+        } else if lang_items.tuple_trait() == Some(def_id) {
+            Some(Tuple)
         } else {
             None
         };
@@ -570,6 +572,7 @@ fn well_known_trait_id(
             CoerceUnsized => lang_items.coerce_unsized_trait(),
             DiscriminantKind => lang_items.discriminant_kind_trait(),
             DispatchFromDyn => lang_items.dispatch_from_dyn_trait(),
+            Tuple => lang_items.tuple_trait(),
         };
         def_id.map(chalk_ir::TraitId)
     }
index b64d53e60dee6d8211103c879d713f58f4b33ba1..25cedefa26127b70d40f8be46b74877f57d4411c 100644 (file)
@@ -507,9 +507,6 @@ fn lower_into(self, interner: RustInterner<'tcx>) -> Region<'tcx> {
                 name: ty::BoundRegionKind::BrAnon(p.idx as u32, None),
             }),
             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::Phantom(void, _) => match *void {},
         };
index 408e8802d862cb86a56b1afbfa556cd31c2380ca..568e2e30c418ca7c91ca3b714c1f42717c0712f4 100644 (file)
@@ -1,5 +1,3 @@
-// known-bug: unknown
-// FIXME(chalk): Chalk needs support for the Tuple trait
 // compile-flags: -Z chalk
 
 fn main() -> () {
@@ -26,7 +24,7 @@ fn main() -> () {
     let mut c = b;
 
     c();
-    b(); // FIXME: reenable when this is fixed ~ ERROR
+    b(); //~ ERROR
 
     // FIXME(chalk): this doesn't quite work
     /*
index bcee0cab96ae7788aa26729790cdb62f55044eeb..a33c0ba0d37c900e57f51169f0015b668bbd1b40 100644 (file)
@@ -1,80 +1,22 @@
-error[E0277]: `()` is not a tuple
-  --> $DIR/closure.rs:7: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 |     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: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
-  --> $DIR/closure.rs:18:5
+error[E0382]: borrow of moved value: `b`
+  --> $DIR/closure.rs:27:5
    |
+LL |     let mut c = b;
+   |                 - value moved here
+...
 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
+   |     ^ value borrowed here after move
    |
-LL |     b(); // FIXME: reenable when this is fixed ~ ERROR
-   |     ^^^ the trait `Tuple` is not implemented for `()`
+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
    |
-help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
+LL |         a = 1;
+   |         ^
+help: consider mutably borrowing `b`
    |
-LL | fn main() -> () where (): Tuple {
-   |                 +++++++++++++++
+LL |     let mut c = &mut b;
+   |                 ++++
 
-error: aborting due to 7 previous errors
+error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0277`.
+For more information about this error, try `rustc --explain E0382`.
index 30929e943bd7fce96989761b40f07c29a7080f64..d56abc42bf540c048951ac55830e97e3c50bf309 100644 (file)
@@ -1,5 +1,4 @@
-// known-bug: unknown
-// FIXME(chalk): Chalk needs support for the Tuple trait
+// check-pass
 // compile-flags: -Z chalk
 
 use std::fmt::Display;
diff --git a/src/test/ui/chalkify/trait-objects.stderr b/src/test/ui/chalkify/trait-objects.stderr
deleted file mode 100644 (file)
index 422d397..0000000
+++ /dev/null
@@ -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`.