make feature recommendations optional

This commit is contained in:
lcnr 2021-04-29 20:06:11 +02:00
parent 814a560072
commit da6261e07f
2 changed files with 21 additions and 12 deletions

View File

@ -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
}

View File

@ -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()
}
};