Skip to content

Commit b5a452e

Browse files
committed
Tie stability attributes to feature gates
1 parent ce825f3 commit b5a452e

File tree

65 files changed

+299
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+299
-212
lines changed

src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![feature(slicing_syntax, unboxed_closures)]
1414
#![feature(box_syntax)]
1515
#![feature(int_uint)]
16-
#![allow(unstable)]
16+
#![feature(unnamed_feature)]
1717

1818
#![deny(warnings)]
1919

src/driver/driver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(unstable)]
11+
#![allow(unknown_features)]
12+
#![feature(unnamed_feature)]
1213

1314
#[cfg(rustdoc)]
1415
extern crate "rustdoc" as this;

src/liballoc/arc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,6 @@ impl<H: Hasher, T: Hash<H>> Hash<H> for Arc<T> {
608608
}
609609

610610
#[cfg(test)]
611-
#[allow(unstable)]
612611
mod tests {
613612
use std::clone::Clone;
614613
use std::sync::mpsc::channel;

src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666

6767
#![no_std]
6868
#![allow(unknown_features)]
69-
#![allow(unstable)]
7069
#![feature(lang_items, unsafe_destructor)]
7170
#![feature(box_syntax)]
7271
#![feature(optin_builtin_traits)]
72+
#![feature(unnamed_feature)]
7373
#![allow(unknown_features)] #![feature(int_uint)]
7474

7575
#[macro_use]

src/liballoc/rc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,6 @@ impl<T> RcBoxPtr<T> for Weak<T> {
937937
}
938938

939939
#[cfg(test)]
940-
#[allow(unstable)]
941940
mod tests {
942941
use super::{Rc, Weak, weak_count, strong_count};
943942
use std::cell::RefCell;

src/libarena/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
#![feature(unsafe_destructor)]
3333
#![feature(unboxed_closures)]
3434
#![feature(box_syntax)]
35+
#![feature(unnamed_feature)]
3536
#![allow(unknown_features)] #![feature(int_uint)]
3637
#![allow(missing_docs)]
37-
#![allow(unstable)]
3838

3939
extern crate alloc;
4040

src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#![feature(unsafe_destructor, slicing_syntax)]
2727
#![feature(box_syntax)]
2828
#![feature(unboxed_closures)]
29+
#![feature(unnamed_feature)]
2930
#![allow(unknown_features)] #![feature(int_uint)]
30-
#![allow(unstable)]
3131
#![no_std]
3232

3333
#[macro_use]

src/libcore/simd.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
//! provided beyond this module.
2020
//!
2121
//! ```rust
22-
//! #[allow(unstable)];
2322
//!
2423
//! fn main() {
2524
//! use std::simd::f32x4;

src/libcore/slice.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,6 @@ pub mod bytes {
14331433

14341434
impl MutableByteVector for [u8] {
14351435
#[inline]
1436-
#[allow(unstable)]
14371436
fn set_memory(&mut self, value: u8) {
14381437
unsafe { ptr::set_memory(self.as_mut_ptr(), value, self.len()) };
14391438
}

src/libcoretest/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#![feature(unsafe_destructor, slicing_syntax)]
1212
#![feature(unboxed_closures)]
1313
#![feature(box_syntax)]
14+
#![feature(unnamed_feature)]
1415
#![allow(unknown_features)] #![feature(int_uint)]
15-
#![allow(unstable)]
1616

1717
extern crate core;
1818
extern crate test;

src/libflate/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#![unstable(feature = "unnamed_feature", since = "1.0.0")]
1919
#![staged_api]
2020
#![allow(unknown_features)] #![feature(int_uint)]
21-
#![allow(unstable)]
21+
#![feature(unnamed_feature)]
2222
#![crate_type = "rlib"]
2323
#![crate_type = "dylib"]
2424
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",

src/libfmt_macros/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#![feature(slicing_syntax)]
2828
#![allow(unknown_features)] #![feature(int_uint)]
29-
#![allow(unstable)]
29+
#![feature(unnamed_feature)]
3030

3131
pub use self::Piece::*;
3232
pub use self::Position::*;

src/libgetopts/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
html_root_url = "http://doc.rust-lang.org/nightly/",
8989
html_playground_url = "http://play.rust-lang.org/")]
9090
#![feature(slicing_syntax)]
91+
#![feature(unnamed_feature)]
9192
#![allow(unknown_features)] #![feature(int_uint)]
92-
#![allow(unstable)]
9393
#![deny(missing_docs)]
9494

9595
#[cfg(test)] #[macro_use] extern crate log;

src/libgraphviz/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@
273273
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
274274
html_root_url = "http://doc.rust-lang.org/nightly/")]
275275
#![feature(slicing_syntax)]
276+
#![feature(unnamed_feature)]
276277
#![allow(unknown_features)] #![feature(int_uint)]
277-
#![allow(unstable)]
278278

279279
use self::LabelText::*;
280280

src/liblibc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#![cfg_attr(not(feature = "cargo-build"),
1414
unstable(feature = "unnamed_feature", since = "1.0.0"))]
1515
#![cfg_attr(not(feature = "cargo-build"), staged_api)]
16+
#![cfg_attr(not(feature = "cargo-build"), feature(unnamed_feature))]
1617
#![allow(unknown_features)] #![feature(int_uint)]
17-
#![allow(unstable)]
1818
#![no_std]
1919
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2020
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
@@ -74,7 +74,7 @@
7474
//! one from Berkeley after the lawsuits died down and the CSRG dissolved.
7575
7676
#![allow(bad_style, raw_pointer_derive)]
77-
77+
#![cfg_attr(not(feature = "cargo-build"), feature(unnamed_feature))]
7878
#[cfg(feature = "cargo-build")] extern crate "std" as core;
7979
#[cfg(not(feature = "cargo-build"))] extern crate core;
8080

src/liblog/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@
169169
#![allow(unknown_features)]
170170
#![feature(slicing_syntax)]
171171
#![feature(box_syntax)]
172+
#![feature(unnamed_feature)]
172173
#![allow(unknown_features)] #![feature(int_uint)]
173-
#![allow(unstable)]
174174
#![deny(missing_docs)]
175175

176176
extern crate regex;

src/librand/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2323
html_root_url = "http://doc.rust-lang.org/nightly/",
2424
html_playground_url = "http://play.rust-lang.org/")]
25+
#![feature(unnamed_feature)]
2526
#![allow(unknown_features)] #![feature(int_uint)]
26-
#![allow(unstable)]
2727
#![no_std]
2828
#![unstable(feature = "unnamed_feature", since = "1.0.0")]
2929
#![staged_api]

src/librbml/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
html_playground_url = "http://play.rust-lang.org/")]
2727
#![allow(unknown_features)]
2828
#![feature(slicing_syntax)]
29+
#![feature(unnamed_feature)]
2930
#![allow(unknown_features)] #![feature(int_uint)]
30-
#![allow(unstable)]
3131

3232
extern crate serialize;
3333
#[macro_use] extern crate log;

src/libregex/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
html_playground_url = "http://play.rust-lang.org/")]
2626

2727
#![allow(unknown_features)]
28-
#![allow(unstable)]
2928
#![feature(slicing_syntax)]
3029
#![feature(box_syntax)]
30+
#![feature(unnamed_feature)]
3131
#![allow(unknown_features)] #![feature(int_uint)]
3232
#![deny(missing_docs)]
3333

src/libregex/re.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ pub struct Captures<'t> {
410410
}
411411

412412
impl<'t> Captures<'t> {
413-
#[allow(unstable)]
414413
fn new(re: &Regex, search: &'t str, locs: CaptureLocs)
415414
-> Option<Captures<'t>> {
416415
if !has_match(&locs) {

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
#![feature(quote)]
2828
#![feature(slicing_syntax, unsafe_destructor)]
2929
#![feature(box_syntax)]
30+
#![feature(unnamed_feature)]
3031
#![allow(unknown_features)] #![feature(int_uint)]
3132
#![feature(rustc_diagnostic_macros)]
32-
#![allow(unstable)]
3333

3434
extern crate arena;
3535
extern crate flate;

src/librustc/lint/builtin.rs

Lines changed: 13 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
4444
use syntax::{abi, ast, ast_map};
4545
use syntax::ast_util::is_shift_binop;
4646
use syntax::attr::{self, AttrMetaMethods};
47-
use syntax::codemap::{Span, DUMMY_SP};
47+
use syntax::codemap::Span;
4848
use syntax::parse::token;
4949
use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
5050
use syntax::ast_util;
@@ -1628,32 +1628,15 @@ declare_lint! {
16281628
"detects use of #[deprecated] items"
16291629
}
16301630

1631-
declare_lint! {
1632-
UNSTABLE,
1633-
Warn,
1634-
"detects use of #[unstable] items (incl. items with no stability attribute)"
1635-
}
1636-
1637-
/// Checks for use of items with `#[deprecated]`, `#[unstable]` and
1638-
/// `#[unstable]` attributes, or no stability attribute.
1631+
/// Checks for use of items with `#[deprecated]` attributes
16391632
#[derive(Copy)]
16401633
pub struct Stability;
16411634

16421635
impl Stability {
1643-
fn lint(&self, cx: &Context, id: ast::DefId, span: Span) {
1644-
1645-
if !stability::is_staged_api(cx.tcx, id) { return }
1636+
fn lint(&self, cx: &Context, _id: ast::DefId, span: Span, stability: &Option<attr::Stability>) {
16461637

1647-
let ref stability = stability::lookup(cx.tcx, id);
1648-
let cross_crate = !ast_util::is_local(id);
1649-
1650-
// stability attributes are promises made across crates; only
1651-
// check DEPRECATED for crate-local usage.
1638+
// deprecated attributes apply in-crate and cross-crate
16521639
let (lint, label) = match *stability {
1653-
// no stability attributes == Unstable
1654-
None if cross_crate => (UNSTABLE, "unmarked"),
1655-
Some(attr::Stability { level: attr::Unstable, .. }) if cross_crate =>
1656-
(UNSTABLE, "unstable"),
16571640
Some(attr::Stability { level: attr::Deprecated, .. }) =>
16581641
(DEPRECATED, "deprecated"),
16591642
_ => return
@@ -1673,100 +1656,26 @@ impl Stability {
16731656
cx.span_lint(lint, span, &msg[]);
16741657
}
16751658
}
1676-
1677-
1678-
fn is_internal(&self, cx: &Context, span: Span) -> bool {
1679-
cx.tcx.sess.codemap().span_is_internal(span)
1680-
}
1681-
16821659
}
16831660

16841661
impl LintPass for Stability {
16851662
fn get_lints(&self) -> LintArray {
1686-
lint_array!(DEPRECATED, UNSTABLE)
1663+
lint_array!(DEPRECATED)
16871664
}
16881665

16891666
fn check_view_item(&mut self, cx: &Context, item: &ast::ViewItem) {
1690-
// compiler-generated `extern crate` statements have a dummy span.
1691-
if item.span == DUMMY_SP { return }
1692-
1693-
let id = match item.node {
1694-
ast::ViewItemExternCrate(_, _, id) => id,
1695-
ast::ViewItemUse(..) => return,
1696-
};
1697-
let cnum = match cx.tcx.sess.cstore.find_extern_mod_stmt_cnum(id) {
1698-
Some(cnum) => cnum,
1699-
None => return,
1700-
};
1701-
let id = ast::DefId { krate: cnum, node: ast::CRATE_NODE_ID };
1702-
self.lint(cx, id, item.span);
1703-
}
1704-
1705-
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
1706-
if self.is_internal(cx, e.span) { return; }
1707-
1708-
let mut span = e.span;
1709-
1710-
let id = match e.node {
1711-
ast::ExprPath(..) | ast::ExprQPath(..) | ast::ExprStruct(..) => {
1712-
match cx.tcx.def_map.borrow().get(&e.id) {
1713-
Some(&def) => def.def_id(),
1714-
None => return
1715-
}
1716-
}
1717-
ast::ExprMethodCall(i, _, _) => {
1718-
span = i.span;
1719-
let method_call = ty::MethodCall::expr(e.id);
1720-
match cx.tcx.method_map.borrow().get(&method_call) {
1721-
Some(method) => {
1722-
match method.origin {
1723-
ty::MethodStatic(def_id) => {
1724-
def_id
1725-
}
1726-
ty::MethodStaticUnboxedClosure(def_id) => {
1727-
def_id
1728-
}
1729-
ty::MethodTypeParam(ty::MethodParam {
1730-
ref trait_ref,
1731-
method_num: index,
1732-
..
1733-
}) |
1734-
ty::MethodTraitObject(ty::MethodObject {
1735-
ref trait_ref,
1736-
method_num: index,
1737-
..
1738-
}) => {
1739-
ty::trait_item(cx.tcx, trait_ref.def_id, index).def_id()
1740-
}
1741-
}
1742-
}
1743-
None => return
1744-
}
1745-
}
1746-
_ => return
1747-
};
1748-
1749-
self.lint(cx, id, span);
1667+
stability::check_view_item(cx.tcx, item,
1668+
&mut |id, sp, stab| self.lint(cx, id, sp, stab));
17501669
}
17511670

17521671
fn check_item(&mut self, cx: &Context, item: &ast::Item) {
1753-
if self.is_internal(cx, item.span) { return }
1672+
stability::check_item(cx.tcx, item,
1673+
&mut |id, sp, stab| self.lint(cx, id, sp, stab));
1674+
}
17541675

1755-
match item.node {
1756-
ast::ItemTrait(_, _, ref supertraits, _) => {
1757-
for t in supertraits.iter() {
1758-
if let ast::TraitTyParamBound(ref t, _) = *t {
1759-
let id = ty::trait_ref_to_def_id(cx.tcx, &t.trait_ref);
1760-
self.lint(cx, id, t.trait_ref.path.span);
1761-
}
1762-
}
1763-
}
1764-
ast::ItemImpl(_, _, _, Some(ref t), _, _) => {
1765-
let id = ty::trait_ref_to_def_id(cx.tcx, t);
1766-
self.lint(cx, id, t.path.span);
1767-
}
1768-
_ => (/* pass */)
1769-
}
1676+
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
1677+
stability::check_expr(cx.tcx, e,
1678+
&mut |id, sp, stab| self.lint(cx, id, sp, stab));
17701679
}
17711680
}
17721681

src/librustc/lint/context.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,6 @@ impl LintStore {
316316
},
317317
None => unreachable!()
318318
}
319-
match self.by_name.get("unstable") {
320-
Some(&Id(lint_id)) => if self.get_level_source(lint_id).0 != Forbid {
321-
self.set_level(lint_id, (lvl, ReleaseChannel))
322-
},
323-
Some(&Renamed(_, lint_id)) => if self.get_level_source(lint_id).0 != Forbid {
324-
self.set_level(lint_id, (lvl, ReleaseChannel))
325-
},
326-
None => unreachable!()
327-
}
328319
}
329320
}
330321

0 commit comments

Comments
 (0)