rustc: rework stability to be on-demand for type-directed lookup.

This commit is contained in:
Eduard Burtescu 2016-11-10 19:08:21 +02:00 committed by Eduard-Mihai Burtescu
parent f97c132cac
commit 9aaf26e7aa
97 changed files with 1775 additions and 859 deletions

View File

@ -37,8 +37,6 @@ TEMPLATE = """// Copyright {year} The Rust Project Developers. See the COPYRIGHT
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
{error_deriving}
struct Error;
{code}
@ -106,7 +104,6 @@ STRUCT = 2
ALL = STRUCT | ENUM
traits = {
'Zero': (STRUCT, [], 1),
'Default': (STRUCT, [], 1),
'FromPrimitive': (0, [], 0), # only works for C-like enums
@ -116,7 +113,7 @@ traits = {
for (trait, supers, errs) in [('Clone', [], 1),
('PartialEq', [], 2),
('PartialOrd', ['PartialEq'], 8),
('PartialOrd', ['PartialEq'], 9),
('Eq', ['PartialEq'], 1),
('Ord', ['Eq', 'PartialOrd', 'PartialEq'], 1),
('Debug', [], 1),

View File

@ -90,7 +90,7 @@ pub enum DepNode<D: Clone + Debug> {
RvalueCheck(D),
Reachability,
DeadCheck,
StabilityCheck,
StabilityCheck(D),
LateLintCheck,
TransCrate,
TransCrateItem(D),
@ -189,7 +189,6 @@ impl<D: Clone + Debug> DepNode<D> {
Privacy => Some(Privacy),
Reachability => Some(Reachability),
DeadCheck => Some(DeadCheck),
StabilityCheck => Some(StabilityCheck),
LateLintCheck => Some(LateLintCheck),
TransCrate => Some(TransCrate),
TransWriteMetadata => Some(TransWriteMetadata),
@ -217,6 +216,7 @@ impl<D: Clone + Debug> DepNode<D> {
Mir(ref d) => op(d).map(Mir),
BorrowCheck(ref d) => op(d).map(BorrowCheck),
RvalueCheck(ref d) => op(d).map(RvalueCheck),
StabilityCheck(ref d) => op(d).map(StabilityCheck),
TransCrateItem(ref d) => op(d).map(TransCrateItem),
TransInlinedItem(ref d) => op(d).map(TransInlinedItem),
AssociatedItems(ref d) => op(d).map(AssociatedItems),

View File

@ -1362,7 +1362,8 @@ impl<'a> LoweringContext<'a> {
} else {
let fields = fields.into_iter().map(|&(s, e)| {
let expr = P(this.lower_expr(&e));
this.field(Symbol::intern(s), expr, e.span)
let unstable_span = this.allow_internal_unstable("...", e.span);
this.field(Symbol::intern(s), expr, unstable_span)
}).collect();
let attrs = ast_expr.attrs.clone();

View File

@ -211,6 +211,12 @@ declare_lint! {
not named `mod.rs`"
}
declare_lint! {
pub DEPRECATED,
Warn,
"detects use of deprecated items"
}
/// Does nothing as a lint pass, but registers some `Lint`s
/// which are used by other parts of the compiler.
#[derive(Copy, Clone)]
@ -250,7 +256,8 @@ impl LintPass for HardwiredLints {
SAFE_EXTERN_STATICS,
PATTERNS_IN_FNS_WITHOUT_BODY,
EXTRA_REQUIREMENT_IN_IMPL,
LEGACY_DIRECTORY_OWNERSHIP
LEGACY_DIRECTORY_OWNERSHIP,
DEPRECATED
)
}
}

View File

@ -15,11 +15,10 @@ pub use self::StabilityLevel::*;
use dep_graph::DepNode;
use hir::map as hir_map;
use session::Session;
use lint;
use hir::def::Def;
use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, DefIndex, LOCAL_CRATE};
use ty::{self, TyCtxt, AdtKind};
use ty::TyCtxt;
use middle::privacy::AccessLevels;
use syntax::symbol::Symbol;
use syntax_pos::{Span, DUMMY_SP};
@ -30,9 +29,9 @@ use syntax::attr::{self, Stability, Deprecation};
use util::nodemap::{DefIdMap, FxHashSet, FxHashMap};
use hir;
use hir::{Item, Generics, StructField, Variant, PatKind};
use hir::{Item, Generics, StructField, Variant};
use hir::intravisit::{self, Visitor};
use hir::pat_util::EnumerateAndAdjustIterator;
use hir::itemlikevisit::DeepVisitor;
use std::mem::replace;
use std::cmp::Ordering;
@ -101,7 +100,13 @@ pub struct Index<'tcx> {
depr_map: DefIdMap<Option<DeprecationEntry>>,
/// Maps for each crate whether it is part of the staged API.
staged_api: FxHashMap<CrateNum, bool>
staged_api: FxHashMap<CrateNum, bool>,
/// Features enabled for this crate.
active_features: FxHashSet<Symbol>,
/// Features used by this crate. Updated before and during typeck.
used_features: FxHashMap<Symbol, attr::StabilityLevel>
}
// A private tree-walker for producing an Index.
@ -110,7 +115,6 @@ struct Annotator<'a, 'tcx: 'a> {
index: &'a mut Index<'tcx>,
parent_stab: Option<&'tcx Stability>,
parent_depr: Option<DeprecationEntry>,
access_levels: &'a AccessLevels,
in_trait_impl: bool,
}
@ -183,20 +187,12 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
self.parent_stab = orig_parent_stab;
} else {
debug!("annotate: not found, parent = {:?}", self.parent_stab);
let mut is_error = kind == AnnotationKind::Required &&
self.access_levels.is_reachable(id) &&
!self.tcx.sess.opts.test;
if let Some(stab) = self.parent_stab {
if stab.level.is_unstable() {
let def_id = self.tcx.map.local_def_id(id);
self.index.stab_map.insert(def_id, Some(stab));
is_error = false;
}
}
if is_error {
self.tcx.sess.span_err(item_sp, "This node does not have \
a stability attribute");
}
visit_children(self);
}
} else {
@ -313,9 +309,81 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
}
}
struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
access_levels: &'a AccessLevels,
}
impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
fn check_missing_stability(&self, id: NodeId, span: Span) {
let def_id = self.tcx.map.local_def_id(id);
let is_error = !self.tcx.sess.opts.test &&
!self.tcx.stability.borrow().stab_map.contains_key(&def_id) &&
self.access_levels.is_reachable(id);
if is_error {
self.tcx.sess.span_err(span, "This node does not have a stability attribute");
}
}
}
impl<'a, 'tcx, 'v> Visitor<'v> for MissingStabilityAnnotations<'a, 'tcx> {
fn visit_item(&mut self, i: &Item) {
match i.node {
// Inherent impls and foreign modules serve only as containers for other items,
// they don't have their own stability. They still can be annotated as unstable
// and propagate this unstability to children, but this annotation is completely
// optional. They inherit stability from their parents when unannotated.
hir::ItemImpl(.., None, _, _) | hir::ItemForeignMod(..) => {}
_ => self.check_missing_stability(i.id, i.span)
}
intravisit::walk_item(self, i)
}
fn visit_trait_item(&mut self, ti: &hir::TraitItem) {
self.check_missing_stability(ti.id, ti.span);
intravisit::walk_trait_item(self, ti);
}
fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
let impl_def_id = self.tcx.map.local_def_id(self.tcx.map.get_parent(ii.id));
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
self.check_missing_stability(ii.id, ii.span);
}
intravisit::walk_impl_item(self, ii);
}
fn visit_variant(&mut self, var: &Variant, g: &Generics, item_id: NodeId) {
self.check_missing_stability(var.node.data.id(), var.span);
intravisit::walk_variant(self, var, g, item_id);
}
fn visit_struct_field(&mut self, s: &StructField) {
self.check_missing_stability(s.id, s.span);
intravisit::walk_struct_field(self, s);
}
fn visit_foreign_item(&mut self, i: &hir::ForeignItem) {
self.check_missing_stability(i.id, i.span);
intravisit::walk_foreign_item(self, i);
}
fn visit_macro_def(&mut self, md: &hir::MacroDef) {
if md.imported_from.is_none() {
self.check_missing_stability(md.id, md.span);
}
}
}
impl<'a, 'tcx> Index<'tcx> {
/// Construct the stability index for a crate being compiled.
pub fn build(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: &AccessLevels) {
pub fn build(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features;
// Put the active features into a map for quick lookup
self.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect();
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
let krate = tcx.map.krate();
let mut annotator = Annotator {
@ -323,7 +391,6 @@ impl<'a, 'tcx> Index<'tcx> {
index: self,
parent_stab: None,
parent_depr: None,
access_levels: access_levels,
in_trait_impl: false,
};
annotator.annotate(ast::CRATE_NODE_ID, &krate.attrs, krate.span, AnnotationKind::Required,
@ -348,87 +415,118 @@ impl<'a, 'tcx> Index<'tcx> {
staged_api: staged_api,
stab_map: DefIdMap(),
depr_map: DefIdMap(),
active_features: FxHashSet(),
used_features: FxHashMap(),
}
}
}
/// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors. Returns a list of all
/// features used.
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
-> FxHashMap<Symbol, attr::StabilityLevel> {
let _task = tcx.dep_graph.in_task(DepNode::StabilityCheck);
let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features;
// Put the active features into a map for quick lookup
let active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect();
let mut checker = Checker {
tcx: tcx,
active_features: active_features,
used_features: FxHashMap(),
};
intravisit::walk_crate(&mut checker, tcx.map.krate());
checker.used_features
/// features and possibly prints errors.
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut checker = Checker { tcx: tcx };
tcx.visit_all_item_likes_in_krate(DepNode::StabilityCheck,
&mut DeepVisitor::new(&mut checker));
}
struct Checker<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
active_features: FxHashSet<Symbol>,
used_features: FxHashMap<Symbol, attr::StabilityLevel>,
}
impl<'a, 'tcx> Checker<'a, 'tcx> {
fn check(&mut self, id: DefId, span: Span,
stab: &Option<&Stability>, _depr: &Option<DeprecationEntry>) {
if !is_staged_api(self.tcx, id) {
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn check_stability(self, def_id: DefId, id: NodeId, span: Span) {
if self.sess.codemap().span_allows_unstable(span) {
debug!("stability: \
skipping span={:?} since it is internal", span);
return;
}
let lint_deprecated = |note: Option<Symbol>| {
let msg = if let Some(note) = note {
format!("use of deprecated item: {}", note)
} else {
format!("use of deprecated item")
};
self.sess.add_lint(lint::builtin::DEPRECATED, id, span, msg);
};
// Deprecated attributes apply in-crate and cross-crate.
if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
let skip = if id == ast::DUMMY_NODE_ID {
true
} else {
let parent_def_id = self.map.local_def_id(self.map.get_parent(id));
self.lookup_deprecation_entry(parent_def_id).map_or(false, |parent_depr| {
parent_depr.same_origin(&depr_entry)
})
};
if !skip {
lint_deprecated(depr_entry.attr.note);
}
}
let is_staged_api = *self.stability.borrow_mut().staged_api.entry(def_id.krate)
.or_insert_with(|| self.sess.cstore.is_staged_api(def_id.krate));
if !is_staged_api {
return;
}
let stability = self.lookup_stability(def_id);
debug!("stability: \
inspecting def_id={:?} span={:?} of stability={:?}", def_id, span, stability);
if let Some(&Stability{rustc_depr: Some(attr::RustcDeprecation { reason, .. }), ..})
= stability {
if id != ast::DUMMY_NODE_ID {
lint_deprecated(Some(reason));
}
}
// Only the cross-crate scenario matters when checking unstable APIs
let cross_crate = !id.is_local();
let cross_crate = !def_id.is_local();
if !cross_crate {
return
}
match *stab {
Some(&Stability { level: attr::Unstable {ref reason, issue}, ref feature, .. }) => {
self.used_features.insert(feature.clone(),
attr::Unstable { reason: reason.clone(), issue: issue });
if let Some(&Stability { ref level, ref feature, .. }) = stability {
self.stability.borrow_mut().used_features.insert(feature.clone(), level.clone());
}
if !self.active_features.contains(feature) {
match stability {
Some(&Stability { level: attr::Unstable {ref reason, issue}, ref feature, .. }) => {
if !self.stability.borrow().active_features.contains(feature) {
let msg = match *reason {
Some(ref r) => format!("use of unstable library feature '{}': {}",
&feature.as_str(), &r),
None => format!("use of unstable library feature '{}'", &feature)
};
emit_feature_err(&self.tcx.sess.parse_sess, &feature.as_str(), span,
emit_feature_err(&self.sess.parse_sess, &feature.as_str(), span,
GateIssue::Library(Some(issue)), &msg);
}
}
Some(&Stability { ref level, ref feature, .. }) => {
self.used_features.insert(feature.clone(), level.clone());
Some(_) => {
// Stable APIs are always ok to call and deprecated APIs are
// handled by a lint.
// handled by the lint emitting logic above.
}
None => {
// This is an 'unmarked' API, which should not exist
// in the standard library.
if self.tcx.sess.features.borrow().unmarked_api {
self.tcx.sess.struct_span_warn(span, "use of unmarked library feature")
.span_note(span, "this is either a bug in the library you are \
using or a bug in the compiler - please \
report it in both places")
.emit()
if self.sess.features.borrow().unmarked_api {
self.sess.struct_span_warn(span, "use of unmarked library feature")
.span_note(span, "this is either a bug in the library you are \
using or a bug in the compiler - please \
report it in both places")
.emit()
} else {
self.tcx.sess.struct_span_err(span, "use of unmarked library feature")
.span_note(span, "this is either a bug in the library you are \
using or a bug in the compiler - please \
report it in both places")
.span_note(span, "use #![feature(unmarked_api)] in the \
crate attributes to override this")
.emit()
self.sess.struct_span_err(span, "use of unmarked library feature")
.span_note(span, "this is either a bug in the library you are \
using or a bug in the compiler - please \
report it in both places")
.span_note(span, "use #![feature(unmarked_api)] in the \
crate attributes to override this")
.emit()
}
}
}
@ -436,249 +534,55 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
}
impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
/// Because stability levels are scoped lexically, we want to walk
/// nested items in the context of the outer item, so enable
/// deep-walking.
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
Some(&self.tcx.map)
}
fn visit_item(&mut self, item: &'tcx hir::Item) {
// When compiling with --test we don't enforce stability on the
// compiler-generated test module, demarcated with `DUMMY_SP` plus the
// name `__test`
if item.span == DUMMY_SP && item.name == "__test" { return }
match item.node {
hir::ItemExternCrate(_) => {
// compiler-generated `extern crate` items have a dummy span.
if item.span == DUMMY_SP { return }
check_item(self.tcx, item, true,
&mut |id, sp, stab, depr| self.check(id, sp, stab, depr));
let cnum = match self.tcx.sess.cstore.extern_mod_stmt_cnum(item.id) {
Some(cnum) => cnum,
None => return,
};
let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
self.tcx.check_stability(def_id, item.id, item.span);
}
// For implementations of traits, check the stability of each item
// individually as it's possible to have a stable trait with unstable
// items.
hir::ItemImpl(.., Some(ref t), _, ref impl_item_refs) => {
if let Def::Trait(trait_did) = t.path.def {
for impl_item_ref in impl_item_refs {
let impl_item = self.tcx.map.impl_item(impl_item_ref.id);
let trait_item_def_id = self.tcx.associated_items(trait_did)
.find(|item| item.name == impl_item.name).map(|item| item.def_id);
if let Some(def_id) = trait_item_def_id {
// Pass `DUMMY_NODE_ID` to skip deprecation warnings.
self.tcx.check_stability(def_id, ast::DUMMY_NODE_ID, impl_item.span);
}
}
}
}
_ => (/* pass */)
}
intravisit::walk_item(self, item);
}
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
check_expr(self.tcx, ex,
&mut |id, sp, stab, depr| self.check(id, sp, stab, depr));
intravisit::walk_expr(self, ex);
}
fn visit_path(&mut self, path: &'tcx hir::Path, _: ast::NodeId) {
check_path(self.tcx, path,
&mut |id, sp, stab, depr| self.check(id, sp, stab, depr));
fn visit_path(&mut self, path: &'tcx hir::Path, id: ast::NodeId) {
match path.def {
Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => {}
_ => self.tcx.check_stability(path.def.def_id(), id, path.span)
}
intravisit::walk_path(self, path)
}
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
check_pat(self.tcx, pat,
&mut |id, sp, stab, depr| self.check(id, sp, stab, depr));
intravisit::walk_pat(self, pat)
}
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
check_ty(self.tcx, ty,
&mut |id, sp, stab, depr| self.check(id, sp, stab, depr));
intravisit::walk_ty(self, ty)
}
}
/// Helper for discovering nodes to check for stability
pub fn check_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
item: &hir::Item,
warn_about_defns: bool,
cb: &mut FnMut(DefId, Span,
&Option<&Stability>,
&Option<DeprecationEntry>)) {
match item.node {
hir::ItemExternCrate(_) => {
// compiler-generated `extern crate` items have a dummy span.
if item.span == DUMMY_SP { return }
let cnum = match tcx.sess.cstore.extern_mod_stmt_cnum(item.id) {
Some(cnum) => cnum,
None => return,
};
let id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
maybe_do_stability_check(tcx, id, item.span, cb);
}
// For implementations of traits, check the stability of each item
// individually as it's possible to have a stable trait with unstable
// items.
hir::ItemImpl(.., Some(ref t), _, ref impl_item_refs) => {
let trait_did = t.path.def.def_id();
for impl_item_ref in impl_item_refs {
let impl_item = tcx.map.impl_item(impl_item_ref.id);
let item = tcx.associated_items(trait_did)
.find(|item| item.name == impl_item.name).unwrap();
if warn_about_defns {
maybe_do_stability_check(tcx, item.def_id, impl_item.span, cb);
}
}
}
_ => (/* pass */)
}
}
/// Helper for discovering nodes to check for stability
pub fn check_expr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, e: &hir::Expr,
cb: &mut FnMut(DefId, Span,
&Option<&Stability>,
&Option<DeprecationEntry>)) {
let span;
let id = match e.node {
hir::ExprMethodCall(i, ..) => {
span = i.span;
let method_call = ty::MethodCall::expr(e.id);
tcx.tables().method_map[&method_call].def_id
}
hir::ExprPath(ref qpath @ hir::QPath::TypeRelative(..)) => {
span = e.span;
tcx.tables().qpath_def(qpath, e.id).def_id()
}
hir::ExprField(ref base_e, ref field) => {
span = field.span;
match tcx.tables().expr_ty_adjusted(base_e).sty {
ty::TyAdt(def, _) => {
def.struct_variant().field_named(field.node).did
}
_ => span_bug!(e.span,
"stability::check_expr: named field access on non-ADT")
}
}
hir::ExprTupField(ref base_e, ref field) => {
span = field.span;
match tcx.tables().expr_ty_adjusted(base_e).sty {
ty::TyAdt(def, _) => {
def.struct_variant().fields[field.node].did
}
ty::TyTuple(..) => return,
_ => span_bug!(e.span,
"stability::check_expr: unnamed field access on \
something other than a tuple or struct")
}
}
hir::ExprStruct(_, ref expr_fields, _) => {
match tcx.tables().expr_ty(e).sty {
ty::TyAdt(adt, ..) => match adt.adt_kind() {
AdtKind::Struct | AdtKind::Union => {
// check the stability of each field that appears
// in the construction expression.
for field in expr_fields {
let did = adt.struct_variant().field_named(field.name.node).did;
maybe_do_stability_check(tcx, did, field.span, cb);
}
// we're done.
return
}
AdtKind::Enum => {
// we don't look at stability attributes on
// struct-like enums (yet...), but it's definitely not
// a bug to have construct one.
return
}
},
ref ty => span_bug!(e.span, "stability::check_expr: struct \
construction of non-ADT type: {:?}", ty)
}
}
_ => return
};
maybe_do_stability_check(tcx, id, span, cb);
}
pub fn check_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
path: &hir::Path,
cb: &mut FnMut(DefId, Span,
&Option<&Stability>,
&Option<DeprecationEntry>)) {
match path.def {
Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => {}
_ => maybe_do_stability_check(tcx, path.def.def_id(), path.span, cb)
}
}
pub fn check_pat<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &hir::Pat,
cb: &mut FnMut(DefId, Span,
&Option<&Stability>,
&Option<DeprecationEntry>)) {
debug!("check_pat(pat = {:?})", pat);
if is_internal(tcx, pat.span) { return; }
if let PatKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) = pat.node {
let def_id = tcx.tables().qpath_def(qpath, pat.id).def_id();
maybe_do_stability_check(tcx, def_id, pat.span, cb)
}
let v = match tcx.tables().pat_ty_opt(pat).map(|ty| &ty.sty) {
Some(&ty::TyAdt(adt, _)) if !adt.is_enum() => adt.struct_variant(),
_ => return,
};
match pat.node {
// Foo(a, b, c)
PatKind::TupleStruct(_, ref pat_fields, ddpos) => {
for (i, field) in pat_fields.iter().enumerate_and_adjust(v.fields.len(), ddpos) {
maybe_do_stability_check(tcx, v.fields[i].did, field.span, cb)
}
}
// Foo { a, b, c }
PatKind::Struct(_, ref pat_fields, _) => {
for field in pat_fields {
let did = v.field_named(field.node.name).did;
maybe_do_stability_check(tcx, did, field.span, cb);
}
}
// everything else is fine.
_ => {}
}
}
pub fn check_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: &hir::Ty,
cb: &mut FnMut(DefId, Span,
&Option<&Stability>,
&Option<DeprecationEntry>)) {
debug!("check_ty(ty = {:?})", ty);
if is_internal(tcx, ty.span) { return; }
if let hir::TyPath(hir::QPath::TypeRelative(..)) = ty.node {
let def_id = tcx.tables().type_relative_path_defs[&ty.id].def_id();
maybe_do_stability_check(tcx, def_id, ty.span, cb);
}
}
fn maybe_do_stability_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: DefId, span: Span,
cb: &mut FnMut(DefId, Span,
&Option<&Stability>,
&Option<DeprecationEntry>)) {
if is_internal(tcx, span) {
debug!("maybe_do_stability_check: \
skipping span={:?} since it is internal", span);
return;
}
let (stability, deprecation) = if is_staged_api(tcx, id) {
(tcx.lookup_stability(id), None)
} else {
(None, tcx.lookup_deprecation_entry(id))
};
debug!("maybe_do_stability_check: \
inspecting id={:?} span={:?} of stability={:?}", id, span, stability);
cb(id, span, &stability, &deprecation);
}
fn is_internal<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span) -> bool {
tcx.sess.codemap().span_allows_unstable(span)
}
fn is_staged_api<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> bool {
*tcx.stability.borrow_mut().staged_api.entry(id.krate).or_insert_with(
|| tcx.sess.cstore.is_staged_api(id.krate))
}
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Lookup the stability for a node, loading external crate
/// metadata as necessary.
pub fn lookup_stability(self, id: DefId) -> Option<&'tcx Stability> {
pub fn lookup_stability(self, id: DefId) -> Option<&'gcx Stability> {
if let Some(st) = self.stability.borrow().stab_map.get(&id) {
return *st;
}
@ -702,7 +606,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
depr
}
fn lookup_stability_uncached(self, id: DefId) -> Option<&'tcx Stability> {
fn lookup_stability_uncached(self, id: DefId) -> Option<&'gcx Stability> {
debug!("lookup(id={:?})", id);
if id.is_local() {
None // The stability cache is filled partially lazily
@ -724,9 +628,22 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
/// Given the list of enabled features that were not language features (i.e. that
/// were expected to be library features), and the list of features used from
/// libraries, identify activated features that don't exist and error about them.
pub fn check_unused_or_stable_features(sess: &Session,
lib_features_used: &FxHashMap<Symbol,
attr::StabilityLevel>) {
pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
access_levels: &AccessLevels) {
let sess = &tcx.sess;
if tcx.stability.borrow().staged_api[&LOCAL_CRATE] && tcx.sess.features.borrow().staged_api {
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
let krate = tcx.map.krate();
let mut missing = MissingStabilityAnnotations {
tcx: tcx,
access_levels: access_levels,
};
missing.check_missing_stability(ast::CRATE_NODE_ID, krate.span);
intravisit::walk_crate(&mut missing, krate);
krate.visit_all_item_likes(&mut DeepVisitor::new(&mut missing));
}
let ref declared_lib_features = sess.features.borrow().declared_lib_features;
let mut remaining_lib_features: FxHashMap<Symbol, Span>
= declared_lib_features.clone().into_iter().collect();
@ -744,7 +661,8 @@ pub fn check_unused_or_stable_features(sess: &Session,
format_stable_since_msg(version));
}
for (used_lib_feature, level) in lib_features_used {
let index = tcx.stability.borrow();
for (used_lib_feature, level) in &index.used_features {
match remaining_lib_features.remove(used_lib_feature) {
Some(span) => {
if let &attr::StabilityLevel::Stable { since: ref version } = level {

View File

@ -886,6 +886,14 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
"load_dep_graph",
|| rustc_incremental::load_dep_graph(tcx, &incremental_hashes_map));
time(time_passes, "stability index", || {
tcx.stability.borrow_mut().build(tcx)
});
time(time_passes,
"stability checking",
|| stability::check_unstable_api_usage(tcx));
// passes are timed inside typeck
analysis.hir_ty_to_ty =
try_with_f!(typeck::check_crate(tcx), (tcx, analysis, incremental_hashes_map));
@ -899,11 +907,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
rustc_privacy::check_crate(tcx, &analysis.export_map)
});
// Do not move this check past lint
time(time_passes, "stability index", || {
tcx.stability.borrow_mut().build(tcx, &analysis.access_levels)
});
time(time_passes,
"intrinsic checking",
|| middle::intrinsicck::check_crate(tcx));
@ -972,14 +975,8 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
middle::dead::check_crate(tcx, &analysis.access_levels);
});
let ref lib_features_used =
time(time_passes,
"stability checking",
|| stability::check_unstable_api_usage(tcx));
time(time_passes, "unused lib feature checking", || {
stability::check_unused_or_stable_features(&tcx.sess,
lib_features_used)
stability::check_unused_or_stable_features(tcx, &analysis.access_levels)
});
time(time_passes,

View File

@ -30,14 +30,13 @@
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use middle::stability;
use rustc::cfg;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::traits::{self, Reveal};
use rustc::hir::map as hir_map;
use util::nodemap::NodeSet;
use lint::{Level, LateContext, LintContext, LintArray, Lint};
use lint::{Level, LateContext, LintContext, LintArray};
use lint::{LintPass, LateLintPass, EarlyLintPass, EarlyContext};
use std::collections::HashSet;
@ -45,7 +44,6 @@ use std::collections::HashSet;
use syntax::ast;
use syntax::attr;
use syntax::feature_gate::{AttributeGate, AttributeType, Stability, deprecated_attributes};
use syntax::symbol::Symbol;
use syntax_pos::Span;
use rustc::hir::{self, PatKind};
@ -607,139 +605,6 @@ impl LateLintPass for MissingDebugImplementations {
}
}
declare_lint! {
DEPRECATED,
Warn,
"detects use of deprecated items"
}
/// Checks for use of items with `#[deprecated]` or `#[rustc_deprecated]` attributes
#[derive(Clone)]
pub struct Deprecated {
/// Tracks the `NodeId` of the current item.
///
/// This is required since not all node ids are present in the hir map.
current_item: ast::NodeId,
}
impl Deprecated {
pub fn new() -> Deprecated {
Deprecated { current_item: ast::CRATE_NODE_ID }
}
fn lint(&self,
cx: &LateContext,
_id: DefId,
span: Span,
stability: &Option<&attr::Stability>,
deprecation: &Option<stability::DeprecationEntry>) {
// Deprecated attributes apply in-crate and cross-crate.
if let Some(&attr::Stability{rustc_depr: Some(attr::RustcDeprecation{reason, ..}), ..})
= *stability {
output(cx, DEPRECATED, span, Some(reason))
} else if let Some(ref depr_entry) = *deprecation {
if let Some(parent_depr) = cx.tcx.lookup_deprecation_entry(self.parent_def(cx)) {
if parent_depr.same_origin(depr_entry) {
return;
}
}
output(cx, DEPRECATED, span, depr_entry.attr.note)
}
fn output(cx: &LateContext, lint: &'static Lint, span: Span, note: Option<Symbol>) {
let msg = if let Some(note) = note {
format!("use of deprecated item: {}", note)
} else {
format!("use of deprecated item")
};
cx.span_lint(lint, span, &msg);
}
}
fn push_item(&mut self, item_id: ast::NodeId) {
self.current_item = item_id;
}
fn item_post(&mut self, cx: &LateContext, item_id: ast::NodeId) {
assert_eq!(self.current_item, item_id);
self.current_item = cx.tcx.map.get_parent(item_id);
}
fn parent_def(&self, cx: &LateContext) -> DefId {
cx.tcx.map.local_def_id(self.current_item)
}
}
impl LintPass for Deprecated {
fn get_lints(&self) -> LintArray {
lint_array!(DEPRECATED)
}
}
impl LateLintPass for Deprecated {
fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
self.push_item(item.id);
stability::check_item(cx.tcx,
item,
false,
&mut |id, sp, stab, depr| self.lint(cx, id, sp, &stab, &depr));
}
fn check_item_post(&mut self, cx: &LateContext, item: &hir::Item) {
self.item_post(cx, item.id);
}
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
stability::check_expr(cx.tcx,
e,
&mut |id, sp, stab, depr| self.lint(cx, id, sp, &stab, &depr));
}
fn check_path(&mut self, cx: &LateContext, path: &hir::Path, _: ast::NodeId) {
stability::check_path(cx.tcx,
path,
&mut |id, sp, stab, depr| self.lint(cx, id, sp, &stab, &depr));
}
fn check_pat(&mut self, cx: &LateContext, pat: &hir::Pat) {
stability::check_pat(cx.tcx,
pat,
&mut |id, sp, stab, depr| self.lint(cx, id, sp, &stab, &depr));
}
fn check_ty(&mut self, cx: &LateContext, ty: &hir::Ty) {
stability::check_ty(cx.tcx, ty,
&mut |id, sp, stab, depr|
self.lint(cx, id, sp, &stab, &depr));
}
fn check_impl_item(&mut self, _: &LateContext, item: &hir::ImplItem) {
self.push_item(item.id);
}
fn check_impl_item_post(&mut self, cx: &LateContext, item: &hir::ImplItem) {
self.item_post(cx, item.id);
}
fn check_trait_item(&mut self, _: &LateContext, item: &hir::TraitItem) {
self.push_item(item.id);
}
fn check_trait_item_post(&mut self, cx: &LateContext, item: &hir::TraitItem) {
self.item_post(cx, item.id);
}
fn check_foreign_item(&mut self, _: &LateContext, item: &hir::ForeignItem) {
self.push_item(item.id);
}
fn check_foreign_item_post(&mut self, cx: &LateContext, item: &hir::ForeignItem) {
self.item_post(cx, item.id);
}
}
declare_lint! {
DEPRECATED_ATTR,
Warn,

View File

@ -145,7 +145,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
);
add_builtin_with_new!(sess,
Deprecated,
TypeLimits,
MissingDoc,
MissingDebugImplementations,

View File

@ -1258,6 +1258,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
// Will fail except for T::A and Self::A; i.e., if ty/ty_path_def are not a type
// parameter or Self.
pub fn associated_path_def_to_ty(&self,
ref_id: ast::NodeId,
span: Span,
ty: Ty<'tcx>,
ty_path_def: Def,
@ -1339,7 +1340,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
let ty = self.projected_ty_from_poly_trait_ref(span, bound, assoc_name);
let item = tcx.associated_items(trait_did).find(|i| i.name == assoc_name);
(ty, Def::AssociatedTy(item.expect("missing associated type").def_id))
let def_id = item.expect("missing associated type").def_id;
tcx.check_stability(def_id, ref_id, span);
(ty, Def::AssociatedTy(def_id))
}
fn qpath_to_ty(&self,
@ -1659,7 +1662,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
} else {
Def::Err
};
let (ty, def) = self.associated_path_def_to_ty(ast_ty.span, ty, def, segment);
let (ty, def) = self.associated_path_def_to_ty(ast_ty.id, ast_ty.span,
ty, def, segment);
// Write back the new resolution.
tcx.tables.borrow_mut().type_relative_path_defs.insert(ast_ty.id, def);

View File

@ -508,7 +508,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.demand_eqtype(pat.span, expected, pat_ty);
// Type check subpatterns.
self.check_struct_pat_fields(pat_ty, pat.span, variant, fields, etc);
self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc);
pat_ty
}
@ -603,6 +603,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
for (i, subpat) in subpats.iter().enumerate_and_adjust(variant.fields.len(), ddpos) {
let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
self.check_pat(&subpat, field_ty);
self.tcx.check_stability(variant.fields[i].did, pat.id, subpat.span);
}
} else {
let subpats_ending = if subpats.len() == 1 { "" } else { "s" };
@ -622,6 +624,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
fn check_struct_pat_fields(&self,
adt_ty: Ty<'tcx>,
pat_id: ast::NodeId,
span: Span,
variant: ty::VariantDef<'tcx>,
fields: &'gcx [Spanned<hir::FieldPat>],
@ -659,7 +662,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
Vacant(vacant) => {
vacant.insert(span);
field_map.get(&field.name)
.map(|f| self.field_ty(span, f, substs))
.map(|f| {
self.tcx.check_stability(f.did, pat_id, span);
self.field_ty(span, f, substs)
})
.unwrap_or_else(|| {
struct_span_err!(tcx.sess, span, E0026,
"{} `{}` does not have a field named `{}`",

View File

@ -136,6 +136,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.tcx.used_trait_imports.borrow_mut().insert(import_id);
}
self.tcx.check_stability(pick.item.def_id, call_expr.id, span);
Ok(self.confirm_method(span,
self_expr,
call_expr,
@ -340,6 +342,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
let def = pick.item.def();
self.tcx.check_stability(def.def_id(), expr_id, span);
if let probe::InherentImplPick = pick.kind {
if !pick.item.vis.is_accessible_from(self.body_id, &self.tcx.map) {
let msg = format!("{} `{}` is private", def.kind_name(), method_name);

View File

@ -2998,6 +2998,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if field.vis.is_accessible_from(self.body_id, &self.tcx().map) {
autoderef.finalize(lvalue_pref, Some(base));
self.write_autoderef_adjustment(base.id, autoderefs, base_t);
self.tcx.check_stability(field.did, expr.id, expr.span);
return field_ty;
}
private_candidate = Some((base_def.did, field_ty));
@ -3100,6 +3103,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let field_ty = self.field_ty(expr.span, field, substs);
private_candidate = Some((base_def.did, field_ty));
if field.vis.is_accessible_from(self.body_id, &self.tcx().map) {
self.tcx.check_stability(field.did, expr.id, expr.span);
Some(field_ty)
} else {
None
@ -3192,13 +3196,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
fn check_expr_struct_fields(&self,
adt_ty: Ty<'tcx>,
expr_id: ast::NodeId,
span: Span,
variant: ty::VariantDef<'tcx>,
ast_fields: &'gcx [hir::Field],
check_completeness: bool) {
let tcx = self.tcx;
let (substs, kind_name) = match adt_ty.sty {
ty::TyAdt(adt, substs) => (substs, adt.variant_descr()),
let (substs, adt_kind, kind_name) = match adt_ty.sty {
ty::TyAdt(adt, substs) => (substs, adt.adt_kind(), adt.variant_descr()),
_ => span_bug!(span, "non-ADT passed to check_expr_struct_fields")
};
@ -3219,6 +3224,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
expected_field_type = self.field_ty(field.span, v_field, substs);
seen_fields.insert(field.name.node, field.span);
// we don't look at stability attributes on
// struct-like enums (yet...), but it's definitely not
// a bug to have construct one.
if adt_kind != ty::AdtKind::Enum {
tcx.check_stability(v_field.did, expr_id, field.span);
}
} else {
error_happened = true;
expected_field_type = tcx.types.err;
@ -3381,7 +3393,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
hir::QPath::TypeRelative(ref qself, _) => qself.span
};
self.check_expr_struct_fields(struct_ty, path_span, variant, fields,
self.check_expr_struct_fields(struct_ty, expr.id, path_span, variant, fields,
base_expr.is_none());
if let &Some(ref base_expr) = base_expr {
self.check_expr_has_type(base_expr, struct_ty);
@ -4012,7 +4024,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} else {
Def::Err
};
let (ty, def) = AstConv::associated_path_def_to_ty(self, path_span,
let (ty, def) = AstConv::associated_path_def_to_ty(self, node_id, path_span,
ty, def, segment);
// Write back the new resolution.

View File

@ -307,7 +307,7 @@ fn generate_test_harness(sess: &ParseSess,
/// The expanded code calls some unstable functions in the test crate.
fn ignored_span(cx: &TestCtxt, sp: Span) -> Span {
let info = ExpnInfo {
call_site: DUMMY_SP,
call_site: sp,
callee: NameAndSpan {
format: MacroAttribute(Symbol::intern("test")),
span: None,
@ -460,6 +460,7 @@ mod __test {
fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
let id_test = Ident::from_str("test");
let sp = ignored_span(cx, DUMMY_SP);
let (vi, vis, ident) = if cx.is_test_crate {
(ast::ItemKind::Use(
P(nospan(ast::ViewPathSimple(id_test,
@ -474,7 +475,7 @@ fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
node: vi,
attrs: vec![],
vis: vis,
span: DUMMY_SP
span: sp
})
}
@ -598,7 +599,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
// FIXME #15962: should be using quote_item, but that stringifies
// __test_reexports, causing it to be reinterned, losing the
// gensym information.
let sp = DUMMY_SP;
let sp = ignored_span(cx, DUMMY_SP);
let ecx = &cx.ext_cx;
let struct_type = ecx.ty_path(ecx.path(sp, vec![ecx.ident_of("self"),
ecx.ident_of("test"),

View File

@ -16,7 +16,7 @@
// which is a reduction of this code to more directly show the reason
// for the error message we see here.)
#![feature(const_fn)]
#![feature(const_fn, rustc_private)]
extern crate arena;

View File

@ -19,6 +19,8 @@
// (Also compare against dropck_tarena_cycle_checked.rs, from which
// this was reduced to better understand its error message.)
#![feature(rustc_private)]
extern crate arena;
use arena::TypedArena;

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
#![feature(proc_macro, proc_macro_lib)]
extern crate proc_macro;

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
#![feature(proc_macro, proc_macro_lib)]
extern crate proc_macro;

View File

@ -11,7 +11,7 @@
// no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
#![feature(proc_macro, proc_macro_lib)]
extern crate proc_macro;

View File

@ -11,7 +11,7 @@
// compile-flags: --test
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
#![feature(proc_macro, proc_macro_lib)]
extern crate proc_macro;

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(proc_macro)]
#![feature(proc_macro, proc_macro_lib)]
extern crate proc_macro;

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
#![feature(proc_macro, proc_macro_lib)]
extern crate proc_macro;

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
#![feature(proc_macro, proc_macro_lib)]
#![allow(warnings)]
extern crate proc_macro;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(collections)]
extern crate collections;
//~^ NOTE previous import of `collections` here

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(collections, libc)]
extern crate collections;
//~^ NOTE previous import of `collections` here

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(collections)]
extern crate collections;
//~^ NOTE previous import of `collections` here

View File

@ -12,7 +12,6 @@
#![feature(box_syntax)]
extern crate collections;
use std::collections::HashMap;
fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(fn_traits)]
// Ensure that invoking a closure counts as a unique immutable borrow
type Fn<'a> = Box<FnMut() + 'a>;

View File

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate collections;
use std::collections::HashSet;
struct Foo {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
#![feature(fn_traits, unboxed_closures)]
use std::ops::{Fn, FnMut, FnOnce};

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(Eq,PartialOrd,PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(Eq,PartialOrd,PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(Eq,PartialOrd,PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(Eq,PartialOrd,PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(PartialEq)]
struct Error;

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -10,8 +10,6 @@
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
extern crate rand;
#[derive(PartialEq)]
struct Error;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(core_intrinsics)]
use std::intrinsics::{init, forget};
// Test that the `forget` and `init` intrinsics are really unsafe

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
#![feature(fn_traits, unboxed_closures)]
use std::{fmt, ops};

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(fn_traits)]
pub fn foo<'a, F: Fn(&'a ())>(bar: F) {
bar.call((
&(), //~ ERROR borrowed value does not live long enough

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
#![feature(fn_traits, unboxed_closures)]
struct Foo;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(libc)]
extern crate libc;
fn main() {

View File

@ -8,7 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(core)]
#![feature(core, fnbox)]
use std::boxed::FnBox;
struct FuncContainer {

View File

@ -17,7 +17,6 @@
extern crate lint_stability;
use lint_stability::{unstable, deprecated}; //~ ERROR use of unstable library feature 'test_feature'
//~^ WARNING use of deprecated item
use lint_stability::unstable::{self as u}; //~ ERROR use of unstable library feature 'test_feature'

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rand)]
fn main() {
extern crate rand;
use rand::Rng; //~ ERROR unresolved import

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(fn_traits)]
fn id<T>(t: T) -> T { t }
fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {

View File

@ -0,0 +1,25 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -F unused_features
// aux-build:lint_output_format.rs
#![feature(foo)] //~ ERROR unused or unknown feature
#![feature(test_feature)]
extern crate lint_output_format;
use lint_output_format::{foo, bar};
//~^ WARNING use of deprecated item: text,
fn main() {
let _x = foo(); //~ WARNING #[warn(deprecated)] on by default
let _y = bar();
}

View File

@ -11,13 +11,12 @@
// compile-flags: -F unused_features
// aux-build:lint_output_format.rs
#![feature(foo)] //~ ERROR unused or unknown feature
#![allow(deprecated)]
extern crate lint_output_format; //~ ERROR use of unstable library feature
use lint_output_format::{foo, bar}; //~ ERROR use of unstable library feature
//~^ WARNING use of deprecated item: text,
fn main() {
let _x = foo(); //~ WARNING #[warn(deprecated)] on by default
let _x = foo();
let _y = bar(); //~ ERROR use of unstable library feature
}

View File

@ -0,0 +1,423 @@
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:lint_stability.rs
// aux-build:stability_cfg1.rs
#![allow(deprecated)]
#![allow(dead_code)]
#![feature(staged_api)]
#![stable(feature = "rust1", since = "1.0.0")]
#[macro_use]
extern crate lint_stability;
mod cross_crate {
extern crate stability_cfg1;
use lint_stability::*;
fn test() {
type Foo = MethodTester;
let foo = MethodTester;
deprecated();
foo.method_deprecated();
Foo::method_deprecated(&foo);
<Foo>::method_deprecated(&foo);
foo.trait_deprecated();
Trait::trait_deprecated(&foo);
<Foo>::trait_deprecated(&foo);
<Foo as Trait>::trait_deprecated(&foo);
deprecated_text();
foo.method_deprecated_text();
Foo::method_deprecated_text(&foo);
<Foo>::method_deprecated_text(&foo);
foo.trait_deprecated_text();
Trait::trait_deprecated_text(&foo);
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
foo.method_deprecated_unstable();
//~^ ERROR use of unstable library feature
Foo::method_deprecated_unstable(&foo);
//~^ ERROR use of unstable library feature
<Foo>::method_deprecated_unstable(&foo);
//~^ ERROR use of unstable library feature
foo.trait_deprecated_unstable();
//~^ ERROR use of unstable library feature
<Foo>::trait_deprecated_unstable(&foo);
//~^ ERROR use of unstable library feature
foo.method_deprecated_unstable_text();
//~^ ERROR use of unstable library feature
Foo::method_deprecated_unstable_text(&foo);
//~^ ERROR use of unstable library feature
<Foo>::method_deprecated_unstable_text(&foo);
//~^ ERROR use of unstable library feature
foo.trait_deprecated_unstable_text();
//~^ ERROR use of unstable library feature
<Foo>::trait_deprecated_unstable_text(&foo);
//~^ ERROR use of unstable library feature
foo.method_unstable(); //~ ERROR use of unstable library feature
Foo::method_unstable(&foo); //~ ERROR use of unstable library feature
<Foo>::method_unstable(&foo); //~ ERROR use of unstable library feature
foo.trait_unstable(); //~ ERROR use of unstable library feature
<Foo>::trait_unstable(&foo); //~ ERROR use of unstable library feature
foo.method_unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
Foo::method_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
<Foo>::method_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
foo.trait_unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
<Foo>::trait_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
stable();
foo.method_stable();
Foo::method_stable(&foo);
<Foo>::method_stable(&foo);
foo.trait_stable();
Trait::trait_stable(&foo);
<Foo>::trait_stable(&foo);
<Foo as Trait>::trait_stable(&foo);
stable_text();
foo.method_stable_text();
Foo::method_stable_text(&foo);
<Foo>::method_stable_text(&foo);
foo.trait_stable_text();
Trait::trait_stable_text(&foo);
<Foo>::trait_stable_text(&foo);
<Foo as Trait>::trait_stable_text(&foo);
struct S2<T: TraitWithAssociatedTypes>(T::TypeDeprecated);
let _ = DeprecatedStruct {
i: 0
};
let _ = StableStruct { i: 0 };
let _ = DeprecatedUnitStruct;
let _ = StableUnitStruct;
let _ = Enum::DeprecatedVariant;
let _ = Enum::StableVariant;
let _ = DeprecatedTupleStruct (1);
let _ = StableTupleStruct (1);
// At the moment, the lint checker only checks stability in
// in the arguments of macros.
// Eventually, we will want to lint the contents of the
// macro in the module *defining* it. Also, stability levels
// on macros themselves are not yet linted.
macro_test_arg!(deprecated_text());
macro_test_arg!(macro_test_arg!(deprecated_text()));
}
fn test_method_param<Foo: Trait>(foo: Foo) {
foo.trait_deprecated();
Trait::trait_deprecated(&foo);
<Foo>::trait_deprecated(&foo);
<Foo as Trait>::trait_deprecated(&foo);
foo.trait_deprecated_text();
Trait::trait_deprecated_text(&foo);
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
foo.trait_deprecated_unstable();
//~^ ERROR use of unstable library feature
<Foo>::trait_deprecated_unstable(&foo);
//~^ ERROR use of unstable library feature
foo.trait_deprecated_unstable_text();
//~^ ERROR use of unstable library feature
<Foo>::trait_deprecated_unstable_text(&foo);
//~^ ERROR use of unstable library feature
foo.trait_unstable(); //~ ERROR use of unstable library feature
<Foo>::trait_unstable(&foo); //~ ERROR use of unstable library feature
foo.trait_unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
<Foo>::trait_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
foo.trait_stable();
Trait::trait_stable(&foo);
<Foo>::trait_stable(&foo);
<Foo as Trait>::trait_stable(&foo);
}
fn test_method_object(foo: &Trait) {
foo.trait_deprecated();
foo.trait_deprecated_text();
foo.trait_deprecated_unstable();
//~^ ERROR use of unstable library feature
foo.trait_deprecated_unstable_text();
//~^ ERROR use of unstable library feature
foo.trait_unstable(); //~ ERROR use of unstable library feature
foo.trait_unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
foo.trait_stable();
}
struct S;
impl DeprecatedTrait for S {}
trait LocalTrait2 : DeprecatedTrait { }
}
mod this_crate {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn deprecated() {}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn deprecated_text() {}
#[unstable(feature = "test_feature", issue = "0")]
pub fn unstable() {}
#[unstable(feature = "test_feature", reason = "text", issue = "0")]
pub fn unstable_text() {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn stable() {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn stable_text() {}
#[stable(feature = "rust1", since = "1.0.0")]
pub struct MethodTester;
impl MethodTester {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn method_deprecated(&self) {}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn method_deprecated_text(&self) {}
#[unstable(feature = "test_feature", issue = "0")]
pub fn method_unstable(&self) {}
#[unstable(feature = "test_feature", reason = "text", issue = "0")]
pub fn method_unstable_text(&self) {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn method_stable(&self) {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn method_stable_text(&self) {}
}
pub trait Trait {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn trait_deprecated(&self) {}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn trait_deprecated_text(&self) {}
#[unstable(feature = "test_feature", issue = "0")]
fn trait_unstable(&self) {}
#[unstable(feature = "test_feature", reason = "text", issue = "0")]
fn trait_unstable_text(&self) {}
#[stable(feature = "rust1", since = "1.0.0")]
fn trait_stable(&self) {}
#[stable(feature = "rust1", since = "1.0.0")]
fn trait_stable_text(&self) {}
}
impl Trait for MethodTester {}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub struct DeprecatedStruct {
#[stable(feature = "test_feature", since = "1.0.0")] i: isize
}
#[unstable(feature = "test_feature", issue = "0")]
pub struct UnstableStruct {
#[stable(feature = "test_feature", since = "1.0.0")] i: isize
}
#[stable(feature = "rust1", since = "1.0.0")]
pub struct StableStruct {
#[stable(feature = "test_feature", since = "1.0.0")] i: isize
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub struct DeprecatedUnitStruct;
#[unstable(feature = "test_feature", issue = "0")]
pub struct UnstableUnitStruct;
#[stable(feature = "rust1", since = "1.0.0")]
pub struct StableUnitStruct;
pub enum Enum {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
DeprecatedVariant,
#[unstable(feature = "test_feature", issue = "0")]
UnstableVariant,
#[stable(feature = "rust1", since = "1.0.0")]
StableVariant,
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub struct DeprecatedTupleStruct(isize);
#[unstable(feature = "test_feature", issue = "0")]
pub struct UnstableTupleStruct(isize);
#[stable(feature = "rust1", since = "1.0.0")]
pub struct StableTupleStruct(isize);
fn test() {
// Only the deprecated cases of the following should generate
// errors, because other stability attributes now have meaning
// only *across* crates, not within a single crate.
type Foo = MethodTester;
let foo = MethodTester;
deprecated();
foo.method_deprecated();
Foo::method_deprecated(&foo);
<Foo>::method_deprecated(&foo);
foo.trait_deprecated();
Trait::trait_deprecated(&foo);
<Foo>::trait_deprecated(&foo);
<Foo as Trait>::trait_deprecated(&foo);
deprecated_text();
foo.method_deprecated_text();
Foo::method_deprecated_text(&foo);
<Foo>::method_deprecated_text(&foo);
foo.trait_deprecated_text();
Trait::trait_deprecated_text(&foo);
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
unstable();
foo.method_unstable();
Foo::method_unstable(&foo);
<Foo>::method_unstable(&foo);
foo.trait_unstable();
Trait::trait_unstable(&foo);
<Foo>::trait_unstable(&foo);
<Foo as Trait>::trait_unstable(&foo);
unstable_text();
foo.method_unstable_text();
Foo::method_unstable_text(&foo);
<Foo>::method_unstable_text(&foo);
foo.trait_unstable_text();
Trait::trait_unstable_text(&foo);
<Foo>::trait_unstable_text(&foo);
<Foo as Trait>::trait_unstable_text(&foo);
stable();
foo.method_stable();
Foo::method_stable(&foo);
<Foo>::method_stable(&foo);
foo.trait_stable();
Trait::trait_stable(&foo);
<Foo>::trait_stable(&foo);
<Foo as Trait>::trait_stable(&foo);
stable_text();
foo.method_stable_text();
Foo::method_stable_text(&foo);
<Foo>::method_stable_text(&foo);
foo.trait_stable_text();
Trait::trait_stable_text(&foo);
<Foo>::trait_stable_text(&foo);
<Foo as Trait>::trait_stable_text(&foo);
let _ = DeprecatedStruct {
i: 0
};
let _ = UnstableStruct { i: 0 };
let _ = StableStruct { i: 0 };
let _ = DeprecatedUnitStruct;
let _ = UnstableUnitStruct;
let _ = StableUnitStruct;
let _ = Enum::DeprecatedVariant;
let _ = Enum::UnstableVariant;
let _ = Enum::StableVariant;
let _ = DeprecatedTupleStruct (1);
let _ = UnstableTupleStruct (1);
let _ = StableTupleStruct (1);
}
fn test_method_param<Foo: Trait>(foo: Foo) {
foo.trait_deprecated();
Trait::trait_deprecated(&foo);
<Foo>::trait_deprecated(&foo);
<Foo as Trait>::trait_deprecated(&foo);
foo.trait_deprecated_text();
Trait::trait_deprecated_text(&foo);
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
foo.trait_unstable();
Trait::trait_unstable(&foo);
<Foo>::trait_unstable(&foo);
<Foo as Trait>::trait_unstable(&foo);
foo.trait_unstable_text();
Trait::trait_unstable_text(&foo);
<Foo>::trait_unstable_text(&foo);
<Foo as Trait>::trait_unstable_text(&foo);
foo.trait_stable();
Trait::trait_stable(&foo);
<Foo>::trait_stable(&foo);
<Foo as Trait>::trait_stable(&foo);
}
fn test_method_object(foo: &Trait) {
foo.trait_deprecated();
foo.trait_deprecated_text();
foo.trait_unstable();
foo.trait_unstable_text();
foo.trait_stable();
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn test_fn_body() {
fn fn_in_body() {}
fn_in_body();
}
impl MethodTester {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn test_method_body(&self) {
fn fn_in_body() {}
fn_in_body();
}
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub trait DeprecatedTrait {
fn dummy(&self) { }
}
struct S;
impl DeprecatedTrait for S { }
trait LocalTrait : DeprecatedTrait { }
}
fn main() {}

View File

@ -0,0 +1,467 @@
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:lint_stability.rs
// aux-build:inherited_stability.rs
// aux-build:stability_cfg1.rs
// aux-build:stability_cfg2.rs
#![deny(deprecated)]
#![allow(dead_code)]
#![feature(staged_api, test_feature)]
#![stable(feature = "rust1", since = "1.0.0")]
#[macro_use]
extern crate lint_stability;
mod cross_crate {
extern crate stability_cfg1;
extern crate stability_cfg2;
use lint_stability::*;
fn test() {
type Foo = MethodTester;
let foo = MethodTester;
deprecated(); //~ ERROR use of deprecated item
foo.method_deprecated(); //~ ERROR use of deprecated item
Foo::method_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::method_deprecated(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated(); //~ ERROR use of deprecated item
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
deprecated_text(); //~ ERROR use of deprecated item: text
foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
deprecated_unstable(); //~ ERROR use of deprecated item
foo.method_deprecated_unstable(); //~ ERROR use of deprecated item
Foo::method_deprecated_unstable(&foo); //~ ERROR use of deprecated item
<Foo>::method_deprecated_unstable(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
Trait::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
deprecated_unstable_text(); //~ ERROR use of deprecated item: text
foo.method_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
Foo::method_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::method_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
unstable();
foo.method_unstable();
Foo::method_unstable(&foo);
<Foo>::method_unstable(&foo);
foo.trait_unstable();
Trait::trait_unstable(&foo);
<Foo>::trait_unstable(&foo);
<Foo as Trait>::trait_unstable(&foo);
unstable_text();
foo.method_unstable_text();
Foo::method_unstable_text(&foo);
<Foo>::method_unstable_text(&foo);
foo.trait_unstable_text();
Trait::trait_unstable_text(&foo);
<Foo>::trait_unstable_text(&foo);
<Foo as Trait>::trait_unstable_text(&foo);
stable();
foo.method_stable();
Foo::method_stable(&foo);
<Foo>::method_stable(&foo);
foo.trait_stable();
Trait::trait_stable(&foo);
<Foo>::trait_stable(&foo);
<Foo as Trait>::trait_stable(&foo);
stable_text();
foo.method_stable_text();
Foo::method_stable_text(&foo);
<Foo>::method_stable_text(&foo);
foo.trait_stable_text();
Trait::trait_stable_text(&foo);
<Foo>::trait_stable_text(&foo);
<Foo as Trait>::trait_stable_text(&foo);
struct S1<T: TraitWithAssociatedTypes>(T::TypeUnstable);
struct S2<T: TraitWithAssociatedTypes>(T::TypeDeprecated);
//~^ ERROR use of deprecated item
let _ = DeprecatedStruct { //~ ERROR use of deprecated item
i: 0 //~ ERROR use of deprecated item
};
let _ = DeprecatedUnstableStruct {
//~^ ERROR use of deprecated item
i: 0 //~ ERROR use of deprecated item
};
let _ = UnstableStruct { i: 0 };
let _ = StableStruct { i: 0 };
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
let _ = DeprecatedUnstableUnitStruct; //~ ERROR use of deprecated item
let _ = UnstableUnitStruct;
let _ = StableUnitStruct;
let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
let _ = Enum::DeprecatedUnstableVariant; //~ ERROR use of deprecated item
let _ = Enum::UnstableVariant;
let _ = Enum::StableVariant;
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
let _ = DeprecatedUnstableTupleStruct (1); //~ ERROR use of deprecated item
let _ = UnstableTupleStruct (1);
let _ = StableTupleStruct (1);
// At the moment, the lint checker only checks stability in
// in the arguments of macros.
// Eventually, we will want to lint the contents of the
// macro in the module *defining* it. Also, stability levels
// on macros themselves are not yet linted.
macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item: text
macro_test_arg!(deprecated_unstable_text()); //~ ERROR use of deprecated item: text
macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item: text
}
fn test_method_param<Foo: Trait>(foo: Foo) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
Trait::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_unstable();
Trait::trait_unstable(&foo);
<Foo>::trait_unstable(&foo);
<Foo as Trait>::trait_unstable(&foo);
foo.trait_unstable_text();
Trait::trait_unstable_text(&foo);
<Foo>::trait_unstable_text(&foo);
<Foo as Trait>::trait_unstable_text(&foo);
foo.trait_stable();
Trait::trait_stable(&foo);
<Foo>::trait_stable(&foo);
<Foo as Trait>::trait_stable(&foo);
}
fn test_method_object(foo: &Trait) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
foo.trait_unstable();
foo.trait_unstable_text();
foo.trait_stable();
}
struct S;
impl UnstableTrait for S { }
impl DeprecatedTrait for S {} //~ ERROR use of deprecated item: text
trait LocalTrait : UnstableTrait { }
trait LocalTrait2 : DeprecatedTrait { } //~ ERROR use of deprecated item: text
impl Trait for S {
fn trait_stable(&self) {}
fn trait_unstable(&self) {}
}
}
mod inheritance {
extern crate inherited_stability;
use self::inherited_stability::*;
fn test_inheritance() {
unstable();
stable();
stable_mod::unstable();
stable_mod::stable();
unstable_mod::deprecated(); //~ ERROR use of deprecated item
unstable_mod::unstable();
let _ = Unstable::UnstableVariant;
let _ = Unstable::StableVariant;
let x: usize = 0;
x.unstable();
x.stable();
}
}
mod this_crate {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn deprecated() {}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn deprecated_text() {}
#[unstable(feature = "test_feature", issue = "0")]
pub fn unstable() {}
#[unstable(feature = "test_feature", reason = "text", issue = "0")]
pub fn unstable_text() {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn stable() {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn stable_text() {}
#[stable(feature = "rust1", since = "1.0.0")]
pub struct MethodTester;
impl MethodTester {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn method_deprecated(&self) {}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub fn method_deprecated_text(&self) {}
#[unstable(feature = "test_feature", issue = "0")]
pub fn method_unstable(&self) {}
#[unstable(feature = "test_feature", reason = "text", issue = "0")]
pub fn method_unstable_text(&self) {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn method_stable(&self) {}
#[stable(feature = "rust1", since = "1.0.0")]
pub fn method_stable_text(&self) {}
}
pub trait Trait {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn trait_deprecated(&self) {}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn trait_deprecated_text(&self) {}
#[unstable(feature = "test_feature", issue = "0")]
fn trait_unstable(&self) {}
#[unstable(feature = "test_feature", reason = "text", issue = "0")]
fn trait_unstable_text(&self) {}
#[stable(feature = "rust1", since = "1.0.0")]
fn trait_stable(&self) {}
#[stable(feature = "rust1", since = "1.0.0")]
fn trait_stable_text(&self) {}
}
impl Trait for MethodTester {}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub struct DeprecatedStruct {
#[stable(feature = "test_feature", since = "1.0.0")] i: isize
}
#[unstable(feature = "test_feature", issue = "0")]
pub struct UnstableStruct {
#[stable(feature = "test_feature", since = "1.0.0")] i: isize
}
#[stable(feature = "rust1", since = "1.0.0")]
pub struct StableStruct {
#[stable(feature = "test_feature", since = "1.0.0")] i: isize
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub struct DeprecatedUnitStruct;
#[unstable(feature = "test_feature", issue = "0")]
pub struct UnstableUnitStruct;
#[stable(feature = "rust1", since = "1.0.0")]
pub struct StableUnitStruct;
pub enum Enum {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
DeprecatedVariant,
#[unstable(feature = "test_feature", issue = "0")]
UnstableVariant,
#[stable(feature = "rust1", since = "1.0.0")]
StableVariant,
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub struct DeprecatedTupleStruct(isize);
#[unstable(feature = "test_feature", issue = "0")]
pub struct UnstableTupleStruct(isize);
#[stable(feature = "rust1", since = "1.0.0")]
pub struct StableTupleStruct(isize);
fn test() {
// Only the deprecated cases of the following should generate
// errors, because other stability attributes now have meaning
// only *across* crates, not within a single crate.
type Foo = MethodTester;
let foo = MethodTester;
deprecated(); //~ ERROR use of deprecated item
foo.method_deprecated(); //~ ERROR use of deprecated item
Foo::method_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::method_deprecated(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated(); //~ ERROR use of deprecated item
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
deprecated_text(); //~ ERROR use of deprecated item: text
foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
unstable();
foo.method_unstable();
Foo::method_unstable(&foo);
<Foo>::method_unstable(&foo);
foo.trait_unstable();
Trait::trait_unstable(&foo);
<Foo>::trait_unstable(&foo);
<Foo as Trait>::trait_unstable(&foo);
unstable_text();
foo.method_unstable_text();
Foo::method_unstable_text(&foo);
<Foo>::method_unstable_text(&foo);
foo.trait_unstable_text();
Trait::trait_unstable_text(&foo);
<Foo>::trait_unstable_text(&foo);
<Foo as Trait>::trait_unstable_text(&foo);
stable();
foo.method_stable();
Foo::method_stable(&foo);
<Foo>::method_stable(&foo);
foo.trait_stable();
Trait::trait_stable(&foo);
<Foo>::trait_stable(&foo);
<Foo as Trait>::trait_stable(&foo);
stable_text();
foo.method_stable_text();
Foo::method_stable_text(&foo);
<Foo>::method_stable_text(&foo);
foo.trait_stable_text();
Trait::trait_stable_text(&foo);
<Foo>::trait_stable_text(&foo);
<Foo as Trait>::trait_stable_text(&foo);
let _ = DeprecatedStruct {
//~^ ERROR use of deprecated item
i: 0 //~ ERROR use of deprecated item
};
let _ = UnstableStruct { i: 0 };
let _ = StableStruct { i: 0 };
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
let _ = UnstableUnitStruct;
let _ = StableUnitStruct;
let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
let _ = Enum::UnstableVariant;
let _ = Enum::StableVariant;
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
let _ = UnstableTupleStruct (1);
let _ = StableTupleStruct (1);
}
fn test_method_param<Foo: Trait>(foo: Foo) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_unstable();
Trait::trait_unstable(&foo);
<Foo>::trait_unstable(&foo);
<Foo as Trait>::trait_unstable(&foo);
foo.trait_unstable_text();
Trait::trait_unstable_text(&foo);
<Foo>::trait_unstable_text(&foo);
<Foo as Trait>::trait_unstable_text(&foo);
foo.trait_stable();
Trait::trait_stable(&foo);
<Foo>::trait_stable(&foo);
<Foo as Trait>::trait_stable(&foo);
}
fn test_method_object(foo: &Trait) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
foo.trait_unstable();
foo.trait_unstable_text();
foo.trait_stable();
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn test_fn_body() {
fn fn_in_body() {}
fn_in_body(); //~ ERROR use of deprecated item: text
}
impl MethodTester {
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn test_method_body(&self) {
fn fn_in_body() {}
fn_in_body(); //~ ERROR use of deprecated item: text
}
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
pub trait DeprecatedTrait {
fn dummy(&self) { }
}
struct S;
impl DeprecatedTrait for S { } //~ ERROR use of deprecated item
trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item
}
fn main() {}

View File

@ -0,0 +1,348 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:lint_stability_fields.rs
#![deny(deprecated)]
#![allow(dead_code)]
#![feature(staged_api, test_feature)]
#![stable(feature = "rust1", since = "1.0.0")]
mod cross_crate {
extern crate lint_stability_fields;
use self::lint_stability_fields::*;
pub fn foo() {
let x = Stable {
inherit: 1,
override1: 2,
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
let _ = x.override1;
let _ = x.override2;
//~^ ERROR use of deprecated item
let Stable {
inherit: _,
override1: _,
override2: _
//~^ ERROR use of deprecated item
} = x;
// all fine
let Stable { .. } = x;
let x = Stable2(1, 2, 3);
let _ = x.0;
let _ = x.1;
let _ = x.2;
//~^ ERROR use of deprecated item
let Stable2(_,
_,
_)
//~^ ERROR use of deprecated item
= x;
// all fine
let Stable2(..) = x;
let x = Unstable {
inherit: 1,
override1: 2,
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
let _ = x.override1;
let _ = x.override2;
//~^ ERROR use of deprecated item
let Unstable {
inherit: _,
override1: _,
override2: _
//~^ ERROR use of deprecated item
} = x;
let Unstable
// the patterns are all fine:
{ .. } = x;
let x = Unstable2(1, 2, 3);
let _ = x.0;
let _ = x.1;
let _ = x.2;
//~^ ERROR use of deprecated item
let Unstable2
(_,
_,
_)
//~^ ERROR use of deprecated item
= x;
let Unstable2
// the patterns are all fine:
(..) = x;
let x = Deprecated {
//~^ ERROR use of deprecated item
inherit: 1,
//~^ ERROR use of deprecated item
override1: 2,
//~^ ERROR use of deprecated item
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
//~^ ERROR use of deprecated item
let _ = x.override1;
//~^ ERROR use of deprecated item
let _ = x.override2;
//~^ ERROR use of deprecated item
let Deprecated {
//~^ ERROR use of deprecated item
inherit: _,
//~^ ERROR use of deprecated item
override1: _,
//~^ ERROR use of deprecated item
override2: _
//~^ ERROR use of deprecated item
} = x;
let Deprecated
//~^ ERROR use of deprecated item
// the patterns are all fine:
{ .. } = x;
let x = Deprecated2(1, 2, 3);
//~^ ERROR use of deprecated item
let _ = x.0;
//~^ ERROR use of deprecated item
let _ = x.1;
//~^ ERROR use of deprecated item
let _ = x.2;
//~^ ERROR use of deprecated item
let Deprecated2
//~^ ERROR use of deprecated item
(_,
//~^ ERROR use of deprecated item
_,
//~^ ERROR use of deprecated item
_)
//~^ ERROR use of deprecated item
= x;
let Deprecated2
//~^ ERROR use of deprecated item
// the patterns are all fine:
(..) = x;
}
}
mod this_crate {
#[stable(feature = "rust1", since = "1.0.0")]
struct Stable {
inherit: u8,
#[unstable(feature = "test_feature", issue = "0")]
override1: u8,
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[unstable(feature = "test_feature", issue = "0")]
override2: u8,
}
#[stable(feature = "rust1", since = "1.0.0")]
struct Stable2(u8,
#[stable(feature = "rust1", since = "1.0.0")] u8,
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
#[unstable(feature = "test_feature", issue = "0")]
struct Unstable {
inherit: u8,
#[stable(feature = "rust1", since = "1.0.0")]
override1: u8,
#[rustc_deprecated(since = "1.0.0", reason = "text")]
#[unstable(feature = "test_feature", issue = "0")]
override2: u8,
}
#[unstable(feature = "test_feature", issue = "0")]
struct Unstable2(u8,
#[stable(feature = "rust1", since = "1.0.0")] u8,
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")] u8);
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
struct Deprecated {
inherit: u8,
#[stable(feature = "rust1", since = "1.0.0")]
override1: u8,
#[unstable(feature = "test_feature", issue = "0")]
override2: u8,
}
#[unstable(feature = "test_feature", issue = "0")]
#[rustc_deprecated(since = "1.0.0", reason = "text")]
struct Deprecated2(u8,
#[stable(feature = "rust1", since = "1.0.0")] u8,
#[unstable(feature = "test_feature", issue = "0")] u8);
pub fn foo() {
let x = Stable {
inherit: 1,
override1: 2,
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
let _ = x.override1;
let _ = x.override2;
//~^ ERROR use of deprecated item
let Stable {
inherit: _,
override1: _,
override2: _
//~^ ERROR use of deprecated item
} = x;
// all fine
let Stable { .. } = x;
let x = Stable2(1, 2, 3);
let _ = x.0;
let _ = x.1;
let _ = x.2;
//~^ ERROR use of deprecated item
let Stable2(_,
_,
_)
//~^ ERROR use of deprecated item
= x;
// all fine
let Stable2(..) = x;
let x = Unstable {
inherit: 1,
override1: 2,
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
let _ = x.override1;
let _ = x.override2;
//~^ ERROR use of deprecated item
let Unstable {
inherit: _,
override1: _,
override2: _
//~^ ERROR use of deprecated item
} = x;
let Unstable
// the patterns are all fine:
{ .. } = x;
let x = Unstable2(1, 2, 3);
let _ = x.0;
let _ = x.1;
let _ = x.2;
//~^ ERROR use of deprecated item
let Unstable2
(_,
_,
_)
//~^ ERROR use of deprecated item
= x;
let Unstable2
// the patterns are all fine:
(..) = x;
let x = Deprecated {
//~^ ERROR use of deprecated item
inherit: 1,
//~^ ERROR use of deprecated item
override1: 2,
//~^ ERROR use of deprecated item
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
//~^ ERROR use of deprecated item
let _ = x.override1;
//~^ ERROR use of deprecated item
let _ = x.override2;
//~^ ERROR use of deprecated item
let Deprecated {
//~^ ERROR use of deprecated item
inherit: _,
//~^ ERROR use of deprecated item
override1: _,
//~^ ERROR use of deprecated item
override2: _
//~^ ERROR use of deprecated item
} = x;
let Deprecated
//~^ ERROR use of deprecated item
// the patterns are all fine:
{ .. } = x;
let x = Deprecated2(1, 2, 3);
//~^ ERROR use of deprecated item
let _ = x.0;
//~^ ERROR use of deprecated item
let _ = x.1;
//~^ ERROR use of deprecated item
let _ = x.2;
//~^ ERROR use of deprecated item
let Deprecated2
//~^ ERROR use of deprecated item
(_,
//~^ ERROR use of deprecated item
_,
//~^ ERROR use of deprecated item
_)
//~^ ERROR use of deprecated item
= x;
let Deprecated2
//~^ ERROR use of deprecated item
// the patterns are all fine:
(..) = x;
}
}
fn main() {}

View File

@ -9,7 +9,7 @@
// except according to those terms.
// aux-build:lint_stability_fields.rs
#![deny(deprecated)]
#![allow(deprecated)]
#![allow(dead_code)]
#![feature(staged_api)]
@ -24,23 +24,17 @@ mod cross_crate {
let x = Stable {
inherit: 1,
override1: 2, //~ ERROR use of unstable
override2: 3,
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
override2: 3, //~ ERROR use of unstable
};
let _ = x.inherit;
let _ = x.override1; //~ ERROR use of unstable
let _ = x.override2;
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let _ = x.override2; //~ ERROR use of unstable
let Stable {
inherit: _,
override1: _, //~ ERROR use of unstable
override2: _
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
override2: _ //~ ERROR use of unstable
} = x;
// all fine
let Stable { .. } = x;
@ -49,15 +43,11 @@ mod cross_crate {
let _ = x.0;
let _ = x.1; //~ ERROR use of unstable
let _ = x.2;
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let _ = x.2; //~ ERROR use of unstable
let Stable2(_,
_, //~ ERROR use of unstable
_)
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
_) //~ ERROR use of unstable
= x;
// all fine
let Stable2(..) = x;
@ -66,23 +56,17 @@ mod cross_crate {
let x = Unstable { //~ ERROR use of unstable
inherit: 1, //~ ERROR use of unstable
override1: 2,
override2: 3,
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
override2: 3, //~ ERROR use of unstable
};
let _ = x.inherit; //~ ERROR use of unstable
let _ = x.override1;
let _ = x.override2;
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let _ = x.override2; //~ ERROR use of unstable
let Unstable { //~ ERROR use of unstable
inherit: _, //~ ERROR use of unstable
override1: _,
override2: _
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
override2: _ //~ ERROR use of unstable
} = x;
let Unstable //~ ERROR use of unstable
@ -94,91 +78,50 @@ mod cross_crate {
let _ = x.0; //~ ERROR use of unstable
let _ = x.1;
let _ = x.2;
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let _ = x.2; //~ ERROR use of unstable
let Unstable2 //~ ERROR use of unstable
(_, //~ ERROR use of unstable
_,
_)
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
_) //~ ERROR use of unstable
= x;
let Unstable2 //~ ERROR use of unstable
// the patterns are all fine:
(..) = x;
let x = Deprecated {
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
inherit: 1,
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let x = Deprecated { //~ ERROR use of unstable
inherit: 1, //~ ERROR use of unstable
override1: 2,
//~^ ERROR use of deprecated item
override2: 3,
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
override2: 3, //~ ERROR use of unstable
};
let _ = x.inherit;
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let _ = x.inherit; //~ ERROR use of unstable
let _ = x.override1;
//~^ ERROR use of deprecated item
let _ = x.override2;
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let _ = x.override2; //~ ERROR use of unstable
let Deprecated {
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
inherit: _,
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let Deprecated { //~ ERROR use of unstable
inherit: _, //~ ERROR use of unstable
override1: _,
//~^ ERROR use of deprecated item
override2: _
//~^ ERROR use of unstable
//~^^ ERROR use of deprecated item
override2: _ //~ ERROR use of unstable
} = x;
let Deprecated
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let Deprecated //~ ERROR use of unstable
// the patterns are all fine:
{ .. } = x;
let x = Deprecated2(1, 2, 3);
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let x = Deprecated2(1, 2, 3); //~ ERROR use of unstable
let _ = x.0;
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let _ = x.0; //~ ERROR use of unstable
let _ = x.1;
//~^ ERROR use of deprecated item
let _ = x.2;
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let _ = x.2; //~ ERROR use of unstable
let Deprecated2
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
(_,
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let Deprecated2 //~ ERROR use of unstable
(_, //~ ERROR use of unstable
_,
//~^ ERROR use of deprecated item
_)
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
_) //~ ERROR use of unstable
= x;
let Deprecated2
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable
let Deprecated2 //~ ERROR use of unstable
// the patterns are all fine:
(..) = x;
}
@ -238,19 +181,16 @@ mod this_crate {
inherit: 1,
override1: 2,
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
let _ = x.override1;
let _ = x.override2;
//~^ ERROR use of deprecated item
let Stable {
inherit: _,
override1: _,
override2: _
//~^ ERROR use of deprecated item
} = x;
// all fine
let Stable { .. } = x;
@ -260,12 +200,10 @@ mod this_crate {
let _ = x.0;
let _ = x.1;
let _ = x.2;
//~^ ERROR use of deprecated item
let Stable2(_,
_,
_)
//~^ ERROR use of deprecated item
= x;
// all fine
let Stable2(..) = x;
@ -275,19 +213,16 @@ mod this_crate {
inherit: 1,
override1: 2,
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
let _ = x.override1;
let _ = x.override2;
//~^ ERROR use of deprecated item
let Unstable {
inherit: _,
override1: _,
override2: _
//~^ ERROR use of deprecated item
} = x;
let Unstable
@ -300,13 +235,11 @@ mod this_crate {
let _ = x.0;
let _ = x.1;
let _ = x.2;
//~^ ERROR use of deprecated item
let Unstable2
(_,
_,
_)
//~^ ERROR use of deprecated item
= x;
let Unstable2
// the patterns are all fine:
@ -314,58 +247,37 @@ mod this_crate {
let x = Deprecated {
//~^ ERROR use of deprecated item
inherit: 1,
//~^ ERROR use of deprecated item
override1: 2,
//~^ ERROR use of deprecated item
override2: 3,
//~^ ERROR use of deprecated item
};
let _ = x.inherit;
//~^ ERROR use of deprecated item
let _ = x.override1;
//~^ ERROR use of deprecated item
let _ = x.override2;
//~^ ERROR use of deprecated item
let Deprecated {
//~^ ERROR use of deprecated item
inherit: _,
//~^ ERROR use of deprecated item
override1: _,
//~^ ERROR use of deprecated item
override2: _
//~^ ERROR use of deprecated item
} = x;
let Deprecated
//~^ ERROR use of deprecated item
// the patterns are all fine:
{ .. } = x;
let x = Deprecated2(1, 2, 3);
//~^ ERROR use of deprecated item
let _ = x.0;
//~^ ERROR use of deprecated item
let _ = x.1;
//~^ ERROR use of deprecated item
let _ = x.2;
//~^ ERROR use of deprecated item
let Deprecated2
//~^ ERROR use of deprecated item
(_,
//~^ ERROR use of deprecated item
_,
//~^ ERROR use of deprecated item
_)
//~^ ERROR use of deprecated item
= x;
let Deprecated2
//~^ ERROR use of deprecated item
// the patterns are all fine:
(..) = x;
}

View File

@ -13,7 +13,7 @@
// aux-build:stability_cfg1.rs
// aux-build:stability_cfg2.rs
#![deny(deprecated)]
#![allow(deprecated)]
#![allow(dead_code)]
#![feature(staged_api)]
@ -32,81 +32,46 @@ mod cross_crate {
type Foo = MethodTester;
let foo = MethodTester;
deprecated(); //~ ERROR use of deprecated item
foo.method_deprecated(); //~ ERROR use of deprecated item
Foo::method_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::method_deprecated(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated(); //~ ERROR use of deprecated item
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
deprecated();
foo.method_deprecated();
Foo::method_deprecated(&foo);
<Foo>::method_deprecated(&foo);
foo.trait_deprecated();
Trait::trait_deprecated(&foo);
<Foo>::trait_deprecated(&foo);
<Foo as Trait>::trait_deprecated(&foo);
deprecated_text(); //~ ERROR use of deprecated item: text
foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
deprecated_text();
foo.method_deprecated_text();
Foo::method_deprecated_text(&foo);
<Foo>::method_deprecated_text(&foo);
foo.trait_deprecated_text();
Trait::trait_deprecated_text(&foo);
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
deprecated_unstable(); //~ ERROR use of deprecated item
deprecated_unstable();
//~^ ERROR use of unstable library feature
foo.method_deprecated_unstable(); //~ ERROR use of deprecated item
Trait::trait_deprecated_unstable(&foo);
//~^ ERROR use of unstable library feature
Foo::method_deprecated_unstable(&foo); //~ ERROR use of deprecated item
//~^ ERROR use of unstable library feature
<Foo>::method_deprecated_unstable(&foo); //~ ERROR use of deprecated item
//~^ ERROR use of unstable library feature
foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
//~^ ERROR use of unstable library feature
Trait::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
//~^ ERROR use of unstable library feature
<Foo>::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
//~^ ERROR use of unstable library feature
<Foo as Trait>::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated_unstable(&foo);
//~^ ERROR use of unstable library feature
deprecated_unstable_text(); //~ ERROR use of deprecated item: text
deprecated_unstable_text();
//~^ ERROR use of unstable library feature
foo.method_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_unstable_text(&foo);
//~^ ERROR use of unstable library feature
Foo::method_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
<Foo>::method_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
Trait::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
<Foo>::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
<Foo as Trait>::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_unstable_text(&foo);
//~^ ERROR use of unstable library feature
unstable(); //~ ERROR use of unstable library feature
foo.method_unstable(); //~ ERROR use of unstable library feature
Foo::method_unstable(&foo); //~ ERROR use of unstable library feature
<Foo>::method_unstable(&foo); //~ ERROR use of unstable library feature
foo.trait_unstable(); //~ ERROR use of unstable library feature
Trait::trait_unstable(&foo); //~ ERROR use of unstable library feature
<Foo>::trait_unstable(&foo); //~ ERROR use of unstable library feature
<Foo as Trait>::trait_unstable(&foo); //~ ERROR use of unstable library feature
unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
foo.method_unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
Foo::method_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
<Foo>::method_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
foo.trait_unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
Trait::trait_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
<Foo>::trait_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
<Foo as Trait>::trait_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
@ -131,33 +96,31 @@ mod cross_crate {
struct S1<T: TraitWithAssociatedTypes>(T::TypeUnstable);
//~^ ERROR use of unstable library feature
struct S2<T: TraitWithAssociatedTypes>(T::TypeDeprecated);
//~^ ERROR use of deprecated item
let _ = DeprecatedStruct { //~ ERROR use of deprecated item
i: 0 //~ ERROR use of deprecated item
let _ = DeprecatedStruct {
i: 0
};
let _ = DeprecatedUnstableStruct {
//~^ ERROR use of deprecated item
//~^^ ERROR use of unstable library feature
i: 0 //~ ERROR use of deprecated item
//~^ ERROR use of unstable library feature
i: 0
};
let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable library feature
let _ = StableStruct { i: 0 };
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
let _ = DeprecatedUnstableUnitStruct; //~ ERROR use of deprecated item
let _ = DeprecatedUnitStruct;
let _ = DeprecatedUnstableUnitStruct;
//~^ ERROR use of unstable library feature
let _ = UnstableUnitStruct; //~ ERROR use of unstable library feature
let _ = StableUnitStruct;
let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
let _ = Enum::DeprecatedUnstableVariant; //~ ERROR use of deprecated item
let _ = Enum::DeprecatedVariant;
let _ = Enum::DeprecatedUnstableVariant;
//~^ ERROR use of unstable library feature
let _ = Enum::UnstableVariant; //~ ERROR use of unstable library feature
let _ = Enum::StableVariant;
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
let _ = DeprecatedUnstableTupleStruct (1); //~ ERROR use of deprecated item
let _ = DeprecatedTupleStruct (1);
let _ = DeprecatedUnstableTupleStruct (1);
//~^ ERROR use of unstable library feature
let _ = UnstableTupleStruct (1); //~ ERROR use of unstable library feature
let _ = StableTupleStruct (1);
@ -167,47 +130,33 @@ mod cross_crate {
// Eventually, we will want to lint the contents of the
// macro in the module *defining* it. Also, stability levels
// on macros themselves are not yet linted.
macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item: text
macro_test_arg!(deprecated_unstable_text()); //~ ERROR use of deprecated item: text
macro_test_arg!(deprecated_text());
macro_test_arg!(deprecated_unstable_text());
//~^ ERROR use of unstable library feature
macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item: text
macro_test_arg!(macro_test_arg!(deprecated_text()));
}
fn test_method_param<Foo: Trait>(foo: Foo) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
foo.trait_deprecated();
Trait::trait_deprecated(&foo);
<Foo>::trait_deprecated(&foo);
<Foo as Trait>::trait_deprecated(&foo);
foo.trait_deprecated_text();
Trait::trait_deprecated_text(&foo);
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
Trait::trait_deprecated_unstable(&foo);
//~^ ERROR use of unstable library feature
Trait::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated_unstable(&foo);
//~^ ERROR use of unstable library feature
<Foo>::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
Trait::trait_deprecated_unstable_text(&foo);
//~^ ERROR use of unstable library feature
<Foo as Trait>::trait_deprecated_unstable(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated_unstable_text(&foo);
//~^ ERROR use of unstable library feature
foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
Trait::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
<Foo>::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
<Foo as Trait>::trait_deprecated_unstable_text(&foo); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
foo.trait_unstable(); //~ ERROR use of unstable library feature
Trait::trait_unstable(&foo); //~ ERROR use of unstable library feature
<Foo>::trait_unstable(&foo); //~ ERROR use of unstable library feature
<Foo as Trait>::trait_unstable(&foo); //~ ERROR use of unstable library feature
foo.trait_unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
Trait::trait_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
<Foo>::trait_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
<Foo as Trait>::trait_unstable_text(&foo);
//~^ ERROR use of unstable library feature 'test_feature': text
foo.trait_stable();
@ -217,24 +166,17 @@ mod cross_crate {
}
fn test_method_object(foo: &Trait) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
foo.trait_deprecated_unstable(); //~ ERROR use of deprecated item
//~^ ERROR use of unstable library feature
foo.trait_deprecated_unstable_text(); //~ ERROR use of deprecated item: text
//~^ ERROR use of unstable library feature
foo.trait_unstable(); //~ ERROR use of unstable library feature
foo.trait_unstable_text();
//~^ ERROR use of unstable library feature 'test_feature': text
foo.trait_deprecated();
foo.trait_deprecated_text();
foo.trait_stable();
}
struct S;
impl UnstableTrait for S { } //~ ERROR use of unstable library feature
impl DeprecatedTrait for S {} //~ ERROR use of deprecated item: text
impl DeprecatedTrait for S {}
trait LocalTrait : UnstableTrait { } //~ ERROR use of unstable library feature
trait LocalTrait2 : DeprecatedTrait { } //~ ERROR use of deprecated item: text
trait LocalTrait2 : DeprecatedTrait { }
impl Trait for S {
fn trait_stable(&self) {}
@ -253,14 +195,13 @@ mod inheritance {
stable_mod::unstable(); //~ ERROR use of unstable library feature
stable_mod::stable();
unstable_mod::deprecated(); //~ ERROR use of deprecated item
unstable_mod::deprecated();
unstable_mod::unstable(); //~ ERROR use of unstable library feature
let _ = Unstable::UnstableVariant; //~ ERROR use of unstable library feature
let _ = Unstable::StableVariant;
let x: usize = 0;
x.unstable(); //~ ERROR use of unstable library feature
x.stable();
}
}
@ -375,23 +316,23 @@ mod this_crate {
type Foo = MethodTester;
let foo = MethodTester;
deprecated(); //~ ERROR use of deprecated item
foo.method_deprecated(); //~ ERROR use of deprecated item
Foo::method_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::method_deprecated(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated(); //~ ERROR use of deprecated item
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
deprecated();
foo.method_deprecated();
Foo::method_deprecated(&foo);
<Foo>::method_deprecated(&foo);
foo.trait_deprecated();
Trait::trait_deprecated(&foo);
<Foo>::trait_deprecated(&foo);
<Foo as Trait>::trait_deprecated(&foo);
deprecated_text(); //~ ERROR use of deprecated item: text
foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::method_deprecated_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
deprecated_text();
foo.method_deprecated_text();
Foo::method_deprecated_text(&foo);
<Foo>::method_deprecated_text(&foo);
foo.trait_deprecated_text();
Trait::trait_deprecated_text(&foo);
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
unstable();
foo.method_unstable();
@ -430,34 +371,33 @@ mod this_crate {
<Foo as Trait>::trait_stable_text(&foo);
let _ = DeprecatedStruct {
//~^ ERROR use of deprecated item
i: 0 //~ ERROR use of deprecated item
i: 0
};
let _ = UnstableStruct { i: 0 };
let _ = StableStruct { i: 0 };
let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
let _ = DeprecatedUnitStruct;
let _ = UnstableUnitStruct;
let _ = StableUnitStruct;
let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
let _ = Enum::DeprecatedVariant;
let _ = Enum::UnstableVariant;
let _ = Enum::StableVariant;
let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
let _ = DeprecatedTupleStruct (1);
let _ = UnstableTupleStruct (1);
let _ = StableTupleStruct (1);
}
fn test_method_param<Foo: Trait>(foo: Foo) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo>::trait_deprecated(&foo); //~ ERROR use of deprecated item
<Foo as Trait>::trait_deprecated(&foo); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
<Foo as Trait>::trait_deprecated_text(&foo); //~ ERROR use of deprecated item: text
foo.trait_deprecated();
Trait::trait_deprecated(&foo);
<Foo>::trait_deprecated(&foo);
<Foo as Trait>::trait_deprecated(&foo);
foo.trait_deprecated_text();
Trait::trait_deprecated_text(&foo);
<Foo>::trait_deprecated_text(&foo);
<Foo as Trait>::trait_deprecated_text(&foo);
foo.trait_unstable();
Trait::trait_unstable(&foo);
<Foo>::trait_unstable(&foo);
@ -473,8 +413,8 @@ mod this_crate {
}
fn test_method_object(foo: &Trait) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
foo.trait_deprecated();
foo.trait_deprecated_text();
foo.trait_unstable();
foo.trait_unstable_text();
foo.trait_stable();
@ -484,7 +424,7 @@ mod this_crate {
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn test_fn_body() {
fn fn_in_body() {}
fn_in_body(); //~ ERROR use of deprecated item: text
fn_in_body();
}
impl MethodTester {
@ -492,7 +432,7 @@ mod this_crate {
#[rustc_deprecated(since = "1.0.0", reason = "text")]
fn test_method_body(&self) {
fn fn_in_body() {}
fn_in_body(); //~ ERROR use of deprecated item: text
fn_in_body();
}
}
@ -504,9 +444,9 @@ mod this_crate {
struct S;
impl DeprecatedTrait for S { } //~ ERROR use of deprecated item
impl DeprecatedTrait for S { }
trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item
trait LocalTrait : DeprecatedTrait { }
}
fn main() {}

View File

@ -10,8 +10,6 @@
#![feature(box_syntax)]
extern crate collections;
use std::collections::HashMap;
trait Map<K, V>

View File

@ -10,7 +10,7 @@
// General test of maybe_uninits state computed by MIR dataflow.
#![feature(rustc_attrs)]
#![feature(core_intrinsics, rustc_attrs)]
use std::intrinsics::rustc_peek;
use std::mem::{drop, replace};

View File

@ -10,7 +10,7 @@
// General test of maybe_inits state computed by MIR dataflow.
#![feature(rustc_attrs)]
#![feature(core_intrinsics, rustc_attrs)]
use std::intrinsics::rustc_peek;
use std::mem::{drop, replace};

View File

@ -10,7 +10,7 @@
// General test of maybe_uninits state computed by MIR dataflow.
#![feature(rustc_attrs)]
#![feature(core_intrinsics, rustc_attrs)]
use std::intrinsics::rustc_peek;
use std::mem::{drop, replace};

View File

@ -10,7 +10,7 @@
// General test of maybe_uninits state computed by MIR dataflow.
#![feature(rustc_attrs)]
#![feature(core_intrinsics, rustc_attrs)]
use std::intrinsics::rustc_peek;
use std::mem::{drop, replace};

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(libc)]
extern crate libc;
fn main() {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
#![feature(fn_traits, unboxed_closures)]
use std::ops::FnMut;

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(unboxed_closures)]
#![feature(fn_traits, unboxed_closures)]
use std::ops::FnMut;

View File

@ -16,10 +16,8 @@
pub fn main() {
let _: std::ops::RangeInclusive<_> = { use std::intrinsics; 1 } ... { use std::intrinsics; 2 };
//~^ ERROR use of unstable library feature 'inclusive_range'
//~^^ ERROR core_intrinsics
//~^^^ ERROR core_intrinsics
//~^^^^ WARN unused_imports
//~^^^^^ WARN unused_imports
//~| ERROR core_intrinsics
//~| ERROR core_intrinsics
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(reflect_marker)]
// Test that types that appear in assoc bindings in an object
// type are subject to the reflect check.

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(reflect_marker)]
// Test that types that appear in input types in an object type are
// subject to the reflect check.

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(reflect_marker)]
// Test that there is no way to get a generic type `T` to be
// considered as `Reflect` (or accessible via something that is
// considered `Reflect`) without a reflect bound, but that any

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(fn_traits)]
struct closure_box<'a> {
cl: Box<FnMut() + 'a>,
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(collections)]
mod a {
extern crate collections;
use collections::HashMap;

View File

@ -23,9 +23,4 @@ fn f2() { }
#[unstable(feature = "a", issue = "no")] //~ ERROR incorrect 'issue'
fn f3() { }
#[macro_export]
macro_rules! mac { //~ ERROR This node does not have a stability attribute
() => ()
}
fn main() { }

View File

@ -0,0 +1,22 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// More checks that stability attributes are used correctly
#![feature(staged_api)]
#![stable(feature = "test_feature", since = "1.0.0")]
#[macro_export]
macro_rules! mac { //~ ERROR This node does not have a stability attribute
() => ()
}
fn main() { }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(libc)]
extern crate libc;
extern {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rand)]
// ensure that the ThreadRng isn't/doesn't become accidentally sendable.
use std::__rand::ThreadRng;

View File

@ -11,7 +11,7 @@
// Checks that the Fn trait hierarchy rules do not permit
// Fn to be used where FnMut is implemented.
#![feature(unboxed_closures)]
#![feature(fn_traits, unboxed_closures)]
#![feature(overloaded_calls)]
use std::ops::{Fn,FnMut,FnOnce};

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(fn_traits)]
// That a closure whose expected argument types include two distinct
// bound regions.

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(core,unboxed_closures)]
#![feature(core, fn_traits, unboxed_closures)]
use std::marker::PhantomData;

View File

@ -10,7 +10,7 @@
// Regression test for #23827
#![feature(core, unboxed_closures)]
#![feature(core, fn_traits, unboxed_closures)]
pub struct Prototype {
pub target: u32