]> git.lizzy.rs Git - rust.git/commitdiff
update tests and add relevant feature gate test
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Tue, 5 May 2020 20:47:54 +0000 (22:47 +0200)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Sun, 17 May 2020 09:05:05 +0000 (11:05 +0200)
12 files changed:
src/librustc_typeck/collect.rs
src/test/ui/const-generics/array-size-in-generic-struct-param.stderr
src/test/ui/const-generics/issues/issue-61336-2.stderr
src/test/ui/const-generics/issues/issue-61336.stderr
src/test/ui/const-generics/issues/issue-61747.stderr
src/test/ui/const-generics/issues/issue-61935.stderr
src/test/ui/const-generics/issues/issue-66205.stderr
src/test/ui/const-generics/issues/issue-67185-1.stderr
src/test/ui/const-generics/issues/issue-67185-2.stderr
src/test/ui/const-generics/lazy-normalization/issue-71922.rs [new file with mode: 0644]
src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.rs [new file with mode: 0644]
src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr [new file with mode: 0644]

index 6ab7f66186333ee2a3c04f11befc2db3f175d41f..d16990cb44c4929a628b18fdd793af01ba51c9c5 100644 (file)
@@ -1164,7 +1164,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
             let parent_id = tcx.hir().get_parent_item(hir_id);
             Some(tcx.hir().local_def_id(parent_id).to_def_id())
         }
-        // FIXME(#43408) always enable this once we use `lazy_normalization` is
+        // FIXME(#43408) always enable this once `lazy_normalization` is
         // stable enough and does not need a feature gate anymore.
         Node::AnonConst(_) => {
             let parent_id = tcx.hir().get_parent_item(hir_id);
@@ -1193,7 +1193,6 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
                 }
             }
         }
-
         Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(..), .. }) => {
             Some(tcx.closure_base_def_id(def_id))
         }
index 8a1ffe1806237e926919edf0f5ffcaad91849471..2ebd063af18aca4a44b40530a4e76ca4c8191381 100644 (file)
@@ -29,5 +29,5 @@ LL |     arr: [u8; CFG.arr_size],
    |
    = note: this may fail depending on what value the parameter takes
 
-error: aborting due to 2 previous errors; 1 warning emitted
+error: aborting due to 2 previous errors; 2 warnings emitted
 
index 3e169f6592f1684fa5b02c8f43b668a70696a01f..c779ac10671a6bd6a59a87e6c8e77cfe08fe6783 100644 (file)
@@ -14,7 +14,7 @@ LL | #![feature(lazy_normalization_consts)]
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
-  --> $DIR/issue-61336-2.rs:9:5
+  --> $DIR/issue-61336-2.rs:11:5
    |
 LL |     [x; { N }]
    |     ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
@@ -25,6 +25,6 @@ help: consider restricting type parameter `T`
 LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
    |       ^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to previous error; 2 warnings emitted
 
 For more information about this error, try `rustc --explain E0277`.
index d619226a854d5811e474b6dc274fd2cad19079f4..7d7cec2c179117b995cf1ae7730127a6d9845590 100644 (file)
@@ -14,7 +14,7 @@ LL | #![feature(lazy_normalization_consts)]
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
-  --> $DIR/issue-61336.rs:9:5
+  --> $DIR/issue-61336.rs:11:5
    |
 LL |     [x; N]
    |     ^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
@@ -25,6 +25,6 @@ help: consider restricting type parameter `T`
 LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
    |       ^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to previous error; 2 warnings emitted
 
 For more information about this error, try `rustc --explain E0277`.
index 8f4c389bb04e4e2151812e86a25c9ec45dbecf75..5eb468cc27263d038255652b786b126f9e2bbd78 100644 (file)
@@ -7,13 +7,11 @@ LL | #![feature(const_generics)]
    = note: `#[warn(incomplete_features)]` on by default
    = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
 
-<<<<<<< HEAD
-warning: 1 warning emitted
-=======
 warning: the feature `lazy_normalization_consts` is incomplete and may cause the compiler to crash
   --> $DIR/issue-61747.rs:5:12
    |
 LL | #![feature(lazy_normalization_consts)]
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
->>>>>>> Added `lazy_normalization_consts` feature, and removed the -Z flag.
+
+warning: 2 warnings emitted
 
index 0cc620738c7144cb0f9620ab47a6ed4268fe7b0e..ec0db0401b41c048e7e7e77c9a610bb2e036a274 100644 (file)
@@ -12,3 +12,5 @@ warning: the feature `lazy_normalization_consts` is incomplete and may cause the
 LL | #![feature(lazy_normalization_consts)]
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
 
+warning: 2 warnings emitted
+
index 2bd013e8b41f2cdd8a147efc79ce06fcb400185e..416b675b56d28cdec77fa8c77d7b79827fa5deed 100644 (file)
@@ -1,5 +1,5 @@
 error: constant expression depends on a generic parameter
-  --> $DIR/issue-66205.rs:5:12
+  --> $DIR/issue-66205.rs:6:12
    |
 LL |     fact::<{ N - 1 }>();
    |            ^^^^^^^^^
index 257949340d0f081bb9a27e25ca2e9e47eb433fea..2472693afcbaf1ead199790276e755ae6e31967c 100644 (file)
@@ -12,3 +12,5 @@ warning: the feature `lazy_normalization_consts` is incomplete and may cause the
 LL | #![feature(lazy_normalization_consts)]
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
 
+warning: 2 warnings emitted
+
index c8620fc268ffb456ecf5fd077c1dd691bf377d20..76d2622e9af0ff833e7dfba456cb4eac05aea33f 100644 (file)
@@ -51,6 +51,12 @@ LL | | }
 error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
   --> $DIR/issue-67185-2.rs:27:6
    |
+LL | trait Foo
+   |       --- required by a bound in this
+...
+LL |         <u8 as Baz>::Quaks: Bar,
+   |                             --- required by this bound in `Foo`
+...
 LL | impl Foo for FooImpl {}
    |      ^^^ the trait `Bar` is not implemented for `[u16; 3]`
    |
@@ -61,6 +67,12 @@ LL | impl Foo for FooImpl {}
 error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
   --> $DIR/issue-67185-2.rs:27:6
    |
+LL | trait Foo
+   |       --- required by a bound in this
+...
+LL |         [<u8 as Baz>::Quaks; 2]: Bar,
+   |                                  --- required by this bound in `Foo`
+...
 LL | impl Foo for FooImpl {}
    |      ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
    |
@@ -71,17 +83,14 @@ LL | impl Foo for FooImpl {}
 error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
   --> $DIR/issue-67185-2.rs:31:14
    |
-LL | / trait Foo
-LL | |
-LL | |     where
-LL | |         [<u8 as Baz>::Quaks; 2]: Bar,
-LL | |         <u8 as Baz>::Quaks: Bar,
-LL | | {
-LL | | }
-   | |_- required by `Foo`
+LL | trait Foo
+   |       --- required by a bound in this
+...
+LL |         [<u8 as Baz>::Quaks; 2]: Bar,
+   |                                  --- required by this bound in `Foo`
 ...
-LL |   fn f(_: impl Foo) {}
-   |                ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
+LL | fn f(_: impl Foo) {}
+   |              ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
    |
    = help: the following implementations were found:
              <[[u16; 3]; 3] as Bar>
@@ -90,22 +99,19 @@ LL |   fn f(_: impl Foo) {}
 error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
   --> $DIR/issue-67185-2.rs:31:14
    |
-LL | / trait Foo
-LL | |
-LL | |     where
-LL | |         [<u8 as Baz>::Quaks; 2]: Bar,
-LL | |         <u8 as Baz>::Quaks: Bar,
-LL | | {
-LL | | }
-   | |_- required by `Foo`
+LL | trait Foo
+   |       --- required by a bound in this
+...
+LL |         <u8 as Baz>::Quaks: Bar,
+   |                             --- required by this bound in `Foo`
 ...
-LL |   fn f(_: impl Foo) {}
-   |                ^^^ the trait `Bar` is not implemented for `[u16; 3]`
+LL | fn f(_: impl Foo) {}
+   |              ^^^ the trait `Bar` is not implemented for `[u16; 3]`
    |
    = help: the following implementations were found:
              <[[u16; 3]; 3] as Bar>
              <[u16; 4] as Bar>
 
-error: aborting due to 6 previous errors
+error: aborting due to 6 previous errors; 2 warnings emitted
 
 For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/const-generics/lazy-normalization/issue-71922.rs b/src/test/ui/const-generics/lazy-normalization/issue-71922.rs
new file mode 100644 (file)
index 0000000..60597b8
--- /dev/null
@@ -0,0 +1,20 @@
+// run-pass
+#![feature(const_generics)]
+#![feature(lazy_normalization_consts)]
+#![allow(incomplete_features)]
+trait Foo {}
+
+impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
+
+trait FooImpl<const IS_ZERO: bool> {}
+
+impl FooImpl<{ 0u8 == 0u8 }> for [(); 0] {}
+
+impl<const N: usize> FooImpl<{ 0u8 != 0u8 }> for [(); N] {}
+
+fn foo<T: Foo>(_: T) {}
+
+fn main() {
+    foo([]);
+    foo([()]);
+}
diff --git a/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.rs b/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.rs
new file mode 100644 (file)
index 0000000..2c6fbfe
--- /dev/null
@@ -0,0 +1,20 @@
+// gate-test-lazy_normalization_consts
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+trait Foo {}
+
+impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
+//~^ ERROR cycle detected
+
+trait FooImpl<const IS_ZERO: bool> {}
+
+impl FooImpl<{ 0u8 == 0u8 }> for [(); 0] {}
+
+impl<const N: usize> FooImpl<{ 0u8 != 0u8 }> for [(); N] {}
+
+fn foo<T: Foo>(_: T) {}
+
+fn main() {
+    foo([]);
+    foo([()]);
+}
diff --git a/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr b/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr
new file mode 100644 (file)
index 0000000..8a97ec0
--- /dev/null
@@ -0,0 +1,44 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/lazy-normalization-feature-gate-hack.rs:2:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+
+error[E0391]: cycle detected when const-evaluating + checking `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`
+  --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
+   |
+LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
+   |                                                          ^^^^^^^^^^
+   |
+note: ...which requires const-evaluating + checking `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`...
+  --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
+   |
+LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
+   |                                                          ^^^^^^^^^^
+note: ...which requires const-evaluating `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`...
+  --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
+   |
+LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
+   |                                                          ^^^^^^^^^^
+note: ...which requires type-checking `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`...
+  --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
+   |
+LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
+   |                                                          ^^^^^^^^^^
+note: ...which requires processing `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`...
+  --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58
+   |
+LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
+   |                                                          ^^^^^^^^^^
+   = note: ...which again requires const-evaluating + checking `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>::{{constant}}#0`, completing the cycle
+note: cycle used when processing `<impl at $DIR/lazy-normalization-feature-gate-hack.rs:6:1: 6:72>`
+  --> $DIR/lazy-normalization-feature-gate-hack.rs:6:1
+   |
+LL | impl<const N: usize> Foo for [(); N] where Self: FooImpl<{ N == 0 }> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0391`.