Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use query to determine whether function needs const checking #69642

Merged
merged 3 commits into from
Apr 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add regression test for #69615
  • Loading branch information
ecstatic-morse committed Apr 9, 2020
commit e8b270a4b6d711b7dcd99b474b0866e6e3531c93
16 changes: 16 additions & 0 deletions src/test/ui/rfc-2632-const-trait-impl/hir-const-check.rs
Original file line number Diff line number Diff line change
@@ -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() {}
12 changes: 12 additions & 0 deletions src/test/ui/rfc-2632-const-trait-impl/hir-const-check.stderr
Original file line number Diff line number Diff line change
@@ -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`.