@@ -169,6 +169,7 @@ only valid if `T: 'a` holds.
169
169
170
170
Implied bounds are added for all parameters and outputs of functions. Inside of ` requires_t_outlives_a `
171
171
you can assume ` T: 'a ` to hold even if you don't explicitly specify this:
172
+
172
173
``` rust
173
174
fn requires_t_outlives_a_not_implied <'a , T : 'a >() {}
174
175
@@ -179,7 +180,7 @@ fn requires_t_outlives_a<'a, T>(x: &'a T) {
179
180
}
180
181
```
181
182
182
- ``` rust,compile_fail
183
+ ``` rust,compile_fail,E0309
183
184
# fn requires_t_outlives_a_not_implied<'a, T: 'a>() {}
184
185
fn not_implied<'a, T>() {
185
186
// This errors, because `T: 'a` is not implied by
@@ -190,14 +191,15 @@ fn not_implied<'a, T>() {
190
191
191
192
Only lifetime bounds are implied, trait bounds still have to be explicitly added.
192
193
The following example therefore causes an error:
193
- ``` rust,compile_fail
194
+
195
+ ``` rust,compile_fail,E0277
194
196
use std::fmt::Debug;
195
197
struct IsDebug<T: Debug>(T);
196
198
// error[E0277]: `T` doesn't implement `Debug`
197
199
fn doesnt_specify_t_debug<T>(x: IsDebug<T>) {}
198
200
```
199
201
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:
201
203
202
204
``` rust
203
205
struct Struct <'a , T > {
0 commit comments