Skip to content

Unsatisfied precondition moving into a closure that is immediately called #1895

Closed
@brson

Description

@brson
fn main() {                                                                                                                                                    
    let x = 1;                                                                                                                                                 
    let y = fn@[move x]() -> int {                                                                                                                             
        x                                                                                                                                                      
    }();                                                                                                                                                       
}     
../src/test/run-pass/test.rs:6:14: 8:7 error: Unsatisfied precondition constraint (for example, init(x id=1 - arising from ../src/test/run-pass/test.rs:5:8: 5:13)) for expression:
fn@[move x]() -> int { x }()
Precondition:
init(x id=1 - arising from ../src/test/run-pass/test.rs:5:8: 5:13)
Prestate:
!init(y id=5 - arising from ../src/test/run-pass/test.rs:6:8: 8:7), !init(x id=1 - arising from ../src/test/run-pass/test.rs:5:8: 5:13), !init(main id=85 - arising from ../src/test/run-pass/test.rs:4:0: 1:0), !init(main! id=86 - arising from ../src/test/run-pass/test.rs:4:0: 1:0)
../src/test/run-pass/test.rs:6     let y = fn@[move x]() -> int {
../src/test/run-pass/test.rs:7         x
../src/test/run-pass/test.rs:8     }();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions