Add new error code tests
This commit is contained in:
parent
4da9bdc563
commit
0658941cd2
10 changed files with 190 additions and 0 deletions
17
src/test/compile-fail/E0365.rs
Normal file
17
src/test/compile-fail/E0365.rs
Normal file
|
@ -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.
|
||||
|
||||
mod foo {
|
||||
pub const X: u32 = 1;
|
||||
}
|
||||
|
||||
pub use foo as foo2; //~ ERROR E0365
|
||||
|
||||
fn main() {}
|
20
src/test/compile-fail/E0370.rs
Normal file
20
src/test/compile-fail/E0370.rs
Normal file
|
@ -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.
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
#[deny(overflowing_literals)]
|
||||
#[repr(i64)]
|
||||
enum Foo {
|
||||
X = 0x7fffffffffffffff,
|
||||
Y, //~ ERROR E0370
|
||||
}
|
||||
|
||||
fn main() {}
|
21
src/test/compile-fail/E0374.rs
Normal file
21
src/test/compile-fail/E0374.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// 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(coerce_unsized)]
|
||||
use std::ops::CoerceUnsized;
|
||||
|
||||
struct Foo<T: ?Sized> {
|
||||
a: i32,
|
||||
}
|
||||
|
||||
impl<T, U> CoerceUnsized<Foo<U>> for Foo<T> //~ ERROR E0374
|
||||
where T: CoerceUnsized<U> {}
|
||||
|
||||
fn main() {}
|
22
src/test/compile-fail/E0375.rs
Normal file
22
src/test/compile-fail/E0375.rs
Normal file
|
@ -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.
|
||||
|
||||
#![feature(coerce_unsized)]
|
||||
use std::ops::CoerceUnsized;
|
||||
|
||||
struct Foo<T: ?Sized, U: ?Sized> {
|
||||
a: i32,
|
||||
b: T,
|
||||
c: U,
|
||||
}
|
||||
|
||||
impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {} //~ ERROR E0375
|
||||
|
||||
fn main() {}
|
20
src/test/compile-fail/E0376.rs
Normal file
20
src/test/compile-fail/E0376.rs
Normal file
|
@ -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.
|
||||
|
||||
#![feature(coerce_unsized)]
|
||||
use std::ops::CoerceUnsized;
|
||||
|
||||
struct Foo<T: ?Sized> {
|
||||
a: T,
|
||||
}
|
||||
|
||||
impl<T, U> CoerceUnsized<U> for Foo<T> {} //~ ERROR E0376
|
||||
|
||||
fn main() {}
|
22
src/test/compile-fail/E0388.rs
Normal file
22
src/test/compile-fail/E0388.rs
Normal file
|
@ -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.
|
||||
|
||||
static X: i32 = 1;
|
||||
const C: i32 = 2;
|
||||
|
||||
const CR: &'static mut i32 = &mut C; //~ ERROR E0017
|
||||
//~| ERROR E0017
|
||||
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
|
||||
//~| ERROR E0017
|
||||
//~| ERROR E0388
|
||||
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
|
||||
//~| ERROR E0017
|
||||
|
||||
fn main() {}
|
20
src/test/compile-fail/E0389.rs
Normal file
20
src/test/compile-fail/E0389.rs
Normal file
|
@ -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 FancyNum {
|
||||
num: u8,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut fancy = FancyNum{ num: 5 };
|
||||
let fancy_ref = &(&mut fancy);
|
||||
fancy_ref.num = 6; //~ ERROR E0389
|
||||
println!("{}", fancy_ref.num);
|
||||
}
|
18
src/test/compile-fail/E0390.rs
Normal file
18
src/test/compile-fail/E0390.rs
Normal file
|
@ -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.
|
||||
|
||||
struct Foo {
|
||||
x: i32
|
||||
}
|
||||
|
||||
impl *mut Foo {} //~ ERROR E0390
|
||||
|
||||
fn main() {
|
||||
}
|
14
src/test/compile-fail/E0392.rs
Normal file
14
src/test/compile-fail/E0392.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// 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<T> { Bar } //~ ERROR E0392
|
||||
|
||||
fn main() {
|
||||
}
|
16
src/test/compile-fail/E0393.rs
Normal file
16
src/test/compile-fail/E0393.rs
Normal file
|
@ -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.
|
||||
|
||||
trait A<T=Self> {}
|
||||
|
||||
fn together_we_will_rule_the_galaxy(son: &A) {} //~ ERROR E0393
|
||||
|
||||
fn main() {
|
||||
}
|
Loading…
Add table
Reference in a new issue