diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index c64f0ddac50..34080a24d9d 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -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;
 }
diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs
index 116e3476897..0624d72dd59 100644
--- a/src/librustc_borrowck/diagnostics.rs
+++ b/src/librustc_borrowck/diagnostics.rs
@@ -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,
 }
diff --git a/src/librustc_const_eval/diagnostics.rs b/src/librustc_const_eval/diagnostics.rs
index 457d25923c6..8b1d7bed7c4 100644
--- a/src/librustc_const_eval/diagnostics.rs
+++ b/src/librustc_const_eval/diagnostics.rs
@@ -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 {
diff --git a/src/librustc_privacy/diagnostics.rs b/src/librustc_privacy/diagnostics.rs
index 1b49409970d..d33bc52c5a7 100644
--- a/src/librustc_privacy/diagnostics.rs
+++ b/src/librustc_privacy/diagnostics.rs
@@ -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
 }
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 35148622052..b576f77dbd7 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -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;
diff --git a/src/librustc_trans/diagnostics.rs b/src/librustc_trans/diagnostics.rs
index d9de673db27..d36878b0332 100644
--- a/src/librustc_trans/diagnostics.rs
+++ b/src/librustc_trans/diagnostics.rs
@@ -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" {
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 40b9b0e01ab..75dcfb2c4f9 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -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
 ```
 
@@ -977,7 +977,7 @@ are generic.
 
 This will cause an error:
 
-```compile_fail
+```ignore
 #![feature(repr_simd)]
 
 #[repr(simd)]
@@ -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,
@@ -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
 }
@@ -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);
 }
@@ -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 {
@@ -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
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index 2754f77444c..53201a9580e 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -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"),
                 _ => {}