Closed
Description
Summary:
The compilation of my source panics. I believe this happens because I use
a struct
that has already been pub use
d. You may be able to reproduce the issue using this github commit from my repository.
I tried this code:
The following source is inside the file: src\syntactic_analysis\nodes\item\mod.rs
These are the complete file contents.
mod visibility;
pub use self::visibility::*;
mod item_raw;
pub use self::item_raw::*;
use syntactic_analysis::nodes::Node;
use syntactic_analysis::nodes::Visibility;
pub struct Item {
pub visibility: Option<Visibility>,
pub item_raw: ItemRaw
}
impl Node for Item {
fn get_nodes(&self) -> Vec<&Node> {
match self.visibility {
Some(ref visibility) => vec![
visibility,
&self.item_raw
],
None => vec![
&self.item_raw
]
}
}
}
Modifying the file to the following snippet resolves the issue:
(Only one line has been modified)
mod visibility;
pub use self::visibility::*;
mod item_raw;
pub use self::item_raw::*;
use syntactic_analysis::nodes::Node;
use syntactic_analysis::nodes::SingleTokenNode; // This line has been modified.
pub struct Item {
pub visibility: Option<Visibility>,
pub item_raw: ItemRaw
}
impl Node for Item {
fn get_nodes(&self) -> Vec<&Node> {
match self.visibility {
Some(ref visibility) => vec![
visibility,
&self.item_raw
],
None => vec![
&self.item_raw
]
}
}
}
I expected to see this happen:
A compilation result.
Instead, this happened:
error: internal compiler error: cat_expr Errd
--> src\syntactic_analysis\nodes\item\mod.rs:24:17
|
24 | visibility,
| ^^^^^^^^^^
error: internal compiler error: src\librustc\hir\def.rs:162: attempted .def_id() on invalid def: Err
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.21.0 (3b72af97e 2017-10-09) running on x86_64-pc-windows-msvc
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:490:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Could not compile `inkc`.
To learn more, run the command again with --verbose.
Meta
rustc --version --verbose
:
rustc 1.21.0 (3b72af97e 2017-10-09)
binary: rustc
commit-hash: 3b72af97e42989b2fe104d8edbaee123cdf7c58f
commit-date: 2017-10-09
host: x86_64-pc-windows-msvc
release: 1.21.0
LLVM version: 4.0
Backtrace:
0: _rdl_shrink_in_place
1: std::panicking::Location::column
2: std::panicking::Location::column
3: std::panicking::rust_panic_with_hook
4: <unknown>
5: rustc_errors::Handler::bug
6: rustc::session::bug_fmt
7: rustc::session::bug_fmt
8: rustc::session::bug_fmt
9: rustc::hir::def::Def::def_id
10: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::ty::fold::TypeVisitor<'tcx>>::visit_ty
11: <unknown>
12: <unknown>
13: <rustc_privacy::ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item