Skip to content

rustdoc: panic caused by a "reexport" of a type alias #30560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gustavla opened this issue Dec 26, 2015 · 2 comments · Fixed by #32134
Closed

rustdoc: panic caused by a "reexport" of a type alias #30560

gustavla opened this issue Dec 26, 2015 · 2 comments · Fixed by #32134
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@gustavla
Copy link

Code that compiles fine with rustc is causing an internal compiler error: unexpected panic with rustdoc.

I tried this code (bug.rs):

type Foo = isize;
pub use self::Foo::*;

The second line is essentially a typo, which can happen if Foo used to be an Enum for instance.

Again, the following works fine (although I'm not sure why, can you even add anything to the Foo namespace?):

rustc bug.rs --crate-type lib

However, if I run:

rustdoc bug.rs

I get the error:

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/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'glob not mapped to a module or enum', ../src/librustdoc/visit_ast.rs:246

This actually happened on a version of a package already pushed to crates.io (hdf5-sys 0.3.0), so anything that depends on the erroneous version and runs cargo doc will see this error.

Meta

Run on rustdoc 1.7.0-nightly (4ce1dafd1 2015-12-23).

Backtrace:

   1:        0x10767a558 - sys::backtrace::tracing::imp::write::h437867c953ecf350mZt
   2:        0x10768060f - panicking::log_panic::_<closure>::closure.41684
   3:        0x1076800b4 - panicking::log_panic::h11dc8b3c6952cc98VRx
   4:        0x107648006 - sys_common::unwind::begin_unwind_inner::haa584e089eabb124o2s
   5:        0x102f80b34 - sys_common::unwind::begin_unwind::begin_unwind::h18100502266587524809
   6:        0x103164cd3 - visit_ast::RustdocVisitor<'a, 'tcx>::resolve_id::h34d767a94ffda832qSt
   7:        0x1031629d6 - visit_ast::RustdocVisitor<'a, 'tcx>::visit_item::hec3b049092d8fa8cEVt
   8:        0x10315ba12 - visit_ast::RustdocVisitor<'a, 'tcx>::visit_mod_contents::h7551e6f2d22647cc1Ot
   9:        0x1030ef4ef - visit_ast::RustdocVisitor<'a, 'tcx>::visit::ha59cf730f9a0c027FHt
  10:        0x1030e8f12 - rustc_driver::driver::phase_3_run_analysis_passes::_<closure>::closure.42399
  11:        0x1030c5d27 - middle::ty::context::ctxt<'tcx>::create_and_enter::create_and_enter::h13379830180998392343
  12:        0x1030c2231 - driver::phase_3_run_analysis_passes::phase_3_run_analysis_passes::h13354236957594875836
  13:        0x102fbebb0 - core::run_core::h09e73f61b678853aZdk
  14:        0x102fba240 - sys_common::unwind::try::try_fn::try_fn::h13762566296504504003
  15:        0x107678088 - __rust_try
  16:        0x10766fd8e - sys_common::unwind::try::inner_try::hf68fe5ebaab44cceWYs
  17:        0x102fbbf01 - boxed::F.FnBox<A>::call_box::call_box::h3532894196117764030
  18:        0x10767f6ad - sys::thread::Thread::new::thread_start::h1257bf86ea35bf0aZbx
  19:     0x7fff8f30e267 - _pthread_body
  20:     0x7fff8f30e1e4 - _pthread_start
@gustavla gustavla changed the title rustdoc: panic caused by a "reexport" of a type alias (compiles fine with rustc) rustdoc: panic caused by a "reexport" of a type alias Dec 26, 2015
@sfackler sfackler added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Dec 26, 2015
Dr-Emann added a commit to Dr-Emann/rust-squash-sys that referenced this issue Feb 8, 2016
This prevents rust-lang/rust#30560. SquashStreamState used to be an
enum, instead of a type alias.
@mitaa
Copy link
Contributor

mitaa commented Mar 8, 2016

This is easy to fix in rustdoc, but should this even compile?

@alexcrichton
Copy link
Member

Whoa kinda crazy...

cc @jseyfried (resolve weridness, longstanding though!)

bors added a commit that referenced this issue Mar 11, 2016
…atsakis

Forbid glob-importing from a type alias

This PR forbids glob-importing from a type alias or trait (fixes #30560):
```rust
type Alias = ();
use Alias::*; // This is currently allowed but shouldn't be
```

This is a [breaking-change]. Since the disallowed glob imports don't actually import anything, any breakage can be fixed by removing the offending glob import.

r? @alexcrichton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants