Add some tests for obsolete code, sugar used in appropriate ways.

This commit is contained in:
Niko Matsakis 2014-11-27 06:59:21 -05:00
parent 0fefd835f2
commit 9c9253e859
4 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,17 @@
// 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 we generate obsolete syntax errors around usages of `proc`.
fn foo(p: proc()) { } //~ ERROR obsolete syntax: the `proc` type
fn bar() { proc() 1; } //~ ERROR obsolete syntax: `proc` expression
fn main() { }

View File

@ -0,0 +1,24 @@
// 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 parentheses form doesn't work with struct types appearing in local variables.
struct Bar<A,R> {
f: A, r: R
}
fn bar() {
let x: Box<Bar()> = panic!();
//~^ ERROR E0169
}
fn main() { }

View File

@ -0,0 +1,29 @@
// 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 parentheses form doesn't work in expression paths.
struct Bar<A,R> {
f: A, r: R
}
impl<A,B> Bar<A,B> {
fn new() -> Bar<A,B> { panic!() }
}
fn bar() {
let b = Box::Bar::<int,uint>::new(); // OK
let b = Box::Bar::()::new();
//~^ ERROR expected ident, found `(`
}
fn main() { }

View File

@ -0,0 +1,22 @@
// 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 parentheses form doesn't work with struct types appearing in argument types.
struct Bar<A,R> {
f: A, r: R
}
fn foo(b: Box<Bar()>) {
//~^ ERROR E0169
}
fn main() { }