From 09275802249824e54d8eac577147112d4752671a Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Sat, 27 Mar 2021 04:22:22 +0100 Subject: Add regression tests for #56445 Closes #56445. --- .../const-generics/issues/issue-56445-1.full.stderr | 20 ++++++++++++++++++++ .../const-generics/issues/issue-56445-1.min.stderr | 11 +++++++++++ src/test/ui/const-generics/issues/issue-56445-1.rs | 11 +++++++++++ src/test/ui/const-generics/issues/issue-56445-2.rs | 11 +++++++++++ .../ui/const-generics/issues/issue-56445-2.stderr | 14 ++++++++++++++ src/test/ui/const-generics/issues/issue-56445-3.rs | 12 ++++++++++++ .../ui/const-generics/issues/issue-56445-3.stderr | 8 ++++++++ .../ui/const-generics/issues/issue-56445.full.stderr | 20 -------------------- .../ui/const-generics/issues/issue-56445.min.stderr | 11 ----------- src/test/ui/const-generics/issues/issue-56445.rs | 11 ----------- 10 files changed, 87 insertions(+), 42 deletions(-) create mode 100644 src/test/ui/const-generics/issues/issue-56445-1.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-56445-1.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-56445-1.rs create mode 100644 src/test/ui/const-generics/issues/issue-56445-2.rs create mode 100644 src/test/ui/const-generics/issues/issue-56445-2.stderr create mode 100644 src/test/ui/const-generics/issues/issue-56445-3.rs create mode 100644 src/test/ui/const-generics/issues/issue-56445-3.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-56445.full.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-56445.min.stderr delete mode 100644 src/test/ui/const-generics/issues/issue-56445.rs (limited to 'src/test/ui/const-generics') diff --git a/src/test/ui/const-generics/issues/issue-56445-1.full.stderr b/src/test/ui/const-generics/issues/issue-56445-1.full.stderr new file mode 100644 index 00000000000..8416d64e1c2 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-1.full.stderr @@ -0,0 +1,20 @@ +warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-56445-1.rs:3:27 + | +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44580 for more information + +error[E0771]: use of non-static lifetime `'a` in const generic + --> $DIR/issue-56445-1.rs:8:26 + | +LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); + | ^^ + | + = note: for more information, see issue #74052 + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445-1.min.stderr b/src/test/ui/const-generics/issues/issue-56445-1.min.stderr new file mode 100644 index 00000000000..f7056f27cb3 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-1.min.stderr @@ -0,0 +1,11 @@ +error[E0771]: use of non-static lifetime `'a` in const generic + --> $DIR/issue-56445-1.rs:8:26 + | +LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); + | ^^ + | + = note: for more information, see issue #74052 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445-1.rs b/src/test/ui/const-generics/issues/issue-56445-1.rs new file mode 100644 index 00000000000..bc9e1dee853 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-1.rs @@ -0,0 +1,11 @@ +// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995. +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![crate_type = "lib"] + +use std::marker::PhantomData; + +struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); +//~^ ERROR: use of non-static lifetime `'a` in const generic + +impl Bug<'_, ""> {} diff --git a/src/test/ui/const-generics/issues/issue-56445-2.rs b/src/test/ui/const-generics/issues/issue-56445-2.rs new file mode 100644 index 00000000000..e078c8487c7 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-2.rs @@ -0,0 +1,11 @@ +// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-502095133 +struct OnDiskDirEntry<'a> { _s: &'a usize } + +impl<'a> OnDiskDirEntry<'a> { + const LFN_FRAGMENT_LEN: usize = 2; + + fn lfn_contents(&self) -> [char; Self::LFN_FRAGMENT_LEN] { loop { } } + //~^ ERROR: generic `Self` types are currently not permitted in anonymous constants +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-56445-2.stderr b/src/test/ui/const-generics/issues/issue-56445-2.stderr new file mode 100644 index 00000000000..770c80cbbd3 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-2.stderr @@ -0,0 +1,14 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-56445-2.rs:7:38 + | +LL | fn lfn_contents(&self) -> [char; Self::LFN_FRAGMENT_LEN] { loop { } } + | ^^^^ + | +note: not a concrete type + --> $DIR/issue-56445-2.rs:4:10 + | +LL | impl<'a> OnDiskDirEntry<'a> { + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-56445-3.rs b/src/test/ui/const-generics/issues/issue-56445-3.rs new file mode 100644 index 00000000000..c29df14586e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-3.rs @@ -0,0 +1,12 @@ +// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-524494170 +pub struct Memory<'rom> { + rom: &'rom [u8], + ram: [u8; Self::SIZE], + //~^ ERROR: generic `Self` types are currently not permitted in anonymous constants +} + +impl<'rom> Memory<'rom> { + pub const SIZE: usize = 0x8000; +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-56445-3.stderr b/src/test/ui/const-generics/issues/issue-56445-3.stderr new file mode 100644 index 00000000000..f1c49eecfb5 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-3.stderr @@ -0,0 +1,8 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-56445-3.rs:4:15 + | +LL | ram: [u8; Self::SIZE], + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-56445.full.stderr b/src/test/ui/const-generics/issues/issue-56445.full.stderr deleted file mode 100644 index 61fba92c196..00000000000 --- a/src/test/ui/const-generics/issues/issue-56445.full.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-56445.rs:3:27 - | -LL | #![cfg_attr(full, feature(const_generics))] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error[E0771]: use of non-static lifetime `'a` in const generic - --> $DIR/issue-56445.rs:8:26 - | -LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); - | ^^ - | - = note: for more information, see issue #74052 - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445.min.stderr b/src/test/ui/const-generics/issues/issue-56445.min.stderr deleted file mode 100644 index 80702dd4bc3..00000000000 --- a/src/test/ui/const-generics/issues/issue-56445.min.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0771]: use of non-static lifetime `'a` in const generic - --> $DIR/issue-56445.rs:8:26 - | -LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); - | ^^ - | - = note: for more information, see issue #74052 - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445.rs b/src/test/ui/const-generics/issues/issue-56445.rs deleted file mode 100644 index bc9e1dee853..00000000000 --- a/src/test/ui/const-generics/issues/issue-56445.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995. -// revisions: full min -#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete -#![crate_type = "lib"] - -use std::marker::PhantomData; - -struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); -//~^ ERROR: use of non-static lifetime `'a` in const generic - -impl Bug<'_, ""> {} -- cgit 1.4.1-3-g733a5