File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11error[E0308]: mismatched types
2- --> $DIR/issue-78262.rs:8 :28
2+ --> $DIR/issue-78262.rs:12 :28
33 |
44LL | let f = |x: &dyn TT| x.func();
55 | ^^^^ lifetime mismatch
66 |
77 = note: expected reference `&(dyn TT + 'static)`
88 found reference `&dyn TT`
9- note: the anonymous lifetime #1 defined on the body at 8 :13...
10- --> $DIR/issue-78262.rs:8 :13
9+ note: the anonymous lifetime #1 defined on the body at 12 :13...
10+ --> $DIR/issue-78262.rs:12 :13
1111 |
1212LL | let f = |x: &dyn TT| x.func();
1313 | ^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change 1+ error[E0521]: borrowed data escapes outside of closure
2+ --> $DIR/issue-78262.rs:12:26
3+ |
4+ LL | let f = |x: &dyn TT| x.func();
5+ | - ^^^^^^^^ `x` escapes the closure body here
6+ | |
7+ | `x` is a reference that is only valid in the closure body
8+
9+ error: aborting due to previous error
10+
Original file line number Diff line number Diff line change 1+ // revisions: nll default
2+ // ignore-compare-mode-nll
3+ //[nll]compile-flags: -Z borrowck=mir
4+
15trait TT { }
26
37impl dyn TT {
48 fn func ( & self ) { }
59}
610
711fn main ( ) {
8- let f = |x : & dyn TT | x. func ( ) ; //~ ERROR: mismatched types
12+ let f = |x : & dyn TT | x. func ( ) ; //[default]~ ERROR: mismatched types
13+ //[nll]~^ ERROR: borrowed data escapes outside of closure
914}
You can’t perform that action at this time.
0 commit comments