Suggest removing `#![feature]` for library features that have been stabilized by...
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.
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;
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.
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
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.
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
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.
compiler/rustc_passes/src/stability.rs
Outdated Show resolved
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK