Skip to content

Commit 5c64916

Browse files
m-ou-sejdonszelmann
authored andcommitted
Allow builtin macros to be used more than once.
This removes E0773 "A builtin-macro was defined more than once."
1 parent 2b305b8 commit 5c64916

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use super::{
2323
AstOwner, FnDeclKind, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
2424
ResolverAstLoweringExt,
2525
};
26-
use crate::GenericArgsMode;
2726

2827
pub(super) struct ItemLowerer<'a, 'hir> {
2928
pub(super) tcx: TyCtxt<'hir>,

compiler/rustc_error_codes/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ E0769: 0769,
515515
E0770: 0770,
516516
E0771: 0771,
517517
E0772: 0772,
518-
E0773: 0773,
519518
E0774: 0774,
520519
E0775: 0775,
521520
E0776: 0776,

compiler/rustc_hir_analysis/src/check/compare_eii.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ use rustc_hir::def_id::{DefId, LocalDefId};
77
use rustc_hir::{self as hir, FnSig, HirId, ItemKind};
88
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
99
use rustc_infer::traits::{ObligationCause, ObligationCauseCode};
10-
use rustc_middle::ty;
10+
use rustc_middle::ty::{self, TypingMode};
1111
use rustc_middle::ty::TyCtxt;
1212
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1313
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol};
1414
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1515
use rustc_trait_selection::regions::InferCtxtRegionExt;
1616
use rustc_trait_selection::traits::ObligationCtxt;
17-
use rustc_type_ir::TypingMode;
1817
use tracing::{debug, instrument};
1918

2019
use super::potentially_plural_count;
@@ -147,7 +146,7 @@ fn compare_number_of_method_arguments<'tcx>(
147146
})
148147
.or_else(|| tcx.hir().span_if_local(declaration));
149148

150-
let (external_impl_sig, _, _) = &tcx.hir().expect_item(external_impl).expect_fn();
149+
let (_, external_impl_sig, _, _) = &tcx.hir_expect_item(external_impl).expect_fn();
151150
let pos = external_impl_number_args.saturating_sub(1);
152151
let impl_span = external_impl_sig
153152
.decl
@@ -321,7 +320,7 @@ fn report_eii_mismatch<'tcx>(
321320
if declaration_sig.inputs().len() == *i {
322321
// Suggestion to change output type. We do not suggest in `async` functions
323322
// to avoid complex logic or incorrect output.
324-
if let ItemKind::Fn { sig, .. } = &tcx.hir().expect_item(external_impl_did).kind
323+
if let ItemKind::Fn { sig, .. } = &tcx.hir_expect_item(external_impl_did).kind
325324
&& !sig.header.asyncness.is_async()
326325
{
327326
let msg = "change the output type to match the declaration";
@@ -376,11 +375,11 @@ fn extract_spans_for_error_reporting<'tcx>(
376375
) -> (Span, Option<Span>, Ident) {
377376
let tcx = infcx.tcx;
378377
let (mut external_impl_args, external_impl_name) = {
379-
let item = tcx.hir().expect_item(external_impl);
380-
let (sig, _, _) = item.expect_fn();
378+
let item = tcx.hir_expect_item(external_impl);
379+
let (ident, sig, _, _) = item.expect_fn();
381380
(
382381
sig.decl.inputs.iter().map(|t| t.span).chain(iter::once(sig.decl.output.span())),
383-
item.ident,
382+
ident,
384383
)
385384
};
386385

compiler/rustc_resolve/src/macros.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11351135
if let Some(builtin_name) = ext.builtin_name {
11361136
// The macro was marked with `#[rustc_builtin_macro]`.
11371137
if let Some(builtin_ext_kind) = self.builtin_macros.get(&builtin_name) {
1138-
// The macro is a built-in, replace its expander function
1139-
// while still taking everything else from the source code.
11401138
ext.kind = builtin_ext_kind.clone();
11411139
rule_spans = Vec::new();
11421140
} else {

0 commit comments

Comments
 (0)