diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 776b5f3c984f1..6df860492f05a 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -135,6 +135,7 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> { IndexOpFeatureGated => {} ErroneousReferencedConstant(_) => {} TypeckError => {} + MiscCatchAll => {} _ => { self.tcx.lint_node(CONST_ERR, expr.id, diff --git a/src/test/compile-fail/issue-7364.rs b/src/test/compile-fail/issue-7364.rs index 3979790e3d4c7..16138c992ff78 100644 --- a/src/test/compile-fail/issue-7364.rs +++ b/src/test/compile-fail/issue-7364.rs @@ -16,6 +16,5 @@ use std::cell::RefCell; static boxed: Box> = box RefCell::new(0); //~^ ERROR allocations are not allowed in statics //~| ERROR `std::cell::RefCell: std::marker::Sync` is not satisfied -//~| WARN unsupported constant expr fn main() { } diff --git a/src/test/compile-fail/static-mut-not-constant.rs b/src/test/compile-fail/static-mut-not-constant.rs index 5cc3384f554d3..7e6ced12fe69a 100644 --- a/src/test/compile-fail/static-mut-not-constant.rs +++ b/src/test/compile-fail/static-mut-not-constant.rs @@ -12,6 +12,5 @@ static mut a: Box = box 3; //~^ ERROR allocations are not allowed in statics -//~| WARN: constant evaluation error fn main() {} diff --git a/src/test/run-pass/issue-46553.rs b/src/test/run-pass/issue-46553.rs new file mode 100644 index 0000000000000..cf00ae4c46755 --- /dev/null +++ b/src/test/run-pass/issue-46553.rs @@ -0,0 +1,32 @@ +// Copyright 2017 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_fn)] +#![deny(const_err)] + +pub struct Data { + function: fn() -> T, +} + +impl Data { + pub const fn new(function: fn() -> T) -> Data { + Data { + function: function, + } + } +} + +pub static DATA: Data = Data::new(|| { + 413i32 +}); + +fn main() { + print!("{:?}", (DATA.function)()); +}