use rustc::util::nodemap::FxHashSet;
use syntax::tokenstream::{TokenTree, TokenStream};
-use syntax::ast;
+use syntax::ast::{self, Expr};
use syntax::ptr::P;
-use syntax::ast::Expr;
use syntax::attr::{self, HasAttrs, AttributeTemplate};
use syntax::source_map::Spanned;
use syntax::edition::Edition;
-use syntax::feature_gate::{AttributeGate, AttributeType};
+use syntax::feature_gate::{self, AttributeGate, AttributeType};
use syntax::feature_gate::{Stability, deprecated_attributes};
use syntax_pos::{BytePos, Span, SyntaxContext};
use syntax::symbol::{Symbol, kw, sym};
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
match it.node {
hir::ItemKind::Fn(..) |
- hir::ItemKind::Ty(..) |
+ hir::ItemKind::TyAlias(..) |
hir::ItemKind::Enum(..) |
hir::ItemKind::Struct(..) |
hir::ItemKind::Union(..) => {
}
"a trait"
}
- hir::ItemKind::Ty(..) => "a type alias",
+ hir::ItemKind::TyAlias(..) => "a type alias",
hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) => {
// If the trait is private, add the impl items to `private_traits` so they don't get
// reported for missing docs.
hir::ImplItemKind::Const(..) => "an associated constant",
hir::ImplItemKind::Method(..) => "a method",
hir::ImplItemKind::Type(_) => "an associated type",
- hir::ImplItemKind::Existential(_) => "an associated existential type",
+ hir::ImplItemKind::OpaqueTy(_) => "an associated `impl Trait` type",
};
self.check_missing_docs_attrs(cx,
Some(impl_item.hir_id),
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
let (ty, type_alias_generics) = match item.node {
- hir::ItemKind::Ty(ref ty, ref generics) => (&*ty, generics),
+ hir::ItemKind::TyAlias(ref ty, ref generics) => (&*ty, generics),
_ => return,
};
let mut suggested_changing_assoc_types = false;
}
}
}
+
+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();
+ });
+ }
+}