Skip to content

Commit 3b90149

Browse files
committed
---
yaml --- r: 151498 b: refs/heads/try2 c: fa43727 h: refs/heads/master v: v3
1 parent b172a9a commit 3b90149

File tree

11 files changed

+49
-112
lines changed

11 files changed

+49
-112
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: 66f4f558cbe1df6a3ceff6c58ed7d994bed17cd5
8+
refs/heads/try2: fa43727781833cfbc17e3161dc131b9c243e965f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/rust.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,10 +1741,10 @@ import public items from their destination, not private items.
17411741
## Attributes
17421742

17431743
~~~~ {.notrust .ebnf .gram}
1744-
attribute : '#' '!' ? '[' meta_item ']' ;
1745-
meta_item : ident [ '=' literal
1746-
| '(' meta_seq ')' ] ? ;
1747-
meta_seq : meta_item [ ',' meta_seq ]* ;
1744+
attribute : '#' '!' ? '[' attr_list ']' ;
1745+
attr_list : attr [ ',' attr_list ]* ;
1746+
attr : ident [ '=' literal
1747+
| '(' attr_list ')' ] ? ;
17481748
~~~~
17491749

17501750
Static entities in Rust — crates, modules and items — may have _attributes_

branches/try2/src/libcore/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ mod should_not_exist;
106106
mod std {
107107
pub use clone;
108108
pub use cmp;
109-
pub use kinds;
110109

111110
#[cfg(test)] pub use realstd::fmt; // needed for fail!()
112111
#[cfg(test)] pub use realstd::rt; // needed for fail!()

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

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,38 +1367,28 @@ fn check_unsafe_block(cx: &Context, e: &ast::Expr) {
13671367
}
13681368
}
13691369

1370-
fn check_unused_mut_pat(cx: &Context, pats: &[@ast::Pat]) {
1371-
// collect all mutable pattern and group their NodeIDs by their Identifier to
1372-
// avoid false warnings in match arms with multiple patterns
1373-
let mut mutables = HashMap::new();
1374-
for &p in pats.iter() {
1375-
pat_util::pat_bindings(&cx.tcx.def_map, p, |mode, id, _, path| {
1376-
match mode {
1377-
ast::BindByValue(ast::MutMutable) => {
1378-
if path.segments.len() != 1 {
1379-
cx.tcx.sess.span_bug(p.span,
1380-
"mutable binding that doesn't consist \
1381-
of exactly one segment");
1382-
}
1383-
let ident = path.segments.get(0).identifier;
1384-
if !token::get_ident(ident).get().starts_with("_") {
1385-
mutables.insert_or_update_with(ident.name as uint, vec!(id), |_, old| {
1386-
old.push(id);
1387-
});
1388-
}
1389-
}
1390-
_ => {
1391-
}
1392-
}
1393-
});
1394-
}
1370+
fn check_unused_mut_pat(cx: &Context, p: &ast::Pat) {
1371+
match p.node {
1372+
ast::PatIdent(ast::BindByValue(ast::MutMutable),
1373+
ref path, _) if pat_util::pat_is_binding(&cx.tcx.def_map, p) => {
1374+
// `let mut _a = 1;` doesn't need a warning.
1375+
let initial_underscore = if path.segments.len() == 1 {
1376+
token::get_ident(path.segments
1377+
.get(0)
1378+
.identifier).get().starts_with("_")
1379+
} else {
1380+
cx.tcx.sess.span_bug(p.span,
1381+
"mutable binding that doesn't consist \
1382+
of exactly one segment")
1383+
};
13951384

1396-
let used_mutables = cx.tcx.used_mut_nodes.borrow();
1397-
for (_, v) in mutables.iter() {
1398-
if !v.iter().any(|e| used_mutables.contains(e)) {
1399-
cx.span_lint(UnusedMut, cx.tcx.map.span(*v.get(0)),
1400-
"variable does not need to be mutable");
1385+
if !initial_underscore &&
1386+
!cx.tcx.used_mut_nodes.borrow().contains(&p.id) {
1387+
cx.span_lint(UnusedMut, p.span,
1388+
"variable does not need to be mutable");
1389+
}
14011390
}
1391+
_ => ()
14021392
}
14031393
}
14041394

@@ -1694,6 +1684,7 @@ impl<'a> Visitor<()> for Context<'a> {
16941684
fn visit_pat(&mut self, p: &ast::Pat, _: ()) {
16951685
check_pat_non_uppercase_statics(self, p);
16961686
check_pat_uppercase_variable(self, p);
1687+
check_unused_mut_pat(self, p);
16971688

16981689
visit::walk_pat(self, p, ());
16991690
}
@@ -1709,11 +1700,6 @@ impl<'a> Visitor<()> for Context<'a> {
17091700
ast::ExprParen(expr) => if self.negated_expr_id == e.id {
17101701
self.negated_expr_id = expr.id
17111702
},
1712-
ast::ExprMatch(_, ref arms) => {
1713-
for a in arms.iter() {
1714-
check_unused_mut_pat(self, a.pats.as_slice());
1715-
}
1716-
},
17171703
_ => ()
17181704
};
17191705

@@ -1737,18 +1723,6 @@ impl<'a> Visitor<()> for Context<'a> {
17371723
check_unused_result(self, s);
17381724
check_unnecessary_parens_stmt(self, s);
17391725

1740-
match s.node {
1741-
ast::StmtDecl(d, _) => {
1742-
match d.node {
1743-
ast::DeclLocal(l) => {
1744-
check_unused_mut_pat(self, &[l.pat]);
1745-
},
1746-
_ => {}
1747-
}
1748-
},
1749-
_ => {}
1750-
}
1751-
17521726
visit::walk_stmt(self, s, ());
17531727
}
17541728

@@ -1758,10 +1732,6 @@ impl<'a> Visitor<()> for Context<'a> {
17581732
visit::walk_fn(this, fk, decl, body, span, id, ());
17591733
};
17601734

1761-
for a in decl.inputs.iter(){
1762-
check_unused_mut_pat(self, &[a.pat]);
1763-
}
1764-
17651735
match *fk {
17661736
visit::FkMethod(_, _, m) => {
17671737
self.with_lint_attrs(m.attrs.as_slice(), |cx| {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ pub fn regionck_expr(fcx: &FnCtxt, e: &ast::Expr) {
299299
// regionck assumes typeck succeeded
300300
rcx.visit_expr(e, ());
301301
}
302-
fcx.infcx().resolve_regions();
302+
fcx.infcx().resolve_regions_and_report_errors();
303303
}
304304

305305
pub fn regionck_fn(fcx: &FnCtxt, blk: &ast::Block) {
@@ -309,7 +309,7 @@ pub fn regionck_fn(fcx: &FnCtxt, blk: &ast::Block) {
309309
// regionck assumes typeck succeeded
310310
rcx.visit_block(blk, ());
311311
}
312-
fcx.infcx().resolve_regions();
312+
fcx.infcx().resolve_regions_and_report_errors();
313313
}
314314

315315
impl<'a> Visitor<()> for Rcx<'a> {

branches/try2/src/librustc/middle/typeck/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<'a> InferCtxt<'a> {
644644
self.region_vars.new_bound(binder_id)
645645
}
646646

647-
pub fn resolve_regions(&self) {
647+
pub fn resolve_regions_and_report_errors(&self) {
648648
let errors = self.region_vars.resolve_regions();
649649
self.report_region_errors(&errors); // see error_reporting.rs
650650
}

branches/try2/src/libstd/io/net/tcp.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ impl TcpStream {
169169
///
170170
/// For clarification on the semantics of interrupting a read and a write,
171171
/// take a look at `set_read_timeout` and `set_write_timeout`.
172-
#[experimental = "the timeout argument may change in type and value"]
173172
pub fn set_timeout(&mut self, timeout_ms: Option<u64>) {
174173
self.obj.set_timeout(timeout_ms)
175174
}
@@ -186,7 +185,6 @@ impl TcpStream {
186185
/// action is taken. Otherwise, the read operation will be scheduled to
187186
/// promptly return. If a timeout error is returned, then no data was read
188187
/// during the timeout period.
189-
#[experimental = "the timeout argument may change in type and value"]
190188
pub fn set_read_timeout(&mut self, timeout_ms: Option<u64>) {
191189
self.obj.set_read_timeout(timeout_ms)
192190
}
@@ -213,7 +211,6 @@ impl TcpStream {
213211
/// does not know how many bytes were written as part of the timeout
214212
/// operation. It may be the case that bytes continue to be written in an
215213
/// asynchronous fashion after the call to write returns.
216-
#[experimental = "the timeout argument may change in type and value"]
217214
pub fn set_write_timeout(&mut self, timeout_ms: Option<u64>) {
218215
self.obj.set_write_timeout(timeout_ms)
219216
}
@@ -947,26 +944,21 @@ mod test {
947944

948945
// Also make sure that even though the timeout is expired that we will
949946
// continue to receive any pending connections.
950-
//
951-
// FIXME: freebsd apparently never sees the pending connection, but
952-
// testing manually always works. Need to investigate this
953-
// flakiness.
954-
if !cfg!(target_os = "freebsd") {
955-
let (tx, rx) = channel();
956-
spawn(proc() {
957-
tx.send(TcpStream::connect(addr).unwrap());
958-
});
959-
let l = rx.recv();
960-
for i in range(0, 1001) {
961-
match a.accept() {
962-
Ok(..) => break,
963-
Err(ref e) if e.kind == TimedOut => {}
964-
Err(e) => fail!("error: {}", e),
965-
}
966-
::task::deschedule();
967-
if i == 1000 { fail!("should have a pending connection") }
947+
let (tx, rx) = channel();
948+
spawn(proc() {
949+
tx.send(TcpStream::connect(addr).unwrap());
950+
});
951+
let l = rx.recv();
952+
for i in range(0, 1001) {
953+
match a.accept() {
954+
Ok(..) => break,
955+
Err(ref e) if e.kind == TimedOut => {}
956+
Err(e) => fail!("error: {}", e),
968957
}
958+
::task::deschedule();
959+
if i == 1000 { fail!("should have a pending connection") }
969960
}
961+
drop(l);
970962

971963
// Unset the timeout and make sure that this always blocks.
972964
a.set_timeout(None);

branches/try2/src/libstd/io/net/udp.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,20 @@ impl UdpSocket {
147147
/// Sets the read/write timeout for this socket.
148148
///
149149
/// For more information, see `TcpStream::set_timeout`
150-
#[experimental = "the timeout argument may change in type and value"]
151150
pub fn set_timeout(&mut self, timeout_ms: Option<u64>) {
152151
self.obj.set_timeout(timeout_ms)
153152
}
154153

155154
/// Sets the read timeout for this socket.
156155
///
157156
/// For more information, see `TcpStream::set_timeout`
158-
#[experimental = "the timeout argument may change in type and value"]
159157
pub fn set_read_timeout(&mut self, timeout_ms: Option<u64>) {
160158
self.obj.set_read_timeout(timeout_ms)
161159
}
162160

163161
/// Sets the write timeout for this socket.
164162
///
165163
/// For more information, see `TcpStream::set_timeout`
166-
#[experimental = "the timeout argument may change in type and value"]
167164
pub fn set_write_timeout(&mut self, timeout_ms: Option<u64>) {
168165
self.obj.set_write_timeout(timeout_ms)
169166
}

branches/try2/src/libstd/io/net/unix.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,20 @@ impl UnixStream {
9797
/// Sets the read/write timeout for this socket.
9898
///
9999
/// For more information, see `TcpStream::set_timeout`
100-
#[experimental = "the timeout argument may change in type and value"]
101100
pub fn set_timeout(&mut self, timeout_ms: Option<u64>) {
102101
self.obj.set_timeout(timeout_ms)
103102
}
104103

105104
/// Sets the read timeout for this socket.
106105
///
107106
/// For more information, see `TcpStream::set_timeout`
108-
#[experimental = "the timeout argument may change in type and value"]
109107
pub fn set_read_timeout(&mut self, timeout_ms: Option<u64>) {
110108
self.obj.set_read_timeout(timeout_ms)
111109
}
112110

113111
/// Sets the write timeout for this socket.
114112
///
115113
/// For more information, see `TcpStream::set_timeout`
116-
#[experimental = "the timeout argument may change in type and value"]
117114
pub fn set_write_timeout(&mut self, timeout_ms: Option<u64>) {
118115
self.obj.set_write_timeout(timeout_ms)
119116
}

branches/try2/src/libstd/os.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ pub fn homedir() -> Option<Path> {
529529
* Returns the path to a temporary directory.
530530
*
531531
* On Unix, returns the value of the 'TMPDIR' environment variable if it is
532-
* set, otherwise for non-Android it returns '/tmp'. If Android, since there
533-
* is no global temporary folder (it is usually allocated per-app), we return
534-
* '/data/local/tmp'.
532+
* set and non-empty and '/tmp' otherwise.
533+
* On Android, there is no global temporary folder (it is usually allocated
534+
* per-app), hence returns '/data/tmp' which is commonly used.
535535
*
536536
* On Windows, returns the value of, in order, the 'TMP', 'TEMP',
537537
* 'USERPROFILE' environment variable if any are set and not the empty
@@ -554,13 +554,11 @@ pub fn tmpdir() -> Path {
554554

555555
#[cfg(unix)]
556556
fn lookup() -> Path {
557-
let default = if cfg!(target_os = "android") {
558-
Path::new("/data/local/tmp")
557+
if cfg!(target_os = "android") {
558+
Path::new("/data/tmp")
559559
} else {
560-
Path::new("/tmp")
561-
};
562-
563-
getenv_nonempty("TMPDIR").unwrap_or(default)
560+
getenv_nonempty("TMPDIR").unwrap_or(Path::new("/tmp"))
561+
}
564562
}
565563

566564
#[cfg(windows)]

branches/try2/src/test/compile-fail/lint-unused-mut-variables.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ fn main() {
2828
match 30 {
2929
mut x => {} //~ ERROR: variable does not need to be mutable
3030
}
31-
match (30, 2) {
32-
(mut x, 1) | //~ ERROR: variable does not need to be mutable
33-
(mut x, 2) |
34-
(mut x, 3) => {
35-
}
36-
_ => {}
37-
}
3831

3932
let x = |mut y: int| 10; //~ ERROR: variable does not need to be mutable
4033
fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
@@ -57,15 +50,6 @@ fn main() {
5750
}
5851
}
5952

60-
match (30, 2) {
61-
(mut x, 1) |
62-
(mut x, 2) |
63-
(mut x, 3) => {
64-
x = 21
65-
}
66-
_ => {}
67-
}
68-
6953
let x = |mut y: int| y = 32;
7054
fn nothing(mut foo: int) { foo = 37; }
7155

0 commit comments

Comments
 (0)