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

Do not suggest #![feature(...)] if we are in beta or stable channel. #23974

Merged
merged 3 commits into from
Apr 3, 2015

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Apr 2, 2015

Do not suggest #![feature(...)] if we are in beta or stable channel.

Fix #23973

@rust-highfive
Copy link
Collaborator

r? @sfackler

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

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

(i'm still working on a local build to double-check that this work, and does not break any tests that might be over-zealously checking the help output, but I figured I'd get this up in the meantime.)

@steveklabnik
Copy link
Member

looks good here. maybe a test?

@@ -409,6 +409,12 @@ impl<'a> Context<'a> {

pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain: &str) {
diag.span_err(span, explain);

// #23973: do not suggest `#![feature(...)]` if we are in beta/stable
Copy link
Member

Choose a reason for hiding this comment

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

do we leave these kind of comments?

Copy link
Member Author

Choose a reason for hiding this comment

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

I do.

Copy link
Member Author

Choose a reason for hiding this comment

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

(In particular, the detail of why we are early returning requires one keep reading beneath the match statement ... I figure a one-line comment with issue number is worthwhile in that context. If I had done this by moving the fileline_help invocations into the _ => { ... } arm instead, then I would not have included the comment, and would have treated the code as self-explanatory in that case. But as soon as I fiddle with return or break or other abnormal control-transfers, I try to err on the side of leaving more comments.)

Copy link
Member

Choose a reason for hiding this comment

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

interesting, I guess it's a different workflow. I tend to reach for blame, which then points to this PR. shrugs

Copy link
Member Author

Choose a reason for hiding this comment

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

(Oh, don't get me wrong; I'm a heavy user of blame too, via M-x vc-annotate. But that can require tracing through a chain of history as code gets moved around or inconsequentially revised by intermediate authors.)

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

I do not yet know how to write tests that are only run on beta/stable or likewise only nightly/development... but I'll look into it. :)

@SimonSapin
Copy link
Contributor

It doesn’t look like option_env!("CFG_RELEASE_CHANNEL") is used to determine whether to allow #![feature(…])

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

@SimonSapin hmm let me go look at how that is controlled in that case.

@SimonSapin
Copy link
Contributor

I think rustc::session::config::get_unstable_features_setting should be used instead.

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

@SimonSapin but I cannot access that from libsyntax ... :(

@SimonSapin
Copy link
Contributor

CC @brson, winner of the git blame lottery :)

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

@SimonSapin However, I will be happy to cut and paste the first line from get_unstable_feature_setting :

    let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();

I.e. this is probably the right environment variable to use, rather than inspecting the value of the CFG_RELEASE_CHANNEL

@SimonSapin
Copy link
Contributor

Hum, yes, that seems right. The bootstrap key thing is probably not relevant since by this time we’ve already decided to emit an error.

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

and its a net win for the code clarity! :)

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

@brson I don't see an obvious way for me to write a clear regression test for this. (I could make a run-make test that inspects the output of rustc --version to determine if we are running on a release tagged as -nightly or -dev, but that is ... sketchy ...)

@alexcrichton
Copy link
Member

Could the get_unstable_features_setting be moved to libsyntax? It looks like it doesn't have any dependencies on librustc and I agree with @SimonSapin that it'd be nice to reduce the number of places an environment variable is read.

Other than that though r=me, I agree that adding a test for this is probably too difficult.

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

@alexcrichton its probably higher priority for me to figure out how to fix the tests that this breaks ...

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

@brson @alexcrichton I just ripped out the checks for the help in our test suite ... but I don't know whether this is then a net win overall.

In other words: What is the better of two bad options: failing to check in our test suite that the feature names continue to match expectations (i.e. the current state of this PR), or providing a misleading help message to beta users who attempt to use a gated feature (i.e., the current state of the master branch, without this PR, as is)?

@nikomatsakis
Copy link
Contributor

@pnkfelix I don't think it's so very important to test that, personally.

@alexcrichton
Copy link
Member

@bors: r+ f6a0680

@brson
Copy link
Contributor

brson commented Apr 2, 2015

Agree that losing those tests is minor.

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 2, 2015

I am not going to attempt to move get_unstable_features_setting in this PR, though I think that I agree that it should be moved. (Basically if any further work needs to be done on this PR tonight, then someone else, maybe @alexcrichton, should just close this PR and open up a new one.)

@alexcrichton
Copy link
Member

@bors: p=1

@alexcrichton alexcrichton assigned alexcrichton and unassigned sfackler Apr 2, 2015
@bors
Copy link
Contributor

bors commented Apr 3, 2015

⌛ Testing commit f6a0680 with merge 5e30f05...

bors added a commit that referenced this pull request Apr 3, 2015
Do not suggest `#![feature(...)]` if we are in beta or stable channel.

Fix #23973
@bors bors merged commit f6a0680 into rust-lang:master Apr 3, 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.

Don’t suggest 'help: add #![feature(…)]' when it’s forbidden
9 participants