Uh oh!
There was an error while loading. Please reload this page.
Implement ? in catch expressions - #40229
Conversation
bors
commented
Mar 3, 2017
☔ The latest upstream changes (presumably #40133) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
commented
Mar 7, 2017
at first read, this all looks good, I'll have to revisit it in more detail when it's rebased |
nikomatsakis
commented
Mar 7, 2017
Ah, a thought. It'd be good to have some tests targeting the CFG etc. The idea would be to have initializations and moves that occur during a let x;let _v = do catch{
x = 5;Ok(());};println!("{}", x);// OKlet x;let _v = do catch{
x = Ok(5)?;Ok(());};println!("{}", x);// ERRORand similar tests for moves that may or may not occur (and perhaps a few for borrows that start in the catch and extend outside, etc). |
bors
commented
Mar 12, 2017
☔ The latest upstream changes (presumably #40220) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
can you add a comment on this test explaining what the test aims to demonstrate (e.g., that a borrowed valid inside the do catch will propagate out?
I also think it'd be good to possibly break this test into distinct files.
There was a problem hiding this comment.
can you modify the test to demonstrate that cfg_resis usable *within the do catch, if not outside?
Also, add a (run-pass) test like so, where cfg_res is initialized before the ?:
pubfnmain(){let cfg_res;let _:Result<(),()> = do catch{
cfg_res = 5;Err(())?;Ok(())};use(cfg_res);// OK}There was a problem hiding this comment.
I think I would also like some tests around lifetimes like these:
// Test that a borrow which only conditionally occurs still freezes `i` fnmain(){letmut i = 222;let j;let x = do catch{Err(())?;Ok(&i)};
i = 0;// ERRORprintln!("{}", i);}// Test that a borrow which only conditionally occurs still freezes `i` fnmain(){letmut i = 222;let j;let x = do catch{Err(())?;
j = &i;Ok(())};
i = 0;// ERROR, I ... guess ... maybe not with NLLprintln!("{}", i);}nikomatsakis
commented
Mar 15, 2017
@bors r+ |
bors
commented
Mar 15, 2017
📌 Commit bc07fe6 has been approved by |
bors
commented
Mar 17, 2017
☔ The latest upstream changes (presumably #40598) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
commented
Mar 20, 2017
@bors r+ |
bors
commented
Mar 20, 2017
📌 Commit 1f43731 has been approved by |
…sakis Implement `?` in catch expressions Builds on rust-lang#39921. Final part of rust-lang#39849. r? @nikomatsakis
Builds on #39921. Final part of #39849.
r? @nikomatsakis