Skip to content

Commit 2ba3d49

Browse files
author
Alexander Regueiro
committed
Removed STATIC & STATIC_REF from Qualif flags.
1 parent 9d5fa12 commit 2ba3d49

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed

src/librustc_mir/transform/promote_consts.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,8 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
384384
local: &mut Local,
385385
_: PlaceContext<'tcx>,
386386
_: Location) {
387-
if self.source.local_kind(*local) == LocalKind::Temp {
388-
*local = self.promote_temp(*local);
389-
}
387+
assert_eq!(self.source.local_kind(*local), LocalKind::Temp);
388+
*local = self.promote_temp(*local);
390389
}
391390
}
392391

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ use super::promote_consts::{self, Candidate, TempState};
4343

4444
bitflags! {
4545
// Borrows of temporaries can be promoted only if
46-
// they have none of these qualifications, with
47-
// the exception of `STATIC_REF` (in statics only).
46+
// they have none of these qualifications.
4847
struct Qualif: u8 {
4948
// Constant containing interior mutability (UnsafeCell).
5049
const MUTABLE_INTERIOR = 1 << 0;

src/test/compile-fail/const-fn-not-safe-for-const.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ static Y: u32 = 0;
2828

2929
const fn get_Y() -> u32 {
3030
Y
31-
//~^ ERROR E0013
31+
//~^ ERROR E0013
3232
}
3333

3434
const fn get_Y_addr() -> &'static u32 {
3535
&Y
36-
//~^ ERROR E0013
3736
}
3837

3938
const fn get() -> u32 {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2016 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+
struct Foo {
12+
a: u32
13+
}
14+
15+
static S : Foo = Foo { a : 0 };
16+
static A : &'static u32 = &S.a;
17+
18+
fn main() {
19+
}

src/test/run-pass/static-by-value.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2016 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+
#![allow(warnings)]
12+
13+
static A: u32 = 0;
14+
static B: u32 = A;
15+
16+
fn main() {}

src/test/ui/issue-17718-const-bad-values.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ const C1: &'static mut [usize] = &mut [];
1313

1414
static mut S: usize = 3;
1515
const C2: &'static mut usize = unsafe { &mut S };
16-
//~^ ERROR: constants cannot refer to statics
17-
//~| ERROR: references in constants may only refer to immutable values
16+
//~^ ERROR: references in constants may only refer to immutable values
1817
//~| ERROR: references in constants may only refer to immutable values
1918

2019
fn main() {}

0 commit comments

Comments
 (0)