diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-03-02 10:53:58 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-04-09 14:56:28 -0700 |
| commit | e8b270a4b6d711b7dcd99b474b0866e6e3531c93 (patch) | |
| tree | c31d485f0e5fa3e9db3b8f8aa0f761efad2d917a | |
| parent | d8047f83a95c42cfab19e3b89d24992b1722eb5c (diff) | |
| download | rust-e8b270a4b6d711b7dcd99b474b0866e6e3531c93.tar.gz rust-e8b270a4b6d711b7dcd99b474b0866e6e3531c93.zip | |
Add regression test for #69615
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr | 12 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs new file mode 100644 index 00000000000..f7af1b506f0 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs @@ -0,0 +1,16 @@ +// Regression test for #69615. + +#![feature(const_trait_impl, const_fn)] +#![allow(incomplete_features)] + +pub trait MyTrait { + fn method(&self); +} + +impl const MyTrait for () { + fn method(&self) { + match *self {} //~ ERROR `match` is not allowed in a `const fn` + } +} + +fn main() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr new file mode 100644 index 00000000000..563a9afe5bb --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr @@ -0,0 +1,12 @@ +error[E0658]: `match` is not allowed in a `const fn` + --> $DIR/hir-const-check.rs:12:9 + | +LL | match *self {} + | ^^^^^^^^^^^^^^ + | + = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information + = help: add `#![feature(const_if_match)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. |
