librustc: Remove cross-borrowing of Box<T> to &T from the language,

except where trait objects are involved.

Part of issue #15349, though I'm leaving it open for trait objects.
Cross borrowing for trait objects remains because it is needed until we
have DST.

This will break code like:

    fn foo(x: &int) { ... }

    let a = box 3i;
    foo(a);

Change this code to:

    fn foo(x: &int) { ... }

    let a = box 3i;
    foo(&*a);

[breaking-change]
This commit is contained in:
Patrick Walton 2014-07-07 16:35:15 -07:00
parent ca24abd4d2
commit de70d76373
72 changed files with 206 additions and 204 deletions

View file

@ -120,46 +120,46 @@ use std::gc::{Gc, GC};
fn main() {
let bool_box: Gc<bool> = box(GC) true;
let bool_ref: &bool = bool_box;
let bool_ref: &bool = &*bool_box;
let int_box: Gc<int> = box(GC) -1;
let int_ref: &int = int_box;
let int_ref: &int = &*int_box;
let char_box: Gc<char> = box(GC) 'a';
let char_ref: &char = char_box;
let char_ref: &char = &*char_box;
let i8_box: Gc<i8> = box(GC) 68;
let i8_ref: &i8 = i8_box;
let i8_ref: &i8 = &*i8_box;
let i16_box: Gc<i16> = box(GC) -16;
let i16_ref: &i16 = i16_box;
let i16_ref: &i16 = &*i16_box;
let i32_box: Gc<i32> = box(GC) -32;
let i32_ref: &i32 = i32_box;
let i32_ref: &i32 = &*i32_box;
let i64_box: Gc<i64> = box(GC) -64;
let i64_ref: &i64 = i64_box;
let i64_ref: &i64 = &*i64_box;
let uint_box: Gc<uint> = box(GC) 1;
let uint_ref: &uint = uint_box;
let uint_ref: &uint = &*uint_box;
let u8_box: Gc<u8> = box(GC) 100;
let u8_ref: &u8 = u8_box;
let u8_ref: &u8 = &*u8_box;
let u16_box: Gc<u16> = box(GC) 16;
let u16_ref: &u16 = u16_box;
let u16_ref: &u16 = &*u16_box;
let u32_box: Gc<u32> = box(GC) 32;
let u32_ref: &u32 = u32_box;
let u32_ref: &u32 = &*u32_box;
let u64_box: Gc<u64> = box(GC) 64;
let u64_ref: &u64 = u64_box;
let u64_ref: &u64 = &*u64_box;
let f32_box: Gc<f32> = box(GC) 2.5;
let f32_ref: &f32 = f32_box;
let f32_ref: &f32 = &*f32_box;
let f64_box: Gc<f64> = box(GC) 3.5;
let f64_ref: &f64 = f64_box;
let f64_ref: &f64 = &*f64_box;
zzz(); // #break
}

View file

@ -100,12 +100,12 @@ fn main() {
let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11, y: 24.5 };
let managed_val = box(GC) SomeStruct { x: 12, y: 25.5 };
let managed_val_ref: &SomeStruct = managed_val;
let managed_val_ref: &SomeStruct = &*managed_val;
let managed_val_interior_ref_1: &int = &managed_val.x;
let managed_val_interior_ref_2: &f64 = &managed_val.y;
let unique_val = box SomeStruct { x: 13, y: 26.5 };
let unique_val_ref: &SomeStruct = unique_val;
let unique_val_ref: &SomeStruct = &*unique_val;
let unique_val_interior_ref_1: &int = &unique_val.x;
let unique_val_interior_ref_2: &f64 = &unique_val.y;

View file

@ -60,10 +60,10 @@ fn main() {
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
let managed_val: Gc<(i16, f32)> = box(GC) (-16, -21f32);
let managed_val_ref: &(i16, f32) = managed_val;
let managed_val_ref: &(i16, f32) = &*managed_val;
let unique_val: Box<(i16, f32)> = box() (-17, -22f32);
let unique_val_ref: &(i16, f32) = unique_val;
let unique_val_ref: &(i16, f32) = &*unique_val;
zzz(); // #break
}

View file

@ -116,46 +116,46 @@
fn main() {
let bool_box: Box<bool> = box true;
let bool_ref: &bool = bool_box;
let bool_ref: &bool = &*bool_box;
let int_box: Box<int> = box -1;
let int_ref: &int = int_box;
let int_ref: &int = &*int_box;
let char_box: Box<char> = box 'a';
let char_ref: &char = char_box;
let char_ref: &char = &*char_box;
let i8_box: Box<i8> = box 68;
let i8_ref: &i8 = i8_box;
let i8_ref: &i8 = &*i8_box;
let i16_box: Box<i16> = box -16;
let i16_ref: &i16 = i16_box;
let i16_ref: &i16 = &*i16_box;
let i32_box: Box<i32> = box -32;
let i32_ref: &i32 = i32_box;
let i32_ref: &i32 = &*i32_box;
let i64_box: Box<i64> = box -64;
let i64_ref: &i64 = i64_box;
let i64_ref: &i64 = &*i64_box;
let uint_box: Box<uint> = box 1;
let uint_ref: &uint = uint_box;
let uint_ref: &uint = &*uint_box;
let u8_box: Box<u8> = box 100;
let u8_ref: &u8 = u8_box;
let u8_ref: &u8 = &*u8_box;
let u16_box: Box<u16> = box 16;
let u16_ref: &u16 = u16_box;
let u16_ref: &u16 = &*u16_box;
let u32_box: Box<u32> = box 32;
let u32_ref: &u32 = u32_box;
let u32_ref: &u32 = &*u32_box;
let u64_box: Box<u64> = box 64;
let u64_ref: &u64 = u64_box;
let u64_ref: &u64 = &*u64_box;
let f32_box: Box<f32> = box 2.5;
let f32_ref: &f32 = f32_box;
let f32_ref: &f32 = &*f32_box;
let f64_box: Box<f64> = box 3.5;
let f64_ref: &f64 = f64_box;
let f64_ref: &f64 = &*f64_box;
zzz(); // #break
}

View file

@ -58,7 +58,7 @@ fn main() {
let closure: proc() = proc() {
zzz(); // #break
do_something(&constant, &a_struct.a, owned);
do_something(&constant, &a_struct.a, &*owned);
};
closure();