From 75fc11806d43b330f4183803711212bb58021ae3 Mon Sep 17 00:00:00 2001 From: Agustin Chiappe Berrini Date: Thu, 7 Dec 2017 14:33:28 -0500 Subject: [PATCH 1/2] Ignore `unsopported constant expr` error --- src/librustc_passes/consts.rs | 1 + src/test/compile-fail/issue-7364.rs | 1 - .../compile-fail/static-mut-not-constant.rs | 1 - src/test/run-pass/issue-46553.rs | 32 +++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/issue-46553.rs 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..35177fc4ae901 --- /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)] +#![warn(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)()); +} From cbd25ed8f420a0728d5a6d8e726f898d26686060 Mon Sep 17 00:00:00 2001 From: Agustin Chiappe Berrini Date: Fri, 8 Dec 2017 03:13:13 -0500 Subject: [PATCH 2/2] deny instead of warn --- src/test/run-pass/issue-46553.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-pass/issue-46553.rs b/src/test/run-pass/issue-46553.rs index 35177fc4ae901..cf00ae4c46755 100644 --- a/src/test/run-pass/issue-46553.rs +++ b/src/test/run-pass/issue-46553.rs @@ -9,7 +9,7 @@ // except according to those terms. #![feature(const_fn)] -#![warn(const_err)] +#![deny(const_err)] pub struct Data { function: fn() -> T,