Commit 5b76e77
committed
Report a specialized error when a
```text
error: lifetime may not live long enough
--> $DIR/static-impl-obligation.rs:8:27
|
LL | fn bar<'a>(x: &'a &'a u32) {
| -- lifetime `'a` defined here
LL | let y: &dyn Foo = x;
| ^ cast requires that `'a` must outlive `'static`
LL | y.hello();
| --------- calling this method introduces a `'static` lifetime requirement
|
help: relax the implicit `'static` bound on the impl
|
LL | impl dyn Foo + '_ {
| ++++
```
```text
error: lifetime may not live long enough
--> $DIR/static-impl-obligation.rs:173:27
|
LL | fn bar<'a>(x: &'a &'a u32) {
| -- lifetime `'a` defined here
LL | let y: &dyn Foo = x;
| ^ cast requires that `'a` must outlive `'static`
LL | y.hello();
| --------- calling this method introduces a `'static` lifetime requirement
|
note: the `impl` on `(dyn p::Foo + 'static)` has `'static` lifetime requirements
--> $DIR/static-impl-obligation.rs:169:20
|
LL | impl dyn Foo + 'static where Self: 'static {
| ^^^^^^^ ^^^^^^^
LL | fn hello(&self) where Self: 'static {}
| ^^^^^^^
```'static obligation comes from an impl dyn Trait
1 parent 8a49772 commit 5b76e77
File tree
18 files changed
+834
-73
lines changed- compiler
- rustc_borrowck
- src
- diagnostics
- region_infer
- type_check
- rustc_hir_analysis/src
- rustc_infer/src/infer/canonical
- rustc_middle/src/traits
- rustc_trait_selection/src/traits
- error_reporting
- tests/ui
- inference
- lifetimes
- regions
- suggestions
18 files changed
+834
-73
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
Lines changed: 262 additions & 44 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2051 | 2051 | | |
2052 | 2052 | | |
2053 | 2053 | | |
| 2054 | + | |
| 2055 | + | |
2054 | 2056 | | |
2055 | 2057 | | |
2056 | 2058 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
| 186 | + | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| |||
Lines changed: 10 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
| 326 | + | |
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
365 | 369 | | |
366 | 370 | | |
367 | 371 | | |
368 | | - | |
| 372 | + | |
369 | 373 | | |
370 | 374 | | |
371 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
1017 | | - | |
| 1017 | + | |
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
| |||
2766 | 2766 | | |
2767 | 2767 | | |
2768 | 2768 | | |
2769 | | - | |
| 2769 | + | |
2770 | 2770 | | |
2771 | 2771 | | |
2772 | 2772 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1630 | 1630 | | |
1631 | 1631 | | |
1632 | 1632 | | |
1633 | | - | |
| 1633 | + | |
1634 | 1634 | | |
1635 | 1635 | | |
1636 | 1636 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
408 | | - | |
| 408 | + | |
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
454 | 457 | | |
455 | 458 | | |
456 | 459 | | |
| |||
0 commit comments