aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2023-02-16 13:53:22 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2023-02-20 12:52:12 +0000
commit57b64a64261ed1d1774af61a1e36eeac604abcde (patch)
tree86370b4355678e9d50aa4941a5d0d9f443d8f5c5 /gcc/rust/backend
parent773d3c6477d7075ceeb01e4c910be24361ff6dcf (diff)
downloadgcc-57b64a64261ed1d1774af61a1e36eeac604abcde.zip
gcc-57b64a64261ed1d1774af61a1e36eeac604abcde.tar.gz
gcc-57b64a64261ed1d1774af61a1e36eeac604abcde.tar.bz2
parser: Allow parsing of qualified type path as nested generic argument
Let's take the example of lexing `Option<<T as Iterator>::Item>` and look at the first few tokens. Originally, `Option<<T` was lexed as 3 tokens: * IDENTIFIER(Option) * LEFT_SHIFT * IDENTIFIER(T) The parser did not allow a list of generic arguments to start with a left shift, and rejected the above type. We are now splitting the left shift into two left angles, as this allows complex generic arguments and overall makes sense parsing wise. Thus, the above list becomes: * IDENTIFIER(Option) * LEFT_ANGLE * LEFT_ANGLE * IDENTIFIER(T) and `<T as Iterator>` is properly parsed as a qualified path. Fixes #1815 Fixed #1809 Addresses #1524 gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_path_generic_args): Split leading `LEFT_SHIFT` token into two `LEFT_ANGLE` tokens when parsing generic arguments. (Parser::parse_type_path_segment): Allow `LEFT_ANGLE` as starting token for parsing generic arguments. gcc/testsuite/ChangeLog: * rust/compile/parse_associated_type_as_generic_arg.rs: New test. * rust/compile/parse_associated_type_as_generic_arg2.rs: New test. * rust/compile/path_as_generic_arg.rs: New test. * rust/compile/nested_generic.rs: New test.
Diffstat (limited to 'gcc/rust/backend')
0 files changed, 0 insertions, 0 deletions