Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upimplement the `?` operator #31954
Conversation
rust-highfive
assigned
arielb1
Feb 28, 2016
This comment has been minimized.
This comment has been minimized.
|
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
japaric
referenced this pull request
Feb 28, 2016
Open
Tracking issue for `?` operator and `try` blocks (RFC 243, `question_mark` & `try_blocks` features) #31436
oli-obk
reviewed
Feb 29, 2016
| expr_call(lctx, e.span, err_ctor, hir_vec![from_expr], None) | ||
| }; | ||
| let err_pat = pat_err(lctx, e.span, pat_ident(lctx, e.span, err_ident)); | ||
| let ret_expr = expr(lctx, e.span, hir::Expr_::ExprRet(Some(err_expr)), None); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Needs a feature gate, right? |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
It might be useful to have tests of what happens when the try expansion fails to resolve. Is it nice? Hideous? |
This comment has been minimized.
This comment has been minimized.
|
Here's the |
This comment has been minimized.
This comment has been minimized.
|
The RFC claims this feature flag should be |
This comment has been minimized.
This comment has been minimized.
I don't have a build at hand, but the error message should be similar to the one for unresolved #![feature(no_core)]
#![no_core]
fn main() {
for x in xs {}
}
@seanmonstar will push a commit renaming the feature gate in a bit. |
This comment has been minimized.
This comment has been minimized.
|
(stealing review) |
rust-highfive
assigned
nikomatsakis
and unassigned
arielb1
Mar 4, 2016
This comment has been minimized.
This comment has been minimized.
|
So first review done, comments:
(I'll take another look afterwards.) |
This comment has been minimized.
This comment has been minimized.
Done. The impl looks simpler now. :-)
You mean like checking that
I've added a test for this. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
Will rebase after @nikomatsakis takes a second look :-). |
This comment has been minimized.
This comment has been minimized.
|
The changes look great. r=me, feel free to rebase. :)
No, I meant some kind of test that |
japaric
force-pushed the
japaric:rfc243
branch
from
d6a9621
to
210dd61
Mar 7, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors: r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
added a commit
that referenced
this pull request
Mar 7, 2016
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@japaric some error messages need correcting: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/8286/steps/test/logs/stdio |
This comment has been minimized.
This comment has been minimized.
|
@bors: r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
japaric commentedFeb 28, 2016
The
?postfix operator is sugar equivalent to the try! macro, but is more amenable to chaining:File::open("foo")?.metadata()?.is_dir().?is accepted on any expression that can return aResult, e.g.x()?,y!()?,{z}?,(w)?, etc. And binds more tightly than unary operators, e.g.!x?is parsed as!(x?).cc #31436
cc @aturon @eddyb