From da6261e07fa892f995703e4ae26832a633fa5a23 Mon Sep 17 00:00:00 2001 From: lcnr Date: Thu, 29 Apr 2021 20:06:11 +0200 Subject: [PATCH] make feature recommendations optional --- compiler/rustc_resolve/src/diagnostics.rs | 8 ++++++- compiler/rustc_typeck/src/check/wfcheck.rs | 25 ++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index c5f12c0c691b3..6ea46f5c5289e 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -487,7 +487,13 @@ impl<'a> Resolver<'a> { name )); } - err.help("use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions"); + + if self.session.is_nightly_build() { + err.help( + "use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` \ + to allow generic const expressions" + ); + } err } diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 26871d6f0285c..d25dd9a6e8302 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -315,17 +315,20 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) { ), ) } else { - tcx.sess - .struct_span_err( - hir_ty.span, - &format!( - "{} is forbidden as the type of a const generic parameter", - unsupported_type - ), - ) - .note("the only supported types are integers, `bool` and `char`") - .help("more complex types are supported with `#![feature(const_generics)]`") - .emit() + let mut err = tcx.sess.struct_span_err( + hir_ty.span, + &format!( + "{} is forbidden as the type of a const generic parameter", + unsupported_type + ), + ); + err.note("the only supported types are integers, `bool` and `char`"); + if tcx.sess.is_nightly_build() { + err.help( + "more complex types are supported with `#![feature(const_generics)]`", + ); + } + err.emit() } };