auto merge of #20760 : alexcrichton/rust/rollup, r=alexcrichton
This commit is contained in:
commit
00b112c45a
1002 changed files with 9170 additions and 9432 deletions
|
|
@ -9,7 +9,8 @@
|
|||
// except according to those terms.
|
||||
#![crate_name="inherited_stability"]
|
||||
#![crate_type = "lib"]
|
||||
#![experimental]
|
||||
#![unstable]
|
||||
#![staged_api]
|
||||
|
||||
pub fn experimental() {}
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ pub mod stable_mod {
|
|||
|
||||
#[unstable]
|
||||
pub mod unstable_mod {
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
pub fn experimental() {}
|
||||
|
||||
pub fn unstable() {}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@
|
|||
|
||||
#![crate_name="lint_output_format"]
|
||||
#![crate_type = "lib"]
|
||||
#![staged_api]
|
||||
|
||||
#[deprecated]
|
||||
pub fn foo() -> uint {
|
||||
20
|
||||
}
|
||||
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
pub fn bar() -> uint {
|
||||
40
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,15 +9,16 @@
|
|||
// except according to those terms.
|
||||
#![crate_name="lint_stability"]
|
||||
#![crate_type = "lib"]
|
||||
#![staged_api]
|
||||
|
||||
#[deprecated]
|
||||
pub fn deprecated() {}
|
||||
#[deprecated="text"]
|
||||
pub fn deprecated_text() {}
|
||||
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
pub fn experimental() {}
|
||||
#[experimental="text"]
|
||||
#[unstable="text"]
|
||||
pub fn experimental_text() {}
|
||||
|
||||
#[unstable]
|
||||
|
|
@ -51,9 +52,9 @@ impl MethodTester {
|
|||
#[deprecated="text"]
|
||||
pub fn method_deprecated_text(&self) {}
|
||||
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
pub fn method_experimental(&self) {}
|
||||
#[experimental="text"]
|
||||
#[unstable="text"]
|
||||
pub fn method_experimental_text(&self) {}
|
||||
|
||||
#[unstable]
|
||||
|
|
@ -85,9 +86,9 @@ pub trait Trait {
|
|||
#[deprecated="text"]
|
||||
fn trait_deprecated_text(&self) {}
|
||||
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
fn trait_experimental(&self) {}
|
||||
#[experimental="text"]
|
||||
#[unstable="text"]
|
||||
fn trait_experimental_text(&self) {}
|
||||
|
||||
#[unstable]
|
||||
|
|
@ -115,12 +116,12 @@ pub trait Trait {
|
|||
|
||||
impl Trait for MethodTester {}
|
||||
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
pub trait ExperimentalTrait {}
|
||||
|
||||
#[deprecated]
|
||||
pub struct DeprecatedStruct { pub i: int }
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
pub struct ExperimentalStruct { pub i: int }
|
||||
#[unstable]
|
||||
pub struct UnstableStruct { pub i: int }
|
||||
|
|
@ -134,7 +135,7 @@ pub struct LockedStruct { pub i: int }
|
|||
|
||||
#[deprecated]
|
||||
pub struct DeprecatedUnitStruct;
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
pub struct ExperimentalUnitStruct;
|
||||
#[unstable]
|
||||
pub struct UnstableUnitStruct;
|
||||
|
|
@ -149,7 +150,7 @@ pub struct LockedUnitStruct;
|
|||
pub enum Enum {
|
||||
#[deprecated]
|
||||
DeprecatedVariant,
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
ExperimentalVariant,
|
||||
#[unstable]
|
||||
UnstableVariant,
|
||||
|
|
@ -165,7 +166,7 @@ pub enum Enum {
|
|||
|
||||
#[deprecated]
|
||||
pub struct DeprecatedTupleStruct(pub int);
|
||||
#[experimental]
|
||||
#[unstable]
|
||||
pub struct ExperimentalTupleStruct(pub int);
|
||||
#[unstable]
|
||||
pub struct UnstableTupleStruct(pub int);
|
||||
|
|
|
|||
|
|
@ -10,3 +10,4 @@
|
|||
|
||||
#![cfg_attr(foo, experimental)]
|
||||
#![cfg_attr(not(foo), stable)]
|
||||
#![staged_api]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
// compile-flags:--cfg foo
|
||||
|
||||
#![cfg_attr(foo, experimental)]
|
||||
#![cfg_attr(foo, unstable)]
|
||||
#![cfg_attr(not(foo), stable)]
|
||||
|
||||
#![staged_api]
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#![feature(simd)]
|
||||
#![allow(experimental)]
|
||||
#![allow(unstable)]
|
||||
|
||||
// ignore-pretty very bad with line comments
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ pub use use_from_trait_xc::Trait;
|
|||
|
||||
fn main() {
|
||||
match () {
|
||||
Trait { x: 42u } => () //~ ERROR use of trait `Trait` in a struct pattern
|
||||
Trait { x: 42us } => () //~ ERROR use of trait `Trait` in a struct pattern
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
// except according to those terms.
|
||||
|
||||
|
||||
struct sty(Vec<int> );
|
||||
struct sty(Vec<isize> );
|
||||
|
||||
fn unpack<F>(_unpack: F) where F: FnOnce(&sty) -> Vec<int> {}
|
||||
fn unpack<F>(_unpack: F) where F: FnOnce(&sty) -> Vec<isize> {}
|
||||
|
||||
fn main() {
|
||||
let _foo = unpack(|s| {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
// error-pattern: parameters were supplied
|
||||
|
||||
fn f(x: int) { }
|
||||
fn f(x: isize) { }
|
||||
|
||||
fn main() { let i: (); i = f(); }
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
fn f(x: int) { }
|
||||
fn f(x: isize) { }
|
||||
|
||||
fn main() { let i: (); i = f(()); }
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@
|
|||
// Test that the old fixed length array syntax is a parsing error.
|
||||
|
||||
fn main() {
|
||||
let _x: [int, ..3] = [0i, 1, 2]; //~ ERROR
|
||||
let _x: [isize, ..3] = [0is, 1, 2]; //~ ERROR
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@
|
|||
// Test that the old repeating array syntax gives an error.
|
||||
|
||||
fn main() {
|
||||
let _ = [0i, ..3]; //~ ERROR
|
||||
let _ = [0is, ..3]; //~ ERROR
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@
|
|||
|
||||
#![feature(asm)]
|
||||
|
||||
fn foo(x: int) { println!("{}", x); }
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64"))]
|
||||
pub fn main() {
|
||||
let x: int;
|
||||
let y: int;
|
||||
let x: isize;
|
||||
let y: isize;
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "=r"(x) : "=r"(5u)); //~ ERROR input operand constraint contains '='
|
||||
asm!("mov $1, $0" : "=r"(y) : "+r"(5u)); //~ ERROR input operand constraint contains '+'
|
||||
asm!("mov $1, $0" : "=r"(x) : "=r"(5us)); //~ ERROR input operand constraint contains '='
|
||||
asm!("mov $1, $0" : "=r"(y) : "+r"(5us)); //~ ERROR input operand constraint contains '+'
|
||||
}
|
||||
foo(x);
|
||||
foo(y);
|
||||
|
|
|
|||
|
|
@ -18,17 +18,17 @@
|
|||
target_arch = "x86_64"))]
|
||||
pub fn main() {
|
||||
// assignment not dead
|
||||
let mut x: int = 0;
|
||||
let mut x: isize = 0;
|
||||
unsafe {
|
||||
// extra colon
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5u), "0"(x) : : "cc");
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5us), "0"(x) : : "cc");
|
||||
//~^ WARNING unrecognized option
|
||||
}
|
||||
assert_eq!(x, 5);
|
||||
|
||||
unsafe {
|
||||
// comma in place of a colon
|
||||
asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8u) : "cc", "volatile");
|
||||
asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8us) : "cc", "volatile");
|
||||
//~^ WARNING expected a clobber, found an option
|
||||
}
|
||||
assert_eq!(x, 13);
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@
|
|||
|
||||
#![feature(asm)]
|
||||
|
||||
fn foo(x: int) { println!("{}", x); }
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64"))]
|
||||
pub fn main() {
|
||||
let x: int;
|
||||
let x: isize;
|
||||
x = 1; //~ NOTE prior assignment occurs here
|
||||
foo(x);
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5u)); //~ ERROR re-assignment of immutable variable `x`
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(5us)); //~ ERROR re-assignment of immutable variable `x`
|
||||
}
|
||||
foo(x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@
|
|||
|
||||
#![feature(asm)]
|
||||
|
||||
fn foo(x: int) { println!("{}", x); }
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64"))]
|
||||
pub fn main() {
|
||||
let x: int;
|
||||
let x: isize;
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "r"(x) : "r"(5u)); //~ ERROR output operand constraint lacks '='
|
||||
asm!("mov $1, $0" : "r"(x) : "r"(5us)); //~ ERROR output operand constraint lacks '='
|
||||
}
|
||||
foo(x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@
|
|||
|
||||
#![feature(asm)]
|
||||
|
||||
fn foo(x: int) { println!("{}", x); }
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64"))]
|
||||
pub fn main() {
|
||||
let x: int;
|
||||
let x: isize;
|
||||
unsafe {
|
||||
asm!("mov $1, $0" : "=r"(x) : "r"(x)); //~ ERROR use of possibly uninitialized variable: `x`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn test() {
|
||||
let v: int;
|
||||
let v: isize;
|
||||
v = 1; //~ NOTE prior assignment occurs here
|
||||
println!("v={}", v);
|
||||
v = 2; //~ ERROR re-assignment of immutable variable
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct cat {
|
||||
meows : uint,
|
||||
meows : usize,
|
||||
|
||||
how_hungry : int,
|
||||
how_hungry : isize,
|
||||
}
|
||||
|
||||
impl cat {
|
||||
pub fn speak(&self) { self.meows += 1u; }
|
||||
pub fn speak(&self) { self.meows += 1us; }
|
||||
}
|
||||
|
||||
fn cat(in_x : uint, in_y : int) -> cat {
|
||||
fn cat(in_x : usize, in_y : isize) -> cat {
|
||||
cat {
|
||||
meows: in_x,
|
||||
how_hungry: in_y
|
||||
|
|
@ -26,6 +26,6 @@ fn cat(in_x : uint, in_y : int) -> cat {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let nyan : cat = cat(52u, 99);
|
||||
let nyan : cat = cat(52us, 99);
|
||||
nyan.speak = |&:| println!("meow"); //~ ERROR attempted to take value of method
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
type Bar = int; //~ERROR associated items are not allowed in inherent impls
|
||||
type Bar = isize; //~ERROR associated items are not allowed in inherent impls
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// Test equality constraints on associated types in a where clause.
|
||||
|
||||
pub trait ToInt {
|
||||
fn to_int(&self) -> int;
|
||||
fn to_int(&self) -> isize;
|
||||
}
|
||||
|
||||
pub trait GetToInt
|
||||
|
|
@ -21,13 +21,13 @@ pub trait GetToInt
|
|||
fn get(&self) -> <Self as GetToInt>::R;
|
||||
}
|
||||
|
||||
fn foo<G>(g: G) -> int
|
||||
fn foo<G>(g: G) -> isize
|
||||
where G : GetToInt
|
||||
{
|
||||
ToInt::to_int(&g.get()) //~ ERROR not implemented
|
||||
}
|
||||
|
||||
fn bar<G : GetToInt>(g: G) -> int
|
||||
fn bar<G : GetToInt>(g: G) -> isize
|
||||
where G::R : ToInt
|
||||
{
|
||||
ToInt::to_int(&g.get()) // OK
|
||||
|
|
|
|||
59
src/test/compile-fail/associated-types-coherence-failure.rs
Normal file
59
src/test/compile-fail/associated-types-coherence-failure.rs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// Copyright 2014 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.
|
||||
|
||||
// Test that coherence detects overlap when some of the types in the
|
||||
// impls are projections of associated type. Issue #20624.
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
pub struct Cow<'a, B: ?Sized>;
|
||||
|
||||
/// Trait for moving into a `Cow`
|
||||
pub trait IntoCow<'a, B: ?Sized> {
|
||||
/// Moves `self` into `Cow`
|
||||
fn into_cow(self) -> Cow<'a, B>;
|
||||
}
|
||||
|
||||
impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned {
|
||||
//~^ ERROR E0119
|
||||
fn into_cow(self) -> Cow<'a, B> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, B: ?Sized> IntoCow<'a, B> for <B as ToOwned>::Owned where B: ToOwned {
|
||||
//~^ ERROR E0119
|
||||
fn into_cow(self) -> Cow<'a, B> {
|
||||
Cow
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned {
|
||||
fn into_cow(self) -> Cow<'a, B> {
|
||||
Cow
|
||||
}
|
||||
}
|
||||
|
||||
impl ToOwned for u8 {
|
||||
type Owned = &'static u8;
|
||||
fn to_owned(&self) -> &'static u8 { panic!() }
|
||||
}
|
||||
|
||||
/// A generalization of Clone to borrowed data.
|
||||
pub trait ToOwned {
|
||||
type Owned;
|
||||
|
||||
/// Create owned data from borrowed data, usually by copying.
|
||||
fn to_owned(&self) -> Self::Owned;
|
||||
}
|
||||
|
||||
|
||||
fn main() {}
|
||||
|
||||
|
|
@ -18,9 +18,9 @@ pub trait Foo {
|
|||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for int {
|
||||
type A = uint;
|
||||
fn boo(&self) -> uint { 42 }
|
||||
impl Foo for isize {
|
||||
type A = usize;
|
||||
fn boo(&self) -> usize { 42 }
|
||||
}
|
||||
|
||||
fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ pub trait Foo {
|
|||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for int {
|
||||
type A = uint;
|
||||
fn boo(&self) -> uint {
|
||||
impl Foo for isize {
|
||||
type A = usize;
|
||||
fn boo(&self) -> usize {
|
||||
42
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ pub fn baz(x: &Foo<A=Bar>) {
|
|||
|
||||
|
||||
pub fn main() {
|
||||
let a = 42i;
|
||||
let a = 42is;
|
||||
foo1(a); //~ERROR expected usize, found struct Bar
|
||||
baz(&a); //~ERROR expected usize, found struct Bar
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@
|
|||
|
||||
trait Foo {
|
||||
type A;
|
||||
fn bar() -> int;
|
||||
fn bar() -> isize;
|
||||
}
|
||||
|
||||
impl Foo for int {
|
||||
type A = uint;
|
||||
fn bar() -> int { 42 }
|
||||
impl Foo for isize {
|
||||
type A = usize;
|
||||
fn bar() -> isize { 42 }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x: int = Foo::<A=uint>::bar();
|
||||
let x: isize = Foo::<A=usize>::bar();
|
||||
//~^ERROR unexpected binding of associated item in expression path
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,43 +17,43 @@ pub trait TheTrait<T> {
|
|||
}
|
||||
|
||||
struct IntStruct {
|
||||
x: int
|
||||
x: isize
|
||||
}
|
||||
|
||||
impl<'a> TheTrait<&'a int> for IntStruct {
|
||||
type A = &'a int;
|
||||
impl<'a> TheTrait<&'a isize> for IntStruct {
|
||||
type A = &'a isize;
|
||||
|
||||
fn get(&self, t: &'a int) -> &'a int {
|
||||
fn get(&self, t: &'a isize) -> &'a isize {
|
||||
t
|
||||
}
|
||||
}
|
||||
|
||||
struct UintStruct {
|
||||
x: int
|
||||
x: isize
|
||||
}
|
||||
|
||||
impl<'a> TheTrait<&'a int> for UintStruct {
|
||||
type A = &'a uint;
|
||||
impl<'a> TheTrait<&'a isize> for UintStruct {
|
||||
type A = &'a usize;
|
||||
|
||||
fn get(&self, t: &'a int) -> &'a uint {
|
||||
fn get(&self, t: &'a isize) -> &'a usize {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<T>()
|
||||
where T : for<'x> TheTrait<&'x int, A = &'x int>
|
||||
where T : for<'x> TheTrait<&'x isize, A = &'x isize>
|
||||
{
|
||||
// ok for IntStruct, but not UintStruct
|
||||
}
|
||||
|
||||
fn bar<T>()
|
||||
where T : for<'x> TheTrait<&'x int, A = &'x uint>
|
||||
where T : for<'x> TheTrait<&'x isize, A = &'x usize>
|
||||
{
|
||||
// ok for UintStruct, but not IntStruct
|
||||
}
|
||||
|
||||
fn baz<T>()
|
||||
where T : for<'x,'y> TheTrait<&'x int, A = &'y int>
|
||||
where T : for<'x,'y> TheTrait<&'x isize, A = &'y isize>
|
||||
{
|
||||
// not ok for either struct, due to the use of two lifetimes
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,24 +19,24 @@ pub trait Foo {
|
|||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for int {
|
||||
type A = uint;
|
||||
impl Foo for isize {
|
||||
type A = usize;
|
||||
type B = char;
|
||||
fn boo(&self) -> uint {
|
||||
fn boo(&self) -> usize {
|
||||
42
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let a = &42i as &Foo<A=uint, B=char>;
|
||||
let a = &42is as &Foo<A=usize, B=char>;
|
||||
|
||||
let b = &42i as &Foo<A=uint>;
|
||||
let b = &42is as &Foo<A=usize>;
|
||||
//~^ ERROR the value of the associated type `B` (from the trait `Foo`) must be specified
|
||||
|
||||
let c = &42i as &Foo<B=char>;
|
||||
let c = &42is as &Foo<B=char>;
|
||||
//~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified
|
||||
|
||||
let d = &42i as &Foo;
|
||||
let d = &42is as &Foo;
|
||||
//~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified
|
||||
//~| ERROR the value of the associated type `B` (from the trait `Foo`) must be specified
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ trait Foo<T> {
|
|||
fn get_bar(&self) -> Self::Bar;
|
||||
}
|
||||
|
||||
fn f<T:Foo<int>>(t: &T) {
|
||||
fn f<T:Foo<isize>>(t: &T) {
|
||||
let u: <T as Foo<usize>>::Bar = t.get_bar();
|
||||
//~^ ERROR the trait `Foo<usize>` is not implemented for the type `T`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ trait Trait {
|
|||
type Type;
|
||||
}
|
||||
|
||||
impl Trait for int {} //~ ERROR missing: `Type`
|
||||
impl Trait for isize {} //~ ERROR missing: `Type`
|
||||
|
||||
fn main() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ trait Get {
|
|||
}
|
||||
|
||||
struct Struct {
|
||||
x: int,
|
||||
x: isize,
|
||||
}
|
||||
|
||||
impl Struct {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ pub trait Foo {
|
|||
type A;
|
||||
}
|
||||
|
||||
impl Foo for int {
|
||||
type A = uint;
|
||||
impl Foo for isize {
|
||||
type A = usize;
|
||||
}
|
||||
|
||||
pub fn f1<T: Foo>(a: T, x: T::A) {}
|
||||
|
|
@ -45,7 +45,7 @@ pub fn f1_uint_int() {
|
|||
}
|
||||
|
||||
pub fn f2_int() {
|
||||
let _: int = f2(2is);
|
||||
let _: isize = f2(2is);
|
||||
//~^ ERROR expected `isize`, found `usize`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub trait Foo<T> {
|
|||
fn get(&self, t: T) -> Self::A;
|
||||
}
|
||||
|
||||
fn foo2<I>(x: <I as for<'x> Foo<&'x int>>::A)
|
||||
fn foo2<I>(x: <I as for<'x> Foo<&'x isize>>::A)
|
||||
//~^ ERROR expected identifier, found keyword `for`
|
||||
//~| ERROR expected one of `::` or `>`
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ pub trait Foo<T> {
|
|||
fn get(&self, t: T) -> Self::A;
|
||||
}
|
||||
|
||||
fn foo<'a, I : for<'x> Foo<&'x int>>(
|
||||
x: <I as Foo<&'a int>>::A)
|
||||
fn foo<'a, I : for<'x> Foo<&'x isize>>(
|
||||
x: <I as Foo<&'a isize>>::A)
|
||||
{
|
||||
let y: I::A = x;
|
||||
}
|
||||
|
||||
fn bar<'a, 'b, I : for<'x> Foo<&'x int>>(
|
||||
x: <I as Foo<&'a int>>::A,
|
||||
y: <I as Foo<&'b int>>::A,
|
||||
fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
|
||||
x: <I as Foo<&'a isize>>::A,
|
||||
y: <I as Foo<&'b isize>>::A,
|
||||
cond: bool)
|
||||
{
|
||||
// x and y here have two distinct lifetimes:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub trait Foo<T> {
|
|||
fn get(&self, t: T) -> Self::A;
|
||||
}
|
||||
|
||||
fn foo2<I : for<'x> Foo<&'x int>>(
|
||||
fn foo2<I : for<'x> Foo<&'x isize>>(
|
||||
x: I::A)
|
||||
//~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
|
||||
{
|
||||
|
|
@ -28,15 +28,15 @@ fn foo2<I : for<'x> Foo<&'x int>>(
|
|||
// specifically for fn signatures.
|
||||
}
|
||||
|
||||
fn foo3<I : for<'x> Foo<&'x int>>(
|
||||
x: <I as Foo<&int>>::A)
|
||||
fn foo3<I : for<'x> Foo<&'x isize>>(
|
||||
x: <I as Foo<&isize>>::A)
|
||||
{
|
||||
// OK, in this case we spelled out the precise regions involved, though we left one of
|
||||
// them anonymous.
|
||||
}
|
||||
|
||||
fn foo4<'a, I : for<'x> Foo<&'x int>>(
|
||||
x: <I as Foo<&'a int>>::A)
|
||||
fn foo4<'a, I : for<'x> Foo<&'x isize>>(
|
||||
x: <I as Foo<&'a isize>>::A)
|
||||
{
|
||||
// OK, in this case we spelled out the precise regions involved.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,18 +17,18 @@ pub trait Foo<T> {
|
|||
fn get(&self, t: T) -> Self::A;
|
||||
}
|
||||
|
||||
struct SomeStruct<I : for<'x> Foo<&'x int>> {
|
||||
struct SomeStruct<I : for<'x> Foo<&'x isize>> {
|
||||
field: I::A
|
||||
//~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
|
||||
}
|
||||
|
||||
struct AnotherStruct<I : for<'x> Foo<&'x int>> {
|
||||
field: <I as Foo<&int>>::A
|
||||
struct AnotherStruct<I : for<'x> Foo<&'x isize>> {
|
||||
field: <I as Foo<&isize>>::A
|
||||
//~^ ERROR missing lifetime specifier
|
||||
}
|
||||
|
||||
struct YetAnotherStruct<'a, I : for<'x> Foo<&'x int>> {
|
||||
field: <I as Foo<&'a int>>::A
|
||||
struct YetAnotherStruct<'a, I : for<'x> Foo<&'x isize>> {
|
||||
field: <I as Foo<&'a isize>>::A
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,17 @@ pub trait Foo<T> {
|
|||
fn get(&self, t: T) -> Self::A;
|
||||
}
|
||||
|
||||
trait SomeTrait<I : for<'x> Foo<&'x int>> {
|
||||
trait SomeTrait<I : for<'x> Foo<&'x isize>> {
|
||||
fn some_method(&self, arg: I::A);
|
||||
//~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
|
||||
}
|
||||
|
||||
trait AnotherTrait<I : for<'x> Foo<&'x int>> {
|
||||
fn some_method(&self, arg: <I as Foo<&int>>::A);
|
||||
trait AnotherTrait<I : for<'x> Foo<&'x isize>> {
|
||||
fn some_method(&self, arg: <I as Foo<&isize>>::A);
|
||||
}
|
||||
|
||||
trait YetAnotherTrait<I : for<'x> Foo<&'x int>> {
|
||||
fn some_method<'a>(&self, arg: <I as Foo<&'a int>>::A);
|
||||
trait YetAnotherTrait<I : for<'x> Foo<&'x isize>> {
|
||||
fn some_method<'a>(&self, arg: <I as Foo<&'a isize>>::A);
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@
|
|||
|
||||
trait Foo {
|
||||
type A;
|
||||
fn bar() -> int;
|
||||
fn bar() -> isize;
|
||||
}
|
||||
|
||||
impl Foo for int {
|
||||
type A = uint;
|
||||
fn bar() -> int { 42 }
|
||||
impl Foo for isize {
|
||||
type A = usize;
|
||||
fn bar() -> isize { 42 }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x: int = Foo::bar();
|
||||
let x: isize = Foo::bar();
|
||||
//~^ ERROR type annotations required
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ trait MyIter {
|
|||
fn test(&self);
|
||||
}
|
||||
|
||||
impl<'a> MyIter for &'a [int] {
|
||||
impl<'a> MyIter for &'a [isize] {
|
||||
fn test_mut(&mut self) { }
|
||||
fn test(&self) { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ fn main() {
|
|||
assert_eq!(z, 21);
|
||||
let forty: fish = fish{a: box 40};
|
||||
let two: fish = fish{a: box 2};
|
||||
let answer: int = forty.a + two.a;
|
||||
let answer: isize = forty.a + two.a;
|
||||
//~^ ERROR binary operation `+` cannot be applied to type `Box<isize>`
|
||||
println!("{}", answer);
|
||||
assert_eq!(answer, 42);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
// Tests that a function with a ! annotation always actually fails
|
||||
|
||||
fn bad_bang(i: uint) -> ! {
|
||||
return 7u; //~ ERROR `return` in a function declared as diverging [E0166]
|
||||
fn bad_bang(i: usize) -> ! {
|
||||
return 7us; //~ ERROR `return` in a function declared as diverging [E0166]
|
||||
}
|
||||
|
||||
fn main() { bad_bang(5u); }
|
||||
fn main() { bad_bang(5us); }
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
// Tests that a function with a ! annotation always actually fails
|
||||
|
||||
fn bad_bang(i: uint) -> ! { //~ ERROR computation may converge in a function marked as diverging
|
||||
if i < 0u { } else { panic!(); }
|
||||
fn bad_bang(i: usize) -> ! { //~ ERROR computation may converge in a function marked as diverging
|
||||
if i < 0us { } else { panic!(); }
|
||||
}
|
||||
|
||||
fn main() { bad_bang(5u); }
|
||||
fn main() { bad_bang(5us); }
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// error-pattern: can't capture dynamic environment in a fn item;
|
||||
fn foo() {
|
||||
let x: int;
|
||||
let x: isize;
|
||||
fn bar() { log(debug, x); }
|
||||
}
|
||||
fn main() { foo(); }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// error-pattern: can't capture dynamic environment in a fn item;
|
||||
fn foo(x: int) {
|
||||
fn foo(x: isize) {
|
||||
fn bar() { log(debug, x); }
|
||||
}
|
||||
fn main() { foo(2); }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
// error-pattern: can't capture dynamic environment in a fn item;
|
||||
fn foo(x: int) {
|
||||
fn foo(x: isize) {
|
||||
fn mth() {
|
||||
fn bar() { log(debug, x); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main(x: int) { } //~ ERROR: main function expects type
|
||||
fn main(x: isize) { } //~ ERROR: main function expects type
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// error-pattern: expected
|
||||
|
||||
fn main() {
|
||||
let int x = 5;
|
||||
let isize x = 5;
|
||||
match x;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn foo<T:'static>() {
|
||||
1u.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented
|
||||
1us.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented
|
||||
}
|
||||
|
||||
trait bar {
|
||||
fn bar<T:Send>(&self);
|
||||
}
|
||||
|
||||
impl bar for uint {
|
||||
impl bar for usize {
|
||||
fn bar<T:Send>(&self) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ trait Trait<T> {
|
|||
}
|
||||
|
||||
struct S2 {
|
||||
contents: int,
|
||||
contents: isize,
|
||||
}
|
||||
|
||||
impl Trait<int> for S2 {
|
||||
fn new<U>(x: int, _: U) -> S2 {
|
||||
impl Trait<isize> for S2 {
|
||||
fn new<U>(x: isize, _: U) -> S2 {
|
||||
S2 {
|
||||
contents: x,
|
||||
}
|
||||
|
|
@ -45,16 +45,16 @@ impl Trait<int> for S2 {
|
|||
}
|
||||
|
||||
fn foo<'a>() {
|
||||
let _ = S::new::<int,f64>(1, 1.0);
|
||||
let _ = S::new::<isize,f64>(1, 1.0);
|
||||
//~^ ERROR too many type parameters provided
|
||||
|
||||
let _ = S::<'a,int>::new::<f64>(1, 1.0);
|
||||
let _ = S::<'a,isize>::new::<f64>(1, 1.0);
|
||||
//~^ ERROR too many lifetime parameters provided
|
||||
|
||||
let _: S2 = Trait::new::<int,f64>(1, 1.0);
|
||||
let _: S2 = Trait::new::<isize,f64>(1, 1.0);
|
||||
//~^ ERROR too many type parameters provided
|
||||
|
||||
let _: S2 = Trait::<'a,int>::new::<f64>(1, 1.0);
|
||||
let _: S2 = Trait::<'a,isize>::new::<f64>(1, 1.0);
|
||||
//~^ ERROR too many lifetime parameters provided
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@
|
|||
// error-pattern: expected
|
||||
|
||||
fn main() {
|
||||
let x.y::<int>.z foo;
|
||||
let x.y::<isize>.z foo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn f() -> ! { //~ ERROR computation may converge in a function marked as diverging
|
||||
3i
|
||||
3is
|
||||
}
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let x: [int 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `3`
|
||||
let x: [isize 3]; //~ ERROR expected one of `(`, `+`, `::`, `;`, or `]`, found `3`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
struct Foo { x: int }
|
||||
struct Foo { x: isize }
|
||||
match (Foo { x: 10 }) {
|
||||
Foo { ref x: ref x } => {}, //~ ERROR unexpected `:`
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) {
|
|||
let m = &mut x;
|
||||
let n = &y;
|
||||
|
||||
*m //~ ERROR: cannot move out of dereference of `&mut`-pointer
|
||||
*m //~ ERROR: cannot move out of borrowed content
|
||||
+
|
||||
*n; //~ ERROR: cannot move out of dereference of `&`-pointer
|
||||
*n; //~ ERROR: cannot move out of borrowed content
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
// error-pattern: unresolved
|
||||
|
||||
enum color { rgb(int, int, int), rgba(int, int, int, int), }
|
||||
enum color { rgb(isize, isize, isize), rgba(isize, isize, isize, isize), }
|
||||
|
||||
fn main() {
|
||||
let red: color = rgb(255, 0, 0);
|
||||
|
|
|
|||
|
|
@ -13,29 +13,29 @@
|
|||
// Tests that we can't assign to or mutably borrow upvars from `Fn`
|
||||
// closures (issue #17780)
|
||||
|
||||
fn set(x: &mut uint) { *x = 5; }
|
||||
fn set(x: &mut usize) { *x = 5; }
|
||||
|
||||
fn main() {
|
||||
// By-ref captures
|
||||
{
|
||||
let mut x = 0u;
|
||||
let mut x = 0us;
|
||||
let _f = |&:| x = 42; //~ ERROR cannot assign
|
||||
|
||||
let mut y = 0u;
|
||||
let mut y = 0us;
|
||||
let _g = |&:| set(&mut y); //~ ERROR cannot borrow
|
||||
|
||||
let mut z = 0u;
|
||||
let mut z = 0us;
|
||||
let _h = |&mut:| { set(&mut z); |&:| z = 42; }; //~ ERROR cannot assign
|
||||
}
|
||||
// By-value captures
|
||||
{
|
||||
let mut x = 0u;
|
||||
let mut x = 0us;
|
||||
let _f = move |&:| x = 42; //~ ERROR cannot assign
|
||||
|
||||
let mut y = 0u;
|
||||
let mut y = 0us;
|
||||
let _g = move |&:| set(&mut y); //~ ERROR cannot borrow
|
||||
|
||||
let mut z = 0u;
|
||||
let mut z = 0us;
|
||||
let _h = move |&mut:| { set(&mut z); move |&:| z = 42; }; //~ ERROR cannot assign
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,33 +11,33 @@
|
|||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct Foo(Box<int>, int);
|
||||
struct Foo(Box<isize>, isize);
|
||||
|
||||
struct Bar(int, int);
|
||||
struct Bar(isize, isize);
|
||||
|
||||
fn main() {
|
||||
let x = (box 1i, 2i);
|
||||
let x = (box 1is, 2is);
|
||||
let r = &x.0;
|
||||
let y = x; //~ ERROR cannot move out of `x` because it is borrowed
|
||||
|
||||
let mut x = (1i, 2i);
|
||||
let mut x = (1is, 2is);
|
||||
let a = &x.0;
|
||||
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as
|
||||
|
||||
let mut x = (1i, 2i);
|
||||
let mut x = (1is, 2is);
|
||||
let a = &mut x.0;
|
||||
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
|
||||
|
||||
|
||||
let x = Foo(box 1i, 2i);
|
||||
let x = Foo(box 1is, 2is);
|
||||
let r = &x.0;
|
||||
let y = x; //~ ERROR cannot move out of `x` because it is borrowed
|
||||
|
||||
let mut x = Bar(1i, 2i);
|
||||
let mut x = Bar(1is, 2is);
|
||||
let a = &x.0;
|
||||
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as
|
||||
|
||||
let mut x = Bar(1i, 2i);
|
||||
let mut x = Bar(1is, 2is);
|
||||
let a = &mut x.0;
|
||||
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let i: int;
|
||||
let i: isize;
|
||||
|
||||
println!("{}", false && { i = 5; true });
|
||||
println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i`
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// Tests that we are able to distinguish when loans borrow different
|
||||
// anonymous fields of a tuple vs the same anonymous field.
|
||||
|
||||
struct Y(uint, uint);
|
||||
struct Y(usize, usize);
|
||||
|
||||
fn distinct_variant() {
|
||||
let mut y = Y(1, 2);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// anonymous fields of a tuple vs the same anonymous field.
|
||||
|
||||
fn distinct_variant() {
|
||||
let mut y = (1i, 2i);
|
||||
let mut y = (1is, 2is);
|
||||
|
||||
let a = match y {
|
||||
(ref mut a, _) => a
|
||||
|
|
@ -27,7 +27,7 @@ fn distinct_variant() {
|
|||
}
|
||||
|
||||
fn same_variant() {
|
||||
let mut y = (1i, 2i);
|
||||
let mut y = (1is, 2is);
|
||||
|
||||
let a = match y {
|
||||
(ref mut a, _) => a
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// anonymous fields of an enum variant vs the same anonymous field.
|
||||
|
||||
enum Foo {
|
||||
X, Y(uint, uint)
|
||||
X, Y(usize, usize)
|
||||
}
|
||||
|
||||
fn distinct_variant() {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
#![feature(box_syntax)]
|
||||
|
||||
fn f() {
|
||||
let mut a = [box 0i, box 1i];
|
||||
let mut a = [box 0is, box 1is];
|
||||
drop(a[0]);
|
||||
a[1] = box 2i;
|
||||
a[1] = box 2is;
|
||||
drop(a[0]); //~ ERROR use of moved value: `a[..]`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,22 +9,22 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct Point {
|
||||
x: int,
|
||||
y: int,
|
||||
x: isize,
|
||||
y: isize,
|
||||
}
|
||||
|
||||
fn a() {
|
||||
let mut p = vec!(1);
|
||||
|
||||
// Create an immutable pointer into p's contents:
|
||||
let q: &int = &p[0];
|
||||
let q: &isize = &p[0];
|
||||
|
||||
p[0] = 5; //~ ERROR cannot borrow
|
||||
|
||||
println!("{}", *q);
|
||||
}
|
||||
|
||||
fn borrow<F>(_x: &[int], _f: F) where F: FnOnce() {}
|
||||
fn borrow<F>(_x: &[isize], _f: F) where F: FnOnce() {}
|
||||
|
||||
fn b() {
|
||||
// here we alias the mutable vector into an imm slice and try to
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct point { x: int, y: int }
|
||||
struct point { x: isize, y: isize }
|
||||
|
||||
fn a() {
|
||||
let mut p = point {x: 3, y: 4};
|
||||
|
|
@ -16,7 +16,7 @@ fn a() {
|
|||
|
||||
// This assignment is illegal because the field x is not
|
||||
// inherently mutable; since `p` was made immutable, `p.x` is now
|
||||
// immutable. Otherwise the type of &_q.x (&int) would be wrong.
|
||||
// immutable. Otherwise the type of &_q.x (&isize) would be wrong.
|
||||
p.x = 5; //~ ERROR cannot assign to `p.x`
|
||||
q.x;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// borrowed (but otherwise non-aliasable) location is illegal.
|
||||
|
||||
struct S<'a> {
|
||||
pointer: &'a mut int
|
||||
pointer: &'a mut isize
|
||||
}
|
||||
|
||||
fn a(s: &S) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// borrowed (but otherwise non-aliasable) location is illegal.
|
||||
|
||||
struct S<'a> {
|
||||
pointer: &'a mut int
|
||||
pointer: &'a mut isize
|
||||
}
|
||||
|
||||
fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
static foo: int = 5;
|
||||
static foo: isize = 5;
|
||||
|
||||
fn main() {
|
||||
// assigning to various global constants
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// Tests that auto-ref can't create mutable aliases to immutable memory.
|
||||
|
||||
struct Foo {
|
||||
x: int
|
||||
x: isize
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
enum Either<T, U> { Left(T), Right(U) }
|
||||
|
||||
struct X(Either<(uint,uint), fn()>);
|
||||
struct X(Either<(usize,usize), fn()>);
|
||||
|
||||
impl X {
|
||||
pub fn with<F>(&self, blk: F) where F: FnOnce(&Either<(uint, uint), fn()>) {
|
||||
pub fn with<F>(&self, blk: F) where F: FnOnce(&Either<(usize, usize), fn()>) {
|
||||
let X(ref e) = *self;
|
||||
blk(e)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn rewrite(v: &mut Box<uint>) -> uint {
|
||||
fn rewrite(v: &mut Box<usize>) -> usize {
|
||||
*v = box 22;
|
||||
**v
|
||||
}
|
||||
|
||||
fn add(v: &uint, w: uint) -> uint {
|
||||
fn add(v: &usize, w: usize) -> usize {
|
||||
*v + w
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn rewrite(v: &mut Box<uint>) -> uint {
|
||||
fn rewrite(v: &mut Box<usize>) -> usize {
|
||||
*v = box 22;
|
||||
**v
|
||||
}
|
||||
|
||||
fn add(v: &uint, w: Box<uint>) -> uint {
|
||||
fn add(v: &usize, w: Box<usize>) -> usize {
|
||||
*v + *w
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
fn force<F>(f: F) where F: FnOnce() { f(); }
|
||||
fn main() {
|
||||
let x: int;
|
||||
let x: isize;
|
||||
force(|| { //~ ERROR capture of possibly uninitialized variable: `x`
|
||||
println!("{}", x);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ struct Foo {
|
|||
impl Copy for Foo {}
|
||||
|
||||
struct Bar {
|
||||
int1: int,
|
||||
int2: int,
|
||||
int1: isize,
|
||||
int2: isize,
|
||||
}
|
||||
|
||||
impl Copy for Bar {}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ struct Foo {
|
|||
impl Copy for Foo {}
|
||||
|
||||
struct Bar {
|
||||
int1: int,
|
||||
int2: int,
|
||||
int1: isize,
|
||||
int2: isize,
|
||||
}
|
||||
|
||||
impl Copy for Bar {}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
// Test lifetimes are linked properly when we take reference
|
||||
// to interior.
|
||||
|
||||
struct Foo(int);
|
||||
struct Foo(isize);
|
||||
|
||||
fn foo<'a>() -> &'a int {
|
||||
fn foo<'a>() -> &'a isize {
|
||||
let &Foo(ref x) = &Foo(3); //~ ERROR borrowed value does not live long enough
|
||||
x
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@ impl A {
|
|||
pub fn main() {
|
||||
let a = box A;
|
||||
a.foo();
|
||||
//~^ ERROR cannot borrow immutable dereference of `Box` `*a` as mutable
|
||||
//~^ ERROR cannot borrow immutable `Box` content `*a` as mutable
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,20 +13,20 @@
|
|||
//
|
||||
// Example from src/middle/borrowck/doc.rs
|
||||
|
||||
fn foo(t0: & &mut int) {
|
||||
fn foo(t0: & &mut isize) {
|
||||
let t1 = t0;
|
||||
let p: &int = &**t0;
|
||||
let p: &isize = &**t0;
|
||||
**t1 = 22; //~ ERROR cannot assign
|
||||
}
|
||||
|
||||
fn foo3(t0: &mut &mut int) {
|
||||
fn foo3(t0: &mut &mut isize) {
|
||||
let t1 = &mut *t0;
|
||||
let p: &int = &**t0; //~ ERROR cannot borrow
|
||||
let p: &isize = &**t0; //~ ERROR cannot borrow
|
||||
**t1 = 22;
|
||||
}
|
||||
|
||||
fn foo4(t0: & &mut int) {
|
||||
let x: &mut int = &mut **t0; //~ ERROR cannot borrow
|
||||
fn foo4(t0: & &mut isize) {
|
||||
let x: &mut isize = &mut **t0; //~ ERROR cannot borrow
|
||||
*x += 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,25 +32,25 @@ impl<T> DerefMut for Own<T> {
|
|||
}
|
||||
|
||||
struct Point {
|
||||
x: int,
|
||||
y: int
|
||||
x: isize,
|
||||
y: isize
|
||||
}
|
||||
|
||||
impl Point {
|
||||
fn get(&self) -> (int, int) {
|
||||
fn get(&self) -> (isize, isize) {
|
||||
(self.x, self.y)
|
||||
}
|
||||
|
||||
fn set(&mut self, x: int, y: int) {
|
||||
fn set(&mut self, x: isize, y: isize) {
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
}
|
||||
|
||||
fn x_ref(&self) -> &int {
|
||||
fn x_ref(&self) -> &isize {
|
||||
&self.x
|
||||
}
|
||||
|
||||
fn y_mut(&mut self) -> &mut int {
|
||||
fn y_mut(&mut self) -> &mut isize {
|
||||
&mut self.y
|
||||
}
|
||||
}
|
||||
|
|
@ -67,15 +67,15 @@ fn deref_mut_field2(mut x: Own<Point>) {
|
|||
let _i = &mut x.y;
|
||||
}
|
||||
|
||||
fn deref_extend_field(x: &Own<Point>) -> &int {
|
||||
fn deref_extend_field(x: &Own<Point>) -> &isize {
|
||||
&x.y
|
||||
}
|
||||
|
||||
fn deref_extend_mut_field1(x: &Own<Point>) -> &mut int {
|
||||
fn deref_extend_mut_field1(x: &Own<Point>) -> &mut isize {
|
||||
&mut x.y //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_mut_field2(x: &mut Own<Point>) -> &mut int {
|
||||
fn deref_extend_mut_field2(x: &mut Own<Point>) -> &mut isize {
|
||||
&mut x.y
|
||||
}
|
||||
|
||||
|
|
@ -126,15 +126,15 @@ fn deref_mut_method2(mut x: Own<Point>) {
|
|||
x.set(0, 0);
|
||||
}
|
||||
|
||||
fn deref_extend_method(x: &Own<Point>) -> &int {
|
||||
fn deref_extend_method(x: &Own<Point>) -> &isize {
|
||||
x.x_ref()
|
||||
}
|
||||
|
||||
fn deref_extend_mut_method1(x: &Own<Point>) -> &mut int {
|
||||
fn deref_extend_mut_method1(x: &Own<Point>) -> &mut isize {
|
||||
x.y_mut() //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_mut_method2(x: &mut Own<Point>) -> &mut int {
|
||||
fn deref_extend_mut_method2(x: &mut Own<Point>) -> &mut isize {
|
||||
x.y_mut()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,25 +26,25 @@ impl<T> Deref for Rc<T> {
|
|||
}
|
||||
|
||||
struct Point {
|
||||
x: int,
|
||||
y: int
|
||||
x: isize,
|
||||
y: isize
|
||||
}
|
||||
|
||||
impl Point {
|
||||
fn get(&self) -> (int, int) {
|
||||
fn get(&self) -> (isize, isize) {
|
||||
(self.x, self.y)
|
||||
}
|
||||
|
||||
fn set(&mut self, x: int, y: int) {
|
||||
fn set(&mut self, x: isize, y: isize) {
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
}
|
||||
|
||||
fn x_ref(&self) -> &int {
|
||||
fn x_ref(&self) -> &isize {
|
||||
&self.x
|
||||
}
|
||||
|
||||
fn y_mut(&mut self) -> &mut int {
|
||||
fn y_mut(&mut self) -> &mut isize {
|
||||
&mut self.y
|
||||
}
|
||||
}
|
||||
|
|
@ -61,15 +61,15 @@ fn deref_mut_field2(mut x: Rc<Point>) {
|
|||
let _i = &mut x.y; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_field(x: &Rc<Point>) -> &int {
|
||||
fn deref_extend_field(x: &Rc<Point>) -> &isize {
|
||||
&x.y
|
||||
}
|
||||
|
||||
fn deref_extend_mut_field1(x: &Rc<Point>) -> &mut int {
|
||||
fn deref_extend_mut_field1(x: &Rc<Point>) -> &mut isize {
|
||||
&mut x.y //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_mut_field2(x: &mut Rc<Point>) -> &mut int {
|
||||
fn deref_extend_mut_field2(x: &mut Rc<Point>) -> &mut isize {
|
||||
&mut x.y //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
|
|
@ -97,15 +97,15 @@ fn deref_mut_method2(mut x: Rc<Point>) {
|
|||
x.set(0, 0); //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_method(x: &Rc<Point>) -> &int {
|
||||
fn deref_extend_method(x: &Rc<Point>) -> &isize {
|
||||
x.x_ref()
|
||||
}
|
||||
|
||||
fn deref_extend_mut_method1(x: &Rc<Point>) -> &mut int {
|
||||
fn deref_extend_mut_method1(x: &Rc<Point>) -> &mut isize {
|
||||
x.y_mut() //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_mut_method2(x: &mut Rc<Point>) -> &mut int {
|
||||
fn deref_extend_mut_method2(x: &mut Rc<Point>) -> &mut isize {
|
||||
x.y_mut() //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,39 +31,39 @@ impl<T> DerefMut for Own<T> {
|
|||
}
|
||||
}
|
||||
|
||||
fn deref_imm(x: Own<int>) {
|
||||
fn deref_imm(x: Own<isize>) {
|
||||
let _i = &*x;
|
||||
}
|
||||
|
||||
fn deref_mut1(x: Own<int>) {
|
||||
fn deref_mut1(x: Own<isize>) {
|
||||
let _i = &mut *x; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_mut2(mut x: Own<int>) {
|
||||
fn deref_mut2(mut x: Own<isize>) {
|
||||
let _i = &mut *x;
|
||||
}
|
||||
|
||||
fn deref_extend<'a>(x: &'a Own<int>) -> &'a int {
|
||||
fn deref_extend<'a>(x: &'a Own<isize>) -> &'a isize {
|
||||
&**x
|
||||
}
|
||||
|
||||
fn deref_extend_mut1<'a>(x: &'a Own<int>) -> &'a mut int {
|
||||
fn deref_extend_mut1<'a>(x: &'a Own<isize>) -> &'a mut isize {
|
||||
&mut **x //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_mut2<'a>(x: &'a mut Own<int>) -> &'a mut int {
|
||||
fn deref_extend_mut2<'a>(x: &'a mut Own<isize>) -> &'a mut isize {
|
||||
&mut **x
|
||||
}
|
||||
|
||||
fn assign1<'a>(x: Own<int>) {
|
||||
fn assign1<'a>(x: Own<isize>) {
|
||||
*x = 3; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn assign2<'a>(x: &'a Own<int>) {
|
||||
fn assign2<'a>(x: &'a Own<isize>) {
|
||||
**x = 3; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn assign3<'a>(x: &'a mut Own<int>) {
|
||||
fn assign3<'a>(x: &'a mut Own<isize>) {
|
||||
**x = 3;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,39 +25,39 @@ impl<T> Deref for Rc<T> {
|
|||
}
|
||||
}
|
||||
|
||||
fn deref_imm(x: Rc<int>) {
|
||||
fn deref_imm(x: Rc<isize>) {
|
||||
let _i = &*x;
|
||||
}
|
||||
|
||||
fn deref_mut1(x: Rc<int>) {
|
||||
fn deref_mut1(x: Rc<isize>) {
|
||||
let _i = &mut *x; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_mut2(mut x: Rc<int>) {
|
||||
fn deref_mut2(mut x: Rc<isize>) {
|
||||
let _i = &mut *x; //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend<'a>(x: &'a Rc<int>) -> &'a int {
|
||||
fn deref_extend<'a>(x: &'a Rc<isize>) -> &'a isize {
|
||||
&**x
|
||||
}
|
||||
|
||||
fn deref_extend_mut1<'a>(x: &'a Rc<int>) -> &'a mut int {
|
||||
fn deref_extend_mut1<'a>(x: &'a Rc<isize>) -> &'a mut isize {
|
||||
&mut **x //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn deref_extend_mut2<'a>(x: &'a mut Rc<int>) -> &'a mut int {
|
||||
fn deref_extend_mut2<'a>(x: &'a mut Rc<isize>) -> &'a mut isize {
|
||||
&mut **x //~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn assign1<'a>(x: Rc<int>) {
|
||||
fn assign1<'a>(x: Rc<isize>) {
|
||||
*x = 3; //~ ERROR cannot assign
|
||||
}
|
||||
|
||||
fn assign2<'a>(x: &'a Rc<int>) {
|
||||
fn assign2<'a>(x: &'a Rc<isize>) {
|
||||
**x = 3; //~ ERROR cannot assign
|
||||
}
|
||||
|
||||
fn assign3<'a>(x: &'a mut Rc<int>) {
|
||||
fn assign3<'a>(x: &'a mut Rc<isize>) {
|
||||
**x = 3; //~ ERROR cannot assign
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ extern crate collections;
|
|||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
let mut buggy_map: HashMap<uint, &uint> = HashMap::new();
|
||||
let mut buggy_map: HashMap<usize, &usize> = HashMap::new();
|
||||
buggy_map.insert(42, &*box 1); //~ ERROR borrowed value does not live long enough
|
||||
|
||||
// but it is ok if we use a temporary
|
||||
|
|
|
|||
|
|
@ -11,23 +11,23 @@
|
|||
#![feature(box_syntax)]
|
||||
|
||||
struct A {
|
||||
x: Box<int>,
|
||||
y: int,
|
||||
x: Box<isize>,
|
||||
y: isize,
|
||||
}
|
||||
|
||||
struct B {
|
||||
x: Box<int>,
|
||||
y: Box<int>,
|
||||
x: Box<isize>,
|
||||
y: Box<isize>,
|
||||
}
|
||||
|
||||
struct C {
|
||||
x: Box<A>,
|
||||
y: int,
|
||||
y: isize,
|
||||
}
|
||||
|
||||
struct D {
|
||||
x: Box<A>,
|
||||
y: Box<int>,
|
||||
y: Box<isize>,
|
||||
}
|
||||
|
||||
fn copy_after_move() {
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn foo() -> int {
|
||||
let x: int;
|
||||
fn foo() -> isize {
|
||||
let x: isize;
|
||||
|
||||
while 1i != 2 {
|
||||
while 1is != 2 {
|
||||
break;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x`
|
||||
|
||||
return 17i;
|
||||
return 17is;
|
||||
}
|
||||
|
||||
fn main() { println!("{}", foo()); }
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn foo() -> int {
|
||||
let x: int;
|
||||
fn foo() -> isize {
|
||||
let x: isize;
|
||||
|
||||
loop {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ fn test1() {
|
|||
}
|
||||
|
||||
fn test2<F>(f: &F) where F: FnMut() {
|
||||
(*f)(); //~ ERROR: cannot borrow immutable dereference of `&`-pointer `*f` as mutable
|
||||
(*f)(); //~ ERROR: cannot borrow immutable borrowed content `*f` as mutable
|
||||
}
|
||||
|
||||
fn test3<F>(f: &mut F) where F: FnMut() {
|
||||
|
|
@ -41,7 +41,7 @@ fn test3<F>(f: &mut F) where F: FnMut() {
|
|||
}
|
||||
|
||||
fn test4(f: &Test) {
|
||||
f.f.call_mut(()) //~ ERROR: cannot borrow immutable dereference of `Box` `*f.f` as mutable
|
||||
f.f.call_mut(()) //~ ERROR: cannot borrow immutable `Box` content `*f.f` as mutable
|
||||
}
|
||||
|
||||
fn test5(f: &mut Test) {
|
||||
|
|
@ -56,8 +56,8 @@ fn test6() {
|
|||
}
|
||||
|
||||
fn test7() {
|
||||
fn foo<F>(_: F) where F: FnMut(Box<FnMut(int)>, int) {}
|
||||
let mut f = |&mut: g: Box<FnMut(int)>, b: int| {};
|
||||
fn foo<F>(_: F) where F: FnMut(Box<FnMut(isize)>, isize) {}
|
||||
let mut f = |&mut: g: Box<FnMut(isize)>, b: isize| {};
|
||||
f(box |a| { //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable
|
||||
foo(f); //~ ERROR: cannot move out of captured outer variable
|
||||
}, 3);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct Foo {
|
||||
x: int,
|
||||
x: isize,
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
|
|
|
|||
|
|
@ -13,53 +13,53 @@
|
|||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
fn get(x: &int) -> int {
|
||||
fn get(x: &isize) -> isize {
|
||||
*x
|
||||
}
|
||||
|
||||
fn set(x: &mut int) {
|
||||
fn set(x: &mut isize) {
|
||||
*x = 4;
|
||||
}
|
||||
|
||||
fn a() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c1 = |&mut:| x = 4;
|
||||
let c2 = |&mut:| x * 5; //~ ERROR cannot borrow `x`
|
||||
}
|
||||
|
||||
fn b() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c1 = |&mut:| set(&mut x);
|
||||
let c2 = |&mut:| get(&x); //~ ERROR cannot borrow `x`
|
||||
}
|
||||
|
||||
fn c() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c1 = |&mut:| set(&mut x);
|
||||
let c2 = |&mut:| x * 5; //~ ERROR cannot borrow `x`
|
||||
}
|
||||
|
||||
fn d() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c2 = |&mut:| x * 5;
|
||||
x = 5; //~ ERROR cannot assign
|
||||
}
|
||||
|
||||
fn e() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c1 = |&mut:| get(&x);
|
||||
x = 5; //~ ERROR cannot assign
|
||||
}
|
||||
|
||||
fn f() {
|
||||
let mut x = box 3i;
|
||||
let mut x = box 3is;
|
||||
let c1 = |&mut:| get(&*x);
|
||||
*x = 5; //~ ERROR cannot assign
|
||||
}
|
||||
|
||||
fn g() {
|
||||
struct Foo {
|
||||
f: Box<int>
|
||||
f: Box<isize>
|
||||
}
|
||||
|
||||
let mut x = box Foo { f: box 3 };
|
||||
|
|
@ -69,7 +69,7 @@ fn g() {
|
|||
|
||||
fn h() {
|
||||
struct Foo {
|
||||
f: Box<int>
|
||||
f: Box<isize>
|
||||
}
|
||||
|
||||
let mut x = box Foo { f: box 3 };
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@
|
|||
// Tests that two closures cannot simultaneously have mutable
|
||||
// and immutable access to the variable. Issue #6801.
|
||||
|
||||
fn get(x: &int) -> int {
|
||||
fn get(x: &isize) -> isize {
|
||||
*x
|
||||
}
|
||||
|
||||
fn set(x: &mut int) {
|
||||
fn set(x: &mut isize) {
|
||||
*x = 4;
|
||||
}
|
||||
|
||||
fn a(x: &int) {
|
||||
fn a(x: &isize) {
|
||||
let c1 = |&mut:| set(&mut *x);
|
||||
//~^ ERROR cannot borrow
|
||||
let c2 = |&mut:| set(&mut *x);
|
||||
|
|
|
|||
|
|
@ -15,29 +15,29 @@
|
|||
#![feature(box_syntax)]
|
||||
|
||||
fn a() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c1 = |&mut:| x = 4;
|
||||
let c2 = |&mut:| x = 5; //~ ERROR cannot borrow `x` as mutable more than once
|
||||
}
|
||||
|
||||
fn set(x: &mut int) {
|
||||
fn set(x: &mut isize) {
|
||||
*x = 4;
|
||||
}
|
||||
|
||||
fn b() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c1 = |&mut:| set(&mut x);
|
||||
let c2 = |&mut:| set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
|
||||
}
|
||||
|
||||
fn c() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c1 = |&mut:| x = 5;
|
||||
let c2 = |&mut:| set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
|
||||
}
|
||||
|
||||
fn d() {
|
||||
let mut x = 3i;
|
||||
let mut x = 3is;
|
||||
let c1 = |&mut:| x = 5;
|
||||
let c2 = |&mut:| { let _y = |&mut:| set(&mut x); }; // (nested closure)
|
||||
//~^ ERROR cannot borrow `x` as mutable more than once
|
||||
|
|
@ -45,7 +45,7 @@ fn d() {
|
|||
|
||||
fn g() {
|
||||
struct Foo {
|
||||
f: Box<int>
|
||||
f: Box<isize>
|
||||
}
|
||||
|
||||
let mut x = box Foo { f: box 3 };
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct Foo {
|
||||
x: int,
|
||||
x: isize,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -14,35 +14,35 @@
|
|||
// may be *immutable*, but we cannot allow
|
||||
// multiple borrows.
|
||||
|
||||
fn get(x: &int) -> int {
|
||||
fn get(x: &isize) -> isize {
|
||||
*x
|
||||
}
|
||||
|
||||
fn set(x: &mut int) -> int {
|
||||
fn set(x: &mut isize) -> isize {
|
||||
*x
|
||||
}
|
||||
|
||||
fn a(x: &mut int) {
|
||||
fn a(x: &mut isize) {
|
||||
let c1 = |&mut:| get(x);
|
||||
let c2 = |&mut:| get(x);
|
||||
}
|
||||
|
||||
fn b(x: &mut int) {
|
||||
fn b(x: &mut isize) {
|
||||
let c1 = |&mut:| get(x);
|
||||
let c2 = |&mut:| set(x); //~ ERROR closure requires unique access to `x`
|
||||
}
|
||||
|
||||
fn c(x: &mut int) {
|
||||
fn c(x: &mut isize) {
|
||||
let c1 = |&mut:| get(x);
|
||||
let c2 = |&mut:| { get(x); set(x); }; //~ ERROR closure requires unique access to `x`
|
||||
}
|
||||
|
||||
fn d(x: &mut int) {
|
||||
fn d(x: &mut isize) {
|
||||
let c1 = |&mut:| set(x);
|
||||
let c2 = |&mut:| set(x); //~ ERROR closure requires unique access to `x`
|
||||
}
|
||||
|
||||
fn e(x: &mut int) {
|
||||
fn e(x: &mut isize) {
|
||||
let c1 = |&mut:| x = panic!(); //~ ERROR closure cannot assign to immutable local variable
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#![feature(box_syntax)]
|
||||
|
||||
struct Foo {
|
||||
x: int
|
||||
x: isize
|
||||
}
|
||||
|
||||
impl Drop for Foo {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
struct A { a: int, b: Box<int> }
|
||||
struct A { a: isize, b: Box<isize> }
|
||||
|
||||
fn deref_after_move() {
|
||||
let x = A { a: 1, b: box 2 };
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
#![feature(box_syntax)]
|
||||
|
||||
struct Foo {
|
||||
a: [Box<int>; 3],
|
||||
a: [Box<isize>; 3],
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut y = 1i;
|
||||
let mut y = 1is;
|
||||
let x = Some(&mut y);
|
||||
for &a in x.iter() { //~ ERROR cannot move out
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ fn main() {
|
|||
for &a in f.a.iter() { //~ ERROR cannot move out
|
||||
}
|
||||
|
||||
let x = Some(box 1i);
|
||||
let x = Some(box 1is);
|
||||
for &a in x.iter() { //~ ERROR cannot move out
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@
|
|||
use std::iter::repeat;
|
||||
|
||||
fn main() {
|
||||
let mut vector = vec![1u, 2];
|
||||
let mut vector = vec![1us, 2];
|
||||
for &x in vector.iter() {
|
||||
let cap = vector.capacity();
|
||||
vector.extend(repeat(0)); //~ ERROR cannot borrow
|
||||
vector[1u] = 5u; //~ ERROR cannot borrow
|
||||
vector[1us] = 5us; //~ ERROR cannot borrow
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn foo(x: int) { println!("{}", x); }
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
fn main() {
|
||||
let x: int; if 1i > 2 { x = 10; }
|
||||
let x: isize; if 1is > 2 { x = 10; }
|
||||
foo(x); //~ ERROR use of possibly uninitialized variable: `x`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn foo(x: int) { println!("{}", x); }
|
||||
fn foo(x: isize) { println!("{}", x); }
|
||||
|
||||
fn main() {
|
||||
let x: int;
|
||||
if 1i > 2 {
|
||||
let x: isize;
|
||||
if 1is > 2 {
|
||||
println!("whoops");
|
||||
} else {
|
||||
x = 10;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let mut _a = 3i;
|
||||
let mut _a = 3is;
|
||||
let _b = &mut _a;
|
||||
{
|
||||
let _c = &*_b;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let j = |&:| -> int {
|
||||
let i: int;
|
||||
let j = |&:| -> isize {
|
||||
let i: isize;
|
||||
i //~ ERROR use of possibly uninitialized variable: `i`
|
||||
};
|
||||
j();
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let f = |&:| -> int {
|
||||
let i: int;
|
||||
let f = |&:| -> isize {
|
||||
let i: isize;
|
||||
i //~ ERROR use of possibly uninitialized variable: `i`
|
||||
};
|
||||
println!("{}", f());
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue