Skip to content

Commit 9ef3e34

Browse files
committed
---
yaml --- r: 65264 b: refs/heads/master c: b5ab101 h: refs/heads/master v: v3
1 parent c94ebea commit 9ef3e34

File tree

6 files changed

+17
-113
lines changed

6 files changed

+17
-113
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3d61931fcac13aadc88ece7e48567f7ff503fba5
2+
refs/heads/master: b5ab1012f1f5786f550e511ba1302a22c85fcd71
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/doc/rust.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,10 +2435,11 @@ match x {
24352435
}
24362436
~~~~
24372437

2438-
Patterns that bind variables default to binding to a copy of the matched value. This can be made
2439-
explicit using the ```copy``` keyword, changed to bind to a borrowed pointer by using the ```ref```
2440-
keyword, or to a mutable borrowed pointer using ```ref mut```, or the value can be moved into
2441-
the new binding using ```move```.
2438+
Patterns that bind variables default to binding to a copy or move of the matched value
2439+
(depending on the matched value's type).
2440+
This can be made explicit using the ```copy``` keyword,
2441+
changed to bind to a borrowed pointer by using the ```ref``` keyword,
2442+
or to a mutable borrowed pointer using ```ref mut```.
24422443

24432444
A pattern that's just an identifier,
24442445
like `Nil` in the previous answer,

trunk/src/librustc/middle/lint.rs

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ pub enum lint {
8282
dead_assignment,
8383
unused_mut,
8484
unnecessary_allocation,
85-
86-
missing_struct_doc,
87-
missing_trait_doc,
8885
}
8986

9087
pub fn level_to_str(lv: level) -> &'static str {
@@ -255,20 +252,6 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
255252
desc: "detects unnecessary allocations that can be eliminated",
256253
default: warn
257254
}),
258-
259-
("missing_struct_doc",
260-
LintSpec {
261-
lint: missing_struct_doc,
262-
desc: "detects missing documentation for structs",
263-
default: allow
264-
}),
265-
266-
("missing_trait_doc",
267-
LintSpec {
268-
lint: missing_trait_doc,
269-
desc: "detects missing documentation for traits",
270-
default: allow
271-
}),
272255
];
273256

274257
/*
@@ -969,69 +952,6 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> {
969952
})
970953
}
971954

972-
fn lint_missing_struct_doc(cx: @mut Context) -> visit::vt<()> {
973-
visit::mk_simple_visitor(@visit::SimpleVisitor {
974-
visit_struct_field: |field| {
975-
let relevant = match field.node.kind {
976-
ast::named_field(_, vis) => vis != ast::private,
977-
ast::unnamed_field => false,
978-
};
979-
980-
if relevant {
981-
let mut has_doc = false;
982-
for field.node.attrs.each |attr| {
983-
if attr.node.is_sugared_doc {
984-
has_doc = true;
985-
break;
986-
}
987-
}
988-
if !has_doc {
989-
cx.span_lint(missing_struct_doc, field.span, "missing documentation \
990-
for a field.");
991-
}
992-
}
993-
},
994-
.. *visit::default_simple_visitor()
995-
})
996-
}
997-
998-
fn lint_missing_trait_doc(cx: @mut Context) -> visit::vt<()> {
999-
visit::mk_simple_visitor(@visit::SimpleVisitor {
1000-
visit_trait_method: |method| {
1001-
let mut has_doc = false;
1002-
let span = match copy *method {
1003-
ast::required(m) => {
1004-
for m.attrs.each |attr| {
1005-
if attr.node.is_sugared_doc {
1006-
has_doc = true;
1007-
break;
1008-
}
1009-
}
1010-
m.span
1011-
},
1012-
ast::provided(m) => {
1013-
if m.vis == ast::private {
1014-
has_doc = true;
1015-
} else {
1016-
for m.attrs.each |attr| {
1017-
if attr.node.is_sugared_doc {
1018-
has_doc = true;
1019-
break;
1020-
}
1021-
}
1022-
}
1023-
m.span
1024-
}
1025-
};
1026-
if !has_doc {
1027-
cx.span_lint(missing_trait_doc, span, "missing documentation \
1028-
for a method.");
1029-
}
1030-
},
1031-
.. *visit::default_simple_visitor()
1032-
})
1033-
}
1034-
1035955
pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
1036956
let cx = @mut Context {
1037957
dict: @get_lint_dict(),
@@ -1060,8 +980,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::crate) {
1060980
cx.add_lint(lint_unused_mut(cx));
1061981
cx.add_lint(lint_session(cx));
1062982
cx.add_lint(lint_unnecessary_allocations(cx));
1063-
cx.add_lint(lint_missing_struct_doc(cx));
1064-
cx.add_lint(lint_missing_trait_doc(cx));
1065983

1066984
// type inference doesn't like this being declared below, we need to tell it
1067985
// what the type of this first function is...

trunk/src/libstd/cell.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,11 @@ Similar to a mutable option type, but friendlier.
2121
*/
2222

2323
#[mutable]
24-
#[deriving(Clone)]
24+
#[deriving(Clone, DeepClone, Eq)]
2525
pub struct Cell<T> {
2626
priv value: Option<T>
2727
}
2828

29-
impl<T: DeepClone> DeepClone for Cell<T> {
30-
fn deep_clone(&self) -> Cell<T> {
31-
Cell{value: self.value.deep_clone()}
32-
}
33-
}
34-
35-
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
36-
fn eq(&self, other: &Cell<T>) -> bool {
37-
(self.value) == (other.value)
38-
}
39-
fn ne(&self, other: &Cell<T>) -> bool { !self.eq(other) }
40-
}
41-
4229
/// Creates a new full cell with the given value.
4330
pub fn Cell<T>(value: T) -> Cell<T> {
4431
Cell { value: Some(value) }

trunk/src/libstd/option.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,12 @@ use clone::DeepClone;
5454
#[cfg(test)] use str;
5555

5656
/// The option type
57-
#[deriving(Clone, Eq)]
57+
#[deriving(Clone, DeepClone, Eq)]
5858
pub enum Option<T> {
5959
None,
6060
Some(T),
6161
}
6262

63-
impl<T: DeepClone> DeepClone for Option<T> {
64-
fn deep_clone(&self) -> Option<T> {
65-
match *self {
66-
Some(ref x) => Some(x.deep_clone()),
67-
None => None
68-
}
69-
}
70-
}
71-
7263
impl<T:Ord> Ord for Option<T> {
7364
fn lt(&self, other: &Option<T>) -> bool {
7465
match (self, other) {

trunk/src/libsyntax/parse/lexer.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
247247
}
248248

249249
pub fn is_line_non_doc_comment(s: &str) -> bool {
250-
s.trim_right().all(|ch| ch == '/')
250+
let s = s.trim_right();
251+
s.len() > 3 && s.all(|ch| ch == '/')
251252
}
252253

253254
// PRECONDITION: rdr.curr is not whitespace
@@ -268,7 +269,7 @@ fn consume_any_line_comment(rdr: @mut StringReader)
268269
str::push_char(&mut acc, rdr.curr);
269270
bump(rdr);
270271
}
271-
// but comments with only "/"s are not
272+
// but comments with only more "/"s are not
272273
if !is_line_non_doc_comment(acc) {
273274
return Some(TokenAndSpan{
274275
tok: token::DOC_COMMENT(rdr.interner.intern(acc)),
@@ -891,4 +892,10 @@ mod test {
891892
let id = env.interner.intern("abc");
892893
assert_eq!(tok, token::LIFETIME(id));
893894
}
895+
896+
#[test] fn line_doc_comments() {
897+
assert!(!is_line_non_doc_comment("///"));
898+
assert!(!is_line_non_doc_comment("/// blah"));
899+
assert!(is_line_non_doc_comment("////"));
900+
}
894901
}

0 commit comments

Comments
 (0)