aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-ast-resolve-expr.h
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-07-25 21:38:24 +0000
committerGitHub <noreply@github.com>2021-07-25 21:38:24 +0000
commita4e3ffd3768b4a985aa7a137c9a553a4588acaba (patch)
tree2f97968a556041560f023ed7e5443f92e29f72df /gcc/rust/resolve/rust-ast-resolve-expr.h
parent4447dba7c8a9126a9701ddc8ae02cc1425e1fa77 (diff)
parentf2ce41608ae0f55e6910756054cddf08aa3678ff (diff)
downloadgcc-a4e3ffd3768b4a985aa7a137c9a553a4588acaba.zip
gcc-a4e3ffd3768b4a985aa7a137c9a553a4588acaba.tar.gz
gcc-a4e3ffd3768b4a985aa7a137c9a553a4588acaba.tar.bz2
Merge #593
593: Support RangeFrom ([x..]) and RangeFromTo ([x..y]) in the parser r=philberty a=dkm Parsing the .. (DOT_DOT) operator to get a range had two issues. Trying to compile: let block = [1,2,3,4,5]; let _rf = &block[1..]; let _rt = &block[..3]; let _rft = &block[2..4]; range.rs:4:23: error: found unexpected token ‘]’ in null denotation 4 | let _rf = &block[1..]; | ^ range.rs:4:24: error: expecting ‘]’ but ‘;’ found 4 | let _rf = &block[1..]; | ^ Since .. can represent either a range from or a range from-to it can be followed by an expression or not. We do have a hack in our pratt-parser so that it is allowed to return a nullptr. But even in that case it will have swallowed the next token. Add another hack to the pratt-parser so that if the next token is one that cannot start an expression and the caller allows a nullptr return then don't skip the token and return immediately. After this patch we can parse the above range expressions, but we still don't handle them fully: range.rs:4:20: fatal error: Failed to lower expr: [1..] 4 | let _rf = &block[1..]; | ^ Ranges are actually syntactic sugar for std::ops::Range[From|To]. Co-authored-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve-expr.h')
0 files changed, 0 insertions, 0 deletions