File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ //! Test that `super let` bindings in `if` expressions' blocks have the same scope as the result
2
+ //! of the block.
3
+ #![ feature( super_let) ]
4
+
5
+ fn main ( ) {
6
+ // For `super let` in an extending `if`, the binding `temp` should live in the scope of the
7
+ // outer `let` statement.
8
+ let x = if true {
9
+ super let temp = ( ) ;
10
+ & temp
11
+ } else {
12
+ super let temp = ( ) ;
13
+ & temp
14
+ } ;
15
+ x;
16
+
17
+ // For `super let` in non-extending `if`, the binding `temp` should live in the temporary scope
18
+ // the `if` expression is in.
19
+ // TODO: make this not an error
20
+ std:: convert:: identity ( if true {
21
+ super let temp = ( ) ;
22
+ & temp
23
+ //~^ ERROR `temp` does not live long enough
24
+ } else {
25
+ super let temp = ( ) ;
26
+ & temp
27
+ //~^ ERROR `temp` does not live long enough
28
+ } ) ;
29
+ }
Original file line number Diff line number Diff line change
1
+ error[E0597]: `temp` does not live long enough
2
+ --> $DIR/super-let-in-if-block.rs:22:9
3
+ |
4
+ LL | std::convert::identity(if true {
5
+ | ---------------------- borrow later used by call
6
+ LL | super let temp = ();
7
+ | ---- binding `temp` declared here
8
+ LL | &temp
9
+ | ^^^^^ borrowed value does not live long enough
10
+ LL |
11
+ LL | } else {
12
+ | - `temp` dropped here while still borrowed
13
+
14
+ error[E0597]: `temp` does not live long enough
15
+ --> $DIR/super-let-in-if-block.rs:26:9
16
+ |
17
+ LL | std::convert::identity(if true {
18
+ | ---------------------- borrow later used by call
19
+ ...
20
+ LL | super let temp = ();
21
+ | ---- binding `temp` declared here
22
+ LL | &temp
23
+ | ^^^^^ borrowed value does not live long enough
24
+ LL |
25
+ LL | });
26
+ | - `temp` dropped here while still borrowed
27
+
28
+ error: aborting due to 2 previous errors
29
+
30
+ For more information about this error, try `rustc --explain E0597`.
You can’t perform that action at this time.
0 commit comments