]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/expprint.c
Add inclusive range support for Rust
authorTom Tromey <tom@tromey.com>
Thu, 29 Mar 2018 20:14:07 +0000 (14:14 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 27 Apr 2018 19:20:13 +0000 (13:20 -0600)
commit6873858b7e464e114f9a877e216949ad8350b4cf
tree8812199c58f09c14b00dc50805d9b066f02d28bd
parent632e107b32c0fe8aede62e070b00756e9fdd2c01
Add inclusive range support for Rust

This is version 2 of the patch to add inclusive range support for
Rust.  I believe it addresses all review comments.

Rust recently stabilized the inclusive range feature:

    https://github.com/rust-lang/rust/issues/28237

An inclusive range is an expression like "..= EXPR" or "EXPR ..=
EXPR".  It is like an ordinary range, except the upper bound is
inclusive, not exclusive.

This patch adds support for this feature to gdb.

Regression tested on x86-64 Fedora 27.

2018-04-27  Tom Tromey  <tom@tromey.com>

PR rust/22545:
* rust-lang.c (rust_inclusive_range_type_p): New function.
(rust_range): Handle inclusive ranges.
(rust_compute_range): Likewise.
* rust-exp.y (struct rust_op) <inclusive>: New field.
(DOTDOTEQ): New constant.
(range_expr): Add "..=" productions.
(operator_tokens): Add "..=" token.
(ast_range): Add "inclusive" parameter.
(convert_ast_to_expression) <case OP_RANGE>: Handle inclusive
ranges.
* parse.c (operator_length_standard) <case OP_RANGE>: Handle new
bounds values.
* expression.h (enum range_type) <NONE_BOUND_DEFAULT_EXCLUSIVE,
LOW_BOUND_DEFAULT_EXCLUSIVE>: New constants.
Update comments.
* expprint.c (print_subexp_standard): Handle new bounds values.
(dump_subexp_body_standard): Likewise.

2018-04-27  Tom Tromey  <tom@tromey.com>

PR rust/22545:
* gdb.rust/simple.exp: Add inclusive range tests.
gdb/ChangeLog
gdb/expprint.c
gdb/expression.h
gdb/parse.c
gdb/rust-exp.y
gdb/rust-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.rust/simple.exp