Skip to content

Commit abe9961

Browse files
* Fix compile_fail tag (in some cases, it compiled whereas it wasn't expected to and was still considered 'ok')
* Fix error explanations tests/tags
1 parent 8393d99 commit abe9961

File tree

8 files changed

+28
-15
lines changed

8 files changed

+28
-15
lines changed

src/librustc/diagnostics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ remainder of a zero divisor) in a static or constant expression. Erroneous
2020
code example:
2121
2222
```compile_fail
23+
#[deny(const_err)]
24+
2325
const X: i32 = 42 / 0;
2426
// error: attempted to divide by zero in a constant expression
2527
```
@@ -66,7 +68,7 @@ this restriction.
6668
6769
This happens when a trait has a method like the following:
6870
69-
```compile_fail
71+
```
7072
trait Trait {
7173
fn foo(&self) -> Self;
7274
}

src/librustc_borrowck/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ structure that is currently uninitialized.
153153
154154
For example, this can happen when a drop has taken place:
155155
156-
```compile_fail
156+
```ignore
157157
struct Foo {
158158
a: u32,
159159
}

src/librustc_const_eval/diagnostics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Not-a-Number (NaN) values cannot be compared for equality and hence can never
7676
match the input to a match expression. So, the following will not compile:
7777
7878
```compile_fail
79+
#![deny(illegal_floating_point_constant_pattern)]
80+
7981
const NAN: f32 = 0.0 / 0.0;
8082
8183
let number = 0.1f32;
@@ -160,7 +162,7 @@ let Some(y) = x;
160162
If you encounter this error you probably need to use a `match` or `if let` to
161163
deal with the possibility of failure. Example:
162164
163-
```compile_fail
165+
```
164166
let x = Some(1);
165167
166168
match x {

src/librustc_privacy/diagnostics.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ A private trait was used on a public type parameter bound. Erroneous code
1717
examples:
1818
1919
```compile_fail
20+
#![deny(private_in_public)]
21+
2022
trait Foo {
2123
fn dummy(&self) { }
2224
}
@@ -45,6 +47,8 @@ E0446: r##"
4547
A private type was used in a public type signature. Erroneous code example:
4648
4749
```compile_fail
50+
#![deny(private_in_public)]
51+
4852
mod Foo {
4953
struct Bar(u32);
5054
@@ -73,7 +77,7 @@ mod Foo {
7377
E0447: r##"
7478
The `pub` keyword was used inside a function. Erroneous code example:
7579
76-
```compile_fail
80+
```ignore
7781
fn foo() {
7882
pub struct Bar; // error: visibility has no effect inside functions
7983
}

src/librustc_resolve/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ variable declarations and expression statements.
2121
2222
Here is an example that demonstrates the error:
2323
24-
```compile_fail
24+
```ignore
2525
fn f() {
2626
// Variable declaration before import
2727
let x = 0;

src/librustc_trans/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ register_long_diagnostics! {
1515
E0510: r##"
1616
`return_address` was used in an invalid context. Erroneous code example:
1717
18-
```compile_fail
18+
```ignore
1919
#![feature(intrinsics)]
2020
2121
extern "rust-intrinsic" {
@@ -54,7 +54,7 @@ E0511: r##"
5454
Invalid monomorphization of an intrinsic function was used. Erroneous code
5555
example:
5656
57-
```compile_fail
57+
```ignore
5858
#![feature(platform_intrinsics)]
5959
6060
extern "platform-intrinsic" {

src/librustc_typeck/diagnostics.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ first instance of `Foo` could be made to initialize another instance!
956956
957957
Here's an example of a struct that has this problem:
958958
959-
```compile_fail
959+
```ignore
960960
struct Foo { x: Box<Foo> } // error
961961
```
962962
@@ -977,7 +977,7 @@ are generic.
977977
978978
This will cause an error:
979979
980-
```compile_fail
980+
```ignore
981981
#![feature(repr_simd)]
982982
983983
#[repr(simd)]
@@ -1168,7 +1168,7 @@ for an explicit choice of the discriminant type. In either cases, the
11681168
discriminant values must fall within a valid range for the expected type;
11691169
otherwise this error is raised. For example:
11701170
1171-
```compile_fail
1171+
```ignore
11721172
#[repr(u8)]
11731173
enum Thing {
11741174
A = 1024,
@@ -1179,7 +1179,7 @@ enum Thing {
11791179
Here, 1024 lies outside the valid range for `u8`, so the discriminant for `A` is
11801180
invalid. Here is another, more subtle example which depends on target word size:
11811181
1182-
```compile_fail
1182+
```ignore
11831183
enum DependsOnPointerSize {
11841184
A = 1 << 32
11851185
}
@@ -2081,7 +2081,7 @@ E0193: r##"
20812081
`where` clauses must use generic type parameters: it does not make sense to use
20822082
them otherwise. An example causing this error:
20832083
2084-
```compile_fail
2084+
```ignore
20852085
trait Foo {
20862086
fn bar(&self);
20872087
}
@@ -3145,7 +3145,7 @@ An attempt was made to access an associated constant through either a generic
31453145
type parameter or `Self`. This is not supported yet. An example causing this
31463146
error is shown below:
31473147
3148-
```compile_fail
3148+
```ignore
31493149
#![feature(associated_consts)]
31503150
31513151
trait Foo {
@@ -3332,6 +3332,7 @@ The maximum value of an enum was reached, so it cannot be automatically
33323332
set in the next enum value. Erroneous code example:
33333333
33343334
```compile_fail
3335+
#[deny(overflowing_literals)]
33353336
enum Foo {
33363337
X = 0x7fffffffffffffff,
33373338
Y, // error: enum discriminant overflowed on value after

src/librustdoc/test.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,12 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec<String>, libs: SearchPaths,
271271
match res {
272272
Ok(r) => {
273273
match r {
274-
Err(count) if count > 0 && compile_fail == false => {
275-
sess.fatal("aborting due to previous error(s)")
274+
Err(count) => {
275+
if count > 0 && compile_fail == false {
276+
sess.fatal("aborting due to previous error(s)")
277+
} else if count == 0 && compile_fail == true {
278+
panic!("test compiled while it wasn't supposed to")
279+
}
276280
}
277281
Ok(()) if compile_fail => panic!("test compiled while it wasn't supposed to"),
278282
_ => {}

0 commit comments

Comments
 (0)