Skip to content

Specifying static-nobundle on command line causes an internal compiler error #57323

Closed

Description

@petrochenkov

Reproduction:

rustc -l static-nobundle=nonexistent main.rs

---

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src\libcore\option.rs:345:21
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

error: internal compiler error: unexpected panic

This happens because code in

assumes that the span always exists, which is not true for things passed from command line.

Activity

  1. added
    E-easy
    I-ICE
    E-mentor
    on Jan 4, 2019
  2. AB1908 commented on Jan 4, 2019

    @AB1908

    I'm very new to Rust so forgive my naivety. Since span may not exist, I assume we need to change span.unwrap() to span.unwrap_or_else() and provide a default value? From the documentation, I couldn't think of a suitable default value for Span which is expected by feature_gate::emit_feature_err(). I couldn't think of any other changes as per your statement:

    assumes that the span always exists, which is not true for things passed from command line.

  3. Patryk27 commented on Jan 4, 2019

    @Patryk27
    Contributor

    Maybe instead of unwrap_or_else() we could go this way?

    if let Some(span) = span {
      feature_gate::emit_feature_err(/* ... */);
    } else {
      self.tcx.sess.err("some error message here");
    }

    (see: processing error messages in the process_command_line function below that register_native_lib)

  4. AB1908 commented on Jan 4, 2019

    @AB1908

    Does this mean that we should throw an error when span is empty? From the original description, it seemed to me that having a Span value was optional. If throwing an error is the way to go, then I think your solution is the appropriate solution.

  5. petrochenkov commented on Jan 4, 2019

    @petrochenkov
    ContributorAuthor

    @AB1908
    DUMMY_SP is the value that's usually used if the span is unknown or doesn't exist.

  6. AB1908 commented on Jan 4, 2019

    @AB1908

    Alright. For future reference, how was I to find that out?

  7. petrochenkov commented on Jan 4, 2019

    @petrochenkov
    ContributorAuthor

    @AB1908
    If type has a default value, it's usually defined somewhere around the definition of that type.
    In case of Span pub const DUMMY_SP: Span = Span(0); is also defined in right below the span definition pub struct Span(u32); in libsyntax_pos/span_encoding.rs

  8. AB1908 commented on Jan 4, 2019

    @AB1908

    Thanks for the hand-holding. I'll try to make the necessary changes and start a PR.

  9. added 2 commits that reference this issue on Jan 18, 2019
    f7f5450
    779929d
  10. added a commit that references this issue on Jan 18, 2019
    e67075e
  11. added a commit that references this issue on Jan 18, 2019
    d2300af
  12. added a commit that references this issue on Jan 31, 2019
    426f81b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyE-mentorI-ICE

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions