1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! A pass that annotates every item and method with its stability level,
12 //! propagating default levels lexically from parent to children ast nodes.
14 pub use self::StabilityLevel::*;
18 use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
19 use ty::{self, TyCtxt};
20 use middle::privacy::AccessLevels;
21 use syntax::symbol::Symbol;
22 use syntax_pos::{Span, DUMMY_SP};
24 use syntax::ast::{NodeId, Attribute};
25 use syntax::feature_gate::{GateIssue, emit_feature_err, find_lang_feature_accepted_version};
26 use syntax::attr::{self, Stability, Deprecation};
27 use util::nodemap::{FxHashSet, FxHashMap};
30 use hir::{Item, Generics, StructField, Variant, HirId};
31 use hir::intravisit::{self, Visitor, NestedVisitorMap};
33 use std::mem::replace;
34 use std::cmp::Ordering;
36 #[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Copy, Debug, Eq, Hash)]
37 pub enum StabilityLevel {
43 pub fn from_attr_level(level: &attr::StabilityLevel) -> Self {
44 if level.is_stable() { Stable } else { Unstable }
50 // Annotation is required if not inherited from unstable parents
52 // Annotation is useless, reject it
54 // Annotation itself is useless, but it can be propagated to children
58 /// An entry in the `depr_map`.
60 pub struct DeprecationEntry {
61 /// The metadata of the attribute associated with this entry.
62 pub attr: Deprecation,
63 /// The def id where the attr was originally attached. `None` for non-local
65 origin: Option<HirId>,
68 impl DeprecationEntry {
69 fn local(attr: Deprecation, id: HirId) -> DeprecationEntry {
76 pub fn external(attr: Deprecation) -> DeprecationEntry {
83 pub fn same_origin(&self, other: &DeprecationEntry) -> bool {
84 match (self.origin, other.origin) {
85 (Some(o1), Some(o2)) => o1 == o2,
91 /// A stability index, giving the stability level for items and methods.
92 pub struct Index<'tcx> {
93 /// This is mostly a cache, except the stabilities of local items
94 /// are filled by the annotator.
95 stab_map: FxHashMap<HirId, &'tcx Stability>,
96 depr_map: FxHashMap<HirId, DeprecationEntry>,
98 /// Maps for each crate whether it is part of the staged API.
99 staged_api: FxHashMap<CrateNum, bool>,
101 /// Features enabled for this crate.
102 active_features: FxHashSet<Symbol>,
105 // A private tree-walker for producing an Index.
106 struct Annotator<'a, 'tcx: 'a> {
107 tcx: TyCtxt<'a, 'tcx, 'tcx>,
108 index: &'a mut Index<'tcx>,
109 parent_stab: Option<&'tcx Stability>,
110 parent_depr: Option<DeprecationEntry>,
114 impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
115 // Determine the stability for a node based on its attributes and inherited
116 // stability. The stability is recorded in the index and used as the parent.
117 fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
118 item_sp: Span, kind: AnnotationKind, visit_children: F)
119 where F: FnOnce(&mut Self)
121 if self.tcx.sess.features.borrow().staged_api {
122 // This crate explicitly wants staged API.
123 debug!("annotate(id = {:?}, attrs = {:?})", id, attrs);
124 if let Some(..) = attr::find_deprecation(self.tcx.sess.diagnostic(), attrs, item_sp) {
125 self.tcx.sess.span_err(item_sp, "`#[deprecated]` cannot be used in staged api, \
126 use `#[rustc_deprecated]` instead");
128 if let Some(mut stab) = attr::find_stability(self.tcx.sess.diagnostic(),
130 // Error if prohibited, or can't inherit anything from a container
131 if kind == AnnotationKind::Prohibited ||
132 (kind == AnnotationKind::Container &&
133 stab.level.is_stable() &&
134 stab.rustc_depr.is_none()) {
135 self.tcx.sess.span_err(item_sp, "This stability annotation is useless");
138 debug!("annotate: found {:?}", stab);
139 // If parent is deprecated and we're not, inherit this by merging
140 // deprecated_since and its reason.
141 if let Some(parent_stab) = self.parent_stab {
142 if parent_stab.rustc_depr.is_some() && stab.rustc_depr.is_none() {
143 stab.rustc_depr = parent_stab.rustc_depr.clone()
147 let stab = self.tcx.intern_stability(stab);
149 // Check if deprecated_since < stable_since. If it is,
150 // this is *almost surely* an accident.
151 if let (&Some(attr::RustcDeprecation {since: dep_since, ..}),
152 &attr::Stable {since: stab_since}) = (&stab.rustc_depr, &stab.level) {
153 // Explicit version of iter::order::lt to handle parse errors properly
154 for (dep_v, stab_v) in
155 dep_since.as_str().split(".").zip(stab_since.as_str().split(".")) {
156 if let (Ok(dep_v), Ok(stab_v)) = (dep_v.parse::<u64>(), stab_v.parse()) {
157 match dep_v.cmp(&stab_v) {
159 self.tcx.sess.span_err(item_sp, "An API can't be stabilized \
160 after it is deprecated");
163 Ordering::Equal => continue,
164 Ordering::Greater => break,
167 // Act like it isn't less because the question is now nonsensical,
168 // and this makes us not do anything else interesting.
169 self.tcx.sess.span_err(item_sp, "Invalid stability or deprecation \
176 let hir_id = self.tcx.hir.node_to_hir_id(id);
177 self.index.stab_map.insert(hir_id, stab);
179 let orig_parent_stab = replace(&mut self.parent_stab, Some(stab));
180 visit_children(self);
181 self.parent_stab = orig_parent_stab;
183 debug!("annotate: not found, parent = {:?}", self.parent_stab);
184 if let Some(stab) = self.parent_stab {
185 if stab.level.is_unstable() {
186 let hir_id = self.tcx.hir.node_to_hir_id(id);
187 self.index.stab_map.insert(hir_id, stab);
190 visit_children(self);
193 // Emit errors for non-staged-api crates.
195 let tag = unwrap_or!(attr.name(), continue);
196 if tag == "unstable" || tag == "stable" || tag == "rustc_deprecated" {
197 attr::mark_used(attr);
198 self.tcx.sess.span_err(attr.span(), "stability attributes may not be used \
199 outside of the standard library");
203 // Propagate unstability. This can happen even for non-staged-api crates in case
204 // -Zforce-unstable-if-unmarked is set.
205 if let Some(stab) = self.parent_stab {
206 if stab.level.is_unstable() {
207 let hir_id = self.tcx.hir.node_to_hir_id(id);
208 self.index.stab_map.insert(hir_id, stab);
212 if let Some(depr) = attr::find_deprecation(self.tcx.sess.diagnostic(), attrs, item_sp) {
213 if kind == AnnotationKind::Prohibited {
214 self.tcx.sess.span_err(item_sp, "This deprecation annotation is useless");
217 // `Deprecation` is just two pointers, no need to intern it
218 let hir_id = self.tcx.hir.node_to_hir_id(id);
219 let depr_entry = DeprecationEntry::local(depr, hir_id);
220 self.index.depr_map.insert(hir_id, depr_entry.clone());
222 let orig_parent_depr = replace(&mut self.parent_depr,
224 visit_children(self);
225 self.parent_depr = orig_parent_depr;
226 } else if let Some(parent_depr) = self.parent_depr.clone() {
227 let hir_id = self.tcx.hir.node_to_hir_id(id);
228 self.index.depr_map.insert(hir_id, parent_depr);
229 visit_children(self);
231 visit_children(self);
237 impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
238 /// Because stability levels are scoped lexically, we want to walk
239 /// nested items in the context of the outer item, so enable
241 fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
242 NestedVisitorMap::All(&self.tcx.hir)
245 fn visit_item(&mut self, i: &'tcx Item) {
246 let orig_in_trait_impl = self.in_trait_impl;
247 let mut kind = AnnotationKind::Required;
249 // Inherent impls and foreign modules serve only as containers for other items,
250 // they don't have their own stability. They still can be annotated as unstable
251 // and propagate this unstability to children, but this annotation is completely
252 // optional. They inherit stability from their parents when unannotated.
253 hir::ItemImpl(.., None, _, _) | hir::ItemForeignMod(..) => {
254 self.in_trait_impl = false;
255 kind = AnnotationKind::Container;
257 hir::ItemImpl(.., Some(_), _, _) => {
258 self.in_trait_impl = true;
260 hir::ItemStruct(ref sd, _) => {
262 self.annotate(sd.id(), &i.attrs, i.span, AnnotationKind::Required, |_| {})
268 self.annotate(i.id, &i.attrs, i.span, kind, |v| {
269 intravisit::walk_item(v, i)
271 self.in_trait_impl = orig_in_trait_impl;
274 fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
275 self.annotate(ti.id, &ti.attrs, ti.span, AnnotationKind::Required, |v| {
276 intravisit::walk_trait_item(v, ti);
280 fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
281 let kind = if self.in_trait_impl {
282 AnnotationKind::Prohibited
284 AnnotationKind::Required
286 self.annotate(ii.id, &ii.attrs, ii.span, kind, |v| {
287 intravisit::walk_impl_item(v, ii);
291 fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: NodeId) {
292 self.annotate(var.node.data.id(), &var.node.attrs, var.span, AnnotationKind::Required, |v| {
293 intravisit::walk_variant(v, var, g, item_id);
297 fn visit_struct_field(&mut self, s: &'tcx StructField) {
298 self.annotate(s.id, &s.attrs, s.span, AnnotationKind::Required, |v| {
299 intravisit::walk_struct_field(v, s);
303 fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem) {
304 self.annotate(i.id, &i.attrs, i.span, AnnotationKind::Required, |v| {
305 intravisit::walk_foreign_item(v, i);
309 fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
310 self.annotate(md.id, &md.attrs, md.span, AnnotationKind::Required, |_| {});
314 struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
315 tcx: TyCtxt<'a, 'tcx, 'tcx>,
316 access_levels: &'a AccessLevels,
319 impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
320 fn check_missing_stability(&self, id: NodeId, span: Span) {
321 let hir_id = self.tcx.hir.node_to_hir_id(id);
322 let stab = self.tcx.stability().local_stability(hir_id);
323 let is_error = !self.tcx.sess.opts.test &&
325 self.access_levels.is_reachable(id);
327 self.tcx.sess.span_err(span, "This node does not have a stability attribute");
332 impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
333 fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
334 NestedVisitorMap::OnlyBodies(&self.tcx.hir)
337 fn visit_item(&mut self, i: &'tcx Item) {
339 // Inherent impls and foreign modules serve only as containers for other items,
340 // they don't have their own stability. They still can be annotated as unstable
341 // and propagate this unstability to children, but this annotation is completely
342 // optional. They inherit stability from their parents when unannotated.
343 hir::ItemImpl(.., None, _, _) | hir::ItemForeignMod(..) => {}
345 _ => self.check_missing_stability(i.id, i.span)
348 intravisit::walk_item(self, i)
351 fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
352 self.check_missing_stability(ti.id, ti.span);
353 intravisit::walk_trait_item(self, ti);
356 fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
357 let impl_def_id = self.tcx.hir.local_def_id(self.tcx.hir.get_parent(ii.id));
358 if self.tcx.impl_trait_ref(impl_def_id).is_none() {
359 self.check_missing_stability(ii.id, ii.span);
361 intravisit::walk_impl_item(self, ii);
364 fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: NodeId) {
365 self.check_missing_stability(var.node.data.id(), var.span);
366 intravisit::walk_variant(self, var, g, item_id);
369 fn visit_struct_field(&mut self, s: &'tcx StructField) {
370 self.check_missing_stability(s.id, s.span);
371 intravisit::walk_struct_field(self, s);
374 fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem) {
375 self.check_missing_stability(i.id, i.span);
376 intravisit::walk_foreign_item(self, i);
379 fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
380 self.check_missing_stability(md.id, md.span);
384 impl<'a, 'tcx> Index<'tcx> {
385 pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Index<'tcx> {
387 tcx.sess.opts.debugging_opts.force_unstable_if_unmarked ||
388 tcx.sess.features.borrow().staged_api;
389 let mut staged_api = FxHashMap();
390 staged_api.insert(LOCAL_CRATE, is_staged_api);
391 let mut index = Index {
393 stab_map: FxHashMap(),
394 depr_map: FxHashMap(),
395 active_features: FxHashSet(),
398 let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features;
400 // Put the active features into a map for quick lookup
401 index.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect();
404 let krate = tcx.hir.krate();
405 let mut annotator = Annotator {
410 in_trait_impl: false,
413 // If the `-Z force-unstable-if-unmarked` flag is passed then we provide
414 // a parent stability annotation which indicates that this is private
415 // with the `rustc_private` feature. This is intended for use when
416 // compiling librustc crates themselves so we can leverage crates.io
417 // while maintaining the invariant that all sysroot crates are unstable
418 // by default and are unable to be used.
419 if tcx.sess.opts.debugging_opts.force_unstable_if_unmarked {
420 let reason = "this crate is being loaded from the sysroot, and \
421 unstable location; did you mean to load this crate \
422 from crates.io via `Cargo.toml` instead?";
423 let stability = tcx.intern_stability(Stability {
424 level: attr::StabilityLevel::Unstable {
425 reason: Some(Symbol::intern(reason)),
428 feature: Symbol::intern("rustc_private"),
430 rustc_const_unstable: None,
432 annotator.parent_stab = Some(stability);
435 annotator.annotate(ast::CRATE_NODE_ID,
438 AnnotationKind::Required,
439 |v| intravisit::walk_crate(v, krate));
444 pub fn local_stability(&self, id: HirId) -> Option<&'tcx Stability> {
445 self.stab_map.get(&id).cloned()
448 pub fn local_deprecation_entry(&self, id: HirId) -> Option<DeprecationEntry> {
449 self.depr_map.get(&id).cloned()
453 /// Cross-references the feature names of unstable APIs with enabled
454 /// features and possibly prints errors.
455 pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
456 let mut checker = Checker { tcx: tcx };
457 tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
460 struct Checker<'a, 'tcx: 'a> {
461 tcx: TyCtxt<'a, 'tcx, 'tcx>,
464 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
465 // (See issue #38412)
466 fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool {
467 // Check if `def_id` is a trait method.
468 match self.describe_def(def_id) {
469 Some(Def::Method(_)) |
470 Some(Def::AssociatedTy(_)) |
471 Some(Def::AssociatedConst(_)) => {
472 match self.associated_item(def_id).container {
473 ty::TraitContainer(trait_def_id) => {
474 // Trait methods do not declare visibility (even
475 // for visibility info in cstore). Use containing
476 // trait instead, so methods of pub traits are
477 // themselves considered pub.
478 def_id = trait_def_id;
486 let visibility = self.visibility(def_id);
489 // must check stability for pub items.
490 ty::Visibility::Public => false,
492 // these are not visible outside crate; therefore
493 // stability markers are irrelevant, if even present.
494 ty::Visibility::Restricted(..) |
495 ty::Visibility::Invisible => true,
499 pub fn check_stability(self, def_id: DefId, id: NodeId, span: Span) {
500 if span.allows_unstable() {
502 skipping span={:?} since it is internal", span);
506 let lint_deprecated = |note: Option<Symbol>| {
507 let msg = if let Some(note) = note {
508 format!("use of deprecated item: {}", note)
510 format!("use of deprecated item")
513 self.lint_node(lint::builtin::DEPRECATED, id, span, &msg);
516 // Deprecated attributes apply in-crate and cross-crate.
517 if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
518 let skip = if id == ast::DUMMY_NODE_ID {
521 let parent_def_id = self.hir.local_def_id(self.hir.get_parent(id));
522 self.lookup_deprecation_entry(parent_def_id).map_or(false, |parent_depr| {
523 parent_depr.same_origin(&depr_entry)
528 lint_deprecated(depr_entry.attr.note);
532 let is_staged_api = self.lookup_stability(DefId {
533 index: CRATE_DEF_INDEX,
540 let stability = self.lookup_stability(def_id);
542 inspecting def_id={:?} span={:?} of stability={:?}", def_id, span, stability);
544 if let Some(&Stability{rustc_depr: Some(attr::RustcDeprecation { reason, .. }), ..})
546 if id != ast::DUMMY_NODE_ID {
547 lint_deprecated(Some(reason));
551 // Only the cross-crate scenario matters when checking unstable APIs
552 let cross_crate = !def_id.is_local();
557 // Issue 38412: private items lack stability markers.
558 if self.skip_stability_check_due_to_privacy(def_id) {
563 Some(&Stability { level: attr::Unstable {ref reason, issue}, ref feature, .. }) => {
564 if self.stability().active_features.contains(feature) {
568 // When we're compiling the compiler itself we may pull in
569 // crates from crates.io, but those crates may depend on other
570 // crates also pulled in from crates.io. We want to ideally be
571 // able to compile everything without requiring upstream
572 // modifications, so in the case that this looks like a
573 // rustc_private crate (e.g. a compiler crate) and we also have
574 // the `-Z force-unstable-if-unmarked` flag present (we're
575 // compiling a compiler crate), then let this missing feature
577 if *feature == "rustc_private" && issue == 27812 {
578 if self.sess.opts.debugging_opts.force_unstable_if_unmarked {
583 let msg = match *reason {
584 Some(ref r) => format!("use of unstable library feature '{}': {}",
585 feature.as_str(), &r),
586 None => format!("use of unstable library feature '{}'", &feature)
588 emit_feature_err(&self.sess.parse_sess, &feature.as_str(), span,
589 GateIssue::Library(Some(issue)), &msg);
592 // Stable APIs are always ok to call and deprecated APIs are
593 // handled by the lint emitting logic above.
596 span_bug!(span, "encountered unmarked API");
602 impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
603 /// Because stability levels are scoped lexically, we want to walk
604 /// nested items in the context of the outer item, so enable
606 fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
607 NestedVisitorMap::OnlyBodies(&self.tcx.hir)
610 fn visit_item(&mut self, item: &'tcx hir::Item) {
612 hir::ItemExternCrate(_) => {
613 // compiler-generated `extern crate` items have a dummy span.
614 if item.span == DUMMY_SP { return }
616 let def_id = self.tcx.hir.local_def_id(item.id);
617 let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) {
621 let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
622 self.tcx.check_stability(def_id, item.id, item.span);
625 // For implementations of traits, check the stability of each item
626 // individually as it's possible to have a stable trait with unstable
628 hir::ItemImpl(.., Some(ref t), _, ref impl_item_refs) => {
629 if let Def::Trait(trait_did) = t.path.def {
630 for impl_item_ref in impl_item_refs {
631 let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
632 let trait_item_def_id = self.tcx.associated_items(trait_did)
633 .find(|item| item.name == impl_item.name).map(|item| item.def_id);
634 if let Some(def_id) = trait_item_def_id {
635 // Pass `DUMMY_NODE_ID` to skip deprecation warnings.
636 self.tcx.check_stability(def_id, ast::DUMMY_NODE_ID, impl_item.span);
642 // There's no good place to insert stability check for non-Copy unions,
643 // so semi-randomly perform it here in stability.rs
644 hir::ItemUnion(..) if !self.tcx.sess.features.borrow().untagged_unions => {
645 let def_id = self.tcx.hir.local_def_id(item.id);
646 let adt_def = self.tcx.adt_def(def_id);
647 let ty = self.tcx.type_of(def_id);
649 if adt_def.has_dtor(self.tcx) {
650 emit_feature_err(&self.tcx.sess.parse_sess,
651 "untagged_unions", item.span, GateIssue::Language,
652 "unions with `Drop` implementations are unstable");
654 let param_env = self.tcx.param_env(def_id);
655 if !param_env.can_type_implement_copy(self.tcx, ty, item.span).is_ok() {
656 emit_feature_err(&self.tcx.sess.parse_sess,
657 "untagged_unions", item.span, GateIssue::Language,
658 "unions with non-`Copy` fields are unstable");
665 intravisit::walk_item(self, item);
668 fn visit_path(&mut self, path: &'tcx hir::Path, id: ast::NodeId) {
670 Def::Local(..) | Def::Upvar(..) |
671 Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => {}
672 _ => self.tcx.check_stability(path.def.def_id(), id, path.span)
674 intravisit::walk_path(self, path)
678 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
679 pub fn lookup_deprecation(self, id: DefId) -> Option<Deprecation> {
680 self.lookup_deprecation_entry(id).map(|depr| depr.attr)
684 /// Given the list of enabled features that were not language features (i.e. that
685 /// were expected to be library features), and the list of features used from
686 /// libraries, identify activated features that don't exist and error about them.
687 pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
688 let sess = &tcx.sess;
690 let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
692 if tcx.stability().staged_api[&LOCAL_CRATE] {
693 let krate = tcx.hir.krate();
694 let mut missing = MissingStabilityAnnotations {
698 missing.check_missing_stability(ast::CRATE_NODE_ID, krate.span);
699 intravisit::walk_crate(&mut missing, krate);
700 krate.visit_all_item_likes(&mut missing.as_deep_visitor());
703 let ref declared_lib_features = sess.features.borrow().declared_lib_features;
704 let mut remaining_lib_features: FxHashMap<Symbol, Span>
705 = declared_lib_features.clone().into_iter().collect();
706 remaining_lib_features.remove(&Symbol::intern("proc_macro"));
708 for &(ref stable_lang_feature, span) in &sess.features.borrow().declared_stable_lang_features {
709 let version = find_lang_feature_accepted_version(&stable_lang_feature.as_str())
710 .expect("unexpectedly couldn't find version feature was stabilized");
711 tcx.lint_node(lint::builtin::STABLE_FEATURES,
714 &format_stable_since_msg(version));
717 // FIXME(#44232) the `used_features` table no longer exists, so we don't
718 // lint about unknown or unused features. We should reenable
721 // let index = tcx.stability();
722 // for (used_lib_feature, level) in &index.used_features {
723 // remaining_lib_features.remove(used_lib_feature);
726 // for &span in remaining_lib_features.values() {
727 // tcx.lint_node(lint::builtin::UNUSED_FEATURES,
728 // ast::CRATE_NODE_ID,
730 // "unused or unknown feature");
734 fn format_stable_since_msg(version: &str) -> String {
735 format!("this feature has been stable since {}. Attribute no longer needed", version)