Skip to content

Commit 20909d7

Browse files
committed
mbe: Silently ignore the body of a macro with rustc_builtin_macro
Don't bother detecting and reporting an error on a builtin macro with `attr` rules; just ignore them.
1 parent a556370 commit 20909d7

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed

compiler/rustc_resolve/messages.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ resolve_binding_shadows_something_unacceptable =
5353
resolve_binding_shadows_something_unacceptable_suggestion =
5454
try specify the pattern arguments
5555
56-
resolve_builtin_macro_with_non_invocation_rules =
57-
built-in macro `{$ident}` has non-invocation rules
58-
5956
resolve_cannot_be_reexported_crate_public =
6057
`{$ident}` is only public within the crate, and cannot be re-exported outside
6158

compiler/rustc_resolve/src/errors.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,14 +1057,6 @@ pub(crate) struct NameReservedInAttributeNamespace {
10571057
pub(crate) ident: Ident,
10581058
}
10591059

1060-
#[derive(Diagnostic)]
1061-
#[diag(resolve_builtin_macro_with_non_invocation_rules)]
1062-
pub(crate) struct BuiltinMacroWithNonInvocationRules {
1063-
#[primary_span]
1064-
pub(crate) span: Span,
1065-
pub(crate) ident: Ident,
1066-
}
1067-
10681060
#[derive(Diagnostic)]
10691061
#[diag(resolve_cannot_find_builtin_macro_with_name)]
10701062
pub(crate) struct CannotFindBuiltinMacroWithName {

compiler/rustc_resolve/src/macros.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11711171
node_id: NodeId,
11721172
edition: Edition,
11731173
) -> MacroData {
1174-
let (mut ext, attr_ext, mut nrules) = compile_declarative_macro(
1174+
let (mut ext, mut attr_ext, mut nrules) = compile_declarative_macro(
11751175
self.tcx.sess,
11761176
self.tcx.features(),
11771177
macro_def,
@@ -1183,14 +1183,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11831183
);
11841184

11851185
if let Some(builtin_name) = ext.builtin_name {
1186-
if attr_ext.is_some() {
1187-
self.dcx().emit_err(errors::BuiltinMacroWithNonInvocationRules { span, ident });
1188-
}
11891186
// The macro was marked with `#[rustc_builtin_macro]`.
11901187
if let Some(builtin_ext_kind) = self.builtin_macros.get(&builtin_name) {
11911188
// The macro is a built-in, replace its expander function
11921189
// while still taking everything else from the source code.
11931190
ext.kind = builtin_ext_kind.clone();
1191+
attr_ext = None;
11941192
nrules = 0;
11951193
} else {
11961194
self.dcx().emit_err(errors::CannotFindBuiltinMacroWithName { span, ident });

0 commit comments

Comments
 (0)