Skip to content
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

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

Closed
petrochenkov opened this issue Jan 4, 2019 · 7 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@petrochenkov
Copy link
Contributor

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.

@petrochenkov petrochenkov added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Jan 4, 2019
@AB1908
Copy link

AB1908 commented Jan 4, 2019

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.

@Patryk27
Copy link
Contributor

Patryk27 commented Jan 4, 2019

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)

@AB1908
Copy link

AB1908 commented Jan 4, 2019

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.

@petrochenkov
Copy link
Contributor Author

petrochenkov commented Jan 4, 2019

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

@AB1908
Copy link

AB1908 commented Jan 4, 2019

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

@petrochenkov
Copy link
Contributor Author

@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

@AB1908
Copy link

AB1908 commented Jan 4, 2019

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

Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
librustc_metadata: Pass a default value when unwrapping a span

Fixes rust-lang#57323.

When compiling with `static-nobundle` a-la

`rustc -l static-nobundle=nonexistent main.rs`

we now get a neat output in the form of:

```
error[E0658]: kind="static-nobundle" is feature gated (see issue rust-lang#37403)
  |
  = help: add #![feature(static_nobundle)] to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
```
The build and tests completed successfully on my machine. Should I be adding a new test?
Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
librustc_metadata: Pass a default value when unwrapping a span

Fixes rust-lang#57323.

When compiling with `static-nobundle` a-la

`rustc -l static-nobundle=nonexistent main.rs`

we now get a neat output in the form of:

```
error[E0658]: kind="static-nobundle" is feature gated (see issue rust-lang#37403)
  |
  = help: add #![feature(static_nobundle)] to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
```
The build and tests completed successfully on my machine. Should I be adding a new test?
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 18, 2019
librustc_metadata: Pass a default value when unwrapping a span

Fixes rust-lang#57323.

When compiling with `static-nobundle` a-la

`rustc -l static-nobundle=nonexistent main.rs`

we now get a neat output in the form of:

```
error[E0658]: kind="static-nobundle" is feature gated (see issue rust-lang#37403)
  |
  = help: add #![feature(static_nobundle)] to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
```
The build and tests completed successfully on my machine. Should I be adding a new test?
Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
librustc_metadata: Pass a default value when unwrapping a span

Fixes rust-lang#57323.

When compiling with `static-nobundle` a-la

`rustc -l static-nobundle=nonexistent main.rs`

we now get a neat output in the form of:

```
error[E0658]: kind="static-nobundle" is feature gated (see issue rust-lang#37403)
  |
  = help: add #![feature(static_nobundle)] to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
```
The build and tests completed successfully on my machine. Should I be adding a new test?
VardhanThigle pushed a commit to jethrogb/rust that referenced this issue Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants