Skip to content

Commit 03c1dd0

Browse files
committed
---
yaml --- r: 146905 b: refs/heads/try2 c: 503e5df h: refs/heads/master i: 146903: baed18e v: v3
1 parent 4adc062 commit 03c1dd0

File tree

9 files changed

+64
-17
lines changed

9 files changed

+64
-17
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: dfe38dbca4b62132d7512f767bca6ebe6ddfe931
8+
refs/heads/try2: 503e5df3f273dd7cb24f63098665d6c2c5268ebf
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,19 @@ Some productions are defined by exclusion of particular Unicode characters:
153153
~~~~ {.ebnf .gram}
154154
comment : block_comment | line_comment ;
155155
block_comment : "/*" block_comment_body * '*' + '/' ;
156-
block_comment_body : non_star * | '*' + non_slash_or_star ;
156+
block_comment_body : (block_comment | character) * ;
157157
line_comment : "//" non_eol * ;
158158
~~~~
159159

160160
Comments in Rust code follow the general C++ style of line and block-comment forms,
161161
with no nesting of block-comment delimiters.
162162

163-
Line comments beginning with _three_ slashes (`///`),
164-
and block comments beginning with a repeated asterisk in the block-open sequence (`/**`),
165-
are interpreted as a special syntax for `doc` [attributes](#attributes).
166-
That is, they are equivalent to writing `#[doc "..."]` around the comment's text.
163+
Line comments beginning with exactly _three_ slashes (`///`), and block
164+
comments beginning with a exactly one repeated asterisk in the block-open
165+
sequence (`/**`), are interpreted as a special syntax for `doc`
166+
[attributes](#attributes). That is, they are equivalent to writing
167+
`#[doc="..."]` around the body of the comment (this includes the comment
168+
characters themselves, ie `/// Foo` turns into `#[doc="/// Foo"]`).
167169

168170
Non-doc comments are interpreted as a form of whitespace.
169171

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ syn match rustCharacter /'\([^'\\]\|\\\([nrt0\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8
187187

188188
syn region rustCommentML start="/\*" end="\*/" contains=rustTodo
189189
syn region rustComment start="//" end="$" contains=rustTodo keepend
190-
syn region rustCommentMLDoc start="/\*\%(!\|\*/\@!\)" end="\*/" contains=rustTodo
191-
syn region rustCommentDoc start="//[/!]" end="$" contains=rustTodo keepend
190+
syn region rustCommentMLDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo
191+
syn region rustCommentDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo keepend
192192

193193
syn keyword rustTodo contained TODO FIXME XXX NB NOTE
194194

branches/try2/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/try2/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/try2/src/libsyntax/parse/lexer.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
317317
}
318318

319319
pub fn is_line_non_doc_comment(s: &str) -> bool {
320-
let s = s.trim_right();
321-
s.len() > 3 && s.chars().all(|ch| ch == '/')
320+
s.starts_with("////")
322321
}
323322

324323
// PRECONDITION: rdr.curr is not whitespace
@@ -378,8 +377,7 @@ fn consume_any_line_comment(rdr: @mut StringReader)
378377
}
379378

380379
pub fn is_block_non_doc_comment(s: &str) -> bool {
381-
assert!(s.len() >= 1u);
382-
s.slice(1u, s.len() - 1u).chars().all(|ch| ch == '*')
380+
s.starts_with("/***")
383381
}
384382

385383
// might return a sugared-doc-attr

branches/try2/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() {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
pub fn main() {
12+
//// I am not a doc comment!
13+
////////////////// still not a doc comment
14+
/////**** nope, me neither */
15+
/*** And neither am I! */
16+
5;
17+
/*****! certainly not I */
18+
}

0 commit comments

Comments
 (0)