Update existing tests to account for stricter, more correct handling of irrefutable patterns
This commit is contained in:
parent
ed69ef0b66
commit
17b3712487
@ -11,7 +11,7 @@ pub fn main() {
|
||||
Foo { string: ~"baz" }
|
||||
];
|
||||
match x {
|
||||
[first, ..tail] => {
|
||||
[_, ..tail] => {
|
||||
match tail {
|
||||
[Foo { string: a }, Foo { string: b }] => {
|
||||
//~^ ERROR cannot move out of dereference of & pointer
|
||||
|
@ -17,4 +17,41 @@ fn b() {
|
||||
}
|
||||
}
|
||||
|
||||
fn c() {
|
||||
let mut vec = [~1, ~2, ~3];
|
||||
match vec {
|
||||
[_a, .._b] => {
|
||||
//~^ ERROR cannot move out
|
||||
|
||||
// Note: `_a` is *moved* here, but `b` is borrowing,
|
||||
// hence illegal.
|
||||
//
|
||||
// See comment in middle/borrowck/gather_loans/mod.rs
|
||||
// in the case covering these sorts of vectors.
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let a = vec[0]; //~ ERROR use of partially moved value: `vec`
|
||||
}
|
||||
|
||||
fn d() {
|
||||
let mut vec = [~1, ~2, ~3];
|
||||
match vec {
|
||||
[.._a, _b] => {
|
||||
//~^ ERROR cannot move out
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let a = vec[0]; //~ ERROR use of partially moved value: `vec`
|
||||
}
|
||||
|
||||
fn e() {
|
||||
let mut vec = [~1, ~2, ~3];
|
||||
match vec {
|
||||
[_a, _b, _c] => {}
|
||||
_ => {}
|
||||
}
|
||||
let a = vec[0]; //~ ERROR use of partially moved value: `vec`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,32 +0,0 @@
|
||||
// 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.
|
||||
|
||||
struct foo {bar: baz}
|
||||
|
||||
struct baz_ {baz: int}
|
||||
|
||||
type baz = @mut baz_;
|
||||
|
||||
trait frob {
|
||||
fn frob(&self);
|
||||
}
|
||||
|
||||
impl frob for foo {
|
||||
fn frob(&self) {
|
||||
really_impure(self.bar);
|
||||
}
|
||||
}
|
||||
|
||||
// Override default mode so that we are passing by value
|
||||
fn really_impure(bar: baz) {
|
||||
bar.baz = 3;
|
||||
}
|
||||
|
||||
pub fn main() {}
|
@ -28,14 +28,14 @@
|
||||
|
||||
|
||||
fn main() {
|
||||
let a = @mut [3i];
|
||||
let b = @mut [a];
|
||||
let c = @mut b;
|
||||
let a = @mut 3i;
|
||||
// let b = @mut [a];
|
||||
// let c = @mut [3];
|
||||
|
||||
// this should freeze `a` only
|
||||
let _x: &mut [int] = c[0];
|
||||
let _x: &mut int = a;
|
||||
|
||||
// hence these writes should not fail:
|
||||
b[0] = b[0];
|
||||
c[0] = c[0];
|
||||
// b[0] = b[0];
|
||||
// c[0] = c[0];
|
||||
}
|
||||
|
@ -14,8 +14,11 @@
|
||||
enum t { make_t(@int), clam, }
|
||||
|
||||
fn foo(s: @int) {
|
||||
debug!(::std::sys::refcount(s));
|
||||
let count = ::std::sys::refcount(s);
|
||||
let x: t = make_t(s); // ref up
|
||||
assert_eq!(::std::sys::refcount(s), count + 1u);
|
||||
debug!(::std::sys::refcount(s));
|
||||
|
||||
match x {
|
||||
make_t(y) => {
|
||||
@ -38,6 +41,5 @@ pub fn main() {
|
||||
|
||||
debug!("%u", ::std::sys::refcount(s));
|
||||
let count2 = ::std::sys::refcount(s);
|
||||
let _ = ::std::sys::refcount(s); // don't get bitten by last-use.
|
||||
assert_eq!(count, count2);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ pub fn main() {
|
||||
Foo { string: ~"baz" }
|
||||
];
|
||||
match x {
|
||||
[first, ..tail] => {
|
||||
[ref first, ..tail] => {
|
||||
assert!(first.string == ~"foo");
|
||||
assert_eq!(tail.len(), 2);
|
||||
assert!(tail[0].string == ~"bar");
|
||||
|
Loading…
Reference in New Issue
Block a user