Change:
: : Steps to reproduce: This is failing when the crate attempts to import the crate (which is a crate). That is, if I modify 's file to only contain: rustc will ICE. <details<summaryBacktrace:</summary</details
I suspect this is a duplicate of , but I only count 2 #[procmacro] and 1 #[procmacro_attribute] in the repository.
The crate only has 1 and 1 . If I comment both of them out, the compiler still ICEs. The crate used to compile a couple weeks ago, so this was a fairly recent change.
To give some bounds on this: the crate compiles with . It fails with . I would bisect this with rustup to determine which nightly the issue started with, but .
Derp, I just remembered I could remove the component. Okay, doing that, I was able to bisect the nightlies: Last working version: First failing version:
I just did a git bisect, and it looks like commit (from PR ) is the source of the breakage. cc
visited for triage. Going to try to followup with . Assigning to self to keep myself honest about that claim.
also, P-high
Am looking at this.
Minified: // #[allow(unused)] // enum ProcMacroHack { // Input = (stringify!(ARGS), 0).1, // } // The problem is caused by containing "host" defids and being used in [trans]. I don't think that this field has any business containing host libraries when compiling a proc macro, but I'll ask for confirmation. [trans]:
visited for triage. Seems like PR handles this. Leaving as P-high

Discussion:
let cnum = cdata.cnum; assert!(cnum != LOCAL_CRATE); <del> // If this crate is a custom derive crate, then we're not even going to // link those in so we skip those crates. if cdata.root.macro_derive_registrar.is_some() { return Arc::new(Vec::new()) } </del> Arc::new(cdata.exported_symbols(tcx)) } }

/// Iterates over all the stability attributes in the given crate. pub fn get_lib_features(&self) -> Vec<(ast::Name, Option<ast::Name>)> { <ins> // FIXME: For a proc macro crate, not sure whether we should return the "host" // features or an empty Vec. Both don't cause ICEs. </ins> self.root .lib_features .decode(self)

/// Iterates over the language items in the given crate. pub fn get_lang_items(&self) -> Vec<(DefId, usize)> { <del> self.root .lang_items .decode(self) .map(|(def_index, index)| (self.local_def_id(def_index), index)) .collect() </del> <ins> if self.proc_macros.is_some() { // Proc macro crates do not export any lang-items to the target. vec![] } else { self.root .lang_items .decode(self) .map(|(def_index, index)| (self.local_def_id(def_index), index)) .collect() } </ins> } /// Iterates over each child of the given item.

pub fn get_implementations_for_trait(&self, filter: Option<DefId>, result: &mut Vec<DefId>) { <ins> if self.proc_macros.is_some() { // proc-macro crates export no trait impls. return } </ins> // Do a reverse lookup beforehand to avoid touching the crate_num // hash map in the loop below. let filter = match filter.map(|def_id| self.reverse_translate_def_id(def_id)) { Some(Some(def_id)) => Some((def_id.krate.as_u32(), def_id.index)), Some(None) => return, <del> None if self.proc_macros.is_some() => return, </del> None => None, };

pub fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLibrary> { <del> self.root.native_libraries.decode((self, sess)).collect() </del> <ins> if self.proc_macros.is_some() { // Proc macro crates do not have any *target* native libraries. vec![] } else { self.root.native_libraries.decode((self, sess)).collect() } </ins> } pub fn get_foreign_modules(&self, sess: &Session) -> Vec<ForeignModule> { <del> self.root.foreign_modules.decode((self, sess)).collect() </del> <ins> if self.proc_macros.is_some() { // Proc macro crates do not have any *target* foreign modules. vec![] } else { self.root.foreign_modules.decode((self, sess)).collect() } </ins> } pub fn get_dylib_dependency_formats(&self) -> Vec<(CrateNum, LinkagePreference)> {

} pub fn get_missing_lang_items(&self) -> Vec<lang_items::LangItem> { <del> self.root .lang_items_missing .decode(self) .collect() </del> <ins> if self.proc_macros.is_some() { // Proc macro crates do not depend on any target weak lang-items. vec![] } else { self.root .lang_items_missing .decode(self) .collect() } </ins> } pub fn get_fn_arg_names(&self, id: DefIndex) -> Vec<ast::Name> {

pub fn exported_symbols(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> { <del> let lazy_seq: LazySeq<(ExportedSymbol<'tcx>, SymbolExportLevel)> = LazySeq::with_position_and_length(self.root.exported_symbols.position, self.root.exported_symbols.len); lazy_seq.decode((self, tcx)).collect() </del> <ins> if self.proc_macros.is_some() { // If this crate is a custom derive crate, then we're not even going to // link those in so we skip those crates. vec![] } else { let lazy_seq: LazySeq<(ExportedSymbol<'tcx>, SymbolExportLevel)> = LazySeq::with_position_and_length(self.root.exported_symbols.position, self.root.exported_symbols.len); lazy_seq.decode((self, tcx)).collect() } </ins> } pub fn get_rendered_const(&self, id: DefIndex) -> String {

/// file they represent, just information about length, line breaks, and /// multibyte characters. This information is enough to generate valid debuginfo /// for items inlined from other crates. <ins> /// /// Proc macro crates don't currently export spans, so this function does not have /// to work for them. </ins> pub fn imported_source_files(&'a self, <del> local_source_map: &source_map::SourceMap) -> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> { </del> <ins> local_source_map: &source_map::SourceMap) -> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> { </ins> { let source_files = self.source_map_import_info.borrow(); if !source_files.is_empty() {

<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // no-prefer-dynamic // check that having extern "C" functions in a proc macro doesn't crash. #![crate_type="proc-macro"] #![allow(non_snake_case)] extern crate proc_macro; macro_rules! proc_macro_tokenstream { () => { ::proc_macro::TokenStream }; } macro_rules! proc_macro_expr_impl { ($( $( #[$attr:meta] )* pub fn $func:ident($input:ident: &str) -> String $body:block )+) => { $( // Parses an input that looks like: // // ``` // #[allow(unused)] // enum ProcMacroHack { //     Input = (stringify!(ARGS), 0).1, // } // ``` $( #[$attr] )* #[proc_macro_derive($func)] pub fn $func(input: proc_macro_tokenstream!()) -> proc_macro_tokenstream!() { unsafe { rust_dbg_extern_identity_u64(0); } panic!() } )+ }; } proc_macro_expr_impl! { pub fn base2_impl(input: &str) -> String { panic!() } } #[link(name="rust_test_helpers")] extern "C" { pub fn rust_dbg_extern_identity_u64(v: u64) -> u64; } </ins>

<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:issue_54059.rs // ignore-stage1 // ignore-wasm32-bare no libc for ffi testing // ignore-windows - dealing with weird symbols issues on dylibs isn't worth it // revisions: rpass1 extern crate issue_54059; fn main() {} </ins>