]> git.lizzy.rs Git - rust.git/commitdiff
improve normalize cycle error
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Tue, 24 Mar 2020 10:24:24 +0000 (11:24 +0100)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Tue, 24 Mar 2020 10:24:24 +0000 (11:24 +0100)
src/librustc/query/mod.rs
src/librustc/ty/normalize_erasing_regions.rs
src/test/ui/associated-const/defaults-cyclic-fail.rs
src/test/ui/associated-const/defaults-cyclic-fail.stderr
src/test/ui/consts/const-size_of-cycle.stderr

index 86855cb0ef0c2c3e27be088b9b695c267b479c38..1cc5c6e6f4ae7c48c62e75eda5b0be000d6068c6 100644 (file)
@@ -1117,7 +1117,7 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
         query normalize_generic_arg_after_erasing_regions(
             goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
         ) -> GenericArg<'tcx> {
-            desc { "normalizing `{:?}`", goal }
+            desc { "normalizing `{}`", goal.value }
         }
 
         query implied_outlives_bounds(
index e49bf6f8e67dcbe069c97d97a86a7e405ebe8f03..2f0a57c59eb14abc0d8672ca7b9ee5f19be510ce 100644 (file)
@@ -94,14 +94,12 @@ fn tcx(&self) -> TyCtxt<'tcx> {
     }
 
     fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
-        self.tcx
-            .normalize_generic_arg_after_erasing_regions(self.param_env.and(ty.into()))
-            .expect_ty()
+        let arg = self.param_env.and(ty.into());
+        self.tcx.normalize_generic_arg_after_erasing_regions(arg).expect_ty()
     }
 
     fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
-        self.tcx
-            .normalize_generic_arg_after_erasing_regions(self.param_env.and(c.into()))
-            .expect_const()
+        let arg = self.param_env.and(c.into());
+        self.tcx.normalize_generic_arg_after_erasing_regions(arg).expect_const()
     }
 }
index 9b899ee316a0e737398a978e3f97947a1598e35a..9fb1bbebc96100847ee3e47bcf85f6c4c376743e 100644 (file)
@@ -1,9 +1,9 @@
 // build-fail
+//~^ ERROR cycle detected when normalizing `<() as Tr>::A`
 
 // Cyclic assoc. const defaults don't error unless *used*
 trait Tr {
     const A: u8 = Self::B;
-    //~^ ERROR cycle detected when const-evaluating + checking `Tr::A`
 
     const B: u8 = Self::A;
 }
index 940182d4aa6766ca62edb8073af465c801f00439..6b2fbe5be4e30f69b867b6377841e201f934bc09 100644 (file)
@@ -1,30 +1,42 @@
-error[E0391]: cycle detected when const-evaluating + checking `Tr::A`
-  --> $DIR/defaults-cyclic-fail.rs:5:5
+error[E0391]: cycle detected when normalizing `<() as Tr>::A`
+   |
+note: ...which requires const-evaluating + checking `Tr::A`...
+  --> $DIR/defaults-cyclic-fail.rs:6:5
    |
 LL |     const A: u8 = Self::B;
    |     ^^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires const-evaluating + checking `Tr::A`...
+  --> $DIR/defaults-cyclic-fail.rs:6:5
    |
+LL |     const A: u8 = Self::B;
+   |     ^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires const-evaluating `Tr::A`...
-  --> $DIR/defaults-cyclic-fail.rs:5:19
+  --> $DIR/defaults-cyclic-fail.rs:6:5
    |
 LL |     const A: u8 = Self::B;
-   |                   ^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^
+   = note: ...which requires normalizing `<() as Tr>::B`...
+note: ...which requires const-evaluating + checking `Tr::B`...
+  --> $DIR/defaults-cyclic-fail.rs:8:5
+   |
+LL |     const B: u8 = Self::A;
+   |     ^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires const-evaluating + checking `Tr::B`...
   --> $DIR/defaults-cyclic-fail.rs:8:5
    |
 LL |     const B: u8 = Self::A;
    |     ^^^^^^^^^^^^^^^^^^^^^^
 note: ...which requires const-evaluating `Tr::B`...
-  --> $DIR/defaults-cyclic-fail.rs:8:19
+  --> $DIR/defaults-cyclic-fail.rs:8:5
    |
 LL |     const B: u8 = Self::A;
-   |                   ^^^^^^^
-   = note: ...which again requires const-evaluating + checking `Tr::A`, completing the cycle
+   |     ^^^^^^^^^^^^^^^^^^^^^^
+   = note: ...which again requires normalizing `<() as Tr>::A`, completing the cycle
 note: cycle used when const-evaluating `main`
-  --> $DIR/defaults-cyclic-fail.rs:16:16
+  --> $DIR/defaults-cyclic-fail.rs:14:1
    |
-LL |     assert_eq!(<() as Tr>::A, 0);
-   |                ^^^^^^^^^^^^^
+LL | fn main() {
+   | ^^^^^^^^^
 
 error: aborting due to previous error
 
index c03b7a19ffc6186b755d569dabd5d943a010f88f..aac3622c6de408f16603ccb1290392be09f39299 100644 (file)
@@ -25,7 +25,7 @@ note: ...which requires const-evaluating + checking `std::intrinsics::size_of`..
 LL |     pub fn size_of<T>() -> usize;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: ...which requires computing layout of `Foo`...
-   = note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: [u8; _] }`...
+   = note: ...which requires normalizing `[u8; _]`...
    = note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}#0`, completing the cycle
 note: cycle used when processing `Foo`
   --> $DIR/const-size_of-cycle.rs:7:1