diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-04-30 12:03:08 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-05-03 09:06:26 +1000 |
| commit | d7f5319b6db4cac89b7989ecfbb1f511a95826e6 (patch) | |
| tree | 6f13734d9b266749ffb8d242511fefeb1b8531ed | |
| parent | e809df6ed42f4c2c5cd37b8711f88f61c38332c8 (diff) | |
| download | rust-d7f5319b6db4cac89b7989ecfbb1f511a95826e6.tar.gz rust-d7f5319b6db4cac89b7989ecfbb1f511a95826e6.zip | |
Inline and remove three `DummyResult` methods.
They each have a single call site.
| -rw-r--r-- | compiler/rustc_expand/src/base.rs | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index ed4cb32d2db..12868a66605 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -571,35 +571,6 @@ impl DummyResult { tokens: None, }) } - - /// A plain dummy pattern. - pub fn raw_pat(sp: Span) -> ast::Pat { - ast::Pat { id: ast::DUMMY_NODE_ID, kind: PatKind::Wild, span: sp, tokens: None } - } - - /// A plain dummy type. - pub fn raw_ty(sp: Span) -> P<ast::Ty> { - // FIXME(nnethercote): you might expect `ast::TyKind::Dummy` to be used here, but some - // values produced here end up being lowered to HIR, which `ast::TyKind::Dummy` does not - // support, so we use an empty tuple instead. - P(ast::Ty { - id: ast::DUMMY_NODE_ID, - kind: ast::TyKind::Tup(ThinVec::new()), - span: sp, - tokens: None, - }) - } - - /// A plain dummy crate. - pub fn raw_crate() -> ast::Crate { - ast::Crate { - attrs: Default::default(), - items: Default::default(), - spans: Default::default(), - id: ast::DUMMY_NODE_ID, - is_placeholder: Default::default(), - } - } } impl MacResult for DummyResult { @@ -608,7 +579,12 @@ impl MacResult for DummyResult { } fn make_pat(self: Box<DummyResult>) -> Option<P<ast::Pat>> { - Some(P(DummyResult::raw_pat(self.span))) + Some(P(ast::Pat { + id: ast::DUMMY_NODE_ID, + kind: PatKind::Wild, + span: self.span, + tokens: None, + })) } fn make_items(self: Box<DummyResult>) -> Option<SmallVec<[P<ast::Item>; 1]>> { @@ -636,7 +612,15 @@ impl MacResult for DummyResult { } fn make_ty(self: Box<DummyResult>) -> Option<P<ast::Ty>> { - Some(DummyResult::raw_ty(self.span)) + // FIXME(nnethercote): you might expect `ast::TyKind::Dummy` to be used here, but some + // values produced here end up being lowered to HIR, which `ast::TyKind::Dummy` does not + // support, so we use an empty tuple instead. + Some(P(ast::Ty { + id: ast::DUMMY_NODE_ID, + kind: ast::TyKind::Tup(ThinVec::new()), + span: self.span, + tokens: None, + })) } fn make_arms(self: Box<DummyResult>) -> Option<SmallVec<[ast::Arm; 1]>> { @@ -668,7 +652,13 @@ impl MacResult for DummyResult { } fn make_crate(self: Box<DummyResult>) -> Option<ast::Crate> { - Some(DummyResult::raw_crate()) + Some(ast::Crate { + attrs: Default::default(), + items: Default::default(), + spans: Default::default(), + id: ast::DUMMY_NODE_ID, + is_placeholder: Default::default(), + }) } } |
