Skip to content

Commit 5bd7cff

Browse files
committed
---
yaml --- r: 149381 b: refs/heads/try2 c: dcee327 h: refs/heads/master i: 149379: ba304d3 v: v3
1 parent 63ed93f commit 5bd7cff

File tree

31 files changed

+106
-425
lines changed

31 files changed

+106
-425
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: 879e8aa7be06a53cd6cd9cc714e85a13c909c0ea
8+
refs/heads/try2: dcee327c355e0289600ab4b0ae224645363bb858
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/tutorial.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,24 +1750,6 @@ closures, but they also own them: that is, no other code can access
17501750
them. Owned closures are used in concurrent code, particularly
17511751
for spawning [tasks][tasks].
17521752
1753-
Closures can be used to spawn tasks.
1754-
A practical example of this pattern is found when using the `spawn` function,
1755-
which starts a new task.
1756-
1757-
~~~~
1758-
use std::task::spawn;
1759-
1760-
// proc is the closure which will be spawned.
1761-
spawn(proc() {
1762-
debug!("I'm a new task")
1763-
});
1764-
~~~~
1765-
1766-
> ***Note:*** If you want to see the output of `debug!` statements, you will need to turn on
1767-
> `debug!` logging. To enable `debug!` logging, set the RUST_LOG environment
1768-
> variable to the name of your crate, which, for a file named `foo.rs`, will be
1769-
> `foo` (e.g., with bash, `export RUST_LOG=foo`).
1770-
17711753
## Closure compatibility
17721754
17731755
Rust closures have a convenient subtyping property: you can pass any kind of
@@ -1789,6 +1771,45 @@ call_twice(function);
17891771
> in small ways. At the moment they can be unsound in some
17901772
> scenarios, particularly with non-copyable types.
17911773
1774+
## Do syntax
1775+
1776+
The `do` expression makes it easier to call functions that take procedures
1777+
as arguments.
1778+
1779+
Consider this function that takes a procedure:
1780+
1781+
~~~~
1782+
fn call_it(op: proc(v: int)) {
1783+
op(10)
1784+
}
1785+
~~~~
1786+
1787+
As a caller, if we use a closure to provide the final operator
1788+
argument, we can write it in a way that has a pleasant, block-like
1789+
structure.
1790+
1791+
~~~~
1792+
# fn call_it(op: proc(v: int)) { }
1793+
call_it(proc(n) {
1794+
println!("{}", n);
1795+
});
1796+
~~~~
1797+
1798+
A practical example of this pattern is found when using the `spawn` function,
1799+
which starts a new task.
1800+
1801+
~~~~
1802+
use std::task::spawn;
1803+
spawn(proc() {
1804+
debug!("I'm a new task")
1805+
});
1806+
~~~~
1807+
1808+
If you want to see the output of `debug!` statements, you will need to turn on
1809+
`debug!` logging. To enable `debug!` logging, set the RUST_LOG environment
1810+
variable to the name of your crate, which, for a file named `foo.rs`, will be
1811+
`foo` (e.g., with bash, `export RUST_LOG=foo`).
1812+
17921813
# Methods
17931814
17941815
Methods are like functions except that they always begin with a special argument,

branches/try2/src/libextra/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ impl<T: Writer> ConsoleTestState<T> {
555555
}
556556
}
557557
}
558-
if_ok!(self.write_plain(format!("result of ratchet: {} metrics added, \
558+
if_ok!(self.write_plain(format!("result of ratchet: {} matrics added, \
559559
{} removed, {} improved, {} regressed, \
560560
{} noise\n",
561561
added, removed, improved, regressed,

branches/try2/src/libextra/url.rs

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,6 @@ pub struct Url {
5555
fragment: Option<~str>
5656
}
5757

58-
#[deriving(Clone, Eq)]
59-
pub struct Path {
60-
/// The path component of a URL, for example `/foo/bar`.
61-
path: ~str,
62-
/// The query component of a URL. `~[(~"baz", ~"qux")]` represents the
63-
/// fragment `baz=qux` in the above example.
64-
query: Query,
65-
/// The fragment component, such as `quz`. Doesn't include the leading `#` character.
66-
fragment: Option<~str>
67-
}
68-
6958
/// An optional subcomponent of a URI authority component.
7059
#[deriving(Clone, Eq)]
7160
pub struct UserInfo {
@@ -99,19 +88,6 @@ impl Url {
9988
}
10089
}
10190

102-
impl Path {
103-
pub fn new(path: ~str,
104-
query: Query,
105-
fragment: Option<~str>)
106-
-> Path {
107-
Path {
108-
path: path,
109-
query: query,
110-
fragment: fragment,
111-
}
112-
}
113-
}
114-
11591
impl UserInfo {
11692
#[inline]
11793
pub fn new(user: ~str, pass: Option<~str>) -> UserInfo {
@@ -751,21 +727,6 @@ pub fn from_str(rawurl: &str) -> Result<Url, ~str> {
751727
Ok(Url::new(scheme, userinfo, host, port, path, query, fragment))
752728
}
753729

754-
pub fn path_from_str(rawpath: &str) -> Result<Path, ~str> {
755-
let (path, rest) = match get_path(rawpath, false) {
756-
Ok(val) => val,
757-
Err(e) => return Err(e)
758-
};
759-
760-
// query and fragment
761-
let (query, fragment) = match get_query_fragment(rest) {
762-
Ok(val) => val,
763-
Err(e) => return Err(e),
764-
};
765-
766-
Ok(Path{ path: path, query: query, fragment: fragment })
767-
}
768-
769730
impl FromStr for Url {
770731
fn from_str(s: &str) -> Option<Url> {
771732
match from_str(s) {
@@ -775,15 +736,6 @@ impl FromStr for Url {
775736
}
776737
}
777738

778-
impl FromStr for Path {
779-
fn from_str(s: &str) -> Option<Path> {
780-
match path_from_str(s) {
781-
Ok(path) => Some(path),
782-
Err(_) => None
783-
}
784-
}
785-
}
786-
787739
/**
788740
* Converts a URL from `Url` to string representation.
789741
*
@@ -828,45 +780,18 @@ pub fn to_str(url: &Url) -> ~str {
828780
format!("{}:{}{}{}{}", url.scheme, authority, url.path, query, fragment)
829781
}
830782

831-
pub fn path_to_str(path: &Path) -> ~str {
832-
let query = if path.query.is_empty() {
833-
~""
834-
} else {
835-
format!("?{}", query_to_str(&path.query))
836-
};
837-
838-
let fragment = match path.fragment {
839-
Some(ref fragment) => format!("\\#{}", encode_component(*fragment)),
840-
None => ~"",
841-
};
842-
843-
format!("{}{}{}", path.path, query, fragment)
844-
}
845-
846783
impl ToStr for Url {
847784
fn to_str(&self) -> ~str {
848785
to_str(self)
849786
}
850787
}
851788

852-
impl ToStr for Path {
853-
fn to_str(&self) -> ~str {
854-
path_to_str(self)
855-
}
856-
}
857-
858789
impl IterBytes for Url {
859790
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
860791
self.to_str().iter_bytes(lsb0, f)
861792
}
862793
}
863794

864-
impl IterBytes for Path {
865-
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
866-
self.to_str().iter_bytes(lsb0, f)
867-
}
868-
}
869-
870795
// Put a few tests outside of the 'test' module so they can test the internal
871796
// functions and those functions don't need 'pub'
872797

@@ -974,17 +899,6 @@ mod tests {
974899
assert_eq!(&u.fragment, &Some(~"something"));
975900
}
976901
977-
#[test]
978-
fn test_path_parse() {
979-
let path = ~"/doc/~u?s=v#something";
980-
981-
let up = path_from_str(path);
982-
let u = up.unwrap();
983-
assert_eq!(&u.path, &~"/doc/~u");
984-
assert_eq!(&u.query, &~[(~"s", ~"v")]);
985-
assert_eq!(&u.fragment, &Some(~"something"));
986-
}
987-
988902
#[test]
989903
fn test_url_parse_host_slash() {
990904
let urlstr = ~"http://0.42.42.42/";
@@ -993,13 +907,6 @@ mod tests {
993907
assert!(url.path == ~"/");
994908
}
995909
996-
#[test]
997-
fn test_path_parse_host_slash() {
998-
let pathstr = ~"/";
999-
let path = path_from_str(pathstr).unwrap();
1000-
assert!(path.path == ~"/");
1001-
}
1002-
1003910
#[test]
1004911
fn test_url_host_with_port() {
1005912
let urlstr = ~"scheme://host:1234";
@@ -1023,27 +930,13 @@ mod tests {
1023930
assert!(url.path == ~"/file_name.html");
1024931
}
1025932
1026-
#[test]
1027-
fn test_path_with_underscores() {
1028-
let pathstr = ~"/file_name.html";
1029-
let path = path_from_str(pathstr).unwrap();
1030-
assert!(path.path == ~"/file_name.html");
1031-
}
1032-
1033933
#[test]
1034934
fn test_url_with_dashes() {
1035935
let urlstr = ~"http://dotcom.com/file-name.html";
1036936
let url = from_str(urlstr).unwrap();
1037937
assert!(url.path == ~"/file-name.html");
1038938
}
1039939
1040-
#[test]
1041-
fn test_path_with_dashes() {
1042-
let pathstr = ~"/file-name.html";
1043-
let path = path_from_str(pathstr).unwrap();
1044-
assert!(path.path == ~"/file-name.html");
1045-
}
1046-
1047940
#[test]
1048941
fn test_no_scheme() {
1049942
assert!(get_scheme("noschemehere.html").is_err());
@@ -1124,14 +1017,6 @@ mod tests {
11241017
assert!(u.query == ~[(~"ba%d ", ~"#&+")]);
11251018
}
11261019
1127-
#[test]
1128-
fn test_path_component_encoding() {
1129-
let path = ~"/doc%20uments?ba%25d%20=%23%26%2B";
1130-
let p = path_from_str(path).unwrap();
1131-
assert!(p.path == ~"/doc uments");
1132-
assert!(p.query == ~[(~"ba%d ", ~"#&+")]);
1133-
}
1134-
11351020
#[test]
11361021
fn test_url_without_authority() {
11371022
let url = ~"mailto:test@email.com";

branches/try2/src/librustc/back/archive.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ impl Archive {
173173
if_ok!(fs::rename(file, &new_filename));
174174
inputs.push(new_filename);
175175
}
176-
if inputs.len() == 0 { return Ok(()) }
177176

178177
// Finally, add all the renamed files to this archive
179178
let mut args = ~[&self.dst];

branches/try2/src/librustc/driver/driver.rs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ use middle;
2727
use util::common::time;
2828
use util::ppaux;
2929

30-
use extra::json;
31-
use serialize::Encodable;
32-
3330
use std::cell::{Cell, RefCell};
3431
use std::hashmap::{HashMap,HashSet};
3532
use std::io;
@@ -157,7 +154,7 @@ pub enum Input {
157154

158155
pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
159156
-> ast::Crate {
160-
let krate = time(sess.time_passes(), "parsing", (), |_| {
157+
time(sess.time_passes(), "parsing", (), |_| {
161158
match *input {
162159
FileInput(ref file) => {
163160
parse::parse_crate_from_file(&(*file), cfg.clone(), sess.parse_sess)
@@ -169,15 +166,7 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
169166
sess.parse_sess)
170167
}
171168
}
172-
});
173-
174-
if sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0 {
175-
let mut stdout = io::stdout();
176-
let mut json = json::PrettyEncoder::new(&mut stdout);
177-
krate.encode(&mut json);
178-
}
179-
180-
krate
169+
})
181170
}
182171

183172
// For continuing compilation after a parsed crate has been
@@ -231,16 +220,8 @@ pub fn phase_2_configure_and_expand(sess: Session,
231220
krate = time(time_passes, "prelude injection", krate, |krate|
232221
front::std_inject::maybe_inject_prelude(sess, krate));
233222

234-
let (krate, map) = time(time_passes, "assinging node ids and indexing ast", krate, |krate|
235-
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate));
236-
237-
if sess.opts.debugging_opts & session::AST_JSON != 0 {
238-
let mut stdout = io::stdout();
239-
let mut json = json::PrettyEncoder::new(&mut stdout);
240-
krate.encode(&mut json);
241-
}
242-
243-
(krate, map)
223+
time(time_passes, "assinging node ids and indexing ast", krate, |krate|
224+
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate))
244225
}
245226

246227
pub struct CrateAnalysis {
@@ -447,15 +428,15 @@ pub fn stop_after_phase_1(sess: Session) -> bool {
447428
debug!("invoked with --parse-only, returning early from compile_input");
448429
return true;
449430
}
450-
return sess.opts.debugging_opts & session::AST_JSON_NOEXPAND != 0;
431+
return false;
451432
}
452433

453434
pub fn stop_after_phase_2(sess: Session) -> bool {
454435
if sess.opts.no_analysis {
455436
debug!("invoked with --no-analysis, returning early from compile_input");
456437
return true;
457438
}
458-
return sess.opts.debugging_opts & session::AST_JSON != 0;
439+
return false;
459440
}
460441

461442
pub fn stop_after_phase_5(sess: Session) -> bool {

branches/try2/src/librustc/driver/session.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ debugging_opts!(
6565
GC,
6666
PRINT_LINK_ARGS,
6767
PRINT_LLVM_PASSES,
68-
LTO,
69-
AST_JSON,
70-
AST_JSON_NOEXPAND
68+
LTO
7169
]
7270
0
7371
)
@@ -99,8 +97,6 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, u64)] {
9997
"Prints the llvm optimization passes being run",
10098
PRINT_LLVM_PASSES),
10199
("lto", "Perform LLVM link-time optimizations", LTO),
102-
("ast-json", "Print the AST as JSON and halt", AST_JSON),
103-
("ast-json-noexpand", "Print the pre-expansion AST as JSON and halt", AST_JSON_NOEXPAND),
104100
]
105101
}
106102

0 commit comments

Comments
 (0)