From eaea188d9674c8b9eba36dec5f20277a6fe7ae43 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 2 Apr 2015 17:29:22 +0200 Subject: [PATCH 1/3] Do not suggest `#![feature(...)]` if we are in beta or stable channel. Fix #23973 --- src/libsyntax/feature_gate.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index dbddd9dd44d..2d6fbb7c683 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -409,6 +409,12 @@ fn check_attribute(&self, attr: &ast::Attribute) { 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 + 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)); @@ -416,6 +422,12 @@ pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain: 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", From 9b8957f1d4451090d6f3e7ac7f61731c8a4f1a80 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 2 Apr 2015 17:47:51 +0200 Subject: [PATCH 2/3] Revise logic to match `rustc::session::config::get_unstable_features_setting` --- src/libsyntax/feature_gate.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2d6fbb7c683..689b4595d39 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -411,10 +411,7 @@ pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain: diag.span_err(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 option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { return; } diag.fileline_help(span, &format!("add #![feature({})] to the \ crate attributes to enable", feature)); @@ -424,10 +421,7 @@ pub fn emit_feature_warn(diag: &SpanHandler, feature: &str, span: Span, explain: 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 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", From f6a06808ec0ec9dec2ca8b5bd2b37c1c66119d95 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 2 Apr 2015 19:30:45 +0200 Subject: [PATCH 3/3] Fallout to tests expecting unconditional help output from missing features. --- src/test/compile-fail-fulldeps/gated-macro-reexports.rs | 1 - src/test/compile-fail/gated-box-patterns.rs | 1 - src/test/compile-fail/gated-box-syntax.rs | 1 - src/test/compile-fail/gated-link-args.rs | 1 - src/test/compile-fail/gated-link-llvm-intrinsics.rs | 1 - src/test/compile-fail/gated-plugin_registrar.rs | 1 - src/test/compile-fail/gated-unsafe-destructor.rs | 2 -- 7 files changed, 8 deletions(-) diff --git a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs index a88445bafc0..022a6b4f2f7 100644 --- a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs +++ b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs @@ -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 diff --git a/src/test/compile-fail/gated-box-patterns.rs b/src/test/compile-fail/gated-box-patterns.rs index abaa256d52e..d82d0dec72b 100644 --- a/src/test/compile-fail/gated-box-patterns.rs +++ b/src/test/compile-fail/gated-box-patterns.rs @@ -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 _ => () }; } diff --git a/src/test/compile-fail/gated-box-syntax.rs b/src/test/compile-fail/gated-box-syntax.rs index 3e08c1f7a71..a2643fe02b8 100644 --- a/src/test/compile-fail/gated-box-syntax.rs +++ b/src/test/compile-fail/gated-box-syntax.rs @@ -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 } diff --git a/src/test/compile-fail/gated-link-args.rs b/src/test/compile-fail/gated-link-args.rs index c8845ced2fc..7b1405c913f 100644 --- a/src/test/compile-fail/gated-link-args.rs +++ b/src/test/compile-fail/gated-link-args.rs @@ -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() { } diff --git a/src/test/compile-fail/gated-link-llvm-intrinsics.rs b/src/test/compile-fail/gated-link-llvm-intrinsics.rs index 716ea9f8dba..92a1b071437 100644 --- a/src/test/compile-fail/gated-link-llvm-intrinsics.rs +++ b/src/test/compile-fail/gated-link-llvm-intrinsics.rs @@ -12,7 +12,6 @@ #[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(){ diff --git a/src/test/compile-fail/gated-plugin_registrar.rs b/src/test/compile-fail/gated-plugin_registrar.rs index d716c53e1d1..9cdebde7b7b 100644 --- a/src/test/compile-fail/gated-plugin_registrar.rs +++ b/src/test/compile-fail/gated-plugin_registrar.rs @@ -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() {} diff --git a/src/test/compile-fail/gated-unsafe-destructor.rs b/src/test/compile-fail/gated-unsafe-destructor.rs index 2aebbf3d54b..9dd1e229e0a 100644 --- a/src/test/compile-fail/gated-unsafe-destructor.rs +++ b/src/test/compile-fail/gated-unsafe-destructor.rs @@ -18,8 +18,6 @@ #[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) { } }