Skip to content

Commit 442b7bd

Browse files
committed
Auto merge of #46570 - AgustinCB:issue-46553, r=oli-obk
Ignore `unsopported constant expr` error Fixes #46553
2 parents 6a36019 + cbd25ed commit 442b7bd

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/librustc_passes/consts.rs

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
135135
IndexOpFeatureGated => {}
136136
ErroneousReferencedConstant(_) => {}
137137
TypeckError => {}
138+
MiscCatchAll => {}
138139
_ => {
139140
self.tcx.lint_node(CONST_ERR,
140141
expr.id,

src/test/compile-fail/issue-7364.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ use std::cell::RefCell;
1616
static boxed: Box<RefCell<isize>> = box RefCell::new(0);
1717
//~^ ERROR allocations are not allowed in statics
1818
//~| ERROR `std::cell::RefCell<isize>: std::marker::Sync` is not satisfied
19-
//~| WARN unsupported constant expr
2019

2120
fn main() { }

src/test/compile-fail/static-mut-not-constant.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212

1313
static mut a: Box<isize> = box 3;
1414
//~^ ERROR allocations are not allowed in statics
15-
//~| WARN: constant evaluation error
1615

1716
fn main() {}

src/test/run-pass/issue-46553.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(const_fn)]
12+
#![deny(const_err)]
13+
14+
pub struct Data<T> {
15+
function: fn() -> T,
16+
}
17+
18+
impl<T> Data<T> {
19+
pub const fn new(function: fn() -> T) -> Data<T> {
20+
Data {
21+
function: function,
22+
}
23+
}
24+
}
25+
26+
pub static DATA: Data<i32> = Data::new(|| {
27+
413i32
28+
});
29+
30+
fn main() {
31+
print!("{:?}", (DATA.function)());
32+
}

0 commit comments

Comments
 (0)