Skip to content

Show the span of feature that is unstable when using a feature-list. #25571

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

Merged
merged 1 commit into from
May 20, 2015

Conversation

hirschenberger
Copy link
Contributor

It is hard to find the actual unstable feature which caused the error when using a list of stable and unstable features as the span marks the whole line

src/k8055.rs:22:1: 22:64 error: unstable feature
src/k8055.rs:22 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This PR spawns an error for each unstable feature in the list:

est.rs:1:12: 1:26 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                     ^~~~~~~~~~~~~~
test.rs:1:28: 1:41 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                     ^~~~~~~~~~~~~
test.rs:1:43: 1:47 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                    ^~~~
test.rs:1:49: 1:56 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                          ^~~~~~~
test.rs:1:58: 1:62 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                                   ^~~~

@rust-highfive
Copy link
Contributor

r? @nrc

(rust_highfive has picked a reviewer for you, use r? to override)

@nrc
Copy link
Member

nrc commented May 18, 2015

The code looks fine, but I wonder if this is the best solution - it seems like it could increase the number of errors by an annoying amount. How would you feel about listing the features which are unstable instead? E.g,

src/k8055.rs:22:1: 22:64 error: unstable feature (slice_patterns, core)
src/k8055.rs:22 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Assumming that only slice_patterns and core are unstable for this example.

Or do you have any other ideas for giving better errors without giving more of them?

@hirschenberger
Copy link
Contributor Author

Yes, first I wanted to implement it the way you suggested. But then I realized that warnings of unused features where realized this way. So I did the same for unstable features.

test.rs:1:49: 1:56 warning: unused or unknown feature, #[warn(unused_features)] on by default
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                          ^~~~~~~
test.rs:1:58: 1:62 warning: unused or unknown feature, #[warn(unused_features)] on by default
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                                   ^~~~
test.rs:1:28: 1:41 warning: unused or unknown feature, #[warn(unused_features)] on by default
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                     ^~~~~~~~~~~~~

@nrc
Copy link
Member

nrc commented May 20, 2015

OK makes sense.

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented May 20, 2015

📌 Commit 70db73a has been approved by nrc

@nrc
Copy link
Member

nrc commented May 20, 2015

cc @alexcrichton Wondering if we should make unused and unstable features a single error when there are multiple features?

@alexcrichton
Copy link
Member

This is probably fine for now, most crates don't have lots of features that aren't already on nightly.

@bors
Copy link
Collaborator

bors commented May 20, 2015

⌛ Testing commit 70db73a with merge d7185dc...

bors added a commit that referenced this pull request May 20, 2015
It is hard to find the actual unstable feature which caused the error when using a list of stable and unstable features as the span marks the whole line

```
src/k8055.rs:22:1: 22:64 error: unstable feature
src/k8055.rs:22 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

This PR spawns an error for each unstable feature in the list:

```
est.rs:1:12: 1:26 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                     ^~~~~~~~~~~~~~
test.rs:1:28: 1:41 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                     ^~~~~~~~~~~~~
test.rs:1:43: 1:47 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                    ^~~~
test.rs:1:49: 1:56 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                          ^~~~~~~
test.rs:1:58: 1:62 error: unstable feature [-D unstable-features]
test.rs:1 #![feature(slice_patterns, rustc_private, core, convert, libc)]
                                                                   ^~~~
```
@bors bors merged commit 70db73a into rust-lang:master May 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants