rust/src/test/compile-fail/const-fn-mismatch.rs
2016-08-05 22:52:57 +12:00

29 lines
871 B
Rust

// 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.
// Test that we can't declare a const fn in an impl -- right now it's
// just not allowed at all, though eventually it'd make sense to allow
// it if the trait fn is const (but right now no trait fns can be
// const).
#![feature(const_fn)]
trait Foo {
fn f() -> u32;
}
impl Foo for u32 {
const fn f() -> u32 { 22 }
//~^ ERROR E0379
//~| NOTE trait fns cannot be const
}
fn main() { }