diff options
| author | Keith Yeung <kungfukeith11@gmail.com> | 2016-08-12 15:47:42 -0700 |
|---|---|---|
| committer | Keith Yeung <kungfukeith11@gmail.com> | 2016-08-27 22:43:51 -0700 |
| commit | e46b09a1f9051a65544dee08f4d8d749d474d586 (patch) | |
| tree | 3266a4b84d9d347b287f83277a3b1be5ef98c027 | |
| parent | aa5c4bb05d1d5d10a2fdbb80f098ba06e73214b9 (diff) | |
| download | rust-e46b09a1f9051a65544dee08f4d8d749d474d586.tar.gz rust-e46b09a1f9051a65544dee08f4d8d749d474d586.zip | |
Add UI test for E0379
| -rw-r--r-- | src/test/ui/mismatched_types/const-fn-in-trait.rs | 25 | ||||
| -rw-r--r-- | src/test/ui/mismatched_types/const-fn-in-trait.stderr | 14 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/mismatched_types/const-fn-in-trait.rs b/src/test/ui/mismatched_types/const-fn-in-trait.rs new file mode 100644 index 00000000000..5e44030eab7 --- /dev/null +++ b/src/test/ui/mismatched_types/const-fn-in-trait.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// rustc-env:RUST_NEW_ERROR_FORMAT + +#![feature(const_fn)] + +trait Foo { + fn f() -> u32; + const fn g(); +} + +impl Foo for u32 { + const fn f() -> u32 { 22 } + fn g() {} +} + +fn main() { } diff --git a/src/test/ui/mismatched_types/const-fn-in-trait.stderr b/src/test/ui/mismatched_types/const-fn-in-trait.stderr new file mode 100644 index 00000000000..f7b7635e41a --- /dev/null +++ b/src/test/ui/mismatched_types/const-fn-in-trait.stderr @@ -0,0 +1,14 @@ +error[E0379]: trait fns cannot be declared const + --> $DIR/const-fn-in-trait.rs:17:5 + | +17 | const fn g(); + | ^^^^^ trait fns cannot be const + +error[E0379]: trait fns cannot be declared const + --> $DIR/const-fn-in-trait.rs:21:5 + | +21 | const fn f() -> u32 { 22 } + | ^^^^^ trait fns cannot be const + +error: aborting due to 2 previous errors + |
