Skip to content

Commit

Permalink
* Fix compile_fail tag (in some cases, it compiled whereas it wasn't …
Browse files Browse the repository at this point in the history
…expected to and was still considered 'ok')

* Fix error explanations tests/tags
  • Loading branch information
GuillaumeGomez committed May 26, 2016
1 parent 8393d99 commit abe9961
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/librustc/diagnostics.rs
Expand Up @@ -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
```
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/diagnostics.rs
Expand Up @@ -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,
}
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_const_eval/diagnostics.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/librustc_privacy/diagnostics.rs
Expand Up @@ -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) { }
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/diagnostics.rs
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/diagnostics.rs
Expand Up @@ -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" {
Expand Down Expand Up @@ -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" {
Expand Down
13 changes: 7 additions & 6 deletions src/librustc_typeck/diagnostics.rs
Expand Up @@ -956,7 +956,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
```
Expand All @@ -977,7 +977,7 @@ are generic.
This will cause an error:
```compile_fail
```ignore
#![feature(repr_simd)]
#[repr(simd)]
Expand Down Expand Up @@ -1168,7 +1168,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,
Expand All @@ -1179,7 +1179,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
}
Expand Down Expand Up @@ -2081,7 +2081,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);
}
Expand Down Expand Up @@ -3145,7 +3145,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 {
Expand Down Expand Up @@ -3332,6 +3332,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
Expand Down
8 changes: 6 additions & 2 deletions src/librustdoc/test.rs
Expand Up @@ -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"),
_ => {}
Expand Down

0 comments on commit abe9961

Please sign in to comment.