]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #69366 - Centril:unified-items, r=petrochenkov
authorbors <bors@rust-lang.org>
Mon, 24 Feb 2020 00:31:01 +0000 (00:31 +0000)
committerbors <bors@rust-lang.org>
Mon, 24 Feb 2020 00:31:01 +0000 (00:31 +0000)
parse: unify item parsing & filter illegal item kinds

This PR fully unifies item parsing into a single `fn parse_item_common` method which produces `Option<Item>`. The `Item` is then mapped into `ForeignItem` and `AssocItem` as necessary by transforming the `*Kind` and converting contextually bad variants into `None`, thereby filtering them away.

The PR does not yet unmerge the definition of `ForeignItemKind` from `AssocItemKind`. I've left that as future work as it didn't feel like this parser-focused PR would be the best one to deal with it. Changes to the AST data structures are instead kept to a reasonable minimum.

Based on https://github.com/rust-lang/rust/pull/69361.

Fixes https://github.com/rust-lang/rust/issues/48137.
RELNOTES: Now, `item` macro fragments can be interpolated into `impl`, `trait`, and `extern` contexts. See `src/test/ui/parser/issue-48137-macros-cannot-interpolate-impl-items.rs` for the relevant test.

r? @petrochenkov
cc @estebank


Trivial merge