Skip to content

Commit

Permalink
Auto merge of #35274 - GuillaumeGomez:err_codes, r=jonathandturner
Browse files Browse the repository at this point in the history
Add new error code tests

r? @jonathandturner
  • Loading branch information
bors authored Aug 5, 2016
2 parents 545a3a9 + 8502c6c commit 802d081
Show file tree
Hide file tree
Showing 21 changed files with 404 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/compile-fail/E0201.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2016 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(u8);

impl Foo {
fn bar(&self) -> bool { self.0 > 5 }
fn bar() {} //~ ERROR E0201
}

trait Baz {
type Quux;
fn baz(&self) -> bool;
}

impl Baz for Foo {
type Quux = u32;

fn baz(&self) -> bool { true }
fn baz(&self) -> bool { self.0 > 5 } //~ ERROR E0201
type Quux = u32; //~ ERROR E0201
}

fn main() {
}
23 changes: 23 additions & 0 deletions src/test/compile-fail/E0204.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2016 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 {
foo: Vec<u32>,
}

impl Copy for Foo { } //~ ERROR E0204

#[derive(Copy)] //~ ERROR E0204
struct Foo2<'a> {
ty: &'a mut bool,
}

fn main() {
}
25 changes: 25 additions & 0 deletions src/test/compile-fail/E0205.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2016 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.

enum Foo {
Bar(Vec<u32>),
Baz,
}

impl Copy for Foo { } //~ ERROR E0205

#[derive(Copy)] //~ ERROR E0205
enum Foo2<'a> {
Bar(&'a mut bool),
Baz,
}

fn main() {
}
22 changes: 22 additions & 0 deletions src/test/compile-fail/E0206.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2016 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.

type Foo = i32;

impl Copy for Foo { } //~ ERROR E0206
//~^ ERROR E0117

#[derive(Copy, Clone)]
struct Bar;

impl Copy for &'static Bar { } //~ ERROR E0206

fn main() {
}
20 changes: 20 additions & 0 deletions src/test/compile-fail/E0207.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2016 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;

impl<T: Default> Foo { //~ ERROR E0207
fn get(&self) -> T {
<T as Default>::default()
}
}

fn main() {
}
13 changes: 13 additions & 0 deletions src/test/compile-fail/E0214.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2016 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.

fn main() {
let v: Vec(&str) = vec!["foo"]; //~ ERROR E0214
}
19 changes: 19 additions & 0 deletions src/test/compile-fail/E0220.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2016 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.

trait Trait {
type Bar;
}

type Foo = Trait<F=i32>; //~ ERROR E0220
//~^ ERROR E0191

fn main() {
}
26 changes: 26 additions & 0 deletions src/test/compile-fail/E0221.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2016 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.

trait T1 {}
trait T2 {}

trait Foo {
type A: T1;
}

trait Bar : Foo {
type A: T2;
fn do_something() {
let _: Self::A; //~ ERROR E0221
}
}

fn main() {
}
15 changes: 15 additions & 0 deletions src/test/compile-fail/E0223.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2016 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.

trait MyTrait { type X; }

fn main() {
let foo: MyTrait::X; //~ ERROR E0223
}
13 changes: 13 additions & 0 deletions src/test/compile-fail/E0225.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2016 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.

fn main() {
let _: Box<std::io::Read + std::io::Write>; //~ ERROR E0225
}
26 changes: 26 additions & 0 deletions src/test/compile-fail/E0229.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2016 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.

pub trait Foo {
type A;
fn boo(&self) -> <Self as Foo>::A;
}

struct Bar;

impl Foo for isize {
type A = usize;
fn boo(&self) -> usize { 42 }
}

fn baz<I>(x: &<I as Foo<A=Bar>>::A) {} //~ ERROR E0229

fn main() {
}
17 changes: 17 additions & 0 deletions src/test/compile-fail/E0232.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2016 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.

#![feature(on_unimplemented)]

#[rustc_on_unimplemented] //~ ERROR E0232
trait Bar {}

fn main() {
}
15 changes: 15 additions & 0 deletions src/test/compile-fail/E0243.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2016 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<T> { x: T }
struct Bar { x: Foo } //~ ERROR E0243

fn main() {
}
15 changes: 15 additions & 0 deletions src/test/compile-fail/E0244.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2016 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 { x: bool }
struct Bar<S, T> { x: Foo<S, T> } //~ ERROR E0244

fn main() {
}
18 changes: 18 additions & 0 deletions src/test/compile-fail/E0248.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2016 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.

enum Foo {
Bar(u32),
}

fn do_something(x: Foo::Bar) { } //~ ERROR E0248

fn main() {
}
23 changes: 23 additions & 0 deletions src/test/compile-fail/E0252.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2016 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.

use foo::baz;
use bar::baz; //~ ERROR E0252

mod foo {
pub struct baz;
}

mod bar {
pub mod baz {}
}

fn main() {
}
16 changes: 16 additions & 0 deletions src/test/compile-fail/E0306.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2016 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.

const A: [u32; "hello"] = []; //~ ERROR E0306
const B: [u32; true] = []; //~ ERROR E0306
const C: [u32; 0.0] = []; //~ ERROR E0306

fn main() {
}
20 changes: 20 additions & 0 deletions src/test/compile-fail/E0308-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2016 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.

use std::rc::Rc;

struct Foo;

impl Foo {
fn x(self: Rc<Foo>) {} //~ ERROR E0308
}

fn main() {
}
11 changes: 11 additions & 0 deletions src/test/compile-fail/E0308-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2016 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.

fn main() -> i32 { 0 } //~ ERROR E0308
Loading

0 comments on commit 802d081

Please sign in to comment.