2015-10-03 10:42:22 -05:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
// A quick test of 'unsafe const fn' functionality
|
|
|
|
|
|
|
|
#![feature(const_fn)]
|
|
|
|
|
2015-10-24 03:52:07 -05:00
|
|
|
const unsafe fn dummy(v: u32) -> u32 {
|
2015-10-03 10:42:22 -05:00
|
|
|
!v
|
|
|
|
}
|
|
|
|
|
2016-08-10 02:29:45 -05:00
|
|
|
const VAL: u32 = dummy(0xFFFF);
|
|
|
|
//~^ ERROR E0133
|
2016-08-18 22:58:26 -05:00
|
|
|
//~| NOTE call to unsafe function
|
2015-10-03 10:42:22 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(VAL, 0xFFFF0000);
|
|
|
|
}
|
|
|
|
|