Skip to content

Commit aaefb29

Browse files
committed
---
yaml --- r: 149378 b: refs/heads/try2 c: ea00582 h: refs/heads/master v: v3
1 parent 34feeac commit aaefb29

File tree

38 files changed

+708
-145
lines changed

38 files changed

+708
-145
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: e6740bb983a0657456d8cc9e848883dcc8fff0b4
8+
refs/heads/try2: ea0058281cfea06a61e5eb23b31c15e9d1dcfda3
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/Makefile.in

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@
1919
#
2020
# First, start with one of these build targets:
2121
#
22-
# * all - The default. Builds a complete, bootstrapped compiler.
22+
# * all - The default. Build a complete, bootstrapped compiler.
2323
# `rustc` will be in `${target-triple}/stage2/bin/`. Run it
2424
# directly from the build directory if you like. This also
2525
# comes with docs in `doc/`.
2626
#
2727
# * check - Run the complete test suite
2828
#
29+
# * clean - Clean the build repertory. It is advised to run this
30+
# command if you want to build Rust again, after an update
31+
# of the git repository.
32+
#
2933
# * install - Install Rust. Note that installation is not necessary
3034
# to use the compiler.
3135
#
@@ -103,7 +107,7 @@
103107
#
104108
# </tips>
105109
#
106-
# <nittygritty>
110+
# <nitty-gritty>
107111
#
108112
# # The Rust Build System
109113
#
@@ -152,12 +156,12 @@
152156
# libraries are managed and versioned without polluting the common
153157
# areas of the filesystem.
154158
#
155-
# General rust binaries may stil live in the host bin directory; they
159+
# General rust binaries may still live in the host bin directory; they
156160
# will just link against the libraries in the target lib directory.
157161
#
158162
# Admittedly this is a little convoluted.
159163
#
160-
# </nittygritty>
164+
# </nitty-gritty>
161165
#
162166

163167
######################################################################

branches/try2/mk/main.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,13 @@ all: $(ALL_TARGET_RULES) $(GENERATED) docs
446446
# $(1) is the name of the doc <section> in Makefile.in
447447
# pick everything between tags | remove first line | remove last line
448448
# | remove extra (?) line | strip leading `#` from lines
449-
SHOW_DOCS = $(Q)awk '/$(1)/,/<\/$(1)>/' $(S)/Makefile.in | sed '1d' | sed '$$d' | sed 's/^\# \?//'
449+
SHOW_DOCS = $(Q)awk '/<$(1)>/,/<\/$(1)>/' $(S)/Makefile.in | sed '1d' | sed '$$d' | sed 's/^\# \?//'
450450

451451
help:
452452
$(call SHOW_DOCS,help)
453453

454-
hot-tips:
455-
$(call SHOW_DOCS,hottips)
454+
tips:
455+
$(call SHOW_DOCS,tips)
456456

457457
nitty-gritty:
458-
$(call SHOW_DOCS,nittygritty)
458+
$(call SHOW_DOCS,nitty-gritty)

branches/try2/src/doc/tutorial.md

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,24 @@ 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+
17531771
## Closure compatibility
17541772
17551773
Rust closures have a convenient subtyping property: you can pass any kind of
@@ -1771,45 +1789,6 @@ call_twice(function);
17711789
> in small ways. At the moment they can be unsound in some
17721790
> scenarios, particularly with non-copyable types.
17731791
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-
18131792
# Methods
18141793
18151794
Methods are like functions except that they always begin with a special argument,

branches/try2/src/libextra/url.rs

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ 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+
5869
/// An optional subcomponent of a URI authority component.
5970
#[deriving(Clone, Eq)]
6071
pub struct UserInfo {
@@ -88,6 +99,19 @@ impl Url {
8899
}
89100
}
90101

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+
91115
impl UserInfo {
92116
#[inline]
93117
pub fn new(user: ~str, pass: Option<~str>) -> UserInfo {
@@ -727,6 +751,21 @@ pub fn from_str(rawurl: &str) -> Result<Url, ~str> {
727751
Ok(Url::new(scheme, userinfo, host, port, path, query, fragment))
728752
}
729753

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+
730769
impl FromStr for Url {
731770
fn from_str(s: &str) -> Option<Url> {
732771
match from_str(s) {
@@ -736,6 +775,15 @@ impl FromStr for Url {
736775
}
737776
}
738777

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+
739787
/**
740788
* Converts a URL from `Url` to string representation.
741789
*
@@ -780,18 +828,45 @@ pub fn to_str(url: &Url) -> ~str {
780828
format!("{}:{}{}{}{}", url.scheme, authority, url.path, query, fragment)
781829
}
782830

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+
783846
impl ToStr for Url {
784847
fn to_str(&self) -> ~str {
785848
to_str(self)
786849
}
787850
}
788851

852+
impl ToStr for Path {
853+
fn to_str(&self) -> ~str {
854+
path_to_str(self)
855+
}
856+
}
857+
789858
impl IterBytes for Url {
790859
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
791860
self.to_str().iter_bytes(lsb0, f)
792861
}
793862
}
794863

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+
795870
// Put a few tests outside of the 'test' module so they can test the internal
796871
// functions and those functions don't need 'pub'
797872

@@ -899,6 +974,17 @@ mod tests {
899974
assert_eq!(&u.fragment, &Some(~"something"));
900975
}
901976
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+
902988
#[test]
903989
fn test_url_parse_host_slash() {
904990
let urlstr = ~"http://0.42.42.42/";
@@ -907,6 +993,13 @@ mod tests {
907993
assert!(url.path == ~"/");
908994
}
909995
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+
9101003
#[test]
9111004
fn test_url_host_with_port() {
9121005
let urlstr = ~"scheme://host:1234";
@@ -930,13 +1023,27 @@ mod tests {
9301023
assert!(url.path == ~"/file_name.html");
9311024
}
9321025
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+
9331033
#[test]
9341034
fn test_url_with_dashes() {
9351035
let urlstr = ~"http://dotcom.com/file-name.html";
9361036
let url = from_str(urlstr).unwrap();
9371037
assert!(url.path == ~"/file-name.html");
9381038
}
9391039
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+
9401047
#[test]
9411048
fn test_no_scheme() {
9421049
assert!(get_scheme("noschemehere.html").is_err());
@@ -1017,6 +1124,14 @@ mod tests {
10171124
assert!(u.query == ~[(~"ba%d ", ~"#&+")]);
10181125
}
10191126
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+
10201135
#[test]
10211136
fn test_url_without_authority() {
10221137
let url = ~"mailto:test@email.com";

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

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4142,7 +4142,7 @@ pub fn enum_variants(cx: ctxt, id: ast::DefId) -> @~[@VariantInfo] {
41424142
.span_err(e.span,
41434143
format!("expected \
41444144
constant: {}",
4145-
(*err)));
4145+
*err));
41464146
}
41474147
},
41484148
None => {}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,15 +1303,15 @@ impl<'a> LookupContext<'a> {
13031303
self.tcx().sess.span_note(
13041304
span,
13051305
format!("candidate \\#{} is `{}`",
1306-
(idx+1u),
1306+
idx+1u,
13071307
ty::item_path_str(self.tcx(), did)));
13081308
}
13091309

13101310
fn report_param_candidate(&self, idx: uint, did: DefId) {
13111311
self.tcx().sess.span_note(
13121312
self.expr.span,
13131313
format!("candidate \\#{} derives from the bound `{}`",
1314-
(idx+1u),
1314+
idx+1u,
13151315
ty::item_path_str(self.tcx(), did)));
13161316
}
13171317

@@ -1320,7 +1320,7 @@ impl<'a> LookupContext<'a> {
13201320
self.expr.span,
13211321
format!("candidate \\#{} derives from the type of the receiver, \
13221322
which is the trait `{}`",
1323-
(idx+1u),
1323+
idx+1u,
13241324
ty::item_path_str(self.tcx(), did)));
13251325
}
13261326

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3551,7 +3551,7 @@ pub fn check_enum_variants(ccx: @CrateCtxt,
35513551
ccx.tcx.sess.span_err(e.span, "expected signed integer constant");
35523552
}
35533553
Err(ref err) => {
3554-
ccx.tcx.sess.span_err(e.span, format!("expected constant: {}", (*err)));
3554+
ccx.tcx.sess.span_err(e.span, format!("expected constant: {}", *err));
35553555
}
35563556
}
35573557
},

0 commit comments

Comments
 (0)