Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brson opened this issue Feb 23, 2012 · 2 comments
Closed

Comments

@brson
Copy link
Contributor

brson commented Feb 23, 2012

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     }();
@ghost ghost assigned catamorphism Feb 23, 2012
@catamorphism
Copy link
Contributor

I started working on this, but I'm confused about the semantics of capture clauses (and the documentation doesn't seem to mention capture clauses at all). If you have a [move x] clause in a fn, does that mean x gets moved when you create the closure? Or when you invoke the closure?

@graydon
Copy link
Contributor

graydon commented Feb 28, 2012

When you create the closure.

flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 10, 2023
…cs, r=dswij

Scope `missing_docs_in_private_items` to only private items

`missing_docs_in_private_items` currently detects missing docs for public items as well as private. Since `missing_docs`already covers public items, this PR updates `missing_docs_in_private_items` to only cover private items.

Fixes rust-lang#1895

changelog: [`missing_docs_in_private_items`]: Apply lint only to private items (used to be public and private)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants