Make many MacResult methods unreachable.#142061
Conversation
- Every method in the `MacResult` trait can be unreachable *except* `make_stmts`. - Lots of `MacEager` methods can removed, so they fall back to the default unreachable methods. Because of this, the `impl_items`/`trait_items`/`foreign_items` fields are never used and can also be removed.
|
@petrochenkov: see what you think of this. I don't fully understand the details of the affected code. I was trying to work out how some of these methods are called, and so I inserted a bunch of |
| trait_items: SmallVec<[P<ast::AssocItem>; 1]>, | ||
| foreign_items: SmallVec<[P<ast::ForeignItem>; 1]>, | ||
| stmts: SmallVec<[ast::Stmt; 1]>, | ||
| ty: P<ast::Ty>, |
There was a problem hiding this comment.
MacEager can certainly be trimmed further, only MacEager::{expr, items, ty} are actually used in built-in macros, the other fields are never set to anything other than None and their uses can be replaced with None.
|
|
||
| fn make_variants(self: Box<DummyResult>) -> Option<SmallVec<[ast::Variant; 1]>> { | ||
| Some(SmallVec::new()) | ||
| } |
There was a problem hiding this comment.
We need
- a test using
#[rustfmt::skip]in all possible attribute positions, - a test using
log_syntax!()in all possible fn-like macro positions, - and a test using
include!()orconcat_idents!()in all possible fn-like macro positions.
If all of those do not crash, then we can keep the unreachable!s.
|
@petrochenkov: I don't have the time or mental bandwidth to make further progress with this. Please take it over if you want. |
Every method in the
MacResulttrait can be unreachable exceptmake_stmts.Lots of
MacEagermethods can removed, so they fall back to the default unreachable methods. Because of this, theimpl_items/trait_items/foreign_itemsfields are never used and can also be removed.r? @petrochenkov