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
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,19 @@ 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.)

if option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { 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
if option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { return; }
if diag.handler.can_emit_warnings {
diag.fileline_help(span, &format!("add #![feature({})] to the \
crate attributes to silence this warning",
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail-fulldeps/gated-macro-reexports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
#[macro_use] #[no_link]
extern crate macro_reexport_1;
//~^ ERROR macros reexports are experimental and possibly buggy
//~| HELP add #![feature(macro_reexport)] to the crate attributes to enable
1 change: 0 additions & 1 deletion src/test/compile-fail/gated-box-patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ fn main() {
match x {
box 1 => (),
//~^ box pattern syntax is experimental
//~| add #![feature(box_patterns)] to the crate attributes to enable
_ => ()
};
}
1 change: 0 additions & 1 deletion src/test/compile-fail/gated-box-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
fn main() {
let x = box 3;
//~^ ERROR box expression syntax is experimental; you can call `Box::new` instead.
//~| HELP add #![feature(box_syntax)] to the crate attributes to enable
}
1 change: 0 additions & 1 deletion src/test/compile-fail/gated-link-args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
#[link_args = "aFdEfSeVEEE"]
extern {}
//~^ ERROR the `link_args` attribute is not portable across platforms
//~| HELP add #![feature(link_args)] to the crate attributes to enable

fn main() { }
1 change: 0 additions & 1 deletion src/test/compile-fail/gated-link-llvm-intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ extern {
#[link_name = "llvm.sqrt.f32"]
fn sqrt(x: f32) -> f32;
//~^ ERROR linking to LLVM intrinsics is experimental
//~| HELP add #![feature(link_llvm_intrinsics)] to the crate attributes
}

fn main(){
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/gated-plugin_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
#[plugin_registrar]
pub fn registrar() {}
//~^ ERROR compiler plugins are experimental
//~| HELP add #![feature(plugin_registrar)] to the crate attributes to enable
fn main() {}
2 changes: 0 additions & 2 deletions src/test/compile-fail/gated-unsafe-destructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ struct D<'a>(&'a u32);

#[unsafe_destructor]
//~^ ERROR `#[unsafe_destructor]` does nothing anymore
//~| HELP: add #![feature(unsafe_destructor)] to the crate attributes to enable
// (but of couse there is no point in doing so)
impl<'a> Drop for D<'a> {
fn drop(&mut self) { }
}
Expand Down