Added compiler flags to example code, removed unexpected curly

This commit is contained in:
Josh White 2020-02-08 06:18:42 -05:00
parent 409146673c
commit 58d0e67f50

View File

@ -2,7 +2,7 @@ An underscore `_` character has been used as the identifier for a lifetime,
or a const generic has been borrowed without an explicit lifetime.
Erroneous example with an underscore:
```
```compile_fail,E0106,E0637
fn foo<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {}
// ^^ `'_` is a reserved lifetime name
```
@ -19,7 +19,7 @@ fn <'a>(str1: &'a str, str2: &'a str) -> &'a str {}
```
Erroneous example with const generic:
```
```compile_fail,E0637
struct A<const N: &u8>;
//~^ ERROR `&` without an explicit lifetime name cannot be used here
trait B {}
@ -35,7 +35,6 @@ impl<const N: &u8> B for A<N> {}
fn bar<const N: &u8>() {}
//~^ ERROR `&` without an explicit lifetime name cannot be used here
}
```
Const generics cannot be borrowed without specifying a lifetime.The
@ -56,6 +55,5 @@ impl<const N: &'a u8> A<N> {
impl<const N: &'a u8> B for A<N> {}
fn bar<const N: &'a u8>() {}
}
```
[bk-no]: https://doc.rust-lang.org/book/appendix-02-operators.html#non-operator-symbols