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

librustc_metadata: Pass a default value when unwrapping a span #57650

Merged
merged 2 commits into from
Jan 19, 2019
Merged

librustc_metadata: Pass a default value when unwrapping a span #57650

merged 2 commits into from
Jan 19, 2019

Conversation

AB1908
Copy link

@AB1908 AB1908 commented Jan 16, 2019

Fixes #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 #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?

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 16, 2019
@AB1908
Copy link
Author

AB1908 commented Jan 16, 2019

Even though I've fixed the issue (at least to my knowledge), I have no clue what static-nobundle is or does. Could someone point me to some info? I also tried compiling a Hello World! program after adding #![feature(static_nobundle)] but I got an error linking with cc failed. If I'm understanding correctly, this allows us to link with other compilers?

@petrochenkov petrochenkov assigned petrochenkov and unassigned eddyb Jan 16, 2019
@petrochenkov
Copy link
Contributor

@AB1908

Even though I've fixed the issue (at least to my knowledge), I have no clue what static-nobundle is or does.

rustc -l static-nobundle=foo main.rs will link our main program with a static library foo (file libfoo.a on Linux) found somewhere in library search directories.
This is usually used for linking to code written in C or Assembler.

"linking with cc failed" is reported because no library named nonexistent is found, so it's a linking error.

Should I be adding a new test?

Yes, this needs a test.
A proper place for the test is probably src/test/ui/feature-gates/feature-gate-static-nobundle-2.rs and the test will look something like this

// compile-flags: -l static-nobundle=nonexistent

fn main() {}

+ ERROR annotation + .stderr file with test output.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 16, 2019
@AB1908
Copy link
Author

AB1908 commented Jan 17, 2019

  • ERROR annotation + .stderr file with test output.

I think I've added the necessary test but I have another issue to raise. From the docs, I couldn't figure out
where to place the ERROR annotation as it should fail because of a compile flag in this case rather than from the source code. However, the testing framework pointed out that it was looking for an ERROR in line 1 rather than say 7, and I was able to fix that up. Should we add some relevant snippet about this in the testing docs to save the hassle for a new contributor or did I not look hard enough?

@petrochenkov
Copy link
Contributor

@bors r+ rollup
Thanks!

Should we add some relevant snippet about this in the testing docs to save the hassle for a new contributor

Sure, if you think it would be useful.
As you said, the testing framework already kind of helps here pointing to the line 1.

@bors
Copy link
Contributor

bors commented Jan 17, 2019

📌 Commit 1e3f475 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 17, 2019
Centril added a commit to Centril/rust that referenced this pull request 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 pull request 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 pull request 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 pull request 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?
bors added a commit that referenced this pull request Jan 18, 2019
Rollup of 11 pull requests

Successful merges:

 - #57107 (Add a regression test for mutating a non-mut #[thread_local])
 - #57132 (Document that `-C opt-level=0` implies `-C debug-assertions`.)
 - #57212 (docs(rustc): Link to the book's source in rustc)
 - #57302 (Fix unused_assignments false positive)
 - #57350 (Better error note on unimplemented Index trait for string)
 - #57635 (use structured macro and path resolve suggestions)
 - #57650 (librustc_metadata: Pass a default value when unwrapping a span)
 - #57657 (Add regression test to close #53787)
 - #57658 (Two HIR tweaks)
 - #57720 (Fix suggestions given mulitple bad lifetimes)
 - #57725 (Use structured suggestion to surround struct literal with parenthesis)

Failed merges:

r? @ghost
@bors bors merged commit 1e3f475 into rust-lang:master Jan 19, 2019
@@ -163,7 +163,7 @@ impl<'a, 'tcx> Collector<'a, 'tcx> {
!self.tcx.features().static_nobundle {
feature_gate::emit_feature_err(&self.tcx.sess.parse_sess,
"static_nobundle",
span.unwrap(),
span.unwrap_or_else(|| syntax_pos::DUMMY_SP),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be span.unwrap_or(syntax_pos::DUMMY_SP), as it's just a constant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I didn't even notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants