Skip to content

Some internal compiler error during playing with rust-by-example (doc.rs) #80370

Closed
@vni

Description

@vni

Hi! I'm reading rust-by-example.
https://doc.rust-lang.org/rust-by-example/meta/doc.html

with this doc.rs I get the next error.
Sorry if this bug report isn't filled as it should be.

The example below runs pretty well with (as in rust-by-example)

rustdoc --test  --extern doc="libdoc.rlib" doc.rs

and fails with

rustdoc  --extern doc="libdoc.rlib" doc.rs

Code

#![crate_name = "doc"]

/// A human being is represented here
pub struct Person {
  /// A person must have a name, no matter how much Juliet may hate it
  name: String
}

impl Person {
  /// Returns a person with the name given them
  ///
  /// # Arguments
  ///
  /// * `name` - A string slice that holds the name of the person
  ///
  /// # Examples
  /// ```
  /// // You can have rust code ...
  /// // if you pass --test to `rustdoc`, it will even test it for you!
  /// use doc::Person;
  /// let person = Person::new("name");
  /// ```
  pub fn new(name: &str) -> Person {
    Person {
      name: name.to_string()
    }
  }

  /// Gives a friendly hello!
  ///
  /// Says "Hello, [name]" to the `Person` it is called on.
  pub fn hello(&self) {
    println!("Hello, {}!", self.name);
  }
}

fn main() {
  let john = Person::new("John");
  john.hello();
}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (0edce6f4b 2020-12-24)

Error output

rustdoc  --extern doc="libdoc.rlib" doc.rs
thread 'rustc' panicked at 'Unable to resolve external crate doc', src/librustdoc/core.rs:439:25
stack backtrace:
   0: rust_begin_unwind
             at /rustc/0edce6f4bbb4514482537f569f0b8ef48e71e0a0/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/0edce6f4bbb4514482537f569f0b8ef48e71e0a0/library/std/src/panicking.rs:435:5
   2: rustdoc::core::create_resolver::{{closure}}::{{closure}}::{{closure}}
   3: rustc_session::utils::<impl rustc_session::session::Session>::time
   4: rustc_interface::passes::BoxedResolver::access::{{closure}}
   5: rustc_interface::passes::configure_and_expand::{{closure}}
   6: rustdoc::core::create_resolver
   7: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
   8: rustc_span::with_source_map
   9: rustdoc::main_options
  10: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.50.0-nightly (0edce6f4b 2020-12-24) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
Backtrace

0: rust_begin_unwind
             at /rustc/0edce6f4bbb4514482537f569f0b8ef48e71e0a0/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/0edce6f4bbb4514482537f569f0b8ef48e71e0a0/library/std/src/panicking.rs:435:5
   2: rustdoc::core::create_resolver::{{closure}}::{{closure}}::{{closure}}
   3: rustc_session::utils::<impl rustc_session::session::Session>::time
   4: rustc_interface::passes::BoxedResolver::access::{{closure}}
   5: rustc_interface::passes::configure_and_expand::{{closure}}
   6: rustdoc::core::create_resolver
   7: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
   8: rustc_span::with_source_map
   9: rustdoc::main_options
  10: scoped_tls::ScopedKey<T>::set

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions