Rollup merge of #33793 - GuillaumeGomez:compile_fail, r=GuillaumeGomez

Fix compile_fail tag

Fixes #33780

r? @steveklabnik
This commit is contained in:
Manish Goregaokar 2016-05-30 15:18:59 +05:30
commit 10e1e6a7a2
8 changed files with 28 additions and 15 deletions

View File

@ -20,6 +20,8 @@ remainder of a zero divisor) in a static or constant expression. Erroneous
code example:
```compile_fail
#[deny(const_err)]
const X: i32 = 42 / 0;
// error: attempted to divide by zero in a constant expression
```
@ -66,7 +68,7 @@ this restriction.
This happens when a trait has a method like the following:
```compile_fail
```
trait Trait {
fn foo(&self) -> Self;
}

View File

@ -153,7 +153,7 @@ structure that is currently uninitialized.
For example, this can happen when a drop has taken place:
```compile_fail
```ignore
struct Foo {
a: u32,
}

View File

@ -76,6 +76,8 @@ Not-a-Number (NaN) values cannot be compared for equality and hence can never
match the input to a match expression. So, the following will not compile:
```compile_fail
#![deny(illegal_floating_point_constant_pattern)]
const NAN: f32 = 0.0 / 0.0;
let number = 0.1f32;
@ -160,7 +162,7 @@ let Some(y) = x;
If you encounter this error you probably need to use a `match` or `if let` to
deal with the possibility of failure. Example:
```compile_fail
```
let x = Some(1);
match x {

View File

@ -17,6 +17,8 @@ A private trait was used on a public type parameter bound. Erroneous code
examples:
```compile_fail
#![deny(private_in_public)]
trait Foo {
fn dummy(&self) { }
}
@ -45,6 +47,8 @@ E0446: r##"
A private type was used in a public type signature. Erroneous code example:
```compile_fail
#![deny(private_in_public)]
mod Foo {
struct Bar(u32);
@ -73,7 +77,7 @@ mod Foo {
E0447: r##"
The `pub` keyword was used inside a function. Erroneous code example:
```compile_fail
```ignore
fn foo() {
pub struct Bar; // error: visibility has no effect inside functions
}

View File

@ -21,7 +21,7 @@ variable declarations and expression statements.
Here is an example that demonstrates the error:
```compile_fail
```ignore
fn f() {
// Variable declaration before import
let x = 0;

View File

@ -15,7 +15,7 @@ register_long_diagnostics! {
E0510: r##"
`return_address` was used in an invalid context. Erroneous code example:
```compile_fail
```ignore
#![feature(intrinsics)]
extern "rust-intrinsic" {
@ -54,7 +54,7 @@ E0511: r##"
Invalid monomorphization of an intrinsic function was used. Erroneous code
example:
```compile_fail
```ignore
#![feature(platform_intrinsics)]
extern "platform-intrinsic" {

View File

@ -931,7 +931,7 @@ first instance of `Foo` could be made to initialize another instance!
Here's an example of a struct that has this problem:
```compile_fail
```ignore
struct Foo { x: Box<Foo> } // error
```
@ -952,7 +952,7 @@ are generic.
This will cause an error:
```compile_fail
```ignore
#![feature(repr_simd)]
#[repr(simd)]
@ -1143,7 +1143,7 @@ for an explicit choice of the discriminant type. In either cases, the
discriminant values must fall within a valid range for the expected type;
otherwise this error is raised. For example:
```compile_fail
```ignore
#[repr(u8)]
enum Thing {
A = 1024,
@ -1154,7 +1154,7 @@ enum Thing {
Here, 1024 lies outside the valid range for `u8`, so the discriminant for `A` is
invalid. Here is another, more subtle example which depends on target word size:
```compile_fail
```ignore
enum DependsOnPointerSize {
A = 1 << 32
}
@ -2076,7 +2076,7 @@ E0193: r##"
`where` clauses must use generic type parameters: it does not make sense to use
them otherwise. An example causing this error:
```compile_fail
```ignore
trait Foo {
fn bar(&self);
}
@ -3140,7 +3140,7 @@ An attempt was made to access an associated constant through either a generic
type parameter or `Self`. This is not supported yet. An example causing this
error is shown below:
```compile_fail
```ignore
#![feature(associated_consts)]
trait Foo {
@ -3327,6 +3327,7 @@ The maximum value of an enum was reached, so it cannot be automatically
set in the next enum value. Erroneous code example:
```compile_fail
#[deny(overflowing_literals)]
enum Foo {
X = 0x7fffffffffffffff,
Y, // error: enum discriminant overflowed on value after

View File

@ -271,8 +271,12 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
match res {
Ok(r) => {
match r {
Err(count) if count > 0 && compile_fail == false => {
sess.fatal("aborting due to previous error(s)")
Err(count) => {
if count > 0 && compile_fail == false {
sess.fatal("aborting due to previous error(s)")
} else if count == 0 && compile_fail == true {
panic!("test compiled while it wasn't supposed to")
}
}
Ok(()) if compile_fail => panic!("test compiled while it wasn't supposed to"),
_ => {}