Skip to content

Commit 3dc7546

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 769db2a commit 3dc7546

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
@@ -1054,14 +1054,6 @@ pub(crate) struct NameReservedInAttributeNamespace {
10541054
pub(crate) ident: Ident,
10551055
}
10561056

1057-
#[derive(Diagnostic)]
1058-
#[diag(resolve_builtin_macro_with_non_invocation_rules)]
1059-
pub(crate) struct BuiltinMacroWithNonInvocationRules {
1060-
#[primary_span]
1061-
pub(crate) span: Span,
1062-
pub(crate) ident: Ident,
1063-
}
1064-
10651057
#[derive(Diagnostic)]
10661058
#[diag(resolve_cannot_find_builtin_macro_with_name)]
10671059
pub(crate) struct CannotFindBuiltinMacroWithName {

compiler/rustc_resolve/src/macros.rs

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

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

0 commit comments

Comments
 (0)