Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Jan 21, 2015
1 parent b50c7a5 commit 9d117c0
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 77 deletions.
2 changes: 1 addition & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ tidy:
| grep '^$(S)src/libbacktrace' -v \
| grep '^$(S)src/rust-installer' -v \
| xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py
$(CFG_PYTHON) $(S)src/etc/featureck.py $(S)src/
$(Q)$(CFG_PYTHON) $(S)src/etc/featureck.py $(S)src/


endif
Expand Down
21 changes: 11 additions & 10 deletions src/etc/featureck.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
line = line.replace("(", "").replace("),", "").replace(")", "")
parts = line.split(",")
if len(parts) != 3:
print "unexpected number of components in line: " + original_line
print "error: unexpected number of components in line: " + original_line
sys.exit(1)
feature_name = parts[0].strip().replace('"', "")
since = parts[1].strip().replace('"', "")
Expand Down Expand Up @@ -102,14 +102,15 @@
lib_features[feature_name] = feature_name
if lib_features_and_level.get((feature_name, level)) is None:
# Add it to the observed features
lib_features_and_level[(feature_name, level)] = (since, path, line_num, line)
lib_features_and_level[(feature_name, level)] = \
(since, path, line_num, line)
else:
# Verify that for this combination of feature_name and level the 'since'
# attribute matches.
(expected_since, source_path, source_line_num, source_line) = \
lib_features_and_level.get((feature_name, level))
if since != expected_since:
print "mismatch in " + level + " feature '" + feature_name + "'"
print "error: mismatch in " + level + " feature '" + feature_name + "'"
print "line " + str(source_line_num) + " of " + source_path + ":"
print source_line
print "line " + str(line_num) + " of " + path + ":"
Expand All @@ -118,13 +119,13 @@

# Verify that this lib feature doesn't duplicate a lang feature
if feature_name in language_feature_names:
print "lib feature '" + feature_name + "' duplicates a lang feature"
print "error: lib feature '" + feature_name + "' duplicates a lang feature"
print "line " + str(line_num) + " of " + path + ":"
print line
errors = True

else:
print "misformed stability attribute"
print "error: misformed stability attribute"
print "line " + str(line_num) + " of " + path + ":"
print line
errors = True
Expand All @@ -141,7 +142,7 @@
status = "unstable"
stable_since = None
partially_deprecated = False

if f[2] == "Accepted":
status = "stable"
if status == "stable":
Expand All @@ -165,7 +166,7 @@
is_deprecated = lib_features_and_level.get((name, "deprecated")) is not None

if is_stable and is_unstable:
print "feature '" + name + "' is both stable and unstable"
print "error: feature '" + name + "' is both stable and unstable"
errors = True

if is_stable:
Expand All @@ -189,7 +190,7 @@
for name in lib_feature_stats:
if language_feature_stats.get(name) is not None:
if not name in joint_features:
print "feature '" + name + "' is both a lang and lib feature but not whitelisted"
print "error: feature '" + name + "' is both a lang and lib feature but not whitelisted"
errors = True
lang_status = lang_feature_stats[name][3]
lib_status = lib_feature_stats[name][3]
Expand All @@ -199,7 +200,7 @@
lib_partially_deprecated = lib_feature_stats[name][5]

if lang_status != lib_status and lib_status != "deprecated":
print "feature '" + name + "' has lang status " + lang_status + \
print "error: feature '" + name + "' has lang status " + lang_status + \
" but lib status " + lib_status
errors = True

Expand All @@ -208,7 +209,7 @@
partially_deprecated = True

if lang_stable_since != lib_stable_since:
print "feature '" + name + "' has lang stable since " + lang_stable_since + \
print "error: feature '" + name + "' has lang stable since " + lang_stable_since + \
" but lib stable since " + lib_stable_since
errors = True

Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,11 +742,9 @@ pub struct Weak<T> {
}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
#[allow(unstable)]
impl<T> !marker::Send for Weak<T> {}

#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
#[allow(unstable)]
impl<T> !marker::Sync for Weak<T> {}


Expand Down
3 changes: 2 additions & 1 deletion src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ pub trait Hasher {

/// A common bound on the `Hasher` parameter to `Hash` implementations in order
/// to generically hash an aggregate.
#[experimental = "this trait will likely be replaced by io::Writer"]
#[unstable(feature = "unnamed_feature", since = "1.0.0",
reason = "this trait will likely be replaced by io::Writer")]
#[allow(missing_docs)]
pub trait Writer {
fn write(&mut self, bytes: &[u8]);
Expand Down
1 change: 0 additions & 1 deletion src/libcoretest/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ fn discard_doesnt_unborrow() {
}

#[test]
#[allow(unstable)]
fn clone_ref_updates_flag() {
let x = RefCell::new(0i);
{
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
None => {
// This is an 'unmarked' API, which should not exist
// in the standard library.
self.tcx.sess.span_err(span, "use of unmarked staged library feature");
self.tcx.sess.span_err(span, "use of unmarked library feature");
self.tcx.sess.span_note(span, "this is either a bug in the library you are \
using or a bug in the compiler - there is \
no way to use this feature");
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,

// Needs to go *after* expansion to be able to check the results of macro expansion.
time(time_passes, "complete gated feature checking", (), |_| {
let features =
let features =
syntax::feature_gate::check_crate(sess.codemap(),
&sess.parse_sess.span_diagnostic,
&krate);
Expand Down
1 change: 1 addition & 0 deletions src/test/auxiliary/lint_output_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![crate_name="lint_output_format"]
#![crate_type = "lib"]
#![staged_api]
#![unstable(feature = "unnamed_feature", since = "1.0.0")]

#[deprecated(feature = "oldstuff", since = "1.0.0")]
pub fn foo() -> uint {
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/lint-forbid-cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -F unstable
// compile-flags: -F deprecated

#![staged_api]
#[allow(unstable)] //~ ERROR allow(unstable) overruled by outer forbid(unstable)
#[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated)
fn main() {
}
8 changes: 5 additions & 3 deletions src/test/compile-fail/lint-output-format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags:-F unstable
// compile-flags: -F unused_features
// aux-build:lint_output_format.rs

extern crate lint_output_format; //~ ERROR: use of unmarked item
#![feature(foo)] //~ ERROR unused or unknown feature

extern crate lint_output_format; //~ WARNING: use of unstable library feature
use lint_output_format::{foo, bar};

fn main() {
let _x = foo(); //~ WARNING #[warn(deprecated)] on by default
let _y = bar(); //~ ERROR [-F unstable]
let _y = bar(); //~ WARNING: use of unstable library feature
}
69 changes: 34 additions & 35 deletions src/test/compile-fail/lint-stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
// aux-build:inherited_stability.rs
// aux-build:stability_cfg1.rs
// aux-build:stability_cfg2.rs
// ignore-tidy-linelength

#![deny(unstable)]
#![deny(deprecated)]
#![deny(unstable)]
#![allow(dead_code)]
#![staged_api]

#[macro_use]
extern crate lint_stability; //~ ERROR: use of unmarked item
extern crate lint_stability; //~ ERROR: use of unmarked library feature

mod cross_crate {
extern crate stability_cfg1;
extern crate stability_cfg2; //~ ERROR: use of unstable item
extern crate stability_cfg2; //~ WARNING: use of unstable library feature

use lint_stability::*;

Expand All @@ -39,17 +38,17 @@ mod cross_crate {
foo.method_deprecated_text(); //~ ERROR use of deprecated item: text
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text

unstable(); //~ ERROR use of unstable item
foo.method_unstable(); //~ ERROR use of unstable item
foo.trait_unstable(); //~ ERROR use of unstable item
unstable(); //~ WARNING use of unstable library feature
foo.method_unstable(); //~ WARNING use of unstable library feature
foo.trait_unstable(); //~ WARNING use of unstable library feature

unstable_text(); //~ ERROR use of unstable item: text
foo.method_unstable_text(); //~ ERROR use of unstable item: text
foo.trait_unstable_text(); //~ ERROR use of unstable item: text
unstable_text(); //~ WARNING use of unstable library feature 'unnamed_feature': text
foo.method_unstable_text(); //~ WARNING use of unstable library feature 'unnamed_feature': text
foo.trait_unstable_text(); //~ WARNING use of unstable library feature 'unnamed_feature': text

unmarked(); //~ ERROR use of unmarked item
foo.method_unmarked(); //~ ERROR use of unmarked item
foo.trait_unmarked(); //~ ERROR use of unmarked item
unmarked(); //~ ERROR use of unmarked library feature
foo.method_unmarked(); //~ ERROR use of unmarked library feature
foo.trait_unmarked(); //~ ERROR use of unmarked library feature

stable();
foo.method_stable();
Expand All @@ -60,23 +59,23 @@ mod cross_crate {
foo.trait_stable_text();

let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item
let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable item
let _ = UnmarkedStruct { i: 0 }; //~ ERROR use of unmarked item
let _ = UnstableStruct { i: 0 }; //~ WARNING use of unstable library feature
let _ = UnmarkedStruct { i: 0 }; //~ ERROR use of unmarked library feature
let _ = StableStruct { i: 0 };

let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item
let _ = UnstableUnitStruct; //~ ERROR use of unstable item
let _ = UnmarkedUnitStruct; //~ ERROR use of unmarked item
let _ = UnstableUnitStruct; //~ WARNING use of unstable library feature
let _ = UnmarkedUnitStruct; //~ ERROR use of unmarked library feature
let _ = StableUnitStruct;

let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item
let _ = Enum::UnstableVariant; //~ ERROR use of unstable item
let _ = Enum::UnmarkedVariant; //~ ERROR use of unmarked item
let _ = Enum::UnstableVariant; //~ WARNING use of unstable library feature
let _ = Enum::UnmarkedVariant; //~ ERROR use of unmarked library feature
let _ = Enum::StableVariant;

let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item
let _ = UnstableTupleStruct (1); //~ ERROR use of unstable item
let _ = UnmarkedTupleStruct (1); //~ ERROR use of unmarked item
let _ = UnstableTupleStruct (1); //~ WARNING use of unstable library feature
let _ = UnmarkedTupleStruct (1); //~ ERROR use of unmarked library feature
let _ = StableTupleStruct (1);

// At the moment, the lint checker only checks stability in
Expand All @@ -93,47 +92,47 @@ mod cross_crate {
fn test_method_param<F: Trait>(foo: F) {
foo.trait_deprecated(); //~ ERROR use of deprecated item
foo.trait_deprecated_text(); //~ ERROR use of deprecated item: text
foo.trait_unstable(); //~ ERROR use of unstable item
foo.trait_unstable_text(); //~ ERROR use of unstable item: text
foo.trait_unmarked(); //~ ERROR use of unmarked item
foo.trait_unstable(); //~ WARNING use of unstable library feature
foo.trait_unstable_text(); //~ WARNING use of unstable library feature 'unnamed_feature': text
foo.trait_unmarked(); //~ ERROR use of unmarked library feature
foo.trait_stable();
}

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(); //~ ERROR use of unstable item
foo.trait_unstable_text(); //~ ERROR use of unstable item: text
foo.trait_unmarked(); //~ ERROR use of unmarked item
foo.trait_unstable(); //~ WARNING use of unstable library feature
foo.trait_unstable_text(); //~ WARNING use of unstable library feature 'unnamed_feature': text
foo.trait_unmarked(); //~ ERROR use of unmarked library feature
foo.trait_stable();
}

struct S;

impl UnstableTrait for S { } //~ ERROR use of unstable item
impl UnstableTrait for S { } //~ WARNING use of unstable library feature

trait LocalTrait : UnstableTrait { } //~ ERROR use of unstable item
trait LocalTrait : UnstableTrait { } //~ WARNING use of unstable library feature
}

mod inheritance {
extern crate inherited_stability; //~ ERROR: use of unstable item
extern crate inherited_stability; //~ WARNING: use of unstable library feature
use self::inherited_stability::*;

fn test_inheritance() {
unstable(); //~ ERROR use of unstable item
unstable(); //~ WARNING use of unstable library feature
stable();

stable_mod::unstable(); //~ ERROR use of unstable item
stable_mod::unstable(); //~ WARNING use of unstable library feature
stable_mod::stable();

unstable_mod::deprecated(); //~ ERROR use of deprecated item
unstable_mod::unstable(); //~ ERROR use of unstable item
unstable_mod::unstable(); //~ WARNING use of unstable library feature

let _ = Unstable::UnstableVariant; //~ ERROR use of unstable item
let _ = Unstable::UnstableVariant; //~ WARNING use of unstable library feature
let _ = Unstable::StableVariant;

let x: usize = 0;
x.unstable(); //~ ERROR use of unstable item
x.unstable(); //~ WARNING use of unstable library feature
x.stable();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/lint-unknown-feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(unknown_features)]
#![deny(unused_features)]

#![feature(this_is_not_a_feature)] //~ ERROR: unknown feature
#![feature(this_is_not_a_feature)] //~ ERROR: unused or unknown feature

fn main() {}
18 changes: 0 additions & 18 deletions src/test/compile-fail/simd-experimental.rs

This file was deleted.

0 comments on commit 9d117c0

Please sign in to comment.