]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/diagnostics.rs
Update long error explanations
[rust.git] / src / librustc_typeck / diagnostics.rs
index f138b997f4cc32767e0191e19fa91a1ee454f444..5c79e9a4ec5c6ecf33fc671d55aa60f424e340af 100644 (file)
 
 ```
 enum Fruit {
-    Apple(String, String)
-    Pear(u32)
+    Apple(String, String),
+    Pear(u32),
 }
 ```
 
 Here the `Apple` variant has two fields, and should be matched against like so:
 
 ```
+enum Fruit {
+    Apple(String, String),
+    Pear(u32),
+}
+
+let x = Fruit::Apple(String::new(), String::new());
+
 // Correct.
 match x {
-    Apple(a, b) => ...
+    Fruit::Apple(a, b) => {},
+    _ => {}
 }
 ```
 
 Matching with the wrong number of fields has no sensible interpretation:
 
-```
+```compile_fail
+enum Fruit {
+    Apple(String, String),
+    Pear(u32),
+}
+
+let x = Fruit::Apple(String::new(), String::new());
+
 // Incorrect.
 match x {
-    Apple(a) => ...,
-    Apple(a, b, c) => ...
+    Apple(a) => {},
+    Apple(a, b, c) => {},
 }
 ```
 
@@ -51,7 +66,7 @@ enum Fruit {
 This error indicates that a pattern attempted to extract the fields of an enum
 variant with no fields. Here's a tiny example of this error:
 
-```
+```compile_fail
 // This enum has two variants.
 enum Number {
     // This variant has no fields.
@@ -62,8 +77,8 @@ enum Number {
 
 // Assuming x is a Number we can pattern match on its contents.
 match x {
-    Zero(inside) => ...,
-    One(inside) => ...
+    Zero(inside) => {},
+    One(inside) => {},
 }
 ```
 
@@ -76,7 +91,7 @@ enum Number {
 Each field of a struct can only be bound once in a pattern. Erroneous code
 example:
 
-```
+```compile_fail
 struct Foo {
     a: u8,
     b: u8,
@@ -122,23 +137,42 @@ struct Thing {
 }
 
 let thing = Thing { x: 1, y: 2 };
+
 match thing {
-    Thing { x: xfield, y: yfield } => ...
+    Thing { x: xfield, y: yfield } => {}
 }
 ```
 
 If you are using shorthand field patterns but want to refer to the struct field
 by a different name, you should rename it explicitly.
 
-```
-// Change this:
+Change this:
+
+```compile_fail
+struct Thing {
+    x: u32,
+    y: u32
+}
+
+let thing = Thing { x: 0, y: 0 };
+
 match thing {
-    Thing { x, z } => ...
+    Thing { x, z } => {}
+}
+```
+
+To this:
+
+```
+struct Thing {
+    x: u32,
+    y: u32
 }
 
-// To this:
+let thing = Thing { x: 0, y: 0 };
+
 match thing {
-    Thing { x, y: z } => ...
+    Thing { x, y: z } => {}
 }
 ```
 "##,
@@ -150,27 +184,37 @@ struct Thing {
 
 For example:
 
-```
+```compile_fail
 struct Dog {
     name: String,
-    age: u32
+    age: u32,
 }
 
 let d = Dog { name: "Rusty".to_string(), age: 8 };
 
 // This is incorrect.
 match d {
-    Dog { age: x } => ...
+    Dog { age: x } => {}
 }
+```
+
+This is correct (explicit):
+
+```
+struct Dog {
+    name: String,
+    age: u32,
+}
+
+let d = Dog { name: "Rusty".to_string(), age: 8 };
 
-// This is correct (explicit).
 match d {
-    Dog { name: n, age: x } => ...
+    Dog { name: ref n, age: x } => {}
 }
 
 // This is also correct (ignore unused fields).
 match d {
-    Dog { age: x, .. } => ...
+    Dog { age: x, .. } => {}
 }
 ```
 "##,
@@ -182,18 +226,18 @@ struct Dog {
 want to capture values of an orderable type between two end-points, you can use
 a guard.
 
-```
+```compile_fail
 // The ordering relation for strings can't be evaluated at compile time,
 // so this doesn't work:
 match string {
-    "hello" ... "world" => ...
-    _ => ...
+    "hello" ... "world" => {}
+    _ => {}
 }
 
 // This is a more general version, using a guard:
 match string {
-    s if s >= "hello" && s <= "world" => ...
-    _ => ...
+    s if s >= "hello" && s <= "world" => {}
+    _ => {}
 }
 ```
 "##,
@@ -205,7 +249,7 @@ struct Dog {
 Therefore, all accesses to trait types must be through pointers. If you
 encounter this error you should try to avoid dereferencing the pointer.
 
-```
+```ignore
 let trait_obj: &SomeTrait = ...;
 
 // This tries to implicitly dereference to create an unsized local variable.
@@ -224,9 +268,9 @@ struct Dog {
 
 E0034: r##"
 The compiler doesn't know what method to call because more than one method
-has the same prototype. Example:
+has the same prototype. Erroneous code example:
 
-```
+```compile_fail
 struct Test;
 
 trait Trait1 {
@@ -286,9 +330,10 @@ fn main() {
 "##,
 
 E0035: r##"
-You tried to give a type parameter where it wasn't needed. Bad example:
+You tried to give a type parameter where it wasn't needed. Erroneous code
+example:
 
-```
+```compile_fail
 struct Test;
 
 impl Test {
@@ -321,9 +366,9 @@ fn main() {
 
 E0036: r##"
 This error occurrs when you pass too many or not enough type parameters to
-a method. Example:
+a method. Erroneous code example:
 
-```
+```compile_fail
 struct Test;
 
 impl Test {
@@ -361,7 +406,7 @@ fn main() {
 
 Please note on the last example that we could have called `method` like this:
 
-```
+```ignore
 x.method(v);
 ```
 "##,
@@ -373,7 +418,7 @@ fn main() {
 
 Here's an example of this error:
 
-```
+```compile_fail
 struct Foo {
     x: i32,
 }
@@ -394,7 +439,7 @@ fn main() {
 E0044: r##"
 You can't use type parameters on foreign items. Example of erroneous code:
 
-```
+```compile_fail
 extern { fn some_func<T>(x: T); }
 ```
 
@@ -412,17 +457,23 @@ fn main() {
 FFI. As such, variadic parameters can only be used with functions which are
 using the C ABI. Examples of erroneous code:
 
-```
+```compile_fail
 extern "rust-call" { fn foo(x: u8, ...); }
+
 // or
+
 fn foo(x: u8, ...) {}
 ```
 
 To fix such code, put them in an extern "C" block:
 
+```ignore
+extern "C" fn foo(x: u8, ...);
+```
+
+Or:
+
 ```
-extern "C" fn foo (x: u8, ...);
-// or:
 extern "C" {
     fn foo (x: u8, ...);
 }
@@ -432,7 +483,7 @@ fn foo(x: u8, ...) {}
 E0046: r##"
 Items are missing in a trait implementation. Erroneous code example:
 
-```
+```compile_fail
 trait Foo {
     fn foo();
 }
@@ -468,7 +519,7 @@ fn foo() {} // ok!
 For example, the trait below has a method `foo` with a type parameter `T`,
 but the implementation of `foo` for the type `Bar` is missing this parameter:
 
-```
+```compile_fail
 trait Foo {
     fn foo<T: Default>(x: T) -> Self;
 }
@@ -491,7 +542,7 @@ fn foo(x: bool) -> Self { Bar }
 (`&self` and `u8`), but the implementation of `foo` for the type `Bar` omits
 the `u8` parameter:
 
-```
+```compile_fail
 trait Foo {
     fn foo(&self, x: u8) -> bool;
 }
@@ -512,7 +563,7 @@ fn foo(&self) -> bool { true }
 
 Here are a couple examples of this error:
 
-```
+```compile_fail
 trait Foo {
     fn foo(x: u16);
     fn bar(&self);
@@ -534,14 +585,18 @@ fn bar(&mut self) { }
 It is not allowed to cast to a bool. If you are trying to cast a numeric type
 to a bool, you can compare it with zero instead:
 
+```compile_fail
+let x = 5;
+
+// Not allowed, won't compile
+let x_is_nonzero = x as bool;
+```
+
 ```
 let x = 5;
 
 // Ok
 let x_is_nonzero = x != 0;
-
-// Not allowed, won't compile
-let x_is_nonzero = x as bool;
 ```
 "##,
 
@@ -553,7 +608,7 @@ fn bar(&mut self) { }
 
 For a somewhat artificial example:
 
-```
+```compile_fail
 #![recursion_limit="2"]
 
 struct Foo;
@@ -583,7 +638,7 @@ fn main() {
 
 An example using a closure:
 
-```
+```compile_fail
 let f = |x| x * 3;
 let a = f();        // invalid, too few parameters
 let b = f(4);       // this works!
@@ -609,13 +664,13 @@ fn foo<F: Fn()>(f: F) {
 The most likely source of this error is using angle-bracket notation without
 wrapping the function argument type into a tuple, for example:
 
-```
+```compile_fail
 fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) }
 ```
 
 It can be fixed by adjusting the trait bound like this:
 
-```
+```ignore
 fn foo<F: Fn<(i32,)>>(f: F) -> F::Output { f(3) }
 ```
 
@@ -628,7 +683,7 @@ fn foo<F: Fn<(i32,)>>(f: F) -> F::Output { f(3) }
 takes a minimum number of arguments. For example, consider C's variadic `printf`
 function:
 
-```
+```ignore
 extern crate libc;
 use libc::{ c_char, c_int };
 
@@ -640,7 +695,7 @@ fn foo<F: Fn<(i32,)>>(f: F) -> F::Output { f(3) }
 Using this declaration, it must be called with at least one argument, so
 simply calling `printf()` is invalid. But the following uses are allowed:
 
-```
+```ignore
 unsafe {
     use std::ffi::CString;
 
@@ -655,13 +710,13 @@ fn foo<F: Fn<(i32,)>>(f: F) -> F::Output { f(3) }
 The number of arguments passed to a function must match the number of arguments
 specified in the function signature.
 
-For example, a function like
+For example, a function like:
 
 ```
 fn f(a: u16, b: &str) {}
 ```
 
-must always be called with exactly two arguments, e.g. `f(2, "test")`.
+Must always be called with exactly two arguments, e.g. `f(2, "test")`.
 
 Note, that Rust does not have a notion of optional function arguments or
 variadic functions (except for its C-FFI).
@@ -672,7 +727,7 @@ fn f(a: u16, b: &str) {}
 enum variant, one of the fields was specified more than once. Erroneous code
 example:
 
-```
+```compile_fail
 struct Foo {
     x: i32
 }
@@ -702,7 +757,7 @@ fn main() {
 This error indicates that during an attempt to build a struct or struct-like
 enum variant, one of the fields was not provided. Erroneous code example:
 
-```
+```compile_fail
 struct Foo {
     x: i32,
     y: i32
@@ -743,9 +798,9 @@ fn main() {
 item paths (ie, namespaced variables), dereferences, indexing expressions,
 and field references.
 
-Let's start with some bad examples:
+Let's start with some erroneous code examples:
 
-```
+```compile_fail
 use std::collections::LinkedList;
 
 // Bad: assignment to non-lvalue expression
@@ -758,7 +813,7 @@ fn some_func(i: &mut i32) {
 }
 ```
 
-And now some good examples:
+And now some working examples:
 
 ```
 let mut i : i32 = 0;
@@ -777,7 +832,7 @@ fn some_func(i: &mut i32) {
 The compiler found a function whose body contains a `return;` statement but
 whose return type is not `()`. An example of this is:
 
-```
+```compile_fail
 // error
 fn foo() -> u8 {
     return;
@@ -797,13 +852,14 @@ fn foo() -> u8 {
 More details can be found here:
 https://doc.rust-lang.org/reference.html#lvalues-rvalues-and-temporaries
 
-Now, we can go further. Here are some bad examples:
+Now, we can go further. Here are some erroneous code examples:
 
-```
+```compile_fail
 struct SomeStruct {
     x: i32,
     y: i32
 }
+
 const SOME_CONST : i32 = 12;
 
 fn some_other_func() {}
@@ -817,7 +873,7 @@ fn some_function() {
 }
 ```
 
-And now let's give good examples:
+And now let's give working examples:
 
 ```
 struct SomeStruct {
@@ -842,7 +898,7 @@ fn some_func(x: &mut i32) {
 
 Example of erroneous code:
 
-```
+```compile_fail
 enum Foo { FirstValue(i32) };
 
 let u = Foo::FirstValue { value: 0i32 }; // error: Foo::FirstValue
@@ -876,7 +932,7 @@ fn main() {
 
 Here's an example of a struct that has this problem:
 
-```
+```compile_fail
 struct Foo { x: Box<Foo> } // error
 ```
 
@@ -895,12 +951,22 @@ struct Foo { x: Option<Box<Foo>> }
 reason about how to use SIMD with them. This error will occur if the types
 are generic.
 
-```
+This will cause an error:
+
+```compile_fail
+#![feature(simd)]
+
 #[simd]
-struct Bad<T>(T, T, T); // This will cause an error
+struct Bad<T>(T, T, T);
+```
+
+This will not:
+
+```
+#![feature(simd)]
 
 #[simd]
-struct Good(u32, u32, u32); // This will not
+struct Good(u32, u32, u32);
 ```
 "##,
 
@@ -909,12 +975,22 @@ struct Foo { x: Option<Box<Foo>> }
 it doesn't make sense to try to use SIMD operations when there are no values to
 operate on.
 
-```
+This will cause an error:
+
+```compile_fail
+#![feature(simd)]
+
 #[simd]
-struct Bad; // This will cause an error
+struct Bad;
+```
+
+This will not:
+
+```
+#![feature(simd)]
 
 #[simd]
-struct Good(u32); // This will not
+struct Good(u32);
 ```
 "##,
 
@@ -923,26 +999,45 @@ struct Foo { x: Option<Box<Foo>> }
 struct, the types in the struct must all be of the same type, or the compiler
 will trigger this error.
 
-```
-#[simd]
-struct Bad(u16, u32, u32); // This will cause an error
+This will cause an error:
+
+```compile_fail
+#![feature(simd)]
 
 #[simd]
-struct Good(u32, u32, u32); // This will not
+struct Bad(u16, u32, u32);
 ```
 
+This will not:
+
+```
+#![feature(simd)]
+
+#[simd]
+struct Good(u32, u32, u32);
+```
 "##,
 
 E0077: r##"
 When using the `#[simd]` attribute on a tuple struct, the elements in the tuple
 must be machine types so SIMD operations can be applied to them.
 
-```
+This will cause an error:
+
+```compile_fail
+#![feature(simd)]
+
 #[simd]
-struct Bad(String); // This will cause an error
+struct Bad(String);
+```
+
+This will not:
+
+```
+#![feature(simd)]
 
 #[simd]
-struct Good(u32, u32, u32); // This will not
+struct Good(u32, u32, u32);
 ```
 "##,
 
@@ -951,15 +1046,15 @@ struct Foo { x: Option<Box<Foo>> }
 representation. This error indicates that the value provided is not an integer
 literal and is therefore invalid.
 
-For example, in the following code,
+For example, in the following code:
 
-```
+```compile_fail
 enum Foo {
     Q = "32"
 }
 ```
 
-we try to set the representation to a string.
+We try to set the representation to a string.
 
 There's no general fix for this; if you can work with an integer then just set
 it to one:
@@ -970,7 +1065,7 @@ enum Foo {
 }
 ```
 
-however if you actually wanted a mapping between variants and non-integer
+However if you actually wanted a mapping between variants and non-integer
 objects, it may be preferable to use a method with a match instead:
 
 ```
@@ -990,7 +1085,7 @@ fn get_str(&self) -> &'static str {
 integer expression provided as an enum discriminant. Attempting to divide by 0
 or causing integer overflow are two ways to induce this error. For example:
 
-```
+```compile_fail
 enum Enum {
     X = (1 << 500),
     Y = (1 / 0)
@@ -1009,17 +1104,19 @@ enum Enum {
 This error indicates that the same value was used for two or more variants,
 making them impossible to tell apart.
 
-```
-// Good.
+```compile_fail
+// Bad.
 enum Enum {
-    P,
+    P = 3,
     X = 3,
     Y = 5
 }
+```
 
-// Bad.
+```
+// Good.
 enum Enum {
-    P = 3,
+    P,
     X = 3,
     Y = 5
 }
@@ -1029,7 +1126,7 @@ enum Enum {
 top to bottom starting from 0, so clashes can occur with seemingly unrelated
 variants.
 
-```
+```compile_fail
 enum Bad {
     X,
     Y = 0
@@ -1046,7 +1143,7 @@ enum Bad {
 an integer literal given as a discriminant is not a member of the discriminant
 type. For example:
 
-```
+```compile_fail
 #[repr(u8)]
 enum Thing {
     A = 1024,
@@ -1075,7 +1172,7 @@ enum Empty {}
 E0087: r##"
 Too many type parameters were supplied for a function. For example:
 
-```
+```compile_fail
 fn foo<T>() {}
 
 fn main() {
@@ -1090,7 +1187,7 @@ fn main() {
 E0088: r##"
 You gave too many lifetime parameters. Erroneous code example:
 
-```
+```compile_fail
 fn f() {}
 
 fn main() {
@@ -1135,7 +1232,7 @@ fn main() {
 E0089: r##"
 Not enough type parameters were supplied for a function. For example:
 
-```
+```compile_fail
 fn foo<T, U>() {}
 
 fn main() {
@@ -1146,7 +1243,7 @@ fn main() {
 Note that if a function takes multiple type parameters but you want the compiler
 to infer some of them, you can use type placeholders:
 
-```
+```compile_fail
 fn foo<T, U>(x: T) {}
 
 fn main() {
@@ -1161,7 +1258,7 @@ fn main() {
 You gave an unnecessary type parameter in a type alias. Erroneous code
 example:
 
-```
+```compile_fail
 type Foo<T> = u32; // error: type parameter `T` is unused
 // or:
 type Foo<A,B> = Box<A>; // error: type parameter `B` is unused
@@ -1171,7 +1268,7 @@ fn main() {
 
 ```
 type Foo = u32; // ok!
-type Foo<A> = Box<A>; // ok!
+type Foo2<A> = Box<A>; // ok!
 ```
 "##,
 
@@ -1179,7 +1276,7 @@ fn main() {
 You tried to declare an undefined atomic operation function.
 Erroneous code example:
 
-```
+```compile_fail
 #![feature(intrinsics)]
 
 extern "rust-intrinsic" {
@@ -1204,7 +1301,7 @@ fn main() {
 E0093: r##"
 You declared an unknown intrinsic function. Erroneous code example:
 
-```
+```compile_fail
 #![feature(intrinsics)]
 
 extern "rust-intrinsic" {
@@ -1241,7 +1338,7 @@ fn main() {
 You gave an invalid number of type parameters to an intrinsic function.
 Erroneous code example:
 
-```
+```compile_fail
 #![feature(intrinsics)]
 
 extern "rust-intrinsic" {
@@ -1267,7 +1364,7 @@ fn main() {
 You hit this error because the compiler lacks the information to
 determine a type for this expression. Erroneous code example:
 
-```
+```compile_fail
 fn main() {
     let x = |_| {}; // error: cannot determine a type for this expression
 }
@@ -1293,7 +1390,7 @@ fn main() {
 You hit this error because the compiler lacks information to
 determine a type for this variable. Erroneous code example:
 
-```
+```compile_fail
 fn demo(devil: fn () -> !) {
     let x: &_ = devil();
     // error: cannot determine a type for this local variable
@@ -1310,6 +1407,8 @@ fn main() {
 Examples:
 
 ```
+#![allow(unused_variables)]
+
 fn some_func(x: &u32) {
     // some code
 }
@@ -1338,7 +1437,7 @@ fn main() {
 
 Here are some simple examples of where you'll run into this error:
 
-```
+```compile_fail
 struct Foo { x: &bool }        // error
 struct Foo<'a> { x: &'a bool } // correct
 
@@ -1366,15 +1465,15 @@ enum Bar<'a> { A(u8), B(&'a bool), } // correct
 
 Here are some examples of elision errors:
 
-```
+```compile_fail
 // error, no input lifetimes
-fn foo() -> &str { ... }
+fn foo() -> &str { }
 
 // error, `x` and `y` have distinct lifetimes inferred
-fn bar(x: &str, y: &str) -> &str { ... }
+fn bar(x: &str, y: &str) -> &str { }
 
 // error, `y`'s lifetime is inferred to be distinct from `x`'s
-fn baz<'a>(x: &'a str, y: &str) -> &str { ... }
+fn baz<'a>(x: &'a str, y: &str) -> &str { }
 ```
 
 [book-le]: https://doc.rust-lang.org/nightly/book/lifetimes.html#lifetime-elision
@@ -1386,7 +1485,7 @@ fn baz<'a>(x: &'a str, y: &str) -> &str { ... }
 
 Some basic examples include:
 
-```
+```compile_fail
 struct Foo<'a>(&'a str);
 enum Bar { A, B, C }
 
@@ -1399,7 +1498,7 @@ struct Baz<'a> {
 Here's an example that is currently an error, but may work in a future version
 of Rust:
 
-```
+```compile_fail
 struct Foo<'a>(&'a str);
 
 trait Quux { }
@@ -1417,8 +1516,8 @@ impl Quux for Foo { } // error: expected 1, found 0
 where the type was defined. For example, an `impl` block as below is not allowed
 since `Vec` is defined in the standard library:
 
-```
-impl Vec<u8> { ... } // error
+```compile_fail
+impl Vec<u8> { } // error
 ```
 
 To fix this problem, you can do either of these things:
@@ -1431,10 +1530,10 @@ impl Vec<u8> { ... } // error
 Note that using the `type` keyword does not work here because `type` only
 introduces a type alias:
 
-```
+```compile_fail
 type Bytes = Vec<u8>;
 
-impl Bytes { ... } // error, same as above
+impl Bytes { } // error, same as above
 ```
 "##,
 
@@ -1449,14 +1548,14 @@ trait defined in another crate) where
 
 Here's one example of this error:
 
-```
+```compile_fail
 impl Drop for u32 {}
 ```
 
 To avoid this kind of error, ensure that at least one local type is referenced
 by the `impl`:
 
-```
+```ignore
 pub struct Foo; // you define your type in your crate
 
 impl Drop for Foo { // and you can implement the trait on it!
@@ -1492,7 +1591,7 @@ fn get(&self) -> usize { 0 }
 You're trying to write an inherent implementation for something which isn't a
 struct nor an enum. Erroneous code example:
 
-```
+```compile_fail
 impl (u8, u8) { // error: no base type found for inherent implementation
     fn get_state(&self) -> String {
         // ...
@@ -1536,7 +1635,7 @@ fn get_state(&self) -> String {
 There are conflicting trait implementations for the same type.
 Example of erroneous code:
 
-```
+```compile_fail
 trait MyTrait {
     fn get(&self) -> usize;
 }
@@ -1561,6 +1660,10 @@ fn get(&self) -> usize { self.value }
 this is an error. So, when you write:
 
 ```
+trait MyTrait {
+    fn get(&self) -> usize;
+}
+
 impl<T> MyTrait for T {
     fn get(&self) -> usize { 0 }
 }
@@ -1593,7 +1696,7 @@ fn main() {
 An attempt was made to implement Drop on a trait, which is not allowed: only
 structs and enums can implement Drop. An example causing this error:
 
-```
+```compile_fail
 trait MyTrait {}
 
 impl Drop for MyTrait {
@@ -1634,7 +1737,7 @@ fn drop(&mut self) {}
 
 Examples of this error include:
 
-```
+```compile_fail
 fn foo() -> _ { 5 } // error, explicitly write out the return type instead
 
 static BAR: _ = "test"; // error, explicitly write out the type instead
@@ -1665,10 +1768,10 @@ fn main() {
 You declared two fields of a struct with the same name. Erroneous code
 example:
 
-```
+```compile_fail
 struct Foo {
     field1: i32,
-    field1: i32 // error: field is already declared
+    field1: i32, // error: field is already declared
 }
 ```
 
@@ -1677,7 +1780,7 @@ struct Foo {
 ```
 struct Foo {
     field1: i32,
-    field2: i32 // ok!
+    field2: i32, // ok!
 }
 ```
 "##,
@@ -1686,8 +1789,8 @@ struct Foo {
 Type parameter defaults can only use parameters that occur before them.
 Erroneous code example:
 
-```
-pub struct Foo<T=U, U=()> {
+```compile_fail
+struct Foo<T=U, U=()> {
     field1: T,
     filed2: U,
 }
@@ -1699,7 +1802,7 @@ pub struct Foo<T=U, U=()> {
 by doing:
 
 ```
-pub struct Foo<U=(), T=U> {
+struct Foo<U=(), T=U> {
     field1: T,
     filed2: U,
 }
@@ -1713,7 +1816,7 @@ pub struct Foo<U=(), T=U> {
 You declared a pattern as an argument in a foreign function declaration.
 Erroneous code example:
 
-```
+```compile_fail
 extern {
     fn foo((a, b): (u32, u32)); // error: patterns aren't allowed in foreign
                                 //        function declarations
@@ -1731,7 +1834,11 @@ struct SomeStruct {
 extern {
     fn foo(s: SomeStruct); // ok!
 }
-// or
+```
+
+Or:
+
+```
 extern {
     fn foo(a: (u32, u32)); // ok!
 }
@@ -1743,7 +1850,7 @@ struct SomeStruct {
 parameters. When `main` is present, it must take no arguments and return `()`.
 Erroneous code example:
 
-```
+```compile_fail
 fn main<T>() { // error: main function is not allowed to have type parameters
 }
 ```
@@ -1753,7 +1860,7 @@ fn main<T>() { // error: main function is not allowed to have type parameters
 It is not possible to declare type parameters on a function that has the `start`
 attribute. Such a function must have the following type signature:
 
-```
+```ignore
 fn(isize, *const *const u8) -> isize;
 ```
 "##,
@@ -1762,12 +1869,12 @@ fn main<T>() { // error: main function is not allowed to have type parameters
 This error means that an attempt was made to match an enum variant as a
 struct type when the variant isn't a struct type:
 
-```
+```compile_fail
 enum Foo { B(u32) }
 
 fn bar(foo: Foo) -> u32 {
     match foo {
-        Foo::B{i} => i // error 0163
+        B{i} => i, // error E0163
     }
 }
 ```
@@ -1775,25 +1882,26 @@ fn bar(foo: Foo) -> u32 {
 Try using `()` instead:
 
 ```
+enum Foo { B(u32) }
+
 fn bar(foo: Foo) -> u32 {
     match foo {
-        Foo::B(i) => i
+        Foo::B(i) => i,
     }
 }
 ```
 "##,
 
 E0164: r##"
-
 This error means that an attempt was made to match a struct type enum
 variant as a non-struct type:
 
-```
-enum Foo { B{ i: u32 } }
+```compile_fail
+enum Foo { B { i: u32 } }
 
 fn bar(foo: Foo) -> u32 {
     match foo {
-        Foo::B(i) => i // error 0164
+        Foo::B(i) => i, // error E0164
     }
 }
 ```
@@ -1801,21 +1909,22 @@ fn bar(foo: Foo) -> u32 {
 Try using `{}` instead:
 
 ```
+enum Foo { B { i: u32 } }
+
 fn bar(foo: Foo) -> u32 {
     match foo {
-        Foo::B{i} => i
+        Foo::B{i} => i,
     }
 }
 ```
 "##,
 
-
 E0166: r##"
 This error means that the compiler found a return expression in a function
 marked as diverging. A function diverges if it has `!` in the place of the
 return type in its signature. For example:
 
-```
+```compile_fail
 fn foo() -> ! { return; } // error
 ```
 
@@ -1828,7 +1937,7 @@ fn bar(foo: Foo) -> u32 {
 This error means that an attempt was made to specify the type of a variable with
 a combination of a concrete type and a trait. Consider the following example:
 
-```
+```compile_fail
 fn foo(bar: i32+std::fmt::Display) {}
 ```
 
@@ -1857,7 +1966,7 @@ fn foo(bar: i32) {}
 
 For example:
 
-```
+```compile_fail
 trait Foo {}
 
 struct Bar<'a> {
@@ -1889,7 +1998,7 @@ struct Bar<'a> {
 
 Here's an example of this error:
 
-```
+```compile_fail
 trait Foo {
     fn foo();
 }
@@ -1910,7 +2019,7 @@ fn foo(&self) {}
 
 Here's an example of this error:
 
-```
+```compile_fail
 trait Foo {
     fn foo(&self);
 }
@@ -1929,7 +2038,7 @@ fn foo() {}
 Trait objects need to have all associated types specified. Erroneous code
 example:
 
-```
+```compile_fail
 trait Trait {
     type Bar;
 }
@@ -1960,7 +2069,7 @@ trait Trait {
 `where` clauses must use generic type parameters: it does not make sense to use
 them otherwise. An example causing this error:
 
-```
+```compile_fail
 trait Foo {
     fn bar(&self);
 }
@@ -1979,6 +2088,14 @@ fn bar(&self) { }
 something like the following:
 
 ```
+trait Foo {
+    fn bar(&self);
+}
+
+#[derive(Copy,Clone)]
+struct Wrapper<T> {
+    Wrapped: T
+}
 impl <T> Foo for Wrapper<T> where Wrapper<T>: Clone {
     fn bar(&self) { }
 }
@@ -1997,7 +2114,7 @@ fn bar(&self) { }
 A type parameter was declared which shadows an existing one. An example of this
 error:
 
-```
+```compile_fail
 trait Foo<T> {
     fn do_something(&self) -> T;
     fn do_something_else<T: Clone>(&self, bar: T);
@@ -2013,7 +2130,7 @@ trait Foo<T> {
 Your method's lifetime parameters do not match the trait declaration.
 Erroneous code example:
 
-```
+```compile_fail
 trait Trait {
     fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
 }
@@ -2052,7 +2169,7 @@ fn t<'a,'b:'a>(x: &'a str, y: &'b str) { // ok!
 implementing an unsafe trait. Removing the `unsafe` keyword from the inherent
 implementation will resolve this error.
 
-```
+```compile_fail
 struct Foo;
 
 // this will cause this error
@@ -2068,22 +2185,38 @@ impl Foo { }
 so negative implementations are always safe and never need to be marked as
 unsafe.
 
-```
+```compile_fail
+#![feature(optin_builtin_traits)]
+
 struct Foo;
 
 // unsafe is unnecessary
 unsafe impl !Clone for Foo { }
-// this will compile
-impl !Clone for Foo { }
 ```
+
+This will compile:
+
+```
+#![feature(optin_builtin_traits)]
+
+struct Foo;
+
+trait Enterprise {}
+
+impl Enterprise for .. { }
+
+impl !Enterprise for Foo { }
+```
+
+Please note that negative impls are only allowed for traits with default impls.
 "##,
 
 E0199: r##"
 Safe traits should not have unsafe implementations, therefore marking an
-implementation for a safe trait unsafe will cause a compiler error. Removing the
-unsafe marker on the trait noted in the error will resolve this problem.
+implementation for a safe trait unsafe will cause a compiler error. Removing
+the unsafe marker on the trait noted in the error will resolve this problem.
 
-```
+```compile_fail
 struct Foo;
 
 trait Bar { }
@@ -2100,7 +2233,7 @@ impl Bar for Foo { }
 implementation for an unsafe trait isn't marked as unsafe. This may be resolved
 by marking the unsafe implementation as unsafe.
 
-```
+```compile_fail
 struct Foo;
 
 unsafe trait Bar { }
@@ -2118,7 +2251,7 @@ unsafe impl Bar for Foo { }
 
 For example:
 
-```
+```compile_fail
 struct Foo(u8);
 
 impl Foo {
@@ -2158,7 +2291,7 @@ fn baz(&self) -> bool { self.0 > 5 }
 fields does not implement `Copy`. To fix this, you must implement `Copy` for the
 mentioned field. Note that this may not be possible, as in the example of
 
-```
+```compile_fail
 struct Foo {
     foo : Vec<u32>,
 }
@@ -2170,7 +2303,7 @@ impl Copy for Foo { }
 
 Here's another example that will fail:
 
-```
+```compile_fail
 #[derive(Copy)]
 struct Foo<'a> {
     ty: &'a mut bool,
@@ -2186,7 +2319,7 @@ struct Foo<'a> {
 variants does not implement `Copy`. To fix this, you must implement `Copy` for
 the mentioned variant. Note that this may not be possible, as in the example of
 
-```
+```compile_fail
 enum Foo {
     Bar(Vec<u32>),
     Baz,
@@ -2199,7 +2332,7 @@ impl Copy for Foo { }
 
 Here's another example that will fail:
 
-```
+```compile_fail
 #[derive(Copy)]
 enum Foo<'a> {
     Bar(&'a mut bool),
@@ -2216,7 +2349,7 @@ enum Foo<'a> {
 examples will fail, because neither `i32` (primitive type) nor `&'static Bar`
 (reference to `Bar`) is a struct or enum:
 
-```
+```compile_fail
 type Foo = i32;
 impl Copy for Foo { } // error
 
@@ -2230,7 +2363,7 @@ impl Copy for &'static Bar { } // error
 You declared an unused type parameter when implementing a trait on an object.
 Erroneous code example:
 
-```
+```compile_fail
 trait MyTrait {
     fn get(&self) -> usize;
 }
@@ -2272,18 +2405,18 @@ fn get(&self) -> usize {
 If `ForeignTrait` is a trait defined in some external crate `foo`, then the
 following trait `impl` is an error:
 
-```
+```compile_fail
 extern crate foo;
 use foo::ForeignTrait;
 
-impl<T> ForeignTrait for T { ... } // error
+impl<T> ForeignTrait for T { } // error
 ```
 
 To work around this, it can be covered with a local type, `MyType`:
 
-```
+```ignore
 struct MyType<T>(T);
-impl<T> ForeignTrait for MyType<T> { ... } // Ok
+impl<T> ForeignTrait for MyType<T> { } // Ok
 ```
 
 Please note that a type alias is not sufficient.
@@ -2292,9 +2425,9 @@ impl<T> ForeignTrait for MyType<T> { ... } // Ok
 named `ForeignTrait2` that takes two type parameters. Then this `impl` results
 in the same rule violation:
 
-```
+```compile_fail
 struct MyType2;
-impl<T> ForeignTrait2<T, MyType<T>> for MyType2 { ... } // error
+impl<T> ForeignTrait2<T, MyType<T>> for MyType2 { } // error
 ```
 
 The reason for this is that there are two appearances of type parameter `T` in
@@ -2303,8 +2436,8 @@ impl<T> ForeignTrait2<T, MyType<T>> for MyType2 { ... } // error
 
 Consider one more example:
 
-```
-impl<T> ForeignTrait2<MyType<T>, T> for MyType2 { ... } // Ok
+```ignore
+impl<T> ForeignTrait2<MyType<T>, T> for MyType2 { } // Ok
 ```
 
 This only differs from the previous `impl` in that the parameters `T` and
@@ -2314,7 +2447,7 @@ impl<T> ForeignTrait2<MyType<T>, T> for MyType2 { ... } // Ok
 To see why that last example was allowed, you need to understand the general
 rule. Unfortunately this rule is a bit tricky to state. Consider an `impl`:
 
-```
+```ignore
 impl<P1, ..., Pm> ForeignTrait<T1, ..., Tn> for T0 { ... }
 ```
 
@@ -2333,7 +2466,7 @@ impl<P1, ..., Pm> ForeignTrait<T1, ..., Tn> for T0 { ... }
 You used a function or type which doesn't fit the requirements for where it was
 used. Erroneous code examples:
 
-```
+```compile_fail
 #![feature(intrinsics)]
 
 extern "rust-intrinsic" {
@@ -2379,7 +2512,7 @@ fn x(self: Rc<Foo>) {}
 The second case example is a bit particular : the main function must always
 have this definition:
 
-```
+```compile_fail
 fn main();
 ```
 
@@ -2390,6 +2523,7 @@ fn x(self: Rc<Foo>) {}
 
 ```
 let x = 1u8;
+
 match x {
     0u8...3u8 => (), // ok!
     _ => ()
@@ -2412,7 +2546,7 @@ fn x(self: Box<Foo>) {} // ok!
 A generic type was described using parentheses rather than angle brackets. For
 example:
 
-```
+```compile_fail
 fn main() {
     let v: Vec(&str) = vec!["foo"];
 }
@@ -2427,7 +2561,7 @@ fn main() {
 You used an associated type which isn't defined in the trait.
 Erroneous code example:
 
-```
+```compile_fail
 trait Trait {
     type Bar;
 }
@@ -2452,7 +2586,7 @@ trait Trait {
 An attempt was made to retrieve an associated type, but the type was ambiguous.
 For example:
 
-```
+```compile_fail
 trait T1 {}
 trait T2 {}
 
@@ -2478,8 +2612,18 @@ fn do_something() {
 following syntax:
 
 ```
-fn do_something() {
-    let _: <Self as Bar>::A;
+trait T1 {}
+trait T2 {}
+
+trait Foo {
+    type A: T1;
+}
+
+trait Bar : Foo {
+    type A: T2;
+    fn do_something() {
+        let _: <Self as Bar>::A;
+    }
 }
 ```
 "##,
@@ -2488,7 +2632,7 @@ fn do_something() {
 An attempt was made to retrieve an associated type, but the type was ambiguous.
 For example:
 
-```
+```compile_fail
 trait MyTrait {type X; }
 
 fn main() {
@@ -2523,7 +2667,7 @@ fn main() {
 You attempted to use multiple types as bounds for a closure or trait object.
 Rust does not currently support this. A simple example that causes this error:
 
-```
+```compile_fail
 fn main() {
     let _: Box<std::io::Read+std::io::Write>;
 }
@@ -2543,7 +2687,9 @@ fn main() {
 E0232: r##"
 The attribute must have a value. Erroneous code example:
 
-```
+```compile_fail
+#![feature(on_unimplemented)]
+
 #[rustc_on_unimplemented] // error: this attribute must have a value
 trait Bar {}
 ```
@@ -2551,6 +2697,8 @@ trait Bar {}
 Please supply the missing value of the attribute. Example:
 
 ```
+#![feature(on_unimplemented)]
+
 #[rustc_on_unimplemented = "foo"] // ok!
 trait Bar {}
 ```
@@ -2563,7 +2711,7 @@ trait Bar {}
 For example, the `Foo` struct below is defined to be generic in `T`, but the
 type parameter is missing in the definition of `Bar`:
 
-```
+```compile_fail
 struct Foo<T> { x: T }
 
 struct Bar { x: Foo }
@@ -2577,7 +2725,7 @@ struct Bar { x: Foo }
 For example, the `Foo` struct below has no type parameters, but is supplied
 with two in the definition of `Bar`:
 
-```
+```compile_fail
 struct Foo { x: bool }
 
 struct Bar<S, T> { x: Foo<S, T> }
@@ -2588,7 +2736,7 @@ struct Bar<S, T> { x: Foo<S, T> }
 This error indicates an attempt to use a value where a type is expected. For
 example:
 
-```
+```compile_fail
 enum Foo {
     Bar(u32)
 }
@@ -2609,7 +2757,7 @@ fn do_something(x: Foo::Bar) { }
 
 Some examples of code that produces this error are:
 
-```
+```compile_fail
 const A: [u32; "hello"] = []; // error
 const B: [u32; true] = []; // error
 const C: [u32; 0.0] = []; // error
@@ -2621,7 +2769,7 @@ fn do_something(x: Foo::Bar) { }
 
 Some examples of this error are:
 
-```
+```compile_fail
 // divide by zero in the length expression
 const A: [u32; 1/0] = [];
 
@@ -2645,7 +2793,7 @@ fn foo() -> usize { 12 }
 A cross-crate opt-out trait was implemented on something which wasn't a struct
 or enum type. Erroneous code example:
 
-```
+```compile_fail
 #![feature(optin_builtin_traits)]
 
 struct Foo;
@@ -2674,7 +2822,9 @@ unsafe impl Send for &'static Foo {
 An associated const was implemented when another trait item was expected.
 Erroneous code example:
 
-```
+```compile_fail
+#![feature(associated_consts)]
+
 trait Foo {
     type N;
 }
@@ -2701,8 +2851,15 @@ trait Foo {
 impl Foo for Bar {
     type N = u32; // ok!
 }
+```
+
+Or:
+
+```
+#![feature(associated_consts)]
+
+struct Bar;
 
-// or:
 trait Foo {
     const N : u32;
 }
@@ -2717,7 +2874,7 @@ impl Foo for Bar {
 A method was implemented when another trait item was expected. Erroneous
 code example:
 
-```
+```compile_fail
 struct Bar;
 
 trait Foo {
@@ -2737,6 +2894,8 @@ fn N() {}
 verify that you are indeed implementing the correct trait items. Example:
 
 ```
+#![feature(associated_consts)]
+
 struct Bar;
 
 trait Foo {
@@ -2757,7 +2916,7 @@ fn M() {} // ok!
 An associated type was implemented when another trait item was expected.
 Erroneous code example:
 
-```
+```compile_fail
 struct Bar;
 
 trait Foo {
@@ -2784,8 +2943,15 @@ trait Foo {
 impl Foo for Bar {
     type N = u32; // ok!
 }
+```
+
+Or:
+
+```
+#![feature(associated_consts)]
+
+struct Bar;
 
-//or:
 trait Foo {
     const N : u32;
 }
@@ -2802,7 +2968,7 @@ impl Foo for Bar {
 
 Here's an example of this error:
 
-```
+```compile_fail
 trait Foo {
     const BAR: bool;
 }
@@ -2819,7 +2985,7 @@ impl Foo for Bar {
 You cannot use associated items other than constant items as patterns. This
 includes method items. Example of erroneous code:
 
-```
+```compile_fail
 enum B {}
 
 impl B {
@@ -2856,7 +3022,9 @@ fn main() {
 type parameter or `Self`. This is not supported yet. An example causing this
 error is shown below:
 
-```
+```compile_fail
+#![feature(associated_consts)]
+
 trait Foo {
     const BAR: f64;
 }
@@ -2872,10 +3040,18 @@ fn get_bar_bad<F: Foo>(t: F) -> f64 {
 }
 ```
 
-Currently, the value of `BAR` for a particular type can only be accessed through
-a concrete type, as shown below:
+Currently, the value of `BAR` for a particular type can only be accessed
+through a concrete type, as shown below:
+
+```ignore
+#![feature(associated_consts)]
+
+trait Foo {
+    const BAR: f64;
+}
+
+struct MyStruct;
 
-```
 fn get_bar_good() -> f64 {
     <MyStruct as Foo>::BAR
 }
@@ -2886,7 +3062,7 @@ fn get_bar_good() -> f64 {
 An attempt was made to implement `Drop` on a concrete specialization of a
 generic type. An example is shown below:
 
-```
+```compile_fail
 struct Foo<T> {
     t: T
 }
@@ -2919,7 +3095,7 @@ fn drop(&mut self) {}
 An attempt was made to implement `Drop` on a specialization of a generic type.
 An example is shown below:
 
-```
+```compile_fail
 trait Foo{}
 
 struct MyStruct<T> {
@@ -2957,9 +3133,9 @@ fn drop(&mut self) {}
 This error indicates that a binary assignment operator like `+=` or `^=` was
 applied to a type that doesn't support it. For example:
 
-```
+```compile_fail
 let mut x = 12f32; // error: binary operation `<<` cannot be applied to
-               //        type `f32`
+                   //        type `f32`
 
 x <<= 2;
 ```
@@ -2967,7 +3143,7 @@ fn drop(&mut self) {}
 To fix this error, please check that this type implements this binary
 operation. Example:
 
-```
+```compile_fail
 let x = 12u32; // the `u32` type does implement the `ShlAssign` trait
 
 x <<= 2; // ok!
@@ -2980,7 +3156,7 @@ fn drop(&mut self) {}
 operator for some type `Foo` by implementing the `std::ops::Add` trait for
 `Foo`, but you find that using `+=` does not work, as in this example:
 
-```
+```compile_fail
 use std::ops::Add;
 
 struct Foo(u32);
@@ -3007,7 +3183,7 @@ fn main() {
 A binary operation was attempted on a type which doesn't support it.
 Erroneous code example:
 
-```
+```compile_fail
 let x = 12f32; // error: binary operation `<<` cannot be applied to
                //        type `f32`
 
@@ -3032,12 +3208,12 @@ fn main() {
 The maximum value of an enum was reached, so it cannot be automatically
 set in the next enum value. Erroneous code example:
 
-```
+```compile_fail
 enum Foo {
     X = 0x7fffffffffffffff,
-    Y // error: enum discriminant overflowed on value after
-      //        9223372036854775807: i64; set explicitly via
-      //        Y = -9223372036854775808 if that is desired outcome
+    Y, // error: enum discriminant overflowed on value after
+       //        9223372036854775807: i64; set explicitly via
+       //        Y = -9223372036854775808 if that is desired outcome
 }
 ```
 
@@ -3049,8 +3225,11 @@ enum Foo {
     X = 0x7fffffffffffffff,
     Y = 0, // ok!
 }
+```
 
-// or:
+Or:
+
+```
 enum Foo {
     Y = 0, // ok!
     X = 0x7fffffffffffffff,
@@ -3066,7 +3245,7 @@ enum Foo {
 
 Example:
 
-```
+```compile_fail
 trait Foo { fn foo(&self) { } }
 trait Bar: Foo { }
 trait Baz: Bar { }
@@ -3094,7 +3273,7 @@ impl Baz for Bar { } // Note: This is OK
 E0390: r##"
 You tried to implement methods for a primitive type. Erroneous code example:
 
-```
+```compile_fail
 struct Foo {
     x: i32
 }
@@ -3128,7 +3307,7 @@ fn bar() {} // ok!
 
 The following example contains a circular dependency between two traits:
 
-```
+```compile_fail
 trait FirstTrait : SecondTrait {
 
 }
@@ -3141,9 +3320,9 @@ trait SecondTrait : FirstTrait {
 
 E0392: r##"
 This error indicates that a type or lifetime parameter has been declared
-but not actually used.  Here is an example that demonstrates the error:
+but not actually used. Here is an example that demonstrates the error:
 
-```
+```compile_fail
 enum Foo<T> {
     Bar
 }
@@ -3172,7 +3351,7 @@ enum Foo<T> {
 which the pointed-at data is valid. An initial attempt (below) causes this
 error:
 
-```
+```compile_fail
 struct Foo<'a, T> {
     x: *const T
 }
@@ -3203,7 +3382,9 @@ struct Foo<'a, T: 'a> {
 The length of the platform-intrinsic function `simd_shuffle`
 wasn't specified. Erroneous code example:
 
-```
+```compile_fail
+#![feature(platform_intrinsics)]
+
 extern "platform-intrinsic" {
     fn simd_shuffle<A,B>(a: A, b: A, c: [u32; 8]) -> B;
     // error: invalid `simd_shuffle`, needs length: `simd_shuffle`
@@ -3214,6 +3395,8 @@ struct Foo<'a, T: 'a> {
 last parameter in its name. Example:
 
 ```
+#![feature(platform_intrinsics)]
+
 extern "platform-intrinsic" {
     fn simd_shuffle8<A,B>(a: A, b: A, c: [u32; 8]) -> B;
 }
@@ -3224,7 +3407,10 @@ struct Foo<'a, T: 'a> {
 A platform-specific intrinsic function has the wrong number of type
 parameters. Erroneous code example:
 
-```
+```compile_fail
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct f64x2(f64, f64);
 
@@ -3239,6 +3425,9 @@ struct Foo<'a, T: 'a> {
 with yours. Example:
 
 ```
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct f64x2(f64, f64);
 
@@ -3252,7 +3441,10 @@ struct Foo<'a, T: 'a> {
 An unknown platform-specific intrinsic function was used. Erroneous
 code example:
 
-```
+```compile_fail
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
 
@@ -3267,6 +3459,9 @@ struct Foo<'a, T: 'a> {
 src/librustc_platform_intrinsics/x86.rs). Example:
 
 ```
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
 
@@ -3280,7 +3475,10 @@ struct Foo<'a, T: 'a> {
 Intrinsic argument(s) and/or return value have the wrong type.
 Erroneous code example:
 
-```
+```compile_fail
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
              i8, i8, i8, i8, i8, i8, i8, i8);
@@ -3299,6 +3497,9 @@ struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
 it the awaited types. Example:
 
 ```
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
 
@@ -3312,7 +3513,10 @@ struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
 Intrinsic argument(s) and/or return value have the wrong type.
 Erroneous code example:
 
-```
+```compile_fail
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
 #[repr(simd)]
@@ -3328,6 +3532,9 @@ struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
 it the awaited types. Example:
 
 ```
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
 
@@ -3341,7 +3548,10 @@ struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
 A platform-specific intrinsic function has wrong number of arguments.
 Erroneous code example:
 
-```
+```compile_fail
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct f64x2(f64, f64);
 
@@ -3355,6 +3565,9 @@ struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
 with yours. Example:
 
 ```
+#![feature(repr_simd)]
+#![feature(platform_intrinsics)]
+
 #[repr(simd)]
 struct f64x2(f64, f64);
 
@@ -3368,7 +3581,7 @@ struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,
 The `typeof` keyword is currently reserved but unimplemented.
 Erroneous code example:
 
-```
+```compile_fail
 fn main() {
     let x: typeof(92) = 92;
 }