5

Suggest removing `#![feature]` for library features that have been stabilized by...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/89012
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Member

@jyn514 jyn514 left a comment

Isn't the point to suggest removing the feature? This looks like you've just duplicated the check later into the compiler.

use rustc_errors::Applicability;

if !sess.opts.unstable_features.is_nightly_build() {

let lang_features = &sess.features_untracked().declared_lang_features;

if lang_features.len() == 0 {

return;

Copy link

Member

@jyn514 jyn514 on Sep 16

What is this check doing? It should never be hit since there will always be some features built-in, but it also doesn't seem to have anything to do with the rest of the code.

Copy link

Contributor

Author

@vishadGoyal vishadGoyal on Sep 16

The lang_features vector contains the declared_lang_features in the session. So only the ones which have been enabled show up here.
I've added this check to skip emitting an error if only lib_features have been enabled and no lang_features

Copy link

Member

@jyn514 jyn514 on Sep 16

Ok. That still seems like the wrong check, though - if there's one language and one library feature, it should still suggest removing the stable library feature.

Copy link

Contributor

Author

@vishadGoyal vishadGoyal on Sep 16

How will that be possible since the suggestion can be generated only after TyCtxt is generated? And we will be throwing an error at the parsing stage if a lang feature has been enabled, the compiler will abort and won't go to the next stage

Copy link

Member

@jyn514 jyn514 on Sep 16

And we will be throwing an error at the parsing stage if a lang feature has been enabled, the compiler will abort and won't go to the next stage

Oh hmm, good point. Ok, this seems fine then - if the language feature wasn't stable removing the library feature wouldn't have helped anyway.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK