Skip to content

Commit f24f128

Browse files
committed
Small editorial nits.
compile_fail is a dangerous thing to use since it doesn't validate which error is generated (it could be something like a typo).
1 parent 24d44b5 commit f24f128

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/trait-bounds.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ only valid if `T: 'a` holds.
169169

170170
Implied bounds are added for all parameters and outputs of functions. Inside of `requires_t_outlives_a`
171171
you can assume `T: 'a` to hold even if you don't explicitly specify this:
172+
172173
```rust
173174
fn requires_t_outlives_a_not_implied<'a, T: 'a>() {}
174175

@@ -179,7 +180,7 @@ fn requires_t_outlives_a<'a, T>(x: &'a T) {
179180
}
180181
```
181182

182-
```rust,compile_fail
183+
```rust,compile_fail,E0309
183184
# fn requires_t_outlives_a_not_implied<'a, T: 'a>() {}
184185
fn not_implied<'a, T>() {
185186
// This errors, because `T: 'a` is not implied by
@@ -190,14 +191,15 @@ fn not_implied<'a, T>() {
190191

191192
Only lifetime bounds are implied, trait bounds still have to be explicitly added.
192193
The following example therefore causes an error:
193-
```rust,compile_fail
194+
195+
```rust,compile_fail,E0277
194196
use std::fmt::Debug;
195197
struct IsDebug<T: Debug>(T);
196198
// error[E0277]: `T` doesn't implement `Debug`
197199
fn doesnt_specify_t_debug<T>(x: IsDebug<T>) {}
198200
```
199201

200-
Lifetime bounds are also inferred for type definitions and impl blocks for any type
202+
Lifetime bounds are also inferred for type definitions and impl blocks for any type:
201203

202204
```rust
203205
struct Struct<'a, T> {

0 commit comments

Comments
 (0)