Skip to content

Commit cae6c75

Browse files
Rollup merge of #33793 - GuillaumeGomez:compile_fail, r=GuillaumeGomez
Fix compile_fail tag Fixes #33780 r? @steveklabnik
2 parents 8f3e8c7 + abe9961 commit cae6c75

File tree

8 files changed

+28
-15
lines changed

8 files changed

+28
-15
lines changed

src/librustc/diagnostics.rs

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ first instance of `Foo` could be made to initialize another instance!
931931
932932
Here's an example of a struct that has this problem:
933933
934-
```compile_fail
934+
```ignore
935935
struct Foo { x: Box<Foo> } // error
936936
```
937937
@@ -952,7 +952,7 @@ are generic.
952952
953953
This will cause an error:
954954
955-
```compile_fail
955+
```ignore
956956
#![feature(repr_simd)]
957957
958958
#[repr(simd)]
@@ -1143,7 +1143,7 @@ for an explicit choice of the discriminant type. In either cases, the
11431143
discriminant values must fall within a valid range for the expected type;
11441144
otherwise this error is raised. For example:
11451145
1146-
```compile_fail
1146+
```ignore
11471147
#[repr(u8)]
11481148
enum Thing {
11491149
A = 1024,
@@ -1154,7 +1154,7 @@ enum Thing {
11541154
Here, 1024 lies outside the valid range for `u8`, so the discriminant for `A` is
11551155
invalid. Here is another, more subtle example which depends on target word size:
11561156
1157-
```compile_fail
1157+
```ignore
11581158
enum DependsOnPointerSize {
11591159
A = 1 << 32
11601160
}
@@ -2076,7 +2076,7 @@ E0193: r##"
20762076
`where` clauses must use generic type parameters: it does not make sense to use
20772077
them otherwise. An example causing this error:
20782078
2079-
```compile_fail
2079+
```ignore
20802080
trait Foo {
20812081
fn bar(&self);
20822082
}
@@ -3140,7 +3140,7 @@ An attempt was made to access an associated constant through either a generic
31403140
type parameter or `Self`. This is not supported yet. An example causing this
31413141
error is shown below:
31423142
3143-
```compile_fail
3143+
```ignore
31443144
#![feature(associated_consts)]
31453145
31463146
trait Foo {
@@ -3327,6 +3327,7 @@ The maximum value of an enum was reached, so it cannot be automatically
33273327
set in the next enum value. Erroneous code example:
33283328
33293329
```compile_fail
3330+
#[deny(overflowing_literals)]
33303331
enum Foo {
33313332
X = 0x7fffffffffffffff,
33323333
Y, // error: enum discriminant overflowed on value after

src/librustdoc/test.rs

Lines changed: 6 additions & 2 deletions
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)