Skip to content

Commit 4a543a6

Browse files
committed
---
yaml --- r: 152374 b: refs/heads/try2 c: 3654ac6 h: refs/heads/master v: v3
1 parent 2ee862b commit 4a543a6

File tree

9 files changed

+131
-74
lines changed

9 files changed

+131
-74
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 010d96ede9168df42c0218c41863a1a013599772
8+
refs/heads/try2: 3654ac68be4f1d8e9c3c4e45f3282dd78dc4bd73
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/licenseck.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"libstd/sync/mpmc_bounded_queue.rs", # BSD
4444
"libsync/mpsc_intrusive.rs", # BSD
4545
"test/bench/shootout-meteor.rs", # BSD
46-
"test/bench/shootout-regex-dna.rs", # BSD
4746
]
4847

4948
def check_license(name, contents):

branches/try2/src/librustc/middle/lang_items.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ impl<'a> LanguageItemCollector<'a> {
187187

188188
pub fn extract(attrs: &[ast::Attribute]) -> Option<InternedString> {
189189
for attribute in attrs.iter() {
190-
match attribute.name_str_pair() {
191-
Some((ref key, ref value)) if key.equiv(&("lang")) => {
192-
return Some((*value).clone());
190+
match attribute.value_str() {
191+
Some(ref value) if attribute.check_name("lang") => {
192+
return Some(value.clone());
193193
}
194-
Some(..) | None => {}
194+
_ => {}
195195
}
196196
}
197197

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ fn check_attrs_usage(cx: &Context, attrs: &[ast::Attribute]) {
11831183
}
11841184
}
11851185

1186-
fn check_unused_attribute(cx: &Context, attrs: &[ast::Attribute]) {
1186+
fn check_unused_attribute(cx: &Context, attr: &ast::Attribute) {
11871187
static ATTRIBUTE_WHITELIST: &'static [&'static str] = &'static [
11881188
// FIXME: #14408 whitelist docs since rustdoc looks at them
11891189
"doc",
@@ -1218,17 +1218,16 @@ fn check_unused_attribute(cx: &Context, attrs: &[ast::Attribute]) {
12181218
"stable",
12191219
"unstable",
12201220
];
1221-
for attr in attrs.iter() {
1222-
for &name in ATTRIBUTE_WHITELIST.iter() {
1223-
if attr.check_name(name) {
1224-
break;
1225-
}
1226-
}
12271221

1228-
if !attr::is_used(attr) {
1229-
cx.span_lint(UnusedAttribute, attr.span, "unused attribute");
1222+
for &name in ATTRIBUTE_WHITELIST.iter() {
1223+
if attr.check_name(name) {
1224+
break;
12301225
}
12311226
}
1227+
1228+
if !attr::is_used(attr) {
1229+
cx.span_lint(UnusedAttribute, attr.span, "unused attribute");
1230+
}
12321231
}
12331232

12341233
fn check_heap_expr(cx: &Context, e: &ast::Expr) {
@@ -1836,7 +1835,6 @@ impl<'a> Visitor<()> for Context<'a> {
18361835
check_heap_item(cx, it);
18371836
check_missing_doc_item(cx, it);
18381837
check_attrs_usage(cx, it.attrs.as_slice());
1839-
check_unused_attribute(cx, it.attrs.as_slice());
18401838
check_raw_ptr_deriving(cx, it);
18411839

18421840
cx.visit_ids(|v| v.visit_item(it, ()));
@@ -2003,6 +2001,10 @@ impl<'a> Visitor<()> for Context<'a> {
20032001

20042002
// FIXME(#10894) should continue recursing
20052003
fn visit_ty(&mut self, _t: &ast::Ty, _: ()) {}
2004+
2005+
fn visit_attribute(&mut self, attr: &ast::Attribute, _: ()) {
2006+
check_unused_attribute(self, attr);
2007+
}
20062008
}
20072009

20082010
impl<'a> IdVisitingOperation for Context<'a> {
@@ -2054,7 +2056,6 @@ pub fn check_crate(tcx: &ty::ctxt,
20542056
check_crate_attrs_usage(cx, krate.attrs.as_slice());
20552057
// since the root module isn't visited as an item (because it isn't an item), warn for it
20562058
// here.
2057-
check_unused_attribute(cx, krate.attrs.as_slice());
20582059
check_missing_doc_attrs(cx,
20592060
None,
20602061
krate.attrs.as_slice(),

branches/try2/src/librustc/middle/typeck/check/_match.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
460460
{
461461
// no-op
462462
} else if !ty::type_is_numeric(b_ty) && !ty::type_is_char(b_ty) {
463-
tcx.sess.span_err(pat.span,
464-
"only char and numeric types are allowed in range");
463+
tcx.sess.span_err(pat.span, "non-numeric type used in range");
465464
} else {
466465
match valid_range_bounds(fcx.ccx, begin, end) {
467466
Some(false) => {

branches/try2/src/libsyntax/visit.rs

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub trait Visitor<E: Clone> {
128128
fn visit_path(&mut self, path: &Path, _id: ast::NodeId, e: E) {
129129
walk_path(self, path, e)
130130
}
131+
fn visit_attribute(&mut self, _attr: &Attribute, _e: E) {}
131132
}
132133

133134
pub fn walk_inlined_item<E: Clone, V: Visitor<E>>(visitor: &mut V,
@@ -142,7 +143,10 @@ pub fn walk_inlined_item<E: Clone, V: Visitor<E>>(visitor: &mut V,
142143

143144

144145
pub fn walk_crate<E: Clone, V: Visitor<E>>(visitor: &mut V, krate: &Crate, env: E) {
145-
visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID, env)
146+
visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID, env.clone());
147+
for attr in krate.attrs.iter() {
148+
visitor.visit_attribute(attr, env.clone());
149+
}
146150
}
147151

148152
pub fn walk_mod<E: Clone, V: Visitor<E>>(visitor: &mut V, module: &Mod, env: E) {
@@ -158,7 +162,7 @@ pub fn walk_mod<E: Clone, V: Visitor<E>>(visitor: &mut V, module: &Mod, env: E)
158162
pub fn walk_view_item<E: Clone, V: Visitor<E>>(visitor: &mut V, vi: &ViewItem, env: E) {
159163
match vi.node {
160164
ViewItemExternCrate(name, _, _) => {
161-
visitor.visit_ident(vi.span, name, env)
165+
visitor.visit_ident(vi.span, name, env.clone())
162166
}
163167
ViewItemUse(ref vp) => {
164168
match vp.node {
@@ -178,6 +182,9 @@ pub fn walk_view_item<E: Clone, V: Visitor<E>>(visitor: &mut V, vi: &ViewItem, e
178182
}
179183
}
180184
}
185+
for attr in vi.attrs.iter() {
186+
visitor.visit_attribute(attr, env.clone());
187+
}
181188
}
182189

183190
pub fn walk_local<E: Clone, V: Visitor<E>>(visitor: &mut V, local: &Local, env: E) {
@@ -213,18 +220,18 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &Item, env: E)
213220
match item.node {
214221
ItemStatic(typ, _, expr) => {
215222
visitor.visit_ty(typ, env.clone());
216-
visitor.visit_expr(expr, env);
223+
visitor.visit_expr(expr, env.clone());
217224
}
218225
ItemFn(declaration, fn_style, abi, ref generics, body) => {
219226
visitor.visit_fn(&FkItemFn(item.ident, generics, fn_style, abi),
220227
declaration,
221228
body,
222229
item.span,
223230
item.id,
224-
env)
231+
env.clone())
225232
}
226233
ItemMod(ref module) => {
227-
visitor.visit_mod(module, item.span, item.id, env)
234+
visitor.visit_mod(module, item.span, item.id, env.clone())
228235
}
229236
ItemForeignMod(ref foreign_module) => {
230237
for view_item in foreign_module.view_items.iter() {
@@ -236,11 +243,11 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &Item, env: E)
236243
}
237244
ItemTy(typ, ref type_parameters) => {
238245
visitor.visit_ty(typ, env.clone());
239-
visitor.visit_generics(type_parameters, env)
246+
visitor.visit_generics(type_parameters, env.clone())
240247
}
241248
ItemEnum(ref enum_definition, ref type_parameters) => {
242249
visitor.visit_generics(type_parameters, env.clone());
243-
walk_enum_def(visitor, enum_definition, type_parameters, env)
250+
walk_enum_def(visitor, enum_definition, type_parameters, env.clone())
244251
}
245252
ItemImpl(ref type_parameters,
246253
ref trait_reference,
@@ -263,7 +270,7 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &Item, env: E)
263270
item.ident,
264271
generics,
265272
item.id,
266-
env)
273+
env.clone())
267274
}
268275
ItemTrait(ref generics, _, ref trait_paths, ref methods) => {
269276
visitor.visit_generics(generics, env.clone());
@@ -276,7 +283,10 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &Item, env: E)
276283
visitor.visit_trait_method(method, env.clone())
277284
}
278285
}
279-
ItemMac(ref macro) => visitor.visit_mac(macro, env),
286+
ItemMac(ref macro) => visitor.visit_mac(macro, env.clone()),
287+
}
288+
for attr in item.attrs.iter() {
289+
visitor.visit_attribute(attr, env.clone());
280290
}
281291
}
282292

@@ -310,9 +320,12 @@ pub fn walk_variant<E: Clone, V: Visitor<E>>(visitor: &mut V,
310320
}
311321
}
312322
match variant.node.disr_expr {
313-
Some(expr) => visitor.visit_expr(expr, env),
323+
Some(expr) => visitor.visit_expr(expr, env.clone()),
314324
None => ()
315325
}
326+
for attr in variant.node.attrs.iter() {
327+
visitor.visit_attribute(attr, env.clone());
328+
}
316329
}
317330

318331
pub fn skip_ty<E, V: Visitor<E>>(_: &mut V, _: &Ty, _: E) {
@@ -469,9 +482,13 @@ pub fn walk_foreign_item<E: Clone, V: Visitor<E>>(visitor: &mut V,
469482
match foreign_item.node {
470483
ForeignItemFn(function_declaration, ref generics) => {
471484
walk_fn_decl(visitor, function_declaration, env.clone());
472-
visitor.visit_generics(generics, env)
485+
visitor.visit_generics(generics, env.clone())
473486
}
474-
ForeignItemStatic(typ, _) => visitor.visit_ty(typ, env),
487+
ForeignItemStatic(typ, _) => visitor.visit_ty(typ, env.clone()),
488+
}
489+
490+
for attr in foreign_item.attrs.iter() {
491+
visitor.visit_attribute(attr, env.clone());
475492
}
476493
}
477494

@@ -525,7 +542,10 @@ pub fn walk_method_helper<E: Clone, V: Visitor<E>>(visitor: &mut V,
525542
method.body,
526543
method.span,
527544
method.id,
528-
env)
545+
env.clone());
546+
for attr in method.attrs.iter() {
547+
visitor.visit_attribute(attr, env.clone());
548+
}
529549
}
530550

531551
pub fn walk_fn<E: Clone, V: Visitor<E>>(visitor: &mut V,
@@ -560,7 +580,10 @@ pub fn walk_ty_method<E: Clone, V: Visitor<E>>(visitor: &mut V,
560580
visitor.visit_ty(argument_type.ty, env.clone())
561581
}
562582
visitor.visit_generics(&method_type.generics, env.clone());
563-
visitor.visit_ty(method_type.decl.output, env);
583+
visitor.visit_ty(method_type.decl.output, env.clone());
584+
for attr in method_type.attrs.iter() {
585+
visitor.visit_attribute(attr, env.clone());
586+
}
564587
}
565588

566589
pub fn walk_trait_method<E: Clone, V: Visitor<E>>(visitor: &mut V,
@@ -596,7 +619,11 @@ pub fn walk_struct_field<E: Clone, V: Visitor<E>>(visitor: &mut V,
596619
_ => {}
597620
}
598621

599-
visitor.visit_ty(struct_field.node.ty, env)
622+
visitor.visit_ty(struct_field.node.ty, env.clone());
623+
624+
for attr in struct_field.node.attrs.iter() {
625+
visitor.visit_attribute(attr, env.clone());
626+
}
600627
}
601628

602629
pub fn walk_block<E: Clone, V: Visitor<E>>(visitor: &mut V, block: &Block, env: E) {
@@ -784,5 +811,8 @@ pub fn walk_arm<E: Clone, V: Visitor<E>>(visitor: &mut V, arm: &Arm, env: E) {
784811
visitor.visit_pat(*pattern, env.clone())
785812
}
786813
walk_expr_opt(visitor, arm.guard, env.clone());
787-
visitor.visit_expr(arm.body, env)
814+
visitor.visit_expr(arm.body, env.clone());
815+
for attr in arm.attrs.iter() {
816+
visitor.visit_attribute(attr, env.clone());
817+
}
788818
}

branches/try2/src/test/bench/shootout-regex-dna.rs

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,12 @@
1-
// The Computer Language Benchmarks Game
2-
// http://benchmarksgame.alioth.debian.org/
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
34
//
4-
// contributed by the Rust Project Developers
5-
6-
// Copyright (c) 2014 The Rust Project Developers
7-
//
8-
// All rights reserved.
9-
//
10-
// Redistribution and use in source and binary forms, with or without
11-
// modification, are permitted provided that the following conditions
12-
// are met:
13-
//
14-
// - Redistributions of source code must retain the above copyright
15-
// notice, this list of conditions and the following disclaimer.
16-
//
17-
// - Redistributions in binary form must reproduce the above copyright
18-
// notice, this list of conditions and the following disclaimer in
19-
// the documentation and/or other materials provided with the
20-
// distribution.
21-
//
22-
// - Neither the name of "The Computer Language Benchmarks Game" nor
23-
// the name of "The Computer Language Shootout Benchmarks" nor the
24-
// names of its contributors may be used to endorse or promote
25-
// products derived from this software without specific prior
26-
// written permission.
27-
//
28-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31-
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32-
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33-
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34-
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35-
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36-
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37-
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38-
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39-
// OF THE POSSIBILITY OF SUCH DAMAGE.
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.
4010

4111
// FIXME(#13725) windows needs fixing.
4212
// ignore-win32

branches/try2/src/test/compile-fail/match-range-fail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
//error-pattern: lower range bound
12-
//error-pattern: only char and numeric types
12+
//error-pattern: non-numeric
1313
//error-pattern: mismatched types
1414

1515
fn main() {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
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+
#![deny(unused_attribute)]
11+
#![allow(attribute_usage, dead_code, unused_imports)]
12+
13+
#![foo] //~ ERROR unused attribute
14+
15+
#[foo] //~ ERROR unused attribute
16+
extern crate std;
17+
18+
#[foo] //~ ERROR unused attribute
19+
use std::collections;
20+
21+
#[foo] //~ ERROR unused attribute
22+
extern "C" {
23+
#[foo] //~ ERROR unused attribute
24+
fn foo();
25+
}
26+
27+
#[foo] //~ ERROR unused attribute
28+
mod foo {
29+
#[foo] //~ ERROR unused attribute
30+
pub enum Foo {
31+
#[foo] //~ ERROR unused attribute
32+
Bar,
33+
}
34+
}
35+
36+
#[foo] //~ ERROR unused attribute
37+
fn bar(f: foo::Foo) {
38+
match f {
39+
#[foo] //~ ERROR unused attribute
40+
foo::Bar => {}
41+
}
42+
}
43+
44+
#[foo] //~ ERROR unused attribute
45+
struct Foo {
46+
#[foo] //~ ERROR unused attribute
47+
a: int
48+
}
49+
50+
#[foo] //~ ERROR unused attribute
51+
trait Baz {
52+
#[foo] //~ ERROR unused attribute
53+
fn blah();
54+
#[foo] //~ ERROR unused attribute
55+
fn blah2() {}
56+
}
57+
58+
fn main() {}

0 commit comments

Comments
 (0)