delay error for enabling unstable lib features
If #![feature] is used outside the nightly channel for only lib features, the check will be delayed to the stability pass after parsing. This is done so that appropriate help messages can be shown if the #![feature] has been used needlessly
This commit is contained in:
parent
d1d8145dff
commit
9f7e281d47
2 changed files with 16 additions and 0 deletions
|
@ -929,6 +929,16 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
|
|||
let declared_lib_features = &tcx.features().declared_lib_features;
|
||||
let mut remaining_lib_features = FxHashMap::default();
|
||||
for (feature, span) in declared_lib_features {
|
||||
if !tcx.sess.opts.unstable_features.is_nightly_build() {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
*span,
|
||||
E0554,
|
||||
"`#![feature]` may not be used on the {} release channel",
|
||||
env!("CFG_RELEASE_CHANNEL")
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
if remaining_lib_features.contains_key(&feature) {
|
||||
// Warn if the user enables a lib feature multiple times.
|
||||
duplicate_feature_err(tcx.sess, *span, *feature);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue