Skip to content

Commit 9517e5f

Browse files
committed
---
yaml --- r: 91971 b: refs/heads/auto c: d2c405e h: refs/heads/master i: 91969: a5e090c 91967: e49d587 v: v3
1 parent e210af3 commit 9517e5f

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: b50b1628840daf849e548c83372f85bc13092314
16+
refs/heads/auto: d2c405eeff3930bf0c0777f06108a2eedcd456f6
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/front/feature_gate.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//! Features are enabled in programs via the crate-level attributes of
1919
//! #[feature(...)] with a comma-separated list of features.
2020
21+
use middle::lint;
22+
2123
use syntax::ast;
2224
use syntax::attr::AttrMetaMethods;
2325
use syntax::codemap::Span;
@@ -209,7 +211,10 @@ pub fn check_crate(sess: Session, crate: &ast::Crate) {
209211
directive not necessary");
210212
}
211213
None => {
212-
sess.span_err(mi.span, "unknown feature");
214+
sess.add_lint(lint::unknown_features,
215+
ast::CRATE_NODE_ID,
216+
mi.span,
217+
~"unknown feature");
213218
}
214219
}
215220
}

branches/auto/src/librustc/middle/lint.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use syntax::codemap::Span;
5959
use syntax::codemap;
6060
use syntax::parse::token;
6161
use syntax::{ast, ast_util, visit};
62+
use syntax::ast_util::IdVisitingOperation;
6263
use syntax::visit::Visitor;
6364

6465
#[deriving(Clone, Eq)]
@@ -77,6 +78,7 @@ pub enum lint {
7778
unused_unsafe,
7879
unsafe_block,
7980
attribute_usage,
81+
unknown_features,
8082

8183
managed_heap_memory,
8284
owned_heap_memory,
@@ -321,6 +323,13 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
321323
desc: "mass-change the level for lints which produce warnings",
322324
default: warn
323325
}),
326+
327+
("unknown_features",
328+
LintSpec {
329+
lint: unknown_features,
330+
desc: "unknown features found in create-level #[feature] directives",
331+
default: deny,
332+
}),
324333
];
325334

326335
/*
@@ -1320,7 +1329,7 @@ impl<'self> Visitor<()> for Context<'self> {
13201329
}
13211330
}
13221331

1323-
impl<'self> ast_util::IdVisitingOperation for Context<'self> {
1332+
impl<'self> IdVisitingOperation for Context<'self> {
13241333
fn visit_id(&self, id: ast::NodeId) {
13251334
match self.tcx.sess.lints.pop(&id) {
13261335
None => {}
@@ -1356,6 +1365,7 @@ pub fn check_crate(tcx: ty::ctxt,
13561365
cx.set_level(lint, level, CommandLine);
13571366
}
13581367
cx.with_lint_attrs(crate.attrs, |cx| {
1368+
cx.visit_id(ast::CRATE_NODE_ID);
13591369
cx.visit_ids(|v| {
13601370
v.visited_outermost = true;
13611371
visit::walk_crate(v, crate, ());

branches/auto/src/test/compile-fail/gated-bad-feature.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
foo(bar),
1414
foo = "baz"
1515
)];
16-
//~^^^^ ERROR: unknown feature
17-
//~^^^^ ERROR: malformed feature
18-
//~^^^^ ERROR: malformed feature
16+
//~^^^ ERROR: malformed feature
17+
//~^^^ ERROR: malformed feature
1918

2019
#[feature]; //~ ERROR: malformed feature
2120
#[feature = "foo"]; //~ ERROR: malformed feature
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deny(unknown_features)];
12+
13+
#[feature(this_is_not_a_feature)]; //~ ERROR: unknown feature
14+
15+
fn main() {}

0 commit comments

Comments
 (0)