From 61cc8925b229c02950885a4cd6dcc048aa104a01 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 9 Apr 2020 00:57:27 +0100 Subject: [PATCH 1/2] Add regression test for #66596 --- .../issue-66596-impl-trait-for-str-const-arg.rs | 16 ++++++++++++++++ ...sue-66596-impl-trait-for-str-const-arg.stderr | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs create mode 100644 src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs new file mode 100644 index 00000000000..b677dcc4af4 --- /dev/null +++ b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +trait Trait { + type Assoc; +} + +impl Trait<"0"> for () { + type Assoc = (); +} + +fn main() { + let _: <() as Trait<"0">>::Assoc = (); +} diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr new file mode 100644 index 00000000000..8ab28cc2a85 --- /dev/null +++ b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr @@ -0,0 +1,8 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + From 0f0252260ce50d9a6a3c1afa3c3df7f469cbcb67 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 9 Apr 2020 00:57:41 +0100 Subject: [PATCH 2/2] Add regression test for #61522 --- .../issue-61522-array-len-succ.rs | 14 ++++++++++ .../issue-61522-array-len-succ.stderr | 26 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/test/ui/const-generics/issue-61522-array-len-succ.rs create mode 100644 src/test/ui/const-generics/issue-61522-array-len-succ.stderr diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.rs b/src/test/ui/const-generics/issue-61522-array-len-succ.rs new file mode 100644 index 00000000000..3b627a5e530 --- /dev/null +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.rs @@ -0,0 +1,14 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +pub struct MyArray([u8; COUNT + 1]); +//~^ ERROR constant expression depends on a generic parameter + +impl MyArray { + fn inner(&self) -> &[u8; COUNT + 1] { + //~^ ERROR constant expression depends on a generic parameter + &self.0 + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.stderr b/src/test/ui/const-generics/issue-61522-array-len-succ.stderr new file mode 100644 index 00000000000..0c4bd4afce4 --- /dev/null +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.stderr @@ -0,0 +1,26 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-61522-array-len-succ.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + +error: constant expression depends on a generic parameter + --> $DIR/issue-61522-array-len-succ.rs:4:40 + | +LL | pub struct MyArray([u8; COUNT + 1]); + | ^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/issue-61522-array-len-succ.rs:8:24 + | +LL | fn inner(&self) -> &[u8; COUNT + 1] { + | ^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to 2 previous errors +