Skip to content

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

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 3 commits into from
Apr 3, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,25 @@ 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.)

match option_env!("CFG_RELEASE_CHANNEL") {
Some("stable") | Some("beta") => return,
_ => {}
}
diag.fileline_help(span, &format!("add #![feature({})] to the \
crate attributes to enable",
feature));
}

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

// #23973: do not suggest `#![feature(...)]` if we are in beta/stable
match option_env!("CFG_RELEASE_CHANNEL") {
Some("stable") | Some("beta") => return,
_ => {}
}
if diag.handler.can_emit_warnings {
diag.fileline_help(span, &format!("add #![feature({})] to the \
crate attributes to silence this warning",
Expand Down