+
+declare_lint! {
+ pub INCOMPLETE_FEATURES,
+ Warn,
+ "incomplete features that may function improperly in some or all cases"
+}
+
+declare_lint_pass!(
+ /// Check for used feature gates in `INCOMPLETE_FEATURES` in `feature_gate.rs`.
+ IncompleteFeatures => [INCOMPLETE_FEATURES]
+);
+
+impl EarlyLintPass for IncompleteFeatures {
+ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
+ let features = cx.sess.features_untracked();
+ features.declared_lang_features
+ .iter().map(|(name, span, _)| (name, span))
+ .chain(features.declared_lib_features.iter().map(|(name, span)| (name, span)))
+ .filter(|(name, _)| feature_gate::INCOMPLETE_FEATURES.iter().any(|f| name == &f))
+ .for_each(|(name, &span)| {
+ cx.struct_span_lint(
+ INCOMPLETE_FEATURES,
+ span,
+ &format!(
+ "the feature `{}` is incomplete and may cause the compiler to crash",
+ name,
+ )
+ )
+ .emit();
+ });
+ }
+}