Stream: t-compiler/help

Topic: error: cannot find a built-in macro with name `cfg`


Joshua Nelson (Aug 09 2020 at 03:51, on Zulip):

Copying from https://github.com/rust-lang/rust/pull/75176#issuecomment-671001837 for convenience:

The error comes from here: https://github.com/rust-lang/rust/blob/e539dd65f8ba80837f7477c0547c61514bceb3ad/src/librustc_resolve/macros.rs#L1077-L1087

Note that compile_macro uses builtin_macros.remove instead of .get. So I think it expects to only ever be called once. I'm not sure why it was called more than once - I'd expect it to only be called once during expand.

There are a bunch of other questions that pop up, like

Joshua Nelson (Aug 10 2020 at 03:54, on Zulip):

I think this might be because rustdoc is generating fake DefIds - this panics when you try to print the def id:

thread 'rustc' panicked at 'index out of bounds: the len is 18 but the index is 18', src/librustc_metadata/creader.rs:128:21

cc @eddyb - rustc_metadata is your specialty and also git blame shows you as the last one to touch next_def_id on auto_trait and blanket_impls. Do you know how rustc_resolve could possibly be seeing a fake ID created by rustdoc?

Joshua Nelson (Aug 10 2020 at 03:54, on Zulip):

(more info on the PR)

Joshua Nelson (Aug 10 2020 at 03:55, on Zulip):

and also, why does rustdoc create fake IDs in the first place instead of using param_env_def_id and impl_def_id?

Joshua Nelson (Aug 10 2020 at 03:57, on Zulip):

ugh this didn't fix it

diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs
index 9c44d27447d..0325ea75445 100644
--- a/src/librustdoc/clean/auto_trait.rs
+++ b/src/librustdoc/clean/auto_trait.rs
@@ -122,7 +122,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
                     name: None,
                     attrs: Default::default(),
                     visibility: Inherited,
-                    def_id: self.cx.next_def_id(param_env_def_id.krate),
+                    //def_id: self.cx.next_def_id(param_env_def_id.krate),
+                    def_id: param_env_def_id,
                     stability: None,
                     deprecation: None,
                     inner: ImplItem(Impl {
diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl
.rs
index 3d2785541be..d3f87c91279 100644
--- a/src/librustdoc/clean/blanket_impl.rs
+++ b/src/librustdoc/clean/blanket_impl.rs
@@ -96,7 +96,8 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
                     name: None,
                     attrs: Default::default(),
                     visibility: Inherited,
-                    def_id: self.cx.next_def_id(impl_def_id.krate),
+                    //def_id: self.cx.next_def_id(impl_def_id.krate),
+                    def_id: impl_def_id,
                     stability: None,
                     deprecation: None,
                     inner: ImplItem(Impl {

so maybe fake IDs aren't to blame after all? I don't see next_def_id used anywhere else

Last update: Sep 28 2020 at 16:30UTC