Fix markdown formatting error of E0277, E0284, E0310, E0502.

This commit is contained in:
kennytm 2016-06-12 16:09:07 +08:00
parent 4c45d26a82
commit ae75593864
No known key found for this signature in database
GPG Key ID: FEF6C8051D0E013C
2 changed files with 7 additions and 2 deletions
src
librustc
librustc_borrowck

@ -1112,6 +1112,7 @@ fn main() {
```
Or in a generic context, an erroneous code example would look like:
```compile_fail
fn some_func<T>(foo: T) {
println!("{:?}", foo); // error: the trait `core::fmt::Debug` is not
@ -1130,6 +1131,7 @@ we only call it with a parameter that does implement `Debug`, the compiler
still rejects the function: It must work with all possible input types. In
order to make this example compile, we need to restrict the generic type we're
accepting:
```
use std::fmt;
@ -1146,11 +1148,10 @@ fn main() {
// struct WithoutDebug;
// some_func(WithoutDebug);
}
```
Rust only looks at the signature of the called function, as such it must
already specify all requirements that will be used for every type parameter.
```
"##,
E0281: r##"
@ -1381,6 +1382,7 @@ denotes this will cause this error.
struct Foo<T> {
foo: &'static T
}
```
This will compile, because it has the constraint on the type parameter:

@ -516,8 +516,10 @@ fn foo(a: &mut i32) {
// as immutable
}
```
To fix this error, ensure that you don't have any other references to the
variable before trying to access it mutably:
```
fn bar(x: &mut i32) {}
fn foo(a: &mut i32) {
@ -525,6 +527,7 @@ fn foo(a: &mut i32) {
let ref y = a; // ok!
}
```
For more information on the rust ownership system, take a look at
https://doc.rust-lang.org/stable/book/references-and-borrowing.html.
"##,