remove special-case code for statics and just use borrowck_fn

Fixes #38520
This commit is contained in:
Niko Matsakis 2017-02-18 06:52:16 -05:00
parent a9ec8841ef
commit 085d71c3ef
11 changed files with 61 additions and 83 deletions

View file

@ -19,8 +19,7 @@ static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
//~| NOTE statics require immutable values
//~| ERROR E0017
//~| NOTE statics require immutable values
//~| ERROR E0388
//~| NOTE cannot write data in a static definition
//~| ERROR cannot borrow
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
//~| NOTE statics require immutable values
//~| ERROR E0017

View file

@ -15,7 +15,7 @@ const CR: &'static mut i32 = &mut C; //~ ERROR E0017
//~| ERROR E0017
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
//~| ERROR E0017
//~| ERROR E0388
//~| ERROR cannot borrow
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
//~| ERROR E0017

View file

@ -0,0 +1,28 @@
// Copyright 2012 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.
// Regression test for #38520. Check that moves of `Foo` are not
// permitted as `Foo` is not copy (even in a static/const
// initializer).
#![feature(const_fn)]
struct Foo(usize);
const fn get(x: Foo) -> usize {
x.0
}
const X: Foo = Foo(22);
static Y: usize = get(*&X); //~ ERROR E0507
const Z: usize = get(*&X); //~ ERROR E0507
fn main() {
}

View file

@ -13,6 +13,6 @@ pub fn main() {
//~^ ERROR blocks in constants are limited to items and tail expressions
let p = 3;
//~^ ERROR blocks in constants are limited to items and tail expressions
&p
&p //~ ERROR `p` does not live long enough
};
}