auto merge of #15405 : pcwalton/rust/delifetime, r=nick29581

This was parsed by the parser but completely ignored; not even stored in
the AST!

This breaks code that looks like:

    static X: &'static [u8] = &'static [1, 2, 3];

Change this code to the shorter:

    static X: &'static [u8] = &[1, 2, 3];

Closes #15312.

[breaking-change]

r? @nick29581
This commit is contained in:
bors 2014-07-04 19:01:33 +00:00
commit 935da0739e
13 changed files with 23 additions and 27 deletions

View file

@ -32,7 +32,7 @@ static STATIC1: UnsafeEnum<int> = VariantSafe;
static STATIC2: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
static STATIC3: MyUnsafe<int> = MyUnsafe{value: STATIC2};
static STATIC4: &'static Unsafe<int> = &'static STATIC2;
static STATIC4: &'static Unsafe<int> = &STATIC2;
//~^ ERROR borrow of immutable static items with unsafe interior is not allowed
struct Wrap<T> {

View file

@ -113,12 +113,12 @@ static mut STATIC14: SafeStruct = SafeStruct {
field2: Variant4("str".to_string())
};
static STATIC15: &'static [Box<MyOwned>] = &'static [box MyOwned, box MyOwned];
static STATIC15: &'static [Box<MyOwned>] = &[box MyOwned, box MyOwned];
//~^ ERROR static items are not allowed to have custom pointers
//~^^ ERROR static items are not allowed to have custom pointers
static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) =
(&'static box MyOwned, &'static box MyOwned);
(&box MyOwned, &box MyOwned);
//~^ ERROR static items are not allowed to have custom pointers
//~^^ ERROR static items are not allowed to have custom pointers

View file

@ -9,7 +9,7 @@
// except according to those terms.
struct T (&'static [int]);
static t : T = T (&'static [5, 4, 3]);
static t : T = T (&[5, 4, 3]);
pub fn main () {
let T(ref v) = t;
assert_eq!(v[0], 5);

View file

@ -17,7 +17,7 @@ impl<'a> UninterpretedOption_NamePart {
static instance: UninterpretedOption_NamePart = UninterpretedOption_NamePart {
name_part: None,
};
&'static instance
&instance
}
}

View file

@ -43,7 +43,7 @@ fn default_instance() -> &'static Request {
// size of struct may be not equal to size of struct, and
// compiler crashes in internal assertion check.
};
&'static instance
&instance
}
fn non_default_instance() -> &'static Request {
@ -51,7 +51,7 @@ fn non_default_instance() -> &'static Request {
foo: TestSome(0x1020304050607080),
bar: 19,
};
&'static instance
&instance
}
pub fn main() {

View file

@ -11,7 +11,7 @@
// This test checks that the `_` type placeholder works
// correctly for enabling type inference.
static CONSTEXPR: *const int = &'static 413 as *const _;
static CONSTEXPR: *const int = &413 as *const _;
pub fn main() {
let x: Vec<_> = range(0u, 5).collect();