Skip to content

Commit e99e226

Browse files
committed
Switch dummy_bang from LegacyBang to Bang
1 parent 1d23da6 commit e99e226

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

compiler/rustc_expand/src/base.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,16 @@ pub trait BangProcMacro {
324324

325325
impl<F> BangProcMacro for F
326326
where
327-
F: Fn(TokenStream) -> TokenStream,
327+
F: Fn(&mut ExtCtxt<'_>, Span, TokenStream) -> Result<TokenStream, ErrorGuaranteed>,
328328
{
329329
fn expand<'cx>(
330330
&self,
331-
_ecx: &'cx mut ExtCtxt<'_>,
332-
_span: Span,
331+
ecx: &'cx mut ExtCtxt<'_>,
332+
span: Span,
333333
ts: TokenStream,
334334
) -> Result<TokenStream, ErrorGuaranteed> {
335335
// FIXME setup implicit context in TLS before calling self.
336-
Ok(self(ts))
336+
self(ecx, span, ts)
337337
}
338338
}
339339

@@ -999,17 +999,14 @@ impl SyntaxExtension {
999999

10001000
/// A dummy bang macro `foo!()`.
10011001
pub fn dummy_bang(edition: Edition) -> SyntaxExtension {
1002-
fn expander<'cx>(
1003-
cx: &'cx mut ExtCtxt<'_>,
1002+
fn expand(
1003+
ecx: &mut ExtCtxt<'_>,
10041004
span: Span,
1005-
_: TokenStream,
1006-
) -> MacroExpanderResult<'cx> {
1007-
ExpandResult::Ready(DummyResult::any(
1008-
span,
1009-
cx.dcx().span_delayed_bug(span, "expanded a dummy bang macro"),
1010-
))
1005+
_ts: TokenStream,
1006+
) -> Result<TokenStream, ErrorGuaranteed> {
1007+
Err(ecx.dcx().span_delayed_bug(span, "expanded a dummy bang macro"))
10111008
}
1012-
SyntaxExtension::default(SyntaxExtensionKind::LegacyBang(Arc::new(expander)), edition)
1009+
SyntaxExtension::default(SyntaxExtensionKind::Bang(Arc::new(expand)), edition)
10131010
}
10141011

10151012
/// A dummy derive macro `#[derive(Foo)]`.

compiler/rustc_expand/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
971971
});
972972
}
973973
},
974-
SyntaxExtensionKind::LegacyBang(..) => {
974+
SyntaxExtensionKind::Bang(..) => {
975975
let msg = "expanded a dummy glob delegation";
976976
let guar = self.cx.dcx().span_delayed_bug(span, msg);
977977
return ExpandResult::Ready(fragment_kind.dummy(span, guar));

0 commit comments

Comments
 (0)