auto merge of #18017 : alexcrichton/rust/rollup, r=alexcrichton
This commit is contained in:
commit
a1e2eb0395
64 changed files with 481 additions and 346 deletions
31
mk/tests.mk
31
mk/tests.mk
|
@ -199,14 +199,29 @@ check-docs: cleantestlibs cleantmptestlogs check-stage2-docs
|
||||||
|
|
||||||
# Some less critical tests that are not prone to breakage.
|
# Some less critical tests that are not prone to breakage.
|
||||||
# Not run as part of the normal test suite, but tested by bors on checkin.
|
# Not run as part of the normal test suite, but tested by bors on checkin.
|
||||||
check-secondary: check-lexer check-pretty
|
check-secondary: check-build-compiletest check-lexer check-pretty
|
||||||
|
|
||||||
# check + check-secondary.
|
# check + check-secondary.
|
||||||
check-all: check check-secondary
|
#
|
||||||
|
# Issue #17883: build check-secondary first so hidden dependencies in
|
||||||
|
# e.g. building compiletest are exercised (resolve those by adding
|
||||||
|
# deps to rules that need them; not by putting `check` first here).
|
||||||
|
check-all: check-secondary check
|
||||||
|
|
||||||
# Pretty-printing tests.
|
# Pretty-printing tests.
|
||||||
check-pretty: check-stage2-T-$(CFG_BUILD)-H-$(CFG_BUILD)-pretty-exec
|
check-pretty: check-stage2-T-$(CFG_BUILD)-H-$(CFG_BUILD)-pretty-exec
|
||||||
|
|
||||||
|
define DEF_CHECK_BUILD_COMPILETEST_FOR_STAGE
|
||||||
|
check-stage$(1)-build-compiletest: $$(HBIN$(1)_H_$(CFG_BUILD))/compiletest$$(X_$(CFG_BUILD))
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach stage,$(STAGES), \
|
||||||
|
$(eval $(call DEF_CHECK_BUILD_COMPILETEST_FOR_STAGE,$(stage))))
|
||||||
|
|
||||||
|
check-build-compiletest: \
|
||||||
|
check-stage1-build-compiletest \
|
||||||
|
check-stage2-build-compiletest
|
||||||
|
|
||||||
.PHONY: cleantmptestlogs cleantestlibs
|
.PHONY: cleantmptestlogs cleantestlibs
|
||||||
|
|
||||||
cleantmptestlogs:
|
cleantmptestlogs:
|
||||||
|
@ -284,7 +299,7 @@ tidy:
|
||||||
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
|
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
|
||||||
$(Q)echo $(ALL_HS) \
|
$(Q)echo $(ALL_HS) \
|
||||||
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
|
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
|
||||||
$(Q)find $(S)src -type f -perm a+x \
|
$(Q)find $(S)src -type f -perm +a+x \
|
||||||
-not -name '*.rs' -and -not -name '*.py' \
|
-not -name '*.rs' -and -not -name '*.py' \
|
||||||
-and -not -name '*.sh' \
|
-and -not -name '*.sh' \
|
||||||
| grep '^$(S)src/jemalloc' -v \
|
| grep '^$(S)src/jemalloc' -v \
|
||||||
|
@ -720,6 +735,13 @@ PRETTY_DEPS_pretty-rpass-full = $(RPASS_FULL_TESTS)
|
||||||
PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
|
PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS)
|
||||||
PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
|
PRETTY_DEPS_pretty-bench = $(BENCH_TESTS)
|
||||||
PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
|
PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS)
|
||||||
|
# The stage- and host-specific dependencies are for e.g. macro_crate_test which pulls in
|
||||||
|
# external crates.
|
||||||
|
PRETTY_DEPS$(1)_H_$(3)_pretty-rpass =
|
||||||
|
PRETTY_DEPS$(1)_H_$(3)_pretty-rpass-full = $$(HLIB$(1)_H_$(3))/stamp.syntax $$(HLIB$(1)_H_$(3))/stamp.rustc
|
||||||
|
PRETTY_DEPS$(1)_H_$(3)_pretty-rfail =
|
||||||
|
PRETTY_DEPS$(1)_H_$(3)_pretty-bench =
|
||||||
|
PRETTY_DEPS$(1)_H_$(3)_pretty-pretty =
|
||||||
PRETTY_DIRNAME_pretty-rpass = run-pass
|
PRETTY_DIRNAME_pretty-rpass = run-pass
|
||||||
PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps
|
PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps
|
||||||
PRETTY_DIRNAME_pretty-rfail = run-fail
|
PRETTY_DIRNAME_pretty-rfail = run-fail
|
||||||
|
@ -738,7 +760,8 @@ check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4
|
||||||
|
|
||||||
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
|
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
|
||||||
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
|
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
|
||||||
$$(PRETTY_DEPS_$(4))
|
$$(PRETTY_DEPS_$(4)) \
|
||||||
|
$$(PRETTY_DEPS$(1)_H_$(3)_$(4))
|
||||||
@$$(call E, run pretty-rpass [$(2)]: $$<)
|
@$$(call E, run pretty-rpass [$(2)]: $$<)
|
||||||
$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
|
$$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3)) \
|
||||||
$$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
|
$$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4)) \
|
||||||
|
|
|
@ -947,15 +947,12 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||||
String::from_chars(c.as_slice())
|
String::from_chars(c.as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(windows)]
|
||||||
fn prefix_matches( line : &str, prefix : &str ) -> bool {
|
fn prefix_matches( line : &str, prefix : &str ) -> bool {
|
||||||
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
|
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux",
|
#[cfg(unix)]
|
||||||
target_os = "macos",
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "dragonfly"))]
|
|
||||||
fn prefix_matches( line : &str, prefix : &str ) -> bool {
|
fn prefix_matches( line : &str, prefix : &str ) -> bool {
|
||||||
line.starts_with( prefix )
|
line.starts_with( prefix )
|
||||||
}
|
}
|
||||||
|
@ -1356,24 +1353,21 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
|
||||||
}
|
}
|
||||||
|
|
||||||
// Linux and mac don't require adjusting the library search path
|
// Linux and mac don't require adjusting the library search path
|
||||||
#[cfg(any(target_os = "linux",
|
#[cfg(unix)]
|
||||||
target_os = "macos",
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "dragonfly"))]
|
|
||||||
fn make_cmdline(_libpath: &str, prog: &str, args: &[String]) -> String {
|
fn make_cmdline(_libpath: &str, prog: &str, args: &[String]) -> String {
|
||||||
format!("{} {}", prog, args.connect(" "))
|
format!("{} {}", prog, args.connect(" "))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(windows)]
|
||||||
fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String {
|
fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String {
|
||||||
format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.connect(" "))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
|
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
|
||||||
// for diagnostic purposes
|
// for diagnostic purposes
|
||||||
#[cfg(target_os = "windows")]
|
fn lib_path_cmd_prefix(path: &str) -> String {
|
||||||
fn lib_path_cmd_prefix(path: &str) -> String {
|
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
|
||||||
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
|
}
|
||||||
|
|
||||||
|
format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.connect(" "))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dump_output(config: &Config, testfile: &Path, out: &str, err: &str) {
|
fn dump_output(config: &Config, testfile: &Path, out: &str, err: &str) {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
# Dependencies
|
# Rust documentations
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
[Pandoc](http://johnmacfarlane.net/pandoc/installing.html), a universal
|
[Pandoc](http://johnmacfarlane.net/pandoc/installing.html), a universal
|
||||||
document converter, is required to generate docs as HTML from Rust's
|
document converter, is required to generate docs as HTML from Rust's
|
||||||
|
@ -10,7 +12,7 @@ docs from the master (English) docs.
|
||||||
[GNU gettext](http://www.gnu.org/software/gettext/) is required for managing
|
[GNU gettext](http://www.gnu.org/software/gettext/) is required for managing
|
||||||
the translation data.
|
the translation data.
|
||||||
|
|
||||||
# Building
|
## Building
|
||||||
|
|
||||||
To generate all the docs, just run `make docs` from the root of the repository.
|
To generate all the docs, just run `make docs` from the root of the repository.
|
||||||
This will convert the distributed Markdown docs to HTML and generate HTML doc
|
This will convert the distributed Markdown docs to HTML and generate HTML doc
|
||||||
|
@ -24,7 +26,7 @@ rustdoc --output html-doc/ --output-format html ../src/libstd/path.rs
|
||||||
|
|
||||||
(This, of course, requires a working build of the `rustdoc` tool.)
|
(This, of course, requires a working build of the `rustdoc` tool.)
|
||||||
|
|
||||||
# Additional notes
|
## Additional notes
|
||||||
|
|
||||||
To generate an HTML version of a doc from Markdown manually, you can do
|
To generate an HTML version of a doc from Markdown manually, you can do
|
||||||
something like:
|
something like:
|
||||||
|
@ -33,37 +35,39 @@ something like:
|
||||||
pandoc --from=markdown --to=html5 --number-sections -o reference.html reference.md
|
pandoc --from=markdown --to=html5 --number-sections -o reference.html reference.md
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
(reference.md being the Rust Reference Manual.)
|
(`reference.md` being the Rust Reference Manual.)
|
||||||
|
|
||||||
The syntax for pandoc flavored markdown can be found at:
|
The syntax for pandoc flavored markdown can be found at:
|
||||||
http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown
|
|
||||||
|
- http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown
|
||||||
|
|
||||||
A nice quick reference (for non-pandoc markdown) is at:
|
A nice quick reference (for non-pandoc markdown) is at:
|
||||||
http://kramdown.rubyforge.org/quickref.html
|
|
||||||
|
|
||||||
# Notes for translators
|
- http://kramdown.gettalong.org/quickref.html
|
||||||
|
|
||||||
|
## Notes for translators
|
||||||
|
|
||||||
Notice: The procedure described below is a work in progress. We are working on
|
Notice: The procedure described below is a work in progress. We are working on
|
||||||
translation system but the procedure contains some manual operations for now.
|
translation system but the procedure contains some manual operations for now.
|
||||||
|
|
||||||
To start the translation for a new language, see po4a.conf at first.
|
To start the translation for a new language, see `po4a.conf` at first.
|
||||||
|
|
||||||
To generate .pot and .po files, do something like:
|
To generate `.pot` and `.po` files, do something like:
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
po4a --copyright-holder="The Rust Project Developers" \
|
po4a --copyright-holder="The Rust Project Developers" \
|
||||||
--package-name="Rust" \
|
--package-name="Rust" \
|
||||||
--package-version="0.11.0" \
|
--package-version="0.13.0" \
|
||||||
-M UTF-8 -L UTF-8 \
|
-M UTF-8 -L UTF-8 \
|
||||||
src/doc/po4a.conf
|
src/doc/po4a.conf
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
(the version number must be changed if it is not 0.11.0 now.)
|
(the version number must be changed if it is not `0.13.0` now.)
|
||||||
|
|
||||||
Now you can translate documents with .po files, commonly used with gettext. If
|
Now you can translate documents with `.po` files, commonly used with gettext. If
|
||||||
you are not familiar with gettext-based translation, please read the online
|
you are not familiar with gettext-based translation, please read the online
|
||||||
manual linked from http://www.gnu.org/software/gettext/ . We use UTF-8 as the
|
manual linked from http://www.gnu.org/software/gettext/ . We use UTF-8 as the
|
||||||
file encoding of .po files.
|
file encoding of `.po` files.
|
||||||
|
|
||||||
When you want to make a commit, do the command below before staging your
|
When you want to make a commit, do the command below before staging your
|
||||||
change:
|
change:
|
||||||
|
@ -79,4 +83,4 @@ for f in src/doc/po/**/*.po; do
|
||||||
done
|
done
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
This removes untranslated entries from .po files to save disk space.
|
This removes untranslated entries from `.po` files to save disk space.
|
||||||
|
|
|
@ -298,7 +298,7 @@ fn main() {
|
||||||
C code:
|
C code:
|
||||||
|
|
||||||
~~~~c
|
~~~~c
|
||||||
typedef void (*rust_callback)(int32_t);
|
typedef void (*rust_callback)(void*, int32_t);
|
||||||
void* cb_target;
|
void* cb_target;
|
||||||
rust_callback cb;
|
rust_callback cb;
|
||||||
|
|
||||||
|
|
|
@ -206,5 +206,5 @@ Many more bytes than graphemes!
|
||||||
|
|
||||||
# Other Documentation
|
# Other Documentation
|
||||||
|
|
||||||
* [the `&str` API documentation](/std/str/index.html)
|
* [the `&str` API documentation](std/str/index.html)
|
||||||
* [the `String` API documentation](std/string/index.html)
|
* [the `String` API documentation](std/string/index.html)
|
||||||
|
|
|
@ -1746,8 +1746,7 @@ For our first project, we'll implement a classic beginner programming problem:
|
||||||
the guessing game. Here's how it works: Our program will generate a random
|
the guessing game. Here's how it works: Our program will generate a random
|
||||||
integer between one and a hundred. It will then prompt us to enter a guess.
|
integer between one and a hundred. It will then prompt us to enter a guess.
|
||||||
Upon entering our guess, it will tell us if we're too low or too high. Once we
|
Upon entering our guess, it will tell us if we're too low or too high. Once we
|
||||||
guess correctly, it will congratulate us, and print the number of guesses we've
|
guess correctly, it will congratulate us. Sound good?
|
||||||
taken to the screen. Sound good?
|
|
||||||
|
|
||||||
## Set up
|
## Set up
|
||||||
|
|
||||||
|
@ -3538,9 +3537,8 @@ restriction:
|
||||||
|
|
||||||
1. If the borrow is immutable, you may read the data the pointer points to.
|
1. If the borrow is immutable, you may read the data the pointer points to.
|
||||||
2. If the borrow is mutable, you may read and write the data the pointer points to.
|
2. If the borrow is mutable, you may read and write the data the pointer points to.
|
||||||
3. You may lend the pointer to someone else in an immutable fashion, **BUT**
|
3. You may lend the pointer to someone else, **BUT**
|
||||||
4. When you do so, they must return it to you before you must give your own
|
4. When you do so, they must return it before you can give your own borrow back.
|
||||||
borrow back.
|
|
||||||
|
|
||||||
This last requirement can seem odd, but it also makes sense. If you have to
|
This last requirement can seem odd, but it also makes sense. If you have to
|
||||||
return something, and you've lent it to someone, they need to give it back to
|
return something, and you've lent it to someone, they need to give it back to
|
||||||
|
@ -5062,8 +5060,8 @@ println!("The value of x[0] is: {}", x[0]); // error: use of moved value: `x`
|
||||||
```
|
```
|
||||||
|
|
||||||
`x` is now owned by the proc, and so we can't use it anymore. Many other
|
`x` is now owned by the proc, and so we can't use it anymore. Many other
|
||||||
languages would let us do this, but it's not safe to do so. Rust's type system
|
languages would let us do this, but it's not safe to do so. Rust's borrow
|
||||||
catches the error.
|
checker catches the error.
|
||||||
|
|
||||||
If tasks were only able to capture these values, they wouldn't be very useful.
|
If tasks were only able to capture these values, they wouldn't be very useful.
|
||||||
Luckily, tasks can communicate with each other through **channel**s. Channels
|
Luckily, tasks can communicate with each other through **channel**s. Channels
|
||||||
|
|
|
@ -185,40 +185,24 @@ grammar as double-quoted strings. Other tokens have exact rules given.
|
||||||
|
|
||||||
### Keywords
|
### Keywords
|
||||||
|
|
||||||
The keywords are the following strings, organized by first letter:
|
<p id="keyword-table-marker">The keywords are the following strings, organized by first letter:</p>
|
||||||
|
|
||||||
<div id="keywords">
|
|
||||||
| | | | |
|
| | | | |
|
||||||
|----------|--------|--------|-------|
|
|----------|--------|--------|-------|
|
||||||
| as | | | |
|
| as | | | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| box | break | | |
|
| box | break | | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| continue | crate | | |
|
| continue | crate | | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| else | enum | extern | |
|
| else | enum | extern | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| false | fn | for | |
|
| false | fn | for | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| if | impl | in | |
|
| if | impl | in | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| let | loop | | |
|
| let | loop | | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| match | mod | mut | |
|
| match | mod | mut | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| priv | proc | pub | |
|
| priv | proc | pub | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| ref | return | | |
|
| ref | return | | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| self | static | struct | super |
|
| self | static | struct | super |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| trait | true | type | |
|
| trait | true | type | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| unsafe | use | | |
|
| unsafe | use | | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
| while | | | |
|
| while | | | |
|
||||||
|----------|--------|--------|-------|
|
|
||||||
</div>
|
|
||||||
|
|
||||||
Each of these keywords has special meaning in its grammar, and all of them are
|
Each of these keywords has special meaning in its grammar, and all of them are
|
||||||
excluded from the `ident` rule.
|
excluded from the `ident` rule.
|
||||||
|
|
|
@ -393,4 +393,9 @@ pre.rust { position: relative; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#keywords table td { border: none; }
|
#keyword-table-marker + table thead { display: none; }
|
||||||
|
#keyword-table-marker + table td { border: none; }
|
||||||
|
#keyword-table-marker + table {
|
||||||
|
margin-left: 2em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
|
@ -604,6 +604,15 @@ if __name__ == "__main__":
|
||||||
rf.write(preamble)
|
rf.write(preamble)
|
||||||
|
|
||||||
# download and parse all the data
|
# download and parse all the data
|
||||||
|
fetch("ReadMe.txt")
|
||||||
|
with open("ReadMe.txt") as readme:
|
||||||
|
pattern = "for Version (\d+)\.(\d+)\.(\d+) of the Unicode"
|
||||||
|
unicode_version = re.search(pattern, readme.read()).groups()
|
||||||
|
rf.write("""
|
||||||
|
/// The version of [Unicode](http://www.unicode.org/)
|
||||||
|
/// that the `UnicodeChar` and `UnicodeStrSlice` traits are based on.
|
||||||
|
pub const UNICODE_VERSION: (uint, uint, uint) = (%s, %s, %s);
|
||||||
|
""" % unicode_version)
|
||||||
(canon_decomp, compat_decomp, gencats, combines,
|
(canon_decomp, compat_decomp, gencats, combines,
|
||||||
lowerupper, upperlower) = load_unicode_data("UnicodeData.txt")
|
lowerupper, upperlower) = load_unicode_data("UnicodeData.txt")
|
||||||
want_derived = ["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"]
|
want_derived = ["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"]
|
||||||
|
|
|
@ -276,7 +276,6 @@ impl<T: Sync + Send> Drop for Weak<T> {
|
||||||
#[allow(experimental)]
|
#[allow(experimental)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::clone::Clone;
|
use std::clone::Clone;
|
||||||
use std::collections::MutableSeq;
|
|
||||||
use std::comm::channel;
|
use std::comm::channel;
|
||||||
use std::mem::drop;
|
use std::mem::drop;
|
||||||
use std::ops::Drop;
|
use std::ops::Drop;
|
||||||
|
|
|
@ -2659,7 +2659,7 @@ mod tests {
|
||||||
let mut r = rng();
|
let mut r = rng();
|
||||||
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
|
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
for i in range(0u, 100) {
|
for _ in range(0u, 100) {
|
||||||
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
|
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
|
||||||
}
|
}
|
||||||
&bitv
|
&bitv
|
||||||
|
|
|
@ -890,13 +890,13 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
let v = vec![1i,2,3,4,5];
|
let v = vec![1i,2,3,4,5];
|
||||||
let u = vec![9i,8,1,2,3,4,5];
|
let mut u = vec![9i,8,1,2,3,4,5];
|
||||||
let mut m = list_from(v.as_slice());
|
let mut m = list_from(v.as_slice());
|
||||||
m.prepend(list_from(u.as_slice()));
|
m.prepend(list_from(u.as_slice()));
|
||||||
check_links(&m);
|
check_links(&m);
|
||||||
let sum = u.append(v.as_slice());
|
u.extend(v.as_slice().iter().map(|&b| b));
|
||||||
assert_eq!(sum.len(), m.len());
|
assert_eq!(u.len(), m.len());
|
||||||
for elt in sum.into_iter() {
|
for elt in u.into_iter() {
|
||||||
assert_eq!(m.pop_front(), Some(elt))
|
assert_eq!(m.pop_front(), Some(elt))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -611,10 +611,10 @@ mod tests {
|
||||||
assert_eq!(deq.len(), 3);
|
assert_eq!(deq.len(), 3);
|
||||||
deq.push_front(a.clone());
|
deq.push_front(a.clone());
|
||||||
assert_eq!(deq.len(), 4);
|
assert_eq!(deq.len(), 4);
|
||||||
assert_eq!((*deq.get(0)).clone(), a.clone());
|
assert_eq!(deq[0].clone(), a.clone());
|
||||||
assert_eq!((*deq.get(1)).clone(), b.clone());
|
assert_eq!(deq[1].clone(), b.clone());
|
||||||
assert_eq!((*deq.get(2)).clone(), c.clone());
|
assert_eq!(deq[2].clone(), c.clone());
|
||||||
assert_eq!((*deq.get(3)).clone(), d.clone());
|
assert_eq!(deq[3].clone(), d.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -626,7 +626,7 @@ mod tests {
|
||||||
assert_eq!(deq.len(), 66);
|
assert_eq!(deq.len(), 66);
|
||||||
|
|
||||||
for i in range(0u, 66) {
|
for i in range(0u, 66) {
|
||||||
assert_eq!(*deq.get(i), 65 - i);
|
assert_eq!(deq[i], 65 - i);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut deq = RingBuf::new();
|
let mut deq = RingBuf::new();
|
||||||
|
@ -635,7 +635,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in range(0u, 66) {
|
for i in range(0u, 66) {
|
||||||
assert_eq!(*deq.get(i), i);
|
assert_eq!(deq[i], i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -883,6 +883,7 @@ mod tests {
|
||||||
use std::slice::{AsSlice, ImmutableSlice};
|
use std::slice::{AsSlice, ImmutableSlice};
|
||||||
use string::String;
|
use string::String;
|
||||||
use vec::Vec;
|
use vec::Vec;
|
||||||
|
use slice::CloneableVector;
|
||||||
|
|
||||||
use unicode::char::UnicodeChar;
|
use unicode::char::UnicodeChar;
|
||||||
|
|
||||||
|
@ -1504,7 +1505,7 @@ mod tests {
|
||||||
fn vec_str_conversions() {
|
fn vec_str_conversions() {
|
||||||
let s1: String = String::from_str("All mimsy were the borogoves");
|
let s1: String = String::from_str("All mimsy were the borogoves");
|
||||||
|
|
||||||
let v: Vec<u8> = Vec::from_slice(s1.as_bytes());
|
let v: Vec<u8> = s1.as_bytes().to_vec();
|
||||||
let s2: String = String::from_str(from_utf8(v.as_slice()).unwrap());
|
let s2: String = String::from_str(from_utf8(v.as_slice()).unwrap());
|
||||||
let mut i: uint = 0u;
|
let mut i: uint = 0u;
|
||||||
let n1: uint = s1.len();
|
let n1: uint = s1.len();
|
||||||
|
|
|
@ -1036,6 +1036,7 @@ mod tests {
|
||||||
use str::{Str, StrSlice, Owned};
|
use str::{Str, StrSlice, Owned};
|
||||||
use super::{as_string, String};
|
use super::{as_string, String};
|
||||||
use vec::Vec;
|
use vec::Vec;
|
||||||
|
use slice::CloneableVector;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_as_string() {
|
fn test_as_string() {
|
||||||
|
@ -1051,15 +1052,15 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_utf8() {
|
fn test_from_utf8() {
|
||||||
let xs = Vec::from_slice(b"hello");
|
let xs = b"hello".to_vec();
|
||||||
assert_eq!(String::from_utf8(xs), Ok(String::from_str("hello")));
|
assert_eq!(String::from_utf8(xs), Ok(String::from_str("hello")));
|
||||||
|
|
||||||
let xs = Vec::from_slice("ศไทย中华Việt Nam".as_bytes());
|
let xs = "ศไทย中华Việt Nam".as_bytes().to_vec();
|
||||||
assert_eq!(String::from_utf8(xs), Ok(String::from_str("ศไทย中华Việt Nam")));
|
assert_eq!(String::from_utf8(xs), Ok(String::from_str("ศไทย中华Việt Nam")));
|
||||||
|
|
||||||
let xs = Vec::from_slice(b"hello\xFF");
|
let xs = b"hello\xFF".to_vec();
|
||||||
assert_eq!(String::from_utf8(xs),
|
assert_eq!(String::from_utf8(xs),
|
||||||
Err(Vec::from_slice(b"hello\xFF")));
|
Err(b"hello\xFF".to_vec()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1211,7 +1212,8 @@ mod tests {
|
||||||
fn test_push_bytes() {
|
fn test_push_bytes() {
|
||||||
let mut s = String::from_str("ABC");
|
let mut s = String::from_str("ABC");
|
||||||
unsafe {
|
unsafe {
|
||||||
s.push_bytes([b'D']);
|
let mv = s.as_mut_vec();
|
||||||
|
mv.push_all([b'D']);
|
||||||
}
|
}
|
||||||
assert_eq!(s.as_slice(), "ABCD");
|
assert_eq!(s.as_slice(), "ABCD");
|
||||||
}
|
}
|
||||||
|
@ -1239,17 +1241,18 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_pop_char() {
|
fn test_pop() {
|
||||||
let mut data = String::from_str("ประเทศไทย中华b¢€𤭢");
|
let mut data = String::from_str("ประเทศไทย中华b¢€𤭢");
|
||||||
assert_eq!(data.pop_char().unwrap(), '𤭢'); // 4 bytes
|
assert_eq!(data.pop().unwrap(), '𤭢'); // 4 bytes
|
||||||
assert_eq!(data.pop_char().unwrap(), '€'); // 3 bytes
|
assert_eq!(data.pop().unwrap(), '€'); // 3 bytes
|
||||||
assert_eq!(data.pop_char().unwrap(), '¢'); // 2 bytes
|
assert_eq!(data.pop().unwrap(), '¢'); // 2 bytes
|
||||||
assert_eq!(data.pop_char().unwrap(), 'b'); // 1 bytes
|
assert_eq!(data.pop().unwrap(), 'b'); // 1 bytes
|
||||||
assert_eq!(data.pop_char().unwrap(), '华');
|
assert_eq!(data.pop().unwrap(), '华');
|
||||||
assert_eq!(data.as_slice(), "ประเทศไทย中");
|
assert_eq!(data.as_slice(), "ประเทศไทย中");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(deprecated)] // use remove(0) instead
|
||||||
fn test_shift_char() {
|
fn test_shift_char() {
|
||||||
let mut data = String::from_str("𤭢€¢b华ประเทศไทย中");
|
let mut data = String::from_str("𤭢€¢b华ประเทศไทย中");
|
||||||
assert_eq!(data.shift_char().unwrap(), '𤭢'); // 4 bytes
|
assert_eq!(data.shift_char().unwrap(), '𤭢'); // 4 bytes
|
||||||
|
|
|
@ -2266,8 +2266,8 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mut_slice_from() {
|
fn test_slice_from_mut() {
|
||||||
let mut values = Vec::from_slice([1u8,2,3,4,5]);
|
let mut values = vec![1u8,2,3,4,5];
|
||||||
{
|
{
|
||||||
let slice = values.slice_from_mut(2);
|
let slice = values.slice_from_mut(2);
|
||||||
assert!(slice == [3, 4, 5]);
|
assert!(slice == [3, 4, 5]);
|
||||||
|
@ -2280,8 +2280,8 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mut_slice_to() {
|
fn test_slice_to_mut() {
|
||||||
let mut values = Vec::from_slice([1u8,2,3,4,5]);
|
let mut values = vec![1u8,2,3,4,5];
|
||||||
{
|
{
|
||||||
let slice = values.slice_to_mut(2);
|
let slice = values.slice_to_mut(2);
|
||||||
assert!(slice == [1, 2]);
|
assert!(slice == [1, 2]);
|
||||||
|
@ -2294,8 +2294,8 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mut_split_at() {
|
fn test_split_at_mut() {
|
||||||
let mut values = Vec::from_slice([1u8,2,3,4,5]);
|
let mut values = vec![1u8,2,3,4,5];
|
||||||
{
|
{
|
||||||
let (left, right) = values.split_at_mut(2);
|
let (left, right) = values.split_at_mut(2);
|
||||||
{
|
{
|
||||||
|
@ -2315,7 +2315,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(values == Vec::from_slice([2u8, 3, 5, 6, 7]));
|
assert!(values == vec![2u8, 3, 5, 6, 7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2355,16 +2355,16 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_grow_fn() {
|
fn test_grow_fn() {
|
||||||
let mut v = Vec::from_slice([0u, 1]);
|
let mut v = vec![0u, 1];
|
||||||
v.grow_fn(3, |i| i);
|
v.grow_fn(3, |i| i);
|
||||||
assert!(v == Vec::from_slice([0u, 1, 0, 1, 2]));
|
assert!(v == vec![0u, 1, 0, 1, 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_retain() {
|
fn test_retain() {
|
||||||
let mut vec = Vec::from_slice([1u, 2, 3, 4]);
|
let mut vec = vec![1u, 2, 3, 4];
|
||||||
vec.retain(|x| x%2 == 0);
|
vec.retain(|x| x%2 == 0);
|
||||||
assert!(vec == Vec::from_slice([2u, 4]));
|
assert!(vec == vec![2u, 4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2567,32 +2567,32 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_move_items() {
|
fn test_move_items() {
|
||||||
let mut vec = vec!(1i, 2, 3);
|
let vec = vec![1, 2, 3];
|
||||||
let mut vec2 : Vec<int> = vec!();
|
let mut vec2 : Vec<i32> = vec![];
|
||||||
for i in vec.into_iter() {
|
for i in vec.into_iter() {
|
||||||
vec2.push(i);
|
vec2.push(i);
|
||||||
}
|
}
|
||||||
assert!(vec2 == vec!(1i, 2, 3));
|
assert!(vec2 == vec![1, 2, 3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_move_items_reverse() {
|
fn test_move_items_reverse() {
|
||||||
let mut vec = vec!(1i, 2, 3);
|
let vec = vec![1, 2, 3];
|
||||||
let mut vec2 : Vec<int> = vec!();
|
let mut vec2 : Vec<i32> = vec![];
|
||||||
for i in vec.into_iter().rev() {
|
for i in vec.into_iter().rev() {
|
||||||
vec2.push(i);
|
vec2.push(i);
|
||||||
}
|
}
|
||||||
assert!(vec2 == vec!(3i, 2, 1));
|
assert!(vec2 == vec![3, 2, 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_move_items_zero_sized() {
|
fn test_move_items_zero_sized() {
|
||||||
let mut vec = vec!((), (), ());
|
let vec = vec![(), (), ()];
|
||||||
let mut vec2 : Vec<()> = vec!();
|
let mut vec2 : Vec<()> = vec![];
|
||||||
for i in vec.into_iter() {
|
for i in vec.into_iter() {
|
||||||
vec2.push(i);
|
vec2.push(i);
|
||||||
}
|
}
|
||||||
assert!(vec2 == vec!((), (), ()));
|
assert!(vec2 == vec![(), (), ()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2707,7 +2707,7 @@ mod tests {
|
||||||
b.bytes = src_len as u64;
|
b.bytes = src_len as u64;
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let dst = Vec::from_slice(src.clone().as_slice());
|
let dst = src.clone().as_slice().to_vec();
|
||||||
assert_eq!(dst.len(), src_len);
|
assert_eq!(dst.len(), src_len);
|
||||||
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
|
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
|
||||||
});
|
});
|
||||||
|
@ -2871,7 +2871,7 @@ mod tests {
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut dst = dst.clone();
|
let mut dst = dst.clone();
|
||||||
dst.push_all_move(src.clone());
|
dst.extend(src.clone().into_iter());
|
||||||
assert_eq!(dst.len(), dst_len + src_len);
|
assert_eq!(dst.len(), dst_len + src_len);
|
||||||
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
|
assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
|
||||||
});
|
});
|
||||||
|
|
|
@ -147,7 +147,7 @@ pub fn to_digit(c: char, radix: uint) -> Option<uint> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_digit(num: uint, radix: uint) -> Option<char> {
|
pub fn from_digit(num: uint, radix: uint) -> Option<char> {
|
||||||
if radix > 36 {
|
if radix > 36 {
|
||||||
fail!("from_digit: radix is to high (maximum 36)");
|
fail!("from_digit: radix is too high (maximum 36)");
|
||||||
}
|
}
|
||||||
if num < radix {
|
if num < radix {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -117,7 +117,7 @@ fn test_is_digit() {
|
||||||
fn test_escape_default() {
|
fn test_escape_default() {
|
||||||
fn string(c: char) -> String {
|
fn string(c: char) -> String {
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
escape_default(c, |c| { result.push_char(c); });
|
escape_default(c, |c| { result.push(c); });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
let s = string('\n');
|
let s = string('\n');
|
||||||
|
@ -152,7 +152,7 @@ fn test_escape_default() {
|
||||||
fn test_escape_unicode() {
|
fn test_escape_unicode() {
|
||||||
fn string(c: char) -> String {
|
fn string(c: char) -> String {
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
escape_unicode(c, |c| { result.push_char(c); });
|
escape_unicode(c, |c| { result.push(c); });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
let s = string('\x00');
|
let s = string('\x00');
|
||||||
|
|
|
@ -868,7 +868,7 @@ fn bench_multiple_take(b: &mut Bencher) {
|
||||||
let mut it = range(0u, 42).cycle();
|
let mut it = range(0u, 42).cycle();
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let n = it.next().unwrap();
|
let n = it.next().unwrap();
|
||||||
for m in range(0u, n) {
|
for _ in range(0u, n) {
|
||||||
it.take(it.next().unwrap()).all(|_| true);
|
it.take(it.next().unwrap()).all(|_| true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -109,7 +109,7 @@ fn test_transmute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(Vec::from_slice([76u8]) == transmute("L".to_string()));
|
assert!(vec![76u8] == transmute("L".to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ fn test_collect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(deprecated)] // we know fold_ is deprecated
|
||||||
fn test_fold() {
|
fn test_fold() {
|
||||||
assert_eq!(fold_(range(0i, 0)
|
assert_eq!(fold_(range(0i, 0)
|
||||||
.map(|_| Ok::<(), ()>(()))),
|
.map(|_| Ok::<(), ()>(()))),
|
||||||
|
|
|
@ -682,7 +682,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore(cfg(windows))] // FIXME (#9406)
|
#[cfg_attr(windows, ignore)] // FIXME (#9406)
|
||||||
fn test_lots_of_files() {
|
fn test_lots_of_files() {
|
||||||
// this is a good test because it touches lots of differently named files
|
// this is a good test because it touches lots of differently named files
|
||||||
glob("/*/*/*/*").skip(10000).next();
|
glob("/*/*/*/*").skip(10000).next();
|
||||||
|
|
|
@ -735,6 +735,20 @@ r#"digraph single_edge {
|
||||||
"#);
|
"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_some_labelled() {
|
||||||
|
let labels : Trivial = SomeNodesLabelled(vec![Some("A"), None]);
|
||||||
|
let result = test_input(LabelledGraph::new("test_some_labelled", labels,
|
||||||
|
vec![edge(0, 1, "A-1")]));
|
||||||
|
assert_eq!(result.unwrap().as_slice(),
|
||||||
|
r#"digraph test_some_labelled {
|
||||||
|
N0[label="A"];
|
||||||
|
N1[label="N1"];
|
||||||
|
N0 -> N1[label="A-1"];
|
||||||
|
}
|
||||||
|
"#);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn single_cyclic_node() {
|
fn single_cyclic_node() {
|
||||||
let labels : Trivial = UnlabelledNodes(1);
|
let labels : Trivial = UnlabelledNodes(1);
|
||||||
|
|
|
@ -1027,7 +1027,6 @@ mod test {
|
||||||
use std::rt::task::TaskOpts;
|
use std::rt::task::TaskOpts;
|
||||||
use std::rt::task::Task;
|
use std::rt::task::Task;
|
||||||
use std::rt::local::Local;
|
use std::rt::local::Local;
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use {TaskState, PoolConfig, SchedPool};
|
use {TaskState, PoolConfig, SchedPool};
|
||||||
use basic;
|
use basic;
|
||||||
|
|
|
@ -462,6 +462,7 @@ macro_rules! impl_integer_for_uint {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(type_overflow)]
|
||||||
fn test_lcm() {
|
fn test_lcm() {
|
||||||
assert_eq!((1 as $T).lcm(&0), 0 as $T);
|
assert_eq!((1 as $T).lcm(&0), 0 as $T);
|
||||||
assert_eq!((0 as $T).lcm(&1), 0 as $T);
|
assert_eq!((0 as $T).lcm(&1), 0 as $T);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
//
|
//
|
||||||
|
@ -641,41 +641,50 @@ impl<'a> Context<'a> {
|
||||||
// rlibs/dylibs.
|
// rlibs/dylibs.
|
||||||
let sess = self.sess;
|
let sess = self.sess;
|
||||||
let dylibname = self.dylibname();
|
let dylibname = self.dylibname();
|
||||||
let mut locs = locs.iter().map(|l| Path::new(l.as_slice())).filter(|loc| {
|
|
||||||
if !loc.exists() {
|
|
||||||
sess.err(format!("extern location does not exist: {}",
|
|
||||||
loc.display()).as_slice());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
let file = loc.filename_str().unwrap();
|
|
||||||
if file.starts_with("lib") && file.ends_with(".rlib") {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
match dylibname {
|
|
||||||
Some((prefix, suffix)) => {
|
|
||||||
if file.starts_with(prefix) && file.ends_with(suffix) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sess.err(format!("extern location is of an unknown type: {}",
|
|
||||||
loc.display()).as_slice());
|
|
||||||
false
|
|
||||||
});
|
|
||||||
|
|
||||||
// Now that we have an iterator of good candidates, make sure there's at
|
|
||||||
// most one rlib and at most one dylib.
|
|
||||||
let mut rlibs = HashSet::new();
|
let mut rlibs = HashSet::new();
|
||||||
let mut dylibs = HashSet::new();
|
let mut dylibs = HashSet::new();
|
||||||
for loc in locs {
|
{
|
||||||
if loc.filename_str().unwrap().ends_with(".rlib") {
|
let mut locs = locs.iter().map(|l| Path::new(l.as_slice())).filter(|loc| {
|
||||||
rlibs.insert(fs::realpath(&loc).unwrap());
|
if !loc.exists() {
|
||||||
} else {
|
sess.err(format!("extern location for {} does not exist: {}",
|
||||||
dylibs.insert(fs::realpath(&loc).unwrap());
|
self.crate_name, loc.display()).as_slice());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let file = match loc.filename_str() {
|
||||||
|
Some(file) => file,
|
||||||
|
None => {
|
||||||
|
sess.err(format!("extern location for {} is not a file: {}",
|
||||||
|
self.crate_name, loc.display()).as_slice());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if file.starts_with("lib") && file.ends_with(".rlib") {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
match dylibname {
|
||||||
|
Some((prefix, suffix)) => {
|
||||||
|
if file.starts_with(prefix) && file.ends_with(suffix) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sess.err(format!("extern location for {} is of an unknown type: {}",
|
||||||
|
self.crate_name, loc.display()).as_slice());
|
||||||
|
false
|
||||||
|
});
|
||||||
|
|
||||||
|
// Now that we have an iterator of good candidates, make sure there's at
|
||||||
|
// most one rlib and at most one dylib.
|
||||||
|
for loc in locs {
|
||||||
|
if loc.filename_str().unwrap().ends_with(".rlib") {
|
||||||
|
rlibs.insert(fs::realpath(&loc).unwrap());
|
||||||
|
} else {
|
||||||
|
dylibs.insert(fs::realpath(&loc).unwrap());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Extract the rlib/dylib pair.
|
// Extract the rlib/dylib pair.
|
||||||
let mut metadata = None;
|
let mut metadata = None;
|
||||||
|
|
|
@ -32,7 +32,7 @@ use syntax::ptr::P;
|
||||||
use syntax::visit::{mod, Visitor, FnKind};
|
use syntax::visit::{mod, Visitor, FnKind};
|
||||||
use util::ppaux::ty_to_string;
|
use util::ppaux::ty_to_string;
|
||||||
|
|
||||||
pub const DUMMY_WILD_PAT: Pat = Pat {
|
pub const DUMMY_WILD_PAT: &'static Pat = &Pat {
|
||||||
id: DUMMY_NODE_ID,
|
id: DUMMY_NODE_ID,
|
||||||
node: PatWild(PatWildSingle),
|
node: PatWild(PatWildSingle),
|
||||||
span: DUMMY_SP
|
span: DUMMY_SP
|
||||||
|
@ -309,12 +309,11 @@ fn raw_pat<'a>(p: &'a Pat) -> &'a Pat {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix) {
|
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix) {
|
||||||
match is_useful(cx, matrix, &[&DUMMY_WILD_PAT], ConstructWitness) {
|
match is_useful(cx, matrix, &[DUMMY_WILD_PAT], ConstructWitness) {
|
||||||
UsefulWithWitness(pats) => {
|
UsefulWithWitness(pats) => {
|
||||||
let dummy = DUMMY_WILD_PAT.clone();
|
|
||||||
let witness = match pats.as_slice() {
|
let witness = match pats.as_slice() {
|
||||||
[ref witness] => &**witness,
|
[ref witness] => &**witness,
|
||||||
[] => &dummy,
|
[] => DUMMY_WILD_PAT,
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
};
|
};
|
||||||
span_err!(cx.tcx.sess, sp, E0004,
|
span_err!(cx.tcx.sess, sp, E0004,
|
||||||
|
@ -568,9 +567,8 @@ fn is_useful(cx: &MatchCheckCtxt,
|
||||||
let arity = constructor_arity(cx, &c, left_ty);
|
let arity = constructor_arity(cx, &c, left_ty);
|
||||||
let mut result = {
|
let mut result = {
|
||||||
let pat_slice = pats.as_slice();
|
let pat_slice = pats.as_slice();
|
||||||
let dummy = DUMMY_WILD_PAT.clone();
|
|
||||||
let subpats = Vec::from_fn(arity, |i| {
|
let subpats = Vec::from_fn(arity, |i| {
|
||||||
pat_slice.get(i).map_or(&dummy, |p| &**p)
|
pat_slice.get(i).map_or(DUMMY_WILD_PAT, |p| &**p)
|
||||||
});
|
});
|
||||||
vec![construct_witness(cx, &c, subpats, left_ty)]
|
vec![construct_witness(cx, &c, subpats, left_ty)]
|
||||||
};
|
};
|
||||||
|
@ -592,9 +590,8 @@ fn is_useful(cx: &MatchCheckCtxt,
|
||||||
}).collect();
|
}).collect();
|
||||||
match is_useful(cx, &matrix, v.tail(), witness) {
|
match is_useful(cx, &matrix, v.tail(), witness) {
|
||||||
UsefulWithWitness(pats) => {
|
UsefulWithWitness(pats) => {
|
||||||
let dummy = DUMMY_WILD_PAT.clone();
|
|
||||||
let arity = constructor_arity(cx, &constructor, left_ty);
|
let arity = constructor_arity(cx, &constructor, left_ty);
|
||||||
let wild_pats = Vec::from_elem(arity, &dummy);
|
let wild_pats = Vec::from_elem(arity, DUMMY_WILD_PAT);
|
||||||
let enum_pat = construct_witness(cx, &constructor, wild_pats, left_ty);
|
let enum_pat = construct_witness(cx, &constructor, wild_pats, left_ty);
|
||||||
let mut new_pats = vec![enum_pat];
|
let mut new_pats = vec![enum_pat];
|
||||||
new_pats.extend(pats.into_iter());
|
new_pats.extend(pats.into_iter());
|
||||||
|
@ -615,11 +612,10 @@ fn is_useful_specialized(cx: &MatchCheckCtxt, &Matrix(ref m): &Matrix,
|
||||||
v: &[&Pat], ctor: Constructor, lty: ty::t,
|
v: &[&Pat], ctor: Constructor, lty: ty::t,
|
||||||
witness: WitnessPreference) -> Usefulness {
|
witness: WitnessPreference) -> Usefulness {
|
||||||
let arity = constructor_arity(cx, &ctor, lty);
|
let arity = constructor_arity(cx, &ctor, lty);
|
||||||
let dummy = DUMMY_WILD_PAT.clone();
|
|
||||||
let matrix = Matrix(m.iter().filter_map(|r| {
|
let matrix = Matrix(m.iter().filter_map(|r| {
|
||||||
specialize(cx, r.as_slice(), &dummy, &ctor, 0u, arity)
|
specialize(cx, r.as_slice(), &ctor, 0u, arity)
|
||||||
}).collect());
|
}).collect());
|
||||||
match specialize(cx, v, &dummy, &ctor, 0u, arity) {
|
match specialize(cx, v, &ctor, 0u, arity) {
|
||||||
Some(v) => is_useful(cx, &matrix, v.as_slice(), witness),
|
Some(v) => is_useful(cx, &matrix, v.as_slice(), witness),
|
||||||
None => NotUseful
|
None => NotUseful
|
||||||
}
|
}
|
||||||
|
@ -741,7 +737,7 @@ fn range_covered_by_constructor(ctor: &Constructor,
|
||||||
/// different patterns.
|
/// different patterns.
|
||||||
/// Structure patterns with a partial wild pattern (Foo { a: 42, .. }) have their missing
|
/// Structure patterns with a partial wild pattern (Foo { a: 42, .. }) have their missing
|
||||||
/// fields filled with wild patterns.
|
/// fields filled with wild patterns.
|
||||||
pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], dummy: &'a Pat,
|
pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
||||||
constructor: &Constructor, col: uint, arity: uint) -> Option<Vec<&'a Pat>> {
|
constructor: &Constructor, col: uint, arity: uint) -> Option<Vec<&'a Pat>> {
|
||||||
let &Pat {
|
let &Pat {
|
||||||
id: pat_id, node: ref node, span: pat_span
|
id: pat_id, node: ref node, span: pat_span
|
||||||
|
@ -749,7 +745,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], dummy: &'a Pat,
|
||||||
let head: Option<Vec<&Pat>> = match node {
|
let head: Option<Vec<&Pat>> = match node {
|
||||||
|
|
||||||
&PatWild(_) =>
|
&PatWild(_) =>
|
||||||
Some(Vec::from_elem(arity, dummy)),
|
Some(Vec::from_elem(arity, DUMMY_WILD_PAT)),
|
||||||
|
|
||||||
&PatIdent(_, _, _) => {
|
&PatIdent(_, _, _) => {
|
||||||
let opt_def = cx.tcx.def_map.borrow().find_copy(&pat_id);
|
let opt_def = cx.tcx.def_map.borrow().find_copy(&pat_id);
|
||||||
|
@ -762,7 +758,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], dummy: &'a Pat,
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
_ => Some(Vec::from_elem(arity, dummy))
|
_ => Some(Vec::from_elem(arity, DUMMY_WILD_PAT))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,7 +772,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], dummy: &'a Pat,
|
||||||
DefVariant(..) | DefStruct(..) => {
|
DefVariant(..) | DefStruct(..) => {
|
||||||
Some(match args {
|
Some(match args {
|
||||||
&Some(ref args) => args.iter().map(|p| &**p).collect(),
|
&Some(ref args) => args.iter().map(|p| &**p).collect(),
|
||||||
&None => Vec::from_elem(arity, dummy)
|
&None => Vec::from_elem(arity, DUMMY_WILD_PAT)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => None
|
_ => None
|
||||||
|
@ -812,7 +808,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], dummy: &'a Pat,
|
||||||
let args = struct_fields.iter().map(|sf| {
|
let args = struct_fields.iter().map(|sf| {
|
||||||
match pattern_fields.iter().find(|f| f.ident.name == sf.name) {
|
match pattern_fields.iter().find(|f| f.ident.name == sf.name) {
|
||||||
Some(ref f) => &*f.pat,
|
Some(ref f) => &*f.pat,
|
||||||
_ => dummy
|
_ => DUMMY_WILD_PAT
|
||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
args
|
args
|
||||||
|
@ -855,13 +851,13 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], dummy: &'a Pat,
|
||||||
// Fixed-length vectors.
|
// Fixed-length vectors.
|
||||||
Single => {
|
Single => {
|
||||||
let mut pats: Vec<&Pat> = before.iter().map(|p| &**p).collect();
|
let mut pats: Vec<&Pat> = before.iter().map(|p| &**p).collect();
|
||||||
pats.grow_fn(arity - before.len() - after.len(), |_| dummy);
|
pats.grow_fn(arity - before.len() - after.len(), |_| DUMMY_WILD_PAT);
|
||||||
pats.extend(after.iter().map(|p| &**p));
|
pats.extend(after.iter().map(|p| &**p));
|
||||||
Some(pats)
|
Some(pats)
|
||||||
},
|
},
|
||||||
Slice(length) if before.len() + after.len() <= length && slice.is_some() => {
|
Slice(length) if before.len() + after.len() <= length && slice.is_some() => {
|
||||||
let mut pats: Vec<&Pat> = before.iter().map(|p| &**p).collect();
|
let mut pats: Vec<&Pat> = before.iter().map(|p| &**p).collect();
|
||||||
pats.grow_fn(arity - before.len() - after.len(), |_| dummy);
|
pats.grow_fn(arity - before.len() - after.len(), |_| DUMMY_WILD_PAT);
|
||||||
pats.extend(after.iter().map(|p| &**p));
|
pats.extend(after.iter().map(|p| &**p));
|
||||||
Some(pats)
|
Some(pats)
|
||||||
},
|
},
|
||||||
|
@ -931,7 +927,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
|
||||||
|
|
||||||
fn is_refutable<A>(cx: &MatchCheckCtxt, pat: &Pat, refutable: |&Pat| -> A) -> Option<A> {
|
fn is_refutable<A>(cx: &MatchCheckCtxt, pat: &Pat, refutable: |&Pat| -> A) -> Option<A> {
|
||||||
let pats = Matrix(vec!(vec!(pat)));
|
let pats = Matrix(vec!(vec!(pat)));
|
||||||
match is_useful(cx, &pats, [&DUMMY_WILD_PAT], ConstructWitness) {
|
match is_useful(cx, &pats, [DUMMY_WILD_PAT], ConstructWitness) {
|
||||||
UsefulWithWitness(pats) => {
|
UsefulWithWitness(pats) => {
|
||||||
assert_eq!(pats.len(), 1);
|
assert_eq!(pats.len(), 1);
|
||||||
Some(refutable(&*pats[0]))
|
Some(refutable(&*pats[0]))
|
||||||
|
|
|
@ -32,13 +32,16 @@ struct RvalueContext<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
||||||
fn visit_fn(&mut self,
|
fn visit_fn(&mut self,
|
||||||
_: visit::FnKind<'v>,
|
fk: visit::FnKind<'v>,
|
||||||
fd: &'v ast::FnDecl,
|
fd: &'v ast::FnDecl,
|
||||||
b: &'v ast::Block,
|
b: &'v ast::Block,
|
||||||
_: Span,
|
s: Span,
|
||||||
_: ast::NodeId) {
|
_: ast::NodeId) {
|
||||||
let mut euv = euv::ExprUseVisitor::new(self, self.tcx);
|
{
|
||||||
euv.walk_fn(fd, b);
|
let mut euv = euv::ExprUseVisitor::new(self, self.tcx);
|
||||||
|
euv.walk_fn(fd, b);
|
||||||
|
}
|
||||||
|
visit::walk_fn(self, fk, fd, b, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
||||||
fn should_warn_about_item(&mut self, item: &ast::Item) -> bool {
|
fn should_warn_about_item(&mut self, item: &ast::Item) -> bool {
|
||||||
let should_warn = match item.node {
|
let should_warn = match item.node {
|
||||||
ast::ItemStatic(..)
|
ast::ItemStatic(..)
|
||||||
|
| ast::ItemConst(..)
|
||||||
| ast::ItemFn(..)
|
| ast::ItemFn(..)
|
||||||
| ast::ItemEnum(..)
|
| ast::ItemEnum(..)
|
||||||
| ast::ItemStruct(..) => true,
|
| ast::ItemStruct(..) => true,
|
||||||
|
|
|
@ -352,19 +352,6 @@ struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> {
|
||||||
pats: Vec<&'p ast::Pat>,
|
pats: Vec<&'p ast::Pat>,
|
||||||
data: &'a ArmData<'p, 'blk, 'tcx>,
|
data: &'a ArmData<'p, 'blk, 'tcx>,
|
||||||
bound_ptrs: Vec<(Ident, ValueRef)>,
|
bound_ptrs: Vec<(Ident, ValueRef)>,
|
||||||
|
|
||||||
// This is a pointer to an instance of check_match::DUMMY_WILD_PAT. The
|
|
||||||
// check_match code requires that we pass this in (with the same lifetime as
|
|
||||||
// the patterns passed in). Unfortunately this is required to be propagated
|
|
||||||
// into this structure in order to get the lifetimes to work.
|
|
||||||
//
|
|
||||||
// Lots of the `check_match` code will deal with &DUMMY_WILD_PAT when
|
|
||||||
// returning references, which used to have the `'static` lifetime before
|
|
||||||
// const was added to the language. The DUMMY_WILD_PAT does not implement
|
|
||||||
// Sync, however, so it must be a const, which longer has a static lifetime,
|
|
||||||
// hence we're passing it in here. This certainly isn't crucial, and if it
|
|
||||||
// can be removed, please do!
|
|
||||||
dummy: &'p ast::Pat,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'p, 'blk, 'tcx> Repr for Match<'a, 'p, 'blk, 'tcx> {
|
impl<'a, 'p, 'blk, 'tcx> Repr for Match<'a, 'p, 'blk, 'tcx> {
|
||||||
|
@ -417,7 +404,6 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
*pats.get_mut(col) = pat;
|
*pats.get_mut(col) = pat;
|
||||||
Match {
|
Match {
|
||||||
pats: pats,
|
pats: pats,
|
||||||
dummy: br.dummy,
|
|
||||||
data: &*br.data,
|
data: &*br.data,
|
||||||
bound_ptrs: bound_ptrs
|
bound_ptrs: bound_ptrs
|
||||||
}
|
}
|
||||||
|
@ -465,7 +451,6 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
}
|
}
|
||||||
Match {
|
Match {
|
||||||
pats: pats,
|
pats: pats,
|
||||||
dummy: br.dummy,
|
|
||||||
data: br.data,
|
data: br.data,
|
||||||
bound_ptrs: bound_ptrs
|
bound_ptrs: bound_ptrs
|
||||||
}
|
}
|
||||||
|
@ -560,8 +545,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
|
||||||
|
|
||||||
let mcx = check_match::MatchCheckCtxt { tcx: bcx.tcx() };
|
let mcx = check_match::MatchCheckCtxt { tcx: bcx.tcx() };
|
||||||
enter_match(bcx, dm, m, col, val, |pats|
|
enter_match(bcx, dm, m, col, val, |pats|
|
||||||
check_match::specialize(&mcx, pats.as_slice(), m[0].dummy, &ctor, col,
|
check_match::specialize(&mcx, pats.as_slice(), &ctor, col, variant_size)
|
||||||
variant_size)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1051,7 +1035,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||||
match adt_vals {
|
match adt_vals {
|
||||||
Some(field_vals) => {
|
Some(field_vals) => {
|
||||||
let pats = enter_match(bcx, dm, m, col, val, |pats|
|
let pats = enter_match(bcx, dm, m, col, val, |pats|
|
||||||
check_match::specialize(&mcx, pats, m[0].dummy,
|
check_match::specialize(&mcx, pats,
|
||||||
&check_match::Single, col,
|
&check_match::Single, col,
|
||||||
field_vals.len())
|
field_vals.len())
|
||||||
);
|
);
|
||||||
|
@ -1375,7 +1359,6 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
||||||
bindings_map: create_bindings_map(bcx, &**arm.pats.get(0), discr_expr, &*arm.body)
|
bindings_map: create_bindings_map(bcx, &**arm.pats.get(0), discr_expr, &*arm.body)
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
let dummy = check_match::DUMMY_WILD_PAT.clone();
|
|
||||||
let mut static_inliner = StaticInliner::new(scope_cx.tcx());
|
let mut static_inliner = StaticInliner::new(scope_cx.tcx());
|
||||||
let arm_pats: Vec<Vec<P<ast::Pat>>> = arm_datas.iter().map(|arm_data| {
|
let arm_pats: Vec<Vec<P<ast::Pat>>> = arm_datas.iter().map(|arm_data| {
|
||||||
arm_data.arm.pats.iter().map(|p| static_inliner.fold_pat((*p).clone())).collect()
|
arm_data.arm.pats.iter().map(|p| static_inliner.fold_pat((*p).clone())).collect()
|
||||||
|
@ -1384,7 +1367,6 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
|
||||||
for (arm_data, pats) in arm_datas.iter().zip(arm_pats.iter()) {
|
for (arm_data, pats) in arm_datas.iter().zip(arm_pats.iter()) {
|
||||||
matches.extend(pats.iter().map(|p| Match {
|
matches.extend(pats.iter().map(|p| Match {
|
||||||
pats: vec![&**p],
|
pats: vec![&**p],
|
||||||
dummy: &dummy,
|
|
||||||
data: arm_data,
|
data: arm_data,
|
||||||
bound_ptrs: Vec::new(),
|
bound_ptrs: Vec::new(),
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -788,7 +788,7 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
llself.is_some(),
|
llself.is_some(),
|
||||||
abi);
|
abi);
|
||||||
|
|
||||||
fcx.pop_custom_cleanup_scope(arg_cleanup_scope);
|
fcx.scopes.borrow_mut().last_mut().unwrap().drop_non_lifetime_clean();
|
||||||
|
|
||||||
// Invoke the actual rust fn and update bcx/llresult.
|
// Invoke the actual rust fn and update bcx/llresult.
|
||||||
let (llret, b) = base::invoke(bcx,
|
let (llret, b) = base::invoke(bcx,
|
||||||
|
@ -829,12 +829,15 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
cleanup::CustomScope(arg_cleanup_scope),
|
cleanup::CustomScope(arg_cleanup_scope),
|
||||||
false,
|
false,
|
||||||
abi);
|
abi);
|
||||||
fcx.pop_custom_cleanup_scope(arg_cleanup_scope);
|
fcx.scopes.borrow_mut().last_mut().unwrap().drop_non_lifetime_clean();
|
||||||
|
|
||||||
bcx = foreign::trans_native_call(bcx, callee_ty,
|
bcx = foreign::trans_native_call(bcx, callee_ty,
|
||||||
llfn, opt_llretslot.unwrap(),
|
llfn, opt_llretslot.unwrap(),
|
||||||
llargs.as_slice(), arg_tys);
|
llargs.as_slice(), arg_tys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fcx.pop_and_trans_custom_cleanup_scope(bcx, arg_cleanup_scope);
|
||||||
|
|
||||||
// If the caller doesn't care about the result of this fn call,
|
// If the caller doesn't care about the result of this fn call,
|
||||||
// drop the temporary slot we made.
|
// drop the temporary slot we made.
|
||||||
match (dest, opt_llretslot) {
|
match (dest, opt_llretslot) {
|
||||||
|
|
|
@ -74,6 +74,7 @@ pub struct CachedEarlyExit {
|
||||||
pub trait Cleanup {
|
pub trait Cleanup {
|
||||||
fn must_unwind(&self) -> bool;
|
fn must_unwind(&self) -> bool;
|
||||||
fn clean_on_unwind(&self) -> bool;
|
fn clean_on_unwind(&self) -> bool;
|
||||||
|
fn is_lifetime_end(&self) -> bool;
|
||||||
fn trans<'blk, 'tcx>(&self,
|
fn trans<'blk, 'tcx>(&self,
|
||||||
bcx: Block<'blk, 'tcx>,
|
bcx: Block<'blk, 'tcx>,
|
||||||
debug_loc: Option<NodeInfo>)
|
debug_loc: Option<NodeInfo>)
|
||||||
|
@ -875,6 +876,10 @@ impl<'blk, 'tcx> CleanupScope<'blk, 'tcx> {
|
||||||
LoopScopeKind(id, _) => format!("{}_loop_{}_", prefix, id),
|
LoopScopeKind(id, _) => format!("{}_loop_{}_", prefix, id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn drop_non_lifetime_clean(&mut self) {
|
||||||
|
self.cleanups.retain(|c| c.is_lifetime_end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'blk, 'tcx> CleanupScopeKind<'blk, 'tcx> {
|
impl<'blk, 'tcx> CleanupScopeKind<'blk, 'tcx> {
|
||||||
|
@ -943,6 +948,10 @@ impl Cleanup for DropValue {
|
||||||
self.must_unwind
|
self.must_unwind
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_lifetime_end(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn trans<'blk, 'tcx>(&self,
|
fn trans<'blk, 'tcx>(&self,
|
||||||
bcx: Block<'blk, 'tcx>,
|
bcx: Block<'blk, 'tcx>,
|
||||||
debug_loc: Option<NodeInfo>)
|
debug_loc: Option<NodeInfo>)
|
||||||
|
@ -978,6 +987,10 @@ impl Cleanup for FreeValue {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_lifetime_end(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn trans<'blk, 'tcx>(&self,
|
fn trans<'blk, 'tcx>(&self,
|
||||||
bcx: Block<'blk, 'tcx>,
|
bcx: Block<'blk, 'tcx>,
|
||||||
debug_loc: Option<NodeInfo>)
|
debug_loc: Option<NodeInfo>)
|
||||||
|
@ -1008,6 +1021,10 @@ impl Cleanup for FreeSlice {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_lifetime_end(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn trans<'blk, 'tcx>(&self,
|
fn trans<'blk, 'tcx>(&self,
|
||||||
bcx: Block<'blk, 'tcx>,
|
bcx: Block<'blk, 'tcx>,
|
||||||
debug_loc: Option<NodeInfo>)
|
debug_loc: Option<NodeInfo>)
|
||||||
|
@ -1035,6 +1052,10 @@ impl Cleanup for LifetimeEnd {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_lifetime_end(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
fn trans<'blk, 'tcx>(&self,
|
fn trans<'blk, 'tcx>(&self,
|
||||||
bcx: Block<'blk, 'tcx>,
|
bcx: Block<'blk, 'tcx>,
|
||||||
debug_loc: Option<NodeInfo>)
|
debug_loc: Option<NodeInfo>)
|
||||||
|
|
|
@ -655,19 +655,19 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smoke_lock() {
|
fn smoke_lock() {
|
||||||
static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
|
static LK: StaticNativeMutex = NATIVE_MUTEX_INIT;
|
||||||
unsafe {
|
unsafe {
|
||||||
let _guard = lock.lock();
|
let _guard = LK.lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smoke_cond() {
|
fn smoke_cond() {
|
||||||
static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
|
static LK: StaticNativeMutex = NATIVE_MUTEX_INIT;
|
||||||
unsafe {
|
unsafe {
|
||||||
let guard = lock.lock();
|
let guard = LK.lock();
|
||||||
let t = Thread::start(proc() {
|
let t = Thread::start(proc() {
|
||||||
let guard = lock.lock();
|
let guard = LK.lock();
|
||||||
guard.signal();
|
guard.signal();
|
||||||
});
|
});
|
||||||
guard.wait();
|
guard.wait();
|
||||||
|
@ -679,25 +679,25 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smoke_lock_noguard() {
|
fn smoke_lock_noguard() {
|
||||||
static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
|
static LK: StaticNativeMutex = NATIVE_MUTEX_INIT;
|
||||||
unsafe {
|
unsafe {
|
||||||
lock.lock_noguard();
|
LK.lock_noguard();
|
||||||
lock.unlock_noguard();
|
LK.unlock_noguard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smoke_cond_noguard() {
|
fn smoke_cond_noguard() {
|
||||||
static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
|
static LK: StaticNativeMutex = NATIVE_MUTEX_INIT;
|
||||||
unsafe {
|
unsafe {
|
||||||
lock.lock_noguard();
|
LK.lock_noguard();
|
||||||
let t = Thread::start(proc() {
|
let t = Thread::start(proc() {
|
||||||
lock.lock_noguard();
|
LK.lock_noguard();
|
||||||
lock.signal_noguard();
|
LK.signal_noguard();
|
||||||
lock.unlock_noguard();
|
LK.unlock_noguard();
|
||||||
});
|
});
|
||||||
lock.wait_noguard();
|
LK.wait_noguard();
|
||||||
lock.unlock_noguard();
|
LK.unlock_noguard();
|
||||||
|
|
||||||
t.join();
|
t.join();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2964,8 +2964,8 @@ mod tests {
|
||||||
let s = "{\"f\":null,\"a\":[null,123]}";
|
let s = "{\"f\":null,\"a\":[null,123]}";
|
||||||
let obj: FloatStruct = super::decode(s).unwrap();
|
let obj: FloatStruct = super::decode(s).unwrap();
|
||||||
assert!(obj.f.is_nan());
|
assert!(obj.f.is_nan());
|
||||||
assert!(obj.a.get(0).is_nan());
|
assert!(obj.a[0].is_nan());
|
||||||
assert_eq!(obj.a.get(1), &123f64);
|
assert_eq!(obj.a[1], 123f64);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -582,15 +582,15 @@ mod tests {
|
||||||
assert_eq!('A'.to_ascii().to_char(), 'A');
|
assert_eq!('A'.to_ascii().to_char(), 'A');
|
||||||
assert_eq!('A'.to_ascii().to_byte(), 65u8);
|
assert_eq!('A'.to_ascii().to_byte(), 65u8);
|
||||||
|
|
||||||
assert_eq!('A'.to_ascii().to_lower().to_char(), 'a');
|
assert_eq!('A'.to_ascii().to_lowercase().to_char(), 'a');
|
||||||
assert_eq!('Z'.to_ascii().to_lower().to_char(), 'z');
|
assert_eq!('Z'.to_ascii().to_lowercase().to_char(), 'z');
|
||||||
assert_eq!('a'.to_ascii().to_upper().to_char(), 'A');
|
assert_eq!('a'.to_ascii().to_uppercase().to_char(), 'A');
|
||||||
assert_eq!('z'.to_ascii().to_upper().to_char(), 'Z');
|
assert_eq!('z'.to_ascii().to_uppercase().to_char(), 'Z');
|
||||||
|
|
||||||
assert_eq!('@'.to_ascii().to_lower().to_char(), '@');
|
assert_eq!('@'.to_ascii().to_lowercase().to_char(), '@');
|
||||||
assert_eq!('['.to_ascii().to_lower().to_char(), '[');
|
assert_eq!('['.to_ascii().to_lowercase().to_char(), '[');
|
||||||
assert_eq!('`'.to_ascii().to_upper().to_char(), '`');
|
assert_eq!('`'.to_ascii().to_uppercase().to_char(), '`');
|
||||||
assert_eq!('{'.to_ascii().to_upper().to_char(), '{');
|
assert_eq!('{'.to_ascii().to_uppercase().to_char(), '{');
|
||||||
|
|
||||||
assert!('0'.to_ascii().is_digit());
|
assert!('0'.to_ascii().is_digit());
|
||||||
assert!('9'.to_ascii().is_digit());
|
assert!('9'.to_ascii().is_digit());
|
||||||
|
|
|
@ -273,8 +273,8 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
flags AnotherSetOfFlags: uint {
|
flags AnotherSetOfFlags: i8 {
|
||||||
const AnotherFlag = 1u,
|
const AnotherFlag = -1_i8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,6 +283,9 @@ mod tests {
|
||||||
assert_eq!(Flags::empty().bits(), 0x00000000);
|
assert_eq!(Flags::empty().bits(), 0x00000000);
|
||||||
assert_eq!(FlagA.bits(), 0x00000001);
|
assert_eq!(FlagA.bits(), 0x00000001);
|
||||||
assert_eq!(FlagABC.bits(), 0x00000111);
|
assert_eq!(FlagABC.bits(), 0x00000111);
|
||||||
|
|
||||||
|
assert_eq!(AnotherSetOfFlags::empty().bits(), 0x00);
|
||||||
|
assert_eq!(AnotherFlag.bits(), !0_i8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -292,6 +295,8 @@ mod tests {
|
||||||
assert!(Flags::from_bits(0x10) == Some(FlagB));
|
assert!(Flags::from_bits(0x10) == Some(FlagB));
|
||||||
assert!(Flags::from_bits(0x11) == Some(FlagA | FlagB));
|
assert!(Flags::from_bits(0x11) == Some(FlagA | FlagB));
|
||||||
assert!(Flags::from_bits(0x1000) == None);
|
assert!(Flags::from_bits(0x1000) == None);
|
||||||
|
|
||||||
|
assert!(AnotherSetOfFlags::from_bits(!0_i8) == Some(AnotherFlag));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -302,6 +307,8 @@ mod tests {
|
||||||
assert!(Flags::from_bits_truncate(0x11) == (FlagA | FlagB));
|
assert!(Flags::from_bits_truncate(0x11) == (FlagA | FlagB));
|
||||||
assert!(Flags::from_bits_truncate(0x1000) == Flags::empty());
|
assert!(Flags::from_bits_truncate(0x1000) == Flags::empty());
|
||||||
assert!(Flags::from_bits_truncate(0x1001) == FlagA);
|
assert!(Flags::from_bits_truncate(0x1001) == FlagA);
|
||||||
|
|
||||||
|
assert!(AnotherSetOfFlags::from_bits_truncate(0_i8) == AnotherSetOfFlags::empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -309,6 +316,8 @@ mod tests {
|
||||||
assert!(Flags::empty().is_empty());
|
assert!(Flags::empty().is_empty());
|
||||||
assert!(!FlagA.is_empty());
|
assert!(!FlagA.is_empty());
|
||||||
assert!(!FlagABC.is_empty());
|
assert!(!FlagABC.is_empty());
|
||||||
|
|
||||||
|
assert!(!AnotherFlag.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -316,6 +325,8 @@ mod tests {
|
||||||
assert!(Flags::all().is_all());
|
assert!(Flags::all().is_all());
|
||||||
assert!(!FlagA.is_all());
|
assert!(!FlagA.is_all());
|
||||||
assert!(FlagABC.is_all());
|
assert!(FlagABC.is_all());
|
||||||
|
|
||||||
|
assert!(AnotherFlag.is_all());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -323,6 +334,8 @@ mod tests {
|
||||||
let e1 = Flags::empty();
|
let e1 = Flags::empty();
|
||||||
let e2 = Flags::empty();
|
let e2 = Flags::empty();
|
||||||
assert!(!e1.intersects(e2));
|
assert!(!e1.intersects(e2));
|
||||||
|
|
||||||
|
assert!(AnotherFlag.intersects(AnotherFlag));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -353,6 +366,8 @@ mod tests {
|
||||||
assert!(!e1.contains(e2));
|
assert!(!e1.contains(e2));
|
||||||
assert!(e2.contains(e1));
|
assert!(e2.contains(e1));
|
||||||
assert!(FlagABC.contains(e2));
|
assert!(FlagABC.contains(e2));
|
||||||
|
|
||||||
|
assert!(AnotherFlag.contains(AnotherFlag));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -361,6 +376,10 @@ mod tests {
|
||||||
let e2 = FlagA | FlagB;
|
let e2 = FlagA | FlagB;
|
||||||
e1.insert(e2);
|
e1.insert(e2);
|
||||||
assert!(e1 == e2);
|
assert!(e1 == e2);
|
||||||
|
|
||||||
|
let mut e3 = AnotherSetOfFlags::empty();
|
||||||
|
e3.insert(AnotherFlag);
|
||||||
|
assert!(e3 == AnotherFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -369,6 +388,10 @@ mod tests {
|
||||||
let e2 = FlagA | FlagC;
|
let e2 = FlagA | FlagC;
|
||||||
e1.remove(e2);
|
e1.remove(e2);
|
||||||
assert!(e1 == FlagB);
|
assert!(e1 == FlagB);
|
||||||
|
|
||||||
|
let mut e3 = AnotherFlag;
|
||||||
|
e3.remove(AnotherFlag);
|
||||||
|
assert!(e3 == AnotherSetOfFlags::empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -383,6 +406,10 @@ mod tests {
|
||||||
let mut e3 = e1;
|
let mut e3 = e1;
|
||||||
e3.toggle(e2);
|
e3.toggle(e2);
|
||||||
assert!(e3 == FlagA | FlagB);
|
assert!(e3 == FlagA | FlagB);
|
||||||
|
|
||||||
|
let mut m4 = AnotherSetOfFlags::empty();
|
||||||
|
m4.toggle(AnotherSetOfFlags::empty());
|
||||||
|
assert!(m4 == AnotherSetOfFlags::empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1930,6 +1930,7 @@ mod test_map {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(deprecated)] // insert_or_update_with
|
||||||
fn test_update_with() {
|
fn test_update_with() {
|
||||||
let mut m = HashMap::with_capacity(4);
|
let mut m = HashMap::with_capacity(4);
|
||||||
assert!(m.insert(1i, 2i));
|
assert!(m.insert(1i, 2i));
|
||||||
|
|
|
@ -400,7 +400,7 @@ mod test {
|
||||||
|
|
||||||
impl Reader for ShortReader {
|
impl Reader for ShortReader {
|
||||||
fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> {
|
fn read(&mut self, _: &mut [u8]) -> io::IoResult<uint> {
|
||||||
match self.lengths.shift() {
|
match self.lengths.remove(0) {
|
||||||
Some(i) => Ok(i),
|
Some(i) => Ok(i),
|
||||||
None => Err(io::standard_error(io::EndOfFile))
|
None => Err(io::standard_error(io::EndOfFile))
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_read_line() {
|
fn test_read_line() {
|
||||||
let in_buf = MemReader::new(Vec::from_slice(b"a\nb\nc"));
|
let in_buf = MemReader::new(b"a\nb\nc".to_vec());
|
||||||
let mut reader = BufferedReader::with_capacity(2, in_buf);
|
let mut reader = BufferedReader::with_capacity(2, in_buf);
|
||||||
assert_eq!(reader.read_line(), Ok("a\n".to_string()));
|
assert_eq!(reader.read_line(), Ok("a\n".to_string()));
|
||||||
assert_eq!(reader.read_line(), Ok("b\n".to_string()));
|
assert_eq!(reader.read_line(), Ok("b\n".to_string()));
|
||||||
|
@ -561,7 +561,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_lines() {
|
fn test_lines() {
|
||||||
let in_buf = MemReader::new(Vec::from_slice(b"a\nb\nc"));
|
let in_buf = MemReader::new(b"a\nb\nc".to_vec());
|
||||||
let mut reader = BufferedReader::with_capacity(2, in_buf);
|
let mut reader = BufferedReader::with_capacity(2, in_buf);
|
||||||
let mut it = reader.lines();
|
let mut it = reader.lines();
|
||||||
assert_eq!(it.next(), Some(Ok("a\n".to_string())));
|
assert_eq!(it.next(), Some(Ok("a\n".to_string())));
|
||||||
|
|
|
@ -1415,7 +1415,7 @@ mod test {
|
||||||
check!(copy(&input, &output));
|
check!(copy(&input, &output));
|
||||||
|
|
||||||
assert_eq!(check!(File::open(&output).read_to_end()),
|
assert_eq!(check!(File::open(&output).read_to_end()),
|
||||||
(Vec::from_slice(b"foo")));
|
b"foo".to_vec());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1459,7 +1459,7 @@ mod test {
|
||||||
}
|
}
|
||||||
assert_eq!(check!(stat(&out)).size, check!(stat(&input)).size);
|
assert_eq!(check!(stat(&out)).size, check!(stat(&input)).size);
|
||||||
assert_eq!(check!(File::open(&out).read_to_end()),
|
assert_eq!(check!(File::open(&out).read_to_end()),
|
||||||
(Vec::from_slice(b"foobar")));
|
b"foobar".to_vec());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))] // apparently windows doesn't like symlinks
|
#[cfg(not(windows))] // apparently windows doesn't like symlinks
|
||||||
|
@ -1497,7 +1497,7 @@ mod test {
|
||||||
assert_eq!(check!(stat(&out)).size, check!(stat(&input)).size);
|
assert_eq!(check!(stat(&out)).size, check!(stat(&input)).size);
|
||||||
assert_eq!(check!(stat(&out)).size, check!(input.stat()).size);
|
assert_eq!(check!(stat(&out)).size, check!(input.stat()).size);
|
||||||
assert_eq!(check!(File::open(&out).read_to_end()),
|
assert_eq!(check!(File::open(&out).read_to_end()),
|
||||||
(Vec::from_slice(b"foobar")));
|
b"foobar".to_vec());
|
||||||
|
|
||||||
// can't link to yourself
|
// can't link to yourself
|
||||||
match link(&input, &input) {
|
match link(&input, &input) {
|
||||||
|
@ -1560,7 +1560,7 @@ mod test {
|
||||||
check!(file.fsync());
|
check!(file.fsync());
|
||||||
assert_eq!(check!(file.stat()).size, 10);
|
assert_eq!(check!(file.stat()).size, 10);
|
||||||
assert_eq!(check!(File::open(&path).read_to_end()),
|
assert_eq!(check!(File::open(&path).read_to_end()),
|
||||||
(Vec::from_slice(b"foobar\0\0\0\0")));
|
b"foobar\0\0\0\0".to_vec());
|
||||||
|
|
||||||
// Truncate to a smaller length, don't seek, and then write something.
|
// Truncate to a smaller length, don't seek, and then write something.
|
||||||
// Ensure that the intermediate zeroes are all filled in (we're seeked
|
// Ensure that the intermediate zeroes are all filled in (we're seeked
|
||||||
|
@ -1571,7 +1571,7 @@ mod test {
|
||||||
check!(file.fsync());
|
check!(file.fsync());
|
||||||
assert_eq!(check!(file.stat()).size, 9);
|
assert_eq!(check!(file.stat()).size, 9);
|
||||||
assert_eq!(check!(File::open(&path).read_to_end()),
|
assert_eq!(check!(File::open(&path).read_to_end()),
|
||||||
(Vec::from_slice(b"fo\0\0\0\0wut")));
|
b"fo\0\0\0\0wut".to_vec());
|
||||||
drop(file);
|
drop(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -617,7 +617,7 @@ mod test {
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_mem_reader(b: &mut Bencher) {
|
fn bench_mem_reader(b: &mut Bencher) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let buf = Vec::from_slice([5 as u8, ..100]);
|
let buf = [5 as u8, ..100].to_vec();
|
||||||
{
|
{
|
||||||
let mut rdr = MemReader::new(buf);
|
let mut rdr = MemReader::new(buf);
|
||||||
for _i in range(0u, 10) {
|
for _i in range(0u, 10) {
|
||||||
|
|
|
@ -1949,62 +1949,62 @@ mod tests {
|
||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
behavior.shift();
|
behavior.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_read_at_least() {
|
fn test_read_at_least() {
|
||||||
let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")),
|
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
|
||||||
Vec::from_slice([GoodBehavior(uint::MAX)]));
|
vec![GoodBehavior(uint::MAX)]);
|
||||||
let mut buf = [0u8, ..5];
|
let mut buf = [0u8, ..5];
|
||||||
assert!(r.read_at_least(1, buf).unwrap() >= 1);
|
assert!(r.read_at_least(1, buf).unwrap() >= 1);
|
||||||
assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least
|
assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least
|
||||||
assert!(r.read_at_least(0, buf).is_ok());
|
assert!(r.read_at_least(0, buf).is_ok());
|
||||||
|
|
||||||
let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")),
|
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
|
||||||
Vec::from_slice([BadBehavior(50), GoodBehavior(uint::MAX)]));
|
vec![BadBehavior(50), GoodBehavior(uint::MAX)]);
|
||||||
assert!(r.read_at_least(1, buf).unwrap() >= 1);
|
assert!(r.read_at_least(1, buf).unwrap() >= 1);
|
||||||
|
|
||||||
let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")),
|
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
|
||||||
Vec::from_slice([BadBehavior(1), GoodBehavior(1),
|
vec![BadBehavior(1), GoodBehavior(1),
|
||||||
BadBehavior(50), GoodBehavior(uint::MAX)]));
|
BadBehavior(50), GoodBehavior(uint::MAX)]);
|
||||||
assert!(r.read_at_least(1, buf).unwrap() >= 1);
|
assert!(r.read_at_least(1, buf).unwrap() >= 1);
|
||||||
assert!(r.read_at_least(1, buf).unwrap() >= 1);
|
assert!(r.read_at_least(1, buf).unwrap() >= 1);
|
||||||
|
|
||||||
let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")),
|
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
|
||||||
Vec::from_slice([BadBehavior(uint::MAX)]));
|
vec![BadBehavior(uint::MAX)]);
|
||||||
assert_eq!(r.read_at_least(1, buf).unwrap_err().kind, NoProgress);
|
assert_eq!(r.read_at_least(1, buf).unwrap_err().kind, NoProgress);
|
||||||
|
|
||||||
let mut r = MemReader::new(Vec::from_slice(b"hello, world!"));
|
let mut r = MemReader::new(b"hello, world!".to_vec());
|
||||||
assert_eq!(r.read_at_least(5, buf).unwrap(), 5);
|
assert_eq!(r.read_at_least(5, buf).unwrap(), 5);
|
||||||
assert_eq!(r.read_at_least(6, buf).unwrap_err().kind, InvalidInput);
|
assert_eq!(r.read_at_least(6, buf).unwrap_err().kind, InvalidInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_push_at_least() {
|
fn test_push_at_least() {
|
||||||
let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")),
|
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
|
||||||
Vec::from_slice([GoodBehavior(uint::MAX)]));
|
vec![GoodBehavior(uint::MAX)]);
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
|
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
|
||||||
assert!(r.push_at_least(0, 5, &mut buf).is_ok());
|
assert!(r.push_at_least(0, 5, &mut buf).is_ok());
|
||||||
|
|
||||||
let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")),
|
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
|
||||||
Vec::from_slice([BadBehavior(50), GoodBehavior(uint::MAX)]));
|
vec![BadBehavior(50), GoodBehavior(uint::MAX)]);
|
||||||
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
|
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
|
||||||
|
|
||||||
let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")),
|
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
|
||||||
Vec::from_slice([BadBehavior(1), GoodBehavior(1),
|
vec![BadBehavior(1), GoodBehavior(1),
|
||||||
BadBehavior(50), GoodBehavior(uint::MAX)]));
|
BadBehavior(50), GoodBehavior(uint::MAX)]);
|
||||||
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
|
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
|
||||||
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
|
assert!(r.push_at_least(1, 5, &mut buf).unwrap() >= 1);
|
||||||
|
|
||||||
let mut r = BadReader::new(MemReader::new(Vec::from_slice(b"hello, world!")),
|
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
|
||||||
Vec::from_slice([BadBehavior(uint::MAX)]));
|
vec![BadBehavior(uint::MAX)]);
|
||||||
assert_eq!(r.push_at_least(1, 5, &mut buf).unwrap_err().kind, NoProgress);
|
assert_eq!(r.push_at_least(1, 5, &mut buf).unwrap_err().kind, NoProgress);
|
||||||
|
|
||||||
let mut r = MemReader::new(Vec::from_slice(b"hello, world!"));
|
let mut r = MemReader::new(b"hello, world!".to_vec());
|
||||||
assert_eq!(r.push_at_least(5, 1, &mut buf).unwrap_err().kind, InvalidInput);
|
assert_eq!(r.push_at_least(5, 1, &mut buf).unwrap_err().kind, InvalidInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,9 +126,7 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>)
|
||||||
#[cfg(all(test, not(target_os = "android")))]
|
#[cfg(all(test, not(target_os = "android")))]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use io::net::tcp::*;
|
|
||||||
use io::net::ip::*;
|
use io::net::ip::*;
|
||||||
use io::net::udp::*;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dns_smoke_test() {
|
fn dns_smoke_test() {
|
||||||
|
|
|
@ -521,10 +521,8 @@ impl Clone for TcpAcceptor {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(experimental)]
|
#[allow(experimental)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
|
||||||
use io::net::tcp::*;
|
use io::net::tcp::*;
|
||||||
use io::net::ip::*;
|
use io::net::ip::*;
|
||||||
use io::net::udp::*;
|
|
||||||
use io::*;
|
use io::*;
|
||||||
use io::test::*;
|
use io::test::*;
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
|
@ -118,7 +118,6 @@ impl Writer for PipeStream {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -727,7 +727,7 @@ mod tests {
|
||||||
assert!(p.is_ok());
|
assert!(p.is_ok());
|
||||||
let mut p = p.unwrap();
|
let mut p = p.unwrap();
|
||||||
assert!(p.stdout.is_some());
|
assert!(p.stdout.is_some());
|
||||||
let ret = read_all(p.stdout.get_mut_ref() as &mut Reader);
|
let ret = read_all(p.stdout.as_mut().unwrap() as &mut Reader);
|
||||||
assert!(p.wait().unwrap().success());
|
assert!(p.wait().unwrap().success());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -758,9 +758,9 @@ mod tests {
|
||||||
.stdin(CreatePipe(true, false))
|
.stdin(CreatePipe(true, false))
|
||||||
.stdout(CreatePipe(false, true))
|
.stdout(CreatePipe(false, true))
|
||||||
.spawn().unwrap();
|
.spawn().unwrap();
|
||||||
p.stdin.get_mut_ref().write("foobar".as_bytes()).unwrap();
|
p.stdin.as_mut().unwrap().write("foobar".as_bytes()).unwrap();
|
||||||
drop(p.stdin.take());
|
drop(p.stdin.take());
|
||||||
let out = read_all(p.stdout.get_mut_ref() as &mut Reader);
|
let out = read_all(p.stdout.as_mut().unwrap() as &mut Reader);
|
||||||
assert!(p.wait().unwrap().success());
|
assert!(p.wait().unwrap().success());
|
||||||
assert_eq!(out, "foobar\n".to_string());
|
assert_eq!(out, "foobar\n".to_string());
|
||||||
}
|
}
|
||||||
|
@ -1019,7 +1019,7 @@ mod tests {
|
||||||
fn test_add_to_env() {
|
fn test_add_to_env() {
|
||||||
let prog = env_cmd().env("RUN_TEST_NEW_ENV", "123").spawn().unwrap();
|
let prog = env_cmd().env("RUN_TEST_NEW_ENV", "123").spawn().unwrap();
|
||||||
let result = prog.wait_with_output().unwrap();
|
let result = prog.wait_with_output().unwrap();
|
||||||
let output = str::from_utf8_lossy(result.output.as_slice()).into_string();
|
let output = String::from_utf8_lossy(result.output.as_slice()).into_string();
|
||||||
|
|
||||||
assert!(output.as_slice().contains("RUN_TEST_NEW_ENV=123"),
|
assert!(output.as_slice().contains("RUN_TEST_NEW_ENV=123"),
|
||||||
"didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
|
"didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
|
||||||
|
|
|
@ -385,6 +385,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
fn smoke() {
|
fn smoke() {
|
||||||
// Just make sure we can acquire handles
|
// Just make sure we can acquire handles
|
||||||
stdin();
|
stdin();
|
||||||
|
@ -392,6 +393,7 @@ mod tests {
|
||||||
stderr();
|
stderr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
fn capture_stdout() {
|
fn capture_stdout() {
|
||||||
use io::{ChanReader, ChanWriter};
|
use io::{ChanReader, ChanWriter};
|
||||||
|
|
||||||
|
@ -404,9 +406,10 @@ mod tests {
|
||||||
assert_eq!(r.read_to_string().unwrap(), "hello!\n".to_string());
|
assert_eq!(r.read_to_string().unwrap(), "hello!\n".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
fn capture_stderr() {
|
fn capture_stderr() {
|
||||||
use realstd::comm::channel;
|
use realstd::comm::channel;
|
||||||
use realstd::io::{Writer, ChanReader, ChanWriter, Reader};
|
use realstd::io::{ChanReader, ChanWriter, Reader};
|
||||||
|
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
|
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
|
||||||
|
|
|
@ -235,7 +235,6 @@ mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use time::Duration;
|
use time::Duration;
|
||||||
use task::spawn;
|
use task::spawn;
|
||||||
use io::*;
|
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -819,72 +819,82 @@ mod bench {
|
||||||
mod uint {
|
mod uint {
|
||||||
use super::test::Bencher;
|
use super::test::Bencher;
|
||||||
use rand::{weak_rng, Rng};
|
use rand::{weak_rng, Rng};
|
||||||
use num::ToStrRadix;
|
use std::fmt;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_string(x: uint, base: u8) {
|
||||||
|
format!("{}", fmt::radix(x, base));
|
||||||
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_bin(b: &mut Bencher) {
|
fn to_str_bin(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<uint>().to_str_radix(2); })
|
b.iter(|| { to_string(rng.gen::<uint>(), 2); })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_oct(b: &mut Bencher) {
|
fn to_str_oct(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<uint>().to_str_radix(8); })
|
b.iter(|| { to_string(rng.gen::<uint>(), 8); })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_dec(b: &mut Bencher) {
|
fn to_str_dec(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<uint>().to_str_radix(10); })
|
b.iter(|| { to_string(rng.gen::<uint>(), 10); })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_hex(b: &mut Bencher) {
|
fn to_str_hex(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<uint>().to_str_radix(16); })
|
b.iter(|| { to_string(rng.gen::<uint>(), 16); })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_base_36(b: &mut Bencher) {
|
fn to_str_base_36(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<uint>().to_str_radix(36); })
|
b.iter(|| { to_string(rng.gen::<uint>(), 36); })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod int {
|
mod int {
|
||||||
use super::test::Bencher;
|
use super::test::Bencher;
|
||||||
use rand::{weak_rng, Rng};
|
use rand::{weak_rng, Rng};
|
||||||
use num::ToStrRadix;
|
use std::fmt;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_string(x: int, base: u8) {
|
||||||
|
format!("{}", fmt::radix(x, base));
|
||||||
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_bin(b: &mut Bencher) {
|
fn to_str_bin(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<int>().to_str_radix(2); })
|
b.iter(|| { to_string(rng.gen::<int>(), 2); })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_oct(b: &mut Bencher) {
|
fn to_str_oct(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<int>().to_str_radix(8); })
|
b.iter(|| { to_string(rng.gen::<int>(), 8); })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_dec(b: &mut Bencher) {
|
fn to_str_dec(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<int>().to_str_radix(10); })
|
b.iter(|| { to_string(rng.gen::<int>(), 10); })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_hex(b: &mut Bencher) {
|
fn to_str_hex(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<int>().to_str_radix(16); })
|
b.iter(|| { to_string(rng.gen::<int>(), 16); })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn to_str_base_36(b: &mut Bencher) {
|
fn to_str_base_36(b: &mut Bencher) {
|
||||||
let mut rng = weak_rng();
|
let mut rng = weak_rng();
|
||||||
b.iter(|| { rng.gen::<int>().to_str_radix(36); })
|
b.iter(|| { to_string(rng.gen::<int>(), 36); })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -775,7 +775,7 @@ mod tests {
|
||||||
t!(s: "a/b/c", ["d".to_string(), "e".to_string()], "a/b/c/d/e");
|
t!(s: "a/b/c", ["d".to_string(), "e".to_string()], "a/b/c/d/e");
|
||||||
t!(v: b"a/b/c", [b"d", b"e"], b"a/b/c/d/e");
|
t!(v: b"a/b/c", [b"d", b"e"], b"a/b/c/d/e");
|
||||||
t!(v: b"a/b/c", [b"d", b"/e", b"f"], b"/e/f");
|
t!(v: b"a/b/c", [b"d", b"/e", b"f"], b"/e/f");
|
||||||
t!(v: b"a/b/c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")], b"a/b/c/d/e");
|
t!(v: b"a/b/c", [b"d".to_vec(), b"e".to_vec()], b"a/b/c/d/e");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -879,7 +879,7 @@ mod tests {
|
||||||
t!(s: "a/b/c", ["d", "/e", "f"], "/e/f");
|
t!(s: "a/b/c", ["d", "/e", "f"], "/e/f");
|
||||||
t!(s: "a/b/c", ["d".to_string(), "e".to_string()], "a/b/c/d/e");
|
t!(s: "a/b/c", ["d".to_string(), "e".to_string()], "a/b/c/d/e");
|
||||||
t!(v: b"a/b/c", [b"d", b"e"], b"a/b/c/d/e");
|
t!(v: b"a/b/c", [b"d", b"e"], b"a/b/c/d/e");
|
||||||
t!(v: b"a/b/c", [Vec::from_slice(b"d"), Vec::from_slice(b"e")], b"a/b/c/d/e");
|
t!(v: b"a/b/c", [b"d".to_vec(), b"e".to_vec()], b"a/b/c/d/e");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -76,7 +76,6 @@ mod test {
|
||||||
|
|
||||||
use super::ReaderRng;
|
use super::ReaderRng;
|
||||||
use io::MemReader;
|
use io::MemReader;
|
||||||
use mem;
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -87,25 +86,25 @@ mod test {
|
||||||
0, 0, 0, 0, 0, 0, 0, 3];
|
0, 0, 0, 0, 0, 0, 0, 3];
|
||||||
let mut rng = ReaderRng::new(MemReader::new(v));
|
let mut rng = ReaderRng::new(MemReader::new(v));
|
||||||
|
|
||||||
assert_eq!(rng.next_u64(), mem::to_be64(1));
|
assert_eq!(rng.next_u64(), 1_u64.to_be());
|
||||||
assert_eq!(rng.next_u64(), mem::to_be64(2));
|
assert_eq!(rng.next_u64(), 2_u64.to_be());
|
||||||
assert_eq!(rng.next_u64(), mem::to_be64(3));
|
assert_eq!(rng.next_u64(), 3_u64.to_be());
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_reader_rng_u32() {
|
fn test_reader_rng_u32() {
|
||||||
let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3];
|
let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3];
|
||||||
let mut rng = ReaderRng::new(MemReader::new(v));
|
let mut rng = ReaderRng::new(MemReader::new(v));
|
||||||
|
|
||||||
assert_eq!(rng.next_u32(), mem::to_be32(1));
|
assert_eq!(rng.next_u32(), 1_u32.to_be());
|
||||||
assert_eq!(rng.next_u32(), mem::to_be32(2));
|
assert_eq!(rng.next_u32(), 2_u32.to_be());
|
||||||
assert_eq!(rng.next_u32(), mem::to_be32(3));
|
assert_eq!(rng.next_u32(), 3_u32.to_be());
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_reader_rng_fill_bytes() {
|
fn test_reader_rng_fill_bytes() {
|
||||||
let v = [1u8, 2, 3, 4, 5, 6, 7, 8];
|
let v = [1u8, 2, 3, 4, 5, 6, 7, 8];
|
||||||
let mut w = [0u8, .. 8];
|
let mut w = [0u8, .. 8];
|
||||||
|
|
||||||
let mut rng = ReaderRng::new(MemReader::new(Vec::from_slice(v)));
|
let mut rng = ReaderRng::new(MemReader::new(v.as_slice().to_vec()));
|
||||||
rng.fill_bytes(w);
|
rng.fill_bytes(w);
|
||||||
|
|
||||||
assert!(v == w);
|
assert!(v == w);
|
||||||
|
|
|
@ -447,6 +447,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(deprecated)]
|
||||||
fn test_with_wrapper() {
|
fn test_with_wrapper() {
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
TaskBuilder::new().with_wrapper(proc(body) {
|
TaskBuilder::new().with_wrapper(proc(body) {
|
||||||
|
|
|
@ -59,10 +59,11 @@ impl<S:Send,R:Send> DuplexStream<S, R> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use std::prelude::*;
|
use std::prelude::*;
|
||||||
use comm::{duplex};
|
use comm::duplex;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn duplex_stream_1() {
|
pub fn duplex_stream_1() {
|
||||||
|
|
|
@ -553,14 +553,12 @@ mod tests {
|
||||||
let threads = range(0, NTHREADS).map(|_| {
|
let threads = range(0, NTHREADS).map(|_| {
|
||||||
let s = s.clone();
|
let s = s.clone();
|
||||||
Thread::start(proc() {
|
Thread::start(proc() {
|
||||||
unsafe {
|
loop {
|
||||||
loop {
|
match s.steal() {
|
||||||
match s.steal() {
|
Data(2) => { HITS.fetch_add(1, SeqCst); }
|
||||||
Data(2) => { HITS.fetch_add(1, SeqCst); }
|
Data(..) => fail!(),
|
||||||
Data(..) => fail!(),
|
_ if DONE.load(SeqCst) => break,
|
||||||
_ if DONE.load(SeqCst) => break,
|
_ => {}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -572,7 +570,7 @@ mod tests {
|
||||||
if rng.gen_range(0i, 3) == 2 {
|
if rng.gen_range(0i, 3) == 2 {
|
||||||
match w.pop() {
|
match w.pop() {
|
||||||
None => {}
|
None => {}
|
||||||
Some(2) => unsafe { HITS.fetch_add(1, SeqCst); },
|
Some(2) => { HITS.fetch_add(1, SeqCst); },
|
||||||
Some(_) => fail!(),
|
Some(_) => fail!(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -581,22 +579,20 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
while HITS.load(SeqCst) < AMT as uint {
|
||||||
while HITS.load(SeqCst) < AMT as uint {
|
match w.pop() {
|
||||||
match w.pop() {
|
None => {}
|
||||||
None => {}
|
Some(2) => { HITS.fetch_add(1, SeqCst); },
|
||||||
Some(2) => { HITS.fetch_add(1, SeqCst); },
|
Some(_) => fail!(),
|
||||||
Some(_) => fail!(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DONE.store(true, SeqCst);
|
|
||||||
}
|
}
|
||||||
|
DONE.store(true, SeqCst);
|
||||||
|
|
||||||
for thread in threads.into_iter() {
|
for thread in threads.into_iter() {
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(unsafe { HITS.load(SeqCst) }, expected as uint);
|
assert_eq!(HITS.load(SeqCst), expected as uint);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -655,7 +651,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { DONE.store(true, SeqCst); }
|
DONE.store(true, SeqCst);
|
||||||
|
|
||||||
for thread in threads.into_iter() {
|
for thread in threads.into_iter() {
|
||||||
thread.join();
|
thread.join();
|
||||||
|
|
|
@ -536,32 +536,32 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smoke_static() {
|
fn smoke_static() {
|
||||||
static m: StaticMutex = MUTEX_INIT;
|
static M: StaticMutex = MUTEX_INIT;
|
||||||
unsafe {
|
unsafe {
|
||||||
drop(m.lock());
|
drop(M.lock());
|
||||||
drop(m.lock());
|
drop(M.lock());
|
||||||
m.destroy();
|
M.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lots_and_lots() {
|
fn lots_and_lots() {
|
||||||
static m: StaticMutex = MUTEX_INIT;
|
static M: StaticMutex = MUTEX_INIT;
|
||||||
static mut CNT: uint = 0;
|
static mut CNT: uint = 0;
|
||||||
static M: uint = 1000;
|
static J: uint = 1000;
|
||||||
static N: uint = 3;
|
static K: uint = 3;
|
||||||
|
|
||||||
fn inc() {
|
fn inc() {
|
||||||
for _ in range(0, M) {
|
for _ in range(0, J) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let _g = m.lock();
|
let _g = M.lock();
|
||||||
CNT += 1;
|
CNT += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
for _ in range(0, N) {
|
for _ in range(0, K) {
|
||||||
let tx2 = tx.clone();
|
let tx2 = tx.clone();
|
||||||
native::task::spawn(proc() { inc(); tx2.send(()); });
|
native::task::spawn(proc() { inc(); tx2.send(()); });
|
||||||
let tx2 = tx.clone();
|
let tx2 = tx.clone();
|
||||||
|
@ -569,12 +569,12 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
drop(tx);
|
drop(tx);
|
||||||
for _ in range(0, 2 * N) {
|
for _ in range(0, 2 * K) {
|
||||||
rx.recv();
|
rx.recv();
|
||||||
}
|
}
|
||||||
assert_eq!(unsafe {CNT}, M * N * 2);
|
assert_eq!(unsafe {CNT}, J * K * 2);
|
||||||
unsafe {
|
unsafe {
|
||||||
m.destroy();
|
M.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,17 +126,17 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn smoke_once() {
|
fn smoke_once() {
|
||||||
static o: Once = ONCE_INIT;
|
static O: Once = ONCE_INIT;
|
||||||
let mut a = 0i;
|
let mut a = 0i;
|
||||||
o.doit(|| a += 1);
|
O.doit(|| a += 1);
|
||||||
assert_eq!(a, 1);
|
assert_eq!(a, 1);
|
||||||
o.doit(|| a += 1);
|
O.doit(|| a += 1);
|
||||||
assert_eq!(a, 1);
|
assert_eq!(a, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn stampede_once() {
|
fn stampede_once() {
|
||||||
static o: Once = ONCE_INIT;
|
static O: Once = ONCE_INIT;
|
||||||
static mut run: bool = false;
|
static mut run: bool = false;
|
||||||
|
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
|
@ -145,7 +145,7 @@ mod test {
|
||||||
spawn(proc() {
|
spawn(proc() {
|
||||||
for _ in range(0u, 4) { task::deschedule() }
|
for _ in range(0u, 4) { task::deschedule() }
|
||||||
unsafe {
|
unsafe {
|
||||||
o.doit(|| {
|
O.doit(|| {
|
||||||
assert!(!run);
|
assert!(!run);
|
||||||
run = true;
|
run = true;
|
||||||
});
|
});
|
||||||
|
@ -156,7 +156,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
o.doit(|| {
|
O.doit(|| {
|
||||||
assert!(!run);
|
assert!(!run);
|
||||||
run = true;
|
run = true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1333,6 +1333,7 @@ impl Item_ {
|
||||||
pub fn descriptive_variant(&self) -> &str {
|
pub fn descriptive_variant(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
ItemStatic(..) => "static item",
|
ItemStatic(..) => "static item",
|
||||||
|
ItemConst(..) => "constant item",
|
||||||
ItemFn(..) => "function",
|
ItemFn(..) => "function",
|
||||||
ItemMod(..) => "module",
|
ItemMod(..) => "module",
|
||||||
ItemForeignMod(..) => "foreign module",
|
ItemForeignMod(..) => "foreign module",
|
||||||
|
@ -1340,7 +1341,8 @@ impl Item_ {
|
||||||
ItemEnum(..) => "enum",
|
ItemEnum(..) => "enum",
|
||||||
ItemStruct(..) => "struct",
|
ItemStruct(..) => "struct",
|
||||||
ItemTrait(..) => "trait",
|
ItemTrait(..) => "trait",
|
||||||
_ => "item"
|
ItemMac(..) |
|
||||||
|
ItemImpl(..) => "item"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -575,7 +575,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::{expand,Words,Variables,Number};
|
use super::{expand,Param,Words,Variables,Number};
|
||||||
use std::result::Ok;
|
use std::result::Ok;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -605,40 +605,39 @@ mod test {
|
||||||
fn test_param_stack_failure_conditions() {
|
fn test_param_stack_failure_conditions() {
|
||||||
let mut varstruct = Variables::new();
|
let mut varstruct = Variables::new();
|
||||||
let vars = &mut varstruct;
|
let vars = &mut varstruct;
|
||||||
|
fn get_res(fmt: &str, cap: &str, params: &[Param], vars: &mut Variables) ->
|
||||||
|
Result<Vec<u8>, String>
|
||||||
|
{
|
||||||
|
let mut u8v: Vec<_> = fmt.bytes().collect();
|
||||||
|
u8v.extend(cap.as_bytes().iter().map(|&b| b));
|
||||||
|
expand(u8v.as_slice(), params, vars)
|
||||||
|
}
|
||||||
|
|
||||||
let caps = ["%d", "%c", "%s", "%Pa", "%l", "%!", "%~"];
|
let caps = ["%d", "%c", "%s", "%Pa", "%l", "%!", "%~"];
|
||||||
for cap in caps.iter() {
|
for &cap in caps.iter() {
|
||||||
let res = expand(cap.as_bytes(), [], vars);
|
let res = get_res("", cap, [], vars);
|
||||||
assert!(res.is_err(),
|
assert!(res.is_err(),
|
||||||
"Op {} succeeded incorrectly with 0 stack entries", *cap);
|
"Op {} succeeded incorrectly with 0 stack entries", cap);
|
||||||
let p = if *cap == "%s" || *cap == "%l" {
|
let p = if cap == "%s" || cap == "%l" {
|
||||||
Words("foo".to_string())
|
Words("foo".to_string())
|
||||||
} else {
|
} else {
|
||||||
Number(97)
|
Number(97)
|
||||||
};
|
};
|
||||||
let res = expand("%p1".bytes().collect::<Vec<_>>()
|
let res = get_res("%p1", cap, [p], vars);
|
||||||
.append(cap.as_bytes()).as_slice(),
|
|
||||||
[p],
|
|
||||||
vars);
|
|
||||||
assert!(res.is_ok(),
|
assert!(res.is_ok(),
|
||||||
"Op {} failed with 1 stack entry: {}", *cap, res.unwrap_err());
|
"Op {} failed with 1 stack entry: {}", cap, res.unwrap_err());
|
||||||
}
|
}
|
||||||
let caps = ["%+", "%-", "%*", "%/", "%m", "%&", "%|", "%A", "%O"];
|
let caps = ["%+", "%-", "%*", "%/", "%m", "%&", "%|", "%A", "%O"];
|
||||||
for cap in caps.iter() {
|
for &cap in caps.iter() {
|
||||||
let res = expand(cap.as_bytes(), [], vars);
|
let res = expand(cap.as_bytes(), [], vars);
|
||||||
assert!(res.is_err(),
|
assert!(res.is_err(),
|
||||||
"Binop {} succeeded incorrectly with 0 stack entries", *cap);
|
"Binop {} succeeded incorrectly with 0 stack entries", cap);
|
||||||
let res = expand("%{1}".bytes().collect::<Vec<_>>()
|
let res = get_res("%{1}", cap, [], vars);
|
||||||
.append(cap.as_bytes()).as_slice(),
|
|
||||||
[],
|
|
||||||
vars);
|
|
||||||
assert!(res.is_err(),
|
assert!(res.is_err(),
|
||||||
"Binop {} succeeded incorrectly with 1 stack entry", *cap);
|
"Binop {} succeeded incorrectly with 1 stack entry", cap);
|
||||||
let res = expand("%{1}%{2}".bytes().collect::<Vec<_>>()
|
let res = get_res("%{1}%{2}", cap, [], vars);
|
||||||
.append(cap.as_bytes()).as_slice(),
|
|
||||||
[],
|
|
||||||
vars);
|
|
||||||
assert!(res.is_ok(),
|
assert!(res.is_ok(),
|
||||||
"Binop {} failed with 2 stack entries: {}", *cap, res.unwrap_err());
|
"Binop {} failed with 2 stack entries: {}", cap, res.unwrap_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ pub mod char {
|
||||||
pub use normalize::{decompose_canonical, decompose_compatible, compose};
|
pub use normalize::{decompose_canonical, decompose_compatible, compose};
|
||||||
|
|
||||||
pub use tables::normalization::canonical_combining_class;
|
pub use tables::normalization::canonical_combining_class;
|
||||||
|
pub use tables::UNICODE_VERSION;
|
||||||
|
|
||||||
pub use u_char::{is_alphabetic, is_XID_start, is_XID_continue};
|
pub use u_char::{is_alphabetic, is_XID_start, is_XID_continue};
|
||||||
pub use u_char::{is_lowercase, is_uppercase, is_whitespace};
|
pub use u_char::{is_lowercase, is_uppercase, is_whitespace};
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
|
|
||||||
#![allow(missing_doc, non_uppercase_statics, non_snake_case)]
|
#![allow(missing_doc, non_uppercase_statics, non_snake_case)]
|
||||||
|
|
||||||
|
/// The version of [Unicode](http://www.unicode.org/)
|
||||||
|
/// that the `UnicodeChar` and `UnicodeStrSlice` traits are based on.
|
||||||
|
pub const UNICODE_VERSION: (uint, uint, uint) = (7, 0, 0);
|
||||||
|
|
||||||
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
|
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
|
||||||
use core::cmp::{Equal, Less, Greater};
|
use core::cmp::{Equal, Less, Greater};
|
||||||
use core::slice::ImmutableSlice;
|
use core::slice::ImmutableSlice;
|
||||||
|
|
14
src/test/compile-fail/empty-extern-arg.rs
Normal file
14
src/test/compile-fail/empty-extern-arg.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// compile-flags: --extern std=
|
||||||
|
// error-pattern: is not a file
|
||||||
|
|
||||||
|
fn main() {}
|
17
src/test/compile-fail/issue-17651.rs
Normal file
17
src/test/compile-fail/issue-17651.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// Test that moves of unsized values within closures are caught
|
||||||
|
// and rejected.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
(|| box *[0u].as_slice())();
|
||||||
|
//~^ ERROR cannot move a value of type [uint]
|
||||||
|
}
|
|
@ -12,5 +12,6 @@
|
||||||
|
|
||||||
const foo: int = 3;
|
const foo: int = 3;
|
||||||
//~^ ERROR: should have an uppercase name such as
|
//~^ ERROR: should have an uppercase name such as
|
||||||
|
//~^^ ERROR: constant item is never used
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -35,6 +35,13 @@ pub static used_static2: int = used_static;
|
||||||
const USED_STATIC: int = 0;
|
const USED_STATIC: int = 0;
|
||||||
const STATIC_USED_IN_ENUM_DISCRIMINANT: int = 10;
|
const STATIC_USED_IN_ENUM_DISCRIMINANT: int = 10;
|
||||||
|
|
||||||
|
pub const pub_const: int = 0;
|
||||||
|
const priv_const: int = 0; //~ ERROR: constant item is never used
|
||||||
|
const used_const: int = 0;
|
||||||
|
pub const used_const2: int = used_const;
|
||||||
|
const USED_CONST: int = 1;
|
||||||
|
const CONST_USED_IN_ENUM_DISCRIMINANT: int = 11;
|
||||||
|
|
||||||
pub type typ = *const UsedStruct4;
|
pub type typ = *const UsedStruct4;
|
||||||
pub struct PubStruct;
|
pub struct PubStruct;
|
||||||
struct PrivStruct; //~ ERROR: struct is never used
|
struct PrivStruct; //~ ERROR: struct is never used
|
||||||
|
@ -61,7 +68,10 @@ pub struct PubStruct2 {
|
||||||
|
|
||||||
pub enum pub_enum { foo1, bar1 }
|
pub enum pub_enum { foo1, bar1 }
|
||||||
pub enum pub_enum2 { a(*const StructUsedInEnum) }
|
pub enum pub_enum2 { a(*const StructUsedInEnum) }
|
||||||
pub enum pub_enum3 { Foo = STATIC_USED_IN_ENUM_DISCRIMINANT }
|
pub enum pub_enum3 {
|
||||||
|
Foo = STATIC_USED_IN_ENUM_DISCRIMINANT,
|
||||||
|
Bar = CONST_USED_IN_ENUM_DISCRIMINANT,
|
||||||
|
}
|
||||||
|
|
||||||
enum priv_enum { foo2, bar2 } //~ ERROR: enum is never used
|
enum priv_enum { foo2, bar2 } //~ ERROR: enum is never used
|
||||||
enum used_enum {
|
enum used_enum {
|
||||||
|
@ -82,6 +92,7 @@ pub fn pub_fn() {
|
||||||
let i = 1i;
|
let i = 1i;
|
||||||
match i {
|
match i {
|
||||||
USED_STATIC => (),
|
USED_STATIC => (),
|
||||||
|
USED_CONST => (),
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
f::<StructUsedInGeneric>();
|
f::<StructUsedInGeneric>();
|
||||||
|
|
|
@ -28,6 +28,10 @@ extern {}
|
||||||
#[link(name = "execinfo")]
|
#[link(name = "execinfo")]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
||||||
|
#[cfg(target_os = "freebsd")]
|
||||||
|
#[link(name = "c")]
|
||||||
|
extern {}
|
||||||
|
|
||||||
#[cfg(target_os = "dragonfly")]
|
#[cfg(target_os = "dragonfly")]
|
||||||
#[link(name = "c")]
|
#[link(name = "c")]
|
||||||
extern {}
|
extern {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue