rust/src/test/compile-fail/regions-scoping.rs

43 lines
2.3 KiB
Rust
Raw Normal View History

2012-04-17 12:05:28 -05:00
fn with<T>(t: T, f: fn(T)) { f(t) }
fn nested(x: &x.int) { // (1)
do with(
2012-04-17 12:05:28 -05:00
fn&(x: &x.int, // Refers to the region `x` at (1)
y: &y.int, // A fresh region `y` (2)
z: fn(x: &x.int, // Refers to `x` at (1)
y: &y.int, // Refers to `y` at (2)
z: &z.int) -> &z.int) // A fresh region `z` (3)
-> &x.int {
if false { ret z(x, x, x); } //~ ERROR mismatched types: expected `&y.int` but found `&x.int`
if false { ret z(x, x, y); } //~ ERROR mismatched types: expected `&y.int` but found `&x.int`
//~^ ERROR mismatched types: expected `&x.int` but found `&y.int`
2012-04-17 12:05:28 -05:00
if false { ret z(x, y, x); }
if false { ret z(x, y, y); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int`
if false { ret z(y, x, x); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int`
//~^ ERROR mismatched types: expected `&y.int` but found `&x.int`
if false { ret z(y, x, y); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int`
//~^ ERROR mismatched types: expected `&y.int` but found `&x.int`
//~^^ ERROR mismatched types: expected `&x.int` but found `&y.int`
if false { ret z(y, y, x); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int`
if false { ret z(y, y, y); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int`
//~^ ERROR mismatched types: expected `&x.int` but found `&y.int`
2012-04-17 12:05:28 -05:00
fail;
}
2012-06-30 18:19:07 -05:00
) |foo| {
2012-06-30 18:19:07 -05:00
let a: &x.int = foo(x, x, |_x, _y, z| z );
let b: &x.int = foo(x, a, |_x, _y, z| z );
let c: &x.int = foo(a, a, |_x, _y, z| z );
2012-04-17 12:05:28 -05:00
let z = 3i;
2012-06-30 18:19:07 -05:00
let d: &x.int = foo(x, x, |_x, _y, z| z );
let e: &x.int = foo(x, &z, |_x, _y, z| z );
Merge remote-tracking branch 'Dretch/prettydocs' Conflicts: src/compiletest/errors.rs src/libsyntax/parse/attr.rs src/libsyntax/parse/comments.rs src/test/compile-fail/ambig_impl_unify.rs src/test/compile-fail/assign-super.rs src/test/compile-fail/bad-for-loop.rs src/test/compile-fail/bad-var-env-capture-in-block-arg.rs src/test/compile-fail/block-arg-as-stmt-with-value.rs src/test/compile-fail/borrowck-assign-comp-idx.rs src/test/compile-fail/borrowck-lend-flow.rs src/test/compile-fail/borrowck-loan-blocks-move-cc.rs src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs src/test/compile-fail/borrowck-loan-rcvr.rs src/test/compile-fail/borrowck-loan-vec-content.rs src/test/compile-fail/borrowck-mut-vec-as-imm-slice-bad.rs src/test/compile-fail/cap-clause-with-stack-closure.rs src/test/compile-fail/do1.rs src/test/compile-fail/do2.rs src/test/compile-fail/empty-vec-trailing-comma.rs src/test/compile-fail/evec-subtyping.rs src/test/compile-fail/issue-1896.rs src/test/compile-fail/issue-2149.rs src/test/compile-fail/issue-2150.rs src/test/compile-fail/issue-2487-b.rs src/test/compile-fail/kindck-implicit-close-over-mut-var.rs src/test/compile-fail/liveness-issue-2163.rs src/test/compile-fail/liveness-use-in-index-lvalue.rs src/test/compile-fail/no-reuse-move-arc.rs src/test/compile-fail/no-send-res-ports.rs src/test/compile-fail/non-const.rs src/test/compile-fail/pure-higher-order.rs src/test/compile-fail/pure-loop-body.rs src/test/compile-fail/regions-addr-of-upvar-self.rs src/test/compile-fail/regions-escape-loop-via-vec.rs src/test/compile-fail/regions-scoping.rs src/test/compile-fail/seq-args.rs src/test/compile-fail/tstate-unsat-in-called-fn-expr.rs src/test/compile-fail/tstate-unsat-in-fn-expr.rs src/test/compile-fail/vec-add.rs src/test/compile-fail/vec-concat-bug.rs src/test/compile-fail/vector-no-ann.rs
2012-07-02 16:44:31 -05:00
let f: &x.int = foo(&z, &z, |_x, _y, z| z ); //~ ERROR mismatched types: expected `&x.int` but found
2012-04-17 12:05:28 -05:00
Merge remote-tracking branch 'Dretch/prettydocs' Conflicts: src/compiletest/errors.rs src/libsyntax/parse/attr.rs src/libsyntax/parse/comments.rs src/test/compile-fail/ambig_impl_unify.rs src/test/compile-fail/assign-super.rs src/test/compile-fail/bad-for-loop.rs src/test/compile-fail/bad-var-env-capture-in-block-arg.rs src/test/compile-fail/block-arg-as-stmt-with-value.rs src/test/compile-fail/borrowck-assign-comp-idx.rs src/test/compile-fail/borrowck-lend-flow.rs src/test/compile-fail/borrowck-loan-blocks-move-cc.rs src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs src/test/compile-fail/borrowck-loan-rcvr.rs src/test/compile-fail/borrowck-loan-vec-content.rs src/test/compile-fail/borrowck-mut-vec-as-imm-slice-bad.rs src/test/compile-fail/cap-clause-with-stack-closure.rs src/test/compile-fail/do1.rs src/test/compile-fail/do2.rs src/test/compile-fail/empty-vec-trailing-comma.rs src/test/compile-fail/evec-subtyping.rs src/test/compile-fail/issue-1896.rs src/test/compile-fail/issue-2149.rs src/test/compile-fail/issue-2150.rs src/test/compile-fail/issue-2487-b.rs src/test/compile-fail/kindck-implicit-close-over-mut-var.rs src/test/compile-fail/liveness-issue-2163.rs src/test/compile-fail/liveness-use-in-index-lvalue.rs src/test/compile-fail/no-reuse-move-arc.rs src/test/compile-fail/no-send-res-ports.rs src/test/compile-fail/non-const.rs src/test/compile-fail/pure-higher-order.rs src/test/compile-fail/pure-loop-body.rs src/test/compile-fail/regions-addr-of-upvar-self.rs src/test/compile-fail/regions-escape-loop-via-vec.rs src/test/compile-fail/regions-scoping.rs src/test/compile-fail/seq-args.rs src/test/compile-fail/tstate-unsat-in-called-fn-expr.rs src/test/compile-fail/tstate-unsat-in-fn-expr.rs src/test/compile-fail/vec-add.rs src/test/compile-fail/vec-concat-bug.rs src/test/compile-fail/vector-no-ann.rs
2012-07-02 16:44:31 -05:00
foo(x, &z, |x, _y, _z| x ); //~ ERROR mismatched types: expected `&z.int` but found `&x.int`
foo(x, &z, |_x, y, _z| y ); //~ ERROR mismatched types: expected `&z.int` but found `&<block at
2012-04-17 12:05:28 -05:00
}
}
fn main() {}