Closed
Description
Code
proc macro:
use proc_macro::TokenStream;
#[proc_macro]
pub fn cause_ice(_: TokenStream) -> TokenStream {
quote::quote!(
enum IceCause {
Variant,
}
pub use IceCause::Variant;
).into()
}
usage:
ice_macro::cause_ice!();
ICE is caused by pub re-exporting a single variant of a non-pub enum generated within a proc macro. Cannot be recreated with a declarative macro. marking the enum as pub
/pub(in super)
, or pub(super)
fixes the issue, while pub(crate)
and pub(self)
do not.
Meta
rustc --version --verbose
:
rustc 1.49.0-nightly (ffa2e7ae8 2020-10-24)
binary: rustc
commit-hash: ffa2e7ae8fbf9badc035740db949b9dae271c29f
commit-date: 2020-10-24
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0
Also recreated on stable:
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0
Error output
thread 'rustc' panicked at '`enum` keyword should exist in snippet', src/librustc_resolve/imports.rs:1453:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.47.0 (18bf6b4f0 2020-10-07) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: could not compile `ice-reproduction`
Backtrace
stack backtrace:
0: rust_begin_unwind
at /rustc/ffa2e7ae8fbf9badc035740db949b9dae271c29f/library/std/src/panicking.rs:483:5
1: core::panicking::panic_fmt
at /rustc/ffa2e7ae8fbf9badc035740db949b9dae271c29f/library/core/src/panicking.rs:85:14
2: core::option::expect_failed
at /rustc/ffa2e7ae8fbf9badc035740db949b9dae271c29f/library/core/src/option.rs:1260:5
3: rustc_resolve::ModuleData::for_each_child
4: rustc_resolve::imports::ImportResolver::finalize_imports
5: rustc_resolve::Resolver::resolve_crate
6: rustc_interface::passes::configure_and_expand_inner
7: rustc_interface::passes::configure_and_expand::{{closure}}
8: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
9: rustc_interface::passes::configure_and_expand
10: rustc_interface::queries::Queries::expansion
11: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
12: rustc_span::with_source_map
13: rustc_interface::interface::create_compiler_and_run
14: scoped_tls::ScopedKey<T>::set
*backtrace is from nightly commit ffa2e7a
I'd love to implement a fix, but figured I should make an issue to ensure it's not dupe work first and would appreciate any guidance as far as where to look and possible concerns when fixing.
Metadata
Metadata
Assignees
Labels
Area: Procedural macrosArea: Name/path resolution done by `rustc_resolve` specificallyCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.