diff options
658 files changed, 7453 insertions, 6579 deletions
diff --git a/.gitignore b/.gitignore index 73edf3bdfce..2fa5de27495 100644 --- a/.gitignore +++ b/.gitignore @@ -75,7 +75,6 @@ src/.DS_Store /nd/ /llvm/ version.md -*.tex keywords.md x86_64-apple-darwin/ x86_64-unknown-linux-gnu/ diff --git a/man/rustc.1 b/man/rustc.1 index 885ec37f374..0f84c26df2b 100644 --- a/man/rustc.1 +++ b/man/rustc.1 @@ -12,17 +12,14 @@ This program is a compiler for the Rust language, available at .SH OPTIONS .TP -\fB\-\-bin\fR -Compile an executable crate (default) -.TP -\fB\-c\fR -Compile and assemble, but do not link +\fB\-\-crate-type=[bin|lib|dylib|rlib|staticlib]\fR +Configure the flavor of rust crate that is generated (default `bin`) .TP \fB\-\-cfg\fR SPEC Configure the compilation environment .TP -\fB\-\-emit\-llvm\fR -Produce an LLVM bitcode file +\fB\-\-emit=[asm,ir,bc,obj,link]\fR +Configure the output that rustc will produce .TP \fB\-h\fR, \fB\-\-help\fR Display this message @@ -30,9 +27,6 @@ Display this message \fB\-L\fR PATH Add a directory to the library search path .TP -\fB\-\-lib\fR -Compile a library crate -.TP \fB\-\-linker\fR LINKER Program to use for linking instead of the default .TP @@ -49,7 +43,7 @@ Run all passes except translation; no output Equivalent to \fI\-\-opt\-level=2\fR .TP \fB\-o\fR FILENAME -Write output to <filename> +Write output to <filename>. Ignored if more than one --emit is specified. .TP \fB\-\-opt\-level\fR LEVEL Optimize with possible levels 0-3 @@ -60,7 +54,8 @@ the default passes for the optimization level. A value of 'list' will list the available passes. .TP \fB\-\-out\-dir\fR DIR -Write output to compiler-chosen filename in <dir> +Write output to compiler-chosen filename in <dir>. Ignored if -o is specified. +(default the current directory) .TP \fB\-\-parse\-only\fR Parse only; do not compile, assemble, or link @@ -71,9 +66,6 @@ Pretty-print the input instead of compiling; valid types are: normal expanded, with type annotations), or identified (fully parenthesized, AST nodes and blocks with IDs) .TP -\fB\-S\fR -Compile only; do not assemble or link -.TP \fB\-\-save\-temps\fR Write intermediate files (.bc, .opt.bc, .o) in addition to normal output .TP @@ -120,7 +112,7 @@ To build an executable from a source file with a main function: $ rustc -o hello hello.rs To build a library from a source file: - $ rustc --lib hello-lib.rs + $ rustc --crate-type=lib hello-lib.rs To build either with a crate (.rs) file: $ rustc hello.rs diff --git a/mk/crates.mk b/mk/crates.mk index ea573b9db8d..05bc38193cd 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -49,29 +49,33 @@ # automatically generated for all stage/host/target combinations. ################################################################################ -TARGET_CRATES := std extra green rustuv native flate arena glob term semver uuid serialize sync +TARGET_CRATES := std extra green rustuv native flate arena glob term semver \ + uuid serialize sync getopts collections HOST_CRATES := syntax rustc rustdoc CRATES := $(TARGET_CRATES) $(HOST_CRATES) TOOLS := compiletest rustdoc rustc DEPS_std := native:rustrt -DEPS_extra := std serialize sync term +DEPS_extra := std term sync serialize getopts collections DEPS_green := std DEPS_rustuv := std native:uv native:uv_support DEPS_native := std -DEPS_syntax := std extra term serialize -DEPS_rustc := syntax native:rustllvm flate arena serialize sync -DEPS_rustdoc := rustc native:sundown serialize sync +DEPS_syntax := std extra term serialize collections +DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \ + collections +DEPS_rustdoc := rustc native:sundown serialize sync getopts collections DEPS_flate := std native:miniz -DEPS_arena := std extra +DEPS_arena := std collections DEPS_glob := std DEPS_serialize := std DEPS_term := std DEPS_semver := std DEPS_uuid := std serialize DEPS_sync := std +DEPS_getopts := std +DEPS_collections := std serialize -TOOL_DEPS_compiletest := extra green rustuv +TOOL_DEPS_compiletest := extra green rustuv getopts TOOL_DEPS_rustdoc := rustdoc green rustuv TOOL_DEPS_rustc := rustc green rustuv TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs @@ -102,7 +106,7 @@ $(foreach crate,$(CRATES),$(eval $(call RUST_CRATE,$(crate)))) # # $(1) is the crate to generate variables for define RUST_TOOL -TOOL_INPUTS_$(1) := $$(wildcard $$(addprefix $(S)$$(dir $$(TOOL_SOURCE_$(1))), \ +TOOL_INPUTS_$(1) := $$(wildcard $$(addprefix $$(dir $$(TOOL_SOURCE_$(1))), \ *.rs */*.rs */*/*.rs */*/*/*.rs)) endef diff --git a/mk/dist.mk b/mk/dist.mk index 656811bab4d..6d4e4401eaf 100644 --- a/mk/dist.mk +++ b/mk/dist.mk @@ -26,19 +26,12 @@ PKG_FILES := \ $(S)man \ $(S)doc \ $(addprefix $(S)src/, \ - README.txt \ - driver \ - librustc \ + README.md \ compiletest \ + driver \ etc \ - libextra \ - libstd \ - libsyntax \ - librustuv \ - libgreen \ - libnative \ + $(foreach crate,$(CRATES),lib$(crate)) \ rt \ - librustdoc \ rustllvm \ snapshots.txt \ test) \ diff --git a/mk/docs.mk b/mk/docs.mk index 2099954dd0d..7861888482e 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -19,8 +19,10 @@ HTML_DEPS := doc/ BASE_DOC_OPTS := --standalone --toc --number-sections HTML_OPTS = $(BASE_DOC_OPTS) --to=html5 --section-divs --css=rust.css \ - --include-before-body=doc/version_info.html --include-in-header=doc/favicon.inc -TEX_OPTS = $(BASE_DOC_OPTS) --include-before-body=doc/version.md --to=latex + --include-before-body=doc/version_info.html \ + --include-in-header=doc/favicon.inc --include-after-body=doc/footer.inc +TEX_OPTS = $(BASE_DOC_OPTS) --include-before-body=doc/version.md \ + --from=markdown --include-before-body=doc/footer.tex --to=latex EPUB_OPTS = $(BASE_DOC_OPTS) --to=epub D := $(S)src/doc @@ -55,12 +57,21 @@ doc/rust.css: $(D)/rust.css | doc/ @$(call E, cp: $@) $(Q)cp -a $< $@ 2> /dev/null +HTML_DEPS += doc/favicon.inc +doc/favicon.inc: $(D)/favicon.inc | doc/ + @$(call E, cp: $@) + $(Q)cp -a $< $@ 2> /dev/null + doc/full-toc.inc: $(D)/full-toc.inc | doc/ @$(call E, cp: $@) $(Q)cp -a $< $@ 2> /dev/null -HTML_DEPS += doc/favicon.inc -doc/favicon.inc: $(D)/favicon.inc | doc/ +HTML_DEPS += doc/footer.inc +doc/footer.inc: $(D)/footer.inc | doc/ + @$(call E, cp: $@) + $(Q)cp -a $< $@ 2> /dev/null + +doc/footer.tex: $(D)/footer.tex | doc/ @$(call E, cp: $@) $(Q)cp -a $< $@ 2> /dev/null @@ -83,7 +94,7 @@ doc/rust.html: $(D)/rust.md doc/full-toc.inc $(HTML_DEPS) | doc/ $(CFG_PANDOC) $(HTML_OPTS) --include-in-header=doc/full-toc.inc --output=$@ DOCS += doc/rust.tex -doc/rust.tex: $(D)/rust.md doc/version.md | doc/ +doc/rust.tex: $(D)/rust.md doc/footer.tex doc/version.md | doc/ @$(call E, pandoc: $@) $(Q)$(CFG_NODE) $(D)/prep.js $< | \ $(CFG_PANDOC) $(TEX_OPTS) --output=$@ @@ -107,7 +118,7 @@ doc/tutorial.html: $(D)/tutorial.md $(HTML_DEPS) $(CFG_PANDOC) $(HTML_OPTS) --output=$@ DOCS += doc/tutorial.tex -doc/tutorial.tex: $(D)/tutorial.md doc/version.md +doc/tutorial.tex: $(D)/tutorial.md doc/footer.tex doc/version.md @$(call E, pandoc: $@) $(Q)$(CFG_NODE) $(D)/prep.js $< | \ $(CFG_PANDOC) $(TEX_OPTS) --output=$@ @@ -199,12 +210,6 @@ doc/guide-tasks.html: $(D)/guide-tasks.md $(HTML_DEPS) $(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \ $(CFG_PANDOC) $(HTML_OPTS) --output=$@ -DOCS += doc/guide-conditions.html -doc/guide-conditions.html: $(D)/guide-conditions.md $(HTML_DEPS) - @$(call E, pandoc: $@) - $(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \ - $(CFG_PANDOC) $(HTML_OPTS) --output=$@ - DOCS += doc/guide-pointers.html doc/guide-pointers.html: $(D)/guide-pointers.md $(HTML_DEPS) @$(call E, pandoc: $@) @@ -275,8 +280,7 @@ endif # The rustdoc executable, rpath included in case --disable-rpath was provided to # ./configure -RUSTDOC = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \ - $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD)) +RUSTDOC = $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD)) # The library documenting macro # @@ -291,7 +295,9 @@ doc/$(1)/index.html: \ $$(foreach dep,$$(RUST_DEPS_$(1)), \ $$(TLIB2_T_$(CFG_BUILD)_H_$(CFG_BUILD))/stamp.$$(dep)) @$$(call E, rustdoc: $$@) - $$(Q)$$(RUSTDOC) --cfg stage2 $$< + $$(Q)$$(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $$(RUSTDOC) \ + --cfg stage2 $$< + endef $(foreach crate,$(CRATES),$(eval $(call libdoc,$(crate)))) diff --git a/mk/tests.mk b/mk/tests.mk index 85c63acb0f1..d2fccbd47cf 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -21,7 +21,7 @@ TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES) # Markdown files under doc/ that should have their code extracted and run DOC_TEST_NAMES = tutorial guide-ffi guide-macros guide-lifetimes \ - guide-tasks guide-conditions guide-container guide-pointers \ + guide-tasks guide-container guide-pointers \ complement-cheatsheet guide-runtime \ rust @@ -116,9 +116,11 @@ endif # Run the compiletest runner itself under valgrind ifdef CTEST_VALGRIND -CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_TEST_$$(CFG_BUILD),$$(2),$$(3)) +CFG_RUN_CTEST_$(1)=$$(RPATH_VAR$$(1)_T_$$(3)_H_$$(3)) \ + $$(call CFG_RUN_TEST_$$(CFG_BUILD),$$(2),$$(3)) else -CFG_RUN_CTEST_$(1)=$$(call CFG_RUN_$$(CFG_BUILD),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2)) +CFG_RUN_CTEST_$(1)=$$(RPATH_VAR$$(1)_T_$$(3)_H_$$(3)) \ + $$(call CFG_RUN_$$(CFG_BUILD),$$(TLIB$$(1)_T_$$(3)_H_$$(3)),$$(2)) endif endef @@ -242,7 +244,6 @@ ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \ tidy: @$(call E, check: formatting) $(Q)find $(S)src -name '*.r[sc]' \ - | grep '^$(S)src/test' -v \ | grep '^$(S)src/libuv' -v \ | grep '^$(S)src/llvm' -v \ | grep '^$(S)src/gyp' -v \ @@ -835,7 +836,7 @@ $$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \ tmp/$$(FT).rc \ $$(SREQ2_T_$(2)_H_$(3)) @$$(call E, compile_and_link: $$@) - $$(STAGE2_T_$(2)_H_$(3)) --lib -o $$@ $$< \ + $$(STAGE2_T_$(2)_H_$(3)) --crate-type=dylib --out-dir $$(@D) $$< \ -L "$$(RT_OUTPUT_DIR_$(2))" $(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \ diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 8896b44f060..b3151ac99b2 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -14,13 +14,13 @@ #[deny(warnings)]; extern mod extra; +extern mod getopts; use std::os; use std::io; use std::io::fs; -use extra::getopts; -use extra::getopts::groups::{optopt, optflag, reqopt}; +use getopts::{optopt, optflag, reqopt}; use extra::test; use common::config; @@ -49,7 +49,7 @@ pub fn main() { pub fn parse_config(args: ~[~str]) -> config { - let groups : ~[getopts::groups::OptGroup] = + let groups : ~[getopts::OptGroup] = ~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"), reqopt("", "run-lib-path", "path to target shared libraries", "PATH"), reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"), @@ -85,20 +85,20 @@ pub fn parse_config(args: ~[~str]) -> config { let args_ = args.tail(); if args[1] == ~"-h" || args[1] == ~"--help" { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); - println!("{}", getopts::groups::usage(message, groups)); + println!("{}", getopts::usage(message, groups)); println!(""); fail!() } let matches = - &match getopts::groups::getopts(args_, groups) { + &match getopts::getopts(args_, groups) { Ok(m) => m, Err(f) => fail!("{}", f.to_err_msg()) }; if matches.opt_present("h") || matches.opt_present("help") { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); - println!("{}", getopts::groups::usage(message, groups)); + println!("{}", getopts::usage(message, groups)); println!(""); fail!() } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 0503790ae94..8edd923390a 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -245,7 +245,7 @@ actual:\n\ }; // FIXME (#9639): This needs to handle non-utf8 paths let mut args = ~[~"-", - ~"--no-trans", ~"--lib", + ~"--no-trans", ~"--crate-type=lib", ~"--target=" + target, ~"-L", config.build_base.as_str().unwrap().to_owned(), ~"-L", @@ -442,9 +442,7 @@ fn check_error_patterns(props: &TestProps, testfile: &Path, ProcRes: &ProcRes) { if props.error_patterns.is_empty() { - testfile.display().with_str(|s| { - fatal(~"no error pattern specified in " + s); - }) + fatal(~"no error pattern specified in " + testfile.display().as_maybe_owned().as_slice()); } if ProcRes.status.success() { @@ -659,7 +657,7 @@ fn compile_test_(config: &config, props: &TestProps, // FIXME (#9639): This needs to handle non-utf8 paths let link_args = ~[~"-L", aux_dir.as_str().unwrap().to_owned()]; let args = make_compile_args(config, props, link_args + extra_args, - make_exe_name, testfile); + |a, b| ThisFile(make_exe_name(a, b)), testfile); compose_and_run_compiler(config, props, testfile, args, None) } @@ -702,8 +700,12 @@ fn compose_and_run_compiler( let abs_ab = config.aux_base.join(rel_ab.as_slice()); let aux_props = load_props(&abs_ab); let aux_args = - make_compile_args(config, &aux_props, ~[~"--dylib"] + extra_link_args, - |a,b| make_lib_name(a, b, testfile), &abs_ab); + make_compile_args(config, &aux_props, ~[~"--crate-type=dylib"] + + extra_link_args, + |a,b| { + let f = make_lib_name(a, b, testfile); + ThisDirectory(f.dir_path()) + }, &abs_ab); let auxres = compose_and_run(config, &abs_ab, aux_args, ~[], config.compile_lib_path, None); if !auxres.status.success() { @@ -741,10 +743,15 @@ fn compose_and_run(config: &config, testfile: &Path, prog, args, procenv, input); } +enum TargetLocation { + ThisFile(Path), + ThisDirectory(Path), +} + fn make_compile_args(config: &config, props: &TestProps, extras: ~[~str], - xform: |&config, &Path| -> Path, + xform: |&config, &Path| -> TargetLocation, testfile: &Path) -> ProcArgs { let xform_file = xform(config, testfile); @@ -755,10 +762,14 @@ fn make_compile_args(config: &config, }; // FIXME (#9639): This needs to handle non-utf8 paths let mut args = ~[testfile.as_str().unwrap().to_owned(), - ~"-o", xform_file.as_str().unwrap().to_owned(), ~"-L", config.build_base.as_str().unwrap().to_owned(), ~"--target=" + target] + extras; + let path = match xform_file { + ThisFile(path) => { args.push(~"-o"); path } + ThisDirectory(path) => { args.push(~"--out-dir"); path } + }; + args.push(path.as_str().unwrap().to_owned()); args.push_all_move(split_maybe_args(&config.rustcflags)); args.push_all_move(split_maybe_args(&props.compile_flags)); return ProcArgs {prog: config.rustc_path.as_str().unwrap().to_owned(), args: args}; @@ -1043,10 +1054,10 @@ fn compile_test_and_save_bitcode(config: &config, props: &TestProps, let aux_dir = aux_output_dir_name(config, testfile); // FIXME (#9639): This needs to handle non-utf8 paths let link_args = ~[~"-L", aux_dir.as_str().unwrap().to_owned()]; - let llvm_args = ~[~"-c", ~"--lib", ~"--save-temps"]; + let llvm_args = ~[~"--emit=obj", ~"--crate-type=lib", ~"--save-temps"]; let args = make_compile_args(config, props, link_args + llvm_args, - make_o_name, testfile); + |a, b| ThisFile(make_o_name(a, b)), testfile); compose_and_run_compiler(config, props, testfile, args, None) } diff --git a/src/doc/footer.inc b/src/doc/footer.inc new file mode 100644 index 00000000000..a103a4908f6 --- /dev/null +++ b/src/doc/footer.inc @@ -0,0 +1,7 @@ +<footer><p> +Copyright © 2011-2014 The Rust Project Developers. Licensed under the +<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> +or the <a href="http://opensource.org/licenses/MIT">MIT license</a>, at your option. +</p><p> +This file may not be copied, modified, or distributed except according to those terms. +</p></footer> diff --git a/src/doc/footer.tex b/src/doc/footer.tex new file mode 100644 index 00000000000..9f9ceb6ba9a --- /dev/null +++ b/src/doc/footer.tex @@ -0,0 +1,7 @@ +Copyright © 2011-2014 The Rust Project Developers. Licensed under the +\href{http://www.apache.org/licenses/LICENSE-2.0}{Apache License, +Version 2.0} or the \href{http://opensource.org/licenses/MIT}{MIT +license}, at your option. + +This file may not be copied, modified, or distributed except according +to those terms. diff --git a/src/doc/guide-conditions.md b/src/doc/guide-conditions.md deleted file mode 100644 index 5b7494c0618..00000000000 --- a/src/doc/guide-conditions.md +++ /dev/null @@ -1,837 +0,0 @@ -% The Rust Condition and Error-handling Guide - -# Introduction - -Rust does not provide exception handling[^why-no-exceptions] -in the form most commonly seen in other programming languages such as C++ or Java. -Instead, it provides four mechanisms that work together to handle errors or other rare events. -The four mechanisms are: - - - Options - - Results - - Failure - - Conditions - -This guide will lead you through use of these mechanisms -in order to understand the trade-offs of each and relationships between them. - -# Example program - -This guide will be based around an example program -that attempts to read lines from a file -consisting of pairs of numbers, -and then print them back out with slightly different formatting. -The input to the program might look like this: - -~~~~ {.notrust} -$ cat numbers.txt -1 2 -34 56 -789 123 -45 67 -~~~~ - -For which the intended output looks like this: - -~~~~ {.notrust} -$ ./example numbers.txt -0001, 0002 -0034, 0056 -0789, 0123 -0045, 0067 -~~~~ - -An example program that does this task reads like this: - -~~~~ -# #[allow(unused_imports)]; -use std::io::{BufferedReader, File}; -# mod BufferedReader { -# use std::io::{File, IoResult}; -# use std::io::MemReader; -# use std::io::BufferedReader; -# static s : &'static [u8] = bytes!("1 2\n\ -# 34 56\n\ -# 789 123\n\ -# 45 67\n\ -# "); -# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> { -# BufferedReader::new(MemReader::new(s.to_owned())) -# } -# } - -fn main() { - let pairs = read_int_pairs(); - for &(a,b) in pairs.iter() { - println!("{:4.4d}, {:4.4d}", a, b); - } -} - -fn read_int_pairs() -> ~[(int,int)] { - let mut pairs = ~[]; - - // Path takes a generic by-value, rather than by reference - let path = Path::new(&"foo.txt"); - let mut reader = BufferedReader::new(File::open(&path)); - - // 1. Iterate over the lines of our file. - for line in reader.lines() { - // 2. Split the line into fields ("words"). - let fields = line.words().to_owned_vec(); - // 3. Match the vector of fields against a vector pattern. - match fields { - - // 4. When the line had two fields: - [a, b] => { - // 5. Try parsing both fields as ints. - match (from_str::<int>(a), from_str::<int>(b)) { - - // 6. If parsing succeeded for both, push both. - (Some(a), Some(b)) => pairs.push((a,b)), - // 7. Ignore non-int fields. - _ => () - } - } - // 8. Ignore lines that don't have 2 fields. - _ => () - } - } - pairs -} -~~~~ - -This example shows the use of `Option`, -along with some other forms of error-handling (and non-handling). -We will look at these mechanisms -and then modify parts of the example to perform "better" error handling. - -# Options - -The simplest and most lightweight mechanism in Rust for indicating an error is the type `std::option::Option<T>`. -This type is a general purpose `enum` -for conveying a value of type `T`, represented as `Some(T)` -_or_ the sentinel `None`, to indicate the absence of a `T` value. -For simple APIs, it may be sufficient to encode errors as `Option<T>`, -returning `Some(T)` on success and `None` on error. -In the example program, the call to `from_str::<int>` returns `Option<int>` -with the understanding that "all parse errors" result in `None`. -The resulting `Option<int>` values are matched against the pattern `(Some(a), Some(b))` -in steps 5 and 6 in the example program, -to handle the case in which both fields were parsed successfully. - -Using `Option` as in this API has some advantages: - - - Simple API, users can read it and guess how it works. - - Very efficient, only an extra `enum` tag on return values. - - Caller has flexibility in handling or propagating errors. - - Caller is forced to acknowledge existence of possible-error before using value. - -However, it has serious disadvantages too: - - - Verbose, requires matching results or calling `Option::unwrap` everywhere. - - Infects caller: if caller doesn't know how to handle the error, must propagate (or force). - - Temptation to do just that: force the `Some(T)` case by blindly calling `unwrap`, - which hides the error from the API without providing any way to make the program robust against the error. - - Collapses all errors into one: - - Caller can't handle different errors differently. - - Caller can't even report a very precise error message - -Note that in order to keep the example code reasonably compact, -several unwanted cases are silently ignored: -lines that do not contain two fields, as well as fields that do not parse as ints. -To propagate these cases to the caller using `Option` would require even more verbose code. - -# Results - -Before getting into _trapping_ the error, -we will look at a slight refinement on the `Option` type above. -This second mechanism for indicating an error is called a `Result`. -The type `std::result::Result<T,E>` is another simple `enum` type with two forms, `Ok(T)` and `Err(E)`. -The `Result` type is not substantially different from the `Option` type in terms of its ergonomics. -Its main advantage is that the error constructor `Err(E)` can convey _more detail_ about the error. -For example, the `from_str` API could be reformed -to return a `Result` carrying an informative description of a parse error, -like this: - -~~~~ {.ignore} -enum IntParseErr { - EmptyInput, - Overflow, - BadChar(char) -} - -fn from_str(&str) -> Result<int,IntParseErr> { - // ... -} -~~~~ - -This would give the caller more information for both handling and reporting the error, -but would otherwise retain the verbosity problems of using `Option`. -In particular, it would still be necessary for the caller to return a further `Result` to _its_ caller if it did not want to handle the error. -Manually propagating result values this way can be attractive in certain circumstances -— for example when processing must halt on the very first error, or backtrack — -but as we will see later, many cases have simpler options available. - -# Failure - -The third and arguably easiest mechanism for handling errors is called "failure". -In fact it was hinted at earlier by suggesting that one can choose to propagate `Option` or `Result` types _or "force" them_. -"Forcing" them, in this case, means calling a method like `Option<T>::unwrap`, -which contains the following code: - -~~~~ {.ignore} -pub fn unwrap(self) -> T { - match self { - Some(x) => return x, - None => fail!("option::unwrap `None`") - } -} -~~~~ - -That is, it returns `T` when `self` is `Some(T)`, and _fails_ when `self` is `None`. - -Every Rust task can _fail_, either indirectly due to a kill signal or other asynchronous event, -or directly by failing an `assert!` or calling the `fail!` macro. -Failure is an _unrecoverable event_ at the task level: -it causes the task to halt normal execution and unwind its control stack, -freeing all task-local resources (the local heap as well as any task-owned values from the global heap) -and running destructors (the `drop` method of the `Drop` trait) -as frames are unwound and heap values destroyed. -A failing task is not permitted to "catch" the unwinding during failure and recover, -it is only allowed to clean up and exit. - -Failure has advantages: - - - Simple and non-verbose. Suitable for programs that can't reasonably continue past an error anyways. - - _All_ errors (except memory-safety errors) can be uniformly trapped in a supervisory task outside the failing task. - For a large program to be robust against a variety of errors, - often some form of task-level partitioning to contain pervasive errors (arithmetic overflow, division by zero, - logic bugs) is necessary anyways. - -As well as obvious disadvantages: - - - A blunt instrument, terminates the containing task entirely. - -Recall that in the first two approaches to error handling, -the example program was only handling success cases, and ignoring error cases. -That is, if the input is changed to contain a malformed line: - -~~~~ {.notrust} -$ cat bad.txt -1 2 -34 56 -ostrich -789 123 -45 67 -~~~~ - -Then the program would give the same output as if there was no error: - -~~~~ {.notrust} -$ ./example bad.txt -0001, 0002 -0034, 0056 -0789, 0123 -0045, 0067 -~~~~ - -If the example is rewritten to use failure, these error cases can be trapped. -In this rewriting, failures are trapped by placing the I/O logic in a sub-task, -and trapping its exit status using `task::try`: - -~~~~ -# #[allow(unused_imports)]; -use std::io::{BufferedReader, File}; -use std::task; -# mod BufferedReader { -# use std::io::{File, IoResult}; -# use std::io::MemReader; -# use std::io::BufferedReader; -# static s : &'static [u8] = bytes!("1 2\n\ -# 34 56\n\ -# 789 123\n\ -# 45 67\n\ -# "); -# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> { -# BufferedReader::new(MemReader::new(s.to_owned())) -# } -# } - -fn main() { - - // Isolate failure within a subtask. - let result = task::try(proc() { - - // The protected logic. - let pairs = read_int_pairs(); - for &(a,b) in pairs.iter() { - println!("{:4.4d}, {:4.4d}", a, b); - } - - }); - if result.is_err() { - println!("parsing failed"); - } -} - -fn read_int_pairs() -> ~[(int,int)] { - let mut pairs = ~[]; - let path = Path::new(&"foo.txt"); - - let mut reader = BufferedReader::new(File::open(&path)); - for line in reader.lines() { - match line.words().to_owned_vec() { - [a, b] => pairs.push((from_str::<int>(a).unwrap(), - from_str::<int>(b).unwrap())), - - // Explicitly fail on malformed lines. - _ => fail!() - } - } - pairs -} -~~~~ - -With these changes in place, running the program on malformed input gives a different answer: - -~~~~ {.notrust} -$ ./example bad.txt -rust: task failed at 'explicit failure', ./example.rs:44 -parsing failed -~~~~ - -Note that while failure unwinds the sub-task performing I/O in `read_int_pairs`, -control returns to `main` and can easily continue uninterrupted. -In this case, control simply prints out `parsing failed` and then exits `main` (successfully). -Failure of a (sub-)task is analogous to calling `exit(1)` or `abort()` in a unix C program: -all the state of a sub-task is cleanly discarded on exit, -and a supervisor task can take appropriate action -without worrying about its own state having been corrupted. - -# Conditions - -The final mechanism for handling errors is called a "condition". -Conditions are less blunt than failure, and less cumbersome than the `Option` or `Result` types; -indeed they are designed to strike just the right balance between the two. -Conditions require some care to use effectively, but give maximum flexibility with minimum verbosity. -While conditions use exception-like terminology ("trap", "raise") they are significantly different: - - - Like exceptions and failure, conditions separate the site at which the error is raised from the site where it is trapped. - - Unlike exceptions and unlike failure, when a condition is raised and trapped, _no unwinding occurs_. - - A successfully trapped condition causes execution to continue _at the site of the error_, as though no error occurred. - -Conditions are declared with the `condition!` macro. -Each condition has a name, an input type and an output type, much like a function. -In fact, conditions are implemented as dynamically-scoped functions held in task local storage. - -The `condition!` macro declares a module with the name of the condition; -the module contains a single static value called `cond`, of type `std::condition::Condition`. -The `cond` value within the module is the rendezvous point -between the site of error and the site that handles the error. -It has two methods of interest: `raise` and `trap`. - -The `raise` method maps a value of the condition's input type to its output type. -The input type should therefore convey all relevant information to the condition handler. -The output type should convey all relevant information _for continuing execution at the site of error_. -When the error site raises a condition handler, -the `Condition::raise` method searches for the innermost installed task-local condition _handler_, -and if any such handler is found, calls it with the provided input value. -If no handler is found, `Condition::raise` will fail the task with an appropriate error message. - -Rewriting the example to use a condition in place of ignoring malformed lines makes it slightly longer, -but similarly clear as the version that used `fail!` in the logic where the error occurs: - -~~~~ -# #[allow(unused_imports)]; -use std::io::{BufferedReader, File}; -# mod BufferedReader { -# use std::io::{File, IoResult}; -# use std::io::MemReader; -# use std::io::BufferedReader; -# static s : &'static [u8] = bytes!("1 2\n\ -# 34 56\n\ -# 789 123\n\ -# 45 67\n\ -# "); -# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> { -# BufferedReader::new(MemReader::new(s.to_owned())) -# } -# } - -// Introduce a new condition. -condition! { - pub malformed_line : ~str -> (int,int); -} - -fn main() { - let pairs = read_int_pairs(); - for &(a,b) in pairs.iter() { - println!("{:4.4d}, {:4.4d}", a, b); - } -} - -fn read_int_pairs() -> ~[(int,int)] { - let mut pairs = ~[]; - let path = Path::new(&"foo.txt"); - - let mut reader = BufferedReader::new(File::open(&path)); - for line in reader.lines() { - match line.words().to_owned_vec() { - [a, b] => pairs.push((from_str::<int>(a).unwrap(), - from_str::<int>(b).unwrap())), - // On malformed lines, call the condition handler and - // push whatever the condition handler returns. - _ => pairs.push(malformed_line::cond.raise(line.clone())) - } - } - pairs -} -~~~~ - -When this is run on malformed input, it still fails, -but with a slightly different failure message than before: - -~~~~ {.notrust} -$ ./example bad.txt -rust: task failed at 'Unhandled condition: malformed_line: ~"ostrich"', .../libstd/condition.rs:43 -~~~~ - -While this superficially resembles the trapped `fail!` call before, -it is only because the example did not install a handler for the condition. -The different failure message is indicating, among other things, -that the condition-handling system is being invoked and failing -only due to the absence of a _handler_ that traps the condition. - -# Trapping a condition - -To trap a condition, use `Condition::trap` in some caller of the site that calls `Condition::raise`. -For example, this version of the program traps the `malformed_line` condition -and replaces bad input lines with the pair `(-1,-1)`: - -~~~~ -# #[allow(unused_imports)]; -use std::io::{BufferedReader, File}; -# mod BufferedReader { -# use std::io::{File, IoResult}; -# use std::io::MemReader; -# use std::io::BufferedReader; -# static s : &'static [u8] = bytes!("1 2\n\ -# 34 56\n\ -# 789 123\n\ -# 45 67\n\ -# "); -# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> { -# BufferedReader::new(MemReader::new(s.to_owned())) -# } -# } - -condition! { - pub malformed_line : ~str -> (int,int); -} - -fn main() { - // Trap the condition: - malformed_line::cond.trap(|_| (-1,-1)).inside(|| { - - // The protected logic. - let pairs = read_int_pairs(); - for &(a,b) in pairs.iter() { - println!("{:4.4d}, {:4.4d}", a, b); - } - - }) -} - -fn read_int_pairs() -> ~[(int,int)] { - let mut pairs = ~[]; - let path = Path::new(&"foo.txt"); - - let mut reader = BufferedReader::new(File::open(&path)); - for line in reader.lines() { - match line.words().to_owned_vec() { - [a, b] => pairs.push((from_str::<int>(a).unwrap(), - from_str::<int>(b).unwrap())), - _ => pairs.push(malformed_line::cond.raise(line.clone())) - } - } - pairs -} -~~~~ - -Note that the remainder of the program is _unchanged_ with this trap in place; -only the caller that installs the trap changed. -Yet when the condition-trapping variant runs on the malformed input, -it continues execution past the malformed line, substituting the handler's return value. - -~~~~ {.notrust} -$ ./example bad.txt -0001, 0002 -0034, 0056 --0001, -0001 -0789, 0123 -0045, 0067 -~~~~ - -# Refining a condition - -As you work with a condition, you may find that the original set of options you present for recovery is insufficient. -This is no different than any other issue of API design: -a condition handler is an API for recovering from the condition, and sometimes APIs need to be enriched. -In the example program, the first form of the `malformed_line` API implicitly assumes that recovery involves a substitute value. -This assumption may not be correct; some callers may wish to skip malformed lines, for example. -Changing the condition's return type from `(int,int)` to `Option<(int,int)>` will suffice to support this type of recovery: - -~~~~ -# #[allow(unused_imports)]; -use std::io::{BufferedReader, File}; -# mod BufferedReader { -# use std::io::{IoResult, File}; -# use std::io::MemReader; -# use std::io::BufferedReader; -# static s : &'static [u8] = bytes!("1 2\n\ -# 34 56\n\ -# 789 123\n\ -# 45 67\n\ -# "); -# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> { -# BufferedReader::new(MemReader::new(s.to_owned())) -# } -# } - -// Modify the condition signature to return an Option. -condition! { - pub malformed_line : ~str -> Option<(int,int)>; -} - -fn main() { - // Trap the condition and return `None` - malformed_line::cond.trap(|_| None).inside(|| { - - // The protected logic. - let pairs = read_int_pairs(); - for &(a,b) in pairs.iter() { - println!("{:4.4d}, {:4.4d}", a, b); - } - - }) -} - -fn read_int_pairs() -> ~[(int,int)] { - let mut pairs = ~[]; - let path = Path::new(&"foo.txt"); - - let mut reader = BufferedReader::new(File::open(&path)); - for line in reader.lines() { - match line.words().to_owned_vec() { - [a, b] => pairs.push((from_str::<int>(a).unwrap(), - from_str::<int>(b).unwrap())), - - // On malformed lines, call the condition handler and - // either ignore the line (if the handler returns `None`) - // or push any `Some(pair)` value returned instead. - _ => { - match malformed_line::cond.raise(line.clone()) { - Some(pair) => pairs.push(pair), - None => () - } - } - } - } - pairs -} -~~~~ - -Again, note that the remainder of the program is _unchanged_, -in particular the signature of `read_int_pairs` is unchanged, -even though the innermost part of its reading-loop has a new way of handling a malformed line. -When the example is run with the `None` trap in place, -the line is ignored as it was in the first example, -but the choice of whether to ignore or use a substitute value has been moved to some caller, -possibly a distant caller. - -~~~~ {.notrust} -$ ./example bad.txt -0001, 0002 -0034, 0056 -0789, 0123 -0045, 0067 -~~~~ - -# Further refining a condition - -Like with any API, the process of refining argument and return types of a condition will continue, -until all relevant combinations encountered in practice are encoded. -In the example, suppose a third possible recovery form arose: reusing the previous value read. -This can be encoded in the handler API by introducing a helper type: `enum MalformedLineFix`. - -~~~~ -# #[allow(unused_imports)]; -use std::io::{BufferedReader, File}; -# mod BufferedReader { -# use std::io::{File, IoResult}; -# use std::io::MemReader; -# use std::io::BufferedReader; -# static s : &'static [u8] = bytes!("1 2\n\ -# 34 56\n\ -# 789 123\n\ -# 45 67\n\ -# "); -# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> { -# BufferedReader::new(MemReader::new(s.to_owned())) -# } -# } - -// Introduce a new enum to convey condition-handling strategy to error site. -pub enum MalformedLineFix { - UsePair(int,int), - IgnoreLine, - UsePreviousLine -} - -// Modify the condition signature to return the new enum. -// Note: a condition introduces a new module, so the enum must be -// named with the `super::` prefix to access it. -condition! { - pub malformed_line : ~str -> super::MalformedLineFix; -} - -fn main() { - // Trap the condition and return `UsePreviousLine` - malformed_line::cond.trap(|_| UsePreviousLine).inside(|| { - - // The protected logic. - let pairs = read_int_pairs(); - for &(a,b) in pairs.iter() { - println!("{:4.4d}, {:4.4d}", a, b); - } - - }) -} - -fn read_int_pairs() -> ~[(int,int)] { - let mut pairs = ~[]; - let path = Path::new(&"foo.txt"); - - let mut reader = BufferedReader::new(File::open(&path)); - for line in reader.lines() { - match line.words().to_owned_vec() { - [a, b] => pairs.push((from_str::<int>(a).unwrap(), - from_str::<int>(b).unwrap())), - - // On malformed lines, call the condition handler and - // take action appropriate to the enum value returned. - _ => { - match malformed_line::cond.raise(line.clone()) { - UsePair(a,b) => pairs.push((a,b)), - IgnoreLine => (), - UsePreviousLine => { - let prev = pairs[pairs.len() - 1]; - pairs.push(prev) - } - } - } - } - } - pairs -} -~~~~ - -Running the example with `UsePreviousLine` as the fix code returned from the handler -gives the expected result: - -~~~~ {.notrust} -$ ./example bad.txt -0001, 0002 -0034, 0056 -0034, 0056 -0789, 0123 -0045, 0067 -~~~~ - -At this point the example has a rich variety of recovery options, -none of which is visible to casual users of the `read_int_pairs` function. -This is intentional: part of the purpose of using a condition -is to free intermediate callers from the burden of having to write repetitive error-propagation logic, -and/or having to change function call and return types as error-handling strategies are refined. - -# Multiple conditions, intermediate callers - -So far the function trapping the condition and the function raising it have been immediately adjacent in the call stack. -That is, the caller traps and its immediate callee raises. -In most programs, the function that traps may be separated by very many function calls from the function that raises. -Again, this is part of the point of using conditions: -to support that separation without having to thread multiple error values and recovery strategies all the way through the program's main logic. - -Careful readers will notice that there is a remaining failure mode in the example program: the call to `.unwrap()` when parsing each integer. -For example, when presented with a file that has the correct number of fields on a line, -but a non-numeric value in one of them, such as this: - -~~~~ {.notrust} -$ cat bad.txt -1 2 -34 56 -7 marmot -789 123 -45 67 -~~~~ - - -Then the program fails once more: - -~~~~ {.notrust} -$ ./example bad.txt -task <unnamed> failed at 'called `Option::unwrap()` on a `None` value', .../libstd/option.rs:314 -~~~~ - -To make the program robust — or at least flexible — in the face of this potential failure, -a second condition and a helper function will suffice: - -~~~~ -# #[allow(unused_imports)]; -use std::io::{BufferedReader, File}; -# mod BufferedReader { -# use std::io::{File, IoResult}; -# use std::io::MemReader; -# use std::io::BufferedReader; -# static s : &'static [u8] = bytes!("1 2\n\ -# 34 56\n\ -# 789 123\n\ -# 45 67\n\ -# "); -# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> { -# BufferedReader::new(MemReader::new(s.to_owned())) -# } -# } - -pub enum MalformedLineFix { - UsePair(int,int), - IgnoreLine, - UsePreviousLine -} - -condition! { - pub malformed_line : ~str -> ::MalformedLineFix; -} - -// Introduce a second condition. -condition! { - pub malformed_int : ~str -> int; -} - -fn main() { - // Trap the `malformed_int` condition and return -1 - malformed_int::cond.trap(|_| -1).inside(|| { - - // Trap the `malformed_line` condition and return `UsePreviousLine` - malformed_line::cond.trap(|_| UsePreviousLine).inside(|| { - - // The protected logic. - let pairs = read_int_pairs(); - for &(a,b) in pairs.iter() { - println!("{:4.4d}, {:4.4d}", a, b); - } - - }) - }) -} - -// Parse an int; if parsing fails, call the condition handler and -// return whatever it returns. -fn parse_int(x: &str) -> int { - match from_str::<int>(x) { - Some(v) => v, - None => malformed_int::cond.raise(x.to_owned()) - } -} - -fn read_int_pairs() -> ~[(int,int)] { - let mut pairs = ~[]; - let path = Path::new(&"foo.txt"); - - let mut reader = BufferedReader::new(File::open(&path)); - for line in reader.lines() { - match line.words().to_owned_vec() { - // Delegate parsing ints to helper function that will - // handle parse errors by calling `malformed_int`. - [a, b] => pairs.push((parse_int(a), parse_int(b))), - - _ => { - match malformed_line::cond.raise(line.clone()) { - UsePair(a,b) => pairs.push((a,b)), - IgnoreLine => (), - UsePreviousLine => { - let prev = pairs[pairs.len() - 1]; - pairs.push(prev) - } - } - } - } - } - pairs -} -~~~~ - -Again, note that `read_int_pairs` has not changed signature, -nor has any of the machinery for trapping or raising `malformed_line`, -but now the program can handle the "right number of fields, non-integral field" form of bad input: - -~~~~ {.notrust} -$ ./example bad.txt -0001, 0002 -0034, 0056 -0007, -0001 -0789, 0123 -0045, 0067 -~~~~ - -There are three other things to note in this variant of the example program: - - - It traps multiple conditions simultaneously, - nesting the protected logic of one `trap` call inside the other. - - - There is a function in between the `trap` site and `raise` site for the `malformed_int` condition. - There could be any number of calls between them: - so long as the `raise` occurs within a callee (of any depth) of the logic protected by the `trap` call, - it will invoke the handler. - - - This variant insulates callers from a design choice in the library: - the `from_str` function was designed to return an `Option<int>`, - but this program insulates callers from that choice, - routing all `None` values that arise from parsing integers in this file into the condition. - - -# When to use which technique - -This guide explored several techniques for handling errors. -Each is appropriate to different circumstances: - - - If an error may be extremely frequent, expected, and very likely dealt with by an immediate caller, - then returning an `Option` or `Result` type is best. These types force the caller to handle the error, - and incur the lowest speed overhead, usually only returning one extra word to tag the return value. - Between `Option` and `Result`: use an `Option` when there is only one kind of error, - otherwise make an `enum FooErr` to represent the possible error codes and use `Result<T,FooErr>`. - - - If an error can reasonably be handled at the site it occurs by one of a few strategies — possibly including failure — - and it is not clear which strategy a caller would want to use, a condition is best. - For many errors, the only reasonable "non-stop" recovery strategies are to retry some number of times, - create or substitute an empty or sentinel value, ignore the error, or fail. - - - If an error cannot reasonably be handled at the site it occurs, - and the only reasonable response is to abandon a large set of operations in progress, - then directly failing is best. - -Note that an unhandled condition will cause failure (along with a more-informative-than-usual message), -so if there is any possibility that a caller might wish to "ignore and keep going", -it is usually harmless to use a condition in place of a direct call to `fail!()`. - - -[^why-no-exceptions]: Exceptions in languages like C++ and Java permit unwinding, like Rust's failure system, -but with the option to halt unwinding partway through the process and continue execution. -This behavior unfortunately means that the _heap_ may be left in an inconsistent but accessible state, -if an exception is thrown part way through the process of initializing or modifying memory. -To compensate for this risk, correct C++ and Java code must program in an extremely elaborate and difficult "exception-safe" style -— effectively transactional style against heap structures — -or else risk introducing silent and very difficult-to-debug errors due to control resuming in a corrupted heap after a caught exception. -These errors are frequently memory-safety errors, which Rust strives to eliminate, -and so Rust unwinding is unrecoverable within a single task: -once unwinding starts, the entire local heap of a task is destroyed and the task is terminated. diff --git a/src/doc/guide-ffi.md b/src/doc/guide-ffi.md index c892c06902a..e19e9978e17 100644 --- a/src/doc/guide-ffi.md +++ b/src/doc/guide-ffi.md @@ -520,7 +520,7 @@ conventions. Rust provides a way to tell the compiler which convention to use: ~~~~ #[cfg(target_os = "win32", target_arch = "x86")] -#[link_name = "kernel32"] +#[link(name = "kernel32")] extern "stdcall" { fn SetEnvironmentVariableA(n: *u8, v: *u8) -> std::libc::c_int; } diff --git a/src/doc/guide-runtime.md b/src/doc/guide-runtime.md index b6a54b042e9..40319c1ec4f 100644 --- a/src/doc/guide-runtime.md +++ b/src/doc/guide-runtime.md @@ -236,9 +236,7 @@ extern mod green; #[start] fn start(argc: int, argv: **u8) -> int { - green::start(argc, argv, proc() { - main(); - }) + green::start(argc, argv, main) } fn main() {} diff --git a/src/doc/index.md b/src/doc/index.md index 1d99a461161..6ed2f3a6a1f 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -38,7 +38,9 @@ li {list-style-type: none; } * [The Rust compiler, `librustc`](rustc/index.html) * [The `arena` allocation library](arena/index.html) +* [The `collections` library](collections/index.html) * [The `flate` compression library](flate/index.html) +* [The `getopts` argument parsing library](getopts/index.html) * [The `glob` file path matching library](glob/index.html) * [The `semver` version collation library](semver/index.html) * [The `serialize` value encoding/decoding library](serialize/index.html) @@ -49,7 +51,6 @@ li {list-style-type: none; } # Tooling * [The `rustdoc` manual](rustdoc.html) -* [The `rustpkg` manual](rustpkg.html) # FAQs diff --git a/src/doc/rust.css b/src/doc/rust.css index 194a401395f..976c62beb03 100644 --- a/src/doc/rust.css +++ b/src/doc/rust.css @@ -15,7 +15,6 @@ body { margin: 0 auto; padding: 0 15px; - margin-bottom: 4em; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; color: #333; @@ -76,6 +75,15 @@ p { margin: 0 0 10px; } +footer { + border-top: 1px solid #ddd; + font-size: 12px; + font-style: italic; + padding-top: 4px; + margin-top: 4em; + margin-bottom: 1em; +} + /* Links layout ========================================================================== */ a { diff --git a/src/doc/rust.md b/src/doc/rust.md index c95bfee4ace..bae8f562af5 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -881,7 +881,7 @@ use foo::baz::foobaz; // good: foo is at the root of the crate mod foo { extern mod extra; - use foo::extra::list; // good: foo is at crate root + use foo::extra::time; // good: foo is at crate root // use extra::*; // bad: extra is not at the crate root use self::baz::foobaz; // good: self refers to module 'foo' use foo::bar::foobar; // good: foo is at crate root @@ -1335,7 +1335,7 @@ to pointers to the trait name, used as a type. # impl Shape for int { } # let mycircle = 0; -let myshape: @Shape = @mycircle as @Shape; +let myshape: ~Shape = ~mycircle as ~Shape; ~~~~ The resulting value is a managed box containing the value that was cast, @@ -1396,7 +1396,7 @@ Likewise, supertrait methods may also be called on trait objects. # impl Circle for int { fn radius(&self) -> f64 { 0.0 } } # let mycircle = 0; -let mycircle: Circle = @mycircle as @Circle; +let mycircle: Circle = ~mycircle as ~Circle; let nonsense = mycircle.radius() * mycircle.area(); ~~~~ @@ -1969,13 +1969,14 @@ impl<T: Eq> Eq for Foo<T> { Supported traits for `deriving` are: * Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`. -* Serialization: `Encodable`, `Decodable`. These require `extra`. +* Serialization: `Encodable`, `Decodable`. These require `serialize`. * `Clone` and `DeepClone`, to perform (deep) copies. * `IterBytes`, to iterate over the bytes in a data type. * `Rand`, to create a random instance of a data type. * `Default`, to create an empty instance of a data type. * `Zero`, to create an zero instance of a numeric data type. -* `FromPrimitive`, to create an instance from a numeric primitve. +* `FromPrimitive`, to create an instance from a numeric primitive. +* `Show`, to format a value using the `{}` formatter. ### Stability One can indicate the stability of an API using the following attributes: @@ -3290,8 +3291,8 @@ Whereas most calls to trait methods are "early bound" (statically resolved) to s a call to a method on an object type is only resolved to a vtable entry at compile time. The actual implementation for each vtable entry can vary on an object-by-object basis. -Given a pointer-typed expression `E` of type `&T`, `~T` or `@T`, where `T` implements trait `R`, -casting `E` to the corresponding pointer type `&R`, `~R` or `@R` results in a value of the _object type_ `R`. +Given a pointer-typed expression `E` of type `&T` or `~T`, where `T` implements trait `R`, +casting `E` to the corresponding pointer type `&R` or `~R` results in a value of the _object type_ `R`. This result is represented as a pair of pointers: the vtable pointer for the `T` implementation of `R`, and the pointer value of `E`. @@ -3306,12 +3307,12 @@ impl Printable for int { fn to_string(&self) -> ~str { self.to_str() } } -fn print(a: @Printable) { +fn print(a: ~Printable) { println!("{}", a.to_string()); } fn main() { - print(@10 as @Printable); + print(~10 as ~Printable); } ~~~~ @@ -3678,43 +3679,43 @@ found in the [ffi tutorial][ffi]. In one session of compilation, the compiler can generate multiple artifacts through the usage of command line flags and the `crate_type` attribute. -* `--bin`, `#[crate_type = "bin"]` - A runnable executable will be produced. - This requires that there is a `main` function in the crate which will be run - when the program begins executing. This will link in all Rust and native - dependencies, producing a distributable binary. - -* `--lib`, `#[crate_type = "lib"]` - A Rust library will be produced. This is - an ambiguous concept as to what exactly is produced because a library can - manifest itself in several forms. The purpose of this generic `lib` option is - to generate the "compiler recommended" style of library. The output library - will always be usable by rustc, but the actual type of library may change - from time-to-time. The remaining output types are all different flavors of - libraries, and the `lib` type can be seen as an alias for one of them (but - the actual one is compiler-defined). - -* `--dylib`, `#[crate_type = "dylib"]` - A dynamic Rust library will be - produced. This is different from the `lib` output type in that this forces +* `--crate-type=bin`, `#[crate_type = "bin"]` - A runnable executable will be + produced. This requires that there is a `main` function in the crate which + will be run when the program begins executing. This will link in all Rust and + native dependencies, producing a distributable binary. + +* `--crate-type=lib`, `#[crate_type = "lib"]` - A Rust library will be produced. + This is an ambiguous concept as to what exactly is produced because a library + can manifest itself in several forms. The purpose of this generic `lib` option + is to generate the "compiler recommended" style of library. The output library + will always be usable by rustc, but the actual type of library may change from + time-to-time. The remaining output types are all different flavors of + libraries, and the `lib` type can be seen as an alias for one of them (but the + actual one is compiler-defined). + +* `--crate-type=dylib`, `#[crate_type = "dylib"]` - A dynamic Rust library will + be produced. This is different from the `lib` output type in that this forces dynamic library generation. The resulting dynamic library can be used as a dependency for other libraries and/or executables. This output type will create `*.so` files on linux, `*.dylib` files on osx, and `*.dll` files on windows. -* `--staticlib`, `#[crate_type = "staticlib"]` - A static system library will - be produced. This is different from other library outputs in that the Rust - compiler will never attempt to link to `staticlib` outputs. The purpose of - this output type is to create a static library containing all of the local - crate's code along with all upstream dependencies. The static library is - actually a `*.a` archive on linux and osx and a `*.lib` file on windows. This - format is recommended for use in situtations such as linking Rust code into an - existing non-Rust application because it will not have dynamic dependencies on - other Rust code. - -* `--rlib`, `#[crate_type = "rlib"]` - A "Rust library" file will be produced. - This is used as an intermediate artifact and can be thought of as a "static - Rust library". These `rlib` files, unlike `staticlib` files, are interpreted - by the Rust compiler in future linkage. This essentially means that `rustc` - will look for metadata in `rlib` files like it looks for metadata in dynamic - libraries. This form of output is used to produce statically linked +* `--crate-type=staticlib`, `#[crate_type = "staticlib"]` - A static system + library will be produced. This is different from other library outputs in that + the Rust compiler will never attempt to link to `staticlib` outputs. The + purpose of this output type is to create a static library containing all of + the local crate's code along with all upstream dependencies. The static + library is actually a `*.a` archive on linux and osx and a `*.lib` file on + windows. This format is recommended for use in situtations such as linking + Rust code into an existing non-Rust application because it will not have + dynamic dependencies on other Rust code. + +* `--crate-type=rlib`, `#[crate_type = "rlib"]` - A "Rust library" file will be + produced. This is used as an intermediate artifact and can be thought of as a + "static Rust library". These `rlib` files, unlike `staticlib` files, are + interpreted by the Rust compiler in future linkage. This essentially means + that `rustc` will look for metadata in `rlib` files like it looks for metadata + in dynamic libraries. This form of output is used to produce statically linked executables as well as `staticlib` outputs. Note that these outputs are stackable in the sense that if multiple are @@ -3769,9 +3770,9 @@ dependencies will be used: then the compiler will force all dependencies to be dynamic and will generate errors if dynamic versions could not be found. -In general, `--bin` or `--lib` should be sufficient for all compilation needs, -and the other options are just available if more fine-grained control is desired -over the output format of a Rust crate. +In general, `--crate-type=bin` or `--crate-type=lib` should be sufficient for +all compilation needs, and the other options are just available if more +fine-grained control is desired over the output format of a Rust crate. ### Logging system @@ -3906,4 +3907,4 @@ Additional specific influences can be seen from the following languages: * The lexical identifier rule of Python. * The block syntax of Ruby. -[ffi]: tutorial-ffi.html +[ffi]: guide-ffi.html diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 75a5840a1ef..a5426c20619 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -1857,7 +1857,7 @@ like any other function, except for the name `self`. The type of `self` is the type on which the method is implemented, or a pointer thereof. As an argument it is written either `self`, -`&self`, `@self`, or `~self`. +`&self`, or `~self`. A caller must in turn have a compatible pointer type to call the method. ~~~ @@ -1870,14 +1870,12 @@ A caller must in turn have a compatible pointer type to call the method. # } impl Shape { fn draw_reference(&self) { ... } - fn draw_managed(@self) { ... } fn draw_owned(~self) { ... } fn draw_value(self) { ... } } let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0); -(@s).draw_managed(); (~s).draw_owned(); (&s).draw_reference(); s.draw_value(); @@ -1897,7 +1895,6 @@ to a reference. # } # impl Shape { # fn draw_reference(&self) { ... } -# fn draw_managed(@self) { ... } # fn draw_owned(~self) { ... } # fn draw_value(self) { ... } # } @@ -2368,29 +2365,29 @@ an _object_. ~~~~ # trait Drawable { fn draw(&self); } -fn draw_all(shapes: &[@Drawable]) { +fn draw_all(shapes: &[~Drawable]) { for shape in shapes.iter() { shape.draw(); } } ~~~~ -In this example, there is no type parameter. Instead, the `@Drawable` -type denotes any managed box value that implements the `Drawable` -trait. To construct such a value, you use the `as` operator to cast a -value to an object: +In this example, there is no type parameter. Instead, the `~Drawable` +type denotes any owned box value that implements the `Drawable` trait. +To construct such a value, you use the `as` operator to cast a value +to an object: ~~~~ # type Circle = int; type Rectangle = bool; # trait Drawable { fn draw(&self); } # fn new_circle() -> Circle { 1 } # fn new_rectangle() -> Rectangle { true } -# fn draw_all(shapes: &[@Drawable]) {} +# fn draw_all(shapes: &[~Drawable]) {} impl Drawable for Circle { fn draw(&self) { ... } } impl Drawable for Rectangle { fn draw(&self) { ... } } -let c: @Circle = @new_circle(); -let r: @Rectangle = @new_rectangle(); -draw_all([c as @Drawable, r as @Drawable]); +let c: ~Circle = ~new_circle(); +let r: ~Rectangle = ~new_rectangle(); +draw_all([c as ~Drawable, r as ~Drawable]); ~~~~ We omit the code for `new_circle` and `new_rectangle`; imagine that @@ -2407,8 +2404,6 @@ for example, an `@Circle` may not be cast to an `~Drawable`. # impl Drawable for int { fn draw(&self) {} } # fn new_circle() -> int { 1 } # fn new_rectangle() -> int { 2 } -// A managed object -let boxy: @Drawable = @new_circle() as @Drawable; // An owned object let owny: ~Drawable = ~new_circle() as ~Drawable; // A borrowed object @@ -2427,7 +2422,6 @@ particular set of built-in kinds that their contents must fulfill in order to be packaged up in a trait object of that storage class. * The contents of owned traits (`~Trait`) must fulfill the `Send` bound. -* The contents of managed traits (`@Trait`) must fulfill the `'static` bound. * The contents of reference traits (`&Trait`) are not constrained by any bound. Consequently, the trait objects themselves automatically fulfill their @@ -2439,7 +2433,6 @@ to fulfilling `Send`, contents must also fulfill `Freeze`, and as a consequence, the trait itself fulfills `Freeze`. * `~Trait:Send` is equivalent to `~Trait`. -* `@Trait:'static` is equivalent to `@Trait`. * `&Trait:` is equivalent to `&Trait`. Builtin kind bounds can also be specified on closure types in the same way (for @@ -2530,7 +2523,7 @@ enum ABC { A, B, C } The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, `Encodable` `Decodable`, `Clone`, `DeepClone`, -`IterBytes`, `Rand`, `Default`, `Zero`, and `ToStr`. +`IterBytes`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`. # Crates and the module system @@ -3162,8 +3155,8 @@ fn main() { println!("hello {}", world::explore()); } Now compile and run like this (adjust to your platform if necessary): ~~~~ {.notrust} -> rustc --lib world.rs # compiles libworld-<HASH>-0.42.so -> rustc main.rs -L . # compiles main +> rustc --crate-type=lib world.rs # compiles libworld-<HASH>-0.42.so +> rustc main.rs -L . # compiles main > ./main "hello world" ~~~~ diff --git a/src/etc/check-summary.py b/src/etc/check-summary.py index dbff82d2b6b..c86e926003f 100755 --- a/src/etc/check-summary.py +++ b/src/etc/check-summary.py @@ -1,5 +1,12 @@ -#!/usr/bin/env python -# xfail-license +# Copyright 2012-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. import glob import sys diff --git a/src/etc/combine-tests.py b/src/etc/combine-tests.py index 457c0b683ac..f1ac3e89846 100755 --- a/src/etc/combine-tests.py +++ b/src/etc/combine-tests.py @@ -1,7 +1,14 @@ -#!/usr/bin/env python -# xfail-license +# Copyright 2011-2013 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. -# this combines all the working run-pass tests into a single large crate so we +# This combines all the working run-pass tests into a single large crate so we # can run it "fast": spawning zillions of windows processes is our major build # bottleneck (and it doesn't hurt to run faster on other platforms as well). diff --git a/src/etc/copy-runtime-deps.py b/src/etc/copy-runtime-deps.py index 4f4949e3c88..8aab3f18bda 100644 --- a/src/etc/copy-runtime-deps.py +++ b/src/etc/copy-runtime-deps.py @@ -1,7 +1,14 @@ -#!/usr/bin/env python -# xfail-license +# Copyright 2013-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. -# Copies Rust runtime dependencies to the specified directory +# Copies Rust runtime dependencies to the specified directory. import snapshot, sys, os, shutil diff --git a/src/etc/extract-tests.py b/src/etc/extract-tests.py index bbc57b7eb73..06cdf66a918 100644 --- a/src/etc/extract-tests.py +++ b/src/etc/extract-tests.py @@ -1,5 +1,13 @@ -# xfail-license -# -*- coding: utf-8 -*- +# Copyright 2012-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. + """ Script for extracting compilable fragments from markdown documentation. See prep.js for a description of the format recognized by this tool. Expects diff --git a/src/etc/extract_grammar.py b/src/etc/extract_grammar.py index 61aabf1d881..4e0fbe94498 100755 --- a/src/etc/extract_grammar.py +++ b/src/etc/extract_grammar.py @@ -1,5 +1,12 @@ -#!/usr/bin/env python -# xfail-license +# Copyright 2012-2013 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. # This script is for extracting the grammar from the rust docs. diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py index f00168a52c6..7acaa761bb2 100755 --- a/src/etc/generate-deriving-span-tests.py +++ b/src/etc/generate-deriving-span-tests.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# xfail-license +# # Copyright 2013 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. @@ -118,7 +118,8 @@ traits = { for (trait, supers, errs) in [('Rand', [], 1), ('Clone', [], 1), ('DeepClone', ['Clone'], 1), ('Eq', [], 2), ('Ord', [], 8), - ('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1)]: + ('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1), + ('Show', [], 1)]: traits[trait] = (ALL, supers, errs) for (trait, (types, super_traits, error_count)) in traits.items(): diff --git a/src/etc/generate-keyword-tests.py b/src/etc/generate-keyword-tests.py index 5b827552e83..de148f3cfab 100755 --- a/src/etc/generate-keyword-tests.py +++ b/src/etc/generate-keyword-tests.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# xfail-license +# # Copyright 2013 The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. diff --git a/src/etc/get-snapshot.py b/src/etc/get-snapshot.py index fb14deabf24..fd97affd9ad 100755 --- a/src/etc/get-snapshot.py +++ b/src/etc/get-snapshot.py @@ -1,5 +1,12 @@ -#!/usr/bin/env python -# xfail-license +# Copyright 2011-2013 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. import os, tarfile, re, shutil, sys from snapshot import * diff --git a/src/etc/latest-unix-snaps.py b/src/etc/latest-unix-snaps.py index 7cecf837161..32e9691f815 100755 --- a/src/etc/latest-unix-snaps.py +++ b/src/etc/latest-unix-snaps.py @@ -1,5 +1,14 @@ #!/usr/bin/env python -# xfail-license +# +# Copyright 2012-2013 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. import os, tarfile, hashlib, re, shutil, sys from snapshot import * diff --git a/src/etc/make-snapshot.py b/src/etc/make-snapshot.py index a60d26673d8..fec78fc1aaf 100755 --- a/src/etc/make-snapshot.py +++ b/src/etc/make-snapshot.py @@ -1,5 +1,12 @@ -#!/usr/bin/env python -# xfail-license +# Copyright 2011-2013 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. import snapshot, sys diff --git a/src/etc/maketest.py b/src/etc/maketest.py index 91de7fba758..fb886f30bd6 100644 --- a/src/etc/maketest.py +++ b/src/etc/maketest.py @@ -1,4 +1,12 @@ -# xfail-license +# Copyright 2013-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. import subprocess import os diff --git a/src/etc/mirror-all-snapshots.py b/src/etc/mirror-all-snapshots.py index 3b5f66c4117..3934c235e8c 100644 --- a/src/etc/mirror-all-snapshots.py +++ b/src/etc/mirror-all-snapshots.py @@ -1,5 +1,14 @@ #!/usr/bin/env python -# xfail-license +# +# Copyright 2011-2013 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. import os, tarfile, hashlib, re, shutil from snapshot import * diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py index 2abe3230c2c..0fdeb23d2e3 100644 --- a/src/etc/mklldeps.py +++ b/src/etc/mklldeps.py @@ -1,4 +1,12 @@ -# xfail-license +# Copyright 2013-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. import os import sys diff --git a/src/etc/snapshot.py b/src/etc/snapshot.py index 8aeee7e22eb..ba193db1eda 100644 --- a/src/etc/snapshot.py +++ b/src/etc/snapshot.py @@ -1,23 +1,31 @@ -# xfail-license +# Copyright 2011-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. import re, os, sys, glob, tarfile, shutil, subprocess, tempfile, distutils.spawn try: - import hashlib - sha_func = hashlib.sha1 + import hashlib + sha_func = hashlib.sha1 except ImportError: - import sha - sha_func = sha.new + import sha + sha_func = sha.new def scrub(b): - if sys.version_info >= (3,) and type(b) == bytes: - return b.decode('ascii') - else: - return b + if sys.version_info >= (3,) and type(b) == bytes: + return b.decode('ascii') + else: + return b src_dir = scrub(os.getenv("CFG_SRC_DIR")) if not src_dir: - raise Exception("missing env var CFG_SRC_DIR") + raise Exception("missing env var CFG_SRC_DIR") snapshotfile = os.path.join(src_dir, "src", "snapshots.txt") download_url_base = "http://static.rust-lang.org/stage0-snapshots" @@ -31,37 +39,36 @@ snapshot_files = { "freebsd": ["bin/rustc"], } -winnt_runtime_deps = ["libgcc_s_dw2-1.dll", - "libstdc++-6.dll"] +winnt_runtime_deps = ["libgcc_s_dw2-1.dll", "libstdc++-6.dll"] def parse_line(n, line): - global snapshotfile + global snapshotfile - if re.match(r"\s*$", line): return None + if re.match(r"\s*$", line): return None - if re.match(r"^T\s*$", line): return None + if re.match(r"^T\s*$", line): return None - match = re.match(r"\s+([\w_-]+) ([a-fA-F\d]{40})\s*$", line) - if match: - return { "type": "file", - "platform": match.group(1), - "hash": match.group(2).lower() } + match = re.match(r"\s+([\w_-]+) ([a-fA-F\d]{40})\s*$", line) + if match: + return { "type": "file", + "platform": match.group(1), + "hash": match.group(2).lower() } - match = re.match(r"([ST]) (\d{4}-\d{2}-\d{2}) ([a-fA-F\d]+)\s*$", line); - if (not match): - raise Exception("%s:%d:E syntax error: " % (snapshotfile, n)) - return {"type": "snapshot", - "date": match.group(2), - "rev": match.group(3)} + match = re.match(r"([ST]) (\d{4}-\d{2}-\d{2}) ([a-fA-F\d]+)\s*$", line); + if not match: + raise Exception("%s:%d:E syntax error: " % (snapshotfile, n)) + return { "type": "snapshot", + "date": match.group(2), + "rev": match.group(3) } def partial_snapshot_name(date, rev, platform): - return ("rust-stage0-%s-%s-%s.tar.bz2" - % (date, rev, platform)) + return ("rust-stage0-%s-%s-%s.tar.bz2" + % (date, rev, platform)) def full_snapshot_name(date, rev, platform, hsh): - return ("rust-stage0-%s-%s-%s-%s.tar.bz2" - % (date, rev, platform, hsh)) + return ("rust-stage0-%s-%s-%s-%s.tar.bz2" + % (date, rev, platform, hsh)) def get_kernel(triple): @@ -78,23 +85,22 @@ def get_kernel(triple): def get_cpu(triple): arch = triple.split('-')[0] if arch == "i686": - return "i386" + return "i386" return arch def get_platform(triple): - return "%s-%s" % (get_kernel(triple), get_cpu(triple)) + return "%s-%s" % (get_kernel(triple), get_cpu(triple)) def cmd_out(cmdline): - p = subprocess.Popen(cmdline, - stdout=subprocess.PIPE) + p = subprocess.Popen(cmdline, stdout=subprocess.PIPE) return scrub(p.communicate()[0].strip()) def local_rev_info(field): return cmd_out(["git", "--git-dir=" + os.path.join(src_dir, ".git"), - "log", "-n", "1", - "--format=%%%s" % field, "HEAD"]) + "log", "-n", "1", + "--format=%%%s" % field, "HEAD"]) def local_rev_full_sha(): @@ -127,10 +133,10 @@ def get_url_to_file(u,f): os.rename(tmpf, f) def snap_filename_hash_part(snap): - match = re.match(r".*([a-fA-F\d]{40}).tar.bz2$", snap) - if not match: - raise Exception("unable to find hash in filename: " + snap) - return match.group(1) + match = re.match(r".*([a-fA-F\d]{40}).tar.bz2$", snap) + if not match: + raise Exception("unable to find hash in filename: " + snap) + return match.group(1) def hash_file(x): h = sha_func() @@ -142,13 +148,13 @@ def get_winnt_runtime_deps(): runtime_deps = [] path_dirs = os.environ["PATH"].split(';') for name in winnt_runtime_deps: - for dir in path_dirs: - matches = glob.glob(os.path.join(dir, name)) - if matches: - runtime_deps.append(matches[0]) - break - else: - raise Exception("Could not find runtime dependency: %s" % name) + for dir in path_dirs: + matches = glob.glob(os.path.join(dir, name)) + if matches: + runtime_deps.append(matches[0]) + break + else: + raise Exception("Could not find runtime dependency: %s" % name) return runtime_deps def make_snapshot(stage, triple): @@ -160,31 +166,31 @@ def make_snapshot(stage, triple): file0 = partial_snapshot_name(date, rev, platform) def in_tar_name(fn): - cs = re.split(r"[\\/]", fn) - if len(cs) >= 2: - return os.sep.join(cs[-2:]) + cs = re.split(r"[\\/]", fn) + if len(cs) >= 2: + return os.sep.join(cs[-2:]) tar = tarfile.open(file0, "w:bz2") for name in snapshot_files[kernel]: - dir = stage - if stage == "stage1" and re.match(r"^lib/(lib)?std.*", name): - dir = "stage0" - fn_glob = os.path.join(triple, dir, name) - matches = glob.glob(fn_glob) - if not matches: - raise Exception("Not found file with name like " + fn_glob) - if len(matches) == 1: - tar.add(matches[0], "rust-stage0/" + in_tar_name(matches[0])) - else: - raise Exception("Found stale files: \n %s\n" - "Please make a clean build." % "\n ".join(matches)) + dir = stage + if stage == "stage1" and re.match(r"^lib/(lib)?std.*", name): + dir = "stage0" + fn_glob = os.path.join(triple, dir, name) + matches = glob.glob(fn_glob) + if not matches: + raise Exception("Not found file with name like " + fn_glob) + if len(matches) == 1: + tar.add(matches[0], "rust-stage0/" + in_tar_name(matches[0])) + else: + raise Exception("Found stale files: \n %s\n" + "Please make a clean build." % "\n ".join(matches)) if kernel=="winnt": - for path in get_winnt_runtime_deps(): - tar.add(path, "rust-stage0/bin/" + os.path.basename(path)) - tar.add(os.path.join(os.path.dirname(__file__), "third-party"), - "rust-stage0/bin/third-party") + for path in get_winnt_runtime_deps(): + tar.add(path, "rust-stage0/bin/" + os.path.basename(path)) + tar.add(os.path.join(os.path.dirname(__file__), "third-party"), + "rust-stage0/bin/third-party") tar.close() @@ -195,40 +201,60 @@ def make_snapshot(stage, triple): return file1 -def determine_curr_snapshot_info(triple): - i = 0 - platform = get_platform(triple) - - found_file = False - found_snap = False - hsh = None - date = None - rev = None - - f = open(snapshotfile) - for line in f.readlines(): - i += 1 - parsed = parse_line(i, line) - if (not parsed): continue - - if found_snap and parsed["type"] == "file": - if parsed["platform"] == platform: - hsh = parsed["hash"] - found_file = True - break; - elif parsed["type"] == "snapshot": - date = parsed["date"] - rev = parsed["rev"] - found_snap = True - - if not found_snap: - raise Exception("no snapshot entries in file") - - if not found_file: - raise Exception("no snapshot file found for platform %s, rev %s" % - (platform, rev)) - - return (date, rev, platform, hsh) +def curr_snapshot_rev(): + i = 0 + found_snap = False + date = None + rev = None + + f = open(snapshotfile) + for line in f.readlines(): + i += 1 + parsed = parse_line(i, line) + if (not parsed): continue + + if parsed["type"] == "snapshot": + date = parsed["date"] + rev = parsed["rev"] + found_snap = True + break + + if not found_snap: + raise Exception("no snapshot entries in file") + + return (date, rev) def determine_curr_snapshot(triple): - return full_snapshot_name(*determine_curr_snapshot_info(triple)) + i = 0 + platform = get_platform(triple) + + found_file = False + found_snap = False + hsh = None + date = None + rev = None + + f = open(snapshotfile) + for line in f.readlines(): + i += 1 + parsed = parse_line(i, line) + if (not parsed): continue + + if found_snap and parsed["type"] == "file": + if parsed["platform"] == platform: + hsh = parsed["hash"] + found_file = True + break; + elif parsed["type"] == "snapshot": + date = parsed["date"] + rev = parsed["rev"] + found_snap = True + + if not found_snap: + raise Exception("no snapshot entries in file") + + if not found_file: + raise Exception("no snapshot file found for platform %s, rev %s" % + (platform, rev)) + + return full_snapshot_name(date, rev, platform, hsh) diff --git a/src/etc/sugarise-doc-comments.py b/src/etc/sugarise-doc-comments.py index 7bd4175fbf0..7d4ad749fe3 100755 --- a/src/etc/sugarise-doc-comments.py +++ b/src/etc/sugarise-doc-comments.py @@ -1,5 +1,14 @@ #!/usr/bin/env python -# xfail-license +# +# Copyright 2012-2013 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. # # this script attempts to turn doc comment attributes (#[doc = "..."]) diff --git a/src/etc/tidy.py b/src/etc/tidy.py index 8157ffba3ef..9bab9a3d998 100644 --- a/src/etc/tidy.py +++ b/src/etc/tidy.py @@ -1,5 +1,12 @@ -#!/usr/bin/env python -# xfail-license +# Copyright 2010-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. import sys, fileinput, subprocess, re from licenseck import * @@ -7,6 +14,9 @@ import snapshot err=0 cols=100 +cr_flag="xfail-tidy-cr" +tab_flag="xfail-tidy-tab" +linelength_flag="xfail-tidy-linelength" # Be careful to support Python 2.4, 2.6, and 3.x here! config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ], @@ -39,12 +49,22 @@ file_names = [s for s in sys.argv[1:] if (not s.endswith("_gen.rs")) current_name = "" current_contents = "" +check_tab = True +check_cr = True +check_linelength = True + try: for line in fileinput.input(file_names, openhook=fileinput.hook_encoded("utf-8")): if fileinput.filename().find("tidy.py") == -1: + if line.find(cr_flag) != -1: + check_cr = False + if line.find(tab_flag) != -1: + check_tab = False + if line.find(linelength_flag) != -1: + check_linelength = False if line.find("// XXX") != -1: report_err("XXX is no longer necessary, use FIXME") if line.find("TODO") != -1: @@ -57,23 +77,24 @@ try: match = re.match(r'^.*//\s*SNAP\s+(\w+)', line) if match: hsh = match.group(1) - a, b, c, phash = snapshot.determine_curr_snapshot_info() - if not phash.startswith(hsh): - report_err("Snapshot out of date: " + line) + date, rev = snapshot.curr_snapshot_rev() + if not hsh.startswith(rev): + report_err("snapshot out of date (" + date + + "): " + line) else: if "SNAP" in line: - report_warn("Unmatched SNAP line: " + line) + report_warn("unmatched SNAP line: " + line) - if (line.find('\t') != -1 and + if check_tab and (line.find('\t') != -1 and fileinput.filename().find("Makefile") == -1): report_err("tab character") - if not autocrlf and line.find('\r') != -1: + if check_cr and not autocrlf and line.find('\r') != -1: report_err("CR character") if line.endswith(" \n") or line.endswith("\t\n"): report_err("trailing whitespace") line_len = len(line)-2 if autocrlf else len(line)-1 - if line_len > cols: + if check_linelength and line_len > cols: report_err("line longer than %d chars" % cols) if fileinput.isfirstline() and current_name != "": @@ -82,6 +103,9 @@ try: if fileinput.isfirstline(): current_name = fileinput.filename() current_contents = "" + check_cr = True + check_tab = True + check_linelength = True current_contents += line diff --git a/src/etc/unicode.py b/src/etc/unicode.py index d35263c100f..71c5c8f8a95 100755 --- a/src/etc/unicode.py +++ b/src/etc/unicode.py @@ -1,5 +1,14 @@ #!/usr/bin/env python -# xfail-license +# +# Copyright 2011-2013 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. # This digests UnicodeData.txt and DerivedCoreProperties.txt and emits rust # code covering the core properties. Since this is a pretty rare event we diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 0d248354b73..9aa76cad83e 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -87,8 +87,7 @@ syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive syn keyword rustTrait GenericPath Path PosixPath WindowsPath syn keyword rustTrait RawPtr syn keyword rustTrait Buffer Writer Reader Seek -syn keyword rustTrait SendStr SendStrOwned SendStrStatic IntoSendStr -syn keyword rustTrait Str StrVector StrSlice OwnedStr +syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned syn keyword rustTrait IterBytes syn keyword rustTrait ToStr IntoStr syn keyword rustTrait CloneableTuple ImmutableTuple diff --git a/src/etc/ziggurat_tables.py b/src/etc/ziggurat_tables.py index 263c76a88dd..d1980cec2ed 100755 --- a/src/etc/ziggurat_tables.py +++ b/src/etc/ziggurat_tables.py @@ -1,5 +1,14 @@ #!/usr/bin/env python -# xfail-license +# +# Copyright 2013 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. # This creates the tables used for distributions implemented using the # ziggurat algorithm in `std::rand::distributions;`. They are diff --git a/src/etc/zsh/_rust b/src/etc/zsh/_rust index 03a8712283c..f1f9e88f7c9 100644 --- a/src/etc/zsh/_rust +++ b/src/etc/zsh/_rust @@ -7,18 +7,15 @@ typeset -A opt_args _rustc_opts_switches=( --android-cross-path'[The path to the Android NDK]' --ar'[Program to use for managing archives instead of the default.]' - --bin'[Compile an executable crate (default)]' -c'[Compile and assemble, but do not link]' --cfg'[Configure the compilation environment]' --crate-id'[Output the crate id and exit]' --crate-file-name'[Output the file(s) that would be written if compilation continued and exit]' --crate-name'[Output the crate name and exit]' --dep-info'[Output dependency info to <filename> after compiling]' - --dylib'[Compile a dynamic library crate]' - --emit-llvm'[Produce an LLVM bitcode file]' + --crate-type'[Specify the type of crate to crate]' {-h,--help}'[Display this message]' -L'[Add a directory to the library search path]' - --lib'[Compile a library crate]' --linker'[Program to use for linking instead of the default.]' --link-args'[FLAGS is a space-separated list of flags passed to the linker]' --llvm-args'[A list of arguments to pass to llvm, comma separated]' @@ -33,10 +30,7 @@ _rustc_opts_switches=( --parse-only'[Parse only; do not compile, assemble, or link]' --passes'[Comma or space separated list of pass names to use]' --pretty'[Pretty-print the input instead of compiling]' - --rlib'[Compile a rust library crate as an rlib file]' - -S'[Compile only; do not assemble or link]' --save-temps'[Write intermediate files (.bc, .opt.bc, .o) in addition to normal output]' - --staticlib'[Compile a static library crate]' --sysroot'[Override the system root]' --test'[Build a test harness]' --target'[Target triple cpu-manufacturer-kernel\[-os\] to compile]' diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 9bd4c1d58fc..3e3ecdda3b0 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -22,10 +22,12 @@ #[allow(missing_doc)]; #[feature(managed_boxes)]; -extern mod extra; +extern mod collections; -use extra::list::{List, Cons, Nil}; -use extra::list; +#[cfg(test)] extern mod extra; + +use collections::list::{List, Cons, Nil}; +use collections::list; use std::cast::{transmute, transmute_mut, transmute_mut_region}; use std::cast; @@ -212,8 +214,7 @@ impl Arena { #[inline] fn alloc_pod<'a, T>(&'a mut self, op: || -> T) -> &'a T { unsafe { - let tydesc = get_tydesc::<T>(); - let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align); + let ptr = self.alloc_pod_inner(mem::size_of::<T>(), mem::min_align_of::<T>()); let ptr: *mut T = transmute(ptr); intrinsics::move_val_init(&mut (*ptr), op()); return transmute(ptr); @@ -270,7 +271,7 @@ impl Arena { unsafe { let tydesc = get_tydesc::<T>(); let (ty_ptr, ptr) = - self.alloc_nonpod_inner((*tydesc).size, (*tydesc).align); + self.alloc_nonpod_inner(mem::size_of::<T>(), mem::min_align_of::<T>()); let ty_ptr: *mut uint = transmute(ty_ptr); let ptr: *mut T = transmute(ptr); // Write in our tydesc along with a bit indicating that it @@ -535,18 +536,18 @@ mod test { x: 1, y: 2, z: 3, - }); + }) }) } #[bench] pub fn bench_pod_nonarena(bh: &mut BenchHarness) { bh.iter(|| { - let _ = ~Point { + ~Point { x: 1, y: 2, z: 3, - }; + } }) } @@ -560,7 +561,7 @@ mod test { y: 2, z: 3, } - }); + }) }) } @@ -587,17 +588,17 @@ mod test { arena.alloc(Nonpod { string: ~"hello world", array: ~[ 1, 2, 3, 4, 5 ], - }); + }) }) } #[bench] pub fn bench_nonpod_nonarena(bh: &mut BenchHarness) { bh.iter(|| { - let _ = ~Nonpod { + ~Nonpod { string: ~"hello world", array: ~[ 1, 2, 3, 4, 5 ], - }; + } }) } @@ -605,10 +606,10 @@ mod test { pub fn bench_nonpod_old_arena(bh: &mut BenchHarness) { let arena = Arena::new(); bh.iter(|| { - let _ = arena.alloc(|| Nonpod { + arena.alloc(|| Nonpod { string: ~"hello world", array: ~[ 1, 2, 3, 4, 5 ], - }); + }) }) } } diff --git a/src/libextra/bitv.rs b/src/libcollections/bitv.rs index 7211907f483..7211907f483 100644 --- a/src/libextra/bitv.rs +++ b/src/libcollections/bitv.rs diff --git a/src/libextra/btree.rs b/src/libcollections/btree.rs index 791673d75bb..791673d75bb 100644 --- a/src/libextra/btree.rs +++ b/src/libcollections/btree.rs diff --git a/src/libextra/container.rs b/src/libcollections/deque.rs index 0ba00510ed8..325f0ee4edb 100644 --- a/src/libextra/container.rs +++ b/src/libcollections/deque.rs @@ -44,7 +44,7 @@ pub mod bench { use std::container::MutableMap; use std::{vec, rand}; use std::rand::Rng; - use test::BenchHarness; + use extra::test::BenchHarness; pub fn insert_rand_n<M:MutableMap<uint,uint>>(n: uint, map: &mut M, diff --git a/src/libextra/dlist.rs b/src/libcollections/dlist.rs index 88df73845d0..2b7c5d37336 100644 --- a/src/libextra/dlist.rs +++ b/src/libcollections/dlist.rs @@ -28,7 +28,7 @@ use std::util; use std::iter::Rev; use std::iter; -use container::Deque; +use deque::Deque; use serialize::{Encodable, Decodable, Encoder, Decoder}; @@ -657,7 +657,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> { #[cfg(test)] mod tests { - use container::Deque; + use deque::Deque; use extra::test; use std::rand; use super::{DList, Node, ListInsertion}; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs new file mode 100644 index 00000000000..417bf47803e --- /dev/null +++ b/src/libcollections/lib.rs @@ -0,0 +1,46 @@ +// Copyright 2013-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. + +/*! + * Collection types. + */ + +#[crate_id = "collections#0.10-pre"]; +#[crate_type = "rlib"]; +#[crate_type = "dylib"]; +#[license = "MIT/ASL2"]; + +#[feature(macro_rules, managed_boxes)]; + +#[cfg(test)] extern mod extra; + +extern mod serialize; + +pub use bitv::Bitv; +pub use btree::BTree; +pub use deque::Deque; +pub use dlist::DList; +pub use list::List; +pub use lru_cache::LruCache; +pub use priority_queue::PriorityQueue; +pub use ringbuf::RingBuf; +pub use smallintmap::SmallIntMap; +pub use treemap::{TreeMap, TreeSet}; + +pub mod bitv; +pub mod btree; +pub mod deque; +pub mod dlist; +pub mod list; +pub mod lru_cache; +pub mod priority_queue; +pub mod ringbuf; +pub mod smallintmap; +pub mod treemap; \ No newline at end of file diff --git a/src/libextra/list.rs b/src/libcollections/list.rs index b530d9c9bc1..79d0f3f49a7 100644 --- a/src/libextra/list.rs +++ b/src/libcollections/list.rs @@ -153,7 +153,7 @@ pub fn each<T>(l: @List<T>, f: |&T| -> bool) -> bool { #[cfg(test)] mod tests { - use list::*; + use list::{List, Nil, from_vec, head, is_empty, tail}; use list; use std::option; diff --git a/src/libextra/lru_cache.rs b/src/libcollections/lru_cache.rs index f602db2e54d..de7b511fd41 100644 --- a/src/libextra/lru_cache.rs +++ b/src/libcollections/lru_cache.rs @@ -17,7 +17,7 @@ //! # Example //! //! ```rust -//! use extra::lru_cache::LruCache; +//! use collections::LruCache; //! //! let mut cache: LruCache<int, int> = LruCache::new(2); //! cache.put(1, 10); diff --git a/src/libextra/priority_queue.rs b/src/libcollections/priority_queue.rs index 3ae3dae9ea3..3ae3dae9ea3 100644 --- a/src/libextra/priority_queue.rs +++ b/src/libcollections/priority_queue.rs diff --git a/src/libextra/ringbuf.rs b/src/libcollections/ringbuf.rs index 17631f5bdff..933fe2048e4 100644 --- a/src/libextra/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -17,7 +17,7 @@ use std::num; use std::vec; use std::iter::{Rev, RandomAccessIterator}; -use container::Deque; +use deque::Deque; use serialize::{Encodable, Decodable, Encoder, Decoder}; @@ -431,7 +431,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for RingBuf<T> { #[cfg(test)] mod tests { - use container::Deque; + use deque::Deque; use extra::test; use std::clone::Clone; use std::cmp::Eq; diff --git a/src/libextra/smallintmap.rs b/src/libcollections/smallintmap.rs index abbd987a9c4..b996f0dea32 100644 --- a/src/libextra/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -471,9 +471,9 @@ mod test_map { #[cfg(test)] mod bench { - use super::*; - use test::BenchHarness; - use container::bench::*; + use super::SmallIntMap; + use extra::test::BenchHarness; + use deque::bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n}; // Find seq #[bench] diff --git a/src/libextra/treemap.rs b/src/libcollections/treemap.rs index 449e72dd0ec..0fccc57b29e 100644 --- a/src/libextra/treemap.rs +++ b/src/libcollections/treemap.rs @@ -1495,9 +1495,9 @@ mod test_treemap { #[cfg(test)] mod bench { - use super::*; - use test::BenchHarness; - use container::bench::*; + use super::TreeMap; + use extra::test::BenchHarness; + use deque::bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n}; // Find seq #[bench] @@ -1555,7 +1555,7 @@ mod bench { #[cfg(test)] mod test_set { - use super::*; + use super::{TreeMap, TreeSet}; #[test] fn test_clear() { diff --git a/src/libextra/json.rs b/src/libextra/json.rs index 8b082bf3056..3938f1a8994 100644 --- a/src/libextra/json.rs +++ b/src/libextra/json.rs @@ -98,9 +98,11 @@ A basic `ToJson` example using a TreeMap of attribute name / attribute value: ```rust +extern mod collections; + use extra::json; use extra::json::ToJson; -use extra::treemap::TreeMap; +use collections::TreeMap; pub struct MyStruct { attr1: u8, @@ -185,10 +187,12 @@ Example of `ToJson` trait implementation for TestStruct1. ```rust extern mod serialize; +extern mod collections; + use extra::json; use extra::json::ToJson; use serialize::{Encodable, Decodable}; -use extra::treemap::TreeMap; +use collections::TreeMap; #[deriving(Decodable, Encodable)] // generate Decodable, Encodable impl. pub struct TestStruct1 { @@ -225,7 +229,6 @@ fn main() { */ use std::char; -use std::cast::transmute; use std::f64; use std::hashmap::HashMap; use std::io; @@ -236,7 +239,7 @@ use std::to_str; use serialize::Encodable; use serialize; -use treemap::TreeMap; +use collections::TreeMap; macro_rules! if_ok( ($e:expr) => ( match $e { Ok(e) => e, Err(e) => { self.error = Err(e); return } } @@ -714,7 +717,7 @@ impl Json { pub struct Parser<T> { priv rdr: T, - priv ch: char, + priv ch: Option<char>, priv line: uint, priv col: uint, } @@ -724,7 +727,7 @@ impl<T: Iterator<char>> Parser<T> { pub fn new(rdr: T) -> Parser<T> { let mut p = Parser { rdr: rdr, - ch: '\x00', + ch: Some('\x00'), line: 1, col: 0, }; @@ -752,16 +755,12 @@ impl<T: Iterator<char>> Parser<T> { } impl<T : Iterator<char>> Parser<T> { - // FIXME: #8971: unsound - fn eof(&self) -> bool { self.ch == unsafe { transmute(-1u32) } } - + fn eof(&self) -> bool { self.ch.is_none() } + fn ch_or_null(&self) -> char { self.ch.unwrap_or('\x00') } fn bump(&mut self) { - match self.rdr.next() { - Some(ch) => self.ch = ch, - None() => self.ch = unsafe { transmute(-1u32) }, // FIXME: #8971: unsound - } + self.ch = self.rdr.next(); - if self.ch == '\n' { + if self.ch_is('\n') { self.line += 1u; self.col = 1u; } else { @@ -769,10 +768,13 @@ impl<T : Iterator<char>> Parser<T> { } } - fn next_char(&mut self) -> char { + fn next_char(&mut self) -> Option<char> { self.bump(); self.ch } + fn ch_is(&self, c: char) -> bool { + self.ch == Some(c) + } fn error<T>(&self, msg: ~str) -> Result<T, Error> { Err(Error { line: self.line, col: self.col, msg: msg }) @@ -783,31 +785,32 @@ impl<T : Iterator<char>> Parser<T> { if self.eof() { return self.error(~"EOF while parsing value"); } - match self.ch { - 'n' => self.parse_ident("ull", Null), - 't' => self.parse_ident("rue", Boolean(true)), - 'f' => self.parse_ident("alse", Boolean(false)), - '0' .. '9' | '-' => self.parse_number(), - '"' => - match self.parse_str() { - Ok(s) => Ok(String(s)), - Err(e) => Err(e), + match self.ch_or_null() { + 'n' => self.parse_ident("ull", Null), + 't' => self.parse_ident("rue", Boolean(true)), + 'f' => self.parse_ident("alse", Boolean(false)), + '0' .. '9' | '-' => self.parse_number(), + '"' => { + match self.parse_str() { + Ok(s) => Ok(String(s)), + Err(e) => Err(e), + } }, - '[' => self.parse_list(), - '{' => self.parse_object(), - _ => self.error(~"invalid syntax") + '[' => self.parse_list(), + '{' => self.parse_object(), + _ => self.error(~"invalid syntax"), } } fn parse_whitespace(&mut self) { - while self.ch == ' ' || - self.ch == '\n' || - self.ch == '\t' || - self.ch == '\r' { self.bump(); } + while self.ch_is(' ') || + self.ch_is('\n') || + self.ch_is('\t') || + self.ch_is('\r') { self.bump(); } } fn parse_ident(&mut self, ident: &str, value: Json) -> Result<Json, Error> { - if ident.chars().all(|c| c == self.next_char()) { + if ident.chars().all(|c| Some(c) == self.next_char()) { self.bump(); Ok(value) } else { @@ -818,7 +821,7 @@ impl<T : Iterator<char>> Parser<T> { fn parse_number(&mut self) -> Result<Json, Error> { let mut neg = 1.0; - if self.ch == '-' { + if self.ch_is('-') { self.bump(); neg = -1.0; } @@ -828,14 +831,14 @@ impl<T : Iterator<char>> Parser<T> { Err(e) => return Err(e) }; - if self.ch == '.' { + if self.ch_is('.') { match self.parse_decimal(res) { Ok(r) => res = r, Err(e) => return Err(e) } } - if self.ch == 'e' || self.ch == 'E' { + if self.ch_is('e') || self.ch_is('E') { match self.parse_exponent(res) { Ok(r) => res = r, Err(e) => return Err(e) @@ -848,32 +851,31 @@ impl<T : Iterator<char>> Parser<T> { fn parse_integer(&mut self) -> Result<f64, Error> { let mut res = 0.0; - match self.ch { - '0' => { - self.bump(); - - // There can be only one leading '0'. - match self.ch { - '0' .. '9' => return self.error(~"invalid number"), - _ => () - } - } - '1' .. '9' => { - while !self.eof() { - match self.ch { - '0' .. '9' => { - res *= 10.0; - res += ((self.ch as int) - ('0' as int)) as f64; + match self.ch_or_null() { + '0' => { + self.bump(); - self.bump(); - } - _ => break + // There can be only one leading '0'. + match self.ch_or_null() { + '0' .. '9' => return self.error(~"invalid number"), + _ => () + } + }, + '1' .. '9' => { + while !self.eof() { + match self.ch_or_null() { + c @ '0' .. '9' => { + res *= 10.0; + res += ((c as int) - ('0' as int)) as f64; + + self.bump(); + } + _ => break, + } } } - } - _ => return self.error(~"invalid number") + _ => return self.error(~"invalid number"), } - Ok(res) } @@ -881,22 +883,22 @@ impl<T : Iterator<char>> Parser<T> { self.bump(); // Make sure a digit follows the decimal place. - match self.ch { - '0' .. '9' => (), - _ => return self.error(~"invalid number") + match self.ch_or_null() { + '0' .. '9' => (), + _ => return self.error(~"invalid number") } let mut res = res; let mut dec = 1.0; while !self.eof() { - match self.ch { - '0' .. '9' => { - dec /= 10.0; - res += (((self.ch as int) - ('0' as int)) as f64) * dec; + match self.ch_or_null() { + c @ '0' .. '9' => { + dec /= 10.0; + res += (((c as int) - ('0' as int)) as f64) * dec; - self.bump(); - } - _ => break + self.bump(); + } + _ => break, } } @@ -909,27 +911,27 @@ impl<T : Iterator<char>> Parser<T> { let mut exp = 0u; let mut neg_exp = false; - match self.ch { - '+' => self.bump(), - '-' => { self.bump(); neg_exp = true; } - _ => () + if self.ch_is('+') { + self.bump(); + } else if self.ch_is('-') { + self.bump(); + neg_exp = true; } // Make sure a digit follows the exponent place. - match self.ch { - '0' .. '9' => (), - _ => return self.error(~"invalid number") + match self.ch_or_null() { + '0' .. '9' => (), + _ => return self.error(~"invalid number") } - while !self.eof() { - match self.ch { - '0' .. '9' => { - exp *= 10u; - exp += (self.ch as uint) - ('0' as uint); + match self.ch_or_null() { + c @ '0' .. '9' => { + exp *= 10; + exp += (c as uint) - ('0' as uint); - self.bump(); - } - _ => break + self.bump(); + } + _ => break } } @@ -954,56 +956,55 @@ impl<T : Iterator<char>> Parser<T> { } if escape { - match self.ch { - '"' => res.push_char('"'), - '\\' => res.push_char('\\'), - '/' => res.push_char('/'), - 'b' => res.push_char('\x08'), - 'f' => res.push_char('\x0c'), - 'n' => res.push_char('\n'), - 'r' => res.push_char('\r'), - 't' => res.push_char('\t'), - 'u' => { - // Parse \u1234. - let mut i = 0u; - let mut n = 0u; - while i < 4u { - match self.next_char() { - '0' .. '9' => { - n = n * 16u + (self.ch as uint) - - ('0' as uint); - }, - 'a' | 'A' => n = n * 16u + 10u, - 'b' | 'B' => n = n * 16u + 11u, - 'c' | 'C' => n = n * 16u + 12u, - 'd' | 'D' => n = n * 16u + 13u, - 'e' | 'E' => n = n * 16u + 14u, - 'f' | 'F' => n = n * 16u + 15u, - _ => return self.error( - ~"invalid \\u escape (unrecognized hex)") - } - i += 1u; - } - - // Error out if we didn't parse 4 digits. - if i != 4u { - return self.error( - ~"invalid \\u escape (not four digits)"); - } - - res.push_char(char::from_u32(n as u32).unwrap()); - } - _ => return self.error(~"invalid escape") + match self.ch_or_null() { + '"' => res.push_char('"'), + '\\' => res.push_char('\\'), + '/' => res.push_char('/'), + 'b' => res.push_char('\x08'), + 'f' => res.push_char('\x0c'), + 'n' => res.push_char('\n'), + 'r' => res.push_char('\r'), + 't' => res.push_char('\t'), + 'u' => { + // Parse \u1234. + let mut i = 0u; + let mut n = 0u; + while i < 4u && !self.eof() { + self.bump(); + n = match self.ch_or_null() { + c @ '0' .. '9' => n * 16u + (c as uint) - ('0' as uint), + 'a' | 'A' => n * 16u + 10u, + 'b' | 'B' => n * 16u + 11u, + 'c' | 'C' => n * 16u + 12u, + 'd' | 'D' => n * 16u + 13u, + 'e' | 'E' => n * 16u + 14u, + 'f' | 'F' => n * 16u + 15u, + _ => return self.error( + ~"invalid \\u escape (unrecognized hex)") + }; + + i += 1u; + } + + // Error out if we didn't parse 4 digits. + if i != 4u { + return self.error( + ~"invalid \\u escape (not four digits)"); + } + + res.push_char(char::from_u32(n as u32).unwrap()); + } + _ => return self.error(~"invalid escape"), } escape = false; - } else if self.ch == '\\' { + } else if self.ch_is('\\') { escape = true; } else { - if self.ch == '"' { - self.bump(); - return Ok(res); + match self.ch { + Some('"') => { self.bump(); return Ok(res); }, + Some(c) => res.push_char(c), + None => unreachable!() } - res.push_char(self.ch); } } } @@ -1014,7 +1015,7 @@ impl<T : Iterator<char>> Parser<T> { let mut values = ~[]; - if self.ch == ']' { + if self.ch_is(']') { self.bump(); return Ok(List(values)); } @@ -1030,10 +1031,13 @@ impl<T : Iterator<char>> Parser<T> { return self.error(~"EOF while parsing list"); } - match self.ch { - ',' => self.bump(), - ']' => { self.bump(); return Ok(List(values)); } - _ => return self.error(~"expected `,` or `]`") + if self.ch_is(',') { + self.bump(); + } else if self.ch_is(']') { + self.bump(); + return Ok(List(values)); + } else { + return self.error(~"expected `,` or `]`") } }; } @@ -1044,7 +1048,7 @@ impl<T : Iterator<char>> Parser<T> { let mut values = ~TreeMap::new(); - if self.ch == '}' { + if self.ch_is('}') { self.bump(); return Ok(Object(values)); } @@ -1052,7 +1056,7 @@ impl<T : Iterator<char>> Parser<T> { while !self.eof() { self.parse_whitespace(); - if self.ch != '"' { + if !self.ch_is('"') { return self.error(~"key must be a string"); } @@ -1063,7 +1067,7 @@ impl<T : Iterator<char>> Parser<T> { self.parse_whitespace(); - if self.ch != ':' { + if !self.ch_is(':') { if self.eof() { break; } return self.error(~"expected `:`"); } @@ -1075,13 +1079,13 @@ impl<T : Iterator<char>> Parser<T> { } self.parse_whitespace(); - match self.ch { - ',' => self.bump(), - '}' => { self.bump(); return Ok(Object(values)); } - _ => { - if self.eof() { break; } - return self.error(~"expected `,` or `}`"); - } + match self.ch_or_null() { + ',' => self.bump(), + '}' => { self.bump(); return Ok(Object(values)); }, + _ => { + if self.eof() { break; } + return self.error(~"expected `,` or `}`"); + } } } @@ -1588,7 +1592,7 @@ mod tests { use std::io; use serialize::{Encodable, Decodable}; - use treemap::TreeMap; + use collections::TreeMap; #[deriving(Eq, Encodable, Decodable)] enum Animal { diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs index 37b4d3cc524..109bf2e489b 100644 --- a/src/libextra/lib.rs +++ b/src/libextra/lib.rs @@ -29,7 +29,7 @@ Rust extras are part of the standard Rust distribution. html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://static.rust-lang.org/doc/master")]; -#[feature(macro_rules, globs, managed_boxes)]; +#[feature(macro_rules, globs, managed_boxes, asm)]; #[deny(non_camel_case_types)]; #[deny(missing_doc)]; @@ -38,6 +38,8 @@ extern mod sync; #[cfg(not(stage0))] extern mod serialize; +extern mod collections; + #[cfg(stage0)] pub mod serialize { #[allow(missing_doc)]; @@ -47,33 +49,13 @@ pub mod serialize { EncoderHelpers, DecoderHelpers}; } -#[cfg(stage0)] -macro_rules! if_ok ( - ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) }) -) - // Utility modules pub mod c_vec; -// Collections - -pub mod container; -pub mod bitv; -pub mod list; -pub mod ringbuf; -pub mod priority_queue; -pub mod smallintmap; - -pub mod dlist; -pub mod treemap; -pub mod btree; -pub mod lru_cache; - // And ... other stuff pub mod url; -pub mod getopts; pub mod json; pub mod tempfile; pub mod time; diff --git a/src/libextra/test.rs b/src/libextra/test.rs index c4d27b25b55..d207bd2298b 100644 --- a/src/libextra/test.rs +++ b/src/libextra/test.rs @@ -15,17 +15,16 @@ // simplest interface possible for representing and running tests // while providing a base that other test frameworks may build off of. +extern mod getopts; extern mod term; -use getopts; -use getopts::groups; use json::ToJson; use json; use serialize::Decodable; use stats::Stats; use stats; use time::precise_time_ns; -use treemap::TreeMap; +use collections::TreeMap; use std::clone::Clone; use std::io; @@ -209,29 +208,29 @@ pub struct TestOpts { /// Result of parsing the options. pub type OptRes = Result<TestOpts, ~str>; -fn optgroups() -> ~[getopts::groups::OptGroup] { - ~[groups::optflag("", "ignored", "Run ignored tests"), - groups::optflag("", "test", "Run tests and not benchmarks"), - groups::optflag("", "bench", "Run benchmarks instead of tests"), - groups::optflag("h", "help", "Display this message (longer with --help)"), - groups::optopt("", "save-metrics", "Location to save bench metrics", +fn optgroups() -> ~[getopts::OptGroup] { + ~[getopts::optflag("", "ignored", "Run ignored tests"), + getopts::optflag("", "test", "Run tests and not benchmarks"), + getopts::optflag("", "bench", "Run benchmarks instead of tests"), + getopts::optflag("h", "help", "Display this message (longer with --help)"), + getopts::optopt("", "save-metrics", "Location to save bench metrics", "PATH"), - groups::optopt("", "ratchet-metrics", + getopts::optopt("", "ratchet-metrics", "Location to load and save metrics from. The metrics \ loaded are cause benchmarks to fail if they run too \ slowly", "PATH"), - groups::optopt("", "ratchet-noise-percent", + getopts::optopt("", "ratchet-noise-percent", "Tests within N% of the recorded metrics will be \ considered as passing", "PERCENTAGE"), - groups::optopt("", "logfile", "Write logs to the specified file instead \ + getopts::optopt("", "logfile", "Write logs to the specified file instead \ of stdout", "PATH"), - groups::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite", + getopts::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite", "A.B")] } fn usage(binary: &str, helpstr: &str) { let message = format!("Usage: {} [OPTIONS] [FILTER]", binary); - println!("{}", groups::usage(message, optgroups())); + println!("{}", getopts::usage(message, optgroups())); println!(""); if helpstr == "help" { println!("{}", "\ @@ -261,7 +260,7 @@ Test Attributes: pub fn parse_opts(args: &[~str]) -> Option<OptRes> { let args_ = args.tail(); let matches = - match groups::getopts(args_, optgroups()) { + match getopts::getopts(args_, optgroups()) { Ok(m) => m, Err(f) => return Some(Err(f.to_err_msg())) }; @@ -894,8 +893,8 @@ pub fn run_test(force_ignore: bool, spawn(proc() { let mut task = task::task(); task.name(match desc.name { - DynTestName(ref name) => SendStrOwned(name.clone()), - StaticTestName(name) => SendStrStatic(name), + DynTestName(ref name) => name.to_owned().into_maybe_owned(), + StaticTestName(name) => name.into_maybe_owned() }); let result_future = task.future_result(); task.spawn(testfn); @@ -1092,13 +1091,25 @@ impl MetricMap { // Benchmarking +/// A function that is opaque to the optimiser, to allow benchmarks to +/// pretend to use outputs to assist in avoiding dead-code +/// elimination. +/// +/// This function is a no-op, and does not even read from `dummy`. +pub fn black_box<T>(dummy: T) { + // we need to "use" the argument in some way LLVM can't + // introspect. + unsafe {asm!("" : : "r"(&dummy))} +} + + impl BenchHarness { /// Callback for benchmark functions to run in their body. - pub fn iter(&mut self, inner: ||) { + pub fn iter<T>(&mut self, inner: || -> T) { self.ns_start = precise_time_ns(); let k = self.iterations; for _ in range(0u64, k) { - inner(); + black_box(inner()); } self.ns_end = precise_time_ns(); } diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs index d16edb7aa1e..007b54adbe5 100644 --- a/src/libextra/workcache.rs +++ b/src/libextra/workcache.rs @@ -14,7 +14,7 @@ use json; use json::ToJson; use serialize::{Encoder, Encodable, Decoder, Decodable}; use sync::{Arc,RWArc}; -use treemap::TreeMap; +use collections::TreeMap; use std::str; use std::io; use std::io::{File, MemWriter}; diff --git a/src/libextra/getopts.rs b/src/libgetopts/lib.rs index 4293f04795e..e5e7c50d2ce 100644 --- a/src/libextra/getopts.rs +++ b/src/libgetopts/lib.rs @@ -30,8 +30,8 @@ //! file name following `-o`, and accepts both `-h` and `--help` as optional flags. //! //! ~~~{.rust} -//! extern mod extra; -//! use extra::getopts::{optopt,optflag,getopts,Opt}; +//! extern mod getopts; +//! use getopts::{optopt,optflag,getopts,OptGroup}; //! use std::os; //! //! fn do_work(inp: &str, out: Option<~str>) { @@ -42,7 +42,7 @@ //! } //! } //! -//! fn print_usage(program: &str, _opts: &[Opt]) { +//! fn print_usage(program: &str, _opts: &[OptGroup]) { //! println!("Usage: {} [options]", program); //! println!("-o\t\tOutput"); //! println!("-h --help\tUsage"); @@ -54,15 +54,14 @@ //! let program = args[0].clone(); //! //! let opts = ~[ -//! optopt("o"), -//! optflag("h"), -//! optflag("help") +//! optopt("o", "", "set output file name", "NAME"), +//! optflag("h", "help", "print this help menu") //! ]; //! let matches = match getopts(args.tail(), opts) { //! Ok(m) => { m } //! Err(f) => { fail!(f.to_err_msg()) } //! }; -//! if matches.opt_present("h") || matches.opt_present("help") { +//! if matches.opt_present("h") { //! print_usage(program, opts); //! return; //! } @@ -77,6 +76,14 @@ //! } //! ~~~ +#[crate_id = "getopts#0.10-pre"]; +#[crate_type = "rlib"]; +#[crate_type = "dylib"]; +#[license = "MIT/ASL2"]; +#[allow(missing_doc)]; + +#[feature(globs)]; + use std::cmp::Eq; use std::result::{Err, Ok}; use std::result; @@ -122,6 +129,24 @@ pub struct Opt { priv aliases: ~[Opt], } +/// One group of options, e.g., both -h and --help, along with +/// their shared description and properties. +#[deriving(Clone, Eq)] +pub struct OptGroup { + /// Short Name of the `OptGroup` + short_name: ~str, + /// Long Name of the `OptGroup` + long_name: ~str, + /// Hint + hint: ~str, + /// Description + desc: ~str, + /// Whether it has an argument + hasarg: HasArg, + /// How often it can occur + occur: Occur +} + /// Describes wether an option is given at all or has a value. #[deriving(Clone, Eq)] enum Optval { @@ -185,6 +210,50 @@ impl Name { } } +impl OptGroup { + /// Translate OptGroup into Opt. + /// (Both short and long names correspond to different Opts). + pub fn long_to_short(&self) -> Opt { + let OptGroup { + short_name: short_name, + long_name: long_name, + hasarg: hasarg, + occur: occur, + .. + } = (*self).clone(); + + match (short_name.len(), long_name.len()) { + (0,0) => fail!("this long-format option was given no name"), + (0,_) => Opt { + name: Long((long_name)), + hasarg: hasarg, + occur: occur, + aliases: ~[] + }, + (1,0) => Opt { + name: Short(short_name.char_at(0)), + hasarg: hasarg, + occur: occur, + aliases: ~[] + }, + (1,_) => Opt { + name: Long((long_name)), + hasarg: hasarg, + occur: occur, + aliases: ~[ + Opt { + name: Short(short_name.char_at(0)), + hasarg: hasarg, + occur: occur, + aliases: ~[] + } + ] + }, + (_,_) => fail!("something is wrong with the long-form opt") + } + } +} + impl Matches { fn opt_vals(&self, nm: &str) -> ~[Optval] { match find_opt(self.opts, Name::from_str(nm)) { @@ -300,65 +369,89 @@ fn find_opt(opts: &[Opt], nm: Name) -> Option<uint> { None } -/// Create an option that is required and takes an argument. -pub fn reqopt(name: &str) -> Opt { - Opt { - name: Name::from_str(name), +/// Create a long option that is required and takes an argument. +pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { + let len = short_name.len(); + assert!(len == 1 || len == 0); + OptGroup { + short_name: short_name.to_owned(), + long_name: long_name.to_owned(), + hint: hint.to_owned(), + desc: desc.to_owned(), hasarg: Yes, - occur: Req, - aliases: ~[] + occur: Req } } -/// Create an option that is optional and takes an argument. -pub fn optopt(name: &str) -> Opt { - Opt { - name: Name::from_str(name), +/// Create a long option that is optional and takes an argument. +pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { + let len = short_name.len(); + assert!(len == 1 || len == 0); + OptGroup { + short_name: short_name.to_owned(), + long_name: long_name.to_owned(), + hint: hint.to_owned(), + desc: desc.to_owned(), hasarg: Yes, - occur: Optional, - aliases: ~[] + occur: Optional } } -/// Create an option that is optional and does not take an argument. -pub fn optflag(name: &str) -> Opt { - Opt { - name: Name::from_str(name), +/// Create a long option that is optional and does not take an argument. +pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup { + let len = short_name.len(); + assert!(len == 1 || len == 0); + OptGroup { + short_name: short_name.to_owned(), + long_name: long_name.to_owned(), + hint: ~"", + desc: desc.to_owned(), hasarg: No, - occur: Optional, - aliases: ~[] + occur: Optional } } -/// Create an option that is optional, does not take an argument, -/// and may occur multiple times. -pub fn optflagmulti(name: &str) -> Opt { - Opt { - name: Name::from_str(name), +/// Create a long option that can occur more than once and does not +/// take an argument. +pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup { + let len = short_name.len(); + assert!(len == 1 || len == 0); + OptGroup { + short_name: short_name.to_owned(), + long_name: long_name.to_owned(), + hint: ~"", + desc: desc.to_owned(), hasarg: No, - occur: Multi, - aliases: ~[] + occur: Multi } } -/// Create an option that is optional and takes an optional argument. -pub fn optflagopt(name: &str) -> Opt { - Opt { - name: Name::from_str(name), +/// Create a long option that is optional and takes an optional argument. +pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { + let len = short_name.len(); + assert!(len == 1 || len == 0); + OptGroup { + short_name: short_name.to_owned(), + long_name: long_name.to_owned(), + hint: hint.to_owned(), + desc: desc.to_owned(), hasarg: Maybe, - occur: Optional, - aliases: ~[] + occur: Optional } } -/// Create an option that is optional, takes an argument, and may occur +/// Create a long option that is optional, takes an argument, and may occur /// multiple times. -pub fn optmulti(name: &str) -> Opt { - Opt { - name: Name::from_str(name), +pub fn optmulti(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { + let len = short_name.len(); + assert!(len == 1 || len == 0); + OptGroup { + short_name: short_name.to_owned(), + long_name: long_name.to_owned(), + hint: hint.to_owned(), + desc: desc.to_owned(), hasarg: Yes, - occur: Multi, - aliases: ~[] + occur: Multi } } @@ -390,7 +483,8 @@ impl Fail_ { /// On success returns `Ok(Opt)`. Use methods such as `opt_present` /// `opt_str`, etc. to interrogate results. Returns `Err(Fail_)` on failure. /// Use `to_err_msg` to get an error message. -pub fn getopts(args: &[~str], opts: &[Opt]) -> Result { +pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result { + let opts = optgrps.map(|x| x.long_to_short()); let n_opts = opts.len(); fn f(_x: uint) -> ~[Optval] { return ~[]; } @@ -516,348 +610,232 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result { }) } -/// A module which provides a way to specify descriptions and -/// groups of short and long option names, together. -pub mod groups { - use getopts::{HasArg, Long, Maybe, Multi, No, Occur, Opt, Optional, Req}; - use getopts::{Short, Yes}; - - /// One group of options, e.g., both -h and --help, along with - /// their shared description and properties. - #[deriving(Clone, Eq)] - pub struct OptGroup { - /// Short Name of the `OptGroup` - short_name: ~str, - /// Long Name of the `OptGroup` - long_name: ~str, - /// Hint - hint: ~str, - /// Description - desc: ~str, - /// Whether it has an argument - hasarg: HasArg, - /// How often it can occur - occur: Occur - } - - impl OptGroup { - /// Translate OptGroup into Opt. - /// (Both short and long names correspond to different Opts). - pub fn long_to_short(&self) -> Opt { - let OptGroup { - short_name: short_name, - long_name: long_name, - hasarg: hasarg, - occur: occur, - .. - } = (*self).clone(); - - match (short_name.len(), long_name.len()) { - (0,0) => fail!("this long-format option was given no name"), - (0,_) => Opt { - name: Long((long_name)), - hasarg: hasarg, - occur: occur, - aliases: ~[] - }, - (1,0) => Opt { - name: Short(short_name.char_at(0)), - hasarg: hasarg, - occur: occur, - aliases: ~[] - }, - (1,_) => Opt { - name: Long((long_name)), - hasarg: hasarg, - occur: occur, - aliases: ~[ - Opt { - name: Short(short_name.char_at(0)), - hasarg: hasarg, - occur: occur, - aliases: ~[] - } - ] - }, - (_,_) => fail!("something is wrong with the long-form opt") - } - } - } +/// Derive a usage message from a set of long options. +pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str { - /// Create a long option that is required and takes an argument. - pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { - let len = short_name.len(); - assert!(len == 1 || len == 0); - OptGroup { - short_name: short_name.to_owned(), - long_name: long_name.to_owned(), - hint: hint.to_owned(), - desc: desc.to_owned(), - hasarg: Yes, - occur: Req - } - } + let desc_sep = "\n" + " ".repeat(24); - /// Create a long option that is optional and takes an argument. - pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { - let len = short_name.len(); - assert!(len == 1 || len == 0); - OptGroup { - short_name: short_name.to_owned(), - long_name: long_name.to_owned(), - hint: hint.to_owned(), - desc: desc.to_owned(), - hasarg: Yes, - occur: Optional - } - } + let mut rows = opts.iter().map(|optref| { + let OptGroup{short_name: short_name, + long_name: long_name, + hint: hint, + desc: desc, + hasarg: hasarg, + ..} = (*optref).clone(); - /// Create a long option that is optional and does not take an argument. - pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup { - let len = short_name.len(); - assert!(len == 1 || len == 0); - OptGroup { - short_name: short_name.to_owned(), - long_name: long_name.to_owned(), - hint: ~"", - desc: desc.to_owned(), - hasarg: No, - occur: Optional - } - } + let mut row = " ".repeat(4); - /// Create a long option that can occur more than once and does not - /// take an argument. - pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup { - let len = short_name.len(); - assert!(len == 1 || len == 0); - OptGroup { - short_name: short_name.to_owned(), - long_name: long_name.to_owned(), - hint: ~"", - desc: desc.to_owned(), - hasarg: No, - occur: Multi + // short option + match short_name.len() { + 0 => {} + 1 => { + row.push_char('-'); + row.push_str(short_name); + row.push_char(' '); + } + _ => fail!("the short name should only be 1 ascii char long"), } - } - /// Create a long option that is optional and takes an optional argument. - pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { - let len = short_name.len(); - assert!(len == 1 || len == 0); - OptGroup { - short_name: short_name.to_owned(), - long_name: long_name.to_owned(), - hint: hint.to_owned(), - desc: desc.to_owned(), - hasarg: Maybe, - occur: Optional + // long option + match long_name.len() { + 0 => {} + _ => { + row.push_str("--"); + row.push_str(long_name); + row.push_char(' '); + } } - } - /// Create a long option that is optional, takes an argument, and may occur - /// multiple times. - pub fn optmulti(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { - let len = short_name.len(); - assert!(len == 1 || len == 0); - OptGroup { - short_name: short_name.to_owned(), - long_name: long_name.to_owned(), - hint: hint.to_owned(), - desc: desc.to_owned(), - hasarg: Yes, - occur: Multi + // arg + match hasarg { + No => {} + Yes => row.push_str(hint), + Maybe => { + row.push_char('['); + row.push_str(hint); + row.push_char(']'); + } } - } - - /// Parse command line args with the provided long format options. - pub fn getopts(args: &[~str], opts: &[OptGroup]) -> ::getopts::Result { - ::getopts::getopts(args, opts.map(|x| x.long_to_short())) - } - /// Derive a usage message from a set of long options. - pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str { - - let desc_sep = "\n" + " ".repeat(24); - - let mut rows = opts.iter().map(|optref| { - let OptGroup{short_name: short_name, - long_name: long_name, - hint: hint, - desc: desc, - hasarg: hasarg, - ..} = (*optref).clone(); - - let mut row = " ".repeat(4); - - // short option - match short_name.len() { - 0 => {} - 1 => { - row.push_char('-'); - row.push_str(short_name); - row.push_char(' '); - } - _ => fail!("the short name should only be 1 ascii char long"), + // FIXME: #5516 should be graphemes not codepoints + // here we just need to indent the start of the description + let rowlen = row.char_len(); + if rowlen < 24 { + for _ in range(0, 24 - rowlen) { + row.push_char(' '); } + } else { + row.push_str(desc_sep) + } - // long option - match long_name.len() { - 0 => {} - _ => { - row.push_str("--"); - row.push_str(long_name); - row.push_char(' '); - } - } + // Normalize desc to contain words separated by one space character + let mut desc_normalized_whitespace = ~""; + for word in desc.words() { + desc_normalized_whitespace.push_str(word); + desc_normalized_whitespace.push_char(' '); + } - // arg - match hasarg { - No => {} - Yes => row.push_str(hint), - Maybe => { - row.push_char('['); - row.push_str(hint); - row.push_char(']'); - } - } + // FIXME: #5516 should be graphemes not codepoints + let mut desc_rows = ~[]; + each_split_within(desc_normalized_whitespace, 54, |substr| { + desc_rows.push(substr.to_owned()); + true + }); - // FIXME: #5516 should be graphemes not codepoints - // here we just need to indent the start of the description - let rowlen = row.char_len(); - if rowlen < 24 { - for _ in range(0, 24 - rowlen) { - row.push_char(' '); - } - } else { - row.push_str(desc_sep) - } + // FIXME: #5516 should be graphemes not codepoints + // wrapped description + row.push_str(desc_rows.connect(desc_sep)); - // Normalize desc to contain words separated by one space character - let mut desc_normalized_whitespace = ~""; - for word in desc.words() { - desc_normalized_whitespace.push_str(word); - desc_normalized_whitespace.push_char(' '); - } + row + }); - // FIXME: #5516 should be graphemes not codepoints - let mut desc_rows = ~[]; - each_split_within(desc_normalized_whitespace, 54, |substr| { - desc_rows.push(substr.to_owned()); - true - }); + format!("{}\n\nOptions:\n{}\n", brief, rows.collect::<~[~str]>().connect("\n")) +} - // FIXME: #5516 should be graphemes not codepoints - // wrapped description - row.push_str(desc_rows.connect(desc_sep)); +fn format_option(opt: &OptGroup) -> ~str { + let mut line = ~""; - row - }); + if opt.occur != Req { + line.push_char('['); + } - format!("{}\n\nOptions:\n{}\n", brief, rows.collect::<~[~str]>().connect("\n")) + // Use short_name is possible, but fallback to long_name. + if opt.short_name.len() > 0 { + line.push_char('-'); + line.push_str(opt.short_name); + } else { + line.push_str("--"); + line.push_str(opt.long_name); } - /// Splits a string into substrings with possibly internal whitespace, - /// each of them at most `lim` bytes long. The substrings have leading and trailing - /// whitespace removed, and are only cut at whitespace boundaries. - /// - /// Note: Function was moved here from `std::str` because this module is the only place that - /// uses it, and because it was to specific for a general string function. - /// - /// #Failure: - /// - /// Fails during iteration if the string contains a non-whitespace - /// sequence longer than the limit. - fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool) - -> bool { - // Just for fun, let's write this as a state machine: - - enum SplitWithinState { - A, // leading whitespace, initial state - B, // words - C, // internal and trailing whitespace - } - enum Whitespace { - Ws, // current char is whitespace - Cr // current char is not whitespace + if opt.hasarg != No { + line.push_char(' '); + if opt.hasarg == Maybe { + line.push_char('['); } - enum LengthLimit { - UnderLim, // current char makes current substring still fit in limit - OverLim // current char makes current substring no longer fit in limit + line.push_str(opt.hint); + if opt.hasarg == Maybe { + line.push_char(']'); } + } + + if opt.occur != Req { + line.push_char(']'); + } + if opt.occur == Multi { + line.push_str(".."); + } - let mut slice_start = 0; - let mut last_start = 0; - let mut last_end = 0; - let mut state = A; - let mut fake_i = ss.len(); - let mut lim = lim; + line +} - let mut cont = true; - let slice: || = || { cont = it(ss.slice(slice_start, last_end)) }; +/// Derive a short one-line usage summary from a set of long options. +pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> ~str { + let mut line = ~"Usage: " + program_name + " "; + line.push_str(opts.iter().map(format_option).to_owned_vec().connect(" ")); - // if the limit is larger than the string, lower it to save cycles - if lim >= fake_i { - lim = fake_i; - } + line +} - let machine: |(uint, char)| -> bool = |(i, c)| { - let whitespace = if ::std::char::is_whitespace(c) { Ws } else { Cr }; - let limit = if (i - slice_start + 1) <= lim { UnderLim } else { OverLim }; - - state = match (state, whitespace, limit) { - (A, Ws, _) => { A } - (A, Cr, _) => { slice_start = i; last_start = i; B } - - (B, Cr, UnderLim) => { B } - (B, Cr, OverLim) if (i - last_start + 1) > lim - => fail!("word starting with {} longer than limit!", - ss.slice(last_start, i + 1)), - (B, Cr, OverLim) => { slice(); slice_start = last_start; B } - (B, Ws, UnderLim) => { last_end = i; C } - (B, Ws, OverLim) => { last_end = i; slice(); A } - - (C, Cr, UnderLim) => { last_start = i; B } - (C, Cr, OverLim) => { slice(); slice_start = i; last_start = i; last_end = i; B } - (C, Ws, OverLim) => { slice(); A } - (C, Ws, UnderLim) => { C } - }; - cont +/// Splits a string into substrings with possibly internal whitespace, +/// each of them at most `lim` bytes long. The substrings have leading and trailing +/// whitespace removed, and are only cut at whitespace boundaries. +/// +/// Note: Function was moved here from `std::str` because this module is the only place that +/// uses it, and because it was to specific for a general string function. +/// +/// #Failure: +/// +/// Fails during iteration if the string contains a non-whitespace +/// sequence longer than the limit. +fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool) + -> bool { + // Just for fun, let's write this as a state machine: + + enum SplitWithinState { + A, // leading whitespace, initial state + B, // words + C, // internal and trailing whitespace + } + enum Whitespace { + Ws, // current char is whitespace + Cr // current char is not whitespace + } + enum LengthLimit { + UnderLim, // current char makes current substring still fit in limit + OverLim // current char makes current substring no longer fit in limit + } + + let mut slice_start = 0; + let mut last_start = 0; + let mut last_end = 0; + let mut state = A; + let mut fake_i = ss.len(); + let mut lim = lim; + + let mut cont = true; + let slice: || = || { cont = it(ss.slice(slice_start, last_end)) }; + + // if the limit is larger than the string, lower it to save cycles + if lim >= fake_i { + lim = fake_i; + } + + let machine: |(uint, char)| -> bool = |(i, c)| { + let whitespace = if ::std::char::is_whitespace(c) { Ws } else { Cr }; + let limit = if (i - slice_start + 1) <= lim { UnderLim } else { OverLim }; + + state = match (state, whitespace, limit) { + (A, Ws, _) => { A } + (A, Cr, _) => { slice_start = i; last_start = i; B } + + (B, Cr, UnderLim) => { B } + (B, Cr, OverLim) if (i - last_start + 1) > lim + => fail!("word starting with {} longer than limit!", + ss.slice(last_start, i + 1)), + (B, Cr, OverLim) => { slice(); slice_start = last_start; B } + (B, Ws, UnderLim) => { last_end = i; C } + (B, Ws, OverLim) => { last_end = i; slice(); A } + + (C, Cr, UnderLim) => { last_start = i; B } + (C, Cr, OverLim) => { slice(); slice_start = i; last_start = i; last_end = i; B } + (C, Ws, OverLim) => { slice(); A } + (C, Ws, UnderLim) => { C } }; - ss.char_indices().advance(|x| machine(x)); + cont + }; - // Let the automaton 'run out' by supplying trailing whitespace - while cont && match state { B | C => true, A => false } { - machine((fake_i, ' ')); - fake_i += 1; - } - return cont; - } + ss.char_indices().advance(|x| machine(x)); - #[test] - fn test_split_within() { - fn t(s: &str, i: uint, u: &[~str]) { - let mut v = ~[]; - each_split_within(s, i, |s| { v.push(s.to_owned()); true }); - assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b)); - } - t("", 0, []); - t("", 15, []); - t("hello", 15, [~"hello"]); - t("\nMary had a little lamb\nLittle lamb\n", 15, - [~"Mary had a", ~"little lamb", ~"Little lamb"]); - t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX, - [~"Mary had a little lamb\nLittle lamb"]); + // Let the automaton 'run out' by supplying trailing whitespace + while cont && match state { B | C => true, A => false } { + machine((fake_i, ' ')); + fake_i += 1; } -} // end groups module + return cont; +} + +#[test] +fn test_split_within() { + fn t(s: &str, i: uint, u: &[~str]) { + let mut v = ~[]; + each_split_within(s, i, |s| { v.push(s.to_owned()); true }); + assert!(v.iter().zip(u.iter()).all(|(a,b)| a == b)); + } + t("", 0, []); + t("", 15, []); + t("hello", 15, [~"hello"]); + t("\nMary had a little lamb\nLittle lamb\n", 15, + [~"Mary had a", ~"little lamb", ~"Little lamb"]); + t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX, + [~"Mary had a little lamb\nLittle lamb"]); +} #[cfg(test)] mod tests { - - use getopts::groups::OptGroup; - use getopts::*; + use super::*; use std::result::{Err, Ok}; use std::result; @@ -872,73 +850,37 @@ mod tests { } } - // Tests for reqopt #[test] - fn test_reqopt_long() { - let args = ~[~"--test=20"]; - let opts = ~[reqopt("test")]; - let rs = getopts(args, opts); + fn test_reqopt() { + let long_args = ~[~"--test=20"]; + let opts = ~[reqopt("t", "test", "testing", "TEST")]; + let rs = getopts(long_args, opts); match rs { Ok(ref m) => { assert!(m.opt_present("test")); assert_eq!(m.opt_str("test").unwrap(), ~"20"); + assert!(m.opt_present("t")); + assert_eq!(m.opt_str("t").unwrap(), ~"20"); } - _ => { fail!("test_reqopt_long failed"); } + _ => { fail!("test_reqopt failed (long arg)"); } } - } - - #[test] - fn test_reqopt_long_missing() { - let args = ~[~"blah"]; - let opts = ~[reqopt("test")]; - let rs = getopts(args, opts); - match rs { - Err(f) => check_fail_type(f, OptionMissing_), - _ => fail!() - } - } - - #[test] - fn test_reqopt_long_no_arg() { - let args = ~[~"--test"]; - let opts = ~[reqopt("test")]; - let rs = getopts(args, opts); - match rs { - Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() - } - } - - #[test] - fn test_reqopt_long_multi() { - let args = ~[~"--test=20", ~"--test=30"]; - let opts = ~[reqopt("test")]; - let rs = getopts(args, opts); - match rs { - Err(f) => check_fail_type(f, OptionDuplicated_), - _ => fail!() - } - } - - #[test] - fn test_reqopt_short() { - let args = ~[~"-t", ~"20"]; - let opts = ~[reqopt("t")]; - let rs = getopts(args, opts); - match rs { + let short_args = ~[~"-t", ~"20"]; + match getopts(short_args, opts) { Ok(ref m) => { - assert!(m.opt_present("t")); + assert!((m.opt_present("test"))); + assert_eq!(m.opt_str("test").unwrap(), ~"20"); + assert!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } - _ => fail!() + _ => { fail!("test_reqopt failed (short arg)"); } } } #[test] - fn test_reqopt_short_missing() { + fn test_reqopt_missing() { let args = ~[~"blah"]; - let opts = ~[reqopt("t")]; + let opts = ~[reqopt("t", "test", "testing", "TEST")]; let rs = getopts(args, opts); match rs { Err(f) => check_fail_type(f, OptionMissing_), @@ -947,20 +889,25 @@ mod tests { } #[test] - fn test_reqopt_short_no_arg() { - let args = ~[~"-t"]; - let opts = ~[reqopt("t")]; - let rs = getopts(args, opts); + fn test_reqopt_no_arg() { + let long_args = ~[~"--test"]; + let opts = ~[reqopt("t", "test", "testing", "TEST")]; + let rs = getopts(long_args, opts); match rs { Err(f) => check_fail_type(f, ArgumentMissing_), _ => fail!() } + let short_args = ~[~"-t"]; + match getopts(short_args, opts) { + Err(f) => check_fail_type(f, ArgumentMissing_), + _ => fail!() + } } #[test] - fn test_reqopt_short_multi() { - let args = ~[~"-t", ~"20", ~"-t", ~"30"]; - let opts = ~[reqopt("t")]; + fn test_reqopt_multi() { + let args = ~[~"--test=20", ~"-t", ~"30"]; + let opts = ~[reqopt("t", "test", "testing", "TEST")]; let rs = getopts(args, opts); match rs { Err(f) => check_fail_type(f, OptionDuplicated_), @@ -968,62 +915,26 @@ mod tests { } } - // Tests for optopt #[test] - fn test_optopt_long() { - let args = ~[~"--test=20"]; - let opts = ~[optopt("test")]; - let rs = getopts(args, opts); + fn test_optopt() { + let long_args = ~[~"--test=20"]; + let opts = ~[optopt("t", "test", "testing", "TEST")]; + let rs = getopts(long_args, opts); match rs { Ok(ref m) => { assert!(m.opt_present("test")); assert_eq!(m.opt_str("test").unwrap(), ~"20"); + assert!((m.opt_present("t"))); + assert_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() } - } - - #[test] - fn test_optopt_long_missing() { - let args = ~[~"blah"]; - let opts = ~[optopt("test")]; - let rs = getopts(args, opts); - match rs { - Ok(ref m) => assert!(!m.opt_present("test")), - _ => fail!() - } - } - - #[test] - fn test_optopt_long_no_arg() { - let args = ~[~"--test"]; - let opts = ~[optopt("test")]; - let rs = getopts(args, opts); - match rs { - Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() - } - } - - #[test] - fn test_optopt_long_multi() { - let args = ~[~"--test=20", ~"--test=30"]; - let opts = ~[optopt("test")]; - let rs = getopts(args, opts); - match rs { - Err(f) => check_fail_type(f, OptionDuplicated_), - _ => fail!() - } - } - - #[test] - fn test_optopt_short() { - let args = ~[~"-t", ~"20"]; - let opts = ~[optopt("t")]; - let rs = getopts(args, opts); - match rs { + let short_args = ~[~"-t", ~"20"]; + match getopts(short_args, opts) { Ok(ref m) => { + assert!((m.opt_present("test"))); + assert_eq!(m.opt_str("test").unwrap(), ~"20"); assert!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } @@ -1032,31 +943,39 @@ mod tests { } #[test] - fn test_optopt_short_missing() { + fn test_optopt_missing() { let args = ~[~"blah"]; - let opts = ~[optopt("t")]; + let opts = ~[optopt("t", "test", "testing", "TEST")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert!(!m.opt_present("t")), + Ok(ref m) => { + assert!(!m.opt_present("test")); + assert!(!m.opt_present("t")); + } _ => fail!() } } #[test] - fn test_optopt_short_no_arg() { - let args = ~[~"-t"]; - let opts = ~[optopt("t")]; - let rs = getopts(args, opts); + fn test_optopt_no_arg() { + let long_args = ~[~"--test"]; + let opts = ~[optopt("t", "test", "testing", "TEST")]; + let rs = getopts(long_args, opts); match rs { Err(f) => check_fail_type(f, ArgumentMissing_), _ => fail!() } + let short_args = ~[~"-t"]; + match getopts(short_args, opts) { + Err(f) => check_fail_type(f, ArgumentMissing_), + _ => fail!() + } } #[test] - fn test_optopt_short_multi() { - let args = ~[~"-t", ~"20", ~"-t", ~"30"]; - let opts = ~[optopt("t")]; + fn test_optopt_multi() { + let args = ~[~"--test=20", ~"-t", ~"30"]; + let opts = ~[optopt("t", "test", "testing", "TEST")]; let rs = getopts(args, opts); match rs { Err(f) => check_fail_type(f, OptionDuplicated_), @@ -1064,26 +983,39 @@ mod tests { } } - // Tests for optflag #[test] - fn test_optflag_long() { - let args = ~[~"--test"]; - let opts = ~[optflag("test")]; - let rs = getopts(args, opts); + fn test_optflag() { + let long_args = ~[~"--test"]; + let opts = ~[optflag("t", "test", "testing")]; + let rs = getopts(long_args, opts); match rs { - Ok(ref m) => assert!(m.opt_present("test")), + Ok(ref m) => { + assert!(m.opt_present("test")); + assert!(m.opt_present("t")); + } + _ => fail!() + } + let short_args = ~[~"-t"]; + match getopts(short_args, opts) { + Ok(ref m) => { + assert!(m.opt_present("test")); + assert!(m.opt_present("t")); + } _ => fail!() } } #[test] - fn test_optflag_long_missing() { + fn test_optflag_missing() { let args = ~[~"blah"]; - let opts = ~[optflag("test")]; + let opts = ~[optflag("t", "test", "testing")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert!(!m.opt_present("test")), + Ok(ref m) => { + assert!(!m.opt_present("test")); + assert!(!m.opt_present("t")); + } _ => fail!() } } @@ -1091,7 +1023,7 @@ mod tests { #[test] fn test_optflag_long_arg() { let args = ~[~"--test=20"]; - let opts = ~[optflag("test")]; + let opts = ~[optflag("t", "test", "testing")]; let rs = getopts(args, opts); match rs { Err(f) => { @@ -1103,9 +1035,9 @@ mod tests { } #[test] - fn test_optflag_long_multi() { - let args = ~[~"--test", ~"--test"]; - let opts = ~[optflag("test")]; + fn test_optflag_multi() { + let args = ~[~"--test", ~"-t"]; + let opts = ~[optflag("t", "test", "testing")]; let rs = getopts(args, opts); match rs { Err(f) => check_fail_type(f, OptionDuplicated_), @@ -1114,31 +1046,9 @@ mod tests { } #[test] - fn test_optflag_short() { - let args = ~[~"-t"]; - let opts = ~[optflag("t")]; - let rs = getopts(args, opts); - match rs { - Ok(ref m) => assert!(m.opt_present("t")), - _ => fail!() - } - } - - #[test] - fn test_optflag_short_missing() { - let args = ~[~"blah"]; - let opts = ~[optflag("t")]; - let rs = getopts(args, opts); - match rs { - Ok(ref m) => assert!(!m.opt_present("t")), - _ => fail!() - } - } - - #[test] fn test_optflag_short_arg() { let args = ~[~"-t", ~"20"]; - let opts = ~[optflag("t")]; + let opts = ~[optflag("t", "test", "testing")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { @@ -1150,22 +1060,11 @@ mod tests { } } - #[test] - fn test_optflag_short_multi() { - let args = ~[~"-t", ~"-t"]; - let opts = ~[optflag("t")]; - let rs = getopts(args, opts); - match rs { - Err(f) => check_fail_type(f, OptionDuplicated_), - _ => fail!() - } - } - // Tests for optflagmulti #[test] fn test_optflagmulti_short1() { let args = ~[~"-v"]; - let opts = ~[optflagmulti("v")]; + let opts = ~[optflagmulti("v", "verbose", "verbosity")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { @@ -1178,7 +1077,7 @@ mod tests { #[test] fn test_optflagmulti_short2a() { let args = ~[~"-v", ~"-v"]; - let opts = ~[optflagmulti("v")]; + let opts = ~[optflagmulti("v", "verbose", "verbosity")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { @@ -1191,7 +1090,7 @@ mod tests { #[test] fn test_optflagmulti_short2b() { let args = ~[~"-vv"]; - let opts = ~[optflagmulti("v")]; + let opts = ~[optflagmulti("v", "verbose", "verbosity")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { @@ -1204,7 +1103,7 @@ mod tests { #[test] fn test_optflagmulti_long1() { let args = ~[~"--verbose"]; - let opts = ~[optflagmulti("verbose")]; + let opts = ~[optflagmulti("v", "verbose", "verbosity")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { @@ -1217,7 +1116,7 @@ mod tests { #[test] fn test_optflagmulti_long2() { let args = ~[~"--verbose", ~"--verbose"]; - let opts = ~[optflagmulti("verbose")]; + let opts = ~[optflagmulti("v", "verbose", "verbosity")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { @@ -1227,67 +1126,40 @@ mod tests { } } - // Tests for optmulti #[test] - fn test_optmulti_long() { - let args = ~[~"--test=20"]; - let opts = ~[optmulti("test")]; + fn test_optflagmulti_mix() { + let args = ~[~"--verbose", ~"-v", ~"-vv", ~"verbose"]; + let opts = ~[optflagmulti("v", "verbose", "verbosity")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert!((m.opt_present("test"))); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); + assert_eq!(m.opt_count("verbose"), 4); + assert_eq!(m.opt_count("v"), 4); } _ => fail!() } } + // Tests for optmulti #[test] - fn test_optmulti_long_missing() { - let args = ~[~"blah"]; - let opts = ~[optmulti("test")]; - let rs = getopts(args, opts); - match rs { - Ok(ref m) => assert!(!m.opt_present("test")), - _ => fail!() - } - } - - #[test] - fn test_optmulti_long_no_arg() { - let args = ~[~"--test"]; - let opts = ~[optmulti("test")]; - let rs = getopts(args, opts); - match rs { - Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() - } - } - - #[test] - fn test_optmulti_long_multi() { - let args = ~[~"--test=20", ~"--test=30"]; - let opts = ~[optmulti("test")]; - let rs = getopts(args, opts); + fn test_optmulti() { + let long_args = ~[~"--test=20"]; + let opts = ~[optmulti("t", "test", "testing", "TEST")]; + let rs = getopts(long_args, opts); match rs { Ok(ref m) => { - assert!(m.opt_present("test")); - assert_eq!(m.opt_str("test").unwrap(), ~"20"); - let pair = m.opt_strs("test"); - assert!(pair[0] == ~"20"); - assert!(pair[1] == ~"30"); + assert!((m.opt_present("test"))); + assert_eq!(m.opt_str("test").unwrap(), ~"20"); + assert!((m.opt_present("t"))); + assert_eq!(m.opt_str("t").unwrap(), ~"20"); } _ => fail!() } - } - - #[test] - fn test_optmulti_short() { - let args = ~[~"-t", ~"20"]; - let opts = ~[optmulti("t")]; - let rs = getopts(args, opts); - match rs { + let short_args = ~[~"-t", ~"20"]; + match getopts(short_args, opts) { Ok(ref m) => { + assert!((m.opt_present("test"))); + assert_eq!(m.opt_str("test").unwrap(), ~"20"); assert!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), ~"20"); } @@ -1296,61 +1168,65 @@ mod tests { } #[test] - fn test_optmulti_short_missing() { + fn test_optmulti_missing() { let args = ~[~"blah"]; - let opts = ~[optmulti("t")]; + let opts = ~[optmulti("t", "test", "testing", "TEST")]; let rs = getopts(args, opts); match rs { - Ok(ref m) => assert!(!m.opt_present("t")), + Ok(ref m) => { + assert!(!m.opt_present("test")); + assert!(!m.opt_present("t")); + } _ => fail!() } } #[test] - fn test_optmulti_short_no_arg() { - let args = ~[~"-t"]; - let opts = ~[optmulti("t")]; - let rs = getopts(args, opts); + fn test_optmulti_no_arg() { + let long_args = ~[~"--test"]; + let opts = ~[optmulti("t", "test", "testing", "TEST")]; + let rs = getopts(long_args, opts); match rs { Err(f) => check_fail_type(f, ArgumentMissing_), _ => fail!() } + let short_args = ~[~"-t"]; + match getopts(short_args, opts) { + Err(f) => check_fail_type(f, ArgumentMissing_), + _ => fail!() + } } #[test] - fn test_optmulti_short_multi() { - let args = ~[~"-t", ~"20", ~"-t", ~"30"]; - let opts = ~[optmulti("t")]; + fn test_optmulti_multi() { + let args = ~[~"--test=20", ~"-t", ~"30"]; + let opts = ~[optmulti("t", "test", "testing", "TEST")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { - assert!((m.opt_present("t"))); - assert_eq!(m.opt_str("t").unwrap(), ~"20"); - let pair = m.opt_strs("t"); - assert!(pair[0] == ~"20"); - assert!(pair[1] == ~"30"); + assert!(m.opt_present("test")); + assert_eq!(m.opt_str("test").unwrap(), ~"20"); + assert!(m.opt_present("t")); + assert_eq!(m.opt_str("t").unwrap(), ~"20"); + let pair = m.opt_strs("test"); + assert!(pair[0] == ~"20"); + assert!(pair[1] == ~"30"); } _ => fail!() } } #[test] - fn test_unrecognized_option_long() { - let args = ~[~"--untest"]; - let opts = ~[optmulti("t")]; - let rs = getopts(args, opts); + fn test_unrecognized_option() { + let long_args = ~[~"--untest"]; + let opts = ~[optmulti("t", "test", "testing", "TEST")]; + let rs = getopts(long_args, opts); match rs { Err(f) => check_fail_type(f, UnrecognizedOption_), _ => fail!() } - } - - #[test] - fn test_unrecognized_option_short() { - let args = ~[~"-t"]; - let opts = ~[optmulti("test")]; - let rs = getopts(args, opts); - match rs { + let short_args = ~[~"-u"]; + match getopts(short_args, opts) { Err(f) => check_fail_type(f, UnrecognizedOption_), _ => fail!() } @@ -1363,9 +1239,13 @@ mod tests { ~"--flag", ~"--long=30", ~"-f", ~"-m", ~"40", ~"-m", ~"50", ~"-n", ~"-A B", ~"-n", ~"-60 70"]; let opts = - ~[optopt("s"), optflag("flag"), reqopt("long"), - optflag("f"), optmulti("m"), optmulti("n"), - optopt("notpresent")]; + ~[optopt("s", "something", "something", "SOMETHING"), + optflag("", "flag", "a flag"), + reqopt("", "long", "hi", "LONG"), + optflag("f", "", "another flag"), + optmulti("m", "", "mmmmmm", "YUM"), + optmulti("n", "", "nothing", "NOTHING"), + optopt("", "notpresent", "nothing to see here", "NOPE")]; let rs = getopts(args, opts); match rs { Ok(ref m) => { @@ -1390,7 +1270,9 @@ mod tests { #[test] fn test_multi() { - let opts = ~[optopt("e"), optopt("encrypt"), optopt("f")]; + let opts = ~[optopt("e", "", "encrypt", "ENCRYPT"), + optopt("", "encrypt", "encrypt", "ENCRYPT"), + optopt("f", "", "flag", "FLAG")]; let args_single = ~[~"-e", ~"foo"]; let matches_single = &match getopts(args_single, opts) { @@ -1430,7 +1312,8 @@ mod tests { #[test] fn test_nospace() { let args = ~[~"-Lfoo", ~"-M."]; - let opts = ~[optmulti("L"), optmulti("M")]; + let opts = ~[optmulti("L", "", "library directory", "LIB"), + optmulti("M", "", "something", "MMMM")]; let matches = &match getopts(args, opts) { result::Ok(m) => m, result::Err(_) => fail!() @@ -1443,125 +1326,42 @@ mod tests { } #[test] - fn test_groups_reqopt() { - let opt = groups::reqopt("b", "banana", "some bananas", "VAL"); - assert!(opt == OptGroup { short_name: ~"b", - long_name: ~"banana", - hint: ~"VAL", - desc: ~"some bananas", - hasarg: Yes, - occur: Req }) - } - - #[test] - fn test_groups_optopt() { - let opt = groups::optopt("a", "apple", "some apples", "VAL"); - assert!(opt == OptGroup { short_name: ~"a", - long_name: ~"apple", - hint: ~"VAL", - desc: ~"some apples", - hasarg: Yes, - occur: Optional }) - } - - #[test] - fn test_groups_optflag() { - let opt = groups::optflag("k", "kiwi", "some kiwis"); - assert!(opt == OptGroup { short_name: ~"k", - long_name: ~"kiwi", - hint: ~"", - desc: ~"some kiwis", - hasarg: No, - occur: Optional }) - } - - #[test] - fn test_groups_optflagopt() { - let opt = groups::optflagopt("p", "pineapple", "some pineapples", "VAL"); - assert!(opt == OptGroup { short_name: ~"p", - long_name: ~"pineapple", - hint: ~"VAL", - desc: ~"some pineapples", - hasarg: Maybe, - occur: Optional }) - } - - #[test] - fn test_groups_optmulti() { - let opt = groups::optmulti("l", "lime", "some limes", "VAL"); - assert!(opt == OptGroup { short_name: ~"l", - long_name: ~"lime", - hint: ~"VAL", - desc: ~"some limes", - hasarg: Yes, - occur: Multi }) - } - - #[test] - fn test_groups_long_to_short() { - let mut short = reqopt("banana"); - short.aliases = ~[reqopt("b")]; - let verbose = groups::reqopt("b", "banana", "some bananas", "VAL"); + fn test_long_to_short() { + let mut short = Opt { name: Long(~"banana"), + hasarg: Yes, + occur: Req, + aliases: ~[] }; + short.aliases = ~[Opt { name: Short('b'), + hasarg: Yes, + occur: Req, + aliases: ~[] }]; + let verbose = reqopt("b", "banana", "some bananas", "VAL"); assert_eq!(verbose.long_to_short(), short); } #[test] - fn test_groups_getopts() { - let mut banana = reqopt("banana"); - banana.aliases = ~[reqopt("b")]; - let mut apple = optopt("apple"); - apple.aliases = ~[optopt("a")]; - let mut kiwi = optflag("kiwi"); - kiwi.aliases = ~[optflag("k")]; - let short = ~[ - banana, - apple, - kiwi, - optflagopt("p"), - optmulti("l") - ]; - - // short and verbose should always be in the same order. if they - // aren't the test will fail (and in mysterious ways) - - let verbose = ~[ - groups::reqopt("b", "banana", "Desc", "VAL"), - groups::optopt("a", "apple", "Desc", "VAL"), - groups::optflag("k", "kiwi", "Desc"), - groups::optflagopt("p", "", "Desc", "VAL"), - groups::optmulti("l", "", "Desc", "VAL"), - ]; - - let sample_args = ~[~"--kiwi", ~"15", ~"--apple", ~"1", ~"k", - ~"-p", ~"16", ~"l", ~"35"]; - - assert!(getopts(sample_args, short) - == groups::getopts(sample_args, verbose)); - } - - #[test] - fn test_groups_aliases_long_and_short() { + fn test_aliases_long_and_short() { let opts = ~[ - groups::optflagmulti("a", "apple", "Desc"), + optflagmulti("a", "apple", "Desc"), ]; let args = ~[~"-a", ~"--apple", ~"-a"]; - let matches = groups::getopts(args, opts).unwrap(); + let matches = getopts(args, opts).unwrap(); assert_eq!(3, matches.opt_count("a")); assert_eq!(3, matches.opt_count("apple")); } #[test] - fn test_groups_usage() { + fn test_usage() { let optgroups = ~[ - groups::reqopt("b", "banana", "Desc", "VAL"), - groups::optopt("a", "012345678901234567890123456789", + reqopt("b", "banana", "Desc", "VAL"), + optopt("a", "012345678901234567890123456789", "Desc", "VAL"), - groups::optflag("k", "kiwi", "Desc"), - groups::optflagopt("p", "", "Desc", "VAL"), - groups::optmulti("l", "", "Desc", "VAL"), + optflag("k", "kiwi", "Desc"), + optflagopt("p", "", "Desc", "VAL"), + optmulti("l", "", "Desc", "VAL"), ]; let expected = @@ -1576,7 +1376,7 @@ Options: -l VAL Desc "; - let generated_usage = groups::usage("Usage: fruits", optgroups); + let generated_usage = usage("Usage: fruits", optgroups); debug!("expected: <<{}>>", expected); debug!("generated: <<{}>>", generated_usage); @@ -1584,14 +1384,14 @@ Options: } #[test] - fn test_groups_usage_description_wrapping() { + fn test_usage_description_wrapping() { // indentation should be 24 spaces // lines wrap after 78: or rather descriptions wrap after 54 let optgroups = ~[ - groups::optflag("k", "kiwi", + optflag("k", "kiwi", "This is a long description which won't be wrapped..+.."), // 54 - groups::optflag("a", "apple", + optflag("a", "apple", "This is a long description which _will_ be wrapped..+.."), // 55 ]; @@ -1604,7 +1404,7 @@ Options: wrapped..+.. "; - let usage = groups::usage("Usage: fruits", optgroups); + let usage = usage("Usage: fruits", optgroups); debug!("expected: <<{}>>", expected); debug!("generated: <<{}>>", usage); @@ -1612,11 +1412,11 @@ Options: } #[test] - fn test_groups_usage_description_multibyte_handling() { + fn test_usage_description_multibyte_handling() { let optgroups = ~[ - groups::optflag("k", "k\u2013w\u2013", + optflag("k", "k\u2013w\u2013", "The word kiwi is normally spelled with two i's"), - groups::optflag("a", "apple", + optflag("a", "apple", "This \u201Cdescription\u201D has some characters that could \ confuse the line wrapping; an apple costs 0.51€ in some parts of Europe."), ]; @@ -1631,10 +1431,29 @@ Options: some parts of Europe. "; - let usage = groups::usage("Usage: fruits", optgroups); + let usage = usage("Usage: fruits", optgroups); debug!("expected: <<{}>>", expected); debug!("generated: <<{}>>", usage); assert!(usage == expected) } + + #[test] + fn test_short_usage() { + let optgroups = ~[ + reqopt("b", "banana", "Desc", "VAL"), + optopt("a", "012345678901234567890123456789", + "Desc", "VAL"), + optflag("k", "kiwi", "Desc"), + optflagopt("p", "", "Desc", "VAL"), + optmulti("l", "", "Desc", "VAL"), + ]; + + let expected = ~"Usage: fruits -b VAL [-a VAL] [-k] [-p [VAL]] [-l VAL].."; + let generated_usage = short_usage("fruits", optgroups); + + debug!("expected: <<{}>>", expected); + debug!("generated: <<{}>>", generated_usage); + assert_eq!(generated_usage, expected); + } } diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index f8d629589fc..c5b221d2272 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -12,10 +12,156 @@ //! //! This library provides M:N threading for rust programs. Internally this has //! the implementation of a green scheduler along with context switching and a -//! stack-allocation strategy. +//! stack-allocation strategy. This can be optionally linked in to rust +//! programs in order to provide M:N functionality inside of 1:1 programs. //! -//! This can be optionally linked in to rust programs in order to provide M:N -//! functionality inside of 1:1 programs. +//! # Architecture +//! +//! An M:N scheduling library implies that there are N OS thread upon which M +//! "green threads" are multiplexed. In other words, a set of green threads are +//! all run inside a pool of OS threads. +//! +//! With this design, you can achieve _concurrency_ by spawning many green +//! threads, and you can achieve _parallelism_ by running the green threads +//! simultaneously on multiple OS threads. Each OS thread is a candidate for +//! being scheduled on a different core (the source of parallelism), and then +//! all of the green threads cooperatively schedule amongst one another (the +//! source of concurrency). +//! +//! ## Schedulers +//! +//! In order to coordinate among green threads, each OS thread is primarily +//! running something which we call a Scheduler. Whenever a reference to a +//! Scheduler is made, it is synonymous to referencing one OS thread. Each +//! scheduler is bound to one and exactly one OS thread, and the thread that it +//! is bound to never changes. +//! +//! Each scheduler is connected to a pool of other schedulers (a `SchedPool`) +//! which is the thread pool term from above. A pool of schedulers all share the +//! work that they create. Furthermore, whenever a green thread is created (also +//! synonymously referred to as a green task), it is associated with a +//! `SchedPool` forevermore. A green thread cannot leave its scheduler pool. +//! +//! Schedulers can have at most one green thread running on them at a time. When +//! a scheduler is asleep on its event loop, there are no green tasks running on +//! the OS thread or the scheduler. The term "context switch" is used for when +//! the running green thread is swapped out, but this simply changes the one +//! green thread which is running on the scheduler. +//! +//! ## Green Threads +//! +//! A green thread can largely be summarized by a stack and a register context. +//! Whenever a green thread is spawned, it allocates a stack, and then prepares +//! a register context for execution. The green task may be executed across +//! multiple OS threads, but it will always use the same stack and it will carry +//! its register context across OS threads. +//! +//! Each green thread is cooperatively scheduled with other green threads. +//! Primarily, this means that there is no pre-emption of a green thread. The +//! major consequence of this design is that a green thread stuck in an infinite +//! loop will prevent all other green threads from running on that particular +//! scheduler. +//! +//! Scheduling events for green threads occur on communication and I/O +//! boundaries. For example, if a green task blocks waiting for a message on a +//! channel some other green thread can now run on the scheduler. This also has +//! the consequence that until a green thread performs any form of scheduling +//! event, it will be running on the same OS thread (unconditionally). +//! +//! ## Work Stealing +//! +//! With a pool of schedulers, a new green task has a number of options when +//! deciding where to run initially. The current implementation uses a concept +//! called work stealing in order to spread out work among schedulers. +//! +//! In a work-stealing model, each scheduler maintains a local queue of tasks to +//! run, and this queue is stolen from by other schedulers. Implementation-wise, +//! work stealing has some hairy parts, but from a user-perspective, work +//! stealing simply implies what with M green threads and N schedulers where +//! M > N it is very likely that all schedulers will be busy executing work. +//! +//! # Considerations when using libgreen +//! +//! An M:N runtime has both pros and cons, and there is no one answer as to +//! whether M:N or 1:1 is appropriate to use. As always, there are many +//! advantages and disadvantages between the two. Regardless of the workload, +//! however, there are some aspects of using green thread which you should be +//! aware of: +//! +//! * The largest concern when using libgreen is interoperating with native +//! code. Care should be taken when calling native code that will block the OS +//! thread as it will prevent further green tasks from being scheduled on the +//! OS thread. +//! +//! * Native code using thread-local-storage should be approached +//! with care. Green threads may migrate among OS threads at any time, so +//! native libraries using thread-local state may not always work. +//! +//! * Native synchronization primitives (e.g. pthread mutexes) will also not +//! work for green threads. The reason for this is because native primitives +//! often operate on a _os thread_ granularity whereas green threads are +//! operating on a more granular unit of work. +//! +//! * A green threading runtime is not fork-safe. If the process forks(), it +//! cannot expect to make reasonable progress by continuing to use green +//! threads. +//! +//! Note that these concerns do not mean that operating with native code is a +//! lost cause. These are simply just concerns which should be considered when +//! invoking native code. +//! +//! # Starting with libgreen +//! +//! ```rust +//! extern mod green; +//! +//! #[start] +//! fn start(argc: int, argv: **u8) -> int { green::start(argc, argv, main) } +//! +//! fn main() { +//! // this code is running in a pool of schedulers +//! } +//! ``` +//! +//! # Using a scheduler pool +//! +//! ```rust +//! use std::task::TaskOpts; +//! use green::{SchedPool, PoolConfig}; +//! use green::sched::{PinnedTask, TaskFromFriend}; +//! +//! let config = PoolConfig::new(); +//! let mut pool = SchedPool::new(config); +//! +//! // Spawn tasks into the pool of schedulers +//! pool.spawn(TaskOpts::new(), proc() { +//! // this code is running inside the pool of schedulers +//! +//! spawn(proc() { +//! // this code is also running inside the same scheduler pool +//! }); +//! }); +//! +//! // Dynamically add a new scheduler to the scheduler pool. This adds another +//! // OS thread that green threads can be multiplexed on to. +//! let mut handle = pool.spawn_sched(); +//! +//! // Pin a task to the spawned scheduler +//! let task = pool.task(TaskOpts::new(), proc() { /* ... */ }); +//! handle.send(PinnedTask(task)); +//! +//! // Schedule a task on this new scheduler +//! let task = pool.task(TaskOpts::new(), proc() { /* ... */ }); +//! handle.send(TaskFromFriend(task)); +//! +//! // Handles keep schedulers alive, so be sure to drop all handles before +//! // destroying the sched pool +//! drop(handle); +//! +//! // Required to shut down this scheduler pool. +//! // The task will fail if `shutdown` is not called. +//! pool.shutdown(); +//! ``` #[crate_id = "green#0.10-pre"]; #[license = "MIT/ASL2"]; @@ -111,7 +257,7 @@ pub fn run(main: proc()) -> int { let (port, chan) = Chan::new(); let mut opts = TaskOpts::new(); opts.notify_chan = Some(chan); - opts.name = Some(SendStrStatic("<main>")); + opts.name = Some("<main>".into_maybe_owned()); pool.spawn(opts, main); // Wait for the main task to return, and set the process error code diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index 4fb61f15680..e492acb4468 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -510,7 +510,7 @@ mod tests { #[test] fn smoke_opts() { let mut opts = TaskOpts::new(); - opts.name = Some(SendStrStatic("test")); + opts.name = Some("test".into_maybe_owned()); opts.stack_size = Some(20 * 4096); let (p, c) = Chan::new(); opts.notify_chan = Some(c); diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index 1e4317af397..4840c561289 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -8,11 +8,38 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! The native runtime crate +//! The native I/O and threading crate //! //! This crate contains an implementation of 1:1 scheduling for a "native" //! runtime. In addition, all I/O provided by this crate is the thread blocking //! version of I/O. +//! +//! # Starting with libnative +//! +//! ```rust +//! extern mod native; +//! +//! #[start] +//! fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) } +//! +//! fn main() { +//! // this code is running on the main OS thread +//! } +//! ``` +//! +//! # Force spawning a native task +//! +//! ```rust +//! extern mod native; +//! +//! fn main() { +//! // We're not sure whether this main function is run in 1:1 or M:N mode. +//! +//! native::task::spawn(proc() { +//! // this code is guaranteed to be run on a native thread +//! }); +//! } +//! ``` #[crate_id = "native#0.10-pre"]; #[license = "MIT/ASL2"]; diff --git a/src/libnative/task.rs b/src/libnative/task.rs index c08e326d903..d0ca8364aa7 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -294,7 +294,7 @@ mod tests { #[test] fn smoke_opts() { let mut opts = TaskOpts::new(); - opts.name = Some(SendStrStatic("test")); + opts.name = Some("test".into_maybe_owned()); opts.stack_size = Some(20 * 4096); let (p, c) = Chan::new(); opts.notify_chan = Some(c); diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index aea9b65087d..531b8bf9034 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -11,7 +11,7 @@ use back::archive::{Archive, METADATA_FILENAME}; use back::rpath; -use driver::driver::CrateTranslation; +use driver::driver::{CrateTranslation, OutputFilenames}; use driver::session::Session; use driver::session; use lib::llvm::llvm; @@ -44,9 +44,8 @@ use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::crateid::CrateId; -#[deriving(Clone, Eq)] +#[deriving(Clone, Eq, TotalOrd, TotalEq)] pub enum OutputType { - OutputTypeNone, OutputTypeBitcode, OutputTypeAssembly, OutputTypeLlvmAssembly, @@ -77,7 +76,7 @@ pub fn WriteOutputFile( let result = llvm::LLVMRustWriteOutputFile( Target, PM, M, Output, FileType); if !result { - llvm_err(sess, ~"Could not write output"); + llvm_err(sess, ~"could not write output"); } }) } @@ -90,7 +89,7 @@ pub mod write { use back::link::{OutputTypeAssembly, OutputTypeBitcode}; use back::link::{OutputTypeExe, OutputTypeLlvmAssembly}; use back::link::{OutputTypeObject}; - use driver::driver::CrateTranslation; + use driver::driver::{CrateTranslation, OutputFilenames}; use driver::session::Session; use driver::session; use lib::llvm::llvm; @@ -101,7 +100,6 @@ pub mod write { use std::c_str::ToCStr; use std::libc::{c_uint, c_int}; - use std::path::Path; use std::run; use std::str; @@ -125,8 +123,8 @@ pub mod write { pub fn run_passes(sess: Session, trans: &CrateTranslation, - output_type: OutputType, - output: &Path) { + output_types: &[OutputType], + output: &OutputFilenames) { let llmod = trans.module; let llcx = trans.context; unsafe { @@ -191,7 +189,7 @@ pub mod write { for pass in sess.opts.custom_passes.iter() { pass.with_c_str(|s| { if !llvm::LLVMRustAddPass(mpm, s) { - sess.warn(format!("Unknown pass {}, ignoring", *pass)); + sess.warn(format!("unknown pass {}, ignoring", *pass)); } }) } @@ -209,10 +207,11 @@ pub mod write { // Emit the bytecode if we're either saving our temporaries or // emitting an rlib. Whenever an rlib is created, the bytecode is // inserted into the archive in order to allow LTO against it. - let outputs = sess.outputs.borrow(); + let crate_types = sess.crate_types.borrow(); if sess.opts.save_temps || - outputs.get().iter().any(|&o| o == session::OutputRlib) { - output.with_extension("bc").with_c_str(|buf| { + (crate_types.get().contains(&session::CrateTypeRlib) && + sess.opts.output_types.contains(&OutputTypeExe)) { + output.temp_path(OutputTypeBitcode).with_c_str(|buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf); }) } @@ -247,52 +246,68 @@ pub mod write { } } - time(sess.time_passes(), "codegen passes", (), |()| { - match output_type { - OutputTypeNone => {} + let mut object_file = None; + let mut needs_metadata = false; + for output_type in output_types.iter() { + let path = output.path(*output_type); + match *output_type { OutputTypeBitcode => { - output.with_c_str(|buf| { + path.with_c_str(|buf| { llvm::LLVMWriteBitcodeToFile(llmod, buf); }) } OutputTypeLlvmAssembly => { - output.with_c_str(|output| { + path.with_c_str(|output| { with_codegen(tm, llmod, |cpm| { llvm::LLVMRustPrintModule(cpm, llmod, output); }) }) } OutputTypeAssembly => { - with_codegen(tm, llmod, |cpm| { - WriteOutputFile(sess, tm, cpm, llmod, output, - lib::llvm::AssemblyFile); - }); - // If we're not using the LLVM assembler, this function // could be invoked specially with output_type_assembly, // so in this case we still want the metadata object // file. - if sess.opts.output_type != OutputTypeAssembly { - with_codegen(tm, trans.metadata_module, |cpm| { - let out = output.with_extension("metadata.o"); - WriteOutputFile(sess, tm, cpm, - trans.metadata_module, &out, - lib::llvm::ObjectFile); - }) - } + let ty = OutputTypeAssembly; + let path = if sess.opts.output_types.contains(&ty) { + path + } else { + needs_metadata = true; + output.temp_path(OutputTypeAssembly) + }; + with_codegen(tm, llmod, |cpm| { + WriteOutputFile(sess, tm, cpm, llmod, &path, + lib::llvm::AssemblyFile); + }); + } + OutputTypeObject => { + object_file = Some(path); } - OutputTypeExe | OutputTypeObject => { + OutputTypeExe => { + object_file = Some(output.temp_path(OutputTypeObject)); + needs_metadata = true; + } + } + } + + time(sess.time_passes(), "codegen passes", (), |()| { + match object_file { + Some(ref path) => { with_codegen(tm, llmod, |cpm| { - WriteOutputFile(sess, tm, cpm, llmod, output, + WriteOutputFile(sess, tm, cpm, llmod, path, lib::llvm::ObjectFile); }); - with_codegen(tm, trans.metadata_module, |cpm| { - let out = output.with_extension("metadata.o"); - WriteOutputFile(sess, tm, cpm, - trans.metadata_module, &out, - lib::llvm::ObjectFile); - }) } + None => {} + } + if needs_metadata { + with_codegen(tm, trans.metadata_module, |cpm| { + let out = output.temp_path(OutputTypeObject) + .with_extension("metadata.o"); + WriteOutputFile(sess, tm, cpm, + trans.metadata_module, &out, + lib::llvm::ObjectFile); + }) } }); @@ -304,8 +319,10 @@ pub mod write { } } - pub fn run_assembler(sess: Session, assembly: &Path, object: &Path) { + pub fn run_assembler(sess: Session, outputs: &OutputFilenames) { let cc = super::get_cc_prog(sess); + let assembly = outputs.temp_path(OutputTypeAssembly); + let object = outputs.path(OutputTypeObject); // FIXME (#9639): This needs to handle non-utf8 paths let args = [ @@ -480,9 +497,8 @@ pub mod write { * system linkers understand. */ -pub fn build_link_meta(sess: Session, - attrs: &[ast::Attribute], - output: &Path, +pub fn build_link_meta(attrs: &[ast::Attribute], + output: &OutputFilenames, symbol_hasher: &mut Sha256) -> LinkMeta { // This calculates CMH as defined above @@ -493,14 +509,7 @@ pub fn build_link_meta(sess: Session, } let crateid = match attr::find_crateid(attrs) { - None => { - let stem = session::expect( - sess, - output.filestem_str(), - || format!("output file name '{}' doesn't appear to have a stem", - output.display())); - from_str(stem).unwrap() - } + None => from_str(output.out_filestem).unwrap(), Some(s) => s, }; @@ -794,20 +803,21 @@ fn remove(sess: Session, path: &Path) { /// of the requested outputs for this compilation session. pub fn link_binary(sess: Session, trans: &CrateTranslation, - obj_filename: &Path, - out_filename: &Path, + outputs: &OutputFilenames, lm: &LinkMeta) -> ~[Path] { let mut out_filenames = ~[]; - let outputs = sess.outputs.borrow(); - for &output in outputs.get().iter() { - let out_file = link_binary_output(sess, trans, output, obj_filename, - out_filename, lm); + let crate_types = sess.crate_types.borrow(); + for &crate_type in crate_types.get().iter() { + let out_file = link_binary_output(sess, trans, crate_type, outputs, lm); out_filenames.push(out_file); } // Remove the temporary object file and metadata if we aren't saving temps if !sess.opts.save_temps { - remove(sess, obj_filename); + let obj_filename = outputs.temp_path(OutputTypeObject); + if !sess.opts.output_types.contains(&OutputTypeObject) { + remove(sess, &obj_filename); + } remove(sess, &obj_filename.with_extension("metadata.o")); } @@ -821,14 +831,14 @@ fn is_writeable(p: &Path) -> bool { } } -pub fn filename_for_input(sess: &Session, output: session::OutputStyle, lm: &LinkMeta, - out_filename: &Path) -> Path { +pub fn filename_for_input(sess: &Session, crate_type: session::CrateType, + lm: &LinkMeta, out_filename: &Path) -> Path { let libname = output_lib_filename(lm); - match output { - session::OutputRlib => { + match crate_type { + session::CrateTypeRlib => { out_filename.with_filename(format!("lib{}.rlib", libname)) } - session::OutputDylib => { + session::CrateTypeDylib => { let (prefix, suffix) = match sess.targ_cfg.os { abi::OsWin32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX), abi::OsMacos => (macos::DLL_PREFIX, macos::DLL_SUFFIX), @@ -838,49 +848,54 @@ pub fn filename_for_input(sess: &Session, output: session::OutputStyle, lm: &Lin }; out_filename.with_filename(format!("{}{}{}", prefix, libname, suffix)) } - session::OutputStaticlib => { + session::CrateTypeStaticlib => { out_filename.with_filename(format!("lib{}.a", libname)) } - session::OutputExecutable => out_filename.clone(), + session::CrateTypeExecutable => out_filename.clone(), } - } fn link_binary_output(sess: Session, trans: &CrateTranslation, - output: session::OutputStyle, - obj_filename: &Path, - out_filename: &Path, + crate_type: session::CrateType, + outputs: &OutputFilenames, lm: &LinkMeta) -> Path { - let out_filename = filename_for_input(&sess, output, lm, out_filename); + let obj_filename = outputs.temp_path(OutputTypeObject); + let out_filename = match outputs.single_output_file { + Some(ref file) => file.clone(), + None => { + let out_filename = outputs.path(OutputTypeExe); + filename_for_input(&sess, crate_type, lm, &out_filename) + } + }; // Make sure the output and obj_filename are both writeable. // Mac, FreeBSD, and Windows system linkers check this already -- // however, the Linux linker will happily overwrite a read-only file. // We should be consistent. - let obj_is_writeable = is_writeable(obj_filename); + let obj_is_writeable = is_writeable(&obj_filename); let out_is_writeable = is_writeable(&out_filename); if !out_is_writeable { - sess.fatal(format!("Output file {} is not writeable -- check its permissions.", + sess.fatal(format!("output file {} is not writeable -- check its permissions.", out_filename.display())); } else if !obj_is_writeable { - sess.fatal(format!("Object file {} is not writeable -- check its permissions.", + sess.fatal(format!("object file {} is not writeable -- check its permissions.", obj_filename.display())); } - match output { - session::OutputRlib => { - link_rlib(sess, Some(trans), obj_filename, &out_filename); + match crate_type { + session::CrateTypeRlib => { + link_rlib(sess, Some(trans), &obj_filename, &out_filename); } - session::OutputStaticlib => { - link_staticlib(sess, obj_filename, &out_filename); + session::CrateTypeStaticlib => { + link_staticlib(sess, &obj_filename, &out_filename); } - session::OutputExecutable => { - link_natively(sess, false, obj_filename, &out_filename); + session::CrateTypeExecutable => { + link_natively(sess, false, &obj_filename, &out_filename); } - session::OutputDylib => { - link_natively(sess, true, obj_filename, &out_filename); + session::CrateTypeDylib => { + link_natively(sess, true, &obj_filename, &out_filename); } } @@ -954,7 +969,8 @@ fn link_rlib(sess: Session, // into the archive. let bc = obj_filename.with_extension("bc"); a.add_file(&bc, false); - if !sess.opts.save_temps { + if !sess.opts.save_temps && + !sess.opts.output_types.contains(&OutputTypeBitcode) { remove(sess, &bc); } diff --git a/src/librustc/back/lto.rs b/src/librustc/back/lto.rs index 3fbcd377b8b..3c7d804435f 100644 --- a/src/librustc/back/lto.rs +++ b/src/librustc/back/lto.rs @@ -26,10 +26,10 @@ pub fn run(sess: session::Session, llmod: ModuleRef, } // Make sure we actually can run LTO - let outputs = sess.outputs.borrow(); - for output in outputs.get().iter() { - match *output { - session::OutputExecutable | session::OutputStaticlib => {} + let crate_types = sess.crate_types.borrow(); + for crate_type in crate_types.get().iter() { + match *crate_type { + session::CrateTypeExecutable | session::CrateTypeStaticlib => {} _ => { sess.fatal("lto can only be run for executables and \ static library outputs"); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index a61c297956d..0d45d5bdbab 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -11,7 +11,7 @@ use back::link; use back::{arm, x86, x86_64, mips}; -use driver::session::{Aggressive, OutputExecutable}; +use driver::session::{Aggressive, CrateTypeExecutable}; use driver::session::{Session, Session_, No, Less, Default}; use driver::session; use front; @@ -34,14 +34,15 @@ use std::io::fs; use std::io::MemReader; use std::os; use std::vec; -use extra::getopts::groups::{optopt, optmulti, optflag, optflagopt}; -use extra::getopts; +use getopts::{optopt, optmulti, optflag, optflagopt}; +use getopts; use syntax::ast; use syntax::abi; use syntax::attr; use syntax::attr::{AttrMetaMethods}; use syntax::codemap; use syntax::diagnostic; +use syntax::diagnostic::Emitter; use syntax::ext::base::CrateLoader; use syntax::parse; use syntax::parse::token::InternedString; @@ -136,10 +137,10 @@ pub fn build_configuration(sess: Session) -> } // Convert strings provided as --cfg [cfgspec] into a crate_cfg -fn parse_cfgspecs(cfgspecs: ~[~str], demitter: @diagnostic::Emitter) +fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::CrateConfig { cfgspecs.move_iter().map(|s| { - let sess = parse::new_parse_sess(Some(demitter)); + let sess = parse::new_parse_sess(); parse::parse_meta_from_source_str("cfgspec".to_str(), s, ~[], sess) }).collect::<ast::CrateConfig>() } @@ -176,14 +177,13 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input) /// harness if one is to be provided and injection of a dependency on the /// standard library and prelude. pub fn phase_2_configure_and_expand(sess: Session, - cfg: ast::CrateConfig, loader: &mut CrateLoader, mut crate: ast::Crate) -> (ast::Crate, syntax::ast_map::Map) { let time_passes = sess.time_passes(); sess.building_library.set(session::building_library(sess.opts, &crate)); - sess.outputs.set(session::collect_outputs(&sess, crate.attrs)); + sess.crate_types.set(session::collect_crate_types(&sess, crate.attrs)); time(time_passes, "gated feature checking", (), |_| front::feature_gate::check_crate(sess, &crate)); @@ -205,7 +205,6 @@ pub fn phase_2_configure_and_expand(sess: Session, crate = time(time_passes, "expansion", crate, |crate| { syntax::ext::expand::expand_crate(sess.parse_sess, loader, - cfg.clone(), crate) }); // dump the syntax-time crates @@ -375,8 +374,7 @@ pub fn phase_4_translate_to_llvm(sess: Session, analysis: &CrateAnalysis, outputs: &OutputFilenames) -> CrateTranslation { time(sess.time_passes(), "translation", crate, |crate| - trans::base::trans_crate(sess, crate, analysis, - &outputs.obj_filename)) + trans::base::trans_crate(sess, crate, analysis, outputs)) } /// Run LLVM itself, producing a bitcode file, assembly file or object file @@ -384,29 +382,24 @@ pub fn phase_4_translate_to_llvm(sess: Session, pub fn phase_5_run_llvm_passes(sess: Session, trans: &CrateTranslation, outputs: &OutputFilenames) { - if sess.no_integrated_as() { let output_type = link::OutputTypeAssembly; - let asm_filename = outputs.obj_filename.with_extension("s"); time(sess.time_passes(), "LLVM passes", (), |_| - link::write::run_passes(sess, - trans, - output_type, - &asm_filename)); + link::write::run_passes(sess, trans, [output_type], outputs)); - link::write::run_assembler(sess, &asm_filename, &outputs.obj_filename); + link::write::run_assembler(sess, outputs); // Remove assembly source, unless --save-temps was specified if !sess.opts.save_temps { - fs::unlink(&asm_filename).unwrap(); + fs::unlink(&outputs.temp_path(link::OutputTypeAssembly)).unwrap(); } } else { time(sess.time_passes(), "LLVM passes", (), |_| link::write::run_passes(sess, trans, - sess.opts.output_type, - &outputs.obj_filename)); + sess.opts.output_types, + outputs)); } } @@ -418,8 +411,7 @@ pub fn phase_6_link_output(sess: Session, time(sess.time_passes(), "linking", (), |_| link::link_binary(sess, trans, - &outputs.obj_filename, - &outputs.out_filename, + outputs, &trans.link)); } @@ -448,24 +440,34 @@ pub fn stop_after_phase_2(sess: Session) -> bool { } pub fn stop_after_phase_5(sess: Session) -> bool { - if sess.opts.output_type != link::OutputTypeExe { + if !sess.opts.output_types.iter().any(|&i| i == link::OutputTypeExe) { debug!("not building executable, returning early from compile_input"); return true; } return false; } -fn write_out_deps(sess: Session, input: &Input, outputs: &OutputFilenames, - crate: &ast::Crate) -> io::IoResult<()> -{ - let lm = link::build_link_meta(sess, crate.attrs, &outputs.obj_filename, +fn write_out_deps(sess: Session, + input: &Input, + outputs: &OutputFilenames, + crate: &ast::Crate) -> io::IoResult<()> { + let lm = link::build_link_meta(crate.attrs, outputs, &mut ::util::sha2::Sha256::new()); - let sess_outputs = sess.outputs.borrow(); - let out_filenames = sess_outputs.get().iter() - .map(|&output| link::filename_for_input(&sess, output, &lm, - &outputs.out_filename)) - .to_owned_vec(); + let mut out_filenames = ~[]; + for output_type in sess.opts.output_types.iter() { + let file = outputs.path(*output_type); + match *output_type { + link::OutputTypeExe => { + let crate_types = sess.crate_types.borrow(); + for output in crate_types.get().iter() { + let p = link::filename_for_input(&sess, *output, &lm, &file); + out_filenames.push(p); + } + } + _ => { out_filenames.push(file); } + } + } // Write out dependency rules to the dep-info file if requested with // --dep-info @@ -475,12 +477,7 @@ fn write_out_deps(sess: Session, input: &Input, outputs: &OutputFilenames, // Use default filename: crate source filename with extension replaced // by ".d" (true, None) => match *input { - FileInput(ref input_path) => { - let filestem = input_path.filestem().expect("input file must \ - have stem"); - let filename = out_filenames[0].dir_path().join(filestem); - filename.with_extension("d") - }, + FileInput(..) => outputs.with_extension("d"), StrInput(..) => { sess.warn("can not write --dep-info without a filename \ when compiling stdin."); @@ -520,32 +517,34 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input, // possible to keep the peak memory usage low let (outputs, trans) = { let (expanded_crate, ast_map) = { - let crate = phase_1_parse_input(sess, cfg.clone(), input); + let crate = phase_1_parse_input(sess, cfg, input); + if sess.show_span() { + front::show_span::run(sess, &crate); + return; + } if stop_after_phase_1(sess) { return; } let loader = &mut Loader::new(sess); - phase_2_configure_and_expand(sess, cfg, loader, crate) + phase_2_configure_and_expand(sess, loader, crate) }; let outputs = build_output_filenames(input, outdir, output, expanded_crate.attrs, sess); - write_out_deps(sess, input, outputs, &expanded_crate).unwrap(); + write_out_deps(sess, input, &outputs, &expanded_crate).unwrap(); if stop_after_phase_2(sess) { return; } let analysis = phase_3_run_analysis_passes(sess, &expanded_crate, ast_map); if stop_after_phase_3(sess) { return; } let trans = phase_4_translate_to_llvm(sess, expanded_crate, - &analysis, outputs); + &analysis, &outputs); (outputs, trans) }; - phase_5_run_llvm_passes(sess, &trans, outputs); + phase_5_run_llvm_passes(sess, &trans, &outputs); if stop_after_phase_5(sess) { return; } - phase_6_link_output(sess, &trans, outputs); + phase_6_link_output(sess, &trans, &outputs); } -struct IdentifiedAnnotation { - contents: (), -} +struct IdentifiedAnnotation; impl pprust::PpAnn for IdentifiedAnnotation { fn pre(&self, node: pprust::AnnNode) -> io::IoResult<()> { @@ -610,12 +609,12 @@ pub fn pretty_print_input(sess: Session, cfg: ast::CrateConfig, input: &Input, ppm: PpMode) { - let crate = phase_1_parse_input(sess, cfg.clone(), input); + let crate = phase_1_parse_input(sess, cfg, input); let (crate, ast_map, is_expanded) = match ppm { PpmExpanded | PpmExpandedIdentified | PpmTyped => { let loader = &mut Loader::new(sess); - let (crate, ast_map) = phase_2_configure_and_expand(sess, cfg, loader, crate); + let (crate, ast_map) = phase_2_configure_and_expand(sess, loader, crate); (crate, Some(ast_map), true) } _ => (crate, None, false) @@ -623,18 +622,16 @@ pub fn pretty_print_input(sess: Session, let annotation = match ppm { PpmIdentified | PpmExpandedIdentified => { - @IdentifiedAnnotation { - contents: (), - } as @pprust::PpAnn + ~IdentifiedAnnotation as ~pprust::PpAnn } PpmTyped => { let ast_map = ast_map.expect("--pretty=typed missing ast_map"); let analysis = phase_3_run_analysis_passes(sess, &crate, ast_map); - @TypedAnnotation { + ~TypedAnnotation { analysis: analysis - } as @pprust::PpAnn + } as ~pprust::PpAnn: } - _ => @pprust::NoAnn as @pprust::PpAnn, + _ => ~pprust::NoAnn as ~pprust::PpAnn:, }; let src = &sess.codemap.get_filemap(source_name(input)).src; @@ -686,17 +683,15 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat ("mips", abi::Mips)]; -pub fn build_target_config(sopts: @session::Options, - demitter: @diagnostic::Emitter) +pub fn build_target_config(sopts: @session::Options) -> @session::Config { let os = match get_os(sopts.target_triple) { Some(os) => os, - None => early_error(demitter, "unknown operating system") + None => early_error("unknown operating system") }; let arch = match get_arch(sopts.target_triple) { Some(arch) => arch, - None => early_error(demitter, - "unknown architecture: " + sopts.target_triple) + None => early_error("unknown architecture: " + sopts.target_triple) }; let (int_type, uint_type) = match arch { abi::X86 => (ast::TyI32, ast::TyU32), @@ -734,25 +729,20 @@ pub fn host_triple() -> ~str { } pub fn build_session_options(binary: ~str, - matches: &getopts::Matches, - demitter: @diagnostic::Emitter) + matches: &getopts::Matches) -> @session::Options { - let mut outputs = ~[]; - if matches.opt_present("lib") { - outputs.push(session::default_lib_output()); - } - if matches.opt_present("rlib") { - outputs.push(session::OutputRlib) - } - if matches.opt_present("staticlib") { - outputs.push(session::OutputStaticlib) - } - if matches.opt_present("dylib") { - outputs.push(session::OutputDylib) - } - if matches.opt_present("bin") { - outputs.push(session::OutputExecutable) - } + let crate_types = matches.opt_strs("crate-type").flat_map(|s| { + s.split(',').map(|part| { + match part { + "lib" => session::default_lib_output(), + "rlib" => session::CrateTypeRlib, + "staticlib" => session::CrateTypeStaticlib, + "dylib" => session::CrateTypeDylib, + "bin" => session::CrateTypeExecutable, + _ => early_error(format!("unknown crate type: `{}`", part)) + } + }).collect() + }); let parse_only = matches.opt_present("parse-only"); let no_trans = matches.opt_present("no-trans"); @@ -774,8 +764,8 @@ pub fn build_session_options(binary: ~str, let lint_name = lint_name.replace("-", "_"); match lint_dict.find_equiv(&lint_name) { None => { - early_error(demitter, format!("unknown {} flag: {}", - level_name, lint_name)); + early_error(format!("unknown {} flag: {}", + level_name, lint_name)); } Some(lint) => { lint_opts.push((lint.lint, *level)); @@ -794,7 +784,7 @@ pub fn build_session_options(binary: ~str, if *name == *debug_flag { this_bit = bit; break; } } if this_bit == 0 { - early_error(demitter, format!("unknown debug flag: {}", *debug_flag)) + early_error(format!("unknown debug flag: {}", *debug_flag)) } debugging_opts |= this_bit; } @@ -803,19 +793,28 @@ pub fn build_session_options(binary: ~str, unsafe { llvm::LLVMSetDebug(1); } } - let output_type = - if parse_only || no_trans { - link::OutputTypeNone - } else if matches.opt_present("S") && - matches.opt_present("emit-llvm") { - link::OutputTypeLlvmAssembly - } else if matches.opt_present("S") { - link::OutputTypeAssembly - } else if matches.opt_present("c") { - link::OutputTypeObject - } else if matches.opt_present("emit-llvm") { - link::OutputTypeBitcode - } else { link::OutputTypeExe }; + let mut output_types = if parse_only || no_trans { + ~[] + } else { + matches.opt_strs("emit").flat_map(|s| { + s.split(',').map(|part| { + match part.as_slice() { + "asm" => link::OutputTypeAssembly, + "ir" => link::OutputTypeLlvmAssembly, + "bc" => link::OutputTypeBitcode, + "obj" => link::OutputTypeObject, + "link" => link::OutputTypeExe, + _ => early_error(format!("unknown emission type: `{}`", part)) + } + }).collect() + }) + }; + output_types.sort(); + output_types.dedup(); + if output_types.len() == 0 { + output_types.push(link::OutputTypeExe); + } + let sysroot_opt = matches.opt_str("sysroot").map(|m| @Path::new(m)); let target = matches.opt_str("target").unwrap_or(host_triple()); let target_cpu = matches.opt_str("target-cpu").unwrap_or(~"generic"); @@ -826,7 +825,7 @@ pub fn build_session_options(binary: ~str, No } else if matches.opt_present("O") { if matches.opt_present("opt-level") { - early_error(demitter, "-O and --opt-level both provided"); + early_error("-O and --opt-level both provided"); } Default } else if matches.opt_present("opt-level") { @@ -836,7 +835,7 @@ pub fn build_session_options(binary: ~str, ~"2" => Default, ~"3" => Aggressive, _ => { - early_error(demitter, "optimization level needs to be between 0-3") + early_error("optimization level needs to be between 0-3") } } } else { No } @@ -861,7 +860,7 @@ pub fn build_session_options(binary: ~str, }).collect() }); - let cfg = parse_cfgspecs(matches.opt_strs("cfg"), demitter); + let cfg = parse_cfgspecs(matches.opt_strs("cfg")); let test = matches.opt_present("test"); let android_cross_path = matches.opt_str("android-cross-path"); let write_dependency_info = (matches.opt_present("dep-info"), @@ -888,7 +887,7 @@ pub fn build_session_options(binary: ~str, matches.opt_present("crate-file-name")); let sopts = @session::Options { - outputs: outputs, + crate_types: crate_types, gc: gc, optimize: opt_level, custom_passes: custom_passes, @@ -897,7 +896,7 @@ pub fn build_session_options(binary: ~str, extra_debuginfo: extra_debuginfo, lint_opts: lint_opts, save_temps: save_temps, - output_type: output_type, + output_types: output_types, addl_lib_search_paths: @RefCell::new(addl_lib_search_paths), ar: ar, linker: linker, @@ -922,25 +921,23 @@ pub fn build_session_options(binary: ~str, } pub fn build_session(sopts: @session::Options, - local_crate_source_file: Option<Path>, - demitter: @diagnostic::Emitter) + local_crate_source_file: Option<Path>) -> Session { let codemap = @codemap::CodeMap::new(); let diagnostic_handler = - diagnostic::mk_handler(Some(demitter)); + diagnostic::mk_handler(); let span_diagnostic_handler = diagnostic::mk_span_handler(diagnostic_handler, codemap); - build_session_(sopts, local_crate_source_file, codemap, demitter, span_diagnostic_handler) + build_session_(sopts, local_crate_source_file, codemap, span_diagnostic_handler) } pub fn build_session_(sopts: @session::Options, local_crate_source_file: Option<Path>, codemap: @codemap::CodeMap, - demitter: @diagnostic::Emitter, span_diagnostic_handler: @diagnostic::SpanHandler) -> Session { - let target_cfg = build_target_config(sopts, demitter); + let target_cfg = build_target_config(sopts); let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler, codemap); let cstore = @CStore::new(token::get_ident_interner()); let filesearch = @filesearch::FileSearch::new( @@ -974,7 +971,7 @@ pub fn build_session_(sopts: @session::Options, working_dir: os::getcwd(), lints: RefCell::new(HashMap::new()), node_id: Cell::new(1), - outputs: @RefCell::new(~[]), + crate_types: @RefCell::new(~[]), } } @@ -994,22 +991,17 @@ pub fn parse_pretty(sess: Session, name: &str) -> PpMode { } // rustc command line options -pub fn optgroups() -> ~[getopts::groups::OptGroup] { +pub fn optgroups() -> ~[getopts::OptGroup] { ~[ - optflag("c", "", "Compile and assemble, but do not link"), - optmulti("", "cfg", "Configure the compilation - environment", "SPEC"), - optflag("", "emit-llvm", - "Produce an LLVM assembly file if used with -S option; - produce an LLVM bitcode file otherwise"), - optflag("h", "help","Display this message"), - optmulti("L", "", "Add a directory to the library search path", - "PATH"), - optflag("", "bin", "Compile an executable crate (default)"), - optflag("", "lib", "Compile a rust library crate using the compiler's default"), - optflag("", "rlib", "Compile a rust library crate as an rlib file"), - optflag("", "staticlib", "Compile a static library crate"), - optflag("", "dylib", "Compile a dynamic library crate"), + optflag("h", "help", "Display this message"), + optmulti("", "cfg", "Configure the compilation environment", "SPEC"), + optmulti("L", "", "Add a directory to the library search path", "PATH"), + optmulti("", "crate-type", "Comma separated list of types of crates for the \ + compiler to emit", + "[bin|lib|rlib|dylib|staticlib]"), + optmulti("", "emit", "Comma separated list of types of output for the compiler + to emit", + "[asm|bc|ir|obj|link]"), optopt("", "linker", "Program to use for linking instead of the default.", "LINKER"), optopt("", "ar", "Program to use for managing archives instead of the default.", "AR"), optflag("", "crate-id", "Output the crate id and exit"), @@ -1047,7 +1039,6 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] { typed (crates expanded, with type annotations), or identified (fully parenthesized, AST nodes and blocks with IDs)", "TYPE"), - optflag("S", "", "Compile only; do not assemble or link"), optflagopt("", "dep-info", "Output dependency info to <filename> after compiling", "FILENAME"), optflag("", "save-temps", @@ -1083,8 +1074,35 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] { } pub struct OutputFilenames { - out_filename: Path, - obj_filename: Path + out_directory: Path, + out_filestem: ~str, + single_output_file: Option<Path>, +} + +impl OutputFilenames { + pub fn path(&self, flavor: link::OutputType) -> Path { + match self.single_output_file { + Some(ref path) => return path.clone(), + None => {} + } + self.temp_path(flavor) + } + + pub fn temp_path(&self, flavor: link::OutputType) -> Path { + let base = self.out_directory.join(self.out_filestem.as_slice()); + match flavor { + link::OutputTypeBitcode => base.with_extension("bc"), + link::OutputTypeAssembly => base.with_extension("s"), + link::OutputTypeLlvmAssembly => base.with_extension("ll"), + link::OutputTypeObject => base.with_extension("o"), + link::OutputTypeExe => base, + } + } + + pub fn with_extension(&self, extension: &str) -> Path { + let stem = self.out_filestem.as_slice(); + self.out_directory.join(stem).with_extension(extension) + } } pub fn build_output_filenames(input: &Input, @@ -1092,88 +1110,58 @@ pub fn build_output_filenames(input: &Input, ofile: &Option<Path>, attrs: &[ast::Attribute], sess: Session) - -> ~OutputFilenames { - let obj_path; - let out_path; - let sopts = sess.opts; - let stop_after_codegen = sopts.output_type != link::OutputTypeExe; - - let obj_suffix = match sopts.output_type { - link::OutputTypeNone => ~"none", - link::OutputTypeBitcode => ~"bc", - link::OutputTypeAssembly => ~"s", - link::OutputTypeLlvmAssembly => ~"ll", - // Object and exe output both use the '.o' extension here - link::OutputTypeObject | link::OutputTypeExe => ~"o" - }; - + -> OutputFilenames { match *ofile { - None => { - // "-" as input file will cause the parser to read from stdin so we - // have to make up a name - // We want to toss everything after the final '.' - let dirpath = match *odir { - Some(ref d) => (*d).clone(), - None => match *input { - StrInput(_) => os::getcwd(), - FileInput(ref ifile) => (*ifile).dir_path() - } - }; - - let mut stem = match *input { - // FIXME (#9639): This needs to handle non-utf8 paths - FileInput(ref ifile) => { - (*ifile).filestem_str().unwrap().to_str() - } - StrInput(_) => ~"rust_out" - }; - - // If a crateid is present, we use it as the link name - let crateid = attr::find_crateid(attrs); - match crateid { - None => {} - Some(crateid) => stem = crateid.name.to_str(), - } - - if sess.building_library.get() { - out_path = dirpath.join(os::dll_filename(stem)); - obj_path = { - let mut p = dirpath.join(stem); - p.set_extension(obj_suffix); - p - }; - } else { - out_path = dirpath.join(stem); - obj_path = out_path.with_extension(obj_suffix); - } - } + None => { + // "-" as input file will cause the parser to read from stdin so we + // have to make up a name + // We want to toss everything after the final '.' + let dirpath = match *odir { + Some(ref d) => d.clone(), + None => os::getcwd(), + }; - Some(ref out_file) => { - out_path = out_file.clone(); - obj_path = if stop_after_codegen { - out_file.clone() - } else { - out_file.with_extension(obj_suffix) - }; + let mut stem = match *input { + // FIXME (#9639): This needs to handle non-utf8 paths + FileInput(ref ifile) => ifile.filestem_str().unwrap().to_str(), + StrInput(_) => ~"rust_out" + }; - if sess.building_library.get() { - sess.warn("ignoring specified output filename for library."); + // If a crateid is present, we use it as the link name + let crateid = attr::find_crateid(attrs); + match crateid { + None => {} + Some(crateid) => stem = crateid.name.to_str(), + } + OutputFilenames { + out_directory: dirpath, + out_filestem: stem, + single_output_file: None, + } } - if *odir != None { - sess.warn("ignoring --out-dir flag due to -o flag."); + Some(ref out_file) => { + let ofile = if sess.opts.output_types.len() > 1 { + sess.warn("ignoring specified output filename because multiple \ + outputs were requested"); + None + } else { + Some(out_file.clone()) + }; + if *odir != None { + sess.warn("ignoring --out-dir flag due to -o flag."); + } + OutputFilenames { + out_directory: out_file.dir_path(), + out_filestem: out_file.filestem_str().unwrap().to_str(), + single_output_file: ofile, + } } - } - } - - ~OutputFilenames { - out_filename: out_path, - obj_filename: obj_path } } -pub fn early_error(emitter: &diagnostic::Emitter, msg: &str) -> ! { - emitter.emit(None, msg, diagnostic::Fatal); +pub fn early_error(msg: &str) -> ! { + diagnostic::DefaultEmitter.emit(None, msg, diagnostic::Fatal); fail!(diagnostic::FatalError); } @@ -1190,10 +1178,9 @@ mod test { use driver::driver::{build_configuration, build_session}; use driver::driver::{build_session_options, optgroups}; - use extra::getopts::groups::getopts; + use getopts::getopts; use syntax::attr; use syntax::attr::AttrMetaMethods; - use syntax::diagnostic; // When the user supplies --test we should implicitly supply --cfg test #[test] @@ -1203,8 +1190,8 @@ mod test { Ok(m) => m, Err(f) => fail!("test_switch_implies_cfg_test: {}", f.to_err_msg()) }; - let sessopts = build_session_options(~"rustc", matches, @diagnostic::DefaultEmitter); - let sess = build_session(sessopts, None, @diagnostic::DefaultEmitter); + let sessopts = build_session_options(~"rustc", matches); + let sess = build_session(sessopts, None); let cfg = build_configuration(sess); assert!((attr::contains_name(cfg, "test"))); } @@ -1221,8 +1208,8 @@ mod test { f.to_err_msg()); } }; - let sessopts = build_session_options(~"rustc", matches, @diagnostic::DefaultEmitter); - let sess = build_session(sessopts, None, @diagnostic::DefaultEmitter); + let sessopts = build_session_options(~"rustc", matches); + let sess = build_session(sessopts, None); let cfg = build_configuration(sess); let mut test_items = cfg.iter().filter(|m| m.name().equiv(&("test"))); assert!(test_items.next().is_some()); diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 4ef97e9234a..dc8598c10d0 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -9,7 +9,6 @@ // except according to those terms. -use back::link; use back::target_strs; use back; use driver::driver::host_triple; @@ -61,6 +60,7 @@ debugging_opts!( BORROWCK_STATS, NO_LANDING_PADS, DEBUG_LLVM, + SHOW_SPAN, COUNT_TYPE_SIZES, META_STATS, NO_OPT, @@ -96,6 +96,7 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, u64)] { ("no-landing-pads", "omit landing pads for unwinding", NO_LANDING_PADS), ("debug-llvm", "enable debug output from LLVM", DEBUG_LLVM), + ("show-span", "show spans for compiler debugging", SHOW_SPAN), ("count-type-sizes", "count the sizes of aggregate types", COUNT_TYPE_SIZES), ("meta-stats", "gather metadata statistics", META_STATS), @@ -139,7 +140,7 @@ pub enum OptLevel { pub struct Options { // The crate config requested for the session, which may be combined // with additional crate configurations during the compile process - outputs: ~[OutputStyle], + crate_types: ~[CrateType], gc: bool, optimize: OptLevel, @@ -149,7 +150,7 @@ pub struct Options { extra_debuginfo: bool, lint_opts: ~[(lint::Lint, lint::level)], save_temps: bool, - output_type: back::link::OutputType, + output_types: ~[back::link::OutputType], // This was mutable for rustpkg, which updates search paths based on the // parsed code. It remains mutable in case its replacements wants to use // this. @@ -192,11 +193,11 @@ pub enum EntryFnType { } #[deriving(Eq, Clone, TotalOrd, TotalEq)] -pub enum OutputStyle { - OutputExecutable, - OutputDylib, - OutputRlib, - OutputStaticlib, +pub enum CrateType { + CrateTypeExecutable, + CrateTypeDylib, + CrateTypeRlib, + CrateTypeStaticlib, } pub struct Session_ { @@ -219,7 +220,7 @@ pub struct Session_ { lints: RefCell<HashMap<ast::NodeId, ~[(lint::Lint, codemap::Span, ~str)]>>, node_id: Cell<ast::NodeId>, - outputs: @RefCell<~[OutputStyle]>, + crate_types: @RefCell<~[CrateType]>, } pub type Session = @Session_; @@ -307,7 +308,7 @@ impl Session_ { // This exists to help with refactoring to eliminate impossible // cases later on pub fn impossible_case(&self, sp: Span, msg: &str) -> ! { - self.span_bug(sp, format!("Impossible case reached: {}", msg)); + self.span_bug(sp, format!("impossible case reached: {}", msg)); } pub fn verbose(&self) -> bool { self.debugging_opt(VERBOSE) } pub fn time_passes(&self) -> bool { self.debugging_opt(TIME_PASSES) } @@ -352,6 +353,9 @@ impl Session_ { pub fn no_landing_pads(&self) -> bool { self.debugging_opt(NO_LANDING_PADS) } + pub fn show_span(&self) -> bool { + self.debugging_opt(SHOW_SPAN) + } // DEPRECATED. This function results in a lot of allocations when they // are not necessary. @@ -374,7 +378,7 @@ impl Session_ { /// Some reasonable defaults pub fn basic_options() -> @Options { @Options { - outputs: ~[], + crate_types: ~[], gc: false, optimize: No, custom_passes: ~[], @@ -383,7 +387,7 @@ pub fn basic_options() -> @Options { extra_debuginfo: false, lint_opts: ~[], save_temps: false, - output_type: link::OutputTypeExe, + output_types: ~[], addl_lib_search_paths: @RefCell::new(HashSet::new()), ar: None, linker: None, @@ -413,10 +417,10 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: || -> ~str) -> T { pub fn building_library(options: &Options, crate: &ast::Crate) -> bool { if options.test { return false } - for output in options.outputs.iter() { + for output in options.crate_types.iter() { match *output { - OutputExecutable => {} - OutputStaticlib | OutputDylib | OutputRlib => return true + CrateTypeExecutable => {} + CrateTypeStaticlib | CrateTypeDylib | CrateTypeRlib => return true } } match syntax::attr::first_attr_value_str_by_name(crate.attrs, "crate_type") { @@ -430,30 +434,30 @@ pub fn building_library(options: &Options, crate: &ast::Crate) -> bool { } } -pub fn default_lib_output() -> OutputStyle { - OutputRlib +pub fn default_lib_output() -> CrateType { + CrateTypeRlib } -pub fn collect_outputs(session: &Session, - attrs: &[ast::Attribute]) -> ~[OutputStyle] { +pub fn collect_crate_types(session: &Session, + attrs: &[ast::Attribute]) -> ~[CrateType] { // If we're generating a test executable, then ignore all other output // styles at all other locations if session.opts.test { - return ~[OutputExecutable]; + return ~[CrateTypeExecutable]; } - let mut base = session.opts.outputs.clone(); + let mut base = session.opts.crate_types.clone(); let mut iter = attrs.iter().filter_map(|a| { if a.name().equiv(&("crate_type")) { match a.value_str() { - Some(ref n) if n.equiv(&("rlib")) => Some(OutputRlib), - Some(ref n) if n.equiv(&("dylib")) => Some(OutputDylib), + Some(ref n) if n.equiv(&("rlib")) => Some(CrateTypeRlib), + Some(ref n) if n.equiv(&("dylib")) => Some(CrateTypeDylib), Some(ref n) if n.equiv(&("lib")) => { Some(default_lib_output()) } Some(ref n) if n.equiv(&("staticlib")) => { - Some(OutputStaticlib) + Some(CrateTypeStaticlib) } - Some(ref n) if n.equiv(&("bin")) => Some(OutputExecutable), + Some(ref n) if n.equiv(&("bin")) => Some(CrateTypeExecutable), Some(_) => { session.add_lint(lint::UnknownCrateType, ast::CRATE_NODE_ID, @@ -473,7 +477,7 @@ pub fn collect_outputs(session: &Session, }); base.extend(&mut iter); if base.len() == 0 { - base.push(OutputExecutable); + base.push(CrateTypeExecutable); } base.sort(); base.dedup(); diff --git a/src/librustc/front/show_span.rs b/src/librustc/front/show_span.rs new file mode 100644 index 00000000000..2c076aac095 --- /dev/null +++ b/src/librustc/front/show_span.rs @@ -0,0 +1,36 @@ +// 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. + +//! Span debugger +//! +//! This module shows spans for all expressions in the crate +//! to help with compiler debugging. + +use syntax::ast; +use syntax::visit; +use syntax::visit::Visitor; + +use driver::session::Session; + +struct ShowSpanVisitor { + sess: Session +} + +impl Visitor<()> for ShowSpanVisitor { + fn visit_expr(&mut self, e: &ast::Expr, _: ()) { + self.sess.span_note(e.span, "expression"); + visit::walk_expr(self, e, ()); + } +} + +pub fn run(sess: Session, crate: &ast::Crate) { + let mut v = ShowSpanVisitor { sess: sess }; + visit::walk_crate(&mut v, crate, ()); +} diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 52ddc8c8108..edcefdf6594 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -37,6 +37,8 @@ extern mod arena; extern mod syntax; extern mod serialize; extern mod sync; +extern mod getopts; +extern mod collections; use back::link; use driver::session; @@ -50,8 +52,6 @@ use std::os; use std::str; use std::task; use std::vec; -use extra::getopts::groups; -use extra::getopts; use syntax::ast; use syntax::attr; use syntax::diagnostic::Emitter; @@ -97,6 +97,7 @@ pub mod front { pub mod std_inject; pub mod assign_node_ids_and_map; pub mod feature_gate; + pub mod show_span; } pub mod back { @@ -142,7 +143,7 @@ pub fn usage(argv0: &str) { Additional help: -W help Print 'lint' options and default settings -Z help Print internal options for debugging rustc\n", - groups::usage(message, d::optgroups())); + getopts::usage(message, d::optgroups())); } pub fn describe_warnings() { @@ -194,17 +195,17 @@ pub fn describe_debug_flags() { } } -pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { +pub fn run_compiler(args: &[~str]) { let mut args = args.to_owned(); let binary = args.shift().unwrap(); if args.is_empty() { usage(binary); return; } let matches = - &match getopts::groups::getopts(args, d::optgroups()) { + &match getopts::getopts(args, d::optgroups()) { Ok(m) => m, Err(f) => { - d::early_error(demitter, f.to_err_msg()); + d::early_error(f.to_err_msg()); } }; @@ -236,7 +237,7 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { return; } let (input, input_file_path) = match matches.free.len() { - 0u => d::early_error(demitter, "no input filename given"), + 0u => d::early_error("no input filename given"), 1u => { let ifile = matches.free[0].as_slice(); if ifile == "-" { @@ -247,11 +248,11 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { (d::FileInput(Path::new(ifile)), Some(Path::new(ifile))) } } - _ => d::early_error(demitter, "multiple input filenames provided") + _ => d::early_error("multiple input filenames provided") }; - let sopts = d::build_session_options(binary, matches, demitter); - let sess = d::build_session(sopts, input_file_path, demitter); + let sopts = d::build_session_options(binary, matches); + let sess = d::build_session(sopts, input_file_path); let odir = matches.opt_str("out-dir").map(|o| Path::new(o)); let ofile = matches.opt_str("o").map(|o| Path::new(o)); let cfg = d::build_configuration(sess); @@ -274,7 +275,7 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { &mut stdout as &mut io::Writer).unwrap(); } d::StrInput(_) => { - d::early_error(demitter, "can not list metadata for stdin"); + d::early_error("can not list metadata for stdin"); } } return; @@ -302,12 +303,12 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) { } if crate_file_name { - let lm = link::build_link_meta(sess, attrs, &t_outputs.obj_filename, + let lm = link::build_link_meta(attrs, &t_outputs, &mut ::util::sha2::Sha256::new()); - let outputs = session::collect_outputs(&sess, attrs); - for &style in outputs.iter() { + let crate_types = session::collect_crate_types(&sess, attrs); + for &style in crate_types.iter() { let fname = link::filename_for_input(&sess, style, &lm, - &t_outputs.out_filename); + &t_outputs.with_extension("")); println!("{}", fname.filename_display()); } } @@ -338,7 +339,7 @@ fn parse_crate_attrs(sess: session::Session, /// /// The diagnostic emitter yielded to the procedure should be used for reporting /// errors of the compiler. -pub fn monitor(f: proc(@diagnostic::Emitter)) { +pub fn monitor(f: proc()) { // FIXME: This is a hack for newsched since it doesn't support split stacks. // rustc needs a lot of stack! When optimizations are disabled, it needs // even *more* stack than usual as well. @@ -362,7 +363,7 @@ pub fn monitor(f: proc(@diagnostic::Emitter)) { match task_builder.try(proc() { io::stdio::set_stderr(~w as ~io::Writer); - f(@diagnostic::DefaultEmitter) + f() }) { Ok(()) => { /* fallthrough */ } Err(value) => { @@ -401,6 +402,6 @@ pub fn main() { pub fn main_args(args: &[~str]) -> int { let owned_args = args.to_owned(); - monitor(proc(demitter) run_compiler(owned_args, demitter)); + monitor(proc() run_compiler(owned_args)); 0 } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index d18017d0043..029682d9315 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -772,7 +772,6 @@ fn get_explicit_self(item: ebml::Doc) -> ast::ExplicitSelf_ { match explicit_self_kind as char { 's' => ast::SelfStatic, 'v' => ast::SelfValue, - '@' => ast::SelfBox, '~' => ast::SelfUniq, // FIXME(#4846) expl. region '&' => ast::SelfRegion(None, get_mutability(string[1])), diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index ba33f57309f..07997577a9f 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -671,7 +671,6 @@ fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::Explic match explicit_self { SelfStatic => { ebml_w.writer.write(&[ 's' as u8 ]); } SelfValue => { ebml_w.writer.write(&[ 'v' as u8 ]); } - SelfBox => { ebml_w.writer.write(&[ '@' as u8 ]); } SelfUniq => { ebml_w.writer.write(&[ '~' as u8 ]); } SelfRegion(_, m) => { // FIXME(#4846) encode custom lifetime diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 92af631c2bd..42e4d986837 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -164,7 +164,6 @@ fn parse_vstore(st: &mut PState, conv: conv_did) -> ty::vstore { fn parse_trait_store(st: &mut PState, conv: conv_did) -> ty::TraitStore { match next(st) { '~' => ty::UniqTraitStore, - '@' => ty::BoxTraitStore, '&' => ty::RegionTraitStore(parse_region(st, conv)), c => st.tcx.sess.bug(format!("parse_trait_store(): bad input '{}'", c)) } @@ -528,7 +527,7 @@ fn parse_sig(st: &mut PState, conv: conv_did) -> ty::FnSig { let variadic = match next(st) { 'V' => true, 'N' => false, - r => fail!(format!("Bad variadic: {}", r)), + r => fail!(format!("bad variadic: {}", r)), }; let ret_ty = parse_ty(st, |x,y| conv(x,y)); ty::FnSig {binder_id: id, diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 913c5dac460..08632b5c9a6 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -195,7 +195,7 @@ fn enc_region(w: &mut MemWriter, cx: @ctxt, r: ty::Region) { } ty::ReInfer(_) => { // these should not crop up after typeck - cx.diag.handler().bug("Cannot encode region variables"); + cx.diag.handler().bug("cannot encode region variables"); } } } @@ -236,7 +236,6 @@ pub fn enc_trait_ref(w: &mut MemWriter, cx: @ctxt, s: &ty::TraitRef) { pub fn enc_trait_store(w: &mut MemWriter, cx: @ctxt, s: ty::TraitStore) { match s { ty::UniqTraitStore => mywrite!(w, "~"), - ty::BoxTraitStore => mywrite!(w, "@"), ty::RegionTraitStore(re) => { mywrite!(w, "&"); enc_region(w, cx, re); @@ -321,7 +320,7 @@ fn enc_sty(w: &mut MemWriter, cx: @ctxt, st: &ty::sty) { enc_bare_fn_ty(w, cx, f); } ty::ty_infer(_) => { - cx.diag.handler().bug("Cannot encode inference variable types"); + cx.diag.handler().bug("cannot encode inference variable types"); } ty::ty_param(param_ty {idx: id, def_id: did}) => { mywrite!(w, "p{}|{}", (cx.ds)(did), id); @@ -335,7 +334,7 @@ fn enc_sty(w: &mut MemWriter, cx: @ctxt, st: &ty::sty) { enc_substs(w, cx, substs); mywrite!(w, "]"); } - ty::ty_err => fail!("Shouldn't encode error type") + ty::ty_err => fail!("shouldn't encode error type") } } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 8adbd37462b..d59ec370e07 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1427,10 +1427,7 @@ trait fake_ext_ctxt { } #[cfg(test)] -type fake_session = @parse::ParseSess; - -#[cfg(test)] -impl fake_ext_ctxt for fake_session { +impl fake_ext_ctxt for @parse::ParseSess { fn cfg(&self) -> ast::CrateConfig { ~[] } fn parse_sess(&self) -> @parse::ParseSess { *self } fn call_site(&self) -> Span { @@ -1446,8 +1443,8 @@ impl fake_ext_ctxt for fake_session { } #[cfg(test)] -fn mk_ctxt() -> @fake_ext_ctxt { - @parse::new_parse_sess(None) as @fake_ext_ctxt +fn mk_ctxt() -> @parse::ParseSess { + parse::new_parse_sess() } #[cfg(test)] diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc/middle/borrowck/gather_loans/lifetime.rs index 4c2f0986d9c..e151f398458 100644 --- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs +++ b/src/librustc/middle/borrowck/gather_loans/lifetime.rs @@ -215,7 +215,7 @@ impl<'a> GuaranteeLifetimeContext<'a> { // the check above should fail for anything is not ReScope self.bccx.tcx.sess.span_bug( cmt_base.span, - format!("Cannot issue root for scope region: {:?}", + format!("cannot issue root for scope region: {:?}", self.loan_region)); } }; diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index 0ae1fefa2a0..173120e32f5 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -416,7 +416,7 @@ impl<'a> GatherLoanCtxt<'a> { } ty::AutoObject(..) => { - // FIXME: Handle @Trait to &Trait casts here? + // FIXME: Handle ~Trait to &Trait casts here? } } } @@ -496,7 +496,7 @@ impl<'a> GatherLoanCtxt<'a> { ty::ReInfer(..) => { self.tcx().sess.span_bug( cmt.span, - format!("Invalid borrow lifetime: {:?}", loan_region)); + format!("invalid borrow lifetime: {:?}", loan_region)); } }; debug!("loan_scope = {:?}", loan_scope); @@ -820,7 +820,7 @@ impl<'a> GatherLoanCtxt<'a> { _ => { self.tcx().sess.span_bug( pat.span, - format!("Type of slice pattern is not a slice")); + format!("type of slice pattern is not a slice")); } } } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 8f6d4de476b..6f3578f667d 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -769,14 +769,14 @@ impl BorrowckCtxt { } _ => { self.tcx.sess.bug( - format!("Loan path LpVar({:?}) maps to {:?}, not local", + format!("loan path LpVar({:?}) maps to {:?}, not local", id, pat)); } } } r => { self.tcx.sess.bug( - format!("Loan path LpVar({:?}) maps to {:?}, not local", + format!("loan path LpVar({:?}) maps to {:?}, not local", id, r)); } } diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index ca9bce19ab8..75549c5944d 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -494,7 +494,7 @@ impl MoveData { dfcx_assign.add_kill(kill_id, assignment_index); } LpExtend(..) => { - tcx.sess.bug("Var assignment for non var path"); + tcx.sess.bug("var assignment for non var path"); } } } diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index eb9c434ca28..9c213558d9c 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -507,13 +507,13 @@ impl CFGBuilder { } self.tcx.sess.span_bug( expr.span, - format!("No loop scope for id {:?}", loop_id)); + format!("no loop scope for id {:?}", loop_id)); } r => { self.tcx.sess.span_bug( expr.span, - format!("Bad entry `{:?}` in def_map for label", r)); + format!("bad entry `{:?}` in def_map for label", r)); } } } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index d402305401e..ab9eff3a372 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -971,7 +971,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, _ => { cx.tcx.sess.span_bug( p.span, - format!("Binding pattern {} is \ + format!("binding pattern {} is \ not an identifier: {:?}", p.id, p.node)); } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index cbe1e8f72d9..75874339f3a 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -342,8 +342,8 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) Ok(const_float(f)) => Ok(const_float(-f)), Ok(const_int(i)) => Ok(const_int(-i)), Ok(const_uint(i)) => Ok(const_uint(-i)), - Ok(const_str(_)) => Err(~"Negate on string"), - Ok(const_bool(_)) => Err(~"Negate on boolean"), + Ok(const_str(_)) => Err(~"negate on string"), + Ok(const_bool(_)) => Err(~"negate on boolean"), ref err => ((*err).clone()) } } @@ -352,7 +352,7 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) Ok(const_int(i)) => Ok(const_int(!i)), Ok(const_uint(i)) => Ok(const_uint(!i)), Ok(const_bool(b)) => Ok(const_bool(!b)), - _ => Err(~"Not on float or string") + _ => Err(~"not on float or string") } } ExprBinary(_, op, a, b) => { @@ -371,7 +371,7 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) BiNe => fromb(a != b), BiGe => fromb(a >= b), BiGt => fromb(a > b), - _ => Err(~"Can't do this op on floats") + _ => Err(~"can't do this op on floats") } } (Ok(const_int(a)), Ok(const_int(b))) => { @@ -423,14 +423,14 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) match op { BiShl => Ok(const_int(a << b)), BiShr => Ok(const_int(a >> b)), - _ => Err(~"Can't do this op on an int and uint") + _ => Err(~"can't do this op on an int and uint") } } (Ok(const_uint(a)), Ok(const_int(b))) => { match op { BiShl => Ok(const_uint(a << b)), BiShr => Ok(const_uint(a >> b)), - _ => Err(~"Can't do this op on a uint and int") + _ => Err(~"can't do this op on a uint and int") } } (Ok(const_bool(a)), Ok(const_bool(b))) => { @@ -442,10 +442,10 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) BiBitOr => a | b, BiEq => a == b, BiNe => a != b, - _ => return Err(~"Can't do this op on bools") + _ => return Err(~"can't do this op on bools") })) } - _ => Err(~"Bad operands for binary") + _ => Err(~"bad operands for binary") } } ExprCast(base, target_ty) => { @@ -456,7 +456,7 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) .or_else(|| astconv::ast_ty_to_prim_ty(tcx.ty_ctxt(), target_ty)) .unwrap_or_else(|| tcx.ty_ctxt().sess.span_fatal( target_ty.span, - format!("Target type not found for const cast") + format!("target type not found for const cast") )); let base = eval_const_expr_partial(tcx, base); @@ -469,7 +469,7 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) const_uint(u) => Ok(const_float(u as f64)), const_int(i) => Ok(const_float(i as f64)), const_float(f) => Ok(const_float(f)), - _ => Err(~"Can't cast float to str"), + _ => Err(~"can't cast float to str"), } } ty::ty_uint(_) => { @@ -477,7 +477,7 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) const_uint(u) => Ok(const_uint(u)), const_int(i) => Ok(const_uint(i as u64)), const_float(f) => Ok(const_uint(f as u64)), - _ => Err(~"Can't cast str to uint"), + _ => Err(~"can't cast str to uint"), } } ty::ty_int(_) | ty::ty_bool => { @@ -485,10 +485,10 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) const_uint(u) => Ok(const_int(u as i64)), const_int(i) => Ok(const_int(i)), const_float(f) => Ok(const_int(f as i64)), - _ => Err(~"Can't cast str to int"), + _ => Err(~"can't cast str to int"), } } - _ => Err(~"Can't cast this type") + _ => Err(~"can't cast this type") } } } @@ -496,14 +496,14 @@ pub fn eval_const_expr_partial<T: ty::ExprTyProvider>(tcx: &T, e: &Expr) ExprPath(_) => { match lookup_const(tcx.ty_ctxt(), e) { Some(actual_e) => eval_const_expr_partial(&tcx.ty_ctxt(), actual_e), - None => Err(~"Non-constant path in constant expr") + None => Err(~"non-constant path in constant expr") } } ExprLit(lit) => Ok(lit_to_const(lit)), // If we have a vstore, just keep going; it has to be a string ExprVstore(e, _) => eval_const_expr_partial(tcx, e), ExprParen(e) => eval_const_expr_partial(tcx, e), - _ => Err(~"Unsupported constant expr") + _ => Err(~"unsupported constant expr") } } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 78221d2adb3..e4b648dd43c 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -347,16 +347,15 @@ impl<O:DataFlowOperator+Clone+'static> DataFlowContext<O> { debug!("Dataflow result:"); debug!("{}", { - let this = @(*self).clone(); - this.pretty_print_to(~io::stderr() as ~io::Writer, blk).unwrap(); + self.pretty_print_to(~io::stderr(), blk).unwrap(); "" }); } - fn pretty_print_to(@self, wr: ~io::Writer, + fn pretty_print_to(&self, wr: ~io::Writer, blk: &ast::Block) -> io::IoResult<()> { let mut ps = pprust::rust_printer_annotated(wr, self.tcx.sess.intr(), - self as @pprust::PpAnn); + self as &pprust::PpAnn); if_ok!(pprust::cbox(&mut ps, pprust::indent_unit)); if_ok!(pprust::ibox(&mut ps, 0u)); if_ok!(pprust::print_block(&mut ps, blk)); @@ -880,7 +879,7 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> { None => { self.tcx().sess.span_bug( expr.span, - format!("No loop scope for id {:?}", loop_id)); + format!("no loop scope for id {:?}", loop_id)); } } } @@ -888,7 +887,7 @@ impl<'a, O:DataFlowOperator> PropagationContext<'a, O> { r => { self.tcx().sess.span_bug( expr.span, - format!("Bad entry `{:?}` in def_map for label", r)); + format!("bad entry `{:?}` in def_map for label", r)); } } } diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index e674af6b3b3..0ebfa8c393c 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -56,7 +56,7 @@ use std::u16; use std::u32; use std::u64; use std::u8; -use extra::smallintmap::SmallIntMap; +use collections::SmallIntMap; use syntax::ast_map; use syntax::ast_util::IdVisitingOperation; use syntax::attr::{AttrMetaMethods, AttributeMethods}; @@ -660,8 +660,7 @@ impl<'a> AstConv for Context<'a>{ } fn ty_infer(&self, _span: Span) -> ty::t { - let infcx: @infer::InferCtxt = infer::new_infer_ctxt(self.tcx); - infcx.next_ty_var() + infer::new_infer_ctxt(self.tcx).next_ty_var() } } @@ -669,8 +668,7 @@ impl<'a> AstConv for Context<'a>{ fn check_unused_casts(cx: &Context, e: &ast::Expr) { return match e.node { ast::ExprCast(expr, ty) => { - let infcx: @infer::InferCtxt = infer::new_infer_ctxt(cx.tcx); - let t_t = ast_ty_to_ty(cx, &infcx, ty); + let t_t = ast_ty_to_ty(cx, &infer::new_infer_ctxt(cx.tcx), ty); if ty::get(ty::expr_ty(cx.tcx, expr)).sty == ty::get(t_t).sty { cx.span_lint(UnnecessaryTypecast, ty.span, "unnecessary type cast"); @@ -887,8 +885,7 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) { let mut n_uniq = 0; ty::fold_ty(cx.tcx, ty, |t| { match ty::get(t).sty { - ty::ty_box(_) | - ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => { + ty::ty_box(_) => { n_box += 1; } ty::ty_uniq(_) | ty::ty_str(ty::vstore_uniq) | diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 26e4a11ae49..546d6f27204 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -328,7 +328,7 @@ impl IrMaps { Some(&var) => var, None => { self.tcx.sess.span_bug( - span, format!("No variable registered for id {}", node_id)); + span, format!("no variable registered for id {}", node_id)); } } } @@ -627,7 +627,7 @@ impl Liveness { // code have to agree about which AST nodes are worth // creating liveness nodes for. self.tcx.sess.span_bug( - span, format!("No live node registered for node {}", + span, format!("no live node registered for node {}", node_id)); } } @@ -759,7 +759,7 @@ impl Liveness { let def_map = self.tcx.def_map.borrow(); match def_map.get().find(&id) { Some(&DefLabel(loop_id)) => loop_id, - _ => self.tcx.sess.span_bug(sp, "Label on break/loop \ + _ => self.tcx.sess.span_bug(sp, "label on break/loop \ doesn't refer to a loop") } } @@ -1152,7 +1152,7 @@ impl Liveness { match break_ln.get().find(&sc) { Some(&b) => b, None => self.tcx.sess.span_bug(expr.span, - "Break to unknown label") + "break to unknown label") } } @@ -1167,7 +1167,7 @@ impl Liveness { match cont_ln.get().find(&sc) { Some(&b) => b, None => self.tcx.sess.span_bug(expr.span, - "Loop to unknown label") + "loop to unknown label") } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 72fd98e56ed..f5e3ff5db34 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -177,8 +177,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> { Some(deref_ptr(region_ptr(ast::MutImmutable, r))) } - ty::ty_box(_) | - ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => { + ty::ty_box(_) => { Some(deref_ptr(gc_ptr)) } @@ -549,7 +548,7 @@ impl mem_categorization_ctxt { _ => { self.tcx.sess.span_bug( span, - format!("Upvar of non-closure {:?} - {}", + format!("upvar of non-closure {:?} - {}", fn_node_id, ty.repr(self.tcx))); } } @@ -653,7 +652,7 @@ impl mem_categorization_ctxt { None => { self.tcx.sess.span_bug( node.span(), - format!("Explicit deref of non-derefable type: {}", + format!("explicit deref of non-derefable type: {}", ty_to_str(self.tcx, base_cmt.ty))); } }; @@ -746,7 +745,7 @@ impl mem_categorization_ctxt { None => { self.tcx.sess.span_bug( elt.span(), - format!("Explicit index of non-index type `{}`", + format!("explicit index of non-index type `{}`", ty_to_str(self.tcx, base_cmt.ty))); } }; @@ -1105,7 +1104,7 @@ pub enum AliasableReason { } impl cmt_ { - pub fn guarantor(@self) -> cmt { + pub fn guarantor(self) -> cmt { //! Returns `self` after stripping away any owned pointer derefs or //! interior content. The return value is basically the `cmt` which //! determines how long the value in `self` remains live. @@ -1119,7 +1118,7 @@ impl cmt_ { cat_deref(_, _, unsafe_ptr(..)) | cat_deref(_, _, gc_ptr) | cat_deref(_, _, region_ptr(..)) => { - self + @self } cat_downcast(b) | cat_stack_upvar(b) | diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 9c11b89bb7e..86de1399acb 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -142,7 +142,7 @@ impl RegionMaps { let scope_map = self.scope_map.borrow(); match scope_map.get().find(&id) { Some(&r) => r, - None => { fail!("No enclosing scope for id {}", id); } + None => { fail!("no enclosing scope for id {}", id); } } } @@ -154,7 +154,7 @@ impl RegionMaps { let var_map = self.var_map.borrow(); match var_map.get().find(&var_id) { Some(&r) => r, - None => { fail!("No enclosing scope for id {}", var_id); } + None => { fail!("no enclosing scope for id {}", var_id); } } } @@ -554,7 +554,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, None => { visitor.sess.span_bug( local.span, - "Local without enclosing block"); + "local without enclosing block"); } }; diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 6ee44c03a80..19e67bb865d 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1378,7 +1378,7 @@ impl Resolver { } match method_map.get().find_mut(name) { Some(s) => { s.insert(def_id); }, - _ => fail!("Can't happen"), + _ => fail!("can't happen"), } } @@ -1696,7 +1696,7 @@ impl Resolver { } match method_map.get().find_mut(name) { Some(s) => { s.insert(def_id); }, - _ => fail!("Can't happen"), + _ => fail!("can't happen"), } } @@ -3992,7 +3992,7 @@ impl Resolver { self.resolve_error(field.span, format!("field `{}` is already declared", ident_str)); self.session.span_note(prev_field.span, - "Previously declared here"); + "previously declared here"); }, None => { ident_map.insert(ident, field); @@ -4476,7 +4476,7 @@ impl Resolver { // in the same disjunct, which is an // error self.resolve_error(pattern.span, - format!("Identifier `{}` is bound more \ + format!("identifier `{}` is bound more \ than once in the same pattern", path_to_str(path, self.session .intr()))); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index ead67f78063..ab730c1b2e5 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -297,7 +297,7 @@ impl LifetimeContext { def: ast::DefRegion) { if lifetime_ref.id == ast::DUMMY_NODE_ID { self.sess.span_bug(lifetime_ref.span, - "Lifetime reference not renumbered, \ + "lifetime reference not renumbered, \ probably a bug in syntax::fold"); } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index ad2e96702b0..f49b0f1af08 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -484,7 +484,7 @@ fn assert_is_binding_or_wild(bcx: &Block, p: @ast::Pat) { if !pat_is_binding_or_wild(bcx.tcx().def_map, p) { bcx.sess().span_bug( p.span, - format!("Expected an identifier pattern but found p: {}", + format!("expected an identifier pattern but found p: {}", p.repr(bcx.tcx()))); } } diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 9d90fdb8011..15fbb54cd11 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -434,7 +434,7 @@ fn generic_type_of(cx: &CrateContext, r: &Repr, name: Option<&str>, sizing: bool Type::array(&Type::i64(), align_units), a if a.population_count() == 1 => Type::array(&Type::vector(&Type::i32(), a / 4), align_units), - _ => fail!("Unsupported enum alignment: {:?}", align) + _ => fail!("unsupported enum alignment: {:?}", align) }; assert_eq!(machine::llalign_of_min(cx, pad_ty) as u64, align); assert_eq!(align % discr_size, 0); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 5b4a9617612..39e0ca176eb 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -28,6 +28,7 @@ use back::link::{mangle_exported_name}; use back::{link, abi}; use driver::session; use driver::session::Session; +use driver::driver::OutputFilenames; use driver::driver::{CrateAnalysis, CrateTranslation}; use lib::llvm::{ModuleRef, ValueRef, BasicBlockRef}; use lib::llvm::{llvm, True, Vector}; @@ -351,7 +352,6 @@ pub fn malloc_raw_dyn<'a>( if heap == heap_exchange { let llty_value = type_of::type_of(ccx, t); - // Allocate space: let r = callee::trans_lang_call( bcx, @@ -374,17 +374,14 @@ pub fn malloc_raw_dyn<'a>( // Grab the TypeRef type of box_ptr_ty. let box_ptr_ty = ty::mk_box(bcx.tcx(), t); let llty = type_of(ccx, box_ptr_ty); - - // Get the tydesc for the body: - let static_ti = get_tydesc(ccx, t); - glue::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti); + let llalign = C_uint(ccx, llalign_of_min(ccx, llty) as uint); // Allocate space: - let tydesc = PointerCast(bcx, static_ti.tydesc, Type::i8p()); + let drop_glue = glue::get_drop_glue(ccx, t); let r = callee::trans_lang_call( bcx, langcall, - [tydesc, size], + [PointerCast(bcx, drop_glue, Type::glue_fn(Type::i8p()).ptr_to()), size, llalign], None); rslt(r.bcx, PointerCast(r.bcx, r.val, llty)) } @@ -2657,7 +2654,7 @@ pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) -> ~[u8] { pub fn trans_crate(sess: session::Session, crate: ast::Crate, analysis: &CrateAnalysis, - output: &Path) -> CrateTranslation { + output: &OutputFilenames) -> CrateTranslation { // Before we touch LLVM, make sure that multithreading is enabled. unsafe { use sync::one::{Once, ONCE_INIT}; @@ -2677,7 +2674,7 @@ pub fn trans_crate(sess: session::Session, } let mut symbol_hasher = Sha256::new(); - let link_meta = link::build_link_meta(sess, crate.attrs, output, + let link_meta = link::build_link_meta(crate.attrs, output, &mut symbol_hasher); // Append ".rs" to crate name as LLVM module identifier. diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 44410ae24b9..e54b2ab29b2 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -34,7 +34,7 @@ pub fn check_not_terminated(cx: &Block) { } } -pub fn B(cx: &Block) -> Builder { +pub fn B<'a>(cx: &'a Block) -> Builder<'a> { let b = cx.fcx.ccx.builder(); b.position_at_end(cx.llbb); b diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index cedd98e261c..e4eeaa5fded 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -23,9 +23,9 @@ use std::libc::{c_uint, c_ulonglong, c_char}; use syntax::codemap::Span; use std::ptr::is_not_null; -pub struct Builder { +pub struct Builder<'a> { llbuilder: BuilderRef, - ccx: @CrateContext, + ccx: &'a CrateContext, } // This is a really awful way to get a zero-length c-string, but better (and a @@ -37,8 +37,8 @@ pub fn noname() -> *c_char { } } -impl Builder { - pub fn new(ccx: @CrateContext) -> Builder { +impl<'a> Builder<'a> { + pub fn new(ccx: &'a CrateContext) -> Builder<'a> { Builder { llbuilder: ccx.builder.B, ccx: ccx, diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 80d92d85686..77fe847f5f2 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -103,7 +103,7 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { _ => { bcx.tcx().sess.span_bug( expr.span, - format!("Type of callee is neither bare-fn nor closure: {}", + format!("type of callee is neither bare-fn nor closure: {}", bcx.ty_to_str(datum.ty))); } } @@ -151,7 +151,7 @@ fn trans<'a>(bcx: &'a Block<'a>, expr: &ast::Expr) -> Callee<'a> { ast::DefSelfTy(..) | ast::DefMethod(..) => { bcx.tcx().sess.span_bug( ref_expr.span, - format!("Cannot translate def {:?} \ + format!("cannot translate def {:?} \ to a callable thing!", def)); } } diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index acbbdf27d1c..e28660ea01f 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -211,7 +211,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { _ => {} } } - self.ccx.tcx.sess.bug("No loop scope found"); + self.ccx.tcx.sess.bug("no loop scope found"); } fn normal_exit_block(&'a self, @@ -337,7 +337,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { } self.ccx.tcx.sess.bug( - format!("No cleanup scope {} found", + format!("no cleanup scope {} found", ast_map::node_id_to_str(self.ccx.tcx.items, cleanup_scope, token::get_ident_interner()))); } @@ -548,7 +548,7 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> { LoopExit(id, _) => { self.ccx.tcx.sess.bug(format!( - "Cannot exit from scope {:?}, \ + "cannot exit from scope {:?}, \ not in scope", id)); } } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 78affcc69e1..7dbf159265d 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -114,7 +114,6 @@ pub struct tydesc_info { size: ValueRef, align: ValueRef, name: ValueRef, - drop_glue: Cell<Option<ValueRef>>, visit_glue: Cell<Option<ValueRef>>, } @@ -473,7 +472,7 @@ impl<'a> Block<'a> { Some(&v) => v, None => { self.tcx().sess.bug(format!( - "No def associated with node id {:?}", nid)); + "no def associated with node id {:?}", nid)); } } } @@ -853,7 +852,7 @@ pub fn node_id_type_params(bcx: &Block, id: ast::NodeId) -> ~[ty::t] { if !params.iter().all(|t| !ty::type_needs_infer(*t)) { bcx.sess().bug( - format!("Type parameters for node {} include inference types: {}", + format!("type parameters for node {} include inference types: {}", id, params.map(|t| bcx.ty_to_str(*t)).connect(","))); } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index a8b0da80266..760c56dd945 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -146,14 +146,14 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool) const_deref_newtype(cx, v, t) } _ => { - cx.sess.bug(format!("Unexpected dereferenceable type {}", + cx.sess.bug(format!("unexpected dereferenceable type {}", ty_to_str(cx.tcx, t))) } }; (dv, mt.ty) } None => { - cx.sess.bug(format!("Can't dereference const of type {}", + cx.sess.bug(format!("can't dereference const of type {}", ty_to_str(cx.tcx, t))) } } diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 2872d556633..95875a01401 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -36,83 +36,84 @@ use syntax::ast; use syntax::parse::token::InternedString; pub struct CrateContext { - sess: session::Session, - llmod: ModuleRef, - llcx: ContextRef, - metadata_llmod: ModuleRef, - td: TargetData, - tn: TypeNames, - externs: RefCell<ExternMap>, - intrinsics: HashMap<&'static str, ValueRef>, - item_vals: RefCell<HashMap<ast::NodeId, ValueRef>>, - exp_map2: resolve::ExportMap2, - reachable: @RefCell<HashSet<ast::NodeId>>, - item_symbols: RefCell<HashMap<ast::NodeId, ~str>>, - link_meta: LinkMeta, - tydescs: RefCell<HashMap<ty::t, @tydesc_info>>, - // Set when running emit_tydescs to enforce that no more tydescs are - // created. - finished_tydescs: Cell<bool>, - // Track mapping of external ids to local items imported for inlining - external: RefCell<HashMap<ast::DefId, Option<ast::NodeId>>>, - // Backwards version of the `external` map (inlined items to where they - // came from) - external_srcs: RefCell<HashMap<ast::NodeId, ast::DefId>>, - // A set of static items which cannot be inlined into other crates. This - // will pevent in IIItem() structures from being encoded into the metadata - // that is generated - non_inlineable_statics: RefCell<HashSet<ast::NodeId>>, - // Cache instances of monomorphized functions - monomorphized: RefCell<HashMap<mono_id, ValueRef>>, - monomorphizing: RefCell<HashMap<ast::DefId, uint>>, - // Cache generated vtables - vtables: RefCell<HashMap<(ty::t, mono_id), ValueRef>>, - // Cache of constant strings, - const_cstr_cache: RefCell<HashMap<InternedString, ValueRef>>, + sess: session::Session, + llmod: ModuleRef, + llcx: ContextRef, + metadata_llmod: ModuleRef, + td: TargetData, + tn: TypeNames, + externs: RefCell<ExternMap>, + intrinsics: HashMap<&'static str, ValueRef>, + item_vals: RefCell<HashMap<ast::NodeId, ValueRef>>, + exp_map2: resolve::ExportMap2, + reachable: @RefCell<HashSet<ast::NodeId>>, + item_symbols: RefCell<HashMap<ast::NodeId, ~str>>, + link_meta: LinkMeta, + drop_glues: RefCell<HashMap<ty::t, ValueRef>>, + tydescs: RefCell<HashMap<ty::t, @tydesc_info>>, + // Set when running emit_tydescs to enforce that no more tydescs are + // created. + finished_tydescs: Cell<bool>, + // Track mapping of external ids to local items imported for inlining + external: RefCell<HashMap<ast::DefId, Option<ast::NodeId>>>, + // Backwards version of the `external` map (inlined items to where they + // came from) + external_srcs: RefCell<HashMap<ast::NodeId, ast::DefId>>, + // A set of static items which cannot be inlined into other crates. This + // will pevent in IIItem() structures from being encoded into the metadata + // that is generated + non_inlineable_statics: RefCell<HashSet<ast::NodeId>>, + // Cache instances of monomorphized functions + monomorphized: RefCell<HashMap<mono_id, ValueRef>>, + monomorphizing: RefCell<HashMap<ast::DefId, uint>>, + // Cache generated vtables + vtables: RefCell<HashMap<(ty::t, mono_id), ValueRef>>, + // Cache of constant strings, + const_cstr_cache: RefCell<HashMap<InternedString, ValueRef>>, - // Reverse-direction for const ptrs cast from globals. - // Key is an int, cast from a ValueRef holding a *T, - // Val is a ValueRef holding a *[T]. - // - // Needed because LLVM loses pointer->pointee association - // when we ptrcast, and we have to ptrcast during translation - // of a [T] const because we form a slice, a [*T,int] pair, not - // a pointer to an LLVM array type. - const_globals: RefCell<HashMap<int, ValueRef>>, + // Reverse-direction for const ptrs cast from globals. + // Key is an int, cast from a ValueRef holding a *T, + // Val is a ValueRef holding a *[T]. + // + // Needed because LLVM loses pointer->pointee association + // when we ptrcast, and we have to ptrcast during translation + // of a [T] const because we form a slice, a [*T,int] pair, not + // a pointer to an LLVM array type. + const_globals: RefCell<HashMap<int, ValueRef>>, - // Cache of emitted const values - const_values: RefCell<HashMap<ast::NodeId, ValueRef>>, + // Cache of emitted const values + const_values: RefCell<HashMap<ast::NodeId, ValueRef>>, - // Cache of external const values - extern_const_values: RefCell<HashMap<ast::DefId, ValueRef>>, + // Cache of external const values + extern_const_values: RefCell<HashMap<ast::DefId, ValueRef>>, - impl_method_cache: RefCell<HashMap<(ast::DefId, ast::Name), ast::DefId>>, + impl_method_cache: RefCell<HashMap<(ast::DefId, ast::Name), ast::DefId>>, - // Cache of closure wrappers for bare fn's. - closure_bare_wrapper_cache: RefCell<HashMap<ValueRef, ValueRef>>, + // Cache of closure wrappers for bare fn's. + closure_bare_wrapper_cache: RefCell<HashMap<ValueRef, ValueRef>>, - module_data: RefCell<HashMap<~str, ValueRef>>, - lltypes: RefCell<HashMap<ty::t, Type>>, - llsizingtypes: RefCell<HashMap<ty::t, Type>>, - adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>, - symbol_hasher: RefCell<Sha256>, - type_hashcodes: RefCell<HashMap<ty::t, ~str>>, - all_llvm_symbols: RefCell<HashSet<~str>>, - tcx: ty::ctxt, - maps: astencode::Maps, - stats: @Stats, - tydesc_type: Type, - int_type: Type, - opaque_vec_type: Type, - builder: BuilderRef_res, - crate_map: ValueRef, - crate_map_name: ~str, - // Set when at least one function uses GC. Needed so that - // decl_gc_metadata knows whether to link to the module metadata, which - // is not emitted by LLVM's GC pass when no functions use GC. - uses_gc: bool, - dbg_cx: Option<debuginfo::CrateDebugContext>, - do_not_commit_warning_issued: Cell<bool>, + module_data: RefCell<HashMap<~str, ValueRef>>, + lltypes: RefCell<HashMap<ty::t, Type>>, + llsizingtypes: RefCell<HashMap<ty::t, Type>>, + adt_reprs: RefCell<HashMap<ty::t, @adt::Repr>>, + symbol_hasher: RefCell<Sha256>, + type_hashcodes: RefCell<HashMap<ty::t, ~str>>, + all_llvm_symbols: RefCell<HashSet<~str>>, + tcx: ty::ctxt, + maps: astencode::Maps, + stats: @Stats, + tydesc_type: Type, + int_type: Type, + opaque_vec_type: Type, + builder: BuilderRef_res, + crate_map: ValueRef, + crate_map_name: ~str, + // Set when at least one function uses GC. Needed so that + // decl_gc_metadata knows whether to link to the module metadata, which + // is not emitted by LLVM's GC pass when no functions use GC. + uses_gc: bool, + dbg_cx: Option<debuginfo::CrateDebugContext>, + do_not_commit_warning_issued: Cell<bool>, } impl CrateContext { @@ -175,69 +176,70 @@ impl CrateContext { } CrateContext { - sess: sess, - llmod: llmod, - llcx: llcx, - metadata_llmod: metadata_llmod, - td: td, - tn: tn, - externs: RefCell::new(HashMap::new()), - intrinsics: intrinsics, - item_vals: RefCell::new(HashMap::new()), - exp_map2: emap2, - reachable: reachable, - item_symbols: RefCell::new(HashMap::new()), - link_meta: link_meta, - tydescs: RefCell::new(HashMap::new()), - finished_tydescs: Cell::new(false), - external: RefCell::new(HashMap::new()), - external_srcs: RefCell::new(HashMap::new()), - non_inlineable_statics: RefCell::new(HashSet::new()), - monomorphized: RefCell::new(HashMap::new()), - monomorphizing: RefCell::new(HashMap::new()), - vtables: RefCell::new(HashMap::new()), - const_cstr_cache: RefCell::new(HashMap::new()), - const_globals: RefCell::new(HashMap::new()), - const_values: RefCell::new(HashMap::new()), - extern_const_values: RefCell::new(HashMap::new()), - impl_method_cache: RefCell::new(HashMap::new()), - closure_bare_wrapper_cache: RefCell::new(HashMap::new()), - module_data: RefCell::new(HashMap::new()), - lltypes: RefCell::new(HashMap::new()), - llsizingtypes: RefCell::new(HashMap::new()), - adt_reprs: RefCell::new(HashMap::new()), - symbol_hasher: RefCell::new(symbol_hasher), - type_hashcodes: RefCell::new(HashMap::new()), - all_llvm_symbols: RefCell::new(HashSet::new()), - tcx: tcx, - maps: maps, - stats: @Stats { - n_static_tydescs: Cell::new(0u), - n_glues_created: Cell::new(0u), - n_null_glues: Cell::new(0u), - n_real_glues: Cell::new(0u), - n_fns: Cell::new(0u), - n_monos: Cell::new(0u), - n_inlines: Cell::new(0u), - n_closures: Cell::new(0u), - n_llvm_insns: Cell::new(0u), - llvm_insns: RefCell::new(HashMap::new()), - fn_stats: RefCell::new(~[]), - }, - tydesc_type: tydesc_type, - int_type: int_type, - opaque_vec_type: opaque_vec_type, - builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)), - crate_map: crate_map, - crate_map_name: crate_map_name, - uses_gc: false, - dbg_cx: dbg_cx, - do_not_commit_warning_issued: Cell::new(false), + sess: sess, + llmod: llmod, + llcx: llcx, + metadata_llmod: metadata_llmod, + td: td, + tn: tn, + externs: RefCell::new(HashMap::new()), + intrinsics: intrinsics, + item_vals: RefCell::new(HashMap::new()), + exp_map2: emap2, + reachable: reachable, + item_symbols: RefCell::new(HashMap::new()), + link_meta: link_meta, + drop_glues: RefCell::new(HashMap::new()), + tydescs: RefCell::new(HashMap::new()), + finished_tydescs: Cell::new(false), + external: RefCell::new(HashMap::new()), + external_srcs: RefCell::new(HashMap::new()), + non_inlineable_statics: RefCell::new(HashSet::new()), + monomorphized: RefCell::new(HashMap::new()), + monomorphizing: RefCell::new(HashMap::new()), + vtables: RefCell::new(HashMap::new()), + const_cstr_cache: RefCell::new(HashMap::new()), + const_globals: RefCell::new(HashMap::new()), + const_values: RefCell::new(HashMap::new()), + extern_const_values: RefCell::new(HashMap::new()), + impl_method_cache: RefCell::new(HashMap::new()), + closure_bare_wrapper_cache: RefCell::new(HashMap::new()), + module_data: RefCell::new(HashMap::new()), + lltypes: RefCell::new(HashMap::new()), + llsizingtypes: RefCell::new(HashMap::new()), + adt_reprs: RefCell::new(HashMap::new()), + symbol_hasher: RefCell::new(symbol_hasher), + type_hashcodes: RefCell::new(HashMap::new()), + all_llvm_symbols: RefCell::new(HashSet::new()), + tcx: tcx, + maps: maps, + stats: @Stats { + n_static_tydescs: Cell::new(0u), + n_glues_created: Cell::new(0u), + n_null_glues: Cell::new(0u), + n_real_glues: Cell::new(0u), + n_fns: Cell::new(0u), + n_monos: Cell::new(0u), + n_inlines: Cell::new(0u), + n_closures: Cell::new(0u), + n_llvm_insns: Cell::new(0u), + llvm_insns: RefCell::new(HashMap::new()), + fn_stats: RefCell::new(~[]), + }, + tydesc_type: tydesc_type, + int_type: int_type, + opaque_vec_type: opaque_vec_type, + builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)), + crate_map: crate_map, + crate_map_name: crate_map_name, + uses_gc: false, + dbg_cx: dbg_cx, + do_not_commit_warning_issued: Cell::new(false), } } } - pub fn builder(@self) -> Builder { + pub fn builder<'a>(&'a self) -> Builder<'a> { Builder::new(self) } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 2a2421077a8..e7ebc2ef526 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -545,7 +545,11 @@ fn load<'a>(bcx: &'a Block<'a>, llptr: ValueRef, ty: ty::t) -> ValueRef { if type_is_zero_size(bcx.ccx(), ty) { C_undef(type_of::type_of(bcx.ccx(), ty)) } else if ty::type_is_bool(ty) { - LoadRangeAssert(bcx, llptr, 0, 2, lib::llvm::True) + LoadRangeAssert(bcx, llptr, 0, 2, lib::llvm::False) + } else if ty::type_is_char(ty) { + // a char is a unicode codepoint, and so takes values from 0 + // to 0x10FFFF inclusive only. + LoadRangeAssert(bcx, llptr, 0, 0x10FFFF + 1, lib::llvm::False) } else { Load(bcx, llptr) } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 3cdb1c52d3c..d214a192ed8 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -298,7 +298,7 @@ pub fn create_local_var_metadata(bcx: &Block, local: &ast::Local) { Some(datum) => datum, None => { bcx.tcx().sess.span_bug(span, - format!("No entry in lllocals table for {:?}", + format!("no entry in lllocals table for {:?}", node_id)); } } @@ -440,7 +440,7 @@ pub fn create_argument_metadata(bcx: &Block, arg: &ast::Arg) { Some(v) => v, None => { bcx.tcx().sess.span_bug(span, - format!("No entry in llargs table for {:?}", + format!("no entry in llargs table for {:?}", node_id)); } } @@ -1130,9 +1130,31 @@ fn pointer_type_metadata(cx: &CrateContext, return ptr_metadata; } -trait MemberDescriptionFactory { +enum MemberDescriptionFactory { + StructMD(StructMemberDescriptionFactory), + TupleMD(TupleMemberDescriptionFactory), + GeneralMD(GeneralMemberDescriptionFactory), + EnumVariantMD(EnumVariantMemberDescriptionFactory) +} + +impl MemberDescriptionFactory { fn create_member_descriptions(&self, cx: &CrateContext) - -> ~[MemberDescription]; + -> ~[MemberDescription] { + match *self { + StructMD(ref this) => { + this.create_member_descriptions(cx) + } + TupleMD(ref this) => { + this.create_member_descriptions(cx) + } + GeneralMD(ref this) => { + this.create_member_descriptions(cx) + } + EnumVariantMD(ref this) => { + this.create_member_descriptions(cx) + } + } + } } struct StructMemberDescriptionFactory { @@ -1140,7 +1162,7 @@ struct StructMemberDescriptionFactory { span: Span, } -impl MemberDescriptionFactory for StructMemberDescriptionFactory { +impl StructMemberDescriptionFactory { fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription] { self.fields.map(|field| { @@ -1189,10 +1211,10 @@ fn prepare_struct_metadata(cx: &CrateContext, metadata_stub: struct_metadata_stub, llvm_type: struct_llvm_type, file_metadata: file_metadata, - member_description_factory: @StructMemberDescriptionFactory { + member_description_factory: StructMD(StructMemberDescriptionFactory { fields: fields, span: span, - } as @MemberDescriptionFactory, + }), } } @@ -1202,7 +1224,7 @@ enum RecursiveTypeDescription { metadata_stub: DICompositeType, llvm_type: Type, file_metadata: DIFile, - member_description_factory: @MemberDescriptionFactory, + member_description_factory: MemberDescriptionFactory, }, FinalMetadata(DICompositeType) } @@ -1217,7 +1239,7 @@ impl RecursiveTypeDescription { metadata_stub, llvm_type, file_metadata, - member_description_factory + ref member_description_factory } => { // Insert the stub into the cache in order to allow recursive references ... { @@ -1246,7 +1268,7 @@ struct TupleMemberDescriptionFactory { span: Span, } -impl MemberDescriptionFactory for TupleMemberDescriptionFactory { +impl TupleMemberDescriptionFactory { fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription] { self.component_types.map(|&component_type| { @@ -1281,10 +1303,10 @@ fn prepare_tuple_metadata(cx: &CrateContext, span), llvm_type: tuple_llvm_type, file_metadata: file_metadata, - member_description_factory: @TupleMemberDescriptionFactory { + member_description_factory: TupleMD(TupleMemberDescriptionFactory { component_types: component_types.to_owned(), span: span, - } as @MemberDescriptionFactory + }) } } @@ -1297,7 +1319,7 @@ struct GeneralMemberDescriptionFactory { span: Span, } -impl MemberDescriptionFactory for GeneralMemberDescriptionFactory { +impl GeneralMemberDescriptionFactory { fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription] { // Capture type_rep, so we don't have to copy the struct_defs array @@ -1344,7 +1366,7 @@ struct EnumVariantMemberDescriptionFactory { span: Span, } -impl MemberDescriptionFactory for EnumVariantMemberDescriptionFactory { +impl EnumVariantMemberDescriptionFactory { fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription] { self.args.iter().enumerate().map(|(i, &(ref name, ty))| { @@ -1368,7 +1390,7 @@ fn describe_enum_variant(cx: &CrateContext, containing_scope: DIScope, file_metadata: DIFile, span: Span) - -> (DICompositeType, Type, @MemberDescriptionFactory) { + -> (DICompositeType, Type, MemberDescriptionFactory) { let variant_info_string = token::get_ident(variant_info.name.name); let variant_name = variant_info_string.get(); let variant_llvm_type = Type::struct_(struct_def.fields.map(|&t| type_of::type_of(cx, t)), @@ -1424,11 +1446,11 @@ fn describe_enum_variant(cx: &CrateContext, .collect(); let member_description_factory = - @EnumVariantMemberDescriptionFactory { + EnumVariantMD(EnumVariantMemberDescriptionFactory { args: args, discriminant_type_metadata: discriminant_type_metadata, span: span, - } as @MemberDescriptionFactory; + }); (metadata_stub, variant_llvm_type, member_description_factory) } @@ -1556,14 +1578,14 @@ fn prepare_enum_metadata(cx: &CrateContext, metadata_stub: enum_metadata, llvm_type: enum_llvm_type, file_metadata: file_metadata, - member_description_factory: @GeneralMemberDescriptionFactory { + member_description_factory: GeneralMD(GeneralMemberDescriptionFactory { type_rep: type_rep, variants: variants, discriminant_type_metadata: discriminant_type_metadata, containing_scope: containing_scope, file_metadata: file_metadata, span: span, - } as @MemberDescriptionFactory, + }), } } adt::NullablePointer { nonnull: ref struct_def, nndiscr, .. } => { @@ -1757,7 +1779,7 @@ fn boxed_type_metadata(cx: &CrateContext, offset: ComputedMemberOffset, }, MemberDescription { - name: ~"tydesc", + name: ~"drop_glue", llvm_type: member_llvm_types[1], type_metadata: nil_pointer_type_metadata, offset: ComputedMemberOffset, @@ -1802,7 +1824,7 @@ fn boxed_type_metadata(cx: &CrateContext, -> bool { member_llvm_types.len() == 5 && member_llvm_types[0] == cx.int_type && - member_llvm_types[1] == cx.tydesc_type.ptr_to() && + member_llvm_types[1] == Type::generic_glue_fn(cx).ptr_to() && member_llvm_types[2] == Type::i8().ptr_to() && member_llvm_types[3] == Type::i8().ptr_to() && member_llvm_types[4] == content_llvm_type diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 517f9e1a31d..8f0101efb16 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -213,8 +213,7 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, unpack_datum!(bcx, auto_borrow_fn(bcx, adjusted_ty, datum)) } Some(AutoBorrowObj(..)) => { - unpack_datum!(bcx, auto_borrow_obj( - bcx, adj.autoderefs, expr, datum)) + unpack_datum!(bcx, auto_borrow_obj(bcx, expr, datum)) } }; } @@ -326,88 +325,17 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>, auto_ref(bcx, datum, expr) } - fn auto_borrow_obj<'a>( - mut bcx: &'a Block<'a>, - autoderefs: uint, - expr: &ast::Expr, - source_datum: Datum<Expr>) - -> DatumBlock<'a, Expr> { + fn auto_borrow_obj<'a>(bcx: &'a Block<'a>, + expr: &ast::Expr, + source_datum: Datum<Expr>) + -> DatumBlock<'a, Expr> { let tcx = bcx.tcx(); let target_obj_ty = expr_ty_adjusted(bcx, expr); - debug!("auto_borrow_obj(target={})", - target_obj_ty.repr(tcx)); - - // Extract source store information - let (source_store, source_mutbl) = match ty::get(source_datum.ty).sty { - ty::ty_trait(_, _, s, m, _) => (s, m), - _ => { - bcx.sess().span_bug( - expr.span, - format!("auto_borrow_trait_obj expected a trait, found {}", - source_datum.ty.repr(bcx.tcx()))); - } - }; - - // check if any borrowing is really needed or we could reuse - // the source_datum instead - match ty::get(target_obj_ty).sty { - ty::ty_trait(_, _, ty::RegionTraitStore(target_scope), target_mutbl, _) => { - if target_mutbl == ast::MutImmutable && target_mutbl == source_mutbl { - match source_store { - ty::RegionTraitStore(source_scope) => { - if tcx.region_maps.is_subregion_of(target_scope, source_scope) { - return DatumBlock { bcx: bcx, datum: source_datum }; - } - }, - _ => {} + debug!("auto_borrow_obj(target={})", target_obj_ty.repr(tcx)); - }; - } - }, - _ => {} - } - - let scratch = rvalue_scratch_datum(bcx, target_obj_ty, - "__auto_borrow_obj"); - - // Convert a @Object, ~Object, or &Object pair into an &Object pair. - - // Get a pointer to the source object, which is represented as - // a (vtable, data) pair. - let source_datum = unpack_datum!( - bcx, source_datum.to_lvalue_datum(bcx, "auto_borrow_obj", expr.id)); - let source_llval = source_datum.to_llref(); - - // Set the vtable field of the new pair - let vtable_ptr = GEPi(bcx, source_llval, [0u, abi::trt_field_vtable]); - let vtable = Load(bcx, vtable_ptr); - Store(bcx, vtable, GEPi(bcx, scratch.val, [0u, abi::trt_field_vtable])); - - // Load the data for the source, which is either an @T, - // ~T, or &T, depending on source_obj_ty. - let source_data_ptr = GEPi(bcx, source_llval, [0u, abi::trt_field_box]); - let target_data = match source_store { - ty::BoxTraitStore(..) => { - // For deref of @T, create a dummy datum and use the - // datum's deref method. This is more work than just - // calling GEPi ourselves, but it ensures that any - // necessary rooting is performed. Note that we don't - // know the type T, so just substitute `i8`-- it - // doesn't really matter for our purposes right now. - let source_ty = ty::mk_box(tcx, ty::mk_i8()); - let source_datum = Datum(source_data_ptr, source_ty, LvalueExpr); - let derefd_datum = unpack_datum!( - bcx, deref_once(bcx, expr, source_datum, autoderefs)); - derefd_datum.assert_lvalue(bcx).to_llref() - } - ty::UniqTraitStore(..) | ty::RegionTraitStore(..) => { - Load(bcx, source_data_ptr) - } - }; - Store(bcx, target_data, - GEPi(bcx, scratch.val, [0u, abi::trt_field_box])); - - DatumBlock(bcx, scratch.to_expr_datum()) + let mut datum = source_datum.to_expr_datum(); + datum.ty = target_obj_ty; + DatumBlock(bcx, datum) } } diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index bc9dd767ec6..cb638e99ab7 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -81,17 +81,17 @@ pub fn llvm_calling_convention(ccx: &CrateContext, match abi { RustIntrinsic => { // Intrinsics are emitted by monomorphic fn - ccx.sess.bug(format!("Asked to register intrinsic fn")); + ccx.sess.bug(format!("asked to register intrinsic fn")); } Rust => { // FIXME(#3678) Implement linking to foreign fns with Rust ABI ccx.sess.unimpl( - format!("Foreign functions with Rust ABI")); + format!("foreign functions with Rust ABI")); } // It's the ABI's job to select this, not us. - System => ccx.sess.bug("System abi should be selected elsewhere"), + System => ccx.sess.bug("system abi should be selected elsewhere"), Stdcall => lib::llvm::X86StdcallCallConv, Fastcall => lib::llvm::X86FastcallCallConv, @@ -365,7 +365,7 @@ pub fn trans_foreign_mod(ccx: @CrateContext, (abis, (*path).clone()) } _ => { - fail!("Unable to find foreign item in tcx.items \ + fail!("unable to find foreign item in tcx.items \ table.") } }; diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 99eccb8f40b..1b9605a172c 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -65,9 +65,6 @@ pub fn take_ty<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) let _icx = push_ctxt("take_ty"); match ty::get(t).sty { ty::ty_box(_) => incr_refcnt_of_boxed(bcx, v), - ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => { - incr_refcnt_of_boxed(bcx, GEPi(bcx, v, [0u, abi::trt_field_box])) - } _ if ty::type_is_structural(t) && ty::type_needs_drop(bcx.tcx(), t) => { iter_structural_ty(bcx, v, t, take_ty) @@ -76,14 +73,49 @@ pub fn take_ty<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) } } -pub fn drop_ty<'a>(cx: &'a Block<'a>, v: ValueRef, t: ty::t) +fn get_drop_glue_type(ccx: &CrateContext, t: ty::t) -> ty::t { + let tcx = ccx.tcx; + if !ty::type_needs_drop(tcx, t) { + return ty::mk_i8(); + } + match ty::get(t).sty { + ty::ty_box(typ) if !ty::type_needs_drop(tcx, typ) => + ty::mk_box(tcx, ty::mk_i8()), + + ty::ty_uniq(typ) if !ty::type_needs_drop(tcx, typ) => { + let llty = sizing_type_of(ccx, typ); + // Unique boxes do not allocate for zero-size types. The standard library may assume + // that `free` is never called on the pointer returned for `~ZeroSizeType`. + if llsize_of_alloc(ccx, llty) == 0 { + ty::mk_i8() + } else { + ty::mk_uniq(tcx, ty::mk_i8()) + } + } + + ty::ty_vec(mt, ty::vstore_uniq) if !ty::type_needs_drop(tcx, mt.ty) => + ty::mk_uniq(tcx, ty::mk_i8()), + + _ => t + } +} + +pub fn drop_ty<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) -> &'a Block<'a> { // NB: v is an *alias* of type t here, not a direct value. let _icx = push_ctxt("drop_ty"); - if ty::type_needs_drop(cx.tcx(), t) { - return call_tydesc_glue(cx, v, t, abi::tydesc_field_drop_glue); + let ccx = bcx.ccx(); + if ty::type_needs_drop(bcx.tcx(), t) { + let glue = get_drop_glue(ccx, t); + let glue_type = get_drop_glue_type(ccx, t); + let ptr = if glue_type != t { + PointerCast(bcx, v, type_of(ccx, glue_type).ptr_to()) + } else { + v + }; + Call(bcx, glue, [ptr], []); } - return cx; + bcx } pub fn drop_ty_immediate<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) @@ -94,95 +126,49 @@ pub fn drop_ty_immediate<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) drop_ty(bcx, vp, t) } -pub fn lazily_emit_all_tydesc_glue(ccx: @CrateContext, - static_ti: @tydesc_info) { - lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti); - lazily_emit_tydesc_glue(ccx, abi::tydesc_field_visit_glue, static_ti); -} - -fn get_glue_type(ccx: &CrateContext, field: uint, t: ty::t) -> ty::t { - let tcx = ccx.tcx; - if field == abi::tydesc_field_drop_glue { - if !ty::type_needs_drop(tcx, t) { - return ty::mk_i8(); - } - match ty::get(t).sty { - ty::ty_box(typ) if !ty::type_needs_drop(tcx, typ) => - return ty::mk_box(tcx, ty::mk_i8()), - - ty::ty_uniq(typ) if !ty::type_needs_drop(tcx, typ) => { - let llty = sizing_type_of(ccx, typ); - // Unique boxes do not allocate for zero-size types. The standard library may assume - // that `free` is never called on the pointer returned for `~ZeroSizeType`. - if llsize_of_alloc(ccx, llty) == 0 { - return ty::mk_i8(); - } else { - return ty::mk_uniq(tcx, ty::mk_i8()); - } - } - - ty::ty_vec(mt, ty::vstore_uniq) if !ty::type_needs_drop(tcx, mt.ty) => - return ty::mk_uniq(tcx, ty::mk_i8()), - - _ => {} +pub fn get_drop_glue(ccx: @CrateContext, t: ty::t) -> ValueRef { + let t = get_drop_glue_type(ccx, t); + { + let drop_glues = ccx.drop_glues.borrow(); + match drop_glues.get().find(&t) { + Some(&glue) => return glue, + _ => { } } } - t -} + let llfnty = Type::glue_fn(type_of(ccx, t).ptr_to()); + let glue = declare_generic_glue(ccx, t, llfnty, "drop"); -pub fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @tydesc_info) { - let _icx = push_ctxt("lazily_emit_tydesc_glue"); + { + let mut drop_glues = ccx.drop_glues.borrow_mut(); + drop_glues.get().insert(t, glue); + } - let simpl = get_glue_type(ccx, field, ti.ty); - if simpl != ti.ty { - let _icx = push_ctxt("lazily_emit_simplified_tydesc_glue"); - let simpl_ti = get_tydesc(ccx, simpl); - lazily_emit_tydesc_glue(ccx, field, simpl_ti); + make_generic_glue(ccx, t, glue, make_drop_glue, "drop"); - if field == abi::tydesc_field_drop_glue { - ti.drop_glue.set(simpl_ti.drop_glue.get()); - } else if field == abi::tydesc_field_visit_glue { - ti.visit_glue.set(simpl_ti.visit_glue.get()); - } + glue +} - return; - } +pub fn lazily_emit_visit_glue(ccx: @CrateContext, ti: @tydesc_info) { + let _icx = push_ctxt("lazily_emit_visit_glue"); let llfnty = Type::glue_fn(type_of(ccx, ti.ty).ptr_to()); - if field == abi::tydesc_field_drop_glue { - match ti.drop_glue.get() { - Some(_) => (), - None => { - debug!("+++ lazily_emit_tydesc_glue DROP {}", - ppaux::ty_to_str(ccx.tcx, ti.ty)); - let glue_fn = declare_generic_glue(ccx, ti.ty, llfnty, "drop"); - ti.drop_glue.set(Some(glue_fn)); - make_generic_glue(ccx, ti.ty, glue_fn, make_drop_glue, "drop"); - debug!("--- lazily_emit_tydesc_glue DROP {}", - ppaux::ty_to_str(ccx.tcx, ti.ty)); - } - } - } else if field == abi::tydesc_field_visit_glue { - match ti.visit_glue.get() { - Some(_) => (), - None => { - debug!("+++ lazily_emit_tydesc_glue VISIT {}", - ppaux::ty_to_str(ccx.tcx, ti.ty)); + match ti.visit_glue.get() { + Some(_) => (), + None => { + debug!("+++ lazily_emit_tydesc_glue VISIT {}", ppaux::ty_to_str(ccx.tcx, ti.ty)); let glue_fn = declare_generic_glue(ccx, ti.ty, llfnty, "visit"); ti.visit_glue.set(Some(glue_fn)); make_generic_glue(ccx, ti.ty, glue_fn, make_visit_glue, "visit"); - debug!("--- lazily_emit_tydesc_glue VISIT {}", - ppaux::ty_to_str(ccx.tcx, ti.ty)); - } + debug!("--- lazily_emit_tydesc_glue VISIT {}", ppaux::ty_to_str(ccx.tcx, ti.ty)); } } } // See [Note-arg-mode] -pub fn call_tydesc_glue_full(bcx: &Block, v: ValueRef, tydesc: ValueRef, - field: uint, static_ti: Option<@tydesc_info>) { +pub fn call_visit_glue(bcx: &Block, v: ValueRef, tydesc: ValueRef, + static_ti: Option<@tydesc_info>) { let _icx = push_ctxt("call_tydesc_glue_full"); let ccx = bcx.ccx(); // NB: Don't short-circuit even if this block is unreachable because @@ -192,37 +178,23 @@ pub fn call_tydesc_glue_full(bcx: &Block, v: ValueRef, tydesc: ValueRef, let static_glue_fn = match static_ti { None => None, Some(sti) => { - lazily_emit_tydesc_glue(ccx, field, sti); - if field == abi::tydesc_field_drop_glue { - sti.drop_glue.get() - } else if field == abi::tydesc_field_visit_glue { - sti.visit_glue.get() - } else { - None - } + lazily_emit_visit_glue(ccx, sti); + sti.visit_glue.get() } }; - // When static type info is available, avoid casting parameter unless the - // glue is using a simplified type, because the function already has the - // right type. Otherwise cast to generic pointer. + // When static type info is available, avoid casting to a generic pointer. let llrawptr = if static_glue_fn.is_none() { PointerCast(bcx, v, Type::i8p()) } else { - let ty = static_ti.unwrap().ty; - let simpl = get_glue_type(ccx, field, ty); - if simpl != ty { - PointerCast(bcx, v, type_of(ccx, simpl).ptr_to()) - } else { - v - } + v }; let llfn = { match static_glue_fn { None => { // Select out the glue function to call from the tydesc - let llfnptr = GEPi(bcx, tydesc, [0u, field]); + let llfnptr = GEPi(bcx, tydesc, [0u, abi::tydesc_field_visit_glue]); Load(bcx, llfnptr) } Some(sgf) => sgf @@ -232,15 +204,6 @@ pub fn call_tydesc_glue_full(bcx: &Block, v: ValueRef, tydesc: ValueRef, Call(bcx, llfn, [llrawptr], []); } -// See [Note-arg-mode] -fn call_tydesc_glue<'a>(cx: &'a Block<'a>, v: ValueRef, t: ty::t, field: uint) - -> &'a Block<'a> { - let _icx = push_ctxt("call_tydesc_glue"); - let ti = get_tydesc(cx.ccx(), t); - call_tydesc_glue_full(cx, v, ti.tydesc, field, Some(ti)); - cx -} - fn make_visit_glue<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t) -> &'a Block<'a> { let _icx = push_ctxt("make_visit_glue"); @@ -323,7 +286,7 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<' let ccx = bcx.ccx(); match ty::get(t).sty { ty::ty_box(body_ty) => { - decr_refcnt_maybe_free(bcx, v0, Some(body_ty)) + decr_refcnt_maybe_free(bcx, v0, body_ty) } ty::ty_uniq(content_ty) => { let llbox = Load(bcx, v0); @@ -354,17 +317,13 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<' } } } - ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => { - let llbox_ptr = GEPi(bcx, v0, [0u, abi::trt_field_box]); - decr_refcnt_maybe_free(bcx, llbox_ptr, None) - } ty::ty_trait(_, _, ty::UniqTraitStore, _, _) => { let lluniquevalue = GEPi(bcx, v0, [0, abi::trt_field_box]); // Only drop the value when it is non-null with_cond(bcx, IsNotNull(bcx, Load(bcx, lluniquevalue)), |bcx| { - let lldtor_ptr = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable])); - let lldtor = Load(bcx, lldtor_ptr); - Call(bcx, lldtor, [PointerCast(bcx, lluniquevalue, Type::i8p())], []); + let dtor_ptr = Load(bcx, GEPi(bcx, v0, [0, abi::trt_field_vtable])); + let dtor = Load(bcx, dtor_ptr); + Call(bcx, dtor, [PointerCast(bcx, lluniquevalue, Type::i8p())], []); bcx }) } @@ -374,18 +333,12 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<' let env_ptr_ty = Type::at_box(ccx, Type::i8()).ptr_to(); let env = PointerCast(bcx, env, env_ptr_ty); with_cond(bcx, IsNotNull(bcx, env), |bcx| { - // Load the type descr found in the env - let lltydescty = ccx.tydesc_type.ptr_to(); - let tydescptr = GEPi(bcx, env, [0u, abi::box_field_tydesc]); - let tydesc = Load(bcx, tydescptr); - let tydesc = PointerCast(bcx, tydesc, lltydescty); - - // Drop the tuple data then free the descriptor + let dtor_ptr = GEPi(bcx, env, [0u, abi::box_field_tydesc]); + let dtor = Load(bcx, dtor_ptr); let cdata = GEPi(bcx, env, [0u, abi::box_field_body]); - call_tydesc_glue_full(bcx, cdata, tydesc, - abi::tydesc_field_drop_glue, None); + Call(bcx, dtor, [PointerCast(bcx, cdata, Type::i8p())], []); - // Free the ty descr (if necc) and the env itself + // Free the environment itself trans_exchange_free(bcx, env) }) } @@ -400,8 +353,9 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<' } } -fn decr_refcnt_maybe_free<'a>(bcx: &'a Block<'a>, box_ptr_ptr: ValueRef, - t: Option<ty::t>) -> &'a Block<'a> { +fn decr_refcnt_maybe_free<'a>(bcx: &'a Block<'a>, + box_ptr_ptr: ValueRef, + t: ty::t) -> &'a Block<'a> { let _icx = push_ctxt("decr_refcnt_maybe_free"); let fcx = bcx.fcx; let ccx = bcx.ccx(); @@ -421,16 +375,7 @@ fn decr_refcnt_maybe_free<'a>(bcx: &'a Block<'a>, box_ptr_ptr: ValueRef, let v = Load(free_bcx, box_ptr_ptr); let body = GEPi(free_bcx, v, [0u, abi::box_field_body]); - let free_bcx = match t { - Some(t) => drop_ty(free_bcx, body, t), - None => { - // Generate code that, dynamically, indexes into the - // tydesc and calls the drop glue that got set dynamically - let td = Load(free_bcx, GEPi(free_bcx, v, [0u, abi::box_field_tydesc])); - call_tydesc_glue_full(free_bcx, body, td, abi::tydesc_field_drop_glue, None); - free_bcx - } - }; + let free_bcx = drop_ty(free_bcx, body, t); let free_bcx = trans_free(free_bcx, v); Br(free_bcx, next_bcx.llbb); @@ -483,7 +428,6 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info { size: llsize, align: llalign, name: ty_name, - drop_glue: Cell::new(None), visit_glue: Cell::new(None), }; debug!("--- declare_tydesc {}", ppaux::ty_to_str(ccx.tcx, t)); @@ -535,7 +479,7 @@ fn make_generic_glue(ccx: @CrateContext, llfn } -pub fn emit_tydescs(ccx: &CrateContext) { +pub fn emit_tydescs(ccx: @CrateContext) { let _icx = push_ctxt("emit_tydescs"); // As of this point, allow no more tydescs to be created. ccx.finished_tydescs.set(true); @@ -548,21 +492,10 @@ pub fn emit_tydescs(ccx: &CrateContext) { // before being put into the tydesc because we only have a singleton // tydesc type. Then we'll recast each function to its real type when // calling it. - let drop_glue = - match ti.drop_glue.get() { - None => { - ccx.stats.n_null_glues.set(ccx.stats.n_null_glues.get() + - 1u); - C_null(glue_fn_ty) - } - Some(v) => { - unsafe { - ccx.stats.n_real_glues.set(ccx.stats.n_real_glues.get() + - 1); - llvm::LLVMConstPointerCast(v, glue_fn_ty.to_ref()) - } - } - }; + let drop_glue = unsafe { + llvm::LLVMConstPointerCast(get_drop_glue(ccx, ti.ty), glue_fn_ty.to_ref()) + }; + ccx.stats.n_real_glues.set(ccx.stats.n_real_glues.get() + 1); let visit_glue = match ti.visit_glue.get() { None => { diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index 49f1b073f87..653f56c6de3 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -11,7 +11,6 @@ #[allow(non_uppercase_pattern_statics)]; use arena::TypedArena; -use back::abi; use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg}; use lib::llvm::{ValueRef, Pointer, Array, Struct}; use lib; @@ -228,7 +227,7 @@ pub fn trans_intrinsic(ccx: @CrateContext, "acq" => lib::llvm::Acquire, "rel" => lib::llvm::Release, "acqrel" => lib::llvm::AcquireRelease, - _ => ccx.sess.fatal("Unknown ordering in atomic intrinsic") + _ => ccx.sess.fatal("unknown ordering in atomic intrinsic") } }; @@ -269,7 +268,7 @@ pub fn trans_intrinsic(ccx: @CrateContext, "min" => lib::llvm::Min, "umax" => lib::llvm::UMax, "umin" => lib::llvm::UMin, - _ => ccx.sess.fatal("Unknown atomic operation") + _ => ccx.sess.fatal("unknown atomic operation") }; let old = AtomicRMW(bcx, atom_op, get_param(decl, first_real_arg), @@ -326,7 +325,7 @@ pub fn trans_intrinsic(ccx: @CrateContext, "get_tydesc" => { let tp_ty = substs.tys[0]; let static_ti = get_tydesc(ccx, tp_ty); - glue::lazily_emit_all_tydesc_glue(ccx, static_ti); + glue::lazily_emit_visit_glue(ccx, static_ti); // FIXME (#3730): ideally this shouldn't need a cast, // but there's a circularity between translating rust types to llvm @@ -459,21 +458,9 @@ pub fn trans_intrinsic(ccx: @CrateContext, let td = get_param(decl, first_real_arg); let visitor = get_param(decl, first_real_arg + 1u); let td = PointerCast(bcx, td, ccx.tydesc_type.ptr_to()); - glue::call_tydesc_glue_full(bcx, visitor, td, - abi::tydesc_field_visit_glue, None); + glue::call_visit_glue(bcx, visitor, td, None); RetVoid(bcx); } - "morestack_addr" => { - // FIXME This is a hack to grab the address of this particular - // native function. There should be a general in-language - // way to do this - let llfty = type_of_rust_fn(bcx.ccx(), false, [], ty::mk_nil()); - let morestack_addr = decl_cdecl_fn(bcx.ccx().llmod, "__morestack", - llfty, ty::mk_nil()); - let morestack_addr = PointerCast(bcx, morestack_addr, - Type::nil().ptr_to()); - Ret(bcx, morestack_addr); - } "offset" => { let ptr = get_param(decl, first_real_arg); let offset = get_param(decl, first_real_arg + 1); diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index b13a8800cee..4a1ba7b22ac 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -350,7 +350,7 @@ fn trans_trait_callee<'a>(bcx: &'a Block<'a>, -> Callee<'a> { /*! * Create a method callee where the method is coming from a trait - * object (e.g., @Trait type). In this case, we must pull the fn + * object (e.g., ~Trait type). In this case, we must pull the fn * pointer out of the vtable that is packaged up with the object. * Objects are represented as a pair, so we first evaluate the self * expression and then extract the self data and vtable out of the @@ -479,11 +479,9 @@ pub fn get_vtable(bcx: &Block, } }); - // Generate a type descriptor for the vtable. - let tydesc = get_tydesc(ccx, self_ty); - glue::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, tydesc); - - let vtable = make_vtable(ccx, tydesc, methods); + // Generate a destructor for the vtable. + let drop_glue = glue::get_drop_glue(ccx, self_ty); + let vtable = make_vtable(ccx, drop_glue, methods); let mut vtables = ccx.vtables.borrow_mut(); vtables.get().insert(hash_id, vtable); @@ -492,13 +490,13 @@ pub fn get_vtable(bcx: &Block, /// Helper function to declare and initialize the vtable. pub fn make_vtable(ccx: &CrateContext, - tydesc: &tydesc_info, + drop_glue: ValueRef, ptrs: &[ValueRef]) -> ValueRef { unsafe { let _icx = push_ctxt("meth::make_vtable"); - let mut components = ~[tydesc.drop_glue.get().unwrap()]; + let mut components = ~[drop_glue]; for &ptr in ptrs.iter() { components.push(ptr) } diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 25c536f2a6d..61100220ffb 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -98,7 +98,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, session::expect( ccx.sess, ccx.tcx.items.find(fn_id.node), - || format!("While monomorphizing {:?}, couldn't find it in the \ + || format!("while monomorphizing {:?}, couldn't find it in the \ item map (may have attempted to monomorphize an item \ defined in a different crate?)", fn_id)) }; @@ -286,7 +286,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, d } _ => { - ccx.tcx.sess.bug(format!("Can't monomorphize a {:?}", + ccx.tcx.sess.bug(format!("can't monomorphize a {:?}", map_node)) } } @@ -310,7 +310,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, ast_map::NodeBlock(..) | ast_map::NodeCalleeScope(..) | ast_map::NodeLocal(..) => { - ccx.tcx.sess.bug(format!("Can't monomorphize a {:?}", map_node)) + ccx.tcx.sess.bug(format!("can't monomorphize a {:?}", map_node)) } }; diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index b9d23c47fcd..1a1ae97bbcd 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -81,7 +81,7 @@ impl<'a> Reflector<'a> { pub fn c_tydesc(&mut self, t: ty::t) -> ValueRef { let bcx = self.bcx; let static_ti = get_tydesc(bcx.ccx(), t); - glue::lazily_emit_all_tydesc_glue(bcx.ccx(), static_ti); + glue::lazily_emit_visit_glue(bcx.ccx(), static_ti); PointerCast(bcx, static_ti.tydesc, self.tydesc_ty.ptr_to()) } @@ -95,7 +95,7 @@ impl<'a> Reflector<'a> { let tcx = self.bcx.tcx(); let mth_idx = ty::method_idx( tcx.sess.ident_of(~"visit_" + ty_name), - *self.visitor_methods).expect(format!("Couldn't find visit method \ + *self.visitor_methods).expect(format!("couldn't find visit method \ for {}", ty_name)); let mth_ty = ty::mk_bare_fn(tcx, self.visitor_methods[mth_idx].fty.clone()); diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index a0a1ff20a9a..c8180362bc5 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -404,7 +404,7 @@ pub fn write_content<'a>( } _ => { bcx.tcx().sess.span_bug(content_expr.span, - "Unexpected evec content"); + "unexpected evec content"); } } } @@ -465,7 +465,7 @@ pub fn write_content<'a>( } _ => { bcx.tcx().sess.span_bug(content_expr.span, - "Unexpected vec content"); + "unexpected vec content"); } } } @@ -498,7 +498,7 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint { ast::LitStr(ref s, _) => s.get().len(), _ => { bcx.tcx().sess.span_bug(content_expr.span, - "Unexpected evec content") + "unexpected evec content") } } }, @@ -507,7 +507,7 @@ pub fn elements_required(bcx: &Block, content_expr: &ast::Expr) -> uint { ty::eval_repeat_count(&bcx.tcx(), count_expr) } _ => bcx.tcx().sess.span_bug(content_expr.span, - "Unexpected vec content") + "unexpected vec content") } } diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs index 39a99ef9950..804486c4159 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc/middle/trans/type_.rs @@ -13,8 +13,6 @@ use lib::llvm::{llvm, TypeRef, Bool, False, True, TypeKind}; use lib::llvm::{Float, Double, X86_FP80, PPC_FP128, FP128}; -use middle::ty; - use middle::trans::context::CrateContext; use middle::trans::base; @@ -240,19 +238,14 @@ impl Type { // The box pointed to by @T. pub fn at_box(ctx: &CrateContext, ty: Type) -> Type { Type::struct_([ - ctx.int_type, ctx.tydesc_type.ptr_to(), + ctx.int_type, Type::glue_fn(Type::i8p()).ptr_to(), Type::i8p(), Type::i8p(), ty ], false) } - pub fn opaque_trait(ctx: &CrateContext, store: ty::TraitStore) -> Type { + pub fn opaque_trait() -> Type { let vtable = Type::glue_fn(Type::i8p()).ptr_to().ptr_to(); - let box_ty = match store { - ty::BoxTraitStore => Type::at_box(ctx, Type::i8()), - ty::UniqTraitStore => Type::i8(), - ty::RegionTraitStore(..) => Type::i8() - }; - Type::struct_([vtable, box_ty.ptr_to()], false) + Type::struct_([vtable, Type::i8p()], false) } pub fn kind(&self) -> TypeKind { diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 0bc5ffd1019..00d67a60ac4 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -129,7 +129,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type { ty::ty_bare_fn(..) => Type::i8p(), ty::ty_closure(..) => Type::struct_([Type::i8p(), Type::i8p()], false), - ty::ty_trait(_, _, store, _, _) => Type::opaque_trait(cx, store), + ty::ty_trait(..) => Type::opaque_trait(), ty::ty_str(ty::vstore_fixed(size)) => Type::array(&Type::i8(), size as u64), ty::ty_vec(mt, ty::vstore_fixed(size)) => { @@ -262,7 +262,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { let fn_ty = type_of_fn_from_ty(cx, t).ptr_to(); Type::struct_([fn_ty, Type::i8p()], false) } - ty::ty_trait(_, _, store, _, _) => Type::opaque_trait(cx, store), + ty::ty_trait(..) => Type::opaque_trait(), ty::ty_type => cx.tydesc_type.ptr_to(), ty::ty_tup(..) => { let repr = adt::represent_type(cx, t); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 003a10eb482..7b2aee9274a 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -135,7 +135,6 @@ pub enum vstore { #[deriving(Clone, Eq, IterBytes, Encodable, Decodable, ToStr)] pub enum TraitStore { - BoxTraitStore, // @Trait UniqTraitStore, // ~Trait RegionTraitStore(Region), // &Trait } @@ -238,7 +237,7 @@ pub enum AutoRef { /// Convert from T to *T AutoUnsafe(ast::Mutability), - /// Convert from @Trait/~Trait/&Trait to &Trait + /// Convert from ~Trait/&Trait to &Trait AutoBorrowObj(Region, ast::Mutability), } @@ -2102,7 +2101,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { ty_type => TC::None, ty_err => { - cx.sess.bug("Asked to compute contents of error type"); + cx.sess.bug("asked to compute contents of error type"); } }; @@ -2156,10 +2155,9 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { let st = match cty.sigil { ast::BorrowedSigil => object_contents(cx, RegionTraitStore(cty.region), MutMutable, cty.bounds), - ast::ManagedSigil => - object_contents(cx, BoxTraitStore, MutImmutable, cty.bounds), ast::OwnedSigil => object_contents(cx, UniqTraitStore, MutImmutable, cty.bounds), + ast::ManagedSigil => unreachable!() }; // FIXME(#3569): This borrowed_contents call should be taken care of in @@ -2190,9 +2188,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { UniqTraitStore => { contents.owned_pointer() } - BoxTraitStore => { - contents.managed_pointer() - } RegionTraitStore(r) => { contents.reference(borrowed_contents(r, mutbl)) } @@ -2931,7 +2926,7 @@ pub fn adjust_ty(cx: ctxt, None => { cx.sess.span_bug( span, - format!("The {}th autoderef failed: \ + format!("the {}th autoderef failed: \ {}", i, ty_to_str(cx, adjusted_ty))); @@ -3060,7 +3055,7 @@ pub fn trait_adjustment_to_ty(cx: ctxt, sigil: &ast::Sigil, region: &Option<Regi let trait_store = match *sigil { BorrowedSigil => RegionTraitStore(region.expect("expected valid region")), OwnedSigil => UniqTraitStore, - ManagedSigil => BoxTraitStore + ManagedSigil => unreachable!() }; mk_trait(cx, def_id, substs.clone(), trait_store, m, bounds) @@ -3137,7 +3132,7 @@ pub fn resolve_expr(tcx: ctxt, expr: &ast::Expr) -> ast::Def { Some(&def) => def, None => { tcx.sess.span_bug(expr.span, format!( - "No def-map entry for expr {:?}", expr.id)); + "no def-map entry for expr {:?}", expr.id)); } } } @@ -3214,7 +3209,7 @@ pub fn expr_kind(tcx: ctxt, def => { tcx.sess.span_bug(expr.span, format!( - "Uncategorized def for expr {:?}: {:?}", + "uncategorized def for expr {:?}: {:?}", expr.id, def)); } } @@ -3340,7 +3335,7 @@ pub fn field_idx_strict(tcx: ty::ctxt, name: ast::Name, fields: &[field]) for f in fields.iter() { if f.ident.name == name { return i; } i += 1u; } let string = token::get_ident(name); tcx.sess.bug(format!( - "No field named `{}` found in the list of fields `{:?}`", + "no field named `{}` found in the list of fields `{:?}`", string.get(), fields.map(|f| tcx.sess.str_of(f.ident)))); } @@ -3692,7 +3687,7 @@ fn lookup_locally_or_in_crate_store<V:Clone>( } if def_id.crate == ast::LOCAL_CRATE { - fail!("No def'n found for {:?} in tcx.{}", def_id, descr); + fail!("no def'n found for {:?} in tcx.{}", def_id, descr); } let v = load_external(); map.insert(def_id, v.clone()); @@ -4935,10 +4930,9 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 { hash.input([17]); did(&mut hash, d); match store { - BoxTraitStore => hash.input([0]), - UniqTraitStore => hash.input([1]), + UniqTraitStore => hash.input([0]), RegionTraitStore(r) => { - hash.input([2]); + hash.input([1]); region(&mut hash, r); } } diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index 63d6e2ae442..9c923077d7d 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -211,7 +211,6 @@ pub fn super_fold_trait_store<T:TypeFolder>(this: &mut T, -> ty::TraitStore { match trait_store { ty::UniqTraitStore => ty::UniqTraitStore, - ty::BoxTraitStore => ty::BoxTraitStore, ty::RegionTraitStore(r) => ty::RegionTraitStore(this.fold_region(r)), } } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 906bb504bb0..f80658e8ac2 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -409,7 +409,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( } } - // Handle @, ~, and & being able to mean strs and vecs. + // Handle ~, and & being able to mean strs and vecs. // If a_seq_ty is a str or a vec, make it a str/vec. // Also handle first-class trait types. fn mk_pointer<AC:AstConv, @@ -449,17 +449,16 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( let result = ast_path_to_trait_ref( this, rscope, trait_def_id, None, path); let trait_store = match ptr_ty { - Box => ty::BoxTraitStore, VStore(ty::vstore_uniq) => ty::UniqTraitStore, VStore(ty::vstore_slice(r)) => { ty::RegionTraitStore(r) } - VStore(ty::vstore_fixed(..)) => { + _ => { tcx.sess.span_err( path.span, - "@trait, ~trait or &trait are the only supported \ + "~trait or &trait are the only supported \ forms of casting-to-trait"); - ty::BoxTraitStore + return ty::mk_err(); } }; let bounds = conv_builtin_bounds(this.tcx(), bounds, trait_store); @@ -546,7 +545,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>( // if none were specified. ast::BorrowedSigil => ty::RegionTraitStore(ty::ReEmpty), // dummy region ast::OwnedSigil => ty::UniqTraitStore, - ast::ManagedSigil => ty::BoxTraitStore, + ast::ManagedSigil => return ty::mk_err() }); let fn_decl = ty_of_closure(this, rscope, @@ -718,9 +717,6 @@ fn ty_of_method_or_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId, ty::mt {ty: self_info.untransformed_self_ty, mutbl: mutability})) } - ast::SelfBox => { - Some(ty::mk_box(this.tcx(), self_info.untransformed_self_ty)) - } ast::SelfUniq => { Some(ty::mk_uniq(this.tcx(), self_info.untransformed_self_ty)) } @@ -868,9 +864,7 @@ fn conv_builtin_bounds(tcx: ty::ctxt, ast_bounds: &Option<OptVec<ast::TyParamBou (&None, ty::UniqTraitStore) => { let mut set = ty::EmptyBuiltinBounds(); set.add(ty::BoundSend); set } - // @Trait is sugar for @Trait:'static. // &'static Trait is sugar for &'static Trait:'static. - (&None, ty::BoxTraitStore) | (&None, ty::RegionTraitStore(ty::ReStatic)) => { let mut set = ty::EmptyBuiltinBounds(); set.add(ty::BoundStatic); set } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index d32d51c251a..f19ca049368 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -72,9 +72,9 @@ Both the inherent candidate collection and the candidate selection proceed by progressively deref'ing the receiver type, after all. The answer is that two phases are needed to elegantly deal with explicit self. After all, if there is an impl for the type `Foo`, it can -define a method with the type `@self`, which means that it expects a -receiver of type `@Foo`. If we have a receiver of type `@Foo`, but we -waited to search for that impl until we have deref'd the `@` away and +define a method with the type `~self`, which means that it expects a +receiver of type `~Foo`. If we have a receiver of type `~Foo`, but we +waited to search for that impl until we have deref'd the `~` away and obtained the type `Foo`, we would never match this method. */ @@ -101,7 +101,7 @@ use std::cell::RefCell; use std::hashmap::HashSet; use std::result; use std::vec; -use syntax::ast::{DefId, SelfValue, SelfRegion, SelfBox}; +use syntax::ast::{DefId, SelfValue, SelfRegion}; use syntax::ast::{SelfUniq, SelfStatic, NodeId}; use syntax::ast::{MutMutable, MutImmutable}; use syntax::ast; @@ -201,8 +201,8 @@ pub struct Candidate { /// considered to "match" a given method candidate. Typically the test /// is whether the receiver is of a particular type. However, this /// type is the type of the receiver *after accounting for the -/// method's self type* (e.g., if the method is an `@self` method, we -/// have *already verified* that the receiver is of some type `@T` and +/// method's self type* (e.g., if the method is an `~self` method, we +/// have *already verified* that the receiver is of some type `~T` and /// now we must check that the type `T` is correct). Unfortunately, /// because traits are not types, this is a pain to do. #[deriving(Clone)] @@ -789,7 +789,7 @@ impl<'a> LookupContext<'a> { ty_err => None, ty_unboxed_vec(_) | ty_type | ty_infer(TyVar(_)) => { - self.bug(format!("Unexpected type: {}", + self.bug(format!("unexpected type: {}", self.ty_to_str(self_ty))); } } @@ -1081,7 +1081,7 @@ impl<'a> LookupContext<'a> { ast::SelfValue => { ty::mk_err() // error reported in `enforce_object_limitations()` } - ast::SelfRegion(..) | ast::SelfBox | ast::SelfUniq => { + ast::SelfRegion(..) | ast::SelfUniq => { let transformed_self_ty = method_ty.fty.sig.inputs[0]; match ty::get(transformed_self_ty).sty { ty::ty_rptr(r, mt) => { // must be SelfRegion @@ -1089,11 +1089,6 @@ impl<'a> LookupContext<'a> { substs, RegionTraitStore(r), mt.mutbl, ty::EmptyBuiltinBounds()) } - ty::ty_box(_) => { // must be SelfBox - ty::mk_trait(self.tcx(), trait_def_id, - substs, BoxTraitStore, ast::MutImmutable, - ty::EmptyBuiltinBounds()) - } ty::ty_uniq(_) => { // must be SelfUniq ty::mk_trait(self.tcx(), trait_def_id, substs, UniqTraitStore, ast::MutImmutable, @@ -1140,7 +1135,7 @@ impl<'a> LookupContext<'a> { through an object"); } - ast::SelfRegion(..) | ast::SelfBox | ast::SelfUniq => {} + ast::SelfRegion(..) | ast::SelfUniq => {} } // reason (a) above @@ -1232,21 +1227,6 @@ impl<'a> LookupContext<'a> { } } - SelfBox => { - debug!("(is relevant?) explicit self is a box"); - match ty::get(rcvr_ty).sty { - ty::ty_box(typ) => { - rcvr_matches_ty(self.fcx, typ, candidate) - } - - ty::ty_trait(self_did, _, BoxTraitStore, ast::MutImmutable, _) => { - rcvr_matches_object(self_did, candidate) - } - - _ => false - } - } - SelfUniq => { debug!("(is relevant?) explicit self is a unique pointer"); match ty::get(rcvr_ty).sty { @@ -1360,8 +1340,8 @@ impl<'a> LookupContext<'a> { ty::item_path_str(self.tcx(), did))); } - fn infcx(&self) -> @infer::InferCtxt { - self.fcx.inh.infcx + fn infcx(&'a self) -> &'a infer::InferCtxt { + &self.fcx.inh.infcx } fn tcx(&self) -> ty::ctxt { diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index e1679c81a0e..2332152a5d7 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -154,7 +154,7 @@ pub mod method; /// `bar()` will each have their own `FnCtxt`, but they will /// share the inherited fields. pub struct Inherited { - infcx: @infer::InferCtxt, + infcx: infer::InferCtxt, locals: @RefCell<HashMap<ast::NodeId, ty::t>>, param_env: ty::ParameterEnvironment, @@ -517,9 +517,9 @@ pub fn check_no_duplicate_fields(tcx: ty::ctxt, let orig_sp = field_names.find(&id).map(|x| *x); match orig_sp { Some(orig_sp) => { - tcx.sess.span_err(sp, format!("Duplicate field name {} in record type declaration", + tcx.sess.span_err(sp, format!("duplicate field name {} in record type declaration", tcx.sess.str_of(id))); - tcx.sess.span_note(orig_sp, "First declaration of this field occurred here"); + tcx.sess.span_note(orig_sp, "first declaration of this field occurred here"); break; } None => { @@ -936,7 +936,7 @@ fn compare_impl_method(tcx: ty::ctxt, }; debug!("trait_fty (post-subst): {}", trait_fty.repr(tcx)); - match infer::mk_subty(infcx, false, infer::MethodCompatCheck(impl_m_span), + match infer::mk_subty(&infcx, false, infer::MethodCompatCheck(impl_m_span), impl_fty, trait_fty) { result::Ok(()) => {} result::Err(ref terr) => { @@ -967,8 +967,8 @@ impl AstConv for FnCtxt { } impl FnCtxt { - pub fn infcx(&self) -> @infer::InferCtxt { - self.inh.infcx + pub fn infcx<'a>(&'a self) -> &'a infer::InferCtxt { + &self.inh.infcx } pub fn err_count_since_creation(&self) -> uint { @@ -983,13 +983,12 @@ impl FnCtxt { } } -impl RegionScope for @infer::InferCtxt { - fn anon_regions(&self, - span: Span, - count: uint) -> Result<~[ty::Region], ()> { - Ok(vec::from_fn( - count, - |_| self.next_region_var(infer::MiscVariable(span)))) +impl RegionScope for infer::InferCtxt { + fn anon_regions(&self, span: Span, count: uint) + -> Result<~[ty::Region], ()> { + Ok(vec::from_fn(count, |_| { + self.next_region_var(infer::MiscVariable(span)) + })) } } @@ -1007,7 +1006,7 @@ impl FnCtxt { None => { self.tcx().sess.span_bug( span, - format!("No type for local variable {:?}", nid)); + format!("no type for local variable {:?}", nid)); } } } @@ -1076,7 +1075,7 @@ impl FnCtxt { } pub fn to_ty(&self, ast_t: &ast::Ty) -> ty::t { - ast_ty_to_ty(self, &self.infcx(), ast_t) + ast_ty_to_ty(self, self.infcx(), ast_t) } pub fn pat_to_str(&self, pat: &ast::Pat) -> ~str { @@ -1620,7 +1619,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, _ => { fcx.tcx().sess.span_bug( sp, - format!("Method without bare fn type")); + format!("method without bare fn type")); } } } @@ -2243,7 +2242,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt, // construct the function type let fn_ty = astconv::ty_of_closure(fcx, - &fcx.infcx(), + fcx.infcx(), expr.id, sigil, purity, @@ -4128,9 +4127,6 @@ pub fn check_intrinsic_type(ccx: @CrateCtxt, it: &ast::ForeignItem) { }); (0, ~[ td_ptr, visitor_object_ty ], ty::mk_nil()) } - "morestack_addr" => { - (0u, ~[], ty::mk_nil_ptr(ccx.tcx)) - } "offset" => { (1, ~[ diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 6d46cd38087..ac15d52ff13 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -473,7 +473,7 @@ fn check_expr_fn_block(rcx: &mut Rcx, _ => { tcx.sess.span_bug( expr.span, - "Expected expr_fn_block"); + "expected expr_fn_block"); } } } @@ -1189,7 +1189,7 @@ pub mod guarantor { None => { tcx.sess.span_bug( expr.span, - format!("Autoderef but type not derefable: {}", + format!("autoderef but type not derefable: {}", ty_to_str(tcx, ct.ty))); } } @@ -1213,9 +1213,7 @@ pub mod guarantor { ty::ty_vec(_, ty::vstore_uniq) => { OwnedPointer } - ty::ty_box(..) | - ty::ty_ptr(..) | - ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => { + ty::ty_box(..) | ty::ty_ptr(..) => { OtherPointer } ty::ty_closure(ref closure_ty) => { diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 4db43b2c913..64589e64f98 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -73,7 +73,7 @@ pub struct LocationInfo { /// A vtable context includes an inference context, a crate context, and a /// callback function to call in case of type error. pub struct VtableContext<'a> { - infcx: @infer::InferCtxt, + infcx: &'a infer::InferCtxt, param_env: &'a ty::ParameterEnvironment, } @@ -578,11 +578,10 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: @FnCtxt, is_early: bool) { // Look up vtables for the type we're casting to, // passing in the source and target type. The source // must be a pointer type suitable to the object sigil, - // e.g.: `@x as @Trait`, `&x as &Trait` or `~x as ~Trait` + // e.g.: `&x as &Trait` or `~x as ~Trait` let ty = structurally_resolved_type(fcx, ex.span, fcx.expr_ty(src)); match (&ty::get(ty).sty, store) { - (&ty::ty_box(..), ty::BoxTraitStore) | (&ty::ty_uniq(..), ty::UniqTraitStore) if !mutability_allowed(ast::MutImmutable, target_mutbl) => { @@ -596,7 +595,6 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: @FnCtxt, is_early: bool) { format!("types differ in mutability")); } - (&ty::ty_box(..), ty::BoxTraitStore) | (&ty::ty_uniq(..), ty::UniqTraitStore) | (&ty::ty_rptr(..), ty::RegionTraitStore(..)) => { let typ = match &ty::get(ty).sty { @@ -657,14 +655,6 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: @FnCtxt, is_early: bool) { ty::ty_sort_str(fcx.tcx(), ty))); } - (_, ty::BoxTraitStore) => { - fcx.ccx.tcx.sess.span_err( - ex.span, - format!("can only cast an @-pointer \ - to an @-object, not a {}", - ty::ty_sort_str(fcx.tcx(), ty))); - } - (_, ty::RegionTraitStore(_)) => { fcx.ccx.tcx.sess.span_err( ex.span, @@ -791,7 +781,7 @@ pub fn resolve_impl(ccx: @CrateCtxt, let impl_trait_ref = @impl_trait_ref.subst(ccx.tcx, ¶m_env.free_substs); - let infcx = infer::new_infer_ctxt(ccx.tcx); + let infcx = &infer::new_infer_ctxt(ccx.tcx); let vcx = VtableContext { infcx: infcx, param_env: ¶m_env }; let loc_info = location_info_for_item(impl_item); diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 06776fc672e..27d52aade93 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -50,16 +50,16 @@ use std::hashmap::HashSet; use std::rc::Rc; use std::vec; -pub struct UniversalQuantificationResult { +struct UniversalQuantificationResult { monotype: t, type_variables: ~[ty::t], type_param_defs: Rc<~[ty::TypeParameterDef]> } -pub fn get_base_type(inference_context: @InferCtxt, - span: Span, - original_type: t) - -> Option<t> { +fn get_base_type(inference_context: &InferCtxt, + span: Span, + original_type: t) + -> Option<t> { let resolved_type; match resolve_type(inference_context, original_type, @@ -92,7 +92,7 @@ pub fn get_base_type(inference_context: @InferCtxt, } } -pub fn type_is_defined_in_local_crate(original_type: t) -> bool { +fn type_is_defined_in_local_crate(original_type: t) -> bool { /*! * * For coherence, when we have `impl Trait for Type`, we need to @@ -119,10 +119,10 @@ pub fn type_is_defined_in_local_crate(original_type: t) -> bool { } // Returns the def ID of the base type, if there is one. -pub fn get_base_type_def_id(inference_context: @InferCtxt, - span: Span, - original_type: t) - -> Option<DefId> { +fn get_base_type_def_id(inference_context: &InferCtxt, + span: Span, + original_type: t) + -> Option<DefId> { match get_base_type(inference_context, span, original_type) { None => { return None; @@ -143,21 +143,16 @@ pub fn get_base_type_def_id(inference_context: @InferCtxt, } } -pub fn CoherenceChecker(crate_context: @CrateCtxt) -> CoherenceChecker { - CoherenceChecker { - crate_context: crate_context, - inference_context: new_infer_ctxt(crate_context.tcx), - } -} - -pub struct CoherenceChecker { +struct CoherenceChecker { crate_context: @CrateCtxt, - inference_context: @InferCtxt, + inference_context: InferCtxt, } -struct CoherenceCheckVisitor { cc: CoherenceChecker } +struct CoherenceCheckVisitor<'a> { + cc: &'a CoherenceChecker +} -impl visit::Visitor<()> for CoherenceCheckVisitor { +impl<'a> visit::Visitor<()> for CoherenceCheckVisitor<'a> { fn visit_item(&mut self, item: &Item, _: ()) { // debug!("(checking coherence) item '{}'", @@ -181,9 +176,9 @@ impl visit::Visitor<()> for CoherenceCheckVisitor { } } -struct PrivilegedScopeVisitor { cc: CoherenceChecker } +struct PrivilegedScopeVisitor<'a> { cc: &'a CoherenceChecker } -impl visit::Visitor<()> for PrivilegedScopeVisitor { +impl<'a> visit::Visitor<()> for PrivilegedScopeVisitor<'a> { fn visit_item(&mut self, item: &Item, _: ()) { match item.node { @@ -232,11 +227,17 @@ impl visit::Visitor<()> for PrivilegedScopeVisitor { } impl CoherenceChecker { - pub fn check_coherence(self, crate: &Crate) { + fn new(crate_context: @CrateCtxt) -> CoherenceChecker { + CoherenceChecker { + crate_context: crate_context, + inference_context: new_infer_ctxt(crate_context.tcx), + } + } + + fn check(&self, crate: &Crate) { // Check implementations and traits. This populates the tables // containing the inherent methods and extension methods. It also // builds up the trait inheritance table. - let mut visitor = CoherenceCheckVisitor { cc: self }; visit::walk_crate(&mut visitor, crate, ()); @@ -257,9 +258,8 @@ impl CoherenceChecker { self.populate_destructor_table(); } - pub fn check_implementation(&self, - item: &Item, - associated_traits: &[TraitRef]) { + fn check_implementation(&self, item: &Item, + associated_traits: &[TraitRef]) { let tcx = self.crate_context.tcx; let self_type = ty::lookup_item_type(tcx, local_def(item.id)); @@ -271,7 +271,7 @@ impl CoherenceChecker { '{}'", self.crate_context.tcx.sess.str_of(item.ident)); - match get_base_type_def_id(self.inference_context, + match get_base_type_def_id(&self.inference_context, item.span, self_type.ty) { None => { @@ -301,7 +301,7 @@ impl CoherenceChecker { // Add the implementation to the mapping from implementation to base // type def ID, if there is a base type for this implementation and // the implementation does not have any associated traits. - match get_base_type_def_id(self.inference_context, + match get_base_type_def_id(&self.inference_context, item.span, self_type.ty) { None => { @@ -322,10 +322,9 @@ impl CoherenceChecker { // Creates default method IDs and performs type substitutions for an impl // and trait pair. Then, for each provided method in the trait, inserts a // `ProvidedMethodInfo` instance into the `provided_method_sources` map. - pub fn instantiate_default_methods(&self, - impl_id: ast::DefId, - trait_ref: &ty::TraitRef, - all_methods: &mut ~[@Method]) { + fn instantiate_default_methods(&self, impl_id: ast::DefId, + trait_ref: &ty::TraitRef, + all_methods: &mut ~[@Method]) { let tcx = self.crate_context.tcx; debug!("instantiate_default_methods(impl_id={:?}, trait_ref={})", impl_id, trait_ref.repr(tcx)); @@ -385,9 +384,8 @@ impl CoherenceChecker { } } - pub fn add_inherent_impl(&self, - base_def_id: DefId, - implementation: @Impl) { + fn add_inherent_impl(&self, base_def_id: DefId, + implementation: @Impl) { let tcx = self.crate_context.tcx; let implementation_list; let mut inherent_impls = tcx.inherent_impls.borrow_mut(); @@ -405,9 +403,8 @@ impl CoherenceChecker { implementation_list.get().push(implementation); } - pub fn add_trait_impl(&self, - base_def_id: DefId, - implementation: @Impl) { + fn add_trait_impl(&self, base_def_id: DefId, + implementation: @Impl) { let tcx = self.crate_context.tcx; let implementation_list; let mut trait_impls = tcx.trait_impls.borrow_mut(); @@ -425,14 +422,14 @@ impl CoherenceChecker { implementation_list.get().push(implementation); } - pub fn check_implementation_coherence(&self) { + fn check_implementation_coherence(&self) { let trait_impls = self.crate_context.tcx.trait_impls.borrow(); for &trait_id in trait_impls.get().keys() { self.check_implementation_coherence_of(trait_id); } } - pub fn check_implementation_coherence_of(&self, trait_def_id: DefId) { + fn check_implementation_coherence_of(&self, trait_def_id: DefId) { // Unify pairs of polytypes. self.iter_impls_of_trait_local(trait_def_id, |a| { let implementation_a = a; @@ -471,7 +468,7 @@ impl CoherenceChecker { }) } - pub fn iter_impls_of_trait(&self, trait_def_id: DefId, f: |@Impl|) { + fn iter_impls_of_trait(&self, trait_def_id: DefId, f: |@Impl|) { self.iter_impls_of_trait_local(trait_def_id, |x| f(x)); if trait_def_id.crate == LOCAL_CRATE { @@ -486,7 +483,7 @@ impl CoherenceChecker { }); } - pub fn iter_impls_of_trait_local(&self, trait_def_id: DefId, f: |@Impl|) { + fn iter_impls_of_trait_local(&self, trait_def_id: DefId, f: |@Impl|) { let trait_impls = self.crate_context.tcx.trait_impls.borrow(); match trait_impls.get().find(&trait_def_id) { Some(impls) => { @@ -499,10 +496,10 @@ impl CoherenceChecker { } } - pub fn polytypes_unify(&self, - polytype_a: ty_param_bounds_and_ty, - polytype_b: ty_param_bounds_and_ty) - -> bool { + fn polytypes_unify(&self, + polytype_a: ty_param_bounds_and_ty, + polytype_b: ty_param_bounds_and_ty) + -> bool { let universally_quantified_a = self.universally_quantify_polytype(polytype_a); let universally_quantified_b = @@ -516,9 +513,8 @@ impl CoherenceChecker { // Converts a polytype to a monotype by replacing all parameters with // type variables. Returns the monotype and the type variables created. - pub fn universally_quantify_polytype(&self, - polytype: ty_param_bounds_and_ty) - -> UniversalQuantificationResult { + fn universally_quantify_polytype(&self, polytype: ty_param_bounds_and_ty) + -> UniversalQuantificationResult { let region_parameter_count = polytype.generics.region_param_defs().len(); let region_parameters = self.inference_context.next_region_vars( @@ -544,30 +540,28 @@ impl CoherenceChecker { } } - pub fn can_unify_universally_quantified<'a>(&self, - a: &'a - UniversalQuantificationResult, - b: &'a - UniversalQuantificationResult) - -> bool { - infer::can_mk_subty(self.inference_context, + fn can_unify_universally_quantified<'a>(&self, + a: &'a UniversalQuantificationResult, + b: &'a UniversalQuantificationResult) + -> bool { + infer::can_mk_subty(&self.inference_context, a.monotype, b.monotype).is_ok() } - pub fn get_self_type_for_implementation(&self, implementation: @Impl) - -> ty_param_bounds_and_ty { + fn get_self_type_for_implementation(&self, implementation: @Impl) + -> ty_param_bounds_and_ty { let tcache = self.crate_context.tcx.tcache.borrow(); return tcache.get().get_copy(&implementation.did); } // Privileged scope checking - pub fn check_privileged_scopes(self, crate: &Crate) { - let mut visitor = PrivilegedScopeVisitor{ cc: self }; + fn check_privileged_scopes(&self, crate: &Crate) { + let mut visitor = PrivilegedScopeVisitor { cc: self }; visit::walk_crate(&mut visitor, crate, ()); } - pub fn trait_ref_to_trait_def_id(&self, trait_ref: &TraitRef) -> DefId { + fn trait_ref_to_trait_def_id(&self, trait_ref: &TraitRef) -> DefId { let def_map = self.crate_context.tcx.def_map; let def_map = def_map.borrow(); let trait_def = def_map.get().get_copy(&trait_ref.ref_id); @@ -578,8 +572,7 @@ impl CoherenceChecker { /// For coherence, when we have `impl Type`, we need to guarantee that /// `Type` is "local" to the crate. For our purposes, this means that it /// must precisely name some nominal type defined in this crate. - pub fn ast_type_is_defined_in_local_crate(&self, original_type: &ast::Ty) - -> bool { + fn ast_type_is_defined_in_local_crate(&self, original_type: &ast::Ty) -> bool { match original_type.node { TyPath(_, _, path_id) => { let def_map = self.crate_context.tcx.def_map.borrow(); @@ -614,7 +607,7 @@ impl CoherenceChecker { } // Converts an implementation in the AST to an Impl structure. - pub fn create_impl_from_item(&self, item: &Item) -> @Impl { + fn create_impl_from_item(&self, item: &Item) -> @Impl { let tcx = self.crate_context.tcx; match item.node { ItemImpl(_, ref trait_refs, _, ref ast_methods) => { @@ -646,7 +639,7 @@ impl CoherenceChecker { } } - pub fn span_of_impl(&self, implementation: @Impl) -> Span { + fn span_of_impl(&self, implementation: @Impl) -> Span { assert_eq!(implementation.did.crate, LOCAL_CRATE); match self.crate_context.tcx.items.find(implementation.did.node) { Some(NodeItem(item, _)) => { @@ -661,9 +654,9 @@ impl CoherenceChecker { // External crate handling - pub fn add_external_impl(&self, - impls_seen: &mut HashSet<DefId>, - impl_def_id: DefId) { + fn add_external_impl(&self, + impls_seen: &mut HashSet<DefId>, + impl_def_id: DefId) { let tcx = self.crate_context.tcx; let implementation = @csearch::get_impl(tcx, impl_def_id); @@ -701,7 +694,7 @@ impl CoherenceChecker { // Adds implementations and traits from external crates to the coherence // info. - pub fn add_external_crates(&self) { + fn add_external_crates(&self) { let mut impls_seen = HashSet::new(); let crate_store = self.crate_context.tcx.sess.cstore; @@ -717,7 +710,7 @@ impl CoherenceChecker { // Destructors // - pub fn populate_destructor_table(&self) { + fn populate_destructor_table(&self) { let tcx = self.crate_context.tcx; let drop_trait = match tcx.lang_items.drop_trait() { Some(id) => id, None => { return } @@ -853,6 +846,5 @@ fn subst_receiver_types_in_method_ty(tcx: ty::ctxt, } pub fn check_coherence(crate_context: @CrateCtxt, crate: &Crate) { - let coherence_checker = CoherenceChecker(crate_context); - coherence_checker.check_coherence(crate); + CoherenceChecker::new(crate_context).check(crate); } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index c1a6e53069e..5e46daad7ee 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -430,7 +430,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt, if ty_trait_refs.iter().any(|other_trait| other_trait.def_id == trait_ref.def_id) { // This means a trait inherited from the same supertrait more // than once. - tcx.sess.span_err(sp, "Duplicate supertrait in trait declaration"); + tcx.sess.span_err(sp, "duplicate supertrait in trait declaration"); break; } else { ty_trait_refs.push(trait_ref); @@ -891,7 +891,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item) ast::ItemTrait(..) => { tcx.sess.span_bug( it.span, - format!("Invoked ty_of_item on trait")); + format!("invoked ty_of_item on trait")); } ast::ItemStruct(_, ref generics) => { let ty_generics = ty_generics(ccx, generics, 0); diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index adf36cf973b..d8166108947 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -83,10 +83,10 @@ use syntax::ast; // Note: Coerce is not actually a combiner, in that it does not // conform to the same interface, though it performs a similar // function. -pub struct Coerce(CombineFields); +pub struct Coerce<'f>(CombineFields<'f>); -impl Coerce { - pub fn get_ref<'a>(&'a self) -> &'a CombineFields { +impl<'f> Coerce<'f> { + pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> { let Coerce(ref v) = *self; v } @@ -131,23 +131,6 @@ impl Coerce { }); } - ty::ty_trait(def_id, ref substs, ty::BoxTraitStore, m, bounds) => { - let result = self.unpack_actual_value(a, |sty_a| { - match *sty_a { - ty::ty_box(..) => { - self.coerce_object(a, sty_a, b, def_id, substs, - ty::BoxTraitStore, m, bounds) - } - _ => Err(ty::terr_mismatch) - } - }); - - match result { - Ok(t) => return Ok(t), - Err(..) => {} - } - } - ty::ty_trait(def_id, ref substs, ty::UniqTraitStore, m, bounds) => { let result = self.unpack_actual_value(a, |sty_a| { match *sty_a { @@ -219,7 +202,7 @@ impl Coerce { Err(e) => { self.get_ref().infcx.tcx.sess.span_bug( self.get_ref().trace.origin.span(), - format!("Failed to resolve even without \ + format!("failed to resolve even without \ any force options: {:?}", e)); } } @@ -462,7 +445,6 @@ impl Coerce { b.inf_str(self.get_ref().infcx)); let (sigil, region) = match trait_store { - ty::BoxTraitStore => (ast::ManagedSigil, None), ty::UniqTraitStore => (ast::OwnedSigil, None), ty::RegionTraitStore(region) => (ast::BorrowedSigil, Some(region)) }; diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index e5d9ee97098..eb45065952d 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -69,14 +69,14 @@ use syntax::opt_vec; use syntax::abi::AbiSet; pub trait Combine { - fn infcx(&self) -> @InferCtxt; + fn infcx<'a>(&'a self) -> &'a InferCtxt; fn tag(&self) -> ~str; fn a_is_expected(&self) -> bool; fn trace(&self) -> TypeTrace; - fn sub(&self) -> Sub; - fn lub(&self) -> Lub; - fn glb(&self) -> Glb; + fn sub<'a>(&'a self) -> Sub<'a>; + fn lub<'a>(&'a self) -> Lub<'a>; + fn glb<'a>(&'a self) -> Glb<'a>; fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt>; fn contratys(&self, a: ty::t, b: ty::t) -> cres<ty::t>; @@ -329,8 +329,8 @@ pub trait Combine { } } -pub struct CombineFields { - infcx: @InferCtxt, +pub struct CombineFields<'a> { + infcx: &'a InferCtxt, a_is_expected: bool, trace: TypeTrace, } diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index d1bf998e989..657b75a44ed 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -77,33 +77,33 @@ use util::ppaux::bound_region_to_str; use util::ppaux::note_and_explain_region; pub trait ErrorReporting { - fn report_region_errors(@self, + fn report_region_errors(&self, errors: &OptVec<RegionResolutionError>); - fn report_and_explain_type_error(@self, + fn report_and_explain_type_error(&self, trace: TypeTrace, terr: &ty::type_err); - fn values_str(@self, values: &ValuePairs) -> Option<~str>; + fn values_str(&self, values: &ValuePairs) -> Option<~str>; fn expected_found_str<T:UserString+Resolvable>( - @self, + &self, exp_found: &ty::expected_found<T>) -> Option<~str>; - fn report_concrete_failure(@self, + fn report_concrete_failure(&self, origin: SubregionOrigin, sub: Region, sup: Region); - fn report_sub_sup_conflict(@self, + fn report_sub_sup_conflict(&self, var_origin: RegionVariableOrigin, sub_origin: SubregionOrigin, sub_region: Region, sup_origin: SubregionOrigin, sup_region: Region); - fn report_sup_sup_conflict(@self, + fn report_sup_sup_conflict(&self, var_origin: RegionVariableOrigin, origin1: SubregionOrigin, region1: Region, @@ -112,15 +112,15 @@ pub trait ErrorReporting { } trait ErrorReportingHelpers { - fn report_inference_failure(@self, + fn report_inference_failure(&self, var_origin: RegionVariableOrigin); - fn note_region_origin(@self, + fn note_region_origin(&self, origin: SubregionOrigin); } impl ErrorReporting for InferCtxt { - fn report_region_errors(@self, + fn report_region_errors(&self, errors: &OptVec<RegionResolutionError>) { for error in errors.iter() { match *error { @@ -147,11 +147,9 @@ impl ErrorReporting for InferCtxt { } } - fn report_and_explain_type_error(@self, + fn report_and_explain_type_error(&self, trace: TypeTrace, terr: &ty::type_err) { - let tcx = self.tcx; - let expected_found_str = match self.values_str(&trace.values) { Some(v) => v, None => { @@ -174,12 +172,12 @@ impl ErrorReporting for InferCtxt { format!("{}: {} ({})", message_root_str, expected_found_str, - ty::type_err_to_str(tcx, terr))); + ty::type_err_to_str(self.tcx, terr))); ty::note_and_explain_type_err(self.tcx, terr); } - fn values_str(@self, values: &ValuePairs) -> Option<~str> { + fn values_str(&self, values: &ValuePairs) -> Option<~str> { /*! * Returns a string of the form "expected `{}` but found `{}`", * or None if this is a derived error. @@ -195,7 +193,7 @@ impl ErrorReporting for InferCtxt { } fn expected_found_str<T:UserString+Resolvable>( - @self, + &self, exp_found: &ty::expected_found<T>) -> Option<~str> { @@ -214,7 +212,7 @@ impl ErrorReporting for InferCtxt { found.user_string(self.tcx))) } - fn report_concrete_failure(@self, + fn report_concrete_failure(&self, origin: SubregionOrigin, sub: Region, sup: Region) { @@ -400,7 +398,7 @@ impl ErrorReporting for InferCtxt { } } - fn report_sub_sup_conflict(@self, + fn report_sub_sup_conflict(&self, var_origin: RegionVariableOrigin, sub_origin: SubregionOrigin, sub_region: Region, @@ -425,7 +423,7 @@ impl ErrorReporting for InferCtxt { self.note_region_origin(sub_origin); } - fn report_sup_sup_conflict(@self, + fn report_sup_sup_conflict(&self, var_origin: RegionVariableOrigin, origin1: SubregionOrigin, region1: Region, @@ -452,7 +450,7 @@ impl ErrorReporting for InferCtxt { } impl ErrorReportingHelpers for InferCtxt { - fn report_inference_failure(@self, + fn report_inference_failure(&self, var_origin: RegionVariableOrigin) { let var_description = match var_origin { infer::MiscVariable(_) => ~"", @@ -484,7 +482,7 @@ impl ErrorReportingHelpers for InferCtxt { var_description)); } - fn note_region_origin(@self, origin: SubregionOrigin) { + fn note_region_origin(&self, origin: SubregionOrigin) { match origin { infer::Subtype(ref trace) => { let desc = match trace.origin { @@ -611,12 +609,12 @@ impl ErrorReportingHelpers for InferCtxt { } trait Resolvable { - fn resolve(&self, infcx: @InferCtxt) -> Self; + fn resolve(&self, infcx: &InferCtxt) -> Self; fn contains_error(&self) -> bool; } impl Resolvable for ty::t { - fn resolve(&self, infcx: @InferCtxt) -> ty::t { + fn resolve(&self, infcx: &InferCtxt) -> ty::t { infcx.resolve_type_vars_if_possible(*self) } fn contains_error(&self) -> bool { @@ -625,7 +623,7 @@ impl Resolvable for ty::t { } impl Resolvable for @ty::TraitRef { - fn resolve(&self, infcx: @InferCtxt) -> @ty::TraitRef { + fn resolve(&self, infcx: &InferCtxt) -> @ty::TraitRef { @infcx.resolve_type_vars_in_trait_ref_if_possible(*self) } fn contains_error(&self) -> bool { diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 075a45e1613..4af6364642e 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -28,21 +28,21 @@ use std::hashmap::HashMap; use util::common::{indenter}; use util::ppaux::mt_to_str; -pub struct Glb(CombineFields); // "greatest lower bound" (common subtype) +pub struct Glb<'f>(CombineFields<'f>); // "greatest lower bound" (common subtype) -impl Glb { - pub fn get_ref<'a>(&'a self) -> &'a CombineFields { let Glb(ref v) = *self; v } +impl<'f> Glb<'f> { + pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> { let Glb(ref v) = *self; v } } -impl Combine for Glb { - fn infcx(&self) -> @InferCtxt { self.get_ref().infcx } +impl<'f> Combine for Glb<'f> { + fn infcx<'a>(&'a self) -> &'a InferCtxt { self.get_ref().infcx } fn tag(&self) -> ~str { ~"glb" } fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected } fn trace(&self) -> TypeTrace { self.get_ref().trace } - fn sub(&self) -> Sub { Sub(*self.get_ref()) } - fn lub(&self) -> Lub { Lub(*self.get_ref()) } - fn glb(&self) -> Glb { Glb(*self.get_ref()) } + fn sub<'a>(&'a self) -> Sub<'a> { Sub(*self.get_ref()) } + fn lub<'a>(&'a self) -> Lub<'a> { Lub(*self.get_ref()) } + fn glb<'a>(&'a self) -> Glb<'a> { Glb(*self.get_ref()) } fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> { let tcx = self.get_ref().infcx.tcx; diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 69bc3e13113..fa40fa6a064 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -109,7 +109,7 @@ pub trait CombineFieldsLatticeMethods { -> ures; } -impl CombineFieldsLatticeMethods for CombineFields { +impl<'f> CombineFieldsLatticeMethods for CombineFields<'f> { fn var_sub_var<T:Clone + InferStr + LatticeValue, V:Clone + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>( &self, @@ -326,7 +326,7 @@ impl CombineFieldsLatticeMethods for CombineFields { // for pairs of variables or for variables and values. pub trait LatticeDir { - fn combine_fields(&self) -> CombineFields; + fn combine_fields<'a>(&'a self) -> CombineFields<'a>; fn bnd<T:Clone>(&self, b: &Bounds<T>) -> Option<T>; fn with_bnd<T:Clone>(&self, b: &Bounds<T>, t: T) -> Bounds<T>; } @@ -335,29 +335,29 @@ pub trait TyLatticeDir { fn ty_bot(&self, t: ty::t) -> cres<ty::t>; } -impl LatticeDir for Lub { - fn combine_fields(&self) -> CombineFields { *self.get_ref() } +impl<'f> LatticeDir for Lub<'f> { + fn combine_fields<'a>(&'a self) -> CombineFields<'a> { *self.get_ref() } fn bnd<T:Clone>(&self, b: &Bounds<T>) -> Option<T> { b.ub.clone() } fn with_bnd<T:Clone>(&self, b: &Bounds<T>, t: T) -> Bounds<T> { Bounds { ub: Some(t), ..(*b).clone() } } } -impl TyLatticeDir for Lub { +impl<'f> TyLatticeDir for Lub<'f> { fn ty_bot(&self, t: ty::t) -> cres<ty::t> { Ok(t) } } -impl LatticeDir for Glb { - fn combine_fields(&self) -> CombineFields { *self.get_ref() } +impl<'f> LatticeDir for Glb<'f> { + fn combine_fields<'a>(&'a self) -> CombineFields<'a> { *self.get_ref() } fn bnd<T:Clone>(&self, b: &Bounds<T>) -> Option<T> { b.lb.clone() } fn with_bnd<T:Clone>(&self, b: &Bounds<T>, t: T) -> Bounds<T> { Bounds { lb: Some(t), ..(*b).clone() } } } -impl TyLatticeDir for Glb { +impl<'f> TyLatticeDir for Glb<'f> { fn ty_bot(&self, _t: ty::t) -> cres<ty::t> { Ok(ty::mk_bot()) } @@ -528,7 +528,7 @@ pub fn var_ids<T:Combine>(this: &T, r => { this.infcx().tcx.sess.span_bug( this.trace().origin.span(), - format!("Found non-region-vid: {:?}", r)); + format!("found non-region-vid: {:?}", r)); } }).collect() } diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 23bd0600383..dc6df333276 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -27,25 +27,25 @@ use syntax::ast::{ExternFn, ImpureFn, UnsafeFn}; use syntax::ast::{Onceness, Purity}; use util::ppaux::mt_to_str; -pub struct Lub(CombineFields); // least-upper-bound: common supertype +pub struct Lub<'f>(CombineFields<'f>); // least-upper-bound: common supertype -impl Lub { - pub fn get_ref<'a>(&'a self) -> &'a CombineFields { let Lub(ref v) = *self; v } +impl<'f> Lub<'f> { + pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> { let Lub(ref v) = *self; v } pub fn bot_ty(&self, b: ty::t) -> cres<ty::t> { Ok(b) } pub fn ty_bot(&self, b: ty::t) -> cres<ty::t> { self.bot_ty(b) // commutative } } -impl Combine for Lub { - fn infcx(&self) -> @InferCtxt { self.get_ref().infcx } +impl<'f> Combine for Lub<'f> { + fn infcx<'a>(&'a self) -> &'a InferCtxt { self.get_ref().infcx } fn tag(&self) -> ~str { ~"lub" } fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected } fn trace(&self) -> TypeTrace { self.get_ref().trace } - fn sub(&self) -> Sub { Sub(*self.get_ref()) } - fn lub(&self) -> Lub { Lub(*self.get_ref()) } - fn glb(&self) -> Glb { Glb(*self.get_ref()) } + fn sub<'a>(&'a self) -> Sub<'a> { Sub(*self.get_ref()) } + fn lub<'a>(&'a self) -> Lub<'a> { Lub(*self.get_ref()) } + fn glb<'a>(&'a self) -> Glb<'a> { Glb(*self.get_ref()) } fn mts(&self, a: &ty::mt, b: &ty::mt) -> cres<ty::mt> { let tcx = self.get_ref().infcx.tcx; diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 812b7ffd97d..496170c3e47 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -20,7 +20,7 @@ pub use middle::typeck::infer::resolve::{resolve_ivar, resolve_all}; pub use middle::typeck::infer::resolve::{resolve_nested_tvar}; pub use middle::typeck::infer::resolve::{resolve_rvar}; -use extra::smallintmap::SmallIntMap; +use collections::SmallIntMap; use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, Vid}; use middle::ty; use middle::ty_fold; @@ -258,8 +258,8 @@ fn new_ValsAndBindings<V:Clone,T:Clone>() -> ValsAndBindings<V, T> { } } -pub fn new_infer_ctxt(tcx: ty::ctxt) -> @InferCtxt { - @InferCtxt { +pub fn new_infer_ctxt(tcx: ty::ctxt) -> InferCtxt { + InferCtxt { tcx: tcx, ty_var_bindings: RefCell::new(new_ValsAndBindings()), @@ -275,7 +275,7 @@ pub fn new_infer_ctxt(tcx: ty::ctxt) -> @InferCtxt { } } -pub fn common_supertype(cx: @InferCtxt, +pub fn common_supertype(cx: &InferCtxt, origin: TypeOrigin, a_is_expected: bool, a: ty::t, @@ -303,7 +303,7 @@ pub fn common_supertype(cx: @InferCtxt, } } -pub fn mk_subty(cx: @InferCtxt, +pub fn mk_subty(cx: &InferCtxt, a_is_expected: bool, origin: TypeOrigin, a: ty::t, @@ -321,7 +321,7 @@ pub fn mk_subty(cx: @InferCtxt, }).to_ures() } -pub fn can_mk_subty(cx: @InferCtxt, a: ty::t, b: ty::t) -> ures { +pub fn can_mk_subty(cx: &InferCtxt, a: ty::t, b: ty::t) -> ures { debug!("can_mk_subty({} <: {})", a.inf_str(cx), b.inf_str(cx)); indent(|| { cx.probe(|| { @@ -334,7 +334,7 @@ pub fn can_mk_subty(cx: @InferCtxt, a: ty::t, b: ty::t) -> ures { }).to_ures() } -pub fn mk_subr(cx: @InferCtxt, +pub fn mk_subr(cx: &InferCtxt, _a_is_expected: bool, origin: SubregionOrigin, a: ty::Region, @@ -345,7 +345,7 @@ pub fn mk_subr(cx: @InferCtxt, cx.region_vars.commit(); } -pub fn mk_eqty(cx: @InferCtxt, +pub fn mk_eqty(cx: &InferCtxt, a_is_expected: bool, origin: TypeOrigin, a: ty::t, @@ -364,7 +364,7 @@ pub fn mk_eqty(cx: @InferCtxt, }).to_ures() } -pub fn mk_sub_trait_refs(cx: @InferCtxt, +pub fn mk_sub_trait_refs(cx: &InferCtxt, a_is_expected: bool, origin: TypeOrigin, a: @ty::TraitRef, @@ -395,7 +395,7 @@ fn expected_found<T>(a_is_expected: bool, } } -pub fn mk_coercety(cx: @InferCtxt, +pub fn mk_coercety(cx: &InferCtxt, a_is_expected: bool, origin: TypeOrigin, a: ty::t, @@ -413,7 +413,7 @@ pub fn mk_coercety(cx: @InferCtxt, }) } -pub fn can_mk_coercety(cx: @InferCtxt, a: ty::t, b: ty::t) -> ures { +pub fn can_mk_coercety(cx: &InferCtxt, a: ty::t, b: ty::t) -> ures { debug!("can_mk_coercety({} -> {})", a.inf_str(cx), b.inf_str(cx)); indent(|| { cx.probe(|| { @@ -427,7 +427,7 @@ pub fn can_mk_coercety(cx: @InferCtxt, a: ty::t, b: ty::t) -> ures { } // See comment on the type `resolve_state` below -pub fn resolve_type(cx: @InferCtxt, +pub fn resolve_type(cx: &InferCtxt, a: ty::t, modes: uint) -> fres<ty::t> { @@ -435,7 +435,7 @@ pub fn resolve_type(cx: @InferCtxt, resolver.resolve_type_chk(a) } -pub fn resolve_region(cx: @InferCtxt, r: ty::Region, modes: uint) +pub fn resolve_region(cx: &InferCtxt, r: ty::Region, modes: uint) -> fres<ty::Region> { let mut resolver = resolver(cx, modes); resolver.resolve_region_chk(r) @@ -502,18 +502,18 @@ struct Snapshot { } impl InferCtxt { - pub fn combine_fields(@self, a_is_expected: bool, trace: TypeTrace) - -> CombineFields { + pub fn combine_fields<'a>(&'a self, a_is_expected: bool, trace: TypeTrace) + -> CombineFields<'a> { CombineFields {infcx: self, a_is_expected: a_is_expected, trace: trace} } - pub fn sub(@self, a_is_expected: bool, trace: TypeTrace) -> Sub { + pub fn sub<'a>(&'a self, a_is_expected: bool, trace: TypeTrace) -> Sub<'a> { Sub(self.combine_fields(a_is_expected, trace)) } - pub fn lub(@self, a_is_expected: bool, trace: TypeTrace) -> Lub { + pub fn lub<'a>(&'a self, a_is_expected: bool, trace: TypeTrace) -> Lub<'a> { Lub(self.combine_fields(a_is_expected, trace)) } @@ -547,7 +547,7 @@ impl InferCtxt { } /// Execute `f` and commit the bindings if successful - pub fn commit<T,E>(@self, f: || -> Result<T,E>) -> Result<T,E> { + pub fn commit<T,E>(&self, f: || -> Result<T,E>) -> Result<T,E> { assert!(!self.in_snapshot()); debug!("commit()"); @@ -564,7 +564,7 @@ impl InferCtxt { } /// Execute `f`, unroll bindings on failure - pub fn try<T,E>(@self, f: || -> Result<T,E>) -> Result<T,E> { + pub fn try<T,E>(&self, f: || -> Result<T,E>) -> Result<T,E> { debug!("try()"); let snapshot = self.start_snapshot(); let r = f(); @@ -579,7 +579,7 @@ impl InferCtxt { } /// Execute `f` then unroll any bindings it creates - pub fn probe<T,E>(@self, f: || -> Result<T,E>) -> Result<T,E> { + pub fn probe<T,E>(&self, f: || -> Result<T,E>) -> Result<T,E> { debug!("probe()"); indent(|| { let snapshot = self.start_snapshot(); @@ -661,34 +661,34 @@ impl InferCtxt { self.region_vars.new_bound(binder_id) } - pub fn resolve_regions(@self) { + pub fn resolve_regions(&self) { let errors = self.region_vars.resolve_regions(); self.report_region_errors(&errors); // see error_reporting.rs } - pub fn ty_to_str(@self, t: ty::t) -> ~str { + pub fn ty_to_str(&self, t: ty::t) -> ~str { ty_to_str(self.tcx, self.resolve_type_vars_if_possible(t)) } - pub fn tys_to_str(@self, ts: &[ty::t]) -> ~str { + pub fn tys_to_str(&self, ts: &[ty::t]) -> ~str { let tstrs = ts.map(|t| self.ty_to_str(*t)); format!("({})", tstrs.connect(", ")) } - pub fn trait_ref_to_str(@self, t: &ty::TraitRef) -> ~str { + pub fn trait_ref_to_str(&self, t: &ty::TraitRef) -> ~str { let t = self.resolve_type_vars_in_trait_ref_if_possible(t); trait_ref_to_str(self.tcx, &t) } - pub fn resolve_type_vars_if_possible(@self, typ: ty::t) -> ty::t { + pub fn resolve_type_vars_if_possible(&self, typ: ty::t) -> ty::t { match resolve_type(self, typ, resolve_nested_tvar | resolve_ivar) { result::Ok(new_type) => new_type, result::Err(_) => typ } } - pub fn resolve_type_vars_in_trait_ref_if_possible(@self, + pub fn resolve_type_vars_in_trait_ref_if_possible(&self, trait_ref: &ty::TraitRef) -> ty::TraitRef { @@ -728,7 +728,7 @@ impl InferCtxt { // in this case. The typechecker should only ever report type errors involving mismatched // types using one of these four methods, and should not call span_err directly for such // errors. - pub fn type_error_message_str(@self, + pub fn type_error_message_str(&self, sp: Span, mk_msg: |Option<~str>, ~str| -> ~str, actual_ty: ~str, @@ -736,7 +736,7 @@ impl InferCtxt { self.type_error_message_str_with_expected(sp, mk_msg, None, actual_ty, err) } - pub fn type_error_message_str_with_expected(@self, + pub fn type_error_message_str_with_expected(&self, sp: Span, mk_msg: |Option<~str>, ~str| @@ -767,7 +767,7 @@ impl InferCtxt { } } - pub fn type_error_message(@self, + pub fn type_error_message(&self, sp: Span, mk_msg: |~str| -> ~str, actual_ty: ty::t, @@ -782,7 +782,7 @@ impl InferCtxt { self.type_error_message_str(sp, |_e, a| { mk_msg(a) }, self.ty_to_str(actual_ty), err); } - pub fn report_mismatched_types(@self, + pub fn report_mismatched_types(&self, sp: Span, e: ty::t, a: ty::t, diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 54998e06f8e..2bc0d7d6419 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -233,7 +233,7 @@ impl RegionVarBindings { self.bound_count.set(sc + 1); if sc >= self.bound_count.get() { - self.tcx.sess.bug("Rollover in RegionInference new_bound()"); + self.tcx.sess.bug("rollover in RegionInference new_bound()"); } ReLateBound(binder_id, BrFresh(sc)) @@ -278,7 +278,7 @@ impl RegionVarBindings { (_, ReLateBound(..)) => { self.tcx.sess.span_bug( origin.span(), - format!("Cannot relate bound region: {} <= {}", + format!("cannot relate bound region: {} <= {}", sub.repr(self.tcx), sup.repr(self.tcx))); } @@ -351,7 +351,7 @@ impl RegionVarBindings { let var_origins = self.var_origins.borrow(); self.tcx.sess.span_bug( var_origins.get()[rid.to_uint()].span(), - format!("Attempt to resolve region variable before \ + format!("attempt to resolve region variable before \ values have been computed!")) } Some(ref values) => values[rid.to_uint()] @@ -544,7 +544,7 @@ impl RegionVarBindings { (ReEarlyBound(..), _) | (_, ReEarlyBound(..)) => { self.tcx.sess.bug( - format!("Cannot relate bound region: LUB({}, {})", + format!("cannot relate bound region: LUB({}, {})", a.repr(self.tcx), b.repr(self.tcx))); } @@ -646,7 +646,7 @@ impl RegionVarBindings { (ReEarlyBound(..), _) | (_, ReEarlyBound(..)) => { self.tcx.sess.bug( - format!("Cannot relate bound region: GLB({}, {})", + format!("cannot relate bound region: GLB({}, {})", a.repr(self.tcx), b.repr(self.tcx))); } diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 85585ecaf54..fec6e357e5a 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -79,15 +79,15 @@ pub static try_resolve_tvar_shallow: uint = 0; pub static resolve_and_force_all_but_regions: uint = (resolve_all | force_all) & not_regions; -pub struct ResolveState { - infcx: @InferCtxt, +pub struct ResolveState<'a> { + infcx: &'a InferCtxt, modes: uint, err: Option<fixup_err>, v_seen: ~[TyVid], type_depth: uint } -pub fn resolver(infcx: @InferCtxt, modes: uint) -> ResolveState { +pub fn resolver<'a>(infcx: &'a InferCtxt, modes: uint) -> ResolveState<'a> { ResolveState { infcx: infcx, modes: modes, @@ -97,7 +97,7 @@ pub fn resolver(infcx: @InferCtxt, modes: uint) -> ResolveState { } } -impl ty_fold::TypeFolder for ResolveState { +impl<'a> ty_fold::TypeFolder for ResolveState<'a> { fn tcx(&self) -> ty::ctxt { self.infcx.tcx } @@ -111,7 +111,7 @@ impl ty_fold::TypeFolder for ResolveState { } } -impl ResolveState { +impl<'a> ResolveState<'a> { pub fn should(&mut self, mode: uint) -> bool { (self.modes & mode) == mode } diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 19abbecaa8a..57953313324 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -27,21 +27,21 @@ use util::ppaux::bound_region_to_str; use syntax::ast::{Onceness, Purity}; -pub struct Sub(CombineFields); // "subtype", "subregion" etc +pub struct Sub<'f>(CombineFields<'f>); // "subtype", "subregion" etc -impl Sub { - pub fn get_ref<'a>(&'a self) -> &'a CombineFields { let Sub(ref v) = *self; v } +impl<'f> Sub<'f> { + pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> { let Sub(ref v) = *self; v } } -impl Combine for Sub { - fn infcx(&self) -> @InferCtxt { self.get_ref().infcx } +impl<'f> Combine for Sub<'f> { + fn infcx<'a>(&'a self) -> &'a InferCtxt { self.get_ref().infcx } fn tag(&self) -> ~str { ~"sub" } fn a_is_expected(&self) -> bool { self.get_ref().a_is_expected } fn trace(&self) -> TypeTrace { self.get_ref().trace } - fn sub(&self) -> Sub { Sub(*self.get_ref()) } - fn lub(&self) -> Lub { Lub(*self.get_ref()) } - fn glb(&self) -> Glb { Glb(*self.get_ref()) } + fn sub<'a>(&'a self) -> Sub<'a> { Sub(*self.get_ref()) } + fn lub<'a>(&'a self) -> Lub<'a> { Lub(*self.get_ref()) } + fn glb<'a>(&'a self) -> Glb<'a> { Glb(*self.get_ref()) } fn contratys(&self, a: ty::t, b: ty::t) -> cres<ty::t> { let opp = CombineFields { diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 6ac4c5ff395..517fe232b03 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -23,12 +23,9 @@ use middle::lang_items::{LanguageItems, language_items}; use middle::ty::{FnTyBase, FnMeta, FnSig}; use util::ppaux::ty_to_str; -use extra::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts}; -use extra::getopts::groups; -use extra::getopts::{opt_present}; -use extra::getopts; -use extra::getopts; use extra::oldmap::HashMap; +use getopts::{optopt, optmulti, optflag, optflagopt, getopts}; +use getopts::opt_present; use syntax::codemap::DUMMY_SP; use syntax::parse::parse_crate_from_source_str; use syntax::{ast, attr, parse}; @@ -100,7 +97,7 @@ impl Env { return match search_mod(self, &self.crate.node.module, 0, names) { Some(id) => id, None => { - fail!("No item found: `%s`", names.connect("::")); + fail!("no item found: `%s`", names.connect("::")); } }; @@ -233,7 +230,7 @@ impl Env { for msg in self.err_messages.iter() { debug!("Error encountered: %s", *msg); } - format!("Resolving regions encountered %u errors but expected %u!", + format!("resolving regions encountered %u errors but expected %u!", self.err_messages.len(), exp_count); } @@ -243,7 +240,7 @@ impl Env { pub fn check_lub(&self, t1: ty::t, t2: ty::t, t_lub: ty::t) { match self.lub().tys(t1, t2) { Err(e) => { - fail!("Unexpected error computing LUB: %?", e) + fail!("unexpected error computing LUB: %?", e) } Ok(t) => { self.assert_eq(t, t_lub); @@ -265,7 +262,7 @@ impl Env { self.ty_to_str(t_glb)); match self.glb().tys(t1, t2) { Err(e) => { - fail!("Unexpected error computing LUB: %?", e) + fail!("unexpected error computing LUB: %?", e) } Ok(t) => { self.assert_eq(t, t_glb); @@ -284,7 +281,7 @@ impl Env { match self.lub().tys(t1, t2) { Err(_) => {} Ok(t) => { - fail!("Unexpected success computing LUB: %?", self.ty_to_str(t)) + fail!("unexpected success computing LUB: %?", self.ty_to_str(t)) } } } @@ -294,7 +291,7 @@ impl Env { match self.glb().tys(t1, t2) { Err(_) => {} Ok(t) => { - fail!("Unexpected success computing GLB: %?", self.ty_to_str(t)) + fail!("unexpected success computing GLB: %?", self.ty_to_str(t)) } } } diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index e34947930fa..c55bdcd0bf9 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -9,7 +9,7 @@ // except according to those terms. -use extra::smallintmap::SmallIntMap; +use collections::SmallIntMap; use middle::ty::{Vid, expected_found, IntVarValue}; use middle::ty; diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index a6fc91899f0..b6ad8cc6c43 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -71,9 +71,8 @@ use util::ppaux; use std::cell::RefCell; use std::hashmap::HashMap; use std::rc::Rc; -use std::result; -use extra::list::List; -use extra::list; +use collections::List; +use collections::list; use syntax::codemap::Span; use syntax::print::pprust::*; use syntax::{ast, ast_map, abi}; @@ -279,32 +278,29 @@ pub fn no_params(t: ty::t) -> ty::ty_param_bounds_and_ty { } pub fn require_same_types(tcx: ty::ctxt, - maybe_infcx: Option<@infer::InferCtxt>, + maybe_infcx: Option<&infer::InferCtxt>, t1_is_expected: bool, span: Span, t1: ty::t, t2: ty::t, msg: || -> ~str) -> bool { - let l_tcx; - let l_infcx; - match maybe_infcx { - None => { - l_tcx = tcx; - l_infcx = infer::new_infer_ctxt(tcx); - } - Some(i) => { - l_tcx = i.tcx; - l_infcx = i; - } - } + let result = match maybe_infcx { + None => { + let infcx = infer::new_infer_ctxt(tcx); + infer::mk_eqty(&infcx, t1_is_expected, infer::Misc(span), t1, t2) + } + Some(infcx) => { + infer::mk_eqty(infcx, t1_is_expected, infer::Misc(span), t1, t2) + } + }; - match infer::mk_eqty(l_infcx, t1_is_expected, infer::Misc(span), t1, t2) { - result::Ok(()) => true, - result::Err(ref terr) => { - l_tcx.sess.span_err(span, msg() + ": " + - ty::type_err_to_str(l_tcx, terr)); - ty::note_and_explain_type_err(l_tcx, terr); + match result { + Ok(_) => true, + Err(ref terr) => { + tcx.sess.span_err(span, msg() + ": " + + ty::type_err_to_str(tcx, terr)); + ty::note_and_explain_type_err(tcx, terr); false } } diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index 51364addfed..e29add4bc95 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -718,7 +718,7 @@ impl<'a> ConstraintContext<'a> { ty::ty_infer(..) | ty::ty_err | ty::ty_type | ty::ty_unboxed_vec(..) => { self.tcx().sess.bug( - format!("Unexpected type encountered in \ + format!("unexpected type encountered in \ variance inference: {}", ty.repr(self.tcx()))); } @@ -804,7 +804,7 @@ impl<'a> ConstraintContext<'a> { ty::ReEmpty => { // We don't expect to see anything but 'static or bound // regions when visiting member types or method types. - self.tcx().sess.bug(format!("Unexpected region encountered in \ + self.tcx().sess.bug(format!("unexpected region encountered in \ variance inference: {}", region.repr(self.tcx()))); } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 334407ff122..5a9c3fd031d 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -267,7 +267,6 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { pub fn trait_store_to_str(cx: ctxt, s: ty::TraitStore) -> ~str { match s { ty::UniqTraitStore => ~"~", - ty::BoxTraitStore => ~"@", ty::RegionTraitStore(r) => region_ptr_to_str(cx, r) } } @@ -918,7 +917,6 @@ impl Repr for ty::RegionVid { impl Repr for ty::TraitStore { fn repr(&self, tcx: ctxt) -> ~str { match self { - &ty::BoxTraitStore => ~"@Trait", &ty::UniqTraitStore => ~"~Trait", &ty::RegionTraitStore(r) => format!("&{} Trait", r.repr(tcx)) } diff --git a/src/librustc/util/sha2.rs b/src/librustc/util/sha2.rs index 74fefe41683..5fbf57c5060 100644 --- a/src/librustc/util/sha2.rs +++ b/src/librustc/util/sha2.rs @@ -64,12 +64,12 @@ fn add_bytes_to_bits<T: Int + CheckedAdd + ToBits>(bits: T, bytes: T) -> T { let (new_high_bits, new_low_bits) = bytes.to_bits(); if new_high_bits > Zero::zero() { - fail!("Numeric overflow occured.") + fail!("numeric overflow occured.") } match bits.checked_add(&new_low_bits) { Some(x) => return x, - None => fail!("Numeric overflow occured.") + None => fail!("numeric overflow occured.") } } diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 8220be10461..ca7f502a2e8 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -404,7 +404,6 @@ pub enum SelfTy { SelfStatic, SelfValue, SelfBorrowed(Option<Lifetime>, Mutability), - SelfManaged, SelfOwned, } @@ -415,7 +414,6 @@ impl Clean<SelfTy> for ast::ExplicitSelf { ast::SelfValue => SelfValue, ast::SelfUniq => SelfOwned, ast::SelfRegion(lt, mt) => SelfBorrowed(lt.clean(), mt.clean()), - ast::SelfBox => SelfManaged, } } } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 0e2d6c972ae..9ac0e1acec5 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -14,7 +14,6 @@ use rustc::metadata::creader::Loader; use rustc::middle::privacy; use syntax::ast; -use syntax::diagnostic; use syntax::parse::token; use syntax::parse; use syntax; @@ -48,26 +47,25 @@ fn get_ast_and_resolve(cpath: &Path, phase_2_configure_and_expand, phase_3_run_analysis_passes}; - let parsesess = parse::new_parse_sess(None); + let parsesess = parse::new_parse_sess(); let input = FileInput(cpath.clone()); let sessopts = @driver::session::Options { binary: ~"rustdoc", maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()), addl_lib_search_paths: @RefCell::new(libs), - outputs: ~[driver::session::OutputDylib], + crate_types: ~[driver::session::CrateTypeDylib], .. (*rustc::driver::session::basic_options()).clone() }; - let diagnostic_handler = syntax::diagnostic::mk_handler(None); + let diagnostic_handler = syntax::diagnostic::mk_handler(); let span_diagnostic_handler = syntax::diagnostic::mk_span_handler(diagnostic_handler, parsesess.cm); let sess = driver::driver::build_session_(sessopts, Some(cpath.clone()), parsesess.cm, - @diagnostic::DefaultEmitter, span_diagnostic_handler); let mut cfg = build_configuration(sess); @@ -76,9 +74,9 @@ fn get_ast_and_resolve(cpath: &Path, cfg.push(@dummy_spanned(ast::MetaWord(cfg_))); } - let crate = phase_1_parse_input(sess, cfg.clone(), &input); + let crate = phase_1_parse_input(sess, cfg, &input); let loader = &mut Loader::new(sess); - let (crate, ast_map) = phase_2_configure_and_expand(sess, cfg, loader, crate); + let (crate, ast_map) = phase_2_configure_and_expand(sess, loader, crate); let driver::driver::CrateAnalysis { exported_items, public_items, ty_cx, .. } = phase_3_run_analysis_passes(sess, &crate, ast_map); diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs index 82850dffa2b..153de66363b 100644 --- a/src/librustdoc/html/escape.rs +++ b/src/librustdoc/html/escape.rs @@ -20,10 +20,10 @@ use std::fmt; pub struct Escape<'a>(&'a str); impl<'a> fmt::Show for Escape<'a> { - fn fmt(s: &Escape<'a>, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { // Because the internet is always right, turns out there's not that many // characters to escape: http://stackoverflow.com/questions/7381974 - let Escape(s) = *s; + let Escape(s) = *self; let pile_o_bits = s.as_slice(); let mut last = 0; for (i, ch) in s.bytes().enumerate() { diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 92d15fbcd67..024d010f0b9 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -48,23 +48,23 @@ impl PuritySpace { } impl fmt::Show for clean::Generics { - fn fmt(g: &clean::Generics, f: &mut fmt::Formatter) -> fmt::Result { - if g.lifetimes.len() == 0 && g.type_params.len() == 0 { return Ok(()) } + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.lifetimes.len() == 0 && self.type_params.len() == 0 { return Ok(()) } if_ok!(f.buf.write("<".as_bytes())); - for (i, life) in g.lifetimes.iter().enumerate() { + for (i, life) in self.lifetimes.iter().enumerate() { if i > 0 { if_ok!(f.buf.write(", ".as_bytes())); } if_ok!(write!(f.buf, "{}", *life)); } - if g.type_params.len() > 0 { - if g.lifetimes.len() > 0 { + if self.type_params.len() > 0 { + if self.lifetimes.len() > 0 { if_ok!(f.buf.write(", ".as_bytes())); } - for (i, tp) in g.type_params.iter().enumerate() { + for (i, tp) in self.type_params.iter().enumerate() { if i > 0 { if_ok!(f.buf.write(", ".as_bytes())) } @@ -87,16 +87,16 @@ impl fmt::Show for clean::Generics { } impl fmt::Show for clean::Lifetime { - fn fmt(l: &clean::Lifetime, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if_ok!(f.buf.write("'".as_bytes())); - if_ok!(f.buf.write(l.get_ref().as_bytes())); + if_ok!(f.buf.write(self.get_ref().as_bytes())); Ok(()) } } impl fmt::Show for clean::TyParamBound { - fn fmt(bound: &clean::TyParamBound, f: &mut fmt::Formatter) -> fmt::Result { - match *bound { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { clean::RegionBound => { f.buf.write("'static".as_bytes()) } @@ -108,11 +108,11 @@ impl fmt::Show for clean::TyParamBound { } impl fmt::Show for clean::Path { - fn fmt(path: &clean::Path, f: &mut fmt::Formatter) -> fmt::Result { - if path.global { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.global { if_ok!(f.buf.write("::".as_bytes())) } - for (i, seg) in path.segments.iter().enumerate() { + for (i, seg) in self.segments.iter().enumerate() { if i > 0 { if_ok!(f.buf.write("::".as_bytes())) } @@ -297,8 +297,8 @@ fn typarams(w: &mut io::Writer, } impl fmt::Show for clean::Type { - fn fmt(g: &clean::Type, f: &mut fmt::Formatter) -> fmt::Result { - match *g { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { clean::TyParamBinder(id) | clean::Generic(id) => { local_data::get(cache_key, |cache| { let m = cache.unwrap().get(); @@ -405,18 +405,18 @@ impl fmt::Show for clean::Type { } impl fmt::Show for clean::FnDecl { - fn fmt(d: &clean::FnDecl, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f.buf, "({args}){arrow, select, yes{ -> {ret}} other{}}", - args = d.inputs, - arrow = match d.output { clean::Unit => "no", _ => "yes" }, - ret = d.output) + args = self.inputs, + arrow = match self.output { clean::Unit => "no", _ => "yes" }, + ret = self.output) } } impl fmt::Show for ~[clean::Argument] { - fn fmt(inputs: &~[clean::Argument], f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut args = ~""; - for (i, input) in inputs.iter().enumerate() { + for (i, input) in self.iter().enumerate() { if i > 0 { args.push_str(", "); } if input.name.len() > 0 { args.push_str(format!("{}: ", input.name)); @@ -428,14 +428,13 @@ impl fmt::Show for ~[clean::Argument] { } impl<'a> fmt::Show for Method<'a> { - fn fmt(m: &Method<'a>, f: &mut fmt::Formatter) -> fmt::Result { - let Method(selfty, d) = *m; + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let Method(selfty, d) = *self; let mut args = ~""; match *selfty { clean::SelfStatic => {}, clean::SelfValue => args.push_str("self"), clean::SelfOwned => args.push_str("~self"), - clean::SelfManaged => args.push_str("@self"), clean::SelfBorrowed(Some(ref lt), clean::Immutable) => { args.push_str(format!("&{} self", *lt)); } @@ -464,8 +463,8 @@ impl<'a> fmt::Show for Method<'a> { } impl fmt::Show for VisSpace { - fn fmt(v: &VisSpace, f: &mut fmt::Formatter) -> fmt::Result { - match v.get() { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.get() { Some(ast::Public) => write!(f.buf, "pub "), Some(ast::Private) => write!(f.buf, "priv "), Some(ast::Inherited) | None => Ok(()) @@ -474,8 +473,8 @@ impl fmt::Show for VisSpace { } impl fmt::Show for PuritySpace { - fn fmt(p: &PuritySpace, f: &mut fmt::Formatter) -> fmt::Result { - match p.get() { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.get() { ast::UnsafeFn => write!(f.buf, "unsafe "), ast::ExternFn => write!(f.buf, "extern "), ast::ImpureFn => Ok(()) @@ -484,8 +483,8 @@ impl fmt::Show for PuritySpace { } impl fmt::Show for clean::ViewPath { - fn fmt(v: &clean::ViewPath, f: &mut fmt::Formatter) -> fmt::Result { - match *v { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { clean::SimpleImport(ref name, ref src) => { if *name == src.path.segments.last().unwrap().name { write!(f.buf, "use {};", *src) @@ -511,14 +510,14 @@ impl fmt::Show for clean::ViewPath { } impl fmt::Show for clean::ImportSource { - fn fmt(v: &clean::ImportSource, f: &mut fmt::Formatter) -> fmt::Result { - match v.did { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.did { // FIXME: shouldn't be restricted to just local imports Some(did) if ast_util::is_local(did) => { - resolved_path(f.buf, did.node, &v.path, true) + resolved_path(f.buf, did.node, &self.path, true) } _ => { - for (i, seg) in v.path.segments.iter().enumerate() { + for (i, seg) in self.path.segments.iter().enumerate() { if i > 0 { if_ok!(write!(f.buf, "::")) } @@ -531,21 +530,21 @@ impl fmt::Show for clean::ImportSource { } impl fmt::Show for clean::ViewListIdent { - fn fmt(v: &clean::ViewListIdent, f: &mut fmt::Formatter) -> fmt::Result { - match v.source { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.source { // FIXME: shouldn't be limited to just local imports Some(did) if ast_util::is_local(did) => { let path = clean::Path { global: false, segments: ~[clean::PathSegment { - name: v.name.clone(), + name: self.name.clone(), lifetimes: ~[], types: ~[], }] }; resolved_path(f.buf, did.node, &path, false) } - _ => write!(f.buf, "{}", v.name), + _ => write!(f.buf, "{}", self.name), } } } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index c2203a352c5..63748203a1a 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -211,8 +211,8 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) { } impl<'a> fmt::Show for Markdown<'a> { - fn fmt(md: &Markdown<'a>, fmt: &mut fmt::Formatter) -> fmt::Result { - let Markdown(md) = *md; + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let Markdown(md) = *self; // This is actually common enough to special-case if md.len() == 0 { return Ok(()) } render(fmt.buf, md.as_slice()) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index f01e420030f..606cb445262 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -250,7 +250,7 @@ pub fn run(mut crate: clean::Crate, dst: Path) -> io::IoResult<()> { let mut dst = cx.dst.join(crate.name.as_slice()); if_ok!(mkdir(&dst)); if_ok!(write(dst.join("jquery.js"), - include_str!("static/jquery-2.0.3.min.js"))); + include_str!("static/jquery-2.1.0.min.js"))); if_ok!(write(dst.join("main.js"), include_str!("static/main.js"))); if_ok!(write(dst.join("main.css"), include_str!("static/main.css"))); if_ok!(write(dst.join("normalize.css"), @@ -436,7 +436,7 @@ impl<'a> SourceCollector<'a> { cur.push(p.filename().expect("source has no filename") + bytes!(".html")); let mut w = BufferedWriter::new(if_ok!(File::create(&cur))); - let title = cur.filename_display().with_str(|s| format!("{} -- source", s)); + let title = format!("{} -- source", cur.filename_display()); let page = layout::Page { title: title, ty: "source", @@ -801,8 +801,8 @@ impl<'a> Item<'a> { } impl<'a> fmt::Show for Item<'a> { - fn fmt(it: &Item<'a>, fmt: &mut fmt::Formatter) -> fmt::Result { - match attr::find_stability(it.item.attrs.iter()) { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match attr::find_stability(self.item.attrs.iter()) { Some(ref stability) => { if_ok!(write!(fmt.buf, "<a class='stability {lvl}' title='{reason}'>{lvl}</a>", @@ -815,29 +815,29 @@ impl<'a> fmt::Show for Item<'a> { None => {} } - if it.cx.include_sources { + if self.cx.include_sources { let mut path = ~[]; - clean_srcpath(it.item.source.filename.as_bytes(), |component| { + clean_srcpath(self.item.source.filename.as_bytes(), |component| { path.push(component.to_owned()); }); - let href = if it.item.source.loline == it.item.source.hiline { - format!("{}", it.item.source.loline) + let href = if self.item.source.loline == self.item.source.hiline { + format!("{}", self.item.source.loline) } else { - format!("{}-{}", it.item.source.loline, it.item.source.hiline) + format!("{}-{}", self.item.source.loline, self.item.source.hiline) }; if_ok!(write!(fmt.buf, "<a class='source' href='{root}src/{crate}/{path}.html\\#{href}'>\ [src]</a>", - root = it.cx.root_path, - crate = it.cx.layout.crate, + root = self.cx.root_path, + crate = self.cx.layout.crate, path = path.connect("/"), href = href)); } // Write the breadcrumb trail header for the top if_ok!(write!(fmt.buf, "<h1 class='fqn'>")); - match it.item.inner { + match self.item.inner { clean::ModuleItem(..) => if_ok!(write!(fmt.buf, "Module ")), clean::FunctionItem(..) => if_ok!(write!(fmt.buf, "Function ")), clean::TraitItem(..) => if_ok!(write!(fmt.buf, "Trait ")), @@ -845,8 +845,8 @@ impl<'a> fmt::Show for Item<'a> { clean::EnumItem(..) => if_ok!(write!(fmt.buf, "Enum ")), _ => {} } - let cur = it.cx.current.as_slice(); - let amt = if it.ismodule() { cur.len() - 1 } else { cur.len() }; + let cur = self.cx.current.as_slice(); + let amt = if self.ismodule() { cur.len() - 1 } else { cur.len() }; for (i, component) in cur.iter().enumerate().take(amt) { let mut trail = ~""; for _ in range(0, cur.len() - i - 1) { @@ -856,17 +856,17 @@ impl<'a> fmt::Show for Item<'a> { trail, component.as_slice())); } if_ok!(write!(fmt.buf, "<a class='{}' href=''>{}</a></h1>", - shortty(it.item), it.item.name.get_ref().as_slice())); + shortty(self.item), self.item.name.get_ref().as_slice())); - match it.item.inner { - clean::ModuleItem(ref m) => item_module(fmt.buf, it.cx, - it.item, m.items), + match self.item.inner { + clean::ModuleItem(ref m) => item_module(fmt.buf, self.cx, + self.item, m.items), clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) => - item_function(fmt.buf, it.item, f), - clean::TraitItem(ref t) => item_trait(fmt.buf, it.item, t), - clean::StructItem(ref s) => item_struct(fmt.buf, it.item, s), - clean::EnumItem(ref e) => item_enum(fmt.buf, it.item, e), - clean::TypedefItem(ref t) => item_typedef(fmt.buf, it.item, t), + item_function(fmt.buf, self.item, f), + clean::TraitItem(ref t) => item_trait(fmt.buf, self.item, t), + clean::StructItem(ref s) => item_struct(fmt.buf, self.item, s), + clean::EnumItem(ref e) => item_enum(fmt.buf, self.item, e), + clean::TypedefItem(ref t) => item_typedef(fmt.buf, self.item, t), _ => Ok(()) } } @@ -992,9 +992,8 @@ fn item_module(w: &mut Writer, cx: &Context, clean::StaticItem(ref s) | clean::ForeignStaticItem(ref s) => { struct Initializer<'a>(&'a str); impl<'a> fmt::Show for Initializer<'a> { - fn fmt(s: &Initializer<'a>, - f: &mut fmt::Formatter) -> fmt::Result { - let Initializer(s) = *s; + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let Initializer(s) = *self; if s.len() == 0 { return Ok(()); } if_ok!(write!(f.buf, "<code> = </code>")); let tag = if s.contains("\n") { "pre" } else { "code" }; @@ -1518,9 +1517,9 @@ fn item_typedef(w: &mut Writer, it: &clean::Item, } impl<'a> fmt::Show for Sidebar<'a> { - fn fmt(s: &Sidebar<'a>, fmt: &mut fmt::Formatter) -> fmt::Result { - let cx = s.cx; - let it = s.item; + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let cx = self.cx; + let it = self.item; if_ok!(write!(fmt.buf, "<p class='location'>")); let len = cx.current.len() - if it.is_mod() {1} else {0}; for (i, name) in cx.current.iter().take(len).enumerate() { @@ -1588,8 +1587,8 @@ fn build_sidebar(m: &clean::Module) -> HashMap<~str, ~[~str]> { } impl<'a> fmt::Show for Source<'a> { - fn fmt(s: &Source<'a>, fmt: &mut fmt::Formatter) -> fmt::Result { - let Source(s) = *s; + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let Source(s) = *self; let lines = s.lines().len(); let mut cols = 0; let mut tmp = lines; diff --git a/src/librustdoc/html/static/jquery-2.0.3.min.js b/src/librustdoc/html/static/jquery-2.0.3.min.js deleted file mode 100644 index 2be209dd223..00000000000 --- a/src/librustdoc/html/static/jquery-2.0.3.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! jQuery v2.0.3 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license -//@ sourceMappingURL=jquery-2.0.3.min.map -*/ -(function(e,undefined){var t,n,r=typeof undefined,i=e.location,o=e.document,s=o.documentElement,a=e.jQuery,u=e.$,l={},c=[],p="2.0.3",f=c.concat,h=c.push,d=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,x=function(e,n){return new x.fn.init(e,n,t)},b=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^-ms-/,N=/-([\da-z])/gi,E=function(e,t){return t.toUpperCase()},S=function(){o.removeEventListener("DOMContentLoaded",S,!1),e.removeEventListener("load",S,!1),x.ready()};x.fn=x.prototype={jquery:p,constructor:x,init:function(e,t,n){var r,i;if(!e)return this;if("string"==typeof e){if(r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:T.exec(e),!r||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof x?t[0]:t,x.merge(this,x.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:o,!0)),C.test(r[1])&&x.isPlainObject(t))for(r in t)x.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return i=o.getElementById(r[2]),i&&i.parentNode&&(this.length=1,this[0]=i),this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?n.ready(e):(e.selector!==undefined&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return d.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,t,n,r,i,o,s=arguments[0]||{},a=1,u=arguments.length,l=!1;for("boolean"==typeof s&&(l=s,s=arguments[1]||{},a=2),"object"==typeof s||x.isFunction(s)||(s={}),u===a&&(s=this,--a);u>a;a++)if(null!=(e=arguments[a]))for(t in e)n=s[t],r=e[t],s!==r&&(l&&r&&(x.isPlainObject(r)||(i=x.isArray(r)))?(i?(i=!1,o=n&&x.isArray(n)?n:[]):o=n&&x.isPlainObject(n)?n:{},s[t]=x.extend(l,o,r)):r!==undefined&&(s[t]=r));return s},x.extend({expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=a),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){(e===!0?--x.readyWait:x.isReady)||(x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(o,[x]),x.fn.trigger&&x(o).trigger("ready").off("ready")))},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray,isWindow:function(e){return null!=e&&e===e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if("object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:JSON.parse,parseXML:function(e){var t,n;if(!e||"string"!=typeof e)return null;try{n=new DOMParser,t=n.parseFromString(e,"text/xml")}catch(r){t=undefined}return(!t||t.getElementsByTagName("parsererror").length)&&x.error("Invalid XML: "+e),t},noop:function(){},globalEval:function(e){var t,n=eval;e=x.trim(e),e&&(1===e.indexOf("use strict")?(t=o.createElement("script"),t.text=e,o.head.appendChild(t).parentNode.removeChild(t)):n(e))},camelCase:function(e){return e.replace(k,"ms-").replace(N,E)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,s=j(e);if(n){if(s){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(s){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:function(e){return null==e?"":v.call(e)},makeArray:function(e,t){var n=t||[];return null!=e&&(j(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:g.call(t,e,n)},merge:function(e,t){var n=t.length,r=e.length,i=0;if("number"==typeof n)for(;n>i;i++)e[r++]=t[i];else while(t[i]!==undefined)e[r++]=t[i++];return e.length=r,e},grep:function(e,t,n){var r,i=[],o=0,s=e.length;for(n=!!n;s>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,s=j(e),a=[];if(s)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(a[a.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(a[a.length]=r);return f.apply([],a)},guid:1,proxy:function(e,t){var n,r,i;return"string"==typeof t&&(n=e[t],t=e,e=n),x.isFunction(e)?(r=d.call(arguments,2),i=function(){return e.apply(t||this,r.concat(d.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):undefined},access:function(e,t,n,r,i,o,s){var a=0,u=e.length,l=null==n;if("object"===x.type(n)){i=!0;for(a in n)x.access(e,t,a,n[a],!0,o,s)}else if(r!==undefined&&(i=!0,x.isFunction(r)||(s=!0),l&&(s?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(x(e),n)})),t))for(;u>a;a++)t(e[a],n,s?r:r.call(e[a],a,t(e[a],n)));return i?e:l?t.call(e):u?t(e[0],n):o},now:Date.now,swap:function(e,t,n,r){var i,o,s={};for(o in t)s[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=s[o];return i}}),x.ready.promise=function(t){return n||(n=x.Deferred(),"complete"===o.readyState?setTimeout(x.ready):(o.addEventListener("DOMContentLoaded",S,!1),e.addEventListener("load",S,!1))),n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function j(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}t=x(o),function(e,undefined){var t,n,r,i,o,s,a,u,l,c,p,f,h,d,g,m,y,v="sizzle"+-new Date,b=e.document,w=0,T=0,C=st(),k=st(),N=st(),E=!1,S=function(e,t){return e===t?(E=!0,0):0},j=typeof undefined,D=1<<31,A={}.hasOwnProperty,L=[],q=L.pop,H=L.push,O=L.push,F=L.slice,P=L.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",W="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",$=W.replace("w","w#"),B="\\["+M+"*("+W+")"+M+"*(?:([*^$|!~]?=)"+M+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+$+")|)|)"+M+"*\\]",I=":("+W+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+B.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=RegExp("^"+M+"*,"+M+"*"),X=RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=RegExp(M+"*[+~]"),Y=RegExp("="+M+"*([^\\]'\"]*)"+M+"*\\]","g"),V=RegExp(I),G=RegExp("^"+$+"$"),J={ID:RegExp("^#("+W+")"),CLASS:RegExp("^\\.("+W+")"),TAG:RegExp("^("+W.replace("w","w*")+")"),ATTR:RegExp("^"+B),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:RegExp("^(?:"+R+")$","i"),needsContext:RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Q=/^[^{]+\{\s*\[native \w/,K=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Z=/^(?:input|select|textarea|button)$/i,et=/^h\d$/i,tt=/'|\\/g,nt=RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),rt=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{O.apply(L=F.call(b.childNodes),b.childNodes),L[b.childNodes.length].nodeType}catch(it){O={apply:L.length?function(e,t){H.apply(e,F.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function ot(e,t,r,i){var o,s,a,u,l,f,g,m,x,w;if((t?t.ownerDocument||t:b)!==p&&c(t),t=t||p,r=r||[],!e||"string"!=typeof e)return r;if(1!==(u=t.nodeType)&&9!==u)return[];if(h&&!i){if(o=K.exec(e))if(a=o[1]){if(9===u){if(s=t.getElementById(a),!s||!s.parentNode)return r;if(s.id===a)return r.push(s),r}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(a))&&y(t,s)&&s.id===a)return r.push(s),r}else{if(o[2])return O.apply(r,t.getElementsByTagName(e)),r;if((a=o[3])&&n.getElementsByClassName&&t.getElementsByClassName)return O.apply(r,t.getElementsByClassName(a)),r}if(n.qsa&&(!d||!d.test(e))){if(m=g=v,x=t,w=9===u&&e,1===u&&"object"!==t.nodeName.toLowerCase()){f=gt(e),(g=t.getAttribute("id"))?m=g.replace(tt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",l=f.length;while(l--)f[l]=m+mt(f[l]);x=U.test(e)&&t.parentNode||t,w=f.join(",")}if(w)try{return O.apply(r,x.querySelectorAll(w)),r}catch(T){}finally{g||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,r,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>i.cacheLength&&delete t[e.shift()],t[n]=r}return t}function at(e){return e[v]=!0,e}function ut(e){var t=p.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function lt(e,t){var n=e.split("|"),r=e.length;while(r--)i.attrHandle[n[r]]=t}function ct(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function pt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return at(function(t){return t=+t,at(function(n,r){var i,o=e([],n.length,t),s=o.length;while(s--)n[i=o[s]]&&(n[i]=!(r[i]=n[i]))})})}s=ot.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},n=ot.support={},c=ot.setDocument=function(e){var t=e?e.ownerDocument||e:b,r=t.defaultView;return t!==p&&9===t.nodeType&&t.documentElement?(p=t,f=t.documentElement,h=!s(t),r&&r.attachEvent&&r!==r.top&&r.attachEvent("onbeforeunload",function(){c()}),n.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ut(function(e){return e.appendChild(t.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=ut(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),n.getById=ut(function(e){return f.appendChild(e).id=v,!t.getElementsByName||!t.getElementsByName(v).length}),n.getById?(i.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(nt,rt);return function(e){return e.getAttribute("id")===t}}):(delete i.find.ID,i.filter.ID=function(e){var t=e.replace(nt,rt);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=n.getElementsByTagName?function(e,t){return typeof t.getElementsByTagName!==j?t.getElementsByTagName(e):undefined}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.CLASS=n.getElementsByClassName&&function(e,t){return typeof t.getElementsByClassName!==j&&h?t.getElementsByClassName(e):undefined},g=[],d=[],(n.qsa=Q.test(t.querySelectorAll))&&(ut(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||d.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll(":checked").length||d.push(":checked")}),ut(function(e){var n=t.createElement("input");n.setAttribute("type","hidden"),e.appendChild(n).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&d.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||d.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),d.push(",.*:")})),(n.matchesSelector=Q.test(m=f.webkitMatchesSelector||f.mozMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&ut(function(e){n.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",I)}),d=d.length&&RegExp(d.join("|")),g=g.length&&RegExp(g.join("|")),y=Q.test(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},S=f.compareDocumentPosition?function(e,r){if(e===r)return E=!0,0;var i=r.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(r);return i?1&i||!n.sortDetached&&r.compareDocumentPosition(e)===i?e===t||y(b,e)?-1:r===t||y(b,r)?1:l?P.call(l,e)-P.call(l,r):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,n){var r,i=0,o=e.parentNode,s=n.parentNode,a=[e],u=[n];if(e===n)return E=!0,0;if(!o||!s)return e===t?-1:n===t?1:o?-1:s?1:l?P.call(l,e)-P.call(l,n):0;if(o===s)return ct(e,n);r=e;while(r=r.parentNode)a.unshift(r);r=n;while(r=r.parentNode)u.unshift(r);while(a[i]===u[i])i++;return i?ct(a[i],u[i]):a[i]===b?-1:u[i]===b?1:0},t):p},ot.matches=function(e,t){return ot(e,null,null,t)},ot.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Y,"='$1']"),!(!n.matchesSelector||!h||g&&g.test(t)||d&&d.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(i){}return ot(t,p,null,[e]).length>0},ot.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},ot.attr=function(e,t){(e.ownerDocument||e)!==p&&c(e);var r=i.attrHandle[t.toLowerCase()],o=r&&A.call(i.attrHandle,t.toLowerCase())?r(e,t,!h):undefined;return o===undefined?n.attributes||!h?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null:o},ot.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},ot.uniqueSort=function(e){var t,r=[],i=0,o=0;if(E=!n.detectDuplicates,l=!n.sortStable&&e.slice(0),e.sort(S),E){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return e},o=ot.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=ot.selectors={cacheLength:50,createPseudo:at,match:J,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(nt,rt),e[3]=(e[4]||e[5]||"").replace(nt,rt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||ot.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&ot.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return J.CHILD.test(e[0])?null:(e[3]&&e[4]!==undefined?e[2]=e[4]:n&&V.test(n)&&(t=gt(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(nt,rt).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=C[e+" "];return t||(t=RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&C(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=ot.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),s="last"!==e.slice(-4),a="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,h,d,g=o!==s?"nextSibling":"previousSibling",m=t.parentNode,y=a&&t.nodeName.toLowerCase(),x=!u&&!a;if(m){if(o){while(g){p=t;while(p=p[g])if(a?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;d=g="only"===e&&!d&&"nextSibling"}return!0}if(d=[s?m.firstChild:m.lastChild],s&&x){c=m[v]||(m[v]={}),l=c[e]||[],h=l[0]===w&&l[1],f=l[0]===w&&l[2],p=h&&m.childNodes[h];while(p=++h&&p&&p[g]||(f=h=0)||d.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[w,h,f];break}}else if(x&&(l=(t[v]||(t[v]={}))[e])&&l[0]===w)f=l[1];else while(p=++h&&p&&p[g]||(f=h=0)||d.pop())if((a?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(x&&((p[v]||(p[v]={}))[e]=[w,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||ot.error("unsupported pseudo: "+e);return r[v]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?at(function(e,n){var i,o=r(e,t),s=o.length;while(s--)i=P.call(e,o[s]),e[i]=!(n[i]=o[s])}):function(e){return r(e,0,n)}):r}},pseudos:{not:at(function(e){var t=[],n=[],r=a(e.replace(z,"$1"));return r[v]?at(function(e,t,n,i){var o,s=r(e,null,i,[]),a=e.length;while(a--)(o=s[a])&&(e[a]=!(t[a]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:at(function(e){return function(t){return ot(e,t).length>0}}),contains:at(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:at(function(e){return G.test(e||"")||ot.error("unsupported lang: "+e),e=e.replace(nt,rt).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return et.test(e.nodeName)},input:function(e){return Z.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},i.pseudos.nth=i.pseudos.eq;for(t in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[t]=pt(t);for(t in{submit:!0,reset:!0})i.pseudos[t]=ft(t);function dt(){}dt.prototype=i.filters=i.pseudos,i.setFilters=new dt;function gt(e,t){var n,r,o,s,a,u,l,c=k[e+" "];if(c)return t?0:c.slice(0);a=e,u=[],l=i.preFilter;while(a){(!n||(r=_.exec(a)))&&(r&&(a=a.slice(r[0].length)||a),u.push(o=[])),n=!1,(r=X.exec(a))&&(n=r.shift(),o.push({value:n,type:r[0].replace(z," ")}),a=a.slice(n.length));for(s in i.filter)!(r=J[s].exec(a))||l[s]&&!(r=l[s](r))||(n=r.shift(),o.push({value:n,type:s,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?ot.error(e):k(e,u).slice(0)}function mt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function yt(e,t,n){var i=t.dir,o=n&&"parentNode"===i,s=T++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,a){var u,l,c,p=w+" "+s;if(a){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,a))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[v]||(t[v]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,a)||r,l[1]===!0)return!0}}function vt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,s=[],a=0,u=e.length,l=null!=t;for(;u>a;a++)(o=e[a])&&(!n||n(o,r,i))&&(s.push(o),l&&t.push(a));return s}function bt(e,t,n,r,i,o){return r&&!r[v]&&(r=bt(r)),i&&!i[v]&&(i=bt(i,o)),at(function(o,s,a,u){var l,c,p,f=[],h=[],d=s.length,g=o||Ct(t||"*",a.nodeType?[a]:a,[]),m=!e||!o&&t?g:xt(g,f,e,a,u),y=n?i||(o?e:d||r)?[]:s:m;if(n&&n(m,y,a,u),r){l=xt(y,h),r(l,[],a,u),c=l.length;while(c--)(p=l[c])&&(y[h[c]]=!(m[h[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?P.call(o,p):f[c])>-1&&(o[l]=!(s[l]=p))}}else y=xt(y===s?y.splice(d,y.length):y),i?i(null,s,y,u):O.apply(s,y)})}function wt(e){var t,n,r,o=e.length,s=i.relative[e[0].type],a=s||i.relative[" "],l=s?1:0,c=yt(function(e){return e===t},a,!0),p=yt(function(e){return P.call(t,e)>-1},a,!0),f=[function(e,n,r){return!s&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>l;l++)if(n=i.relative[e[l].type])f=[yt(vt(f),n)];else{if(n=i.filter[e[l].type].apply(null,e[l].matches),n[v]){for(r=++l;o>r;r++)if(i.relative[e[r].type])break;return bt(l>1&&vt(f),l>1&&mt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&wt(e.slice(l,r)),o>r&&wt(e=e.slice(r)),o>r&&mt(e))}f.push(n)}return vt(f)}function Tt(e,t){var n=0,o=t.length>0,s=e.length>0,a=function(a,l,c,f,h){var d,g,m,y=[],v=0,x="0",b=a&&[],T=null!=h,C=u,k=a||s&&i.find.TAG("*",h&&l.parentNode||l),N=w+=null==C?1:Math.random()||.1;for(T&&(u=l!==p&&l,r=n);null!=(d=k[x]);x++){if(s&&d){g=0;while(m=e[g++])if(m(d,l,c)){f.push(d);break}T&&(w=N,r=++n)}o&&((d=!m&&d)&&v--,a&&b.push(d))}if(v+=x,o&&x!==v){g=0;while(m=t[g++])m(b,y,l,c);if(a){if(v>0)while(x--)b[x]||y[x]||(y[x]=q.call(f));y=xt(y)}O.apply(f,y),T&&!a&&y.length>0&&v+t.length>1&&ot.uniqueSort(f)}return T&&(w=N,u=C),b};return o?at(a):a}a=ot.compile=function(e,t){var n,r=[],i=[],o=N[e+" "];if(!o){t||(t=gt(e)),n=t.length;while(n--)o=wt(t[n]),o[v]?r.push(o):i.push(o);o=N(e,Tt(i,r))}return o};function Ct(e,t,n){var r=0,i=t.length;for(;i>r;r++)ot(e,t[r],n);return n}function kt(e,t,r,o){var s,u,l,c,p,f=gt(e);if(!o&&1===f.length){if(u=f[0]=f[0].slice(0),u.length>2&&"ID"===(l=u[0]).type&&n.getById&&9===t.nodeType&&h&&i.relative[u[1].type]){if(t=(i.find.ID(l.matches[0].replace(nt,rt),t)||[])[0],!t)return r;e=e.slice(u.shift().value.length)}s=J.needsContext.test(e)?0:u.length;while(s--){if(l=u[s],i.relative[c=l.type])break;if((p=i.find[c])&&(o=p(l.matches[0].replace(nt,rt),U.test(u[0].type)&&t.parentNode||t))){if(u.splice(s,1),e=o.length&&mt(u),!e)return O.apply(r,o),r;break}}}return a(e,f)(o,t,!h,r,U.test(e)),r}n.sortStable=v.split("").sort(S).join("")===v,n.detectDuplicates=E,c(),n.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(p.createElement("div"))}),ut(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||lt("type|href|height|width",function(e,t,n){return n?undefined:e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ut(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||lt("value",function(e,t,n){return n||"input"!==e.nodeName.toLowerCase()?undefined:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||lt(R,function(e,t,n){var r;return n?undefined:(r=e.getAttributeNode(t))&&r.specified?r.value:e[t]===!0?t.toLowerCase():null}),x.find=ot,x.expr=ot.selectors,x.expr[":"]=x.expr.pseudos,x.unique=ot.uniqueSort,x.text=ot.getText,x.isXMLDoc=ot.isXML,x.contains=ot.contains}(e);var D={};function A(e){var t=D[e]={};return x.each(e.match(w)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?D[e]||A(e):x.extend({},e);var t,n,r,i,o,s,a=[],u=!e.once&&[],l=function(p){for(t=e.memory&&p,n=!0,s=i||0,i=0,o=a.length,r=!0;a&&o>s;s++)if(a[s].apply(p[0],p[1])===!1&&e.stopOnFalse){t=!1;break}r=!1,a&&(u?u.length&&l(u.shift()):t?a=[]:c.disable())},c={add:function(){if(a){var n=a.length;(function s(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&c.has(n)||a.push(n):n&&n.length&&"string"!==r&&s(n)})})(arguments),r?o=a.length:t&&(i=n,l(t))}return this},remove:function(){return a&&x.each(arguments,function(e,t){var n;while((n=x.inArray(t,a,n))>-1)a.splice(n,1),r&&(o>=n&&o--,s>=n&&s--)}),this},has:function(e){return e?x.inArray(e,a)>-1:!(!a||!a.length)},empty:function(){return a=[],o=0,this},disable:function(){return a=u=t=undefined,this},disabled:function(){return!a},lock:function(){return u=undefined,t||c.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!a||n&&!u||(t=t||[],t=[e,t.slice?t.slice():t],r?u.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!n}};return c},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var s=o[0],a=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=a&&a.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===r?n.promise():this,a?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var s=o[2],a=o[3];r[o[1]]=s.add,a&&s.add(function(){n=a},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=s.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=d.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),s=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?d.call(arguments):r,n===a?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},a,u,l;if(r>1)for(a=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(s(t,l,n)).fail(o.reject).progress(s(t,u,a)):--i;return i||o.resolveWith(l,n),o.promise()}}),x.support=function(t){var n=o.createElement("input"),r=o.createDocumentFragment(),i=o.createElement("div"),s=o.createElement("select"),a=s.appendChild(o.createElement("option"));return n.type?(n.type="checkbox",t.checkOn=""!==n.value,t.optSelected=a.selected,t.reliableMarginRight=!0,t.boxSizingReliable=!0,t.pixelPosition=!1,n.checked=!0,t.noCloneChecked=n.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!a.disabled,n=o.createElement("input"),n.value="t",n.type="radio",t.radioValue="t"===n.value,n.setAttribute("checked","t"),n.setAttribute("name","t"),r.appendChild(n),t.checkClone=r.cloneNode(!0).cloneNode(!0).lastChild.checked,t.focusinBubbles="onfocusin"in e,i.style.backgroundClip="content-box",i.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===i.style.backgroundClip,x(function(){var n,r,s="padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",a=o.getElementsByTagName("body")[0];a&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",a.appendChild(n).appendChild(i),i.innerHTML="",i.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%",x.swap(a,null!=a.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===i.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(i,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(i,null)||{width:"4px"}).width,r=i.appendChild(o.createElement("div")),r.style.cssText=i.style.cssText=s,r.style.marginRight=r.style.width="0",i.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),a.removeChild(n))}),t):t}({});var L,q,H=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,O=/([A-Z])/g;function F(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=x.expando+Math.random()}F.uid=1,F.accepts=function(e){return e.nodeType?1===e.nodeType||9===e.nodeType:!0},F.prototype={key:function(e){if(!F.accepts(e))return 0;var t={},n=e[this.expando];if(!n){n=F.uid++;try{t[this.expando]={value:n},Object.defineProperties(e,t)}catch(r){t[this.expando]=n,x.extend(e,t)}}return this.cache[n]||(this.cache[n]={}),n},set:function(e,t,n){var r,i=this.key(e),o=this.cache[i];if("string"==typeof t)o[t]=n;else if(x.isEmptyObject(o))x.extend(this.cache[i],t);else for(r in t)o[r]=t[r];return o},get:function(e,t){var n=this.cache[this.key(e)];return t===undefined?n:n[t]},access:function(e,t,n){var r;return t===undefined||t&&"string"==typeof t&&n===undefined?(r=this.get(e,t),r!==undefined?r:this.get(e,x.camelCase(t))):(this.set(e,t,n),n!==undefined?n:t)},remove:function(e,t){var n,r,i,o=this.key(e),s=this.cache[o];if(t===undefined)this.cache[o]={};else{x.isArray(t)?r=t.concat(t.map(x.camelCase)):(i=x.camelCase(t),t in s?r=[t,i]:(r=i,r=r in s?[r]:r.match(w)||[])),n=r.length;while(n--)delete s[r[n]]}},hasData:function(e){return!x.isEmptyObject(this.cache[e[this.expando]]||{})},discard:function(e){e[this.expando]&&delete this.cache[e[this.expando]]}},L=new F,q=new F,x.extend({acceptData:F.accepts,hasData:function(e){return L.hasData(e)||q.hasData(e)},data:function(e,t,n){return L.access(e,t,n)},removeData:function(e,t){L.remove(e,t)},_data:function(e,t,n){return q.access(e,t,n)},_removeData:function(e,t){q.remove(e,t)}}),x.fn.extend({data:function(e,t){var n,r,i=this[0],o=0,s=null;if(e===undefined){if(this.length&&(s=L.get(i),1===i.nodeType&&!q.get(i,"hasDataAttrs"))){for(n=i.attributes;n.length>o;o++)r=n[o].name,0===r.indexOf("data-")&&(r=x.camelCase(r.slice(5)),P(i,r,s[r]));q.set(i,"hasDataAttrs",!0)}return s}return"object"==typeof e?this.each(function(){L.set(this,e)}):x.access(this,function(t){var n,r=x.camelCase(e);if(i&&t===undefined){if(n=L.get(i,e),n!==undefined)return n;if(n=L.get(i,r),n!==undefined)return n;if(n=P(i,r,undefined),n!==undefined)return n}else this.each(function(){var n=L.get(this,r);L.set(this,r,t),-1!==e.indexOf("-")&&n!==undefined&&L.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){L.remove(this,e)})}});function P(e,t,n){var r;if(n===undefined&&1===e.nodeType)if(r="data-"+t.replace(O,"-$1").toLowerCase(),n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:H.test(n)?JSON.parse(n):n}catch(i){}L.set(e,t,n)}else n=undefined;return n}x.extend({queue:function(e,t,n){var r;return e?(t=(t||"fx")+"queue",r=q.get(e,t),n&&(!r||x.isArray(n)?r=q.access(e,t,x.makeArray(n)):r.push(n)),r||[]):undefined},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),s=function(){x.dequeue(e,t) -};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,s,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return q.get(e,n)||q.access(e,n,{empty:x.Callbacks("once memory").add(function(){q.remove(e,[t+"queue",n])})})}}),x.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),n>arguments.length?x.queue(this[0],e):t===undefined?this:this.each(function(){var n=x.queue(this,e,t);x._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=x.Deferred(),o=this,s=this.length,a=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=undefined),e=e||"fx";while(s--)n=q.get(o[s],e+"queueHooks"),n&&n.empty&&(r++,n.empty.add(a));return a(),i.promise(t)}});var R,M,W=/[\t\r\n\f]/g,$=/\r/g,B=/^(?:input|select|textarea|button)$/i;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[x.propFix[e]||e]})},addClass:function(e){var t,n,r,i,o,s=0,a=this.length,u="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];a>s;s++)if(n=this[s],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(W," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,s=0,a=this.length,u=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];a>s;s++)if(n=this[s],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(W," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,i=0,o=x(this),s=e.match(w)||[];while(t=s[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===r||"boolean"===n)&&(this.className&&q.set(this,"__className__",this.className),this.className=this.className||e===!1?"":q.get(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(W," ").indexOf(t)>=0)return!0;return!1},val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=x.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,x(this).val()):e,null==i?i="":"number"==typeof i?i+="":x.isArray(i)&&(i=x.map(i,function(e){return null==e?"":e+""})),t=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],t&&"set"in t&&t.set(this,i,"value")!==undefined||(this.value=i))});if(i)return t=x.valHooks[i.type]||x.valHooks[i.nodeName.toLowerCase()],t&&"get"in t&&(n=t.get(i,"value"))!==undefined?n:(n=i.value,"string"==typeof n?n.replace($,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,s=o?null:[],a=o?i+1:r.length,u=0>i?a:o?i:0;for(;a>u;u++)if(n=r[u],!(!n.selected&&u!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),s=i.length;while(s--)r=i[s],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,t,n){var i,o,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===r?x.prop(e,t,n):(1===s&&x.isXMLDoc(e)||(t=t.toLowerCase(),i=x.attrHooks[t]||(x.expr.match.bool.test(t)?M:R)),n===undefined?i&&"get"in i&&null!==(o=i.get(e,t))?o:(o=x.find.attr(e,t),null==o?undefined:o):null!==n?i&&"set"in i&&(o=i.set(e,n,t))!==undefined?o:(e.setAttribute(t,n+""),n):(x.removeAttr(e,t),undefined))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)&&(e[r]=!1),e.removeAttribute(n)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,t,n){var r,i,o,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return o=1!==s||!x.isXMLDoc(e),o&&(t=x.propFix[t]||t,i=x.propHooks[t]),n!==undefined?i&&"set"in i&&(r=i.set(e,n,t))!==undefined?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){return e.hasAttribute("tabindex")||B.test(e.nodeName)||e.href?e.tabIndex:-1}}}}),M={set:function(e,t,n){return t===!1?x.removeAttr(e,n):e.setAttribute(n,n),n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,t){var n=x.expr.attrHandle[t]||x.find.attr;x.expr.attrHandle[t]=function(e,t,r){var i=x.expr.attrHandle[t],o=r?undefined:(x.expr.attrHandle[t]=undefined)!=n(e,t,r)?t.toLowerCase():null;return x.expr.attrHandle[t]=i,o}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,t){return x.isArray(t)?e.checked=x.inArray(x(e).val(),t)>=0:undefined}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var I=/^key/,z=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,X=/^([^.]*)(?:\.(.+)|)$/;function U(){return!0}function Y(){return!1}function V(){try{return o.activeElement}catch(e){}}x.event={global:{},add:function(e,t,n,i,o){var s,a,u,l,c,p,f,h,d,g,m,y=q.get(e);if(y){n.handler&&(s=n,n=s.handler,o=s.selector),n.guid||(n.guid=x.guid++),(l=y.events)||(l=y.events={}),(a=y.handle)||(a=y.handle=function(e){return typeof x===r||e&&x.event.triggered===e.type?undefined:x.event.dispatch.apply(a.elem,arguments)},a.elem=e),t=(t||"").match(w)||[""],c=t.length;while(c--)u=X.exec(t[c])||[],d=m=u[1],g=(u[2]||"").split(".").sort(),d&&(f=x.event.special[d]||{},d=(o?f.delegateType:f.bindType)||d,f=x.event.special[d]||{},p=x.extend({type:d,origType:m,data:i,handler:n,guid:n.guid,selector:o,needsContext:o&&x.expr.match.needsContext.test(o),namespace:g.join(".")},s),(h=l[d])||(h=l[d]=[],h.delegateCount=0,f.setup&&f.setup.call(e,i,g,a)!==!1||e.addEventListener&&e.addEventListener(d,a,!1)),f.add&&(f.add.call(e,p),p.handler.guid||(p.handler.guid=n.guid)),o?h.splice(h.delegateCount++,0,p):h.push(p),x.event.global[d]=!0);e=null}},remove:function(e,t,n,r,i){var o,s,a,u,l,c,p,f,h,d,g,m=q.hasData(e)&&q.get(e);if(m&&(u=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(a=X.exec(t[l])||[],h=g=a[1],d=(a[2]||"").split(".").sort(),h){p=x.event.special[h]||{},h=(r?p.delegateType:p.bindType)||h,f=u[h]||[],a=a[2]&&RegExp("(^|\\.)"+d.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=o=f.length;while(o--)c=f[o],!i&&g!==c.origType||n&&n.guid!==c.guid||a&&!a.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(f.splice(o,1),c.selector&&f.delegateCount--,p.remove&&p.remove.call(e,c));s&&!f.length&&(p.teardown&&p.teardown.call(e,d,m.handle)!==!1||x.removeEvent(e,h,m.handle),delete u[h])}else for(h in u)x.event.remove(e,h+t[l],n,r,!0);x.isEmptyObject(u)&&(delete m.handle,q.remove(e,"events"))}},trigger:function(t,n,r,i){var s,a,u,l,c,p,f,h=[r||o],d=y.call(t,"type")?t.type:t,g=y.call(t,"namespace")?t.namespace.split("."):[];if(a=u=r=r||o,3!==r.nodeType&&8!==r.nodeType&&!_.test(d+x.event.triggered)&&(d.indexOf(".")>=0&&(g=d.split("."),d=g.shift(),g.sort()),c=0>d.indexOf(":")&&"on"+d,t=t[x.expando]?t:new x.Event(d,"object"==typeof t&&t),t.isTrigger=i?2:3,t.namespace=g.join("."),t.namespace_re=t.namespace?RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=undefined,t.target||(t.target=r),n=null==n?[t]:x.makeArray(n,[t]),f=x.event.special[d]||{},i||!f.trigger||f.trigger.apply(r,n)!==!1)){if(!i&&!f.noBubble&&!x.isWindow(r)){for(l=f.delegateType||d,_.test(l+d)||(a=a.parentNode);a;a=a.parentNode)h.push(a),u=a;u===(r.ownerDocument||o)&&h.push(u.defaultView||u.parentWindow||e)}s=0;while((a=h[s++])&&!t.isPropagationStopped())t.type=s>1?l:f.bindType||d,p=(q.get(a,"events")||{})[t.type]&&q.get(a,"handle"),p&&p.apply(a,n),p=c&&a[c],p&&x.acceptData(a)&&p.apply&&p.apply(a,n)===!1&&t.preventDefault();return t.type=d,i||t.isDefaultPrevented()||f._default&&f._default.apply(h.pop(),n)!==!1||!x.acceptData(r)||c&&x.isFunction(r[d])&&!x.isWindow(r)&&(u=r[c],u&&(r[c]=null),x.event.triggered=d,r[d](),x.event.triggered=undefined,u&&(r[c]=u)),t.result}},dispatch:function(e){e=x.event.fix(e);var t,n,r,i,o,s=[],a=d.call(arguments),u=(q.get(this,"events")||{})[e.type]||[],l=x.event.special[e.type]||{};if(a[0]=e,e.delegateTarget=this,!l.preDispatch||l.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),t=0;while((i=s[t++])&&!e.isPropagationStopped()){e.currentTarget=i.elem,n=0;while((o=i.handlers[n++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(o.namespace))&&(e.handleObj=o,e.data=o.data,r=((x.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,a),r!==undefined&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return l.postDispatch&&l.postDispatch.call(this,e),e.result}},handlers:function(e,t){var n,r,i,o,s=[],a=t.delegateCount,u=e.target;if(a&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!==this;u=u.parentNode||this)if(u.disabled!==!0||"click"!==e.type){for(r=[],n=0;a>n;n++)o=t[n],i=o.selector+" ",r[i]===undefined&&(r[i]=o.needsContext?x(i,this).index(u)>=0:x.find(i,this,null,[u]).length),r[i]&&r.push(o);r.length&&s.push({elem:u,handlers:r})}return t.length>a&&s.push({elem:this,handlers:t.slice(a)}),s},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,t){var n,r,i,s=t.button;return null==e.pageX&&null!=t.clientX&&(n=e.target.ownerDocument||o,r=n.documentElement,i=n.body,e.pageX=t.clientX+(r&&r.scrollLeft||i&&i.scrollLeft||0)-(r&&r.clientLeft||i&&i.clientLeft||0),e.pageY=t.clientY+(r&&r.scrollTop||i&&i.scrollTop||0)-(r&&r.clientTop||i&&i.clientTop||0)),e.which||s===undefined||(e.which=1&s?1:2&s?3:4&s?2:0),e}},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,s=e,a=this.fixHooks[i];a||(this.fixHooks[i]=a=z.test(i)?this.mouseHooks:I.test(i)?this.keyHooks:{}),r=a.props?this.props.concat(a.props):this.props,e=new x.Event(s),t=r.length;while(t--)n=r[t],e[n]=s[n];return e.target||(e.target=o),3===e.target.nodeType&&(e.target=e.target.parentNode),a.filter?a.filter(e,s):e},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==V()&&this.focus?(this.focus(),!1):undefined},delegateType:"focusin"},blur:{trigger:function(){return this===V()&&this.blur?(this.blur(),!1):undefined},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&x.nodeName(this,"input")?(this.click(),!1):undefined},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==undefined&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)},x.Event=function(e,t){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.getPreventDefault&&e.getPreventDefault()?U:Y):this.type=e,t&&x.extend(this,t),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,undefined):new x.Event(e,t)},x.Event.prototype={isDefaultPrevented:Y,isPropagationStopped:Y,isImmediatePropagationStopped:Y,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=U,e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=U,e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=U,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,t,n,r,i){var o,s;if("object"==typeof e){"string"!=typeof t&&(n=n||t,t=undefined);for(s in e)this.on(s,t,n,e[s],i);return this}if(null==n&&null==r?(r=t,n=t=undefined):null==r&&("string"==typeof t?(r=n,n=undefined):(r=n,n=t,t=undefined)),r===!1)r=Y;else if(!r)return this;return 1===i&&(o=r,r=function(e){return x().off(e),o.apply(this,arguments)},r.guid=o.guid||(o.guid=x.guid++)),this.each(function(){x.event.add(this,e,r,n,t)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,x(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return(t===!1||"function"==typeof t)&&(n=t,t=undefined),n===!1&&(n=Y),this.each(function(){x.event.remove(this,e,n,t)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];return n?x.event.trigger(e,t,n,!0):undefined}});var G=/^.[^:#\[\.,]*$/,J=/^(?:parents|prev(?:Until|All))/,Q=x.expr.match.needsContext,K={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t=x(e,this),n=t.length;return this.filter(function(){var e=0;for(;n>e;e++)if(x.contains(this,t[e]))return!0})},not:function(e){return this.pushStack(et(this,e||[],!0))},filter:function(e){return this.pushStack(et(this,e||[],!1))},is:function(e){return!!et(this,"string"==typeof e&&Q.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],s=Q.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(s?s.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?g.call(x(e),this[0]):g.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function Z(e,t){while((e=e[t])&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return Z(e,"nextSibling")},prev:function(e){return Z(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return e.contentDocument||x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(K[e]||x.unique(i),J.test(e)&&i.reverse()),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,t,n){var r=[],i=n!==undefined;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&x(e).is(n))break;r.push(e)}return r},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function et(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(G.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return g.call(t,e)>=0!==n})}var tt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,nt=/<([\w:]+)/,rt=/<|&#?\w+;/,it=/<(?:script|style|link)/i,ot=/^(?:checkbox|radio)$/i,st=/checked\s*(?:[^=]|=\s*.checked.)/i,at=/^$|\/(?:java|ecma)script/i,ut=/^true\/(.*)/,lt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ct={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ct.optgroup=ct.option,ct.tbody=ct.tfoot=ct.colgroup=ct.caption=ct.thead,ct.th=ct.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===undefined?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=pt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=pt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(mt(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&dt(mt(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++)1===e.nodeType&&(x.cleanData(mt(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var t=this[0]||{},n=0,r=this.length;if(e===undefined&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!it.test(e)&&!ct[(nt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(tt,"<$1></$2>");try{for(;r>n;n++)t=this[n]||{},1===t.nodeType&&(x.cleanData(mt(t,!1)),t.innerHTML=e);t=0}catch(i){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=f.apply([],e);var r,i,o,s,a,u,l=0,c=this.length,p=this,h=c-1,d=e[0],g=x.isFunction(d);if(g||!(1>=c||"string"!=typeof d||x.support.checkClone)&&st.test(d))return this.each(function(r){var i=p.eq(r);g&&(e[0]=d.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(r=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),i=r.firstChild,1===r.childNodes.length&&(r=i),i)){for(o=x.map(mt(r,"script"),ft),s=o.length;c>l;l++)a=r,l!==h&&(a=x.clone(a,!0,!0),s&&x.merge(o,mt(a,"script"))),t.call(this[l],a,l);if(s)for(u=o[o.length-1].ownerDocument,x.map(o,ht),l=0;s>l;l++)a=o[l],at.test(a.type||"")&&!q.access(a,"globalEval")&&x.contains(u,a)&&(a.src?x._evalUrl(a.src):x.globalEval(a.textContent.replace(lt,"")))}return this}}),x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=[],i=x(e),o=i.length-1,s=0;for(;o>=s;s++)n=s===o?this:this.clone(!0),x(i[s])[t](n),h.apply(r,n.get());return this.pushStack(r)}}),x.extend({clone:function(e,t,n){var r,i,o,s,a=e.cloneNode(!0),u=x.contains(e.ownerDocument,e);if(!(x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(s=mt(a),o=mt(e),r=0,i=o.length;i>r;r++)yt(o[r],s[r]);if(t)if(n)for(o=o||mt(e),s=s||mt(a),r=0,i=o.length;i>r;r++)gt(o[r],s[r]);else gt(e,a);return s=mt(a,"script"),s.length>0&&dt(s,!u&&mt(e,"script")),a},buildFragment:function(e,t,n,r){var i,o,s,a,u,l,c=0,p=e.length,f=t.createDocumentFragment(),h=[];for(;p>c;c++)if(i=e[c],i||0===i)if("object"===x.type(i))x.merge(h,i.nodeType?[i]:i);else if(rt.test(i)){o=o||f.appendChild(t.createElement("div")),s=(nt.exec(i)||["",""])[1].toLowerCase(),a=ct[s]||ct._default,o.innerHTML=a[1]+i.replace(tt,"<$1></$2>")+a[2],l=a[0];while(l--)o=o.lastChild;x.merge(h,o.childNodes),o=f.firstChild,o.textContent=""}else h.push(t.createTextNode(i));f.textContent="",c=0;while(i=h[c++])if((!r||-1===x.inArray(i,r))&&(u=x.contains(i.ownerDocument,i),o=mt(f.appendChild(i),"script"),u&&dt(o),n)){l=0;while(i=o[l++])at.test(i.type||"")&&n.push(i)}return f},cleanData:function(e){var t,n,r,i,o,s,a=x.event.special,u=0;for(;(n=e[u])!==undefined;u++){if(F.accepts(n)&&(o=n[q.expando],o&&(t=q.cache[o]))){if(r=Object.keys(t.events||{}),r.length)for(s=0;(i=r[s])!==undefined;s++)a[i]?x.event.remove(n,i):x.removeEvent(n,i,t.handle);q.cache[o]&&delete q.cache[o]}delete L.cache[n[L.expando]]}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}});function pt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function ft(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function ht(e){var t=ut.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function dt(e,t){var n=e.length,r=0;for(;n>r;r++)q.set(e[r],"globalEval",!t||q.get(t[r],"globalEval"))}function gt(e,t){var n,r,i,o,s,a,u,l;if(1===t.nodeType){if(q.hasData(e)&&(o=q.access(e),s=q.set(t,o),l=o.events)){delete s.handle,s.events={};for(i in l)for(n=0,r=l[i].length;r>n;n++)x.event.add(t,i,l[i][n])}L.hasData(e)&&(a=L.access(e),u=x.extend({},a),L.set(t,u))}}function mt(e,t){var n=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];return t===undefined||t&&x.nodeName(e,t)?x.merge([e],n):n}function yt(e,t){var n=t.nodeName.toLowerCase();"input"===n&&ot.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}x.fn.extend({wrapAll:function(e){var t;return x.isFunction(e)?this.each(function(t){x(this).wrapAll(e.call(this,t))}):(this[0]&&(t=x(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this)},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var vt,xt,bt=/^(none|table(?!-c[ea]).+)/,wt=/^margin/,Tt=RegExp("^("+b+")(.*)$","i"),Ct=RegExp("^("+b+")(?!px)[a-z%]+$","i"),kt=RegExp("^([+-])=("+b+")","i"),Nt={BODY:"block"},Et={position:"absolute",visibility:"hidden",display:"block"},St={letterSpacing:0,fontWeight:400},jt=["Top","Right","Bottom","Left"],Dt=["Webkit","O","Moz","ms"];function At(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Dt.length;while(i--)if(t=Dt[i]+n,t in e)return t;return r}function Lt(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function qt(t){return e.getComputedStyle(t,null)}function Ht(e,t){var n,r,i,o=[],s=0,a=e.length;for(;a>s;s++)r=e[s],r.style&&(o[s]=q.get(r,"olddisplay"),n=r.style.display,t?(o[s]||"none"!==n||(r.style.display=""),""===r.style.display&&Lt(r)&&(o[s]=q.access(r,"olddisplay",Rt(r.nodeName)))):o[s]||(i=Lt(r),(n&&"none"!==n||!i)&&q.set(r,"olddisplay",i?n:x.css(r,"display"))));for(s=0;a>s;s++)r=e[s],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[s]||"":"none"));return e}x.fn.extend({css:function(e,t){return x.access(this,function(e,t,n){var r,i,o={},s=0;if(x.isArray(t)){for(r=qt(e),i=t.length;i>s;s++)o[t[s]]=x.css(e,t[s],!1,r);return o}return n!==undefined?x.style(e,t,n):x.css(e,t)},e,t,arguments.length>1)},show:function(){return Ht(this,!0)},hide:function(){return Ht(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Lt(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=vt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,s,a=x.camelCase(t),u=e.style;return t=x.cssProps[a]||(x.cssProps[a]=At(u,a)),s=x.cssHooks[t]||x.cssHooks[a],n===undefined?s&&"get"in s&&(i=s.get(e,!1,r))!==undefined?i:u[t]:(o=typeof n,"string"===o&&(i=kt.exec(n))&&(n=(i[1]+1)*i[2]+parseFloat(x.css(e,t)),o="number"),null==n||"number"===o&&isNaN(n)||("number"!==o||x.cssNumber[a]||(n+="px"),x.support.clearCloneStyle||""!==n||0!==t.indexOf("background")||(u[t]="inherit"),s&&"set"in s&&(n=s.set(e,n,r))===undefined||(u[t]=n)),undefined)}},css:function(e,t,n,r){var i,o,s,a=x.camelCase(t);return t=x.cssProps[a]||(x.cssProps[a]=At(e.style,a)),s=x.cssHooks[t]||x.cssHooks[a],s&&"get"in s&&(i=s.get(e,!0,n)),i===undefined&&(i=vt(e,t,r)),"normal"===i&&t in St&&(i=St[t]),""===n||n?(o=parseFloat(i),n===!0||x.isNumeric(o)?o||0:i):i}}),vt=function(e,t,n){var r,i,o,s=n||qt(e),a=s?s.getPropertyValue(t)||s[t]:undefined,u=e.style;return s&&(""!==a||x.contains(e.ownerDocument,e)||(a=x.style(e,t)),Ct.test(a)&&wt.test(t)&&(r=u.width,i=u.minWidth,o=u.maxWidth,u.minWidth=u.maxWidth=u.width=a,a=s.width,u.width=r,u.minWidth=i,u.maxWidth=o)),a};function Ot(e,t,n){var r=Tt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function Ft(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,s=0;for(;4>o;o+=2)"margin"===n&&(s+=x.css(e,n+jt[o],!0,i)),r?("content"===n&&(s-=x.css(e,"padding"+jt[o],!0,i)),"margin"!==n&&(s-=x.css(e,"border"+jt[o]+"Width",!0,i))):(s+=x.css(e,"padding"+jt[o],!0,i),"padding"!==n&&(s+=x.css(e,"border"+jt[o]+"Width",!0,i)));return s}function Pt(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=qt(e),s=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=vt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Ct.test(i))return i;r=s&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+Ft(e,t,n||(s?"border":"content"),r,o)+"px"}function Rt(e){var t=o,n=Nt[e];return n||(n=Mt(e,t),"none"!==n&&n||(xt=(xt||x("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(xt[0].contentWindow||xt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=Mt(e,t),xt.detach()),Nt[e]=n),n}function Mt(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,t){x.cssHooks[t]={get:function(e,n,r){return n?0===e.offsetWidth&&bt.test(x.css(e,"display"))?x.swap(e,Et,function(){return Pt(e,t,r)}):Pt(e,t,r):undefined},set:function(e,n,r){var i=r&&qt(e);return Ot(e,n,r?Ft(e,t,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,t){return t?x.swap(e,{display:"inline-block"},vt,[e,"marginRight"]):undefined}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,t){x.cssHooks[t]={get:function(e,n){return n?(n=vt(e,t),Ct.test(n)?x(e).position()[t]+"px":n):undefined}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+jt[r]+t]=o[r]||o[r-2]||o[0];return i}},wt.test(e)||(x.cssHooks[e+t].set=Ot)});var Wt=/%20/g,$t=/\[\]$/,Bt=/\r?\n/g,It=/^(?:submit|button|image|reset|file)$/i,zt=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&zt.test(this.nodeName)&&!It.test(e)&&(this.checked||!ot.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace(Bt,"\r\n")}}):{name:t.name,value:n.replace(Bt,"\r\n")}}).get()}}),x.param=function(e,t){var n,r=[],i=function(e,t){t=x.isFunction(t)?t():null==t?"":t,r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(t===undefined&&(t=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){i(this.name,this.value)});else for(n in e)_t(n,e[n],t,i);return r.join("&").replace(Wt,"+")};function _t(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||$t.test(e)?r(e,i):_t(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)_t(e+"["+i+"]",t[i],n,r)}x.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t) -},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var Xt,Ut,Yt=x.now(),Vt=/\?/,Gt=/#.*$/,Jt=/([?&])_=[^&]*/,Qt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Kt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Zt=/^(?:GET|HEAD)$/,en=/^\/\//,tn=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,nn=x.fn.load,rn={},on={},sn="*/".concat("*");try{Ut=i.href}catch(an){Ut=o.createElement("a"),Ut.href="",Ut=Ut.href}Xt=tn.exec(Ut.toLowerCase())||[];function un(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(w)||[];if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function ln(e,t,n,r){var i={},o=e===on;function s(a){var u;return i[a]=!0,x.each(e[a]||[],function(e,a){var l=a(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):undefined:(t.dataTypes.unshift(l),s(l),!1)}),u}return s(t.dataTypes[0])||!i["*"]&&s("*")}function cn(e,t){var n,r,i=x.ajaxSettings.flatOptions||{};for(n in t)t[n]!==undefined&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,t,n){if("string"!=typeof e&&nn)return nn.apply(this,arguments);var r,i,o,s=this,a=e.indexOf(" ");return a>=0&&(r=e.slice(a),e=e.slice(0,a)),x.isFunction(t)?(n=t,t=undefined):t&&"object"==typeof t&&(i="POST"),s.length>0&&x.ajax({url:e,type:i,dataType:"html",data:t}).done(function(e){o=arguments,s.html(r?x("<div>").append(x.parseHTML(e)).find(r):e)}).complete(n&&function(e,t){s.each(n,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ut,type:"GET",isLocal:Kt.test(Xt[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":sn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?cn(cn(e,x.ajaxSettings),t):cn(x.ajaxSettings,e)},ajaxPrefilter:un(rn),ajaxTransport:un(on),ajax:function(e,t){"object"==typeof e&&(t=e,e=undefined),t=t||{};var n,r,i,o,s,a,u,l,c=x.ajaxSetup({},t),p=c.context||c,f=c.context&&(p.nodeType||p.jquery)?x(p):x.event,h=x.Deferred(),d=x.Callbacks("once memory"),g=c.statusCode||{},m={},y={},v=0,b="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(2===v){if(!o){o={};while(t=Qt.exec(i))o[t[1].toLowerCase()]=t[2]}t=o[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===v?i:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return v||(e=y[n]=y[n]||e,m[e]=t),this},overrideMimeType:function(e){return v||(c.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>v)for(t in e)g[t]=[g[t],e[t]];else T.always(e[T.status]);return this},abort:function(e){var t=e||b;return n&&n.abort(t),k(0,t),this}};if(h.promise(T).complete=d.add,T.success=T.done,T.error=T.fail,c.url=((e||c.url||Ut)+"").replace(Gt,"").replace(en,Xt[1]+"//"),c.type=t.method||t.type||c.method||c.type,c.dataTypes=x.trim(c.dataType||"*").toLowerCase().match(w)||[""],null==c.crossDomain&&(a=tn.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===Xt[1]&&a[2]===Xt[2]&&(a[3]||("http:"===a[1]?"80":"443"))===(Xt[3]||("http:"===Xt[1]?"80":"443")))),c.data&&c.processData&&"string"!=typeof c.data&&(c.data=x.param(c.data,c.traditional)),ln(rn,c,t,T),2===v)return T;u=c.global,u&&0===x.active++&&x.event.trigger("ajaxStart"),c.type=c.type.toUpperCase(),c.hasContent=!Zt.test(c.type),r=c.url,c.hasContent||(c.data&&(r=c.url+=(Vt.test(r)?"&":"?")+c.data,delete c.data),c.cache===!1&&(c.url=Jt.test(r)?r.replace(Jt,"$1_="+Yt++):r+(Vt.test(r)?"&":"?")+"_="+Yt++)),c.ifModified&&(x.lastModified[r]&&T.setRequestHeader("If-Modified-Since",x.lastModified[r]),x.etag[r]&&T.setRequestHeader("If-None-Match",x.etag[r])),(c.data&&c.hasContent&&c.contentType!==!1||t.contentType)&&T.setRequestHeader("Content-Type",c.contentType),T.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+("*"!==c.dataTypes[0]?", "+sn+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)T.setRequestHeader(l,c.headers[l]);if(c.beforeSend&&(c.beforeSend.call(p,T,c)===!1||2===v))return T.abort();b="abort";for(l in{success:1,error:1,complete:1})T[l](c[l]);if(n=ln(on,c,t,T)){T.readyState=1,u&&f.trigger("ajaxSend",[T,c]),c.async&&c.timeout>0&&(s=setTimeout(function(){T.abort("timeout")},c.timeout));try{v=1,n.send(m,k)}catch(C){if(!(2>v))throw C;k(-1,C)}}else k(-1,"No Transport");function k(e,t,o,a){var l,m,y,b,w,C=t;2!==v&&(v=2,s&&clearTimeout(s),n=undefined,i=a||"",T.readyState=e>0?4:0,l=e>=200&&300>e||304===e,o&&(b=pn(c,T,o)),b=fn(c,b,T,l),l?(c.ifModified&&(w=T.getResponseHeader("Last-Modified"),w&&(x.lastModified[r]=w),w=T.getResponseHeader("etag"),w&&(x.etag[r]=w)),204===e||"HEAD"===c.type?C="nocontent":304===e?C="notmodified":(C=b.state,m=b.data,y=b.error,l=!y)):(y=C,(e||!C)&&(C="error",0>e&&(e=0))),T.status=e,T.statusText=(t||C)+"",l?h.resolveWith(p,[m,C,T]):h.rejectWith(p,[T,C,y]),T.statusCode(g),g=undefined,u&&f.trigger(l?"ajaxSuccess":"ajaxError",[T,c,l?m:y]),d.fireWith(p,[T,C]),u&&(f.trigger("ajaxComplete",[T,c]),--x.active||x.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,t){return x.get(e,undefined,t,"script")}}),x.each(["get","post"],function(e,t){x[t]=function(e,n,r,i){return x.isFunction(n)&&(i=i||r,r=n,n=undefined),x.ajax({url:e,type:t,dataType:i,data:n,success:r})}});function pn(e,t,n){var r,i,o,s,a=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),r===undefined&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in a)if(a[i]&&a[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}s||(s=i)}o=o||s}return o?(o!==u[0]&&u.unshift(o),n[o]):undefined}function fn(e,t,n,r){var i,o,s,a,u,l={},c=e.dataTypes.slice();if(c[1])for(s in e.converters)l[s.toLowerCase()]=e.converters[s];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(s=l[u+" "+o]||l["* "+o],!s)for(i in l)if(a=i.split(" "),a[1]===o&&(s=l[u+" "+a[0]]||l["* "+a[0]])){s===!0?s=l[i]:l[i]!==!0&&(o=a[0],c.unshift(a[1]));break}if(s!==!0)if(s&&e["throws"])t=s(t);else try{t=s(t)}catch(p){return{state:"parsererror",error:s?p:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===undefined&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),x.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(r,i){t=x("<script>").prop({async:!0,charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&i("error"===e.type?404:200,e.type)}),o.head.appendChild(t[0])},abort:function(){n&&n()}}}});var hn=[],dn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=hn.pop()||x.expando+"_"+Yt++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(t,n,r){var i,o,s,a=t.jsonp!==!1&&(dn.test(t.url)?"url":"string"==typeof t.data&&!(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&dn.test(t.data)&&"data");return a||"jsonp"===t.dataTypes[0]?(i=t.jsonpCallback=x.isFunction(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,a?t[a]=t[a].replace(dn,"$1"+i):t.jsonp!==!1&&(t.url+=(Vt.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return s||x.error(i+" was not called"),s[0]},t.dataTypes[0]="json",o=e[i],e[i]=function(){s=arguments},r.always(function(){e[i]=o,t[i]&&(t.jsonpCallback=n.jsonpCallback,hn.push(i)),s&&x.isFunction(o)&&o(s[0]),s=o=undefined}),"script"):undefined}),x.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(e){}};var gn=x.ajaxSettings.xhr(),mn={0:200,1223:204},yn=0,vn={};e.ActiveXObject&&x(e).on("unload",function(){for(var e in vn)vn[e]();vn=undefined}),x.support.cors=!!gn&&"withCredentials"in gn,x.support.ajax=gn=!!gn,x.ajaxTransport(function(e){var t;return x.support.cors||gn&&!e.crossDomain?{send:function(n,r){var i,o,s=e.xhr();if(s.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(i in e.xhrFields)s[i]=e.xhrFields[i];e.mimeType&&s.overrideMimeType&&s.overrideMimeType(e.mimeType),e.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest");for(i in n)s.setRequestHeader(i,n[i]);t=function(e){return function(){t&&(delete vn[o],t=s.onload=s.onerror=null,"abort"===e?s.abort():"error"===e?r(s.status||404,s.statusText):r(mn[s.status]||s.status,s.statusText,"string"==typeof s.responseText?{text:s.responseText}:undefined,s.getAllResponseHeaders()))}},s.onload=t(),s.onerror=t("error"),t=vn[o=yn++]=t("abort"),s.send(e.hasContent&&e.data||null)},abort:function(){t&&t()}}:undefined});var xn,bn,wn=/^(?:toggle|show|hide)$/,Tn=RegExp("^(?:([+-])=|)("+b+")([a-z%]*)$","i"),Cn=/queueHooks$/,kn=[An],Nn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Tn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),s=(x.cssNumber[e]||"px"!==o&&+r)&&Tn.exec(x.css(n.elem,e)),a=1,u=20;if(s&&s[3]!==o){o=o||s[3],i=i||[],s=+r||1;do a=a||".5",s/=a,x.style(n.elem,e,s+o);while(a!==(a=n.cur()/r)&&1!==a&&--u)}return i&&(s=n.start=+s||+r||0,n.unit=o,n.end=i[1]?s+(i[1]+1)*i[2]:+i[2]),n}]};function En(){return setTimeout(function(){xn=undefined}),xn=x.now()}function Sn(e,t,n){var r,i=(Nn[t]||[]).concat(Nn["*"]),o=0,s=i.length;for(;s>o;o++)if(r=i[o].call(n,t,e))return r}function jn(e,t,n){var r,i,o=0,s=kn.length,a=x.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;var t=xn||En(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,s=0,u=l.tweens.length;for(;u>s;s++)l.tweens[s].run(o);return a.notifyWith(e,[l,o,n]),1>o&&u?n:(a.resolveWith(e,[l]),!1)},l=a.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:xn||En(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)l.tweens[n].run(1);return t?a.resolveWith(e,[l,t]):a.rejectWith(e,[l,t]),this}}),c=l.props;for(Dn(c,l.opts.specialEasing);s>o;o++)if(r=kn[o].call(l,e,c,l.opts))return r;return x.map(c,Sn,l),x.isFunction(l.opts.start)&&l.opts.start.call(e,l),x.fx.timer(x.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always)}function Dn(e,t){var n,r,i,o,s;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),s=x.cssHooks[r],s&&"expand"in s){o=s.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(jn,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Nn[n]=Nn[n]||[],Nn[n].unshift(t)},prefilter:function(e,t){t?kn.unshift(e):kn.push(e)}});function An(e,t,n){var r,i,o,s,a,u,l=this,c={},p=e.style,f=e.nodeType&&Lt(e),h=q.get(e,"fxshow");n.queue||(a=x._queueHooks(e,"fx"),null==a.unqueued&&(a.unqueued=0,u=a.empty.fire,a.empty.fire=function(){a.unqueued||u()}),a.unqueued++,l.always(function(){l.always(function(){a.unqueued--,x.queue(e,"fx").length||a.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(p.display="inline-block")),n.overflow&&(p.overflow="hidden",l.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],wn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show")){if("show"!==i||!h||h[r]===undefined)continue;f=!0}c[r]=h&&h[r]||x.style(e,r)}if(!x.isEmptyObject(c)){h?"hidden"in h&&(f=h.hidden):h=q.access(e,"fxshow",{}),o&&(h.hidden=!f),f?x(e).show():l.done(function(){x(e).hide()}),l.done(function(){var t;q.remove(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)s=Sn(f?h[r]:0,r,l),r in h||(h[r]=s.start,f&&(s.end=s.start,s.start="width"===r||"height"===r?1:0))}}function Ln(e,t,n,r,i){return new Ln.prototype.init(e,t,n,r,i)}x.Tween=Ln,Ln.prototype={constructor:Ln,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=Ln.propHooks[this.prop];return e&&e.get?e.get(this):Ln.propHooks._default.get(this)},run:function(e){var t,n=Ln.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Ln.propHooks._default.set(this),this}},Ln.prototype.init.prototype=Ln.prototype,Ln.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Ln.propHooks.scrollTop=Ln.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(qn(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Lt).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),s=function(){var t=jn(this,x.extend({},e),o);(i||q.get(this,"finish"))&&t.stop(!0)};return s.finish=s,i||o.queue===!1?this.each(s):this.queue(o.queue,s)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=undefined),t&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=x.timers,s=q.get(this);if(i)s[i]&&s[i].stop&&r(s[i]);else for(i in s)s[i]&&s[i].stop&&Cn.test(i)&&r(s[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));(t||!n)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=q.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,s=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;s>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function qn(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=jt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:qn("show"),slideUp:qn("hide"),slideToggle:qn("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=Ln.prototype.init,x.fx.tick=function(){var e,t=x.timers,n=0;for(xn=x.now();t.length>n;n++)e=t[n],e()||t[n]!==e||t.splice(n--,1);t.length||x.fx.stop(),xn=undefined},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){bn||(bn=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(bn),bn=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===undefined?this:this.each(function(t){x.offset.setOffset(this,e,t)});var t,n,i=this[0],o={top:0,left:0},s=i&&i.ownerDocument;if(s)return t=s.documentElement,x.contains(t,i)?(typeof i.getBoundingClientRect!==r&&(o=i.getBoundingClientRect()),n=Hn(s),{top:o.top+n.pageYOffset-t.clientTop,left:o.left+n.pageXOffset-t.clientLeft}):o},x.offset={setOffset:function(e,t,n){var r,i,o,s,a,u,l,c=x.css(e,"position"),p=x(e),f={};"static"===c&&(e.style.position="relative"),a=p.offset(),o=x.css(e,"top"),u=x.css(e,"left"),l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1,l?(r=p.position(),s=r.top,i=r.left):(s=parseFloat(o)||0,i=parseFloat(u)||0),x.isFunction(t)&&(t=t.call(e,n,a)),null!=t.top&&(f.top=t.top-a.top+s),null!=t.left&&(f.left=t.left-a.left+i),"using"in t?t.using.call(e,f):p.css(f)}},x.fn.extend({position:function(){if(this[0]){var e,t,n=this[0],r={top:0,left:0};return"fixed"===x.css(n,"position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(r=e.offset()),r.top+=x.css(e[0],"borderTopWidth",!0),r.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-r.top-x.css(n,"marginTop",!0),left:t.left-r.left-x.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,n){var r="pageYOffset"===n;x.fn[t]=function(i){return x.access(this,function(t,i,o){var s=Hn(t);return o===undefined?s?s[n]:t[i]:(s?s.scrollTo(r?e.pageXOffset:o,r?o:e.pageYOffset):t[i]=o,undefined)},t,i,arguments.length,null)}});function Hn(e){return x.isWindow(e)?e:9===e.nodeType&&e.defaultView}x.each({Height:"height",Width:"width"},function(e,t){x.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){x.fn[r]=function(r,i){var o=arguments.length&&(n||"boolean"!=typeof r),s=n||(r===!0||i===!0?"margin":"border");return x.access(this,function(t,n,r){var i;return x.isWindow(t)?t.document.documentElement["client"+e]:9===t.nodeType?(i=t.documentElement,Math.max(t.body["scroll"+e],i["scroll"+e],t.body["offset"+e],i["offset"+e],i["client"+e])):r===undefined?x.css(t,n,s):x.style(t,n,r,s)},t,o?r:undefined,o,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}),"object"==typeof e&&"object"==typeof e.document&&(e.jQuery=e.$=x)})(window); diff --git a/src/librustdoc/html/static/jquery-2.1.0.min.js b/src/librustdoc/html/static/jquery-2.1.0.min.js new file mode 100644 index 00000000000..cbe6abe59a8 --- /dev/null +++ b/src/librustdoc/html/static/jquery-2.1.0.min.js @@ -0,0 +1,4 @@ +/*! jQuery v2.1.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m=a.document,n="2.1.0",o=function(a,b){return new o.fn.init(a,b)},p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};o.fn=o.prototype={jquery:n,constructor:o,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=o.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return o.each(this,a,b)},map:function(a){return this.pushStack(o.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},o.extend=o.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||o.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(o.isPlainObject(d)||(e=o.isArray(d)))?(e?(e=!1,f=c&&o.isArray(c)?c:[]):f=c&&o.isPlainObject(c)?c:{},g[b]=o.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},o.extend({expando:"jQuery"+(n+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===o.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isPlainObject:function(a){if("object"!==o.type(a)||a.nodeType||o.isWindow(a))return!1;try{if(a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=o.trim(a),a&&(1===a.indexOf("use strict")?(b=m.createElement("script"),b.text=a,m.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":k.call(a)},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?o.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),o.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||o.guid++,f):void 0},now:Date.now,support:l}),o.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=o.type(a);return"function"===c||o.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="<select t=''><option selected=''></option></select>",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=jb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=kb(b);function nb(){}nb.prototype=d.filters=d.pseudos,d.setFilters=new nb;function ob(a,b){var c,e,f,g,h,i,j,k=x[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=Q.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=R.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(P," ")}),h=h.slice(c.length));for(g in d.filter)!(e=V[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?db.error(a):x(a,i).slice(0)}function pb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);o.find=t,o.expr=t.selectors,o.expr[":"]=o.expr.pseudos,o.unique=t.uniqueSort,o.text=t.getText,o.isXMLDoc=t.isXML,o.contains=t.contains;var u=o.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(o.isFunction(b))return o.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return o.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return o.filter(b,a,c);b=o.filter(b,a)}return o.grep(a,function(a){return g.call(b,a)>=0!==c})}o.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?o.find.matchesSelector(d,a)?[d]:[]:o.find.matches(a,o.grep(b,function(a){return 1===a.nodeType}))},o.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(o(a).filter(function(){for(b=0;c>b;b++)if(o.contains(e[b],this))return!0}));for(b=0;c>b;b++)o.find(a,e[b],d);return d=this.pushStack(c>1?o.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?o(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=o.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof o?b[0]:b,o.merge(this,o.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:m,!0)),v.test(c[1])&&o.isPlainObject(b))for(c in b)o.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=m.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=m,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):o.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(o):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),o.makeArray(a,this))};A.prototype=o.fn,y=o(m);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};o.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&o(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),o.fn.extend({has:function(a){var b=o(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(o.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?o(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&o.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?o.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(o(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(o.unique(o.merge(this.get(),o(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}o.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return o.dir(a,"parentNode")},parentsUntil:function(a,b,c){return o.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return o.dir(a,"nextSibling")},prevAll:function(a){return o.dir(a,"previousSibling")},nextUntil:function(a,b,c){return o.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return o.dir(a,"previousSibling",c)},siblings:function(a){return o.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return o.sibling(a.firstChild)},contents:function(a){return a.contentDocument||o.merge([],a.childNodes)}},function(a,b){o.fn[a]=function(c,d){var e=o.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=o.filter(d,e)),this.length>1&&(C[a]||o.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return o.each(a.match(E)||[],function(a,c){b[c]=!0}),b}o.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):o.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){o.each(b,function(b,c){var d=o.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&o.each(arguments,function(a,b){var c;while((c=o.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?o.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},o.extend({Deferred:function(a){var b=[["resolve","done",o.Callbacks("once memory"),"resolved"],["reject","fail",o.Callbacks("once memory"),"rejected"],["notify","progress",o.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return o.Deferred(function(c){o.each(b,function(b,f){var g=o.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&o.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?o.extend(a,d):d}},e={};return d.pipe=d.then,o.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&o.isFunction(a.promise)?e:0,g=1===f?a:o.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&o.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;o.fn.ready=function(a){return o.ready.promise().done(a),this},o.extend({isReady:!1,readyWait:1,holdReady:function(a){a?o.readyWait++:o.ready(!0)},ready:function(a){(a===!0?--o.readyWait:o.isReady)||(o.isReady=!0,a!==!0&&--o.readyWait>0||(H.resolveWith(m,[o]),o.fn.trigger&&o(m).trigger("ready").off("ready")))}});function I(){m.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),o.ready()}o.ready.promise=function(b){return H||(H=o.Deferred(),"complete"===m.readyState?setTimeout(o.ready):(m.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},o.ready.promise();var J=o.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===o.type(c)){e=!0;for(h in c)o.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,o.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(o(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};o.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=o.expando+Math.random()}K.uid=1,K.accepts=o.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,o.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(o.isEmptyObject(f))o.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,o.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{o.isArray(b)?d=b.concat(b.map(o.camelCase)):(e=o.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!o.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?o.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}o.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),o.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length; +while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=o.camelCase(d.slice(5)),P(f,d,e[d]));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=o.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),o.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||o.isArray(c)?d=L.access(a,b,o.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=o.queue(a,b),d=c.length,e=c.shift(),f=o._queueHooks(a,b),g=function(){o.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:o.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),o.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?o.queue(this[0],a):void 0===b?this:this.each(function(){var c=o.queue(this,a,b);o._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&o.dequeue(this,a)})},dequeue:function(a){return this.each(function(){o.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=o.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===o.css(a,"display")||!o.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=m.createDocumentFragment(),b=a.appendChild(m.createElement("div"));b.innerHTML="<input type='radio' checked='checked' name='t'/>",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";l.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return m.activeElement}catch(a){}}o.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=o.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof o!==U&&o.event.triggered!==b.type?o.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n&&(l=o.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=o.event.special[n]||{},k=o.extend({type:n,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&o.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(n,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),o.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n){l=o.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||o.removeEvent(a,n,r.handle),delete i[n])}else for(n in i)o.event.remove(a,n+b[j],c,d,!0);o.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,p=[d||m],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||m,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+o.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[o.expando]?b:new o.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:o.makeArray(c,[b]),n=o.event.special[q]||{},e||!n.trigger||n.trigger.apply(d,c)!==!1)){if(!e&&!n.noBubble&&!o.isWindow(d)){for(i=n.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||m)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:n.bindType||q,l=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),l&&l.apply(g,c),l=k&&g[k],l&&l.apply&&o.acceptData(g)&&(b.result=l.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||n._default&&n._default.apply(p.pop(),c)!==!1||!o.acceptData(d)||k&&o.isFunction(d[q])&&!o.isWindow(d)&&(h=d[k],h&&(d[k]=null),o.event.triggered=q,d[q](),o.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=o.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=o.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=o.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((o.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?o(e,this).index(i)>=0:o.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||m,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[o.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new o.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=m),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&o.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return o.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=o.extend(new o.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?o.event.trigger(e,null,b):o.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},o.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},o.Event=function(a,b){return this instanceof o.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.getPreventDefault&&a.getPreventDefault()?Z:$):this.type=a,b&&o.extend(this,b),this.timeStamp=a&&a.timeStamp||o.now(),void(this[o.expando]=!0)):new o.Event(a,b)},o.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z,this.stopPropagation()}},o.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){o.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!o.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),l.focusinBubbles||o.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){o.event.simulate(b,a.target,o.event.fix(a),!0)};o.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),o.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return o().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=o.guid++)),this.each(function(){o.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,o(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){o.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){o.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?o.event.trigger(a,b,c,!0):void 0}});var ab=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ib={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return o.nodeName(a,"table")&&o.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)o.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=o.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&o.nodeName(a,b)?o.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}o.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=o.contains(a.ownerDocument,a);if(!(l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||o.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,n=a.length;n>m;m++)if(e=a[m],e||0===e)if("object"===o.type(e))o.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;o.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===o.inArray(e,d))&&(i=o.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f,g,h=o.event.special,i=0;void 0!==(c=a[i]);i++){if(o.acceptData(c)&&(f=c[L.expando],f&&(b=L.cache[f]))){if(d=Object.keys(b.events||{}),d.length)for(g=0;void 0!==(e=d[g]);g++)h[e]?o.event.remove(c,e):o.removeEvent(c,e,b.handle);L.cache[f]&&delete L.cache[f]}delete M.cache[c[M.expando]]}}}),o.fn.extend({text:function(a){return J(this,function(a){return void 0===a?o.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?o.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||o.cleanData(ob(c)),c.parentNode&&(b&&o.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(o.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return o.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(o.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,o.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,n=k-1,p=a[0],q=o.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(c=o.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=o.map(ob(c,"script"),kb),g=f.length;k>j;j++)h=c,j!==n&&(h=o.clone(h,!0,!0),g&&o.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,o.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&o.contains(i,h)&&(h.src?o._evalUrl&&o._evalUrl(h.src):o.globalEval(h.textContent.replace(hb,"")))}return this}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){o.fn[a]=function(a){for(var c,d=[],e=o(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),o(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d=o(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:o.css(d[0],"display");return d.detach(),e}function tb(a){var b=m,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||o("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||o.contains(a.ownerDocument,a)||(g=o.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d="padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",e=m.documentElement,f=m.createElement("div"),g=m.createElement("div");g.style.backgroundClip="content-box",g.cloneNode(!0).style.backgroundClip="",l.clearCloneStyle="content-box"===g.style.backgroundClip,f.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",f.appendChild(g);function h(){g.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%",e.appendChild(f);var d=a.getComputedStyle(g,null);b="1%"!==d.top,c="4px"===d.width,e.removeChild(f)}a.getComputedStyle&&o.extend(l,{pixelPosition:function(){return h(),b},boxSizingReliable:function(){return null==c&&h(),c},reliableMarginRight:function(){var b,c=g.appendChild(m.createElement("div"));return c.style.cssText=g.style.cssText=d,c.style.marginRight=c.style.width="0",g.style.width="1px",e.appendChild(f),b=!parseFloat(a.getComputedStyle(c,null).marginRight),e.removeChild(f),g.innerHTML="",b}})}(),o.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:0,fontWeight:400},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=o.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=o.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=o.css(a,"border"+R[f]+"Width",!0,e))):(g+=o.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=o.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===o.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(l.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):f[g]||(e=S(d),(c&&"none"!==c||!e)&&L.set(d,"olddisplay",e?c:o.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}o.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=o.camelCase(b),i=a.style;return b=o.cssProps[h]||(o.cssProps[h]=Fb(i,h)),g=o.cssHooks[b]||o.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(o.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||o.cssNumber[h]||(c+="px"),l.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]="",i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=o.camelCase(b);return b=o.cssProps[h]||(o.cssProps[h]=Fb(a.style,h)),g=o.cssHooks[b]||o.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||o.isNumeric(f)?f||0:e):e}}),o.each(["height","width"],function(a,b){o.cssHooks[b]={get:function(a,c,d){return c?0===a.offsetWidth&&zb.test(o.css(a,"display"))?o.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===o.css(a,"boxSizing",!1,e),e):0)}}}),o.cssHooks.marginRight=yb(l.reliableMarginRight,function(a,b){return b?o.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),o.each({margin:"",padding:"",border:"Width"},function(a,b){o.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(o.cssHooks[a+b].set=Gb)}),o.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(o.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=o.css(a,b[g],!1,d);return f}return void 0!==c?o.style(a,b,c):o.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?o(this).show():o(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}o.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(o.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?o.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=o.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){o.fx.step[a.prop]?o.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[o.cssProps[a.prop]]||o.cssHooks[a.prop])?o.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},o.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},o.fx=Kb.prototype.init,o.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(o.cssNumber[a]?"":"px"),g=(o.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(o.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,o.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=o.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k=this,l={},m=a.style,n=a.nodeType&&S(a),p=L.get(a,"fxshow");c.queue||(h=o._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,k.always(function(){k.always(function(){h.unqueued--,o.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],j=o.css(a,"display"),"none"===j&&(j=tb(a.nodeName)),"inline"===j&&"none"===o.css(a,"float")&&(m.display="inline-block")),c.overflow&&(m.overflow="hidden",k.always(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(n?"hide":"show")){if("show"!==e||!p||void 0===p[d])continue;n=!0}l[d]=p&&p[d]||o.style(a,d)}if(!o.isEmptyObject(l)){p?"hidden"in p&&(n=p.hidden):p=L.access(a,"fxshow",{}),f&&(p.hidden=!n),n?o(a).show():k.done(function(){o(a).hide()}),k.done(function(){var b;L.remove(a,"fxshow");for(b in l)o.style(a,b,l[b])});for(d in l)g=Ub(n?p[d]:0,d,k),d in p||(p[d]=g.start,n&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=o.camelCase(c),e=b[d],f=a[c],o.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=o.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=o.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:o.extend({},b),opts:o.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=o.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return o.map(k,Ub,j),o.isFunction(j.opts.start)&&j.opts.start.call(a,j),o.fx.timer(o.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}o.Animation=o.extend(Xb,{tweener:function(a,b){o.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),o.speed=function(a,b,c){var d=a&&"object"==typeof a?o.extend({},a):{complete:c||!c&&b||o.isFunction(a)&&a,duration:a,easing:c&&b||b&&!o.isFunction(b)&&b};return d.duration=o.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in o.fx.speeds?o.fx.speeds[d.duration]:o.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){o.isFunction(d.old)&&d.old.call(this),d.queue&&o.dequeue(this,d.queue)},d},o.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=o.isEmptyObject(a),f=o.speed(b,c,d),g=function(){var b=Xb(this,o.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=o.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&o.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=o.timers,g=d?d.length:0;for(c.finish=!0,o.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),o.each(["toggle","show","hide"],function(a,b){var c=o.fn[b];o.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),o.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){o.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),o.timers=[],o.fx.tick=function(){var a,b=0,c=o.timers;for(Lb=o.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||o.fx.stop(),Lb=void 0},o.fx.timer=function(a){o.timers.push(a),a()?o.fx.start():o.timers.pop()},o.fx.interval=13,o.fx.start=function(){Mb||(Mb=setInterval(o.fx.tick,o.fx.interval))},o.fx.stop=function(){clearInterval(Mb),Mb=null},o.fx.speeds={slow:600,fast:200,_default:400},o.fn.delay=function(a,b){return a=o.fx?o.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=m.createElement("input"),b=m.createElement("select"),c=b.appendChild(m.createElement("option"));a.type="checkbox",l.checkOn=""!==a.value,l.optSelected=c.selected,b.disabled=!0,l.optDisabled=!c.disabled,a=m.createElement("input"),a.value="t",a.type="radio",l.radioValue="t"===a.value}();var Yb,Zb,$b=o.expr.attrHandle;o.fn.extend({attr:function(a,b){return J(this,o.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){o.removeAttr(this,a)})}}),o.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?o.prop(a,b,c):(1===f&&o.isXMLDoc(a)||(b=b.toLowerCase(),d=o.attrHooks[b]||(o.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=o.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void o.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=o.propFix[c]||c,o.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!l.radioValue&&"radio"===b&&o.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?o.removeAttr(a,c):a.setAttribute(c,c),c}},o.each(o.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||o.find.attr;$b[b]=function(a,b,d){var e,f; +return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;o.fn.extend({prop:function(a,b){return J(this,o.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[o.propFix[a]||a]})}}),o.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!o.isXMLDoc(a),f&&(b=o.propFix[b]||b,e=o.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),l.optSelected||(o.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;o.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=o.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?o.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(o.isFunction(a)?function(c){o(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=o(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;o.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=o.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,o(this).val()):a,null==e?e="":"number"==typeof e?e+="":o.isArray(e)&&(e=o.map(e,function(a){return null==a?"":a+""})),b=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=o.valHooks[e.type]||o.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),o.extend({valHooks:{select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(l.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&o.nodeName(c.parentNode,"optgroup"))){if(b=o(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=o.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=o.inArray(o(d).val(),f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),o.each(["radio","checkbox"],function(){o.valHooks[this]={set:function(a,b){return o.isArray(b)?a.checked=o.inArray(o(a).val(),b)>=0:void 0}},l.checkOn||(o.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),o.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){o.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),o.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=o.now(),dc=/\?/;o.parseJSON=function(a){return JSON.parse(a+"")},o.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&o.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=m.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(o.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,o.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=o.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&o.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":o.parseJSON,"text xml":o.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,o.ajaxSettings),b):tc(o.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=o.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?o(l):o.event,n=o.Deferred(),p=o.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(n.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=o.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=o.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===o.active++&&o.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(o.lastModified[d]&&v.setRequestHeader("If-Modified-Since",o.lastModified[d]),o.etag[d]&&v.setRequestHeader("If-None-Match",o.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(o.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(o.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?n.resolveWith(l,[r,x,v]):n.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--o.active||o.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return o.get(a,b,c,"json")},getScript:function(a,b){return o.get(a,void 0,b,"script")}}),o.each(["get","post"],function(a,b){o[b]=function(a,c,d,e){return o.isFunction(c)&&(e=e||d,d=c,c=void 0),o.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),o.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){o.fn[b]=function(a){return this.on(b,a)}}),o._evalUrl=function(a){return o.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},o.fn.extend({wrapAll:function(a){var b;return o.isFunction(a)?this.each(function(b){o(this).wrapAll(a.call(this,b))}):(this[0]&&(b=o(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(o.isFunction(a)?function(b){o(this).wrapInner(a.call(this,b))}:function(){var b=o(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=o.isFunction(a);return this.each(function(c){o(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){o.nodeName(this,"body")||o(this).replaceWith(this.childNodes)}).end()}}),o.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},o.expr.filters.visible=function(a){return!o.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(o.isArray(b))o.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==o.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}o.param=function(a,b){var c,d=[],e=function(a,b){b=o.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=o.ajaxSettings&&o.ajaxSettings.traditional),o.isArray(a)||a.jquery&&!o.isPlainObject(a))o.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},o.fn.extend({serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=o.prop(this,"elements");return a?o.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!o(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=o(this).val();return null==c?null:o.isArray(c)?o.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),o.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=o.ajaxSettings.xhr();a.ActiveXObject&&o(a).on("unload",function(){for(var a in Dc)Dc[a]()}),l.cors=!!Fc&&"withCredentials"in Fc,l.ajax=Fc=!!Fc,o.ajaxTransport(function(a){var b;return l.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort"),f.send(a.hasContent&&a.data||null)},abort:function(){b&&b()}}:void 0}),o.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return o.globalEval(a),a}}}),o.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),o.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=o("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),m.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Gc=[],Hc=/(=)\?(?=&|$)|\?\?/;o.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Gc.pop()||o.expando+"_"+cc++;return this[a]=!0,a}}),o.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Hc.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Hc.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=o.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Hc,"$1"+e):b.jsonp!==!1&&(b.url+=(dc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||o.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Gc.push(e)),g&&o.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),o.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||m;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=o.buildFragment([a],b,e),e&&e.length&&o(e).remove(),o.merge([],d.childNodes))};var Ic=o.fn.load;o.fn.load=function(a,b,c){if("string"!=typeof a&&Ic)return Ic.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=a.slice(h),a=a.slice(0,h)),o.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&o.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?o("<div>").append(o.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},o.expr.filters.animated=function(a){return o.grep(o.timers,function(b){return a===b.elem}).length};var Jc=a.document.documentElement;function Kc(a){return o.isWindow(a)?a:9===a.nodeType&&a.defaultView}o.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=o.css(a,"position"),l=o(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=o.css(a,"top"),i=o.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),o.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},o.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){o.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,o.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Kc(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===o.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),o.nodeName(a[0],"html")||(d=a.offset()),d.top+=o.css(a[0],"borderTopWidth",!0),d.left+=o.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-o.css(c,"marginTop",!0),left:b.left-d.left-o.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Jc;while(a&&!o.nodeName(a,"html")&&"static"===o.css(a,"position"))a=a.offsetParent;return a||Jc})}}),o.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;o.fn[b]=function(e){return J(this,function(b,e,f){var g=Kc(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),o.each(["top","left"],function(a,b){o.cssHooks[b]=yb(l.pixelPosition,function(a,c){return c?(c=xb(a,b),vb.test(c)?o(a).position()[b]+"px":c):void 0})}),o.each({Height:"height",Width:"width"},function(a,b){o.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){o.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return o.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?o.css(b,c,g):o.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),o.fn.size=function(){return this.length},o.fn.andSelf=o.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return o});var Lc=a.jQuery,Mc=a.$;return o.noConflict=function(b){return a.$===o&&(a.$=Mc),b&&a.jQuery===o&&(a.jQuery=Lc),o},typeof b===U&&(a.jQuery=a.$=o),o}); diff --git a/src/librustdoc/html/static/normalize.css b/src/librustdoc/html/static/normalize.css index fd2854ab60f..0c9fafbb61a 100644 --- a/src/librustdoc/html/static/normalize.css +++ b/src/librustdoc/html/static/normalize.css @@ -1 +1 @@ -/*! normalize.css v2.1.2 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{font-size:2em;margin:.67em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}mark{background:#ff0;color:#000}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0} \ No newline at end of file +/*! normalize.css v3.0.0 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} \ No newline at end of file diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 7256e8923fa..3dbf4726ae4 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -20,13 +20,13 @@ extern mod rustc; extern mod extra; extern mod serialize; extern mod sync; +extern mod getopts; +extern mod collections; use std::local_data; use std::io; use std::io::{File, MemWriter}; use std::str; -use extra::getopts; -use extra::getopts::groups; use extra::json; use serialize::{Decodable, Encodable}; use extra::time; @@ -80,8 +80,8 @@ pub fn main() { std::os::set_exit_status(main_args(std::os::args())); } -pub fn opts() -> ~[groups::OptGroup] { - use extra::getopts::groups::*; +pub fn opts() -> ~[getopts::OptGroup] { + use getopts::*; ~[ optflag("h", "help", "show this help message"), optflag("", "version", "print rustdoc's version"), @@ -107,11 +107,11 @@ pub fn opts() -> ~[groups::OptGroup] { } pub fn usage(argv0: &str) { - println!("{}", groups::usage(format!("{} [options] <input>", argv0), opts())); + println!("{}", getopts::usage(format!("{} [options] <input>", argv0), opts())); } pub fn main_args(args: &[~str]) -> int { - let matches = match groups::getopts(args.tail(), opts()) { + let matches = match getopts::getopts(args.tail(), opts()) { Ok(m) => m, Err(err) => { println!("{}", err.to_err_msg()); @@ -327,7 +327,7 @@ fn json_output(crate: clean::Crate, res: ~[plugins::PluginJson], // "crate": { parsed crate ... }, // "plugins": { output of plugins ... } // } - let mut json = ~extra::treemap::TreeMap::new(); + let mut json = ~collections::TreeMap::new(); json.insert(~"schema", json::String(SCHEMA_VERSION.to_owned())); let plugins_json = ~res.move_iter().filter_map(|opt| opt).collect(); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 9e3b217f69f..58c89d6aa4a 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -16,11 +16,12 @@ use std::run; use std::str; use extra::tempfile::TempDir; -use extra::getopts; use extra::test; +use rustc::back::link; use rustc::driver::driver; use rustc::driver::session; use rustc::metadata::creader::Loader; +use getopts; use syntax::diagnostic; use syntax::parse; @@ -33,7 +34,7 @@ use passes; use visit_ast::RustdocVisitor; pub fn run(input: &str, matches: &getopts::Matches) -> int { - let parsesess = parse::new_parse_sess(None); + let parsesess = parse::new_parse_sess(); let input_path = Path::new(input); let input = driver::FileInput(input_path.clone()); let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice())); @@ -43,25 +44,24 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int { binary: ~"rustdoc", maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()), addl_lib_search_paths: libs, - outputs: ~[session::OutputDylib], + crate_types: ~[session::CrateTypeDylib], .. (*session::basic_options()).clone() }; - let diagnostic_handler = diagnostic::mk_handler(None); + let diagnostic_handler = diagnostic::mk_handler(); let span_diagnostic_handler = diagnostic::mk_span_handler(diagnostic_handler, parsesess.cm); let sess = driver::build_session_(sessopts, Some(input_path), parsesess.cm, - @diagnostic::DefaultEmitter, span_diagnostic_handler); let cfg = driver::build_configuration(sess); - let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input); + let crate = driver::phase_1_parse_input(sess, cfg, &input); let loader = &mut Loader::new(sess); - let (crate, _) = driver::phase_2_configure_and_expand(sess, cfg, loader, crate); + let (crate, _) = driver::phase_2_configure_and_expand(sess, loader, crate); let ctx = @core::DocContext { crate: crate, @@ -97,26 +97,26 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int { fn runtest(test: &str, cratename: &str, libs: HashSet<Path>) { let test = maketest(test, cratename); - let parsesess = parse::new_parse_sess(None); + let parsesess = parse::new_parse_sess(); let input = driver::StrInput(test); let sessopts = @session::Options { binary: ~"rustdoctest", maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()), addl_lib_search_paths: @RefCell::new(libs), - outputs: ~[session::OutputExecutable], + crate_types: ~[session::CrateTypeExecutable], debugging_opts: session::PREFER_DYNAMIC, + output_types: ~[link::OutputTypeExe], .. (*session::basic_options()).clone() }; - let diagnostic_handler = diagnostic::mk_handler(None); + let diagnostic_handler = diagnostic::mk_handler(); let span_diagnostic_handler = diagnostic::mk_span_handler(diagnostic_handler, parsesess.cm); let sess = driver::build_session_(sessopts, None, parsesess.cm, - @diagnostic::DefaultEmitter, span_diagnostic_handler); let outdir = TempDir::new("rustdoctest").expect("rustdoc needs a tempdir"); diff --git a/src/libsemver/lib.rs b/src/libsemver/lib.rs index 01feb1c8c0d..6c794e031ab 100644 --- a/src/libsemver/lib.rs +++ b/src/libsemver/lib.rs @@ -35,6 +35,8 @@ use std::char; use std::cmp; +use std::fmt; +use std::fmt::Show; use std::option::{Option, Some, None}; use std::to_str::ToStr; @@ -59,13 +61,20 @@ impl cmp::Ord for Identifier { } } +impl fmt::Show for Identifier { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Numeric(ref n) => n.fmt(f), + AlphaNumeric(ref s) => s.fmt(f) + } + } +} + impl ToStr for Identifier { #[inline] fn to_str(&self) -> ~str { - match self { - &Numeric(n) => n.to_str(), - &AlphaNumeric(ref s) => s.to_str() - } + format!("{}", *self) } } @@ -74,33 +83,45 @@ impl ToStr for Identifier { #[deriving(Clone, Eq)] pub struct Version { /// The major version, to be incremented on incompatible changes. - priv major: uint, + major: uint, /// The minor version, to be incremented when functionality is added in a /// backwards-compatible manner. - priv minor: uint, + minor: uint, /// The patch version, to be incremented when backwards-compatible bug /// fixes are made. - priv patch: uint, + patch: uint, /// The pre-release version identifier, if one exists. - priv pre: ~[Identifier], + pre: ~[Identifier], /// The build metadata, ignored when determining version precedence. - priv build: ~[Identifier], + build: ~[Identifier], +} + +impl fmt::Show for Version { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if_ok!(write!(f.buf, "{}.{}.{}", self.major, self.minor, self.patch)) + if !self.pre.is_empty() { + if_ok!(write!(f.buf, "-")); + for (i, x) in self.pre.iter().enumerate() { + if i != 0 { if_ok!(write!(f.buf, ".")) }; + if_ok!(x.fmt(f)); + } + } + if !self.build.is_empty() { + if_ok!(write!(f.buf, "+")); + for (i, x) in self.build.iter().enumerate() { + if i != 0 { if_ok!(write!(f.buf, ".")) }; + if_ok!(x.fmt(f)); + } + } + Ok(()) + } } impl ToStr for Version { #[inline] fn to_str(&self) -> ~str { - let s = format!("{}.{}.{}", self.major, self.minor, self.patch); - let s = if self.pre.is_empty() { - s - } else { - format!("{}-{}", s, self.pre.map(|i| i.to_str()).connect(".")) - }; - if self.build.is_empty() { - s - } else { - format!("{}+{}", s, self.build.map(|i| i.to_str()).connect(".")) - } + format!("{}", *self) } } @@ -131,19 +152,6 @@ impl cmp::Ord for Version { (_, _) => self.pre < other.pre })) } - - #[inline] - fn le(&self, other: &Version) -> bool { - ! (other < self) - } - #[inline] - fn gt(&self, other: &Version) -> bool { - other < self - } - #[inline] - fn ge(&self, other: &Version) -> bool { - ! (self < other) - } } fn take_nonempty_prefix<T:Iterator<char>>(rdr: &mut T, pred: |char| -> bool) @@ -366,6 +374,22 @@ fn test_ne() { } #[test] +fn test_show() { + assert_eq!(format!("{}", parse("1.2.3").unwrap()), ~"1.2.3"); + assert_eq!(format!("{}", parse("1.2.3-alpha1").unwrap()), ~"1.2.3-alpha1"); + assert_eq!(format!("{}", parse("1.2.3+build.42").unwrap()), ~"1.2.3+build.42"); + assert_eq!(format!("{}", parse("1.2.3-alpha1+42").unwrap()), ~"1.2.3-alpha1+42"); +} + +#[test] +fn test_to_str() { + assert_eq!(parse("1.2.3").unwrap().to_str(), ~"1.2.3"); + assert_eq!(parse("1.2.3-alpha1").unwrap().to_str(), ~"1.2.3-alpha1"); + assert_eq!(parse("1.2.3+build.42").unwrap().to_str(), ~"1.2.3+build.42"); + assert_eq!(parse("1.2.3-alpha1+42").unwrap().to_str(), ~"1.2.3-alpha1+42"); +} + +#[test] fn test_lt() { assert!(parse("0.0.0") < parse("1.2.3-alpha2")); assert!(parse("1.0.0") < parse("1.2.3-alpha2")); diff --git a/src/libstd/any.rs b/src/libstd/any.rs index 72ccf6be023..4433bd9096f 100644 --- a/src/libstd/any.rs +++ b/src/libstd/any.rs @@ -177,15 +177,6 @@ mod tests { assert_eq!(b.as_void_ptr(), b_r.as_void_ptr()); assert_eq!(c.as_void_ptr(), c_r.as_void_ptr()); - let (a, b, c) = (@5u as @Any, @TEST as @Any, @Test as @Any); - let a_r: &Any = a; - let b_r: &Any = b; - let c_r: &Any = c; - - assert_eq!(a.as_void_ptr(), a_r.as_void_ptr()); - assert_eq!(b.as_void_ptr(), b_r.as_void_ptr()); - assert_eq!(c.as_void_ptr(), c_r.as_void_ptr()); - let (a, b, c) = (&5u as &Any, &TEST as &Any, &Test as &Any); let a_r: &Any = a; let b_r: &Any = b; @@ -304,23 +295,6 @@ mod tests { } #[test] - fn any_managed() { - let (a, b, c) = (@5u as @Any, @TEST as @Any, @Test as @Any); - - assert!(a.is::<uint>()); - assert!(!b.is::<uint>()); - assert!(!c.is::<uint>()); - - assert!(!a.is::<&'static str>()); - assert!(b.is::<&'static str>()); - assert!(!c.is::<&'static str>()); - - assert!(!a.is::<Test>()); - assert!(!b.is::<Test>()); - assert!(c.is::<Test>()); - } - - #[test] fn any_as_ref() { let a = &5u as &Any; diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 83aec9d0aa6..7965127007c 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -10,7 +10,7 @@ //! Operations on ASCII strings and characters -use to_str::{ToStr,IntoStr}; +use to_str::{ToStr, IntoStr}; use str; use str::Str; use str::StrSlice; diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index 7e79ad97df0..fdef7e36bd5 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -75,24 +75,11 @@ use ptr::RawPtr; use ptr; use str::StrSlice; use str; -use vec::{CloneableVector, ImmutableVector, MutableVector}; +use vec::{ImmutableVector, MutableVector}; use vec; use unstable::intrinsics; use rt::global_heap::malloc_raw; -/// Resolution options for the `null_byte` condition -pub enum NullByteResolution { - /// Truncate at the null byte - Truncate, - /// Use a replacement byte - ReplaceWith(libc::c_char) -} - -condition! { - // This should be &[u8] but there's a lifetime issue (#5370). - pub null_byte: (~[u8]) -> NullByteResolution; -} - /// The representation of a C String. /// /// This structure wraps a `*libc::c_char`, and will automatically free the @@ -252,7 +239,7 @@ pub trait ToCStr { /// /// # Failure /// - /// Raises the `null_byte` condition if the receiver has an interior null. + /// Fails the task if the receiver has an interior null. fn to_c_str(&self) -> CString; /// Unsafe variant of `to_c_str()` that doesn't check for nulls. @@ -273,7 +260,7 @@ pub trait ToCStr { /// /// # Failure /// - /// Raises the `null_byte` condition if the receiver has an interior null. + /// Fails the task if the receiver has an interior null. #[inline] fn with_c_str<T>(&self, f: |*libc::c_char| -> T) -> T { self.to_c_str().with_ref(f) @@ -362,12 +349,7 @@ fn check_for_null(v: &[u8], buf: *mut libc::c_char) { for i in range(0, v.len()) { unsafe { let p = buf.offset(i as int); - if *p == 0 { - match null_byte::cond.raise(v.to_owned()) { - Truncate => break, - ReplaceWith(c) => *p = c - } - } + assert!(*p != 0); } } } @@ -541,29 +523,8 @@ mod tests { #[test] fn test_to_c_str_fail() { - use c_str::null_byte::cond; - - let mut error_happened = false; - cond.trap(|err| { - assert_eq!(err, bytes!("he", 0, "llo").to_owned()) - error_happened = true; - Truncate - }).inside(|| "he\x00llo".to_c_str()); - assert!(error_happened); - - cond.trap(|_| { - ReplaceWith('?' as libc::c_char) - }).inside(|| "he\x00llo".to_c_str()).with_ref(|buf| { - unsafe { - assert_eq!(*buf.offset(0), 'h' as libc::c_char); - assert_eq!(*buf.offset(1), 'e' as libc::c_char); - assert_eq!(*buf.offset(2), '?' as libc::c_char); - assert_eq!(*buf.offset(3), 'l' as libc::c_char); - assert_eq!(*buf.offset(4), 'l' as libc::c_char); - assert_eq!(*buf.offset(5), 'o' as libc::c_char); - assert_eq!(*buf.offset(6), 0); - } - }) + use task; + assert!(task::try(proc() { "he\x00llo".to_c_str() }).is_err()); } #[test] diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index e19b8ae712f..0a3c87f4058 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -10,7 +10,10 @@ //! Types dealing with dynamic mutability -use prelude::*; +use clone::{Clone, DeepClone}; +use cmp::Eq; +use ops::Drop; +use option::{None, Option, Some}; use cast; use kinds::{marker, Pod}; diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs index 82c1ed7440c..a43dca94970 100644 --- a/src/libstd/cleanup.rs +++ b/src/libstd/cleanup.rs @@ -11,11 +11,8 @@ #[doc(hidden)]; use ptr; -use unstable::intrinsics::TyDesc; use unstable::raw; -type DropGlue<'a> = 'a |**TyDesc, *u8|; - static RC_IMMORTAL : uint = 0x77777777; /* @@ -24,11 +21,6 @@ static RC_IMMORTAL : uint = 0x77777777; * This runs at task death to free all boxes. */ -struct AnnihilateStats { - n_total_boxes: uint, - n_bytes_freed: uint -} - unsafe fn each_live_alloc(read_next_before: bool, f: |alloc: *mut raw::Box<()>| -> bool) -> bool { @@ -65,21 +57,18 @@ fn debug_mem() -> bool { } /// Destroys all managed memory (i.e. @ boxes) held by the current task. +#[cfg(stage0)] pub unsafe fn annihilate() { use rt::local_heap::local_free; - use mem; - let mut stats = AnnihilateStats { - n_total_boxes: 0, - n_bytes_freed: 0 - }; + let mut n_total_boxes = 0u; // Pass 1: Make all boxes immortal. // // In this pass, nothing gets freed, so it does not matter whether // we read the next field before or after the callback. each_live_alloc(true, |alloc| { - stats.n_total_boxes += 1; + n_total_boxes += 1; (*alloc).ref_count = RC_IMMORTAL; true }); @@ -103,18 +92,58 @@ pub unsafe fn annihilate() { // left), so we must read the `next` field before, since it will // not be valid after. each_live_alloc(true, |alloc| { - stats.n_bytes_freed += - (*((*alloc).type_desc)).size - + mem::size_of::<raw::Box<()>>(); local_free(alloc as *u8); true }); if debug_mem() { // We do logging here w/o allocation. - debug!("annihilator stats:\n \ - total boxes: {}\n \ - bytes freed: {}", - stats.n_total_boxes, stats.n_bytes_freed); + debug!("total boxes annihilated: {}", n_total_boxes); + } +} + +/// Destroys all managed memory (i.e. @ boxes) held by the current task. +#[cfg(not(stage0))] +pub unsafe fn annihilate() { + use rt::local_heap::local_free; + + let mut n_total_boxes = 0u; + + // Pass 1: Make all boxes immortal. + // + // In this pass, nothing gets freed, so it does not matter whether + // we read the next field before or after the callback. + each_live_alloc(true, |alloc| { + n_total_boxes += 1; + (*alloc).ref_count = RC_IMMORTAL; + true + }); + + // Pass 2: Drop all boxes. + // + // In this pass, unique-managed boxes may get freed, but not + // managed boxes, so we must read the `next` field *after* the + // callback, as the original value may have been freed. + each_live_alloc(false, |alloc| { + let drop_glue = (*alloc).drop_glue; + let data = &mut (*alloc).data as *mut (); + drop_glue(data as *mut u8); + true + }); + + // Pass 3: Free all boxes. + // + // In this pass, managed boxes may get freed (but not + // unique-managed boxes, though I think that none of those are + // left), so we must read the `next` field before, since it will + // not be valid after. + each_live_alloc(true, |alloc| { + local_free(alloc as *u8); + true + }); + + if debug_mem() { + // We do logging here w/o allocation. + debug!("total boxes annihilated: {}", n_total_boxes); } } diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs deleted file mode 100644 index e0dc5c8b65d..00000000000 --- a/src/libstd/condition.rs +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright 2012 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. - -/*! - -Condition handling - -Conditions are a utility used to deal with handling error conditions. The syntax -of a condition handler strikes a resemblance to try/catch blocks in other -languages, but condition handlers are *not* a form of exception handling in the -same manner. - -A condition is declared through the `condition!` macro provided by the compiler: - -```rust -condition! { - pub my_error: int -> ~str; -} -# fn main() {} -``` - -This macro declares an inner module called `my_error` with one static variable, -`cond` that is a static `Condition` instance. To help understand what the other -parameters are used for, an example usage of this condition would be: - -```rust -# condition! { pub my_error: int -> ~str; } -# fn main() { - -my_error::cond.trap(|raised_int| { - - // the condition `my_error` was raised on, and the value it raised is stored - // in `raised_int`. This closure must return a `~str` type (as specified in - // the declaration of the condition - if raised_int == 3 { ~"three" } else { ~"oh well" } - -}).inside(|| { - - // The condition handler above is installed for the duration of this block. - // That handler will override any previous handler, but the previous handler - // is restored when this block returns (handlers nest) - // - // If any code from this block (or code from another block) raises on the - // condition, then the above handler will be invoked (so long as there's no - // other nested handler). - - println!("{}", my_error::cond.raise(3)); // prints "three" - println!("{}", my_error::cond.raise(4)); // prints "oh well" - -}) - -# } - ``` - -Condition handling is useful in cases where propagating errors is either to -cumbersome or just not necessary in the first place. It should also be noted, -though, that if there is not handler installed when a condition is raised, then -the task invokes `fail!()` and will terminate. - -## More Info - -Condition handlers as an error strategy is well explained in the [conditions -tutorial](http://static.rust-lang.org/doc/master/tutorial-conditions.html), -along with comparing and contrasting it with other error handling strategies. - -*/ - -use local_data; -use prelude::*; -use unstable::raw::Closure; - -#[doc(hidden)] -pub struct Handler<T, U> { - priv handle: Closure, - priv prev: Option<@Handler<T, U>>, -} - -/// This struct represents the state of a condition handler. It contains a key -/// into TLS which holds the currently install handler, along with the name of -/// the condition (useful for debugging). -/// -/// This struct should never be created directly, but rather only through the -/// `condition!` macro provided to all libraries using `std`. -pub struct Condition<T, U> { - /// Name of the condition handler - name: &'static str, - /// TLS key used to insert/remove values in TLS. - key: local_data::Key<@Handler<T, U>> -} - -impl<T, U> Condition<T, U> { - /// Creates an object which binds the specified handler. This will also save - /// the current handler *on creation* such that when the `Trap` is consumed, - /// it knows which handler to restore. - /// - /// # Example - /// - /// ```rust - /// condition! { my_error: int -> int; } - /// - /// # fn main() { - /// let trap = my_error::cond.trap(|error| error + 3); - /// - /// // use `trap`'s inside method to register the handler and then run a - /// // block of code with the handler registered - /// # } - /// ``` - pub fn trap<'a>(&'a self, h: 'a |T| -> U) -> Trap<'a, T, U> { - let h: Closure = unsafe { ::cast::transmute(h) }; - let prev = local_data::get(self.key, |k| k.map(|x| *x)); - let h = @Handler { handle: h, prev: prev }; - Trap { cond: self, handler: h } - } - - /// Raises on this condition, invoking any handler if one has been - /// registered, or failing the current task otherwise. - /// - /// While a condition handler is being run, the condition will have no - /// handler listed, so a task failure will occur if the condition is - /// re-raised during the handler. - /// - /// # Arguments - /// - /// * t - The argument to pass along to the condition handler. - /// - /// # Return value - /// - /// If a handler is found, its return value is returned, otherwise this - /// function will not return. - pub fn raise(&self, t: T) -> U { - let msg = format!("Unhandled condition: {}: {:?}", self.name, t); - self.raise_default(t, || fail!("{}", msg.clone())) - } - - /// Performs the same functionality as `raise`, except that when no handler - /// is found the `default` argument is called instead of failing the task. - pub fn raise_default(&self, t: T, default: || -> U) -> U { - match local_data::pop(self.key) { - None => { - debug!("Condition.raise: found no handler"); - default() - } - Some(handler) => { - debug!("Condition.raise: found handler"); - match handler.prev { - None => {} - Some(hp) => local_data::set(self.key, hp) - } - let handle : |T| -> U = unsafe { - ::cast::transmute(handler.handle) - }; - let u = handle(t); - local_data::set(self.key, handler); - u - } - } - } -} - -/// A `Trap` is created when the `trap` method is invoked on a `Condition`, and -/// it is used to actually bind a handler into the TLS slot reserved for this -/// condition. -/// -/// Normally this object is not dealt with directly, but rather it's directly -/// used after being returned from `trap` -pub struct Trap<'a, T, U> { - priv cond: &'a Condition<T, U>, - priv handler: @Handler<T, U> -} - -impl<'a, T, U> Trap<'a, T, U> { - /// Execute a block of code with this trap handler's exception handler - /// registered. - /// - /// # Example - /// - /// ```rust - /// condition! { my_error: int -> int; } - /// - /// # fn main() { - /// let result = my_error::cond.trap(|error| error + 3).inside(|| { - /// my_error::cond.raise(4) - /// }); - /// assert_eq!(result, 7); - /// # } - /// ``` - pub fn inside<V>(&self, inner: 'a || -> V) -> V { - let _g = Guard { cond: self.cond }; - debug!("Trap: pushing handler to TLS"); - local_data::set(self.cond.key, self.handler); - inner() - } - - /// Returns a guard that will automatically reset the condition upon - /// exit of the scope. This is useful if you want to use conditions with - /// an RAII pattern. - pub fn guard(&self) -> Guard<'a,T,U> { - let guard = Guard { - cond: self.cond - }; - debug!("Guard: pushing handler to TLS"); - local_data::set(self.cond.key, self.handler); - guard - } -} - -/// A guard that will automatically reset the condition handler upon exit of -/// the scope. This is useful if you want to use conditions with an RAII -/// pattern. -pub struct Guard<'a, T, U> { - priv cond: &'a Condition<T, U> -} - -#[unsafe_destructor] -impl<'a, T, U> Drop for Guard<'a, T, U> { - fn drop(&mut self) { - debug!("Guard: popping handler from TLS"); - let curr = local_data::pop(self.cond.key); - match curr { - None => {} - Some(h) => match h.prev { - None => {} - Some(hp) => local_data::set(self.cond.key, hp) - } - } - } -} - -#[cfg(test)] -mod test { - condition! { - sadness: int -> int; - } - - fn trouble(i: int) { - debug!("trouble: raising condition"); - let j = sadness::cond.raise(i); - debug!("trouble: handler recovered with {}", j); - } - - fn nested_trap_test_inner() { - let mut inner_trapped = false; - - sadness::cond.trap(|_j| { - debug!("nested_trap_test_inner: in handler"); - inner_trapped = true; - 0 - }).inside(|| { - debug!("nested_trap_test_inner: in protected block"); - trouble(1); - }); - - assert!(inner_trapped); - } - - #[test] - fn nested_trap_test_outer() { - let mut outer_trapped = false; - - sadness::cond.trap(|_j| { - debug!("nested_trap_test_outer: in handler"); - outer_trapped = true; 0 - }).inside(|| { - debug!("nested_guard_test_outer: in protected block"); - nested_trap_test_inner(); - trouble(1); - }); - - assert!(outer_trapped); - } - - fn nested_reraise_trap_test_inner() { - let mut inner_trapped = false; - - sadness::cond.trap(|_j| { - debug!("nested_reraise_trap_test_inner: in handler"); - inner_trapped = true; - let i = 10; - debug!("nested_reraise_trap_test_inner: handler re-raising"); - sadness::cond.raise(i) - }).inside(|| { - debug!("nested_reraise_trap_test_inner: in protected block"); - trouble(1); - }); - - assert!(inner_trapped); - } - - #[test] - fn nested_reraise_trap_test_outer() { - let mut outer_trapped = false; - - sadness::cond.trap(|_j| { - debug!("nested_reraise_trap_test_outer: in handler"); - outer_trapped = true; 0 - }).inside(|| { - debug!("nested_reraise_trap_test_outer: in protected block"); - nested_reraise_trap_test_inner(); - }); - - assert!(outer_trapped); - } - - #[test] - fn test_default() { - let mut trapped = false; - - sadness::cond.trap(|j| { - debug!("test_default: in handler"); - sadness::cond.raise_default(j, || { trapped=true; 5 }) - }).inside(|| { - debug!("test_default: in protected block"); - trouble(1); - }); - - assert!(trapped); - } - - // Issue #6009 - mod m { - condition! { - // #6009, #8215: should this truly need a `pub` for access from n? - pub sadness: int -> int; - } - - mod n { - use super::sadness; - - #[test] - fn test_conditions_are_public() { - let mut trapped = false; - sadness::cond.trap(|_| { - trapped = true; - 0 - }).inside(|| { - sadness::cond.raise(0); - }); - assert!(trapped); - } - } - } -} diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 40ad1fb250a..d2e9fe040f7 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -166,11 +166,11 @@ method of the signature: # mod fmt { pub type Result = (); } # struct T; # trait SomeName<T> { -fn fmt(value: &T, f: &mut std::fmt::Formatter) -> fmt::Result; +fn fmt(&self, f: &mut std::fmt::Formatter) -> fmt::Result; # } ``` -Your type will be passed by-reference in `value`, and then the function should +Your type will be passed as `self` by-reference, and then the function should emit output into the `f.buf` stream. It is up to each format trait implementation to correctly adhere to the requested formatting parameters. The values of these parameters will be listed in the fields of the `Formatter` @@ -195,19 +195,19 @@ struct Vector2D { } impl fmt::Show for Vector2D { - fn fmt(obj: &Vector2D, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // The `f.buf` value is of the type `&mut io::Writer`, which is what th // write! macro is expecting. Note that this formatting ignores the // various flags provided to format strings. - write!(f.buf, "({}, {})", obj.x, obj.y) + write!(f.buf, "({}, {})", self.x, self.y) } } // Different traits allow different forms of output of a type. The meaning of // this format is to print the magnitude of a vector. impl fmt::Binary for Vector2D { - fn fmt(obj: &Vector2D, f: &mut fmt::Formatter) -> fmt::Result { - let magnitude = (obj.x * obj.x + obj.y * obj.y) as f64; + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let magnitude = (self.x * self.x + self.y * self.y) as f64; let magnitude = magnitude.sqrt(); // Respect the formatting flags by using the helper method @@ -558,50 +558,50 @@ pub struct Arguments<'a> { /// to this trait. There is not an explicit way of selecting this trait to be /// used for formatting, it is only if no other format is specified. #[allow(missing_doc)] -pub trait Show { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Show { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `b` character #[allow(missing_doc)] -pub trait Bool { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Bool { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `c` character #[allow(missing_doc)] -pub trait Char { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Char { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `i` and `d` characters #[allow(missing_doc)] -pub trait Signed { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Signed { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `u` character #[allow(missing_doc)] -pub trait Unsigned { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Unsigned { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `o` character #[allow(missing_doc)] -pub trait Octal { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Octal { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `b` character #[allow(missing_doc)] -pub trait Binary { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Binary { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `x` character #[allow(missing_doc)] -pub trait LowerHex { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait LowerHex { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `X` character #[allow(missing_doc)] -pub trait UpperHex { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait UpperHex { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `s` character #[allow(missing_doc)] -pub trait String { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait String { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `?` character #[allow(missing_doc)] -pub trait Poly { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Poly { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `p` character #[allow(missing_doc)] -pub trait Pointer { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Pointer { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `f` character #[allow(missing_doc)] -pub trait Float { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait Float { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `e` character #[allow(missing_doc)] -pub trait LowerExp { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait LowerExp { fn fmt(&self, &mut Formatter) -> Result; } /// Format trait for the `E` character #[allow(missing_doc)] -pub trait UpperExp { fn fmt(&Self, &mut Formatter) -> Result; } +pub trait UpperExp { fn fmt(&self, &mut Formatter) -> Result; } // FIXME #11938 - UFCS would make us able call the above methods // directly Show::show(x, fmt). @@ -615,7 +615,7 @@ macro_rules! uniform_fn_call_workaround { $( #[doc(hidden)] pub fn $name<T: $trait_>(x: &T, fmt: &mut Formatter) -> Result { - $trait_::fmt(x, fmt) + x.fmt(fmt) } )* } @@ -1042,44 +1042,44 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result, /// (such as for select), then it invokes this method. #[doc(hidden)] #[inline] pub fn argumentstr<'a>(s: &'a &str) -> Argument<'a> { - argument(String::fmt, s) + argument(secret_string, s) } /// When the compiler determines that the type of an argument *must* be a uint /// (such as for plural), then it invokes this method. #[doc(hidden)] #[inline] pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> { - argument(Unsigned::fmt, s) + argument(secret_unsigned, s) } // Implementations of the core formatting traits impl Bool for bool { - fn fmt(b: &bool, f: &mut Formatter) -> Result { - String::fmt(&(if *b {"true"} else {"false"}), f) + fn fmt(&self, f: &mut Formatter) -> Result { + secret_string(&(if *self {"true"} else {"false"}), f) } } impl<'a, T: str::Str> String for T { - fn fmt(s: &T, f: &mut Formatter) -> Result { - f.pad(s.as_slice()) + fn fmt(&self, f: &mut Formatter) -> Result { + f.pad(self.as_slice()) } } impl Char for char { - fn fmt(c: &char, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter) -> Result { let mut utf8 = [0u8, ..4]; - let amt = c.encode_utf8(utf8); + let amt = self.encode_utf8(utf8); let s: &str = unsafe { cast::transmute(utf8.slice_to(amt)) }; - String::fmt(&s, f) + secret_string(&s, f) } } macro_rules! int_base(($ty:ident, $into:ident, $base:expr, $name:ident, $prefix:expr) => { impl $name for $ty { - fn fmt(c: &$ty, f: &mut Formatter) -> Result { - ::$into::to_str_bytes(*c as $into, $base, |buf| { + fn fmt(&self, f: &mut Formatter) -> Result { + ::$into::to_str_bytes(*self as $into, $base, |buf| { f.pad_integral(buf, $prefix, true) }) } @@ -1087,8 +1087,8 @@ macro_rules! int_base(($ty:ident, $into:ident, $base:expr, }) macro_rules! upper_hex(($ty:ident, $into:ident) => { impl UpperHex for $ty { - fn fmt(c: &$ty, f: &mut Formatter) -> Result { - ::$into::to_str_bytes(*c as $into, 16, |buf| { + fn fmt(&self, f: &mut Formatter) -> Result { + ::$into::to_str_bytes(*self as $into, 16, |buf| { upperhex(buf, f) }) } @@ -1112,9 +1112,9 @@ macro_rules! integer(($signed:ident, $unsigned:ident) => { // Signed is special because it actuall emits the negative sign, // nothing else should do that, however. impl Signed for $signed { - fn fmt(c: &$signed, f: &mut Formatter) -> Result { - ::$unsigned::to_str_bytes(c.abs() as $unsigned, 10, |buf| { - f.pad_integral(buf, "", *c >= 0) + fn fmt(&self, f: &mut Formatter) -> Result { + ::$unsigned::to_str_bytes(self.abs() as $unsigned, 10, |buf| { + f.pad_integral(buf, "", *self >= 0) }) } } @@ -1138,35 +1138,35 @@ integer!(i64, u64) macro_rules! floating(($ty:ident) => { impl Float for $ty { - fn fmt(f: &$ty, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter) -> Result { // FIXME: this shouldn't perform an allocation let s = match fmt.precision { - Some(i) => ::$ty::to_str_exact(f.abs(), i), - None => ::$ty::to_str_digits(f.abs(), 6) + Some(i) => ::$ty::to_str_exact(self.abs(), i), + None => ::$ty::to_str_digits(self.abs(), 6) }; - fmt.pad_integral(s.as_bytes(), "", *f >= 0.0) + fmt.pad_integral(s.as_bytes(), "", *self >= 0.0) } } impl LowerExp for $ty { - fn fmt(f: &$ty, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter) -> Result { // FIXME: this shouldn't perform an allocation let s = match fmt.precision { - Some(i) => ::$ty::to_str_exp_exact(f.abs(), i, false), - None => ::$ty::to_str_exp_digits(f.abs(), 6, false) + Some(i) => ::$ty::to_str_exp_exact(self.abs(), i, false), + None => ::$ty::to_str_exp_digits(self.abs(), 6, false) }; - fmt.pad_integral(s.as_bytes(), "", *f >= 0.0) + fmt.pad_integral(s.as_bytes(), "", *self >= 0.0) } } impl UpperExp for $ty { - fn fmt(f: &$ty, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter) -> Result { // FIXME: this shouldn't perform an allocation let s = match fmt.precision { - Some(i) => ::$ty::to_str_exp_exact(f.abs(), i, true), - None => ::$ty::to_str_exp_digits(f.abs(), 6, true) + Some(i) => ::$ty::to_str_exp_exact(self.abs(), i, true), + None => ::$ty::to_str_exp_digits(self.abs(), 6, true) }; - fmt.pad_integral(s.as_bytes(), "", *f >= 0.0) + fmt.pad_integral(s.as_bytes(), "", *self >= 0.0) } } }) @@ -1174,16 +1174,16 @@ floating!(f32) floating!(f64) impl<T> Poly for T { - fn fmt(t: &T, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter) -> Result { match (f.width, f.precision) { (None, None) => { - repr::write_repr(f.buf, t) + repr::write_repr(f.buf, self) } // If we have a specified width for formatting, then we have to make // this allocation of a new string _ => { - let s = repr::repr_to_str(t); + let s = repr::repr_to_str(self); f.pad(s) } } @@ -1191,16 +1191,16 @@ impl<T> Poly for T { } impl<T> Pointer for *T { - fn fmt(t: &*T, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter) -> Result { f.flags |= 1 << (parse::FlagAlternate as uint); - ::uint::to_str_bytes(*t as uint, 16, |buf| { + ::uint::to_str_bytes(*self as uint, 16, |buf| { f.pad_integral(buf, "0x", true) }) } } impl<T> Pointer for *mut T { - fn fmt(t: &*mut T, f: &mut Formatter) -> Result { - Pointer::fmt(&(*t as *T), f) + fn fmt(&self, f: &mut Formatter) -> Result { + secret_pointer(&(*self as *T), f) } } @@ -1208,33 +1208,33 @@ impl<T> Pointer for *mut T { macro_rules! delegate(($ty:ty to $other:ident) => { impl<'a> Show for $ty { - fn fmt(me: &$ty, f: &mut Formatter) -> Result { - $other::fmt(me, f) + fn fmt(&self, f: &mut Formatter) -> Result { + (concat_idents!(secret_, $other)(self, f)) } } }) -delegate!(int to Signed) -delegate!( i8 to Signed) -delegate!(i16 to Signed) -delegate!(i32 to Signed) -delegate!(i64 to Signed) -delegate!(uint to Unsigned) -delegate!( u8 to Unsigned) -delegate!( u16 to Unsigned) -delegate!( u32 to Unsigned) -delegate!( u64 to Unsigned) -delegate!(~str to String) -delegate!(&'a str to String) -delegate!(bool to Bool) -delegate!(char to Char) -delegate!(f32 to Float) -delegate!(f64 to Float) +delegate!(int to signed) +delegate!( i8 to signed) +delegate!(i16 to signed) +delegate!(i32 to signed) +delegate!(i64 to signed) +delegate!(uint to unsigned) +delegate!( u8 to unsigned) +delegate!( u16 to unsigned) +delegate!( u32 to unsigned) +delegate!( u64 to unsigned) +delegate!(~str to string) +delegate!(&'a str to string) +delegate!(bool to bool) +delegate!(char to char) +delegate!(f32 to float) +delegate!(f64 to float) impl<T> Show for *T { - fn fmt(me: &*T, f: &mut Formatter) -> Result { Pointer::fmt(me, f) } + fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) } } impl<T> Show for *mut T { - fn fmt(me: &*mut T, f: &mut Formatter) -> Result { Pointer::fmt(me, f) } + fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) } } // If you expected tests to be here, look instead at the run-pass/ifmt.rs test, diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs index 6c08eae7474..555fe29bed0 100644 --- a/src/libstd/fmt/parse.rs +++ b/src/libstd/fmt/parse.rs @@ -19,8 +19,6 @@ use prelude::*; use char; use str; -condition! { pub parse_error: ~str -> (); } - /// A piece is a portion of the format string which represents the next part to /// emit. These are emitted as a stream by the `Parser` class. #[deriving(Eq)] @@ -170,6 +168,8 @@ pub struct Parser<'a> { priv input: &'a str, priv cur: str::CharOffsets<'a>, priv depth: uint, + /// Error messages accumulated during parsing + errors: ~[~str], } impl<'a> Iterator<Piece<'a>> for Parser<'a> { @@ -207,14 +207,15 @@ impl<'a> Parser<'a> { input: s, cur: s.char_indices(), depth: 0, + errors: ~[], } } /// Notifies of an error. The message doesn't actually need to be of type /// ~str, but I think it does when this eventually uses conditions so it /// might as well start using it now. - fn err(&self, msg: &str) { - parse_error::cond.raise("invalid format string: " + msg); + fn err(&mut self, msg: &str) { + self.errors.push(msg.to_owned()); } /// Optionally consumes the specified character. If the character is not at @@ -671,7 +672,9 @@ mod tests { } fn musterr(s: &str) { - Parser::new(s).next(); + let mut p = Parser::new(s); + p.next(); + assert!(p.errors.len() != 0); } #[test] @@ -684,12 +687,12 @@ mod tests { same("\\}", ~[String("}")]); } - #[test] #[should_fail] fn invalid01() { musterr("{") } - #[test] #[should_fail] fn invalid02() { musterr("\\") } - #[test] #[should_fail] fn invalid03() { musterr("\\a") } - #[test] #[should_fail] fn invalid04() { musterr("{3a}") } - #[test] #[should_fail] fn invalid05() { musterr("{:|}") } - #[test] #[should_fail] fn invalid06() { musterr("{:>>>}") } + #[test] fn invalid01() { musterr("{") } + #[test] fn invalid02() { musterr("\\") } + #[test] fn invalid03() { musterr("\\a") } + #[test] fn invalid04() { musterr("{3a}") } + #[test] fn invalid05() { musterr("{:|}") } + #[test] fn invalid06() { musterr("{:>>>}") } #[test] fn format_nothing() { @@ -916,36 +919,16 @@ mod tests { })]); } - #[test] #[should_fail] fn badselect01() { - musterr("{select, }") - } - #[test] #[should_fail] fn badselect02() { - musterr("{1, select}") - } - #[test] #[should_fail] fn badselect03() { - musterr("{1, select, }") - } - #[test] #[should_fail] fn badselect04() { - musterr("{1, select, a {}}") - } - #[test] #[should_fail] fn badselect05() { - musterr("{1, select, other }}") - } - #[test] #[should_fail] fn badselect06() { - musterr("{1, select, other {}") - } - #[test] #[should_fail] fn badselect07() { - musterr("{select, other {}") - } - #[test] #[should_fail] fn badselect08() { - musterr("{1 select, other {}") - } - #[test] #[should_fail] fn badselect09() { - musterr("{:d select, other {}") - } - #[test] #[should_fail] fn badselect10() { - musterr("{1:d select, other {}") - } + #[test] fn badselect01() { musterr("{select, }") } + #[test] fn badselect02() { musterr("{1, select}") } + #[test] fn badselect03() { musterr("{1, select, }") } + #[test] fn badselect04() { musterr("{1, select, a {}}") } + #[test] fn badselect05() { musterr("{1, select, other }}") } + #[test] fn badselect06() { musterr("{1, select, other {}") } + #[test] fn badselect07() { musterr("{select, other {}") } + #[test] fn badselect08() { musterr("{1 select, other {}") } + #[test] fn badselect09() { musterr("{:d select, other {}") } + #[test] fn badselect10() { musterr("{1:d select, other {}") } #[test] fn plural_simple() { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 7690c88478f..4d28143c75a 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -364,9 +364,9 @@ pub struct IoError { } impl fmt::Show for IoError { - fn fmt(err: &IoError, fmt: &mut fmt::Formatter) -> fmt::Result { - if_ok!(fmt.buf.write_str(err.desc)); - match err.detail { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + if_ok!(fmt.buf.write_str(self.desc)); + match self.detail { Some(ref s) => write!(fmt.buf, " ({})", *s), None => Ok(()) } diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 3c02f563847..ae99101e179 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -335,17 +335,18 @@ mod test { let sock2 = UdpSocket::bind(addr2).unwrap(); let (p, c) = SharedChan::new(); + let (serv_port, serv_chan) = Chan::new(); spawn(proc() { let mut sock2 = sock2; let mut buf = [0, 1]; - for _ in p.iter() { - match sock2.recvfrom(buf) { - Ok(..) => {} - Err(e) => fail!("failed receive: {}", e), - } + p.recv(); + match sock2.recvfrom(buf) { + Ok(..) => {} + Err(e) => fail!("failed receive: {}", e), } + serv_chan.send(()); }); let sock3 = sock1.clone(); @@ -355,16 +356,18 @@ mod test { spawn(proc() { let mut sock3 = sock3; match sock3.sendto([1], addr2) { - Ok(..) => c2.send(()), + Ok(..) => { let _ = c2.try_send(()); } Err(..) => {} } done.send(()); }); match sock1.sendto([2], addr2) { - Ok(..) => c.send(()), + Ok(..) => { let _ = c.try_send(()); } Err(..) => {} } + drop(c); p.recv(); + serv_port.recv(); }) } diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index ccf3d4582de..b515cd9d31c 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -93,8 +93,8 @@ pub enum ProcessExit { impl fmt::Show for ProcessExit { /// Format a ProcessExit enum, to nicely present the information. - fn fmt(obj: &ProcessExit, f: &mut fmt::Formatter) -> fmt::Result { - match *obj { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { ExitStatus(code) => write!(f.buf, "exit code: {}", code), ExitSignal(code) => write!(f.buf, "signal: {}", code), } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index adce11fed2d..7b574d68e78 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -117,7 +117,6 @@ pub mod vec_ng; pub mod str; pub mod ascii; -pub mod send_str; pub mod ptr; pub mod owned; @@ -178,8 +177,6 @@ pub mod run; pub mod cast; pub mod fmt; pub mod cleanup; -#[deprecated] -pub mod condition; pub mod logging; pub mod util; pub mod mem; @@ -216,7 +213,6 @@ mod std { pub use clone; pub use cmp; pub use comm; - pub use condition; pub use fmt; pub use io; pub use kinds; diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 719cf2450c5..8e6643f0413 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -41,7 +41,9 @@ local_data::get(key_vector, |opt| assert_eq!(*opt.unwrap(), ~[4])); // magic. use cast; -use prelude::*; +use option::{None, Option, Some}; +use vec::{ImmutableVector, MutableVector, OwnedVector}; +use iter::{Iterator}; use rt::task::{Task, LocalStorage}; use util::replace; diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index b31ae92d742..be1fdc4594d 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -20,23 +20,33 @@ macro_rules! log( } }) ) + #[macro_export] -macro_rules! error( ($($arg:tt)*) => (log!(1u32, $($arg)*)) ) +macro_rules! error( + ($($arg:tt)*) => (log!(1u32, $($arg)*)) +) + #[macro_export] -macro_rules! warn ( ($($arg:tt)*) => (log!(2u32, $($arg)*)) ) +macro_rules! warn( + ($($arg:tt)*) => (log!(2u32, $($arg)*)) +) + #[macro_export] -macro_rules! info ( ($($arg:tt)*) => (log!(3u32, $($arg)*)) ) +macro_rules! info( + ($($arg:tt)*) => (log!(3u32, $($arg)*)) +) + #[macro_export] -macro_rules! debug( ($($arg:tt)*) => ( - if cfg!(not(ndebug)) { log!(4u32, $($arg)*) } -)) +macro_rules! debug( + ($($arg:tt)*) => (if cfg!(not(ndebug)) { log!(4u32, $($arg)*) }) +) #[macro_export] macro_rules! log_enabled( - ($lvl:expr) => ( { + ($lvl:expr) => ({ let lvl = $lvl; lvl <= __log_level() && (lvl != 4 || cfg!(not(ndebug))) - } ) + }) ) #[macro_export] @@ -47,54 +57,50 @@ macro_rules! fail( ($msg:expr) => ( ::std::rt::begin_unwind($msg, file!(), line!()) ); - ($fmt:expr, $($arg:tt)*) => ( - { - // a closure can't have return type !, so we need a full - // function to pass to format_args!, *and* we need the - // file and line numbers right here; so an inner bare fn - // is our only choice. - #[inline] - fn run_fmt(fmt: &::std::fmt::Arguments) -> ! { - ::std::rt::begin_unwind_fmt(fmt, file!(), line!()) - } - format_args!(run_fmt, $fmt, $($arg)*) + ($fmt:expr, $($arg:tt)*) => ({ + // a closure can't have return type !, so we need a full + // function to pass to format_args!, *and* we need the + // file and line numbers right here; so an inner bare fn + // is our only choice. + #[inline] + fn run_fmt(fmt: &::std::fmt::Arguments) -> ! { + ::std::rt::begin_unwind_fmt(fmt, file!(), line!()) } - ) + format_args!(run_fmt, $fmt, $($arg)*) + }); ) #[macro_export] macro_rules! assert( - ($cond:expr) => { + ($cond:expr) => ( if !$cond { fail!("assertion failed: {:s}", stringify!($cond)) } - }; - ($cond:expr, $msg:expr) => { + ); + ($cond:expr, $msg:expr) => ( if !$cond { fail!($msg) } - }; - ($cond:expr, $( $arg:expr ),+) => { + ); + ($cond:expr, $($arg:expr),+) => ( if !$cond { - fail!( $($arg),+ ) + fail!($($arg),+) } - } + ); ) #[macro_export] -macro_rules! assert_eq ( - ($given:expr , $expected:expr) => ( - { - let given_val = &($given); - let expected_val = &($expected); - // check both directions of equality.... - if !((*given_val == *expected_val) && - (*expected_val == *given_val)) { - fail!("assertion failed: `(left == right) && (right == left)` \ - (left: `{:?}`, right: `{:?}`)", *given_val, *expected_val) - } +macro_rules! assert_eq( + ($given:expr , $expected:expr) => ({ + let given_val = &($given); + let expected_val = &($expected); + // check both directions of equality.... + if !((*given_val == *expected_val) && + (*expected_val == *given_val)) { + fail!("assertion failed: `(left == right) && (right == left)` \ + (left: `{:?}`, right: `{:?}`)", *given_val, *expected_val) } - ) + }) ) /// A utility macro for indicating unreachable code. It will fail if @@ -103,7 +109,7 @@ macro_rules! assert_eq ( /// /// # Example /// -/// ```rust +/// ~~~rust /// fn choose_weighted_item(v: &[Item]) -> Item { /// assert!(!v.is_empty()); /// let mut so_far = 0u; @@ -117,88 +123,61 @@ macro_rules! assert_eq ( /// // type checker that it isn't possible to get down here /// unreachable!(); /// } -/// ``` +/// ~~~ #[macro_export] -macro_rules! unreachable (() => ( - fail!("internal error: entered unreachable code"); -)) +macro_rules! unreachable( + () => (fail!("internal error: entered unreachable code")) +) +/// A standardised placeholder for marking unfinished code. It fails with the +/// message `"not yet implemented"` when executed. #[macro_export] -macro_rules! condition ( - - { pub $c:ident: $input:ty -> $out:ty; } => { - - pub mod $c { - #[allow(unused_imports)]; - #[allow(non_uppercase_statics)]; - #[allow(missing_doc)]; - - use super::*; - - local_data_key!(key: @::std::condition::Handler<$input, $out>) - - pub static cond : - ::std::condition::Condition<$input,$out> = - ::std::condition::Condition { - name: stringify!($c), - key: key - }; - } - }; - - { $c:ident: $input:ty -> $out:ty; } => { - - mod $c { - #[allow(unused_imports)]; - #[allow(non_uppercase_statics)]; - #[allow(dead_code)]; - - use super::*; - - local_data_key!(key: @::std::condition::Handler<$input, $out>) - - pub static cond : - ::std::condition::Condition<$input,$out> = - ::std::condition::Condition { - name: stringify!($c), - key: key - }; - } - } +macro_rules! unimplemented( + () => (fail!("not yet implemented")) ) #[macro_export] -macro_rules! format(($($arg:tt)*) => ( - format_args!(::std::fmt::format, $($arg)*) -)) +macro_rules! format( + ($($arg:tt)*) => ( + format_args!(::std::fmt::format, $($arg)*) + ) +) + #[macro_export] -macro_rules! write(($dst:expr, $($arg:tt)*) => ( - format_args!(|args| { ::std::fmt::write($dst, args) }, $($arg)*) -)) +macro_rules! write( + ($dst:expr, $($arg:tt)*) => ( + format_args!(|args| { ::std::fmt::write($dst, args) }, $($arg)*) + ) +) + #[macro_export] -macro_rules! writeln(($dst:expr, $($arg:tt)*) => ( - format_args!(|args| { ::std::fmt::writeln($dst, args) }, $($arg)*) -)) +macro_rules! writeln( + ($dst:expr, $($arg:tt)*) => ( + format_args!(|args| { ::std::fmt::writeln($dst, args) }, $($arg)*) + ) +) + #[macro_export] -macro_rules! print ( +macro_rules! print( ($($arg:tt)*) => (format_args!(::std::io::stdio::print_args, $($arg)*)) ) + #[macro_export] -macro_rules! println ( +macro_rules! println( ($($arg:tt)*) => (format_args!(::std::io::stdio::println_args, $($arg)*)) ) #[macro_export] -macro_rules! local_data_key ( +macro_rules! local_data_key( ($name:ident: $ty:ty) => ( static $name: ::std::local_data::Key<$ty> = &::std::local_data::Key; ); (pub $name:ident: $ty:ty) => ( pub static $name: ::std::local_data::Key<$ty> = &::std::local_data::Key; - ) + ); ) #[macro_export] -macro_rules! if_ok ( +macro_rules! if_ok( ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) }) ) diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 7bb29fdfacf..5d986a73ca1 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -382,8 +382,8 @@ impl<T: Default> Option<T> { impl<T: fmt::Show> fmt::Show for Option<T> { #[inline] - fn fmt(s: &Option<T>, f: &mut fmt::Formatter) -> fmt::Result { - match *s { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { Some(ref t) => write!(f.buf, "Some({})", *t), None => write!(f.buf, "None") } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 541db01f148..78cae296457 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -28,20 +28,31 @@ #[allow(missing_doc)]; -use clone::Clone; -use container::Container; #[cfg(target_os = "macos")] +#[cfg(windows)] use iter::range; + +use clone::Clone; +use container::Container; use libc; use libc::{c_char, c_void, c_int}; -use option::{Some, None}; +use option::{Some, None, Option}; use os; -use prelude::*; +use ops::Drop; +use result::{Err, Ok, Result}; use ptr; use str; +use str::{Str, StrSlice}; use fmt; use unstable::finally::Finally; use sync::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; +use path::{Path, GenericPath}; +use iter::Iterator; +use vec::{Vector, CloneableVector, ImmutableVector, MutableVector, OwnedVector}; +use ptr::RawPtr; + +#[cfg(unix)] +use c_str::ToCStr; /// Delegates to the libc close() function, returning the same return value. pub fn close(fd: int) -> int { @@ -396,6 +407,8 @@ pub fn self_exe_name() -> Option<Path> { #[cfg(windows)] fn load_self() -> Option<~[u8]> { + use str::OwnedStr; + unsafe { use os::win32::fill_utf16_buf_and_decode; fill_utf16_buf_and_decode(|buf, sz| { @@ -929,8 +942,8 @@ pub enum MapError { } impl fmt::Show for MapError { - fn fmt(val: &MapError, out: &mut fmt::Formatter) -> fmt::Result { - let str = match *val { + fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result { + let str = match *self { ErrFdNotAvail => "fd not available for reading or writing", ErrInvalidFd => "Invalid fd", ErrUnaligned => { @@ -967,6 +980,7 @@ impl MemoryMap { /// `ErrZeroLength`. pub fn new(min_len: uint, options: &[MapOption]) -> Result<MemoryMap, MapError> { use libc::off_t; + use cmp::Equiv; if min_len == 0 { return Err(ErrZeroLength) diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 4aa4a3feab1..ed0ce201750 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -70,7 +70,7 @@ use fmt; use iter::Iterator; use option::{Option, None, Some}; use str; -use str::{OwnedStr, Str, StrSlice}; +use str::{MaybeOwned, OwnedStr, Str, StrSlice, from_utf8_lossy}; use to_str::ToStr; use vec; use vec::{CloneableVector, OwnedCloneableVector, OwnedVector, Vector}; @@ -147,12 +147,6 @@ pub use is_sep_byte = self::windows::is_sep_byte; pub mod posix; pub mod windows; -// Condition that is raised when a NUL is found in a byte vector given to a Path function -condition! { - // this should be a &[u8] but there's a lifetime issue - null_byte: ~[u8] -> ~[u8]; -} - /// A trait that represents the generic operations available on paths pub trait GenericPath: Clone + GenericPathUnsafe { /// Creates a new Path from a byte vector or string. @@ -160,18 +154,13 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// # Failure /// - /// Raises the `null_byte` condition if the path contains a NUL. + /// Fails the task if the path contains a NUL. /// /// See individual Path impls for additional restrictions. #[inline] fn new<T: BytesContainer>(path: T) -> Self { - if contains_nul(path.container_as_bytes()) { - let path = self::null_byte::cond.raise(path.container_into_owned_bytes()); - assert!(!contains_nul(path)); - unsafe { GenericPathUnsafe::new_unchecked(path) } - } else { - unsafe { GenericPathUnsafe::new_unchecked(path) } - } + assert!(!contains_nul(path.container_as_bytes())); + unsafe { GenericPathUnsafe::new_unchecked(path) } } /// Creates a new Path from a byte vector or string, if possible. @@ -283,16 +272,11 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// # Failure /// - /// Raises the `null_byte` condition if the filename contains a NUL. + /// Fails the task if the filename contains a NUL. #[inline] fn set_filename<T: BytesContainer>(&mut self, filename: T) { - if contains_nul(filename.container_as_bytes()) { - let filename = self::null_byte::cond.raise(filename.container_into_owned_bytes()); - assert!(!contains_nul(filename)); - unsafe { self.set_filename_unchecked(filename) } - } else { - unsafe { self.set_filename_unchecked(filename) } - } + assert!(!contains_nul(filename.container_as_bytes())); + unsafe { self.set_filename_unchecked(filename) } } /// Replaces the extension with the given byte vector or string. /// If there is no extension in `self`, this adds one. @@ -301,8 +285,9 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// # Failure /// - /// Raises the `null_byte` condition if the extension contains a NUL. + /// Fails the task if the extension contains a NUL. fn set_extension<T: BytesContainer>(&mut self, extension: T) { + assert!(!contains_nul(extension.container_as_bytes())); // borrowck causes problems here too let val = { match self.filename() { @@ -315,21 +300,11 @@ pub trait GenericPath: Clone + GenericPathUnsafe { None } else { let mut v; - if contains_nul(extension.container_as_bytes()) { - let ext = extension.container_into_owned_bytes(); - let extension = self::null_byte::cond.raise(ext); - assert!(!contains_nul(extension)); - v = vec::with_capacity(name.len() + extension.len() + 1); - v.push_all(name); - v.push(dot); - v.push_all(extension); - } else { - let extension = extension.container_as_bytes(); - v = vec::with_capacity(name.len() + extension.len() + 1); - v.push_all(name); - v.push(dot); - v.push_all(extension); - } + let extension = extension.container_as_bytes(); + v = vec::with_capacity(name.len() + extension.len() + 1); + v.push_all(name); + v.push(dot); + v.push_all(extension); Some(v) } } @@ -338,19 +313,10 @@ pub trait GenericPath: Clone + GenericPathUnsafe { Some(name.slice_to(idx).to_owned()) } else { let mut v; - if contains_nul(extension.container_as_bytes()) { - let ext = extension.container_into_owned_bytes(); - let extension = self::null_byte::cond.raise(ext); - assert!(!contains_nul(extension)); - v = vec::with_capacity(idx + extension.len() + 1); - v.push_all(name.slice_to(idx+1)); - v.push_all(extension); - } else { - let extension = extension.container_as_bytes(); - v = vec::with_capacity(idx + extension.len() + 1); - v.push_all(name.slice_to(idx+1)); - v.push_all(extension); - } + let extension = extension.container_as_bytes(); + v = vec::with_capacity(idx + extension.len() + 1); + v.push_all(name.slice_to(idx+1)); + v.push_all(extension); Some(v) } } @@ -370,7 +336,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// # Failure /// - /// Raises the `null_byte` condition if the filename contains a NUL. + /// Fails the task if the filename contains a NUL. #[inline] fn with_filename<T: BytesContainer>(&self, filename: T) -> Self { let mut p = self.clone(); @@ -383,7 +349,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// # Failure /// - /// Raises the `null_byte` condition if the extension contains a NUL. + /// Fails the task if the extension contains a NUL. #[inline] fn with_extension<T: BytesContainer>(&self, extension: T) -> Self { let mut p = self.clone(); @@ -408,16 +374,11 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// # Failure /// - /// Raises the `null_byte` condition if the path contains a NUL. + /// Fails the task if the path contains a NUL. #[inline] fn push<T: BytesContainer>(&mut self, path: T) { - if contains_nul(path.container_as_bytes()) { - let path = self::null_byte::cond.raise(path.container_into_owned_bytes()); - assert!(!contains_nul(path)); - unsafe { self.push_unchecked(path) } - } else { - unsafe { self.push_unchecked(path) } - } + assert!(!contains_nul(path.container_as_bytes())); + unsafe { self.push_unchecked(path) } } /// Pushes multiple paths (as byte vectors or strings) onto `self`. /// See `push` for details. @@ -445,7 +406,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// /// # Failure /// - /// Raises the `null_byte` condition if the path contains a NUL. + /// Fails the task if the path contains a NUL. #[inline] fn join<T: BytesContainer>(&self, path: T) -> Self { let mut p = self.clone(); @@ -533,8 +494,8 @@ pub struct Display<'a, P> { } impl<'a, P: GenericPath> fmt::Show for Display<'a, P> { - fn fmt(d: &Display<P>, f: &mut fmt::Formatter) -> fmt::Result { - d.with_str(|s| f.pad(s)) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.as_maybe_owned().as_slice().fmt(f) } } @@ -544,33 +505,25 @@ impl<'a, P: GenericPath> ToStr for Display<'a, P> { /// If the path is not UTF-8, invalid sequences with be replaced with the /// unicode replacement char. This involves allocation. fn to_str(&self) -> ~str { - if self.filename { - match self.path.filename() { - None => ~"", - Some(v) => from_utf8_with_replacement(v) - } - } else { - from_utf8_with_replacement(self.path.as_vec()) - } + self.as_maybe_owned().into_owned() } } impl<'a, P: GenericPath> Display<'a, P> { - /// Provides the path as a string to a closure + /// Returns the path as a possibly-owned string. /// /// If the path is not UTF-8, invalid sequences will be replaced with the /// unicode replacement char. This involves allocation. #[inline] - pub fn with_str<T>(&self, f: |&str| -> T) -> T { - let opt = if self.filename { self.path.filename_str() } - else { self.path.as_str() }; - match opt { - Some(s) => f(s), - None => { - let s = self.to_str(); - f(s.as_slice()) + pub fn as_maybe_owned(&self) -> MaybeOwned<'a> { + from_utf8_lossy(if self.filename { + match self.path.filename() { + None => &[], + Some(v) => v } - } + } else { + self.path.as_vec() + }) } } @@ -630,34 +583,28 @@ impl BytesContainer for CString { } } +impl<'a> BytesContainer for str::MaybeOwned<'a> { + #[inline] + fn container_as_bytes<'b>(&'b self) -> &'b [u8] { + self.as_slice().as_bytes() + } + #[inline] + fn container_into_owned_bytes(self) -> ~[u8] { + self.into_owned().into_bytes() + } + #[inline] + fn container_as_str<'b>(&'b self) -> Option<&'b str> { + Some(self.as_slice()) + } + #[inline] + fn is_str(_: Option<str::MaybeOwned>) -> bool { true } +} + #[inline(always)] fn contains_nul(v: &[u8]) -> bool { v.iter().any(|&x| x == 0) } -#[inline(always)] -fn from_utf8_with_replacement(mut v: &[u8]) -> ~str { - // FIXME (#9516): Don't decode utf-8 manually here once we have a good way to do it in str - // This is a truly horrifically bad implementation, done as a functionality stopgap until - // we have a proper utf-8 decoder. I don't really want to write one here. - static REPLACEMENT_CHAR: char = '\uFFFD'; - - let mut s = str::with_capacity(v.len()); - while !v.is_empty() { - let w = str::utf8_char_width(v[0]); - if w == 0u { - s.push_char(REPLACEMENT_CHAR); - v = v.slice_from(1); - } else if v.len() < w || !str::is_utf8(v.slice_to(w)) { - s.push_char(REPLACEMENT_CHAR); - v = v.slice_from(1); - } else { - s.push_str(unsafe { ::cast::transmute(v.slice_to(w)) }); - v = v.slice_from(w); - } - } - s -} #[cfg(test)] mod tests { use prelude::*; diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index ba0cd0bb521..f8e9d0ae344 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -318,7 +318,7 @@ impl Path { /// /// # Failure /// - /// Raises the `null_byte` condition if the vector contains a NUL. + /// Fails the task if the vector contains a NUL. #[inline] pub fn new<T: BytesContainer>(path: T) -> Path { GenericPath::new(path) @@ -527,83 +527,21 @@ mod tests { #[test] fn test_null_byte() { - use path::null_byte::cond; - - let mut handled = false; - let mut p = cond.trap(|v| { - handled = true; - assert_eq!(v.as_slice(), b!("foo/bar", 0)); - (b!("/bar").to_owned()) - }).inside(|| { + use task; + let result = task::try(proc() { Path::new(b!("foo/bar", 0)) }); - assert!(handled); - assert_eq!(p.as_vec(), b!("/bar")); - - handled = false; - cond.trap(|v| { - handled = true; - assert_eq!(v.as_slice(), b!("f", 0, "o")); - (b!("foo").to_owned()) - }).inside(|| { - p.set_filename(b!("f", 0, "o")) - }); - assert!(handled); - assert_eq!(p.as_vec(), b!("/foo")); - - handled = false; - cond.trap(|v| { - handled = true; - assert_eq!(v.as_slice(), b!("f", 0, "o")); - (b!("foo").to_owned()) - }).inside(|| { - p.push(b!("f", 0, "o")); - }); - assert!(handled); - assert_eq!(p.as_vec(), b!("/foo/foo")); - } - - #[test] - fn test_null_byte_fail() { - use path::null_byte::cond; - use task; + assert!(result.is_err()); - macro_rules! t( - ($name:expr => $code:expr) => ( - { - let mut t = task::task(); - t.name($name); - let res = t.try(proc() $code); - assert!(res.is_err()); - } - ) - ) + let result = task::try(proc() { + Path::new("test").set_filename(b!("f", 0, "o")) + }); + assert!(result.is_err()); - t!(~"new() w/nul" => { - cond.trap(|_| { - (b!("null", 0).to_owned()) - }).inside(|| { - Path::new(b!("foo/bar", 0)) - }); - }) - - t!(~"set_filename w/nul" => { - let mut p = Path::new(b!("foo/bar")); - cond.trap(|_| { - (b!("null", 0).to_owned()) - }).inside(|| { - p.set_filename(b!("foo", 0)) - }); - }) - - t!(~"push w/nul" => { - let mut p = Path::new(b!("foo/bar")); - cond.trap(|_| { - (b!("null", 0).to_owned()) - }).inside(|| { - p.push(b!("foo", 0)) - }); - }) + let result = task::try(proc() { + Path::new("test").push(b!("f", 0, "o")); + }); + assert!(result.is_err()); } #[test] @@ -626,24 +564,16 @@ mod tests { macro_rules! t( ($path:expr, $exp:expr) => ( { - let mut called = false; let path = Path::new($path); - path.display().with_str(|s| { - assert_eq!(s, $exp); - called = true; - }); - assert!(called); + let mo = path.display().as_maybe_owned(); + assert_eq!(mo.as_slice(), $exp); } ); ($path:expr, $exp:expr, filename) => ( { - let mut called = false; let path = Path::new($path); - path.filename_display().with_str(|s| { - assert_eq!(s, $exp); - called = true; - }); - assert!(called); + let mo = path.filename_display().as_maybe_owned(); + assert_eq!(mo.as_slice(), $exp); } ) ) diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index eec6f37b627..972b7d178a1 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -590,7 +590,7 @@ impl Path { /// /// # Failure /// - /// Raises the `null_byte` condition if the vector contains a NUL. + /// Fails the task if the vector contains a NUL. /// Fails if invalid UTF-8. #[inline] pub fn new<T: BytesContainer>(path: T) -> Path { @@ -1248,83 +1248,21 @@ mod tests { #[test] fn test_null_byte() { - use path::null_byte::cond; - - let mut handled = false; - let mut p = cond.trap(|v| { - handled = true; - assert_eq!(v.as_slice(), b!("foo\\bar", 0)); - (b!("\\bar").to_owned()) - }).inside(|| { - Path::new(b!("foo\\bar", 0)) - }); - assert!(handled); - assert_eq!(p.as_vec(), b!("\\bar")); - - handled = false; - cond.trap(|v| { - handled = true; - assert_eq!(v.as_slice(), b!("f", 0, "o")); - (b!("foo").to_owned()) - }).inside(|| { - p.set_filename(b!("f", 0, "o")) - }); - assert!(handled); - assert_eq!(p.as_vec(), b!("\\foo")); - - handled = false; - cond.trap(|v| { - handled = true; - assert_eq!(v.as_slice(), b!("f", 0, "o")); - (b!("foo").to_owned()) - }).inside(|| { - p.push(b!("f", 0, "o")); - }); - assert!(handled); - assert_eq!(p.as_vec(), b!("\\foo\\foo")); - } - - #[test] - fn test_null_byte_fail() { - use path::null_byte::cond; use task; + let result = task::try(proc() { + Path::new(b!("foo/bar", 0)) + }); + assert!(result.is_err()); - macro_rules! t( - ($name:expr => $code:expr) => ( - { - let mut t = task::task(); - t.name($name); - let res = t.try(proc() $code); - assert!(res.is_err()); - } - ) - ) - - t!(~"from_vec() w\\nul" => { - cond.trap(|_| { - (b!("null", 0).to_owned()) - }).inside(|| { - Path::new(b!("foo\\bar", 0)) - }); - }) - - t!(~"set_filename w\\nul" => { - let mut p = Path::new(b!("foo\\bar")); - cond.trap(|_| { - (b!("null", 0).to_owned()) - }).inside(|| { - p.set_filename(b!("foo", 0)) - }); - }) + let result = task::try(proc() { + Path::new("test").set_filename(b!("f", 0, "o")) + }); + assert!(result.is_err()); - t!(~"push w\\nul" => { - let mut p = Path::new(b!("foo\\bar")); - cond.trap(|_| { - (b!("null", 0).to_owned()) - }).inside(|| { - p.push(b!("foo", 0)) - }); - }) + let result = task::try(proc() { + Path::new("test").push(b!("f", 0, "o")); + }); + assert!(result.is_err()); } #[test] @@ -1340,20 +1278,12 @@ mod tests { let path = Path::new(b!("\\")); assert_eq!(path.filename_display().to_str(), ~""); - let mut called = false; let path = Path::new("foo"); - path.display().with_str(|s| { - assert_eq!(s, "foo"); - called = true; - }); - assert!(called); - called = false; + let mo = path.display().as_maybe_owned(); + assert_eq!(mo.as_slice(), "foo"); let path = Path::new(b!("\\")); - path.filename_display().with_str(|s| { - assert_eq!(s, ""); - called = true; - }); - assert!(called); + let mo = path.filename_display().as_maybe_owned(); + assert_eq!(mo.as_slice(), ""); } #[test] diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index b08d792822b..f113b2f17eb 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -63,8 +63,7 @@ pub use num::{Primitive, Int, Float, ToStrRadix, ToPrimitive, FromPrimitive}; pub use path::{GenericPath, Path, PosixPath, WindowsPath}; pub use ptr::RawPtr; pub use io::{Buffer, Writer, Reader, Seek}; -pub use send_str::{SendStr, SendStrOwned, SendStrStatic, IntoSendStr}; -pub use str::{Str, StrVector, StrSlice, OwnedStr}; +pub use str::{Str, StrVector, StrSlice, OwnedStr, IntoMaybeOwned}; pub use to_bytes::IterBytes; pub use to_str::{ToStr, IntoStr}; pub use tuple::{CloneableTuple, ImmutableTuple}; diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 7d0ddb2e4fb..a1565bc85de 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -50,7 +50,12 @@ impl<T> Rc<T> { pub fn new(value: T) -> Rc<T> { unsafe { Rc { - ptr: transmute(~RcBox { value: value, strong: 1, weak: 0 }), + // there is an implicit weak pointer owned by all the + // strong pointers, which ensures that the weak + // destructor never frees the allocation while the + // strong destructor is running, even if the weak + // pointer is stored inside the strong one. + ptr: transmute(~RcBox { value: value, strong: 1, weak: 1 }), marker: marker::NoSend, } } @@ -81,6 +86,11 @@ impl<T> Drop for Rc<T> { (*self.ptr).strong -= 1; if (*self.ptr).strong == 0 { read_ptr(self.borrow()); // destroy the contained object + + // remove the implicit "strong weak" pointer now + // that we've destroyed the contents. + (*self.ptr).weak -= 1; + if (*self.ptr).weak == 0 { exchange_free(self.ptr as *u8) } @@ -156,7 +166,9 @@ impl<T> Drop for Weak<T> { unsafe { if self.ptr != 0 as *mut RcBox<T> { (*self.ptr).weak -= 1; - if (*self.ptr).weak == 0 && (*self.ptr).strong == 0 { + // the weak count starts at 1, and will only go to + // zero if all the strong pointers have disappeared. + if (*self.ptr).weak == 0 { exchange_free(self.ptr as *u8) } } @@ -242,4 +254,17 @@ mod tests { let a = Rc::new(RefCell::new(Gc::new(1))); assert!(a.borrow().try_borrow_mut().is_some()); } + + #[test] + fn weak_self_cyclic() { + struct Cycle { + x: RefCell<Option<Weak<Cycle>>> + } + + let a = Rc::new(Cycle { x: RefCell::new(None) }); + let b = a.clone().downgrade(); + *a.borrow().x.borrow_mut().get() = Some(b); + + // hopefully we don't double-free (or leak)... + } } diff --git a/src/libstd/reference.rs b/src/libstd/reference.rs index 91f03f02892..fdbca2b9f33 100644 --- a/src/libstd/reference.rs +++ b/src/libstd/reference.rs @@ -11,7 +11,7 @@ //! Utilities for references #[cfg(not(test))] -use prelude::*; +use cmp::{Eq, Ord, Ordering, TotalEq, TotalOrd}; // Equality for region pointers #[cfg(not(test))] diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index 168ed583570..e441ea6ec74 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -424,9 +424,9 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { } fn visit_trait(&mut self, name: &str) -> bool { - self.align_to::<@TyVisitor>(); + self.align_to::<~TyVisitor>(); if ! self.inner.visit_trait(name) { return false; } - self.bump_past::<@TyVisitor>(); + self.bump_past::<~TyVisitor>(); true } diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 846bba7533f..39e8b6ad6c1 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -208,8 +208,8 @@ impl<T, E> Result<T, E> { impl<T: fmt::Show, E: fmt::Show> fmt::Show for Result<T, E> { #[inline] - fn fmt(s: &Result<T, E>, f: &mut fmt::Formatter) -> fmt::Result { - match *s { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { Ok(ref t) => write!(f.buf, "Ok({})", *t), Err(ref e) => write!(f.buf, "Err({})", *e) } diff --git a/src/libstd/rt/env.rs b/src/libstd/rt/env.rs index 729e377e1af..571ed77592f 100644 --- a/src/libstd/rt/env.rs +++ b/src/libstd/rt/env.rs @@ -10,6 +10,8 @@ //! Runtime environment settings +// NOTE: remove `POISON_ON_FREE` after a snapshot + use from_str::from_str; use option::{Some, None}; use os; diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 6bee8cb70f5..2f553585f38 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -10,7 +10,9 @@ use libc::{c_void, size_t, free, malloc, realloc}; use ptr::{RawPtr, mut_null}; -use unstable::intrinsics::{TyDesc, abort}; +#[cfg(stage0)] +use unstable::intrinsics::TyDesc; +use unstable::intrinsics::abort; use unstable::raw; use mem::size_of; @@ -73,14 +75,23 @@ pub unsafe fn exchange_malloc(size: uint) -> *u8 { } // FIXME: #7496 -#[cfg(not(test))] +#[cfg(not(test), stage0)] #[lang="closure_exchange_malloc"] #[inline] pub unsafe fn closure_exchange_malloc_(td: *u8, size: uint) -> *u8 { closure_exchange_malloc(td, size) } +// FIXME: #7496 +#[cfg(not(test), not(stage0))] +#[lang="closure_exchange_malloc"] #[inline] +pub unsafe fn closure_exchange_malloc_(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { + closure_exchange_malloc(drop_glue, size, align) +} + +#[inline] +#[cfg(stage0)] pub unsafe fn closure_exchange_malloc(td: *u8, size: uint) -> *u8 { let td = td as *TyDesc; let size = size; @@ -96,6 +107,18 @@ pub unsafe fn closure_exchange_malloc(td: *u8, size: uint) -> *u8 { alloc as *u8 } +#[inline] +#[cfg(not(stage0))] +pub unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { + let total_size = get_box_size(size, align); + let p = malloc_raw(total_size); + + let alloc = p as *mut raw::Box<()>; + (*alloc).drop_glue = drop_glue; + + alloc as *u8 +} + // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from // inside a landing pad may corrupt the state of the exception handler. #[cfg(not(test))] diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index 79936b4afad..3bee9e48b60 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -21,6 +21,7 @@ use rt::env; use rt::global_heap; use rt::local::Local; use rt::task::Task; +#[cfg(stage0)] use unstable::intrinsics::TyDesc; use unstable::raw; use vec::ImmutableVector; @@ -60,6 +61,7 @@ impl LocalHeap { } #[inline] + #[cfg(stage0)] pub fn alloc(&mut self, td: *TyDesc, size: uint) -> *mut Box { let total_size = global_heap::get_box_size(size, unsafe { (*td).align }); let alloc = self.memory_region.malloc(total_size); @@ -81,6 +83,28 @@ impl LocalHeap { } #[inline] + #[cfg(not(stage0))] + pub fn alloc(&mut self, drop_glue: fn(*mut u8), size: uint, align: uint) -> *mut Box { + let total_size = global_heap::get_box_size(size, align); + let alloc = self.memory_region.malloc(total_size); + { + // Make sure that we can't use `mybox` outside of this scope + let mybox: &mut Box = unsafe { cast::transmute(alloc) }; + // Clear out this box, and move it to the front of the live + // allocations list + mybox.drop_glue = drop_glue; + mybox.ref_count = 1; + mybox.prev = ptr::mut_null(); + mybox.next = self.live_allocs; + if !self.live_allocs.is_null() { + unsafe { (*self.live_allocs).prev = alloc; } + } + self.live_allocs = alloc; + } + return alloc; + } + + #[inline] pub fn realloc(&mut self, ptr: *mut Box, size: uint) -> *mut Box { // Make sure that we can't use `mybox` outside of this scope let total_size = size + mem::size_of::<Box>(); @@ -102,6 +126,7 @@ impl LocalHeap { } #[inline] + #[cfg(stage0)] pub fn free(&mut self, alloc: *mut Box) { { // Make sure that we can't use `mybox` outside of this scope @@ -133,6 +158,28 @@ impl LocalHeap { self.memory_region.free(alloc); } + + #[inline] + #[cfg(not(stage0))] + pub fn free(&mut self, alloc: *mut Box) { + { + // Make sure that we can't use `mybox` outside of this scope + let mybox: &mut Box = unsafe { cast::transmute(alloc) }; + + // Unlink it from the linked list + if !mybox.prev.is_null() { + unsafe { (*mybox.prev).next = mybox.next; } + } + if !mybox.next.is_null() { + unsafe { (*mybox.next).prev = mybox.prev; } + } + if self.live_allocs == alloc { + self.live_allocs = mybox.next; + } + } + + self.memory_region.free(alloc); + } } impl Drop for LocalHeap { @@ -292,6 +339,7 @@ impl Drop for MemoryRegion { } #[inline] +#[cfg(stage0)] pub unsafe fn local_malloc(td: *u8, size: uint) -> *u8 { // FIXME: Unsafe borrow for speed. Lame. let task: Option<*mut Task> = Local::try_unsafe_borrow(); @@ -303,6 +351,19 @@ pub unsafe fn local_malloc(td: *u8, size: uint) -> *u8 { } } +#[inline] +#[cfg(not(stage0))] +pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { + // FIXME: Unsafe borrow for speed. Lame. + let task: Option<*mut Task> = Local::try_unsafe_borrow(); + match task { + Some(task) => { + (*task).heap.alloc(drop_glue, size, align) as *u8 + } + None => rtabort!("local malloc outside of task") + } +} + // A little compatibility function #[inline] pub unsafe fn local_free(ptr: *u8) { diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 55425eb2e72..376d685c8ac 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -44,7 +44,6 @@ Several modules in `core` are clients of `rt`: * `std::local_data` - The interface to local data. * `std::gc` - The garbage collector. * `std::unstable::lang` - Miscellaneous lang items, some of which rely on `std::rt`. -* `std::condition` - Uses local data. * `std::cleanup` - Local heap destruction. * `std::io` - In the future `std::io` will use an `rt` implementation. * `std::logging` diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index fbe82531f69..a7648dd2d19 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -30,7 +30,7 @@ use rt::local::Local; use rt::local_heap::LocalHeap; use rt::rtio::LocalIo; use rt::unwind::Unwinder; -use send_str::SendStr; +use str::SendStr; use sync::arc::UnsafeArc; use sync::atomics::{AtomicUint, SeqCst}; use task::{TaskResult, TaskOpts}; diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 04e42b3eedf..fdd26c6c383 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -20,7 +20,13 @@ use io::process; use io; use libc::{pid_t, c_int}; use libc; -use prelude::*; +use option::{None, Option, Some}; +use task::spawn; +use path::{Path, GenericPath}; +use result::Ok; +use str::Str; +use vec::Vector; +use clone::Clone; /** * A value representing a child process. diff --git a/src/libstd/send_str.rs b/src/libstd/send_str.rs deleted file mode 100644 index b075b75b70a..00000000000 --- a/src/libstd/send_str.rs +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2013-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. - -//! The `SendStr` trait for optionally static strings - -use clone::{Clone, DeepClone}; -use cmp::{Eq, TotalEq, Ord, TotalOrd, Equiv}; -use cmp::Ordering; -use container::Container; -use default::Default; -use str::{Str, StrSlice}; -use to_str::ToStr; -use to_bytes::{IterBytes, Cb}; - -/// A SendStr is a string that can hold either a ~str or a &'static str. -/// This can be useful as an optimization when an allocation is sometimes -/// needed but the common case is statically known. -#[allow(missing_doc)] -pub enum SendStr { - SendStrOwned(~str), - SendStrStatic(&'static str) -} - -impl SendStr { - /// Returns `true` if this `SendStr` wraps an owned string - #[inline] - pub fn is_owned(&self) -> bool { - match *self { - SendStrOwned(_) => true, - SendStrStatic(_) => false - } - } - - /// Returns `true` if this `SendStr` wraps a static string - #[inline] - pub fn is_static(&self) -> bool { - match *self { - SendStrOwned(_) => false, - SendStrStatic(_) => true - } - } -} - -/// Trait for moving into an `SendStr` -pub trait IntoSendStr { - /// Moves self into an `SendStr` - fn into_send_str(self) -> SendStr; -} - -impl IntoSendStr for ~str { - #[inline] - fn into_send_str(self) -> SendStr { SendStrOwned(self) } -} - -impl IntoSendStr for &'static str { - #[inline] - fn into_send_str(self) -> SendStr { SendStrStatic(self) } -} - -impl IntoSendStr for SendStr { - #[inline] - fn into_send_str(self) -> SendStr { self } -} - -/* -Section: String trait impls. -`SendStr` should behave like a normal string, so we don't derive. -*/ - -impl ToStr for SendStr { - #[inline] - fn to_str(&self) -> ~str { self.as_slice().to_owned() } -} - -impl Eq for SendStr { - #[inline] - fn eq(&self, other: &SendStr) -> bool { - self.as_slice().equals(&other.as_slice()) - } -} - -impl TotalEq for SendStr { - #[inline] - fn equals(&self, other: &SendStr) -> bool { - self.as_slice().equals(&other.as_slice()) - } -} - -impl Ord for SendStr { - #[inline] - fn lt(&self, other: &SendStr) -> bool { - self.as_slice().lt(&other.as_slice()) - } -} - -impl TotalOrd for SendStr { - #[inline] - fn cmp(&self, other: &SendStr) -> Ordering { - self.as_slice().cmp(&other.as_slice()) - } -} - -impl<'a, S: Str> Equiv<S> for SendStr { - #[inline] - fn equiv(&self, other: &S) -> bool { - self.as_slice().equals(&other.as_slice()) - } -} - -impl Str for SendStr { - #[inline] - fn as_slice<'r>(&'r self) -> &'r str { - match *self { - SendStrOwned(ref s) => s.as_slice(), - // FIXME: Borrowchecker doesn't recognize lifetime as static unless prompted - // SendStrStatic(s) => s.as_slice() - SendStrStatic(s) => {let tmp: &'static str = s; tmp} - } - } - - #[inline] - fn into_owned(self) -> ~str { - match self { - SendStrOwned(s) => s, - SendStrStatic(s) => s.to_owned() - } - } -} - -impl Container for SendStr { - #[inline] - fn len(&self) -> uint { self.as_slice().len() } -} - -impl Clone for SendStr { - #[inline] - fn clone(&self) -> SendStr { - match *self { - SendStrOwned(ref s) => SendStrOwned(s.to_owned()), - SendStrStatic(s) => SendStrStatic(s) - } - } -} - -impl DeepClone for SendStr { - #[inline] - fn deep_clone(&self) -> SendStr { - match *self { - SendStrOwned(ref s) => SendStrOwned(s.to_owned()), - SendStrStatic(s) => SendStrStatic(s) - } - } -} - -impl Default for SendStr { - #[inline] - fn default() -> SendStr { SendStrStatic("") } -} - -impl IterBytes for SendStr { - #[inline] - fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { - match *self { - SendStrOwned(ref s) => s.iter_bytes(lsb0, f), - SendStrStatic(s) => s.iter_bytes(lsb0, f) - } - } -} - -#[cfg(test)] -mod tests { - use prelude::*; - use send_str::{SendStrOwned, SendStrStatic}; - - #[test] - fn test_send_str_traits() { - let s = SendStrStatic("abcde"); - assert_eq!(s.len(), 5); - assert_eq!(s.as_slice(), "abcde"); - assert_eq!(s.to_str(), ~"abcde"); - assert!(s.lt(&SendStrOwned(~"bcdef"))); - assert_eq!(SendStrStatic(""), Default::default()); - - let o = SendStrOwned(~"abcde"); - assert_eq!(o.len(), 5); - assert_eq!(o.as_slice(), "abcde"); - assert_eq!(o.to_str(), ~"abcde"); - assert!(o.lt(&SendStrStatic("bcdef"))); - assert_eq!(SendStrOwned(~""), Default::default()); - - assert_eq!(s.cmp(&o), Equal); - assert!(s.equals(&o)); - assert!(s.equiv(&o)); - - assert_eq!(o.cmp(&s), Equal); - assert!(o.equals(&s)); - assert!(o.equiv(&s)); - } - - #[test] - fn test_send_str_methods() { - let s = SendStrStatic("abcde"); - assert!(s.is_static()); - assert!(!s.is_owned()); - - let o = SendStrOwned(~"abcde"); - assert!(!o.is_static()); - assert!(o.is_owned()); - } - - #[test] - fn test_send_str_clone() { - assert_eq!(SendStrOwned(~"abcde"), SendStrStatic("abcde").clone()); - assert_eq!(SendStrOwned(~"abcde"), SendStrStatic("abcde").deep_clone()); - - assert_eq!(SendStrOwned(~"abcde"), SendStrOwned(~"abcde").clone()); - assert_eq!(SendStrOwned(~"abcde"), SendStrOwned(~"abcde").deep_clone()); - - assert_eq!(SendStrStatic("abcde"), SendStrStatic("abcde").clone()); - assert_eq!(SendStrStatic("abcde"), SendStrStatic("abcde").deep_clone()); - - assert_eq!(SendStrStatic("abcde"), SendStrOwned(~"abcde").clone()); - assert_eq!(SendStrStatic("abcde"), SendStrOwned(~"abcde").deep_clone()); - } - - #[test] - fn test_send_str_into_owned() { - assert_eq!(SendStrStatic("abcde").into_owned(), ~"abcde"); - assert_eq!(SendStrOwned(~"abcde").into_owned(), ~"abcde"); - } - - #[test] - fn test_into_send_str() { - assert_eq!("abcde".into_send_str(), SendStrStatic("abcde")); - assert_eq!((~"abcde").into_send_str(), SendStrStatic("abcde")); - assert_eq!("abcde".into_send_str(), SendStrOwned(~"abcde")); - assert_eq!((~"abcde").into_send_str(), SendStrOwned(~"abcde")); - } -} diff --git a/src/libstd/str.rs b/src/libstd/str.rs index e33e2c31c6d..3225bb3a678 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -86,7 +86,9 @@ use cast::transmute; use char; use char::Char; use clone::{Clone, DeepClone}; +use cmp::{Eq, TotalEq, Ord, TotalOrd, Equiv, Ordering}; use container::{Container, Mutable}; +use fmt; use iter::{Iterator, FromIterator, Extendable, range}; use iter::{Filter, AdditiveIterator, Map}; use iter::{Rev, DoubleEndedIterator, ExactSize}; @@ -100,7 +102,7 @@ use from_str::FromStr; use vec; use vec::{OwnedVector, OwnedCloneableVector, ImmutableVector, MutableVector}; use default::Default; -use send_str::{SendStr, SendStrOwned}; +use to_bytes::{IterBytes, Cb}; use unstable::raw::Repr; /* @@ -729,6 +731,11 @@ Section: Misc /// Determines if a vector of bytes contains valid UTF-8 pub fn is_utf8(v: &[u8]) -> bool { + first_non_utf8_index(v).is_none() +} + +#[inline(always)] +fn first_non_utf8_index(v: &[u8]) -> Option<uint> { let mut i = 0u; let total = v.len(); fn unsafe_get(xs: &[u8], i: uint) -> u8 { @@ -740,10 +747,10 @@ pub fn is_utf8(v: &[u8]) -> bool { i += 1u; } else { let w = utf8_char_width(v_i); - if w == 0u { return false; } + if w == 0u { return Some(i); } let nexti = i + w; - if nexti > total { return false; } + if nexti > total { return Some(i); } // 2-byte encoding is for codepoints \u0080 to \u07ff // first C2 80 last DF BF @@ -766,7 +773,7 @@ pub fn is_utf8(v: &[u8]) -> bool { // UTF8-tail = %x80-BF match w { 2 => if unsafe_get(v, i + 1) & 192u8 != TAG_CONT_U8 { - return false + return Some(i) }, 3 => match (v_i, unsafe_get(v, i + 1), @@ -775,7 +782,7 @@ pub fn is_utf8(v: &[u8]) -> bool { (0xE1 .. 0xEC, 0x80 .. 0xBF, TAG_CONT_U8) => (), (0xED , 0x80 .. 0x9F, TAG_CONT_U8) => (), (0xEE .. 0xEF, 0x80 .. 0xBF, TAG_CONT_U8) => (), - _ => return false, + _ => return Some(i), }, _ => match (v_i, unsafe_get(v, i + 1), @@ -784,14 +791,14 @@ pub fn is_utf8(v: &[u8]) -> bool { (0xF0 , 0x90 .. 0xBF, TAG_CONT_U8, TAG_CONT_U8) => (), (0xF1 .. 0xF3, 0x80 .. 0xBF, TAG_CONT_U8, TAG_CONT_U8) => (), (0xF4 , 0x80 .. 0x8F, TAG_CONT_U8, TAG_CONT_U8) => (), - _ => return false, + _ => return Some(i) }, } i = nexti; } } - true + None } /// Determines if a vector of `u16` contains valid UTF-16 @@ -900,16 +907,303 @@ pub struct CharRange { // The first byte is special, only want bottom 5 bits for width 2, 4 bits // for width 3, and 3 bits for width 4 macro_rules! utf8_first_byte( - ($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as uint) + ($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as u32) ) // return the value of $ch updated with continuation byte $byte macro_rules! utf8_acc_cont_byte( - ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as uint) + ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as u32) ) static TAG_CONT_U8: u8 = 128u8; +/// Converts a vector of bytes to a new utf-8 string. +/// Any invalid utf-8 sequences are replaced with U+FFFD REPLACEMENT CHARACTER. +/// +/// # Example +/// +/// ```rust +/// let input = bytes!("Hello ", 0xF0, 0x90, 0x80, "World"); +/// let output = std::str::from_utf8_lossy(input); +/// assert_eq!(output.as_slice(), "Hello \uFFFDWorld"); +/// ``` +pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> { + let firstbad = match first_non_utf8_index(v) { + None => return Slice(unsafe { cast::transmute(v) }), + Some(i) => i + }; + + static REPLACEMENT: &'static [u8] = bytes!(0xEF, 0xBF, 0xBD); // U+FFFD in UTF-8 + let mut i = firstbad; + let total = v.len(); + fn unsafe_get(xs: &[u8], i: uint) -> u8 { + unsafe { *xs.unsafe_ref(i) } + } + fn safe_get(xs: &[u8], i: uint, total: uint) -> u8 { + if i >= total { + 0 + } else { + unsafe_get(xs, i) + } + } + let mut res = with_capacity(total); + + if i > 0 { + unsafe { raw::push_bytes(&mut res, v.slice_to(i)) }; + } + + // subseqidx is the index of the first byte of the subsequence we're looking at. + // It's used to copy a bunch of contiguous good codepoints at once instead of copying + // them one by one. + let mut subseqidx = firstbad; + + while i < total { + let i_ = i; + let byte = unsafe_get(v, i); + i += 1; + + macro_rules! error(() => ({ + unsafe { + if subseqidx != i_ { + raw::push_bytes(&mut res, v.slice(subseqidx, i_)); + } + subseqidx = i; + raw::push_bytes(&mut res, REPLACEMENT); + } + })) + + if byte < 128u8 { + // subseqidx handles this + } else { + let w = utf8_char_width(byte); + + match w { + 2 => { + if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 { + error!(); + continue; + } + i += 1; + } + 3 => { + match (byte, safe_get(v, i, total)) { + (0xE0 , 0xA0 .. 0xBF) => (), + (0xE1 .. 0xEC, 0x80 .. 0xBF) => (), + (0xED , 0x80 .. 0x9F) => (), + (0xEE .. 0xEF, 0x80 .. 0xBF) => (), + _ => { + error!(); + continue; + } + } + i += 1; + if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 { + error!(); + continue; + } + i += 1; + } + 4 => { + match (byte, safe_get(v, i, total)) { + (0xF0 , 0x90 .. 0xBF) => (), + (0xF1 .. 0xF3, 0x80 .. 0xBF) => (), + (0xF4 , 0x80 .. 0x8F) => (), + _ => { + error!(); + continue; + } + } + i += 1; + if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 { + error!(); + continue; + } + i += 1; + if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 { + error!(); + continue; + } + i += 1; + } + _ => { + error!(); + continue; + } + } + } + } + if subseqidx < total { + unsafe { raw::push_bytes(&mut res, v.slice(subseqidx, total)) }; + } + Owned(res) +} + +/* +Section: MaybeOwned +*/ + +/// A MaybeOwned is a string that can hold either a ~str or a &str. +/// This can be useful as an optimization when an allocation is sometimes +/// needed but not always. +pub enum MaybeOwned<'a> { + /// A borrowed string + Slice(&'a str), + /// An owned string + Owned(~str) +} + +/// SendStr is a specialization of `MaybeOwned` to be sendable +pub type SendStr = MaybeOwned<'static>; + +impl<'a> MaybeOwned<'a> { + /// Returns `true` if this `MaybeOwned` wraps an owned string + #[inline] + pub fn is_owned(&self) -> bool { + match *self { + Slice(_) => false, + Owned(_) => true + } + } + + /// Returns `true` if this `MaybeOwned` wraps a borrowed string + #[inline] + pub fn is_slice(&self) -> bool { + match *self { + Slice(_) => true, + Owned(_) => false + } + } +} + +/// Trait for moving into a `MaybeOwned` +pub trait IntoMaybeOwned<'a> { + /// Moves self into a `MaybeOwned` + fn into_maybe_owned(self) -> MaybeOwned<'a>; +} + +impl<'a> IntoMaybeOwned<'a> for ~str { + #[inline] + fn into_maybe_owned(self) -> MaybeOwned<'a> { Owned(self) } +} + +impl<'a> IntoMaybeOwned<'a> for &'a str { + #[inline] + fn into_maybe_owned(self) -> MaybeOwned<'a> { Slice(self) } +} + +impl<'a> IntoMaybeOwned<'a> for MaybeOwned<'a> { + #[inline] + fn into_maybe_owned(self) -> MaybeOwned<'a> { self } +} + +impl<'a> ToStr for MaybeOwned<'a> { + #[inline] + fn to_str(&self) -> ~str { self.as_slice().to_owned() } +} + +impl<'a> Eq for MaybeOwned<'a> { + #[inline] + fn eq(&self, other: &MaybeOwned) -> bool { + self.as_slice().equals(&other.as_slice()) + } +} + +impl<'a> TotalEq for MaybeOwned<'a> { + #[inline] + fn equals(&self, other: &MaybeOwned) -> bool { + self.as_slice().equals(&other.as_slice()) + } +} + +impl<'a> Ord for MaybeOwned<'a> { + #[inline] + fn lt(&self, other: &MaybeOwned) -> bool { + self.as_slice().lt(&other.as_slice()) + } +} + +impl<'a> TotalOrd for MaybeOwned<'a> { + #[inline] + fn cmp(&self, other: &MaybeOwned) -> Ordering { + self.as_slice().cmp(&other.as_slice()) + } +} + +impl<'a, S: Str> Equiv<S> for MaybeOwned<'a> { + #[inline] + fn equiv(&self, other: &S) -> bool { + self.as_slice().equals(&other.as_slice()) + } +} + +impl<'a> Str for MaybeOwned<'a> { + #[inline] + fn as_slice<'b>(&'b self) -> &'b str { + match *self { + Slice(s) => s, + Owned(ref s) => s.as_slice() + } + } + + #[inline] + fn into_owned(self) -> ~str { + match self { + Slice(s) => s.to_owned(), + Owned(s) => s + } + } +} + +impl<'a> Container for MaybeOwned<'a> { + #[inline] + fn len(&self) -> uint { self.as_slice().len() } +} + +impl<'a> Clone for MaybeOwned<'a> { + #[inline] + fn clone(&self) -> MaybeOwned<'a> { + match *self { + Slice(s) => Slice(s), + Owned(ref s) => Owned(s.to_owned()) + } + } +} + +impl<'a> DeepClone for MaybeOwned<'a> { + #[inline] + fn deep_clone(&self) -> MaybeOwned<'a> { + match *self { + Slice(s) => Slice(s), + Owned(ref s) => Owned(s.to_owned()) + } + } +} + +impl<'a> Default for MaybeOwned<'a> { + #[inline] + fn default() -> MaybeOwned<'a> { Slice("") } +} + +impl<'a> IterBytes for MaybeOwned<'a> { + #[inline] + fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool { + match *self { + Slice(s) => s.iter_bytes(lsb0, f), + Owned(ref s) => s.iter_bytes(lsb0, f) + } + } +} + +impl<'a> fmt::Show for MaybeOwned<'a> { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Slice(ref s) => s.fmt(f), + Owned(ref s) => s.fmt(f) + } + } +} + /// Unsafe operations pub mod raw { use cast; @@ -1664,9 +1958,6 @@ pub trait StrSlice<'a> { /// Converts to a vector of `u16` encoded as UTF-16. fn to_utf16(&self) -> ~[u16]; - /// Copy a slice into a new `SendStr`. - fn to_send_str(&self) -> SendStr; - /// Check that `index`-th byte lies at the start and/or end of a /// UTF-8 code point sequence. /// @@ -2192,11 +2483,6 @@ impl<'a> StrSlice<'a> for &'a str { } #[inline] - fn to_send_str(&self) -> SendStr { - SendStrOwned(self.to_owned()) - } - - #[inline] fn is_char_boundary(&self, index: uint) -> bool { if index == self.len() { return true; } let b = self[index]; @@ -2211,7 +2497,7 @@ impl<'a> StrSlice<'a> for &'a str { // Multibyte case is a fn to allow char_range_at to inline cleanly fn multibyte_char_range_at(s: &str, i: uint) -> CharRange { - let mut val = s[i] as uint; + let mut val = s[i] as u32; let w = UTF8_CHAR_WIDTH[val] as uint; assert!((w != 0)); @@ -2220,7 +2506,7 @@ impl<'a> StrSlice<'a> for &'a str { if w > 2 { val = utf8_acc_cont_byte!(val, s[i + 2]); } if w > 3 { val = utf8_acc_cont_byte!(val, s[i + 3]); } - return CharRange {ch: unsafe { transmute(val as u32) }, next: i + w}; + return CharRange {ch: unsafe { transmute(val) }, next: i + w}; } return multibyte_char_range_at(*self, i); @@ -2243,7 +2529,7 @@ impl<'a> StrSlice<'a> for &'a str { i -= 1u; } - let mut val = s[i] as uint; + let mut val = s[i] as u32; let w = UTF8_CHAR_WIDTH[val] as uint; assert!((w != 0)); @@ -2252,7 +2538,7 @@ impl<'a> StrSlice<'a> for &'a str { if w > 2 { val = utf8_acc_cont_byte!(val, s[i + 2]); } if w > 3 { val = utf8_acc_cont_byte!(val, s[i + 3]); } - return CharRange {ch: unsafe { transmute(val as u32) }, next: i}; + return CharRange {ch: unsafe { transmute(val) }, next: i}; } return multibyte_char_range_at_reverse(*self, prev); @@ -2635,7 +2921,6 @@ mod tests { use prelude::*; use ptr; use str::*; - use send_str::{SendStrOwned, SendStrStatic}; #[test] fn test_eq() { @@ -3835,9 +4120,34 @@ mod tests { } #[test] - fn test_to_send_str() { - assert_eq!("abcde".to_send_str(), SendStrStatic("abcde")); - assert_eq!("abcde".to_send_str(), SendStrOwned(~"abcde")); + fn test_str_from_utf8_lossy() { + let xs = bytes!("hello"); + assert_eq!(from_utf8_lossy(xs), Slice("hello")); + + let xs = bytes!("ศไทย中华Việt Nam"); + assert_eq!(from_utf8_lossy(xs), Slice("ศไทย中华Việt Nam")); + + let xs = bytes!("Hello", 0xC2, " There", 0xFF, " Goodbye"); + assert_eq!(from_utf8_lossy(xs), Owned(~"Hello\uFFFD There\uFFFD Goodbye")); + + let xs = bytes!("Hello", 0xC0, 0x80, " There", 0xE6, 0x83, " Goodbye"); + assert_eq!(from_utf8_lossy(xs), Owned(~"Hello\uFFFD\uFFFD There\uFFFD Goodbye")); + + let xs = bytes!(0xF5, "foo", 0xF5, 0x80, "bar"); + assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFD\uFFFDbar")); + + let xs = bytes!(0xF1, "foo", 0xF1, 0x80, "bar", 0xF1, 0x80, 0x80, "baz"); + assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFDbar\uFFFDbaz")); + + let xs = bytes!(0xF4, "foo", 0xF4, 0x80, "bar", 0xF4, 0xBF, "baz"); + assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFDfoo\uFFFDbar\uFFFD\uFFFDbaz")); + + let xs = bytes!(0xF0, 0x80, 0x80, 0x80, "foo", 0xF0, 0x90, 0x80, 0x80, "bar"); + assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFD\uFFFD\uFFFD\uFFFDfoo\U00010000bar")); + + // surrogates + let xs = bytes!(0xED, 0xA0, 0x80, "foo", 0xED, 0xBF, 0xBF, "bar"); + assert_eq!(from_utf8_lossy(xs), Owned(~"\uFFFD\uFFFD\uFFFDfoo\uFFFD\uFFFD\uFFFDbar")); } #[test] @@ -3845,6 +4155,71 @@ mod tests { let owned: Option<~str> = from_str(&"string"); assert_eq!(owned, Some(~"string")); } + + #[test] + fn test_maybe_owned_traits() { + let s = Slice("abcde"); + assert_eq!(s.len(), 5); + assert_eq!(s.as_slice(), "abcde"); + assert_eq!(s.to_str(), ~"abcde"); + assert!(s.lt(&Owned(~"bcdef"))); + assert_eq!(Slice(""), Default::default()); + + let o = Owned(~"abcde"); + assert_eq!(o.len(), 5); + assert_eq!(o.as_slice(), "abcde"); + assert_eq!(o.to_str(), ~"abcde"); + assert!(o.lt(&Slice("bcdef"))); + assert_eq!(Owned(~""), Default::default()); + + assert_eq!(s.cmp(&o), Equal); + assert!(s.equals(&o)); + assert!(s.equiv(&o)); + + assert_eq!(o.cmp(&s), Equal); + assert!(o.equals(&s)); + assert!(o.equiv(&s)); + } + + #[test] + fn test_maybe_owned_methods() { + let s = Slice("abcde"); + assert!(s.is_slice()); + assert!(!s.is_owned()); + + let o = Owned(~"abcde"); + assert!(!o.is_slice()); + assert!(o.is_owned()); + } + + #[test] + fn test_maybe_owned_clone() { + assert_eq!(Owned(~"abcde"), Slice("abcde").clone()); + assert_eq!(Owned(~"abcde"), Slice("abcde").deep_clone()); + + assert_eq!(Owned(~"abcde"), Owned(~"abcde").clone()); + assert_eq!(Owned(~"abcde"), Owned(~"abcde").deep_clone()); + + assert_eq!(Slice("abcde"), Slice("abcde").clone()); + assert_eq!(Slice("abcde"), Slice("abcde").deep_clone()); + + assert_eq!(Slice("abcde"), Owned(~"abcde").clone()); + assert_eq!(Slice("abcde"), Owned(~"abcde").deep_clone()); + } + + #[test] + fn test_maybe_owned_into_owned() { + assert_eq!(Slice("abcde").into_owned(), ~"abcde"); + assert_eq!(Owned(~"abcde").into_owned(), ~"abcde"); + } + + #[test] + fn test_into_maybe_owned() { + assert_eq!("abcde".into_maybe_owned(), Slice("abcde")); + assert_eq!((~"abcde").into_maybe_owned(), Slice("abcde")); + assert_eq!("abcde".into_maybe_owned(), Owned(~"abcde")); + assert_eq!((~"abcde").into_maybe_owned(), Owned(~"abcde")); + } } #[cfg(test)] @@ -3993,6 +4368,42 @@ mod bench { } #[bench] + fn from_utf8_lossy_100_ascii(bh: &mut BenchHarness) { + let s = bytes!("Hello there, the quick brown fox jumped over the lazy dog! \ + Lorem ipsum dolor sit amet, consectetur. "); + + assert_eq!(100, s.len()); + bh.iter(|| { + let _ = from_utf8_lossy(s); + }); + } + + #[bench] + fn from_utf8_lossy_100_multibyte(bh: &mut BenchHarness) { + let s = bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰"); + assert_eq!(100, s.len()); + bh.iter(|| { + let _ = from_utf8_lossy(s); + }); + } + + #[bench] + fn from_utf8_lossy_invalid(bh: &mut BenchHarness) { + let s = bytes!("Hello", 0xC0, 0x80, " There", 0xE6, 0x83, " Goodbye"); + bh.iter(|| { + let _ = from_utf8_lossy(s); + }); + } + + #[bench] + fn from_utf8_lossy_100_invalid(bh: &mut BenchHarness) { + let s = ::vec::from_elem(100, 0xF5u8); + bh.iter(|| { + let _ = from_utf8_lossy(s); + }); + } + + #[bench] fn bench_with_capacity(bh: &mut BenchHarness) { bh.iter(|| { let _ = with_capacity(100); diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 078933be78f..921d0feaa8b 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -62,8 +62,7 @@ use option::{None, Some, Option}; use result::{Result, Ok, Err}; use rt::local::Local; use rt::task::Task; -use send_str::{SendStr, IntoSendStr}; -use str::Str; +use str::{Str, SendStr, IntoMaybeOwned}; #[cfg(test)] use any::{AnyOwnExt, AnyRefExt}; #[cfg(test)] use comm::SharedChan; @@ -190,8 +189,8 @@ impl TaskBuilder { /// Name the task-to-be. Currently the name is used for identification /// only in failure messages. - pub fn name<S: IntoSendStr>(&mut self, name: S) { - self.opts.name = Some(name.into_send_str()); + pub fn name<S: IntoMaybeOwned<'static>>(&mut self, name: S) { + self.opts.name = Some(name.into_maybe_owned()); } /** @@ -396,7 +395,7 @@ fn test_static_named_task() { #[test] fn test_send_named_task() { let mut t = task(); - t.name("ada lovelace".into_send_str()); + t.name("ada lovelace".into_maybe_owned()); t.spawn(proc() { with_task_name(|name| { assert!(name.unwrap() == "ada lovelace"); diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index ef0930fabf1..f1c3d7a7a91 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -10,12 +10,16 @@ //! Ordered containers with integer keys, implemented as radix tries (`TrieSet` and `TrieMap` types) -use prelude::*; +use option::{None, Option, Some}; +use container::{Container, Map, Mutable, MutableMap}; +use iter::{Extendable, FromIterator, Iterator}; use mem; use uint; use util::replace; use unstable::intrinsics::init; use vec; +use ptr::RawPtr; +use vec::{ImmutableVector, Items, MutableVector, MutItems, OwnedVector}; // FIXME: #5244: need to manually update the TrieNode constructor static SHIFT: uint = 4; diff --git a/src/libstd/unit.rs b/src/libstd/unit.rs index 786a7f42bb3..3aa3e020500 100644 --- a/src/libstd/unit.rs +++ b/src/libstd/unit.rs @@ -11,7 +11,9 @@ //! Functions for the unit type. #[cfg(not(test))] -use prelude::*; +use default::Default; +#[cfg(not(test))] +use cmp::{Eq, Equal, Ord, Ordering, TotalEq, TotalOrd}; #[cfg(not(test))] impl Eq for () { diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index ca49576ab2d..7ca28711504 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -310,9 +310,6 @@ extern "rust-intrinsic" { pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor); - /// Get the address of the `__morestack` stack growth function. - pub fn morestack_addr() -> *(); - /// Calculates the offset from a pointer. The offset *must* be in-bounds of /// the object, or one-byte-past-the-end. An arithmetic overflow is also /// undefined behaviour. diff --git a/src/libstd/unstable/lang.rs b/src/libstd/unstable/lang.rs index 046d3fc820d..a85f26720bf 100644 --- a/src/libstd/unstable/lang.rs +++ b/src/libstd/unstable/lang.rs @@ -27,11 +27,19 @@ pub fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! { } #[lang="malloc"] +#[cfg(stage0)] #[inline] pub unsafe fn local_malloc(td: *u8, size: uint) -> *u8 { ::rt::local_heap::local_malloc(td, size) } +#[lang="malloc"] +#[cfg(not(stage0))] +#[inline] +pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *u8 { + ::rt::local_heap::local_malloc(drop_glue, size, align) +} + // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from // inside a landing pad may corrupt the state of the exception handler. If a // problem occurs, call exit instead. diff --git a/src/libstd/unstable/mutex.rs b/src/libstd/unstable/mutex.rs index 82957cd93ce..e9df17ef514 100644 --- a/src/libstd/unstable/mutex.rs +++ b/src/libstd/unstable/mutex.rs @@ -153,13 +153,17 @@ mod imp { static __SIZEOF_PTHREAD_MUTEX_T: uint = 40 - 8; #[cfg(target_arch = "x86")] static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8; + #[cfg(target_arch = "arm")] + static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8; #[cfg(target_arch = "x86_64")] static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8; #[cfg(target_arch = "x86")] static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8; + #[cfg(target_arch = "arm")] + static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8; pub struct pthread_mutex_t { - __align: libc::c_long, + __align: libc::c_longlong, size: [u8, ..__SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_cond_t { diff --git a/src/libstd/unstable/raw.rs b/src/libstd/unstable/raw.rs index 63208b3f2d7..98dde95d3b7 100644 --- a/src/libstd/unstable/raw.rs +++ b/src/libstd/unstable/raw.rs @@ -9,9 +9,11 @@ // except according to those terms. use cast; +#[cfg(stage0)] use unstable::intrinsics::TyDesc; /// The representation of a Rust managed box +#[cfg(stage0)] pub struct Box<T> { ref_count: uint, type_desc: *TyDesc, @@ -20,6 +22,16 @@ pub struct Box<T> { data: T } +/// The representation of a Rust managed box +#[cfg(not(stage0))] +pub struct Box<T> { + ref_count: uint, + drop_glue: fn(ptr: *mut u8), + prev: *mut Box<T>, + next: *mut Box<T>, + data: T +} + /// The representation of a Rust vector pub struct Vec<T> { fill: uint, @@ -59,9 +71,6 @@ impl<T> Repr<*Box<T>> for @T {} impl<T> Repr<*Vec<T>> for ~[T] {} impl Repr<*String> for ~str {} -// sure would be nice to have this -// impl<T> Repr<*Vec<T>> for ~[T] {} - #[cfg(test)] mod tests { use super::*; diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index d53c2dceba2..fa5566ecab4 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1812,12 +1812,70 @@ impl<T:Eq> OwnedEqVector<T> for ~[T] { } } +fn insertion_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) { + let len = v.len() as int; + let buf_v = v.as_mut_ptr(); + + // 1 <= i < len; + for i in range(1, len) { + // j satisfies: 0 <= j <= i; + let mut j = i; + unsafe { + // `i` is in bounds. + let read_ptr = buf_v.offset(i) as *T; + + // find where to insert, we need to do strict <, + // rather than <=, to maintain stability. + + // 0 <= j - 1 < len, so .offset(j - 1) is in bounds. + while j > 0 && + compare(&*read_ptr, &*buf_v.offset(j - 1)) == Less { + j -= 1; + } + + // shift everything to the right, to make space to + // insert this value. + + // j + 1 could be `len` (for the last `i`), but in + // that case, `i == j` so we don't copy. The + // `.offset(j)` is always in bounds. + + if i != j { + let tmp = ptr::read_ptr(read_ptr); + ptr::copy_memory(buf_v.offset(j + 1), + buf_v.offset(j), + (i - j) as uint); + ptr::copy_nonoverlapping_memory(buf_v.offset(j), + &tmp as *T, + 1); + cast::forget(tmp); + } + } + } +} + fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) { // warning: this wildly uses unsafe. - static INSERTION: uint = 8; + static BASE_INSERTION: uint = 32; + static LARGE_INSERTION: uint = 16; + + // FIXME #12092: smaller insertion runs seems to make sorting + // vectors of large elements a little faster on some platforms, + // but hasn't been tested/tuned extensively + let insertion = if size_of::<T>() <= 16 { + BASE_INSERTION + } else { + LARGE_INSERTION + }; let len = v.len(); + // short vectors get sorted in-place via insertion sort to avoid allocations + if len <= insertion { + insertion_sort(v, compare); + return; + } + // allocate some memory to use as scratch memory, we keep the // length 0 so we can keep shallow copies of the contents of `v` // without risking the dtors running on an object twice if @@ -1837,9 +1895,9 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) { // We could hardcode the sorting comparisons here, and we could // manipulate/step the pointers themselves, rather than repeatedly // .offset-ing. - for start in range_step(0, len, INSERTION) { - // start <= i <= len; - for i in range(start, cmp::min(start + INSERTION, len)) { + for start in range_step(0, len, insertion) { + // start <= i < len; + for i in range(start, cmp::min(start + insertion, len)) { // j satisfies: start <= j <= i; let mut j = i as int; unsafe { @@ -1871,7 +1929,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) { } // step 2. merge the sorted runs. - let mut width = INSERTION; + let mut width = insertion; while width < len { // merge the sorted runs of length `width` in `buf_dat` two at // a time, placing the result in `buf_tmp`. @@ -4505,4 +4563,45 @@ mod bench { }); bh.bytes = (v.len() * mem::size_of_val(&v[0])) as u64; } + + type BigSortable = (u64,u64,u64,u64); + + #[bench] + fn sort_big_random_small(bh: &mut BenchHarness) { + let mut rng = weak_rng(); + bh.iter(|| { + let mut v: ~[BigSortable] = rng.gen_vec(5); + v.sort(); + }); + bh.bytes = 5 * mem::size_of::<BigSortable>() as u64; + } + + #[bench] + fn sort_big_random_medium(bh: &mut BenchHarness) { + let mut rng = weak_rng(); + bh.iter(|| { + let mut v: ~[BigSortable] = rng.gen_vec(100); + v.sort(); + }); + bh.bytes = 100 * mem::size_of::<BigSortable>() as u64; + } + + #[bench] + fn sort_big_random_large(bh: &mut BenchHarness) { + let mut rng = weak_rng(); + bh.iter(|| { + let mut v: ~[BigSortable] = rng.gen_vec(10000); + v.sort(); + }); + bh.bytes = 10000 * mem::size_of::<BigSortable>() as u64; + } + + #[bench] + fn sort_big_sorted(bh: &mut BenchHarness) { + let mut v = vec::from_fn(10000u, |i| (i, i, i, i)); + bh.iter(|| { + v.sort(); + }); + bh.bytes = (v.len() * mem::size_of_val(&v[0])) as u64; + } } diff --git a/src/libstd/vec_ng.rs b/src/libstd/vec_ng.rs index e503497d95d..c49a7302e72 100644 --- a/src/libstd/vec_ng.rs +++ b/src/libstd/vec_ng.rs @@ -11,12 +11,16 @@ // Migrate documentation over from `std::vec` when it is removed. #[doc(hidden)]; -use prelude::*; +use ops::Drop; +use option::{None, Option, Some}; +use clone::Clone; +use iter::{DoubleEndedIterator, Iterator}; +use num::CheckedMul; use container::Container; use mem::size_of; use cast::{forget, transmute}; use rt::global_heap::{malloc_raw, realloc_raw}; -use vec::Items; +use vec::{ImmutableVector, Items, MutableVector}; use unstable::raw::Slice; use ptr::{offset, read_ptr}; use libc::{free, c_void}; diff --git a/src/libsync/lib.rs b/src/libsync/lib.rs index de1b0f91d6d..d96685c7f55 100644 --- a/src/libsync/lib.rs +++ b/src/libsync/lib.rs @@ -17,7 +17,7 @@ #[crate_type = "dylib"]; #[license = "MIT/ASL2"]; -pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, Condvar}; +pub use arc::{Arc, MutexArc, RWArc, RWWriteMode, RWReadMode, Condvar, CowArc}; pub use sync::{Mutex, RWLock, Condvar, Semaphore, RWLockWriteMode, RWLockReadMode, Barrier, one, mutex}; pub use comm::{DuplexStream, SyncChan, SyncPort, rendezvous}; diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 9194acfcdec..6b0f2c6e516 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -323,7 +323,7 @@ fn cannot_combine(n: Abi, m: Abi) { (m == a && n == b)); } None => { - fail!("Invalid match not detected"); + fail!("invalid match not detected"); } } } @@ -335,7 +335,7 @@ fn can_combine(n: Abi, m: Abi) { set.add(m); match set.check_valid() { Some((_, _)) => { - fail!("Valid match declared invalid"); + fail!("valid match declared invalid"); } None => {} } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index abfd119acbb..ca876054fa8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -964,7 +964,6 @@ pub enum ExplicitSelf_ { SelfStatic, // no self SelfValue, // `self` SelfRegion(Option<Lifetime>, Mutability), // `&'lt self`, `&'lt mut self` - SelfBox, // `@self` SelfUniq // `~self` } @@ -1064,8 +1063,8 @@ pub struct ViewItem { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum ViewItem_ { // ident: name used to refer to this crate in the code - // optional @str: if present, this is a location (containing - // arbitrary characters) from which to fetch the crate sources + // optional (InternedString,StrStyle): if present, this is a location + // (containing arbitrary characters) from which to fetch the crate sources // For example, extern mod whatever = "github.com/mozilla/rust" ViewItemExternMod(Ident, Option<(InternedString,StrStyle)>, NodeId), ViewItemUse(~[@ViewPath]), @@ -1231,6 +1230,6 @@ mod test { }, }; // doesn't matter which encoder we use.... - let _f = (@e as @serialize::Encodable<extra::json::Encoder>); + let _f = (&e as &serialize::Encodable<extra::json::Encoder>); } } diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 89209ab2104..817668f2232 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -22,7 +22,7 @@ use util::small_vector::SmallVector; use std::logging; use std::cell::RefCell; -use extra::smallintmap::SmallIntMap; +use collections::SmallIntMap; #[deriving(Clone, Eq)] pub enum PathElem { diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 5b3b436a6fc..3f6540570b0 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -24,10 +24,8 @@ static BUG_REPORT_URL: &'static str = static MAX_LINES: uint = 6u; pub trait Emitter { - fn emit(&self, - cmsp: Option<(&codemap::CodeMap, Span)>, - msg: &str, - lvl: Level); + fn emit(&self, cmsp: Option<(&codemap::CodeMap, Span)>, + msg: &str, lvl: Level); fn custom_emit(&self, cm: &codemap::CodeMap, sp: Span, msg: &str, lvl: Level); } @@ -46,30 +44,30 @@ pub struct SpanHandler { } impl SpanHandler { - pub fn span_fatal(@self, sp: Span, msg: &str) -> ! { + pub fn span_fatal(&self, sp: Span, msg: &str) -> ! { self.handler.emit(Some((&*self.cm, sp)), msg, Fatal); fail!(FatalError); } - pub fn span_err(@self, sp: Span, msg: &str) { + pub fn span_err(&self, sp: Span, msg: &str) { self.handler.emit(Some((&*self.cm, sp)), msg, Error); self.handler.bump_err_count(); } - pub fn span_warn(@self, sp: Span, msg: &str) { + pub fn span_warn(&self, sp: Span, msg: &str) { self.handler.emit(Some((&*self.cm, sp)), msg, Warning); } - pub fn span_note(@self, sp: Span, msg: &str) { + pub fn span_note(&self, sp: Span, msg: &str) { self.handler.emit(Some((&*self.cm, sp)), msg, Note); } - pub fn span_end_note(@self, sp: Span, msg: &str) { + pub fn span_end_note(&self, sp: Span, msg: &str) { self.handler.custom_emit(&*self.cm, sp, msg, Note); } - pub fn span_bug(@self, sp: Span, msg: &str) -> ! { + pub fn span_bug(&self, sp: Span, msg: &str) -> ! { self.span_fatal(sp, ice_msg(msg)); } - pub fn span_unimpl(@self, sp: Span, msg: &str) -> ! { + pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! { self.span_bug(sp, ~"unimplemented " + msg); } - pub fn handler(@self) -> @Handler { + pub fn handler(&self) -> @Handler { self.handler } } @@ -79,28 +77,28 @@ impl SpanHandler { // others log errors for later reporting. pub struct Handler { err_count: Cell<uint>, - emit: @Emitter, + emit: DefaultEmitter, } impl Handler { - pub fn fatal(@self, msg: &str) -> ! { + pub fn fatal(&self, msg: &str) -> ! { self.emit.emit(None, msg, Fatal); fail!(FatalError); } - pub fn err(@self, msg: &str) { + pub fn err(&self, msg: &str) { self.emit.emit(None, msg, Error); self.bump_err_count(); } - pub fn bump_err_count(@self) { + pub fn bump_err_count(&self) { self.err_count.set(self.err_count.get() + 1u); } - pub fn err_count(@self) -> uint { + pub fn err_count(&self) -> uint { self.err_count.get() } - pub fn has_errors(@self) -> bool { + pub fn has_errors(&self) -> bool { self.err_count.get()> 0u } - pub fn abort_if_errors(@self) { + pub fn abort_if_errors(&self) { let s; match self.err_count.get() { 0u => return, @@ -112,25 +110,25 @@ impl Handler { } self.fatal(s); } - pub fn warn(@self, msg: &str) { + pub fn warn(&self, msg: &str) { self.emit.emit(None, msg, Warning); } - pub fn note(@self, msg: &str) { + pub fn note(&self, msg: &str) { self.emit.emit(None, msg, Note); } - pub fn bug(@self, msg: &str) -> ! { + pub fn bug(&self, msg: &str) -> ! { self.fatal(ice_msg(msg)); } - pub fn unimpl(@self, msg: &str) -> ! { + pub fn unimpl(&self, msg: &str) -> ! { self.bug(~"unimplemented " + msg); } - pub fn emit(@self, - cmsp: Option<(&codemap::CodeMap, Span)>, - msg: &str, - lvl: Level) { + pub fn emit(&self, + cmsp: Option<(&codemap::CodeMap, Span)>, + msg: &str, + lvl: Level) { self.emit.emit(cmsp, msg, lvl); } - pub fn custom_emit(@self, cm: &codemap::CodeMap, + pub fn custom_emit(&self, cm: &codemap::CodeMap, sp: Span, msg: &str, lvl: Level) { self.emit.custom_emit(cm, sp, msg, lvl); } @@ -149,15 +147,10 @@ pub fn mk_span_handler(handler: @Handler, cm: @codemap::CodeMap) } } -pub fn mk_handler(emitter: Option<@Emitter>) -> @Handler { - let emit: @Emitter = match emitter { - Some(e) => e, - None => @DefaultEmitter as @Emitter - }; - +pub fn mk_handler() -> @Handler { @Handler { err_count: Cell::new(0), - emit: emit, + emit: DefaultEmitter, } } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 08098b71ce4..848f4ba3871 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -36,7 +36,7 @@ pub struct MacroDef { } pub type ItemDecorator = - fn(&ExtCtxt, Span, @ast::MetaItem, ~[@ast::Item]) -> ~[@ast::Item]; + fn(&mut ExtCtxt, Span, @ast::MetaItem, ~[@ast::Item]) -> ~[@ast::Item]; pub struct BasicMacroExpander { expander: MacroExpanderFn, @@ -105,7 +105,7 @@ pub trait AnyMacro { pub enum MacResult { MRExpr(@ast::Expr), MRItem(@ast::Item), - MRAny(@AnyMacro), + MRAny(~AnyMacro:), MRDef(MacroDef), } impl MacResult { diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index c5ee1948466..e41decbd8ef 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -56,7 +56,6 @@ pub trait AstBuilder { lifetime: Option<ast::Lifetime>, mutbl: ast::Mutability) -> P<ast::Ty>; fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>; - fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>; fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>; fn ty_infer(&self, sp: Span) -> P<ast::Ty>; @@ -329,10 +328,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.ty(span, ast::TyUniq(ty)) } - fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> { - self.ty(span, ast::TyBox(ty)) - } - fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> { self.ty_path( self.path_all(DUMMY_SP, diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 6852a0cec33..39bb870b969 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -40,7 +40,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> // u8 literal, push to vector expression ast::LitUint(v, ast::TyU8) => { if v > 0xFF { - cx.span_err(expr.span, "Too large u8 literal in bytes!") + cx.span_err(expr.span, "too large u8 literal in bytes!") } else { bytes.push(cx.expr_u8(expr.span, v as u8)); } @@ -49,9 +49,9 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> // integer literal, push to vector expression ast::LitIntUnsuffixed(v) => { if v > 0xFF { - cx.span_err(expr.span, "Too large integer literal in bytes!") + cx.span_err(expr.span, "too large integer literal in bytes!") } else if v < 0 { - cx.span_err(expr.span, "Negative integer literal in bytes!") + cx.span_err(expr.span, "negative integer literal in bytes!") } else { bytes.push(cx.expr_u8(expr.span, v as u8)); } @@ -62,14 +62,14 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> if char::from_u32(v).unwrap().is_ascii() { bytes.push(cx.expr_u8(expr.span, v as u8)); } else { - cx.span_err(expr.span, "Non-ascii char literal in bytes!") + cx.span_err(expr.span, "non-ascii char literal in bytes!") } } - _ => cx.span_err(expr.span, "Unsupported literal in bytes!") + _ => cx.span_err(expr.span, "unsupported literal in bytes!") }, - _ => cx.span_err(expr.span, "Non-literal in bytes!") + _ => cx.span_err(expr.span, "non-literal in bytes!") } } diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 567b89d3453..d911208e7de 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_clone(cx: &ExtCtxt, +pub fn expand_deriving_clone(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) @@ -42,7 +42,7 @@ pub fn expand_deriving_clone(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -pub fn expand_deriving_deep_clone(cx: &ExtCtxt, +pub fn expand_deriving_deep_clone(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) @@ -74,7 +74,7 @@ pub fn expand_deriving_deep_clone(cx: &ExtCtxt, fn cs_clone( name: &str, - cx: &ExtCtxt, trait_span: Span, + cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let clone_ident = substr.method_ident; let ctor_ident; @@ -92,10 +92,10 @@ fn cs_clone( all_fields = af; }, EnumNonMatching(..) => cx.span_bug(trait_span, - format!("Non-matching enum variants in `deriving({})`", + format!("non-matching enum variants in `deriving({})`", name)), StaticEnum(..) | StaticStruct(..) => cx.span_bug(trait_span, - format!("Static method in `deriving({})`", + format!("static method in `deriving({})`", name)) } diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 99b5163214a..a469c4a960b 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -14,17 +14,17 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_eq(cx: &ExtCtxt, +pub fn expand_deriving_eq(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) -> ~[@Item] { // structures are equal if all fields are equal, and non equal, if // any fields are not equal or if the enum variants are different - fn cs_eq(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_and(|cx, span, _, _| cx.expr_bool(span, false), cx, span, substr) } - fn cs_ne(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_or(|cx, span, _, _| cx.expr_bool(span, true), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index 5a02d8eead8..c06b4e30e07 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -15,7 +15,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_ord(cx: &ExtCtxt, +pub fn expand_deriving_ord(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) -> ~[@Item] { @@ -51,7 +51,7 @@ pub fn expand_deriving_ord(cx: &ExtCtxt, } /// Strict inequality. -fn cs_op(less: bool, equal: bool, cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let op = if less {ast::BiLt} else {ast::BiGt}; cs_fold( false, // need foldr, @@ -75,7 +75,7 @@ fn cs_op(less: bool, equal: bool, cx: &ExtCtxt, span: Span, substr: &Substructur */ let other_f = match other_fs { [o_f] => o_f, - _ => cx.span_bug(span, "Not exactly 2 arguments in `deriving(Ord)`") + _ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`") }; let cmp = cx.expr_binary(span, op, self_f, other_f); @@ -99,7 +99,7 @@ fn cs_op(less: bool, equal: bool, cx: &ExtCtxt, span: Span, substr: &Substructur } else { self_var > other_var }), - _ => cx.span_bug(span, "Not exactly 2 arguments in `deriving(Ord)`") + _ => cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`") } }, cx, span, substr) diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 6a1aaeb2f9e..0a38a2ce30d 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -14,11 +14,11 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_totaleq(cx: &ExtCtxt, +pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) -> ~[@Item] { - fn cs_equals(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + fn cs_equals(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_and(|cx, span, _, _| cx.expr_bool(span, false), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index f1e360f20ba..68de158e9e7 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -16,7 +16,7 @@ use ext::build::AstBuilder; use ext::deriving::generic::*; use std::cmp::{Ordering, Equal, Less, Greater}; -pub fn expand_deriving_totalord(cx: &ExtCtxt, +pub fn expand_deriving_totalord(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) -> ~[@Item] { @@ -44,7 +44,7 @@ pub fn expand_deriving_totalord(cx: &ExtCtxt, } -pub fn ordering_const(cx: &ExtCtxt, span: Span, cnst: Ordering) -> ast::Path { +pub fn ordering_const(cx: &mut ExtCtxt, span: Span, cnst: Ordering) -> ast::Path { let cnst = match cnst { Less => "Less", Equal => "Equal", @@ -56,7 +56,7 @@ pub fn ordering_const(cx: &ExtCtxt, span: Span, cnst: Ordering) -> ast::Path { cx.ident_of(cnst)]) } -pub fn cs_cmp(cx: &ExtCtxt, span: Span, +pub fn cs_cmp(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let test_id = cx.ident_of("__test"); let equals_path = ordering_const(cx, span, Equal); @@ -106,9 +106,11 @@ pub fn cs_cmp(cx: &ExtCtxt, span: Span, // an earlier nonmatching variant is Less than a // later one. [(self_var, _, _), - (other_var, _, _)] => cx.expr_path(ordering_const(cx, span, - self_var.cmp(&other_var))), - _ => cx.span_bug(span, "Not exactly 2 arguments in `deriving(TotalOrd)`") + (other_var, _, _)] => { + let order = ordering_const(cx, span, self_var.cmp(&other_var)); + cx.expr_path(order) + } + _ => cx.span_bug(span, "not exactly 2 arguments in `deriving(TotalOrd)`") } }, cx, span, substr) diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index ad7b3a2e950..7324500a8a0 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -21,7 +21,7 @@ use ext::deriving::generic::*; use parse::token::InternedString; use parse::token; -pub fn expand_deriving_decodable(cx: &ExtCtxt, +pub fn expand_deriving_decodable(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) -> ~[@Item] { @@ -53,7 +53,7 @@ pub fn expand_deriving_decodable(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -fn decodable_substructure(cx: &ExtCtxt, trait_span: Span, +fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let decoder = substr.nonself_args[0]; let recurse = ~[cx.ident_of("serialize"), @@ -77,7 +77,7 @@ fn decodable_substructure(cx: &ExtCtxt, trait_span: Span, trait_span, substr.type_ident, summary, - |span, name, field| { + |cx, span, name, field| { cx.expr_method_call(span, blkdecoder, read_struct_field, ~[cx.expr_str(span, name), cx.expr_uint(span, field), @@ -108,10 +108,10 @@ fn decodable_substructure(cx: &ExtCtxt, trait_span: Span, v_span, name, parts, - |span, _, field| { + |cx, span, _, field| { + let idx = cx.expr_uint(span, field); cx.expr_method_call(span, blkdecoder, rvariant_arg, - ~[cx.expr_uint(span, field), - lambdadecode]) + ~[idx, lambdadecode]) }); arms.push(cx.arm(v_span, @@ -143,11 +143,11 @@ fn decodable_substructure(cx: &ExtCtxt, trait_span: Span, /// Create a decoder for a single enum variant/struct: /// - `outer_pat_ident` is the name of this enum variant/struct /// - `getarg` should retrieve the `uint`-th field with name `@str`. -fn decode_static_fields(cx: &ExtCtxt, +fn decode_static_fields(cx: &mut ExtCtxt, trait_span: Span, outer_pat_ident: Ident, fields: &StaticFields, - getarg: |Span, InternedString, uint| -> @Expr) + getarg: |&mut ExtCtxt, Span, InternedString, uint| -> @Expr) -> @Expr { match *fields { Unnamed(ref fields) => { @@ -155,7 +155,7 @@ fn decode_static_fields(cx: &ExtCtxt, cx.expr_ident(trait_span, outer_pat_ident) } else { let fields = fields.iter().enumerate().map(|(i, &span)| { - getarg(span, + getarg(cx, span, token::intern_and_get_ident(format!("_field{}", i)), i) @@ -167,9 +167,8 @@ fn decode_static_fields(cx: &ExtCtxt, Named(ref fields) => { // use the field's span to get nicer error messages. let fields = fields.iter().enumerate().map(|(i, &(name, span))| { - cx.field_imm(span, - name, - getarg(span, token::get_ident(name.name), i)) + let arg = getarg(cx, span, token::get_ident(name.name), i); + cx.field_imm(span, name, arg) }).collect(); cx.expr_struct_ident(trait_span, outer_pat_ident, fields) } diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index 22f850d5609..922ee164353 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_default(cx: &ExtCtxt, +pub fn expand_deriving_default(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) @@ -41,7 +41,7 @@ pub fn expand_deriving_default(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -fn default_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { +fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let default_ident = ~[ cx.ident_of("std"), cx.ident_of("default"), diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 66b744ecbcb..4de31adc7f2 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -75,14 +75,14 @@ would yield functions like: } */ -use ast::{MetaItem, Item, Expr, MutImmutable, MutMutable}; +use ast::{MetaItem, Item, Expr, MutMutable}; use codemap::Span; use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; use parse::token; -pub fn expand_deriving_encodable(cx: &ExtCtxt, +pub fn expand_deriving_encodable(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) -> ~[@Item] { @@ -100,7 +100,7 @@ pub fn expand_deriving_encodable(cx: &ExtCtxt, MethodDef { name: "encode", generics: LifetimeBounds::empty(), - explicit_self: Some(Some(Borrowed(None, MutImmutable))), + explicit_self: borrowed_explicit_self(), args: ~[Ptr(~Literal(Path::new_local("__E")), Borrowed(None, MutMutable))], ret_ty: nil_ty(), @@ -114,7 +114,7 @@ pub fn expand_deriving_encodable(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -fn encodable_substructure(cx: &ExtCtxt, trait_span: Span, +fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let encoder = substr.nonself_args[0]; // throw an underscore in front to suppress unused variable warnings diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 992ee3175ed..01006a0c15d 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -194,7 +194,7 @@ mod ty; pub struct TraitDef<'a> { /// The extension context - cx: &'a ExtCtxt<'a>, + cx: &'a mut ExtCtxt<'a>, /// The span for the current #[deriving(Foo)] header. span: Span, @@ -304,7 +304,7 @@ Combine the values of all the fields together. The last argument is all the fields of all the structures, see above for details. */ pub type CombineSubstructureFunc<'a> = - 'a |&ExtCtxt, Span, &Substructure| -> @Expr; + 'a |&mut ExtCtxt, Span, &Substructure| -> @Expr; /** Deal with non-matching enum variants, the arguments are a list @@ -312,7 +312,7 @@ representing each variant: (variant index, ast::Variant instance, [variant fields]), and a list of the nonself args of the type */ pub type EnumNonMatchFunc<'a> = - 'a |&ExtCtxt, + 'a |&mut ExtCtxt, Span, &[(uint, P<ast::Variant>, ~[(Span, Option<Ident>, @Expr)])], &[@Expr]| @@ -356,7 +356,7 @@ impl<'a> TraitDef<'a> { fn create_derived_impl(&self, type_ident: Ident, generics: &Generics, methods: ~[@ast::Method]) -> @ast::Item { - let cx = self.cx; + let cx = &*self.cx; let trait_path = self.path.to_path(cx, self.span, type_ident, generics); let mut trait_generics = self.generics.to_generics(cx, self.span, @@ -656,7 +656,7 @@ impl<'a> MethodDef<'a> { }).collect() } [] => { trait_.cx.span_bug(trait_.span, - "No self arguments to non-static method \ + "no self arguments to non-static method \ in generic `deriving`") } }; @@ -764,7 +764,7 @@ impl<'a> MethodDef<'a> { matches_so_far: &mut ~[(uint, P<ast::Variant>, ~[(Span, Option<Ident>, @Expr)])], match_count: uint) -> @Expr { - let cx = trait_.cx; + let cx = &trait_.cx; if match_count == self_args.len() { // we've matched against all arguments, so make the final // expression at the bottom of the match tree @@ -840,7 +840,7 @@ impl<'a> MethodDef<'a> { let index = match matching { Some(i) => i, None => cx.span_bug(trait_.span, - "Non-matching variants when required to \ + "non-matching variants when required to \ be matching in generic `deriving`") }; @@ -965,7 +965,7 @@ impl<'a> TraitDef<'a> { match (just_spans.is_empty(), named_idents.is_empty()) { (false, false) => self.cx.span_bug(self.span, - "A struct with named and unnamed \ + "a struct with named and unnamed \ fields in generic `deriving`"), // named fields (_, false) => Named(named_idents), @@ -990,7 +990,7 @@ impl<'a> TraitDef<'a> { prefix: &str, mutbl: ast::Mutability) -> (@ast::Pat, ~[(Span, Option<Ident>, @Expr)]) { - let cx = self.cx; + let cx = &self.cx; if struct_def.fields.is_empty() { return ( @@ -1019,7 +1019,7 @@ impl<'a> TraitDef<'a> { None } _ => { - cx.span_bug(sp, "A struct with named and unnamed fields in `deriving`"); + cx.span_bug(sp, "a struct with named and unnamed fields in `deriving`"); } }; let path = cx.path_ident(sp, cx.ident_of(format!("{}_{}", prefix, i))); @@ -1050,7 +1050,7 @@ impl<'a> TraitDef<'a> { prefix: &str, mutbl: ast::Mutability) -> (@ast::Pat, ~[(Span, Option<Ident>, @Expr)]) { - let cx = self.cx; + let cx = &*self.cx; let variant_ident = variant.node.name; match variant.node.kind { ast::TupleVariantKind(ref variant_args) => { @@ -1093,10 +1093,10 @@ Fold the fields. `use_foldl` controls whether this is done left-to-right (`true`) or right-to-left (`false`). */ pub fn cs_fold(use_foldl: bool, - f: |&ExtCtxt, Span, @Expr, @Expr, &[@Expr]| -> @Expr, + f: |&mut ExtCtxt, Span, @Expr, @Expr, &[@Expr]| -> @Expr, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: &ExtCtxt, + cx: &mut ExtCtxt, trait_span: Span, substructure: &Substructure) -> @Expr { @@ -1116,7 +1116,7 @@ pub fn cs_fold(use_foldl: bool, *all_enums, substructure.nonself_args), StaticEnum(..) | StaticStruct(..) => { - cx.span_bug(trait_span, "Static function in `deriving`") + cx.span_bug(trait_span, "static function in `deriving`") } } } @@ -1132,9 +1132,9 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1), ~~~ */ #[inline] -pub fn cs_same_method(f: |&ExtCtxt, Span, ~[@Expr]| -> @Expr, +pub fn cs_same_method(f: |&mut ExtCtxt, Span, ~[@Expr]| -> @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: &ExtCtxt, + cx: &mut ExtCtxt, trait_span: Span, substructure: &Substructure) -> @Expr { @@ -1154,7 +1154,7 @@ pub fn cs_same_method(f: |&ExtCtxt, Span, ~[@Expr]| -> @Expr, *all_enums, substructure.nonself_args), StaticEnum(..) | StaticStruct(..) => { - cx.span_bug(trait_span, "Static function in `deriving`") + cx.span_bug(trait_span, "static function in `deriving`") } } } @@ -1166,10 +1166,10 @@ fields. `use_foldl` controls whether this is done left-to-right */ #[inline] pub fn cs_same_method_fold(use_foldl: bool, - f: |&ExtCtxt, Span, @Expr, @Expr| -> @Expr, + f: |&mut ExtCtxt, Span, @Expr, @Expr| -> @Expr, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: &ExtCtxt, + cx: &mut ExtCtxt, trait_span: Span, substructure: &Substructure) -> @Expr { @@ -1196,7 +1196,7 @@ on all the fields. #[inline] pub fn cs_binop(binop: ast::BinOp, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: &ExtCtxt, trait_span: Span, + cx: &mut ExtCtxt, trait_span: Span, substructure: &Substructure) -> @Expr { cs_same_method_fold( true, // foldl is good enough @@ -1214,7 +1214,7 @@ pub fn cs_binop(binop: ast::BinOp, base: @Expr, /// cs_binop with binop == or #[inline] pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, - cx: &ExtCtxt, span: Span, + cx: &mut ExtCtxt, span: Span, substructure: &Substructure) -> @Expr { cs_binop(ast::BiOr, cx.expr_bool(span, false), enum_nonmatch_f, @@ -1224,7 +1224,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, /// cs_binop with binop == and #[inline] pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc, - cx: &ExtCtxt, span: Span, + cx: &mut ExtCtxt, span: Span, substructure: &Substructure) -> @Expr { cs_binop(ast::BiAnd, cx.expr_bool(span, true), enum_nonmatch_f, diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs index d82e1ef1842..5f680745ea7 100644 --- a/src/libsyntax/ext/deriving/iter_bytes.rs +++ b/src/libsyntax/ext/deriving/iter_bytes.rs @@ -15,7 +15,7 @@ use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_iter_bytes(cx: &ExtCtxt, +pub fn expand_deriving_iter_bytes(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) -> ~[@Item] { @@ -45,10 +45,10 @@ pub fn expand_deriving_iter_bytes(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -fn iter_bytes_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { +fn iter_bytes_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let (lsb0, f)= match substr.nonself_args { [l, f] => (l, f), - _ => cx.span_bug(trait_span, "Incorrect number of arguments in `deriving(IterBytes)`") + _ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(IterBytes)`") }; // Build the "explicitly borrowed" stack closure, "|_buf| f(_buf)". let blk_arg = cx.ident_of("_buf"); @@ -82,7 +82,7 @@ fn iter_bytes_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure fields = fs; } - _ => cx.span_bug(trait_span, "Impossible substructure in `deriving(IterBytes)`") + _ => cx.span_bug(trait_span, "impossible substructure in `deriving(IterBytes)`") } for &FieldInfo { self_, span, .. } in fields.iter() { diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index 9c487146639..01e31fc5724 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -18,8 +18,7 @@ library. */ -use ast::{EnumDef, Ident, Item, Generics, StructDef}; -use ast::{MetaItem, MetaList, MetaNameValue, MetaWord}; +use ast::{Item, MetaItem, MetaList, MetaNameValue, MetaWord}; use ext::base::ExtCtxt; use codemap::Span; @@ -29,6 +28,7 @@ pub mod encodable; pub mod decodable; pub mod rand; pub mod to_str; +pub mod show; pub mod zero; pub mod default; pub mod primitive; @@ -45,20 +45,7 @@ pub mod totalord; pub mod generic; -pub type ExpandDerivingStructDefFn<'a> = 'a |&ExtCtxt, - Span, - x: &StructDef, - Ident, - y: &Generics| - -> @Item; -pub type ExpandDerivingEnumDefFn<'a> = 'a |&ExtCtxt, - Span, - x: &EnumDef, - Ident, - y: &Generics| - -> @Item; - -pub fn expand_meta_deriving(cx: &ExtCtxt, +pub fn expand_meta_deriving(cx: &mut ExtCtxt, _span: Span, mitem: @MetaItem, in_items: ~[@Item]) @@ -97,6 +84,7 @@ pub fn expand_meta_deriving(cx: &ExtCtxt, "Rand" => expand!(rand::expand_deriving_rand), "ToStr" => expand!(to_str::expand_deriving_to_str), + "Show" => expand!(show::expand_deriving_show), "Zero" => expand!(zero::expand_deriving_zero), "Default" => expand!(default::expand_deriving_default), diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index e2f72e87085..f74b807bae6 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -16,7 +16,7 @@ use ext::build::AstBuilder; use ext::deriving::generic::*; use parse::token::InternedString; -pub fn expand_deriving_from_primitive(cx: &ExtCtxt, +pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) -> ~[@Item] { @@ -65,10 +65,10 @@ pub fn expand_deriving_from_primitive(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -fn cs_from(name: &str, cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { +fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let n = match substr.nonself_args { [n] => n, - _ => cx.span_bug(trait_span, "Incorrect number of arguments in `deriving(FromPrimitive)`") + _ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(FromPrimitive)`") }; match *substr.fields { diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index a22822c2ddc..15595f6eddc 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -16,7 +16,7 @@ use ext::build::{AstBuilder}; use ext::deriving::generic::*; use opt_vec; -pub fn expand_deriving_rand(cx: &ExtCtxt, +pub fn expand_deriving_rand(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) @@ -50,7 +50,7 @@ pub fn expand_deriving_rand(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -fn rand_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { +fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let rng = match substr.nonself_args { [rng] => ~[ rng ], _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`") @@ -112,9 +112,8 @@ fn rand_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @ let i_expr = cx.expr_uint(v_span, i); let pat = cx.pat_lit(v_span, i_expr); - cx.arm(v_span, - ~[ pat ], - rand_thing(cx, v_span, ident, summary, |sp| rand_call(sp))) + let thing = rand_thing(cx, v_span, ident, summary, |sp| rand_call(sp)); + cx.arm(v_span, ~[ pat ], thing) }).collect::<~[ast::Arm]>(); // _ => {} at the end. Should never occur @@ -128,7 +127,7 @@ fn rand_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @ _ => cx.bug("Non-static method in `deriving(Rand)`") }; - fn rand_thing(cx: &ExtCtxt, + fn rand_thing(cx: &mut ExtCtxt, trait_span: Span, ctor_ident: Ident, summary: &StaticFields, diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs new file mode 100644 index 00000000000..67cfd151f62 --- /dev/null +++ b/src/libsyntax/ext/deriving/show.rs @@ -0,0 +1,138 @@ +// 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. + +use ast; +use ast::{MetaItem, Item, Expr}; +use codemap::Span; +use ext::format; +use ext::base::ExtCtxt; +use ext::build::AstBuilder; +use ext::deriving::generic::*; + +use parse::token; + +use std::hashmap::HashMap; + +pub fn expand_deriving_show(cx: &mut ExtCtxt, + span: Span, + mitem: @MetaItem, + in_items: ~[@Item]) + -> ~[@Item] { + // &mut ::std::fmt::Formatter + let fmtr = Ptr(~Literal(Path::new(~["std", "fmt", "Formatter"])), + Borrowed(None, ast::MutMutable)); + + let trait_def = TraitDef { + cx: cx, span: span, + + path: Path::new(~["std", "fmt", "Show"]), + additional_bounds: ~[], + generics: LifetimeBounds::empty(), + methods: ~[ + MethodDef { + name: "fmt", + generics: LifetimeBounds::empty(), + explicit_self: borrowed_explicit_self(), + args: ~[fmtr], + ret_ty: Literal(Path::new(~["std", "fmt", "Result"])), + inline: false, + const_nonmatching: false, + combine_substructure: show_substructure + } + ] + }; + trait_def.expand(mitem, in_items) +} + +// we construct a format string and then defer to std::fmt, since that +// knows what's up with formatting at so on. +fn show_substructure(cx: &mut ExtCtxt, span: Span, + substr: &Substructure) -> @Expr { + // build `<name>`, `<name>({}, {}, ...)` or `<name> { <field>: {}, + // <field>: {}, ... }` based on the "shape". + // + // Easy start: they all start with the name. + let name = match *substr.fields { + Struct(_) => substr.type_ident, + EnumMatching(_, v, _) => v.node.name, + + EnumNonMatching(..) | StaticStruct(..) | StaticEnum(..) => { + cx.span_bug(span, "nonsensical .fields in `#[deriving(Show)]`") + } + }; + + let mut format_string = token::get_ident(name.name).get().to_owned(); + // the internal fields we're actually formatting + let mut exprs = ~[]; + + // Getting harder... making the format string: + match *substr.fields { + // unit struct/nullary variant: no work necessary! + Struct([]) | EnumMatching(_, _, []) => {} + + Struct(ref fields) | EnumMatching(_, _, ref fields) => { + if fields[0].name.is_none() { + // tuple struct/"normal" variant + + format_string.push_str("("); + + for (i, field) in fields.iter().enumerate() { + if i != 0 { format_string.push_str(", "); } + + format_string.push_str("{}"); + + exprs.push(field.self_); + } + + format_string.push_str(")"); + } else { + // normal struct/struct variant + + format_string.push_str(" \\{"); + + for (i, field) in fields.iter().enumerate() { + if i != 0 { format_string.push_str(","); } + + let name = token::get_ident(field.name.unwrap().name); + format_string.push_str(" "); + format_string.push_str(name.get()); + format_string.push_str(": {}"); + + exprs.push(field.self_); + } + + format_string.push_str(" \\}"); + } + } + _ => unreachable!() + } + + // AST construction! + // we're basically calling + // + // format_arg!(|__args| ::std::fmt::write(fmt.buf, __args), "<format_string>", exprs...) + // + // but doing it directly via ext::format. + let formatter = substr.nonself_args[0]; + let buf = cx.expr_field_access(span, formatter, cx.ident_of("buf")); + + let std_write = ~[cx.ident_of("std"), cx.ident_of("fmt"), cx.ident_of("write")]; + let args = cx.ident_of("__args"); + let write_call = cx.expr_call_global(span, std_write, ~[buf, cx.expr_ident(span, args)]); + let format_closure = cx.lambda_expr(span, ~[args], write_call); + + let s = token::intern_and_get_ident(format_string); + let format_string = cx.expr_str(span, s); + + // phew, not our responsibility any more! + format::expand_preparsed_format_args(cx, span, + format_closure, + format_string, exprs, HashMap::new()) +} diff --git a/src/libsyntax/ext/deriving/to_str.rs b/src/libsyntax/ext/deriving/to_str.rs index 6101d647ca5..2f50d5ad121 100644 --- a/src/libsyntax/ext/deriving/to_str.rs +++ b/src/libsyntax/ext/deriving/to_str.rs @@ -17,7 +17,7 @@ use ext::deriving::generic::*; use parse::token::InternedString; use parse::token; -pub fn expand_deriving_to_str(cx: &ExtCtxt, +pub fn expand_deriving_to_str(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) @@ -49,7 +49,7 @@ pub fn expand_deriving_to_str(cx: &ExtCtxt, // doesn't invoke the to_str() method on each field. Hence we mirror // the logic of the repr_to_str() method, but with tweaks to call to_str() // on sub-fields. -fn to_str_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) +fn to_str_substructure(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let to_str = cx.ident_of("to_str"); diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 893a1c68426..ff0fd388ebe 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -24,7 +24,6 @@ use opt_vec::OptVec; /// The types of pointers pub enum PtrTy<'a> { Send, // ~ - Managed, // @ Borrowed(Option<&'a str>, ast::Mutability), // &['lifetime] [mut] } @@ -138,9 +137,6 @@ impl<'a> Ty<'a> { Send => { cx.ty_uniq(span, raw_ty) } - Managed => { - cx.ty_box(span, raw_ty) - } Borrowed(ref lt, mutbl) => { let lt = mk_lifetime(cx, span, lt); cx.ty_rptr(span, raw_ty, lt, mutbl) @@ -182,8 +178,8 @@ impl<'a> Ty<'a> { Literal(ref p) => { p.to_path(cx, span, self_ty, self_generics) } - Ptr(..) => { cx.span_bug(span, "Pointer in a path in generic `deriving`") } - Tuple(..) => { cx.span_bug(span, "Tuple in a path in generic `deriving`") } + Ptr(..) => { cx.span_bug(span, "pointer in a path in generic `deriving`") } + Tuple(..) => { cx.span_bug(span, "tuple in a path in generic `deriving`") } } } } @@ -251,7 +247,6 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) span, match *ptr { Send => ast::SelfUniq, - Managed => ast::SelfBox, Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s))); ast::SelfRegion(lt, mutbl) diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index dd99e821620..ecd06b3f49e 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_zero(cx: &ExtCtxt, +pub fn expand_deriving_zero(cx: &mut ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@Item]) @@ -57,7 +57,7 @@ pub fn expand_deriving_zero(cx: &ExtCtxt, trait_def.expand(mitem, in_items) } -fn zero_substructure(cx: &ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { +fn zero_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> @Expr { let zero_ident = ~[ cx.ident_of("std"), cx.ident_of("num"), diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index ae93c235ad2..cfad88e2482 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast::{P, Block, Crate, DeclLocal, ExprMac, SyntaxContext}; +use ast::{P, Block, Crate, DeclLocal, ExprMac}; use ast::{Local, Ident, MacInvocTT}; use ast::{ItemMac, Mrk, Stmt, StmtDecl, StmtMac, StmtExpr, StmtSemi}; use ast::{TokenTree}; @@ -134,7 +134,7 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr { // Desugar expr_for_loop // From: `['<ident>:] for <src_pat> in <src_expr> <src_loop_block>` - // FIXME #6993 : change type of opt_ident to Option<Name> + // FIXME #6993: change type of opt_ident to Option<Name> ast::ExprForLoop(src_pat, src_expr, src_loop_block, opt_ident) => { // Expand any interior macros etc. // NB: we don't fold pats yet. Curious. @@ -800,9 +800,8 @@ impl<'a> Folder for MacroExpander<'a> { pub fn expand_crate(parse_sess: @parse::ParseSess, loader: &mut CrateLoader, - cfg: ast::CrateConfig, c: Crate) -> Crate { - let mut cx = ExtCtxt::new(parse_sess, cfg.clone(), loader); + let mut cx = ExtCtxt::new(parse_sess, c.config.clone(), loader); let mut expander = MacroExpander { extsbox: syntax_expander_table(), cx: &mut cx, @@ -819,59 +818,16 @@ pub fn expand_crate(parse_sess: @parse::ParseSess, // element that has one. a CtxtFn is a trait-ified // version of a closure in (SyntaxContext -> SyntaxContext). // the ones defined here include: -// Renamer - add a rename to a context -// MultiRenamer - add a set of renames to a context // Marker - add a mark to a context -// Repainter - replace a context (maybe Replacer would be a better name?) -// a function in SyntaxContext -> SyntaxContext -pub trait CtxtFn{ - fn f(&self, ast::SyntaxContext) -> ast::SyntaxContext; -} - -// a renamer adds a rename to the syntax context -pub struct Renamer { - from : ast::Ident, - to : ast::Name -} +// A Marker adds the given mark to the syntax context +struct Marker { mark: Mrk } -impl CtxtFn for Renamer { - fn f(&self, ctxt : ast::SyntaxContext) -> ast::SyntaxContext { - new_rename(self.from,self.to,ctxt) - } -} - -// a marker adds the given mark to the syntax context -pub struct Marker { mark : Mrk } - -impl CtxtFn for Marker { - fn f(&self, ctxt : ast::SyntaxContext) -> ast::SyntaxContext { - new_mark(self.mark,ctxt) - } -} - -// a repainter just replaces the given context with the one it's closed over -pub struct Repainter { ctxt : SyntaxContext } - -impl CtxtFn for Repainter { - fn f(&self, _ctxt : ast::SyntaxContext) -> ast::SyntaxContext { - self.ctxt - } -} - -pub struct ContextWrapper { - context_function: @CtxtFn, -} - -impl Folder for ContextWrapper { +impl Folder for Marker { fn fold_ident(&mut self, id: ast::Ident) -> ast::Ident { - let ast::Ident { - name, - ctxt - } = id; ast::Ident { - name: name, - ctxt: self.context_function.f(ctxt), + name: id.name, + ctxt: new_mark(self.mark, id.ctxt) } } fn fold_mac(&mut self, m: &ast::Mac) -> ast::Mac { @@ -879,7 +835,7 @@ impl Folder for ContextWrapper { MacInvocTT(ref path, ref tts, ctxt) => { MacInvocTT(self.fold_path(path), fold_tts(*tts, self), - self.context_function.f(ctxt)) + new_mark(self.mark, ctxt)) } }; Spanned { @@ -889,50 +845,32 @@ impl Folder for ContextWrapper { } } -// given a function from ctxts to ctxts, produce -// a Folder that applies that function to all ctxts: -pub fn fun_to_ctxt_folder<T : 'static + CtxtFn>(cf: @T) -> ContextWrapper { - ContextWrapper { - context_function: cf as @CtxtFn, - } -} - // just a convenience: -pub fn new_mark_folder(m: Mrk) -> ContextWrapper { - fun_to_ctxt_folder(@Marker{mark:m}) -} - -pub fn new_rename_folder(from: ast::Ident, to: ast::Name) -> ContextWrapper { - fun_to_ctxt_folder(@Renamer{from:from,to:to}) +fn new_mark_folder(m: Mrk) -> Marker { + Marker {mark: m} } // apply a given mark to the given token trees. Used prior to expansion of a macro. -fn mark_tts(tts : &[TokenTree], m : Mrk) -> ~[TokenTree] { +fn mark_tts(tts: &[TokenTree], m: Mrk) -> ~[TokenTree] { fold_tts(tts, &mut new_mark_folder(m)) } // apply a given mark to the given expr. Used following the expansion of a macro. -fn mark_expr(expr : @ast::Expr, m : Mrk) -> @ast::Expr { +fn mark_expr(expr: @ast::Expr, m: Mrk) -> @ast::Expr { new_mark_folder(m).fold_expr(expr) } // apply a given mark to the given stmt. Used following the expansion of a macro. -fn mark_stmt(expr : &ast::Stmt, m : Mrk) -> @ast::Stmt { +fn mark_stmt(expr: &ast::Stmt, m: Mrk) -> @ast::Stmt { new_mark_folder(m).fold_stmt(expr) .expect_one("marking a stmt didn't return a stmt") } // apply a given mark to the given item. Used following the expansion of a macro. -fn mark_item(expr : @ast::Item, m : Mrk) -> SmallVector<@ast::Item> { +fn mark_item(expr: @ast::Item, m: Mrk) -> SmallVector<@ast::Item> { new_mark_folder(m).fold_item(expr) } -// replace all contexts in a given expr with the given mark. Used -// for capturing macros -pub fn replace_ctxts(expr : @ast::Expr, ctxt : SyntaxContext) -> @ast::Expr { - fun_to_ctxt_folder(@Repainter{ctxt:ctxt}).fold_expr(expr) -} - fn original_span(cx: &ExtCtxt) -> @codemap::ExpnInfo { let mut relevant_info = cx.backtrace(); let mut einfo = relevant_info.unwrap(); @@ -952,17 +890,15 @@ fn original_span(cx: &ExtCtxt) -> @codemap::ExpnInfo { mod test { use super::*; use ast; - use ast::{Attribute_, AttrOuter, MetaWord, EMPTY_CTXT}; - use ast_util::{get_sctable, mtwt_marksof, mtwt_resolve, new_rename}; + use ast::{Attribute_, AttrOuter, MetaWord}; + use ast_util::{get_sctable, mtwt_marksof, mtwt_resolve}; use ast_util; use codemap; use codemap::Spanned; - use fold::*; use ext::base::{CrateLoader, MacroCrate}; use parse; - use parse::token::{fresh_mark, gensym, intern}; use parse::token; - use util::parser_testing::{string_to_crate, string_to_crate_and_sess}; + use util::parser_testing::{string_to_crate_and_sess}; use util::parser_testing::{string_to_pat, strs_to_idents}; use visit; use visit::Visitor; @@ -1026,14 +962,14 @@ mod test { #[test] fn macros_cant_escape_fns_test () { let src = ~"fn bogus() {macro_rules! z (() => (3+4))}\ fn inty() -> int { z!() }"; - let sess = parse::new_parse_sess(None); + let sess = parse::new_parse_sess(); let crate_ast = parse::parse_crate_from_source_str( ~"<test>", src, ~[],sess); // should fail: let mut loader = ErrLoader; - expand_crate(sess,&mut loader,~[],crate_ast); + expand_crate(sess,&mut loader,crate_ast); } // make sure that macros can leave scope for modules @@ -1041,28 +977,28 @@ mod test { #[test] fn macros_cant_escape_mods_test () { let src = ~"mod foo {macro_rules! z (() => (3+4))}\ fn inty() -> int { z!() }"; - let sess = parse::new_parse_sess(None); + let sess = parse::new_parse_sess(); let crate_ast = parse::parse_crate_from_source_str( ~"<test>", src, ~[],sess); // should fail: let mut loader = ErrLoader; - expand_crate(sess,&mut loader,~[],crate_ast); + expand_crate(sess,&mut loader,crate_ast); } // macro_escape modules shouldn't cause macros to leave scope #[test] fn macros_can_escape_flattened_mods_test () { let src = ~"#[macro_escape] mod foo {macro_rules! z (() => (3+4))}\ fn inty() -> int { z!() }"; - let sess = parse::new_parse_sess(None); + let sess = parse::new_parse_sess(); let crate_ast = parse::parse_crate_from_source_str( ~"<test>", src, ~[], sess); // should fail: let mut loader = ErrLoader; - expand_crate(sess, &mut loader, ~[], crate_ast); + expand_crate(sess, &mut loader, crate_ast); } #[test] fn test_contains_flatten (){ @@ -1090,41 +1026,6 @@ mod test { } } - #[test] - fn renaming () { - let item_ast = string_to_crate(~"fn f() -> int { a }"); - let a_name = intern("a"); - let a2_name = gensym("a2"); - let mut renamer = new_rename_folder(ast::Ident{name:a_name,ctxt:EMPTY_CTXT}, - a2_name); - let renamed_ast = renamer.fold_crate(item_ast.clone()); - let mut path_finder = new_path_finder(~[]); - visit::walk_crate(&mut path_finder, &renamed_ast, ()); - - match path_finder.path_accumulator { - [ast::Path{segments:[ref seg],..}] => - assert_eq!(mtwt_resolve(seg.identifier),a2_name), - _ => assert_eq!(0,1) - } - - // try a double-rename, with pending_renames. - let a3_name = gensym("a3"); - // a context that renames from ("a",empty) to "a2" : - let ctxt2 = new_rename(ast::Ident::new(a_name),a2_name,EMPTY_CTXT); - let mut pending_renames = ~[ - (ast::Ident::new(a_name),a2_name), - (ast::Ident{name:a_name,ctxt:ctxt2},a3_name) - ]; - let double_renamed = renames_to_fold(&mut pending_renames).fold_crate(item_ast); - let mut path_finder = new_path_finder(~[]); - visit::walk_crate(&mut path_finder, &double_renamed, ()); - match path_finder.path_accumulator { - [ast::Path{segments:[ref seg],..}] => - assert_eq!(mtwt_resolve(seg.identifier),a3_name), - _ => assert_eq!(0,1) - } - } - //fn fake_print_crate(crate: &ast::Crate) { // let mut out = ~std::io::stderr() as ~std::io::Writer; // let mut s = pprust::rust_printer(out, get_ident_interner()); @@ -1135,7 +1036,7 @@ mod test { let (crate_ast,ps) = string_to_crate_and_sess(crate_str); // the cfg argument actually does matter, here... let mut loader = ErrLoader; - expand_crate(ps,&mut loader,~[],crate_ast) + expand_crate(ps,&mut loader,crate_ast) } //fn expand_and_resolve(crate_str: @str) -> ast::crate { @@ -1143,7 +1044,7 @@ mod test { // println!("expanded: {:?}\n",expanded_ast); //mtwt_resolve_crate(expanded_ast) //} - //fn expand_and_resolve_and_pretty_print (crate_str : @str) -> ~str { + //fn expand_and_resolve_and_pretty_print (crate_str: @str) -> ~str { //let resolved_ast = expand_and_resolve(crate_str); //pprust::to_str(&resolved_ast,fake_print_crate,get_ident_interner()) //} @@ -1176,12 +1077,12 @@ mod test { #[test] fn automatic_renaming () { - let tests : ~[RenamingTest] = + let tests: ~[RenamingTest] = ~[// b & c should get new names throughout, in the expr too: ("fn a() -> int { let b = 13; let c = b; b+c }", ~[~[0,1],~[2]], false), // both x's should be renamed (how is this causing a bug?) - ("fn main () {let x : int = 13;x;}", + ("fn main () {let x: int = 13;x;}", ~[~[0]], false), // the use of b after the + should be renamed, the other one not: ("macro_rules! f (($x:ident) => (b + $x)) fn a() -> int { let b = 13; f!(b)}", @@ -1301,7 +1202,7 @@ foo_module!() visit::walk_crate(&mut name_finder, &cr, ()); let bindings = name_finder.ident_accumulator; - let cxbinds : ~[&ast::Ident] = + let cxbinds: ~[&ast::Ident] = bindings.iter().filter(|b| { let string = token::get_ident(b.name); "xx" == string.get() @@ -1324,7 +1225,7 @@ foo_module!() "xx" == string.get() } }).enumerate() { - if (mtwt_resolve(v.segments[0].identifier) != resolved_binding) { + if mtwt_resolve(v.segments[0].identifier) != resolved_binding { println!("uh oh, xx binding didn't match xx varref:"); println!("this is xx varref \\# {:?}",idx); println!("binding: {:?}",cxbind); @@ -1338,7 +1239,7 @@ foo_module!() { let table = table.table.borrow(); for (idx,val) in table.get().iter().enumerate() { - println!("{:4u} : {:?}",idx,val); + println!("{:4u}: {:?}",idx,val); } } } diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 1893cc0c722..4bc3b804c7f 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -56,78 +56,83 @@ struct Context<'a> { next_arg: uint, } -impl<'a> Context<'a> { - /// Parses the arguments from the given list of tokens, returning None if - /// there's a parse error so we can continue parsing other format! expressions. - fn parse_args(&mut self, sp: Span, tts: &[ast::TokenTree]) - -> (@ast::Expr, Option<@ast::Expr>) { - let mut p = rsparse::new_parser_from_tts(self.ecx.parse_sess(), - self.ecx.cfg(), - tts.to_owned()); - // Parse the leading function expression (maybe a block, maybe a path) - let extra = p.parse_expr(); - if !p.eat(&token::COMMA) { - self.ecx.span_err(sp, "expected token: `,`"); - return (extra, None); - } +/// Parses the arguments from the given list of tokens, returning None +/// if there's a parse error so we can continue parsing other format! +/// expressions. +/// +/// If parsing succeeds, the second return value is: +/// +/// Some((fmtstr, unnamed arguments, named arguments)) +fn parse_args(ecx: &mut ExtCtxt, sp: Span, + tts: &[ast::TokenTree]) -> (@ast::Expr, Option<(@ast::Expr, ~[@ast::Expr], + HashMap<~str, @ast::Expr>)>) { + let mut args = ~[]; + let mut names = HashMap::<~str, @ast::Expr>::new(); + + let mut p = rsparse::new_parser_from_tts(ecx.parse_sess(), + ecx.cfg(), + tts.to_owned()); + // Parse the leading function expression (maybe a block, maybe a path) + let extra = p.parse_expr(); + if !p.eat(&token::COMMA) { + ecx.span_err(sp, "expected token: `,`"); + return (extra, None); + } - if p.token == token::EOF { - self.ecx.span_err(sp, "requires at least a format string argument"); + if p.token == token::EOF { + ecx.span_err(sp, "requires at least a format string argument"); + return (extra, None); + } + let fmtstr = p.parse_expr(); + let mut named = false; + while p.token != token::EOF { + if !p.eat(&token::COMMA) { + ecx.span_err(sp, "expected token: `,`"); return (extra, None); } - let fmtstr = p.parse_expr(); - let mut named = false; - while p.token != token::EOF { - if !p.eat(&token::COMMA) { - self.ecx.span_err(sp, "expected token: `,`"); - return (extra, None); - } - if p.token == token::EOF { break } // accept trailing commas - if named || (token::is_ident(&p.token) && - p.look_ahead(1, |t| *t == token::EQ)) { - named = true; - let ident = match p.token { - token::IDENT(i, _) => { - p.bump(); - i - } - _ if named => { - self.ecx.span_err(p.span, - "expected ident, positional arguments \ - cannot follow named arguments"); - return (extra, None); - } - _ => { - self.ecx.span_err(p.span, - format!("expected ident for named \ - argument, but found `{}`", - p.this_token_to_str())); - return (extra, None); - } - }; - let interned_name = token::get_ident(ident.name); - let name = interned_name.get(); - p.expect(&token::EQ); - let e = p.parse_expr(); - match self.names.find_equiv(&name) { - None => {} - Some(prev) => { - self.ecx.span_err(e.span, format!("duplicate argument \ - named `{}`", name)); - self.ecx.parse_sess.span_diagnostic.span_note( - prev.span, "previously here"); - continue - } + if p.token == token::EOF { break } // accept trailing commas + if named || (token::is_ident(&p.token) && + p.look_ahead(1, |t| *t == token::EQ)) { + named = true; + let ident = match p.token { + token::IDENT(i, _) => { + p.bump(); + i + } + _ if named => { + ecx.span_err(p.span, + "expected ident, positional arguments \ + cannot follow named arguments"); + return (extra, None); + } + _ => { + ecx.span_err(p.span, + format!("expected ident for named argument, but found `{}`", + p.this_token_to_str())); + return (extra, None); + } + }; + let interned_name = token::get_ident(ident.name); + let name = interned_name.get(); + p.expect(&token::EQ); + let e = p.parse_expr(); + match names.find_equiv(&name) { + None => {} + Some(prev) => { + ecx.span_err(e.span, format!("duplicate argument named `{}`", name)); + ecx.parse_sess.span_diagnostic.span_note(prev.span, "previously here"); + continue } - self.names.insert(name.to_str(), e); - } else { - self.args.push(p.parse_expr()); - self.arg_types.push(None); } + names.insert(name.to_str(), e); + } else { + args.push(p.parse_expr()); } - return (extra, Some(fmtstr)); } + return (extra, Some((fmtstr, args, names))); +} +impl<'a> Context<'a> { /// Verifies one piece of a parse string. All errors are not emitted as /// fatal so we can continue giving errors about this and possibly other /// format strings. @@ -758,11 +763,28 @@ impl<'a> Context<'a> { pub fn expand_args(ecx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult { + + match parse_args(ecx, sp, tts) { + (extra, Some((efmt, args, names))) => { + MRExpr(expand_preparsed_format_args(ecx, sp, extra, efmt, args, names)) + } + (_, None) => MRExpr(ecx.expr_uint(sp, 2)) + } +} + +/// Take the various parts of `format_args!(extra, efmt, args..., +/// name=names...)` and construct the appropriate formatting +/// expression. +pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, + extra: @ast::Expr, + efmt: @ast::Expr, args: ~[@ast::Expr], + names: HashMap<~str, @ast::Expr>) -> @ast::Expr { + let arg_types = vec::from_fn(args.len(), |_| None); let mut cx = Context { ecx: ecx, - args: ~[], - arg_types: ~[], - names: HashMap::new(), + args: args, + arg_types: arg_types, + names: names, name_positions: HashMap::new(), name_types: HashMap::new(), nest_level: 0, @@ -771,10 +793,6 @@ pub fn expand_args(ecx: &mut ExtCtxt, sp: Span, method_statics: ~[], fmtsp: sp, }; - let (extra, efmt) = match cx.parse_args(sp, tts) { - (extra, Some(e)) => (extra, e), - (_, None) => { return MRExpr(cx.ecx.expr_uint(sp, 2)); } - }; cx.fmtsp = efmt.span; // Be sure to recursively expand macros just in case the format string uses // a macro to build the format expression. @@ -783,25 +801,28 @@ pub fn expand_args(ecx: &mut ExtCtxt, sp: Span, expr, "format argument must be a string literal.") { Some((fmt, _)) => fmt, - None => return MacResult::dummy_expr() + None => return efmt }; - let mut err = false; - parse::parse_error::cond.trap(|m| { - if !err { - err = true; - cx.ecx.span_err(efmt.span, m); - } - }).inside(|| { - for piece in parse::Parser::new(fmt.get()) { - if !err { + let mut parser = parse::Parser::new(fmt.get()); + loop { + match parser.next() { + Some(piece) => { + if parser.errors.len() > 0 { break } cx.verify_piece(&piece); let piece = cx.trans_piece(&piece); cx.pieces.push(piece); } + None => break } - }); - if err { return MRExpr(efmt) } + } + match parser.errors.shift() { + Some(error) => { + cx.ecx.span_err(efmt.span, "invalid format string: " + error); + return efmt; + } + None => {} + } // Make sure that all arguments were used and all arguments have types. for (i, ty) in cx.arg_types.iter().enumerate() { @@ -815,5 +836,5 @@ pub fn expand_args(ecx: &mut ExtCtxt, sp: Span, } } - MRExpr(cx.to_expr(extra)) + cx.to_expr(extra) } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index bd1ac616f52..e9832209904 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -257,7 +257,7 @@ pub mod rt { match res { Some(ast) => ast, None => { - error!("Parse error"); + error!("parse error"); fail!() } } @@ -589,7 +589,7 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) let cx_expr = p.parse_expr(); if !p.eat(&token::COMMA) { - p.fatal("Expected token `,`"); + p.fatal("expected token `,`"); } let tts = p.parse_all_token_trees(); diff --git a/src/libsyntax/ext/registrar.rs b/src/libsyntax/ext/registrar.rs index 1c349c4343a..e831e8fbb10 100644 --- a/src/libsyntax/ext/registrar.rs +++ b/src/libsyntax/ext/registrar.rs @@ -49,7 +49,7 @@ pub fn find_macro_registrar(diagnostic: @diagnostic::SpanHandler, }) }, _ => { - diagnostic.handler().err("Multiple macro registration functions found"); + diagnostic.handler().err("multiple macro registration functions found"); for &(_, span) in ctx.registrars.iter() { diagnostic.span_note(span, "one is here"); } diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index 83c6c6a1762..4189ea6a967 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -25,8 +25,7 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt, let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic, None, tt.to_owned()); - let rdr = tt_rdr as @Reader; - let mut rust_parser = Parser(sess, cfg.clone(), rdr.dup()); + let mut rust_parser = Parser(sess, cfg.clone(), tt_rdr.dup()); if rust_parser.is_keyword(keywords::True) { cx.set_trace_macros(true); @@ -39,7 +38,7 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt, rust_parser.bump(); - let mut rust_parser = Parser(sess, cfg, rdr.dup()); + let mut rust_parser = Parser(sess, cfg, tt_rdr.dup()); let result = rust_parser.parse_expr(); base::MRExpr(result) } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 6d1b8dd2358..92bc204e2c1 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -185,7 +185,7 @@ pub fn nameize(p_s: @ParseSess, ms: &[Matcher], res: &[@NamedMatch]) if ret_val.contains_key(bind_name) { let string = token::get_ident(bind_name.name); p_s.span_diagnostic - .span_fatal(sp, "Duplicated bind name: " + string.get()) + .span_fatal(sp, "duplicated bind name: " + string.get()) } ret_val.insert(*bind_name, res[idx]); } @@ -202,11 +202,11 @@ pub enum ParseResult { Error(codemap::Span, ~str) } -pub fn parse_or_else(sess: @ParseSess, - cfg: ast::CrateConfig, - rdr: @Reader, - ms: ~[Matcher]) - -> HashMap<Ident, @NamedMatch> { +pub fn parse_or_else<R: Reader>(sess: @ParseSess, + cfg: ast::CrateConfig, + rdr: R, + ms: ~[Matcher]) + -> HashMap<Ident, @NamedMatch> { match parse(sess, cfg, rdr, ms) { Success(m) => m, Failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str), @@ -223,11 +223,11 @@ pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool { } } -pub fn parse(sess: @ParseSess, - cfg: ast::CrateConfig, - rdr: @Reader, - ms: &[Matcher]) - -> ParseResult { +pub fn parse<R: Reader>(sess: @ParseSess, + cfg: ast::CrateConfig, + rdr: R, + ms: &[Matcher]) + -> ParseResult { let mut cur_eis = ~[]; cur_eis.push(initial_matcher_pos(ms.to_owned(), None, rdr.peek().sp.lo)); @@ -441,6 +441,6 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal { res } "matchers" => token::NtMatchers(p.parse_matchers()), - _ => p.fatal(~"Unsupported builtin nonterminal parser: " + name) + _ => p.fatal(~"unsupported builtin nonterminal parser: " + name) } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index c179e9959e0..e196bdccfe3 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -18,7 +18,7 @@ use ext::base; use ext::tt::macro_parser::{Success, Error, Failure}; use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal}; use ext::tt::macro_parser::{parse, parse_or_else}; -use parse::lexer::{new_tt_reader, Reader}; +use parse::lexer::new_tt_reader; use parse::parser::Parser; use parse::attr::ParserAttr; use parse::token::{get_ident_interner, special_idents, gensym_ident}; @@ -129,8 +129,8 @@ fn generic_extension(cx: &ExtCtxt, for (i, lhs) in lhses.iter().enumerate() { // try each arm's matchers match **lhs { MatchedNonterminal(NtMatchers(ref mtcs)) => { - // `none` is because we're not interpolating - let arg_rdr = new_tt_reader(s_d, None, arg.to_owned()) as @Reader; + // `None` is because we're not interpolating + let arg_rdr = new_tt_reader(s_d, None, arg.to_owned()); match parse(cx.parse_sess(), cx.cfg(), arg_rdr, *mtcs) { Success(named_matches) => { let rhs = match *rhses[i] { @@ -150,12 +150,12 @@ fn generic_extension(cx: &ExtCtxt, // rhs has holes ( `$id` and `$(...)` that need filled) let trncbr = new_tt_reader(s_d, Some(named_matches), rhs); - let p = Parser(cx.parse_sess(), cx.cfg(), trncbr as @Reader); + let p = Parser(cx.parse_sess(), cx.cfg(), ~trncbr); // Let the context choose how to interpret the result. // Weird, but useful for X-macros. - return MRAny(@ParserAnyMacro { + return MRAny(~ParserAnyMacro { parser: RefCell::new(p), - } as @AnyMacro) + }) } Failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo { best_fail_spot = sp; @@ -210,7 +210,7 @@ pub fn add_new_extension(cx: &mut ExtCtxt, arg.clone()); let argument_map = parse_or_else(cx.parse_sess(), cx.cfg(), - arg_reader as @Reader, + arg_reader, argument_gram); // Extract the arguments: diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index d2fa24b1cfe..fccbc57f12c 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -49,8 +49,8 @@ pub struct TtReader { pub fn new_tt_reader(sp_diag: @SpanHandler, interp: Option<HashMap<Ident, @NamedMatch>>, src: ~[ast::TokenTree]) - -> @TtReader { - let r = @TtReader { + -> TtReader { + let r = TtReader { sp_diag: sp_diag, stack: RefCell::new(@TtFrame { forest: @src, @@ -69,7 +69,7 @@ pub fn new_tt_reader(sp_diag: @SpanHandler, cur_tok: RefCell::new(EOF), cur_span: RefCell::new(DUMMY_SP), }; - tt_next_token(r); /* get cur_tok and cur_span set up */ + tt_next_token(&r); /* get cur_tok and cur_span set up */ return r; } @@ -86,8 +86,8 @@ fn dup_tt_frame(f: @TtFrame) -> @TtFrame { } } -pub fn dup_tt_reader(r: @TtReader) -> @TtReader { - @TtReader { +pub fn dup_tt_reader(r: &TtReader) -> TtReader { + TtReader { sp_diag: r.sp_diag, stack: RefCell::new(dup_tt_frame(r.stack.get())), repeat_idx: r.repeat_idx.clone(), @@ -148,7 +148,7 @@ fn lis_merge(lhs: LockstepIterSize, rhs: LockstepIterSize) -> LockstepIterSize { LisConstraint(r_len, ref r_id) => { let l_n = token::get_ident(l_id.name); let r_n = token::get_ident(r_id.name); - LisContradiction(format!("Inconsistent lockstep iteration: \ + LisContradiction(format!("inconsistent lockstep iteration: \ '{}' has {} items, but '{}' has {}", l_n.get(), l_len, r_n.get(), r_len)) } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 297ec6acf51..8fbaea7ac1e 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -306,7 +306,7 @@ pub trait Folder { fn fold_explicit_self_(&mut self, es: &ExplicitSelf_) -> ExplicitSelf_ { match *es { - SelfStatic | SelfValue | SelfUniq | SelfBox => *es, + SelfStatic | SelfValue | SelfUniq => *es, SelfRegion(ref lifetime, m) => { SelfRegion(fold_opt_lifetime(lifetime, self), m) } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 3f305a4eb0e..613416bed1c 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -35,6 +35,7 @@ This API is completely unstable and subject to change. extern mod extra; extern mod serialize; extern mod term; +extern mod collections; pub mod util { pub mod interner; diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index c575e170bef..21f05fa684a 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -85,7 +85,7 @@ impl<T> OptVec<T> { pub fn get<'a>(&'a self, i: uint) -> &'a T { match *self { - Empty => fail!("Invalid index {}", i), + Empty => fail!("invalid index {}", i), Vec(ref v) => &v[i] } } @@ -103,7 +103,7 @@ impl<T> OptVec<T> { pub fn swap_remove(&mut self, index: uint) { match *self { - Empty => { fail!("Index out of bounds"); } + Empty => { fail!("index out of bounds"); } Vec(ref mut v) => { assert!(index < v.len()); v.swap_remove(index); diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index f65bc3ad7a3..138f9d71640 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -12,7 +12,7 @@ use ast; use codemap::{BytePos, CharPos, CodeMap, Pos}; use diagnostic; use parse::lexer::{is_whitespace, with_str_from, Reader}; -use parse::lexer::{StringReader, bump, is_eof, nextch, TokenAndSpan}; +use parse::lexer::{StringReader, bump, is_eof, nextch_is, TokenAndSpan}; use parse::lexer::{is_line_non_doc_comment, is_block_non_doc_comment}; use parse::lexer; use parse::token; @@ -134,31 +134,31 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str { fail!("not a doc-comment: {}", comment); } -fn read_to_eol(rdr: @StringReader) -> ~str { +fn read_to_eol(rdr: &StringReader) -> ~str { let mut val = ~""; - while rdr.curr.get() != '\n' && !is_eof(rdr) { - val.push_char(rdr.curr.get()); + while !rdr.curr_is('\n') && !is_eof(rdr) { + val.push_char(rdr.curr.get().unwrap()); bump(rdr); } - if rdr.curr.get() == '\n' { bump(rdr); } + if rdr.curr_is('\n') { bump(rdr); } return val; } -fn read_one_line_comment(rdr: @StringReader) -> ~str { +fn read_one_line_comment(rdr: &StringReader) -> ~str { let val = read_to_eol(rdr); assert!((val[0] == '/' as u8 && val[1] == '/' as u8) || (val[0] == '#' as u8 && val[1] == '!' as u8)); return val; } -fn consume_non_eol_whitespace(rdr: @StringReader) { - while is_whitespace(rdr.curr.get()) && rdr.curr.get() != '\n' && +fn consume_non_eol_whitespace(rdr: &StringReader) { + while is_whitespace(rdr.curr.get()) && !rdr.curr_is('\n') && !is_eof(rdr) { bump(rdr); } } -fn push_blank_line_comment(rdr: @StringReader, comments: &mut ~[Comment]) { +fn push_blank_line_comment(rdr: &StringReader, comments: &mut ~[Comment]) { debug!(">>> blank-line comment"); let v: ~[~str] = ~[]; comments.push(Comment { @@ -168,10 +168,10 @@ fn push_blank_line_comment(rdr: @StringReader, comments: &mut ~[Comment]) { }); } -fn consume_whitespace_counting_blank_lines(rdr: @StringReader, +fn consume_whitespace_counting_blank_lines(rdr: &StringReader, comments: &mut ~[Comment]) { while is_whitespace(rdr.curr.get()) && !is_eof(rdr) { - if rdr.col.get() == CharPos(0u) && rdr.curr.get() == '\n' { + if rdr.col.get() == CharPos(0u) && rdr.curr_is('\n') { push_blank_line_comment(rdr, &mut *comments); } bump(rdr); @@ -179,7 +179,7 @@ fn consume_whitespace_counting_blank_lines(rdr: @StringReader, } -fn read_shebang_comment(rdr: @StringReader, code_to_the_left: bool, +fn read_shebang_comment(rdr: &StringReader, code_to_the_left: bool, comments: &mut ~[Comment]) { debug!(">>> shebang comment"); let p = rdr.last_pos.get(); @@ -191,12 +191,12 @@ fn read_shebang_comment(rdr: @StringReader, code_to_the_left: bool, }); } -fn read_line_comments(rdr: @StringReader, code_to_the_left: bool, +fn read_line_comments(rdr: &StringReader, code_to_the_left: bool, comments: &mut ~[Comment]) { debug!(">>> line comments"); let p = rdr.last_pos.get(); let mut lines: ~[~str] = ~[]; - while rdr.curr.get() == '/' && nextch(rdr) == '/' { + while rdr.curr_is('/') && nextch_is(rdr, '/') { let line = read_one_line_comment(rdr); debug!("{}", line); if is_doc_comment(line) { // doc-comments are not put in comments @@ -248,7 +248,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str], lines.push(s1); } -fn read_block_comment(rdr: @StringReader, +fn read_block_comment(rdr: &StringReader, code_to_the_left: bool, comments: &mut ~[Comment]) { debug!(">>> block comment"); @@ -261,9 +261,9 @@ fn read_block_comment(rdr: @StringReader, let mut curr_line = ~"/*"; // doc-comments are not really comments, they are attributes - if rdr.curr.get() == '*' || rdr.curr.get() == '!' { - while !(rdr.curr.get() == '*' && nextch(rdr) == '/') && !is_eof(rdr) { - curr_line.push_char(rdr.curr.get()); + if rdr.curr_is('*') || rdr.curr_is('!') { + while !(rdr.curr_is('*') && nextch_is(rdr, '/')) && !is_eof(rdr) { + curr_line.push_char(rdr.curr.get().unwrap()); bump(rdr); } if !is_eof(rdr) { @@ -279,22 +279,22 @@ fn read_block_comment(rdr: @StringReader, while level > 0 { debug!("=== block comment level {}", level); if is_eof(rdr) { - (rdr as @Reader).fatal(~"unterminated block comment"); + rdr.fatal(~"unterminated block comment"); } - if rdr.curr.get() == '\n' { + if rdr.curr_is('\n') { trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col); curr_line = ~""; bump(rdr); } else { - curr_line.push_char(rdr.curr.get()); - if rdr.curr.get() == '/' && nextch(rdr) == '*' { + curr_line.push_char(rdr.curr.get().unwrap()); + if rdr.curr_is('/') && nextch_is(rdr, '*') { bump(rdr); bump(rdr); curr_line.push_char('*'); level += 1; } else { - if rdr.curr.get() == '*' && nextch(rdr) == '/' { + if rdr.curr_is('*') && nextch_is(rdr, '/') { bump(rdr); bump(rdr); curr_line.push_char('/'); @@ -310,28 +310,28 @@ fn read_block_comment(rdr: @StringReader, let mut style = if code_to_the_left { Trailing } else { Isolated }; consume_non_eol_whitespace(rdr); - if !is_eof(rdr) && rdr.curr.get() != '\n' && lines.len() == 1u { + if !is_eof(rdr) && !rdr.curr_is('\n') && lines.len() == 1u { style = Mixed; } debug!("<<< block comment"); comments.push(Comment {style: style, lines: lines, pos: p}); } -fn peeking_at_comment(rdr: @StringReader) -> bool { - return ((rdr.curr.get() == '/' && nextch(rdr) == '/') || - (rdr.curr.get() == '/' && nextch(rdr) == '*')) || - (rdr.curr.get() == '#' && nextch(rdr) == '!'); +fn peeking_at_comment(rdr: &StringReader) -> bool { + return (rdr.curr_is('/') && nextch_is(rdr, '/')) || + (rdr.curr_is('/') && nextch_is(rdr, '*')) || + (rdr.curr_is('#') && nextch_is(rdr, '!')); } -fn consume_comment(rdr: @StringReader, +fn consume_comment(rdr: &StringReader, code_to_the_left: bool, comments: &mut ~[Comment]) { debug!(">>> consume comment"); - if rdr.curr.get() == '/' && nextch(rdr) == '/' { + if rdr.curr_is('/') && nextch_is(rdr, '/') { read_line_comments(rdr, code_to_the_left, comments); - } else if rdr.curr.get() == '/' && nextch(rdr) == '*' { + } else if rdr.curr_is('/') && nextch_is(rdr, '*') { read_block_comment(rdr, code_to_the_left, comments); - } else if rdr.curr.get() == '#' && nextch(rdr) == '!' { + } else if rdr.curr_is('#') && nextch_is(rdr, '!') { read_shebang_comment(rdr, code_to_the_left, comments); } else { fail!(); } debug!("<<< consume comment"); @@ -359,17 +359,17 @@ pub fn gather_comments_and_literals(span_diagnostic: let mut comments: ~[Comment] = ~[]; let mut literals: ~[Literal] = ~[]; let mut first_read: bool = true; - while !is_eof(rdr) { + while !is_eof(&rdr) { loop { let mut code_to_the_left = !first_read; - consume_non_eol_whitespace(rdr); - if rdr.curr.get() == '\n' { + consume_non_eol_whitespace(&rdr); + if rdr.curr_is('\n') { code_to_the_left = false; - consume_whitespace_counting_blank_lines(rdr, &mut comments); + consume_whitespace_counting_blank_lines(&rdr, &mut comments); } - while peeking_at_comment(rdr) { - consume_comment(rdr, code_to_the_left, &mut comments); - consume_whitespace_counting_blank_lines(rdr, &mut comments); + while peeking_at_comment(&rdr) { + consume_comment(&rdr, code_to_the_left, &mut comments); + consume_whitespace_counting_blank_lines(&rdr, &mut comments); } break; } @@ -380,7 +380,7 @@ pub fn gather_comments_and_literals(span_diagnostic: //discard, and look ahead; we're working with internal state let TokenAndSpan {tok: tok, sp: sp} = rdr.peek(); if token::is_lit(&tok) { - with_str_from(rdr, bstart, |s| { + with_str_from(&rdr, bstart, |s| { debug!("tok lit: {}", s); literals.push(Literal {lit: s.to_owned(), pos: sp.lo}); }) diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 8c55990289a..f6ebfbfcc3b 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -12,12 +12,10 @@ use ast; use codemap::{BytePos, CharPos, CodeMap, Pos, Span}; use codemap; use diagnostic::SpanHandler; -use ext::tt::transcribe::{tt_next_token}; -use ext::tt::transcribe::{dup_tt_reader}; +use ext::tt::transcribe::{dup_tt_reader, tt_next_token}; use parse::token; use parse::token::{str_to_ident}; -use std::cast::transmute; use std::cell::{Cell, RefCell}; use std::char; use std::num::from_str_radix; @@ -26,12 +24,12 @@ use std::util; pub use ext::tt::transcribe::{TtReader, new_tt_reader}; pub trait Reader { - fn is_eof(@self) -> bool; - fn next_token(@self) -> TokenAndSpan; - fn fatal(@self, ~str) -> !; - fn span_diag(@self) -> @SpanHandler; - fn peek(@self) -> TokenAndSpan; - fn dup(@self) -> @Reader; + fn is_eof(&self) -> bool; + fn next_token(&self) -> TokenAndSpan; + fn fatal(&self, ~str) -> !; + fn span_diag(&self) -> @SpanHandler; + fn peek(&self) -> TokenAndSpan; + fn dup(&self) -> ~Reader:; } #[deriving(Clone, Eq)] @@ -49,47 +47,53 @@ pub struct StringReader { // The column of the next character to read col: Cell<CharPos>, // The last character to be read - curr: Cell<char>, + curr: Cell<Option<char>>, filemap: @codemap::FileMap, /* cached: */ peek_tok: RefCell<token::Token>, peek_span: RefCell<Span>, } +impl StringReader { + pub fn curr_is(&self, c: char) -> bool { + self.curr.get() == Some(c) + } +} + pub fn new_string_reader(span_diagnostic: @SpanHandler, filemap: @codemap::FileMap) - -> @StringReader { + -> StringReader { let r = new_low_level_string_reader(span_diagnostic, filemap); - string_advance_token(r); /* fill in peek_* */ - return r; + string_advance_token(&r); /* fill in peek_* */ + r } /* For comments.rs, which hackily pokes into 'pos' and 'curr' */ pub fn new_low_level_string_reader(span_diagnostic: @SpanHandler, filemap: @codemap::FileMap) - -> @StringReader { + -> StringReader { // Force the initial reader bump to start on a fresh line let initial_char = '\n'; - let r = @StringReader { + let r = StringReader { span_diagnostic: span_diagnostic, pos: Cell::new(filemap.start_pos), last_pos: Cell::new(filemap.start_pos), col: Cell::new(CharPos(0)), - curr: Cell::new(initial_char), + curr: Cell::new(Some(initial_char)), filemap: filemap, /* dummy values; not read */ peek_tok: RefCell::new(token::EOF), peek_span: RefCell::new(codemap::DUMMY_SP), }; - bump(r); - return r; + bump(&r); + r } // duplicating the string reader is probably a bad idea, in // that using them will cause interleaved pushes of line // offsets to the underlying filemap... -fn dup_string_reader(r: @StringReader) -> @StringReader { - @StringReader { +fn dup_string_reader(r: &StringReader) -> StringReader { + StringReader { span_diagnostic: r.span_diagnostic, pos: Cell::new(r.pos.get()), last_pos: Cell::new(r.last_pos.get()), @@ -102,9 +106,9 @@ fn dup_string_reader(r: @StringReader) -> @StringReader { } impl Reader for StringReader { - fn is_eof(@self) -> bool { is_eof(self) } + fn is_eof(&self) -> bool { is_eof(self) } // return the next token. EFFECT: advances the string_reader. - fn next_token(@self) -> TokenAndSpan { + fn next_token(&self) -> TokenAndSpan { let ret_val = { let mut peek_tok = self.peek_tok.borrow_mut(); TokenAndSpan { @@ -115,45 +119,45 @@ impl Reader for StringReader { string_advance_token(self); ret_val } - fn fatal(@self, m: ~str) -> ! { + fn fatal(&self, m: ~str) -> ! { self.span_diagnostic.span_fatal(self.peek_span.get(), m) } - fn span_diag(@self) -> @SpanHandler { self.span_diagnostic } - fn peek(@self) -> TokenAndSpan { + fn span_diag(&self) -> @SpanHandler { self.span_diagnostic } + fn peek(&self) -> TokenAndSpan { // FIXME(pcwalton): Bad copy! TokenAndSpan { tok: self.peek_tok.get(), sp: self.peek_span.get(), } } - fn dup(@self) -> @Reader { dup_string_reader(self) as @Reader } + fn dup(&self) -> ~Reader: { ~dup_string_reader(self) as ~Reader: } } impl Reader for TtReader { - fn is_eof(@self) -> bool { + fn is_eof(&self) -> bool { let cur_tok = self.cur_tok.borrow(); *cur_tok.get() == token::EOF } - fn next_token(@self) -> TokenAndSpan { + fn next_token(&self) -> TokenAndSpan { let r = tt_next_token(self); debug!("TtReader: r={:?}", r); return r; } - fn fatal(@self, m: ~str) -> ! { + fn fatal(&self, m: ~str) -> ! { self.sp_diag.span_fatal(self.cur_span.get(), m); } - fn span_diag(@self) -> @SpanHandler { self.sp_diag } - fn peek(@self) -> TokenAndSpan { + fn span_diag(&self) -> @SpanHandler { self.sp_diag } + fn peek(&self) -> TokenAndSpan { TokenAndSpan { tok: self.cur_tok.get(), sp: self.cur_span.get(), } } - fn dup(@self) -> @Reader { dup_tt_reader(self) as @Reader } + fn dup(&self) -> ~Reader: { ~dup_tt_reader(self) as ~Reader: } } // report a lexical error spanning [`from_pos`, `to_pos`) -fn fatal_span(rdr: @StringReader, +fn fatal_span(rdr: &StringReader, from_pos: BytePos, to_pos: BytePos, m: ~str) @@ -164,7 +168,7 @@ fn fatal_span(rdr: @StringReader, // report a lexical error spanning [`from_pos`, `to_pos`), appending an // escaped character to the error message -fn fatal_span_char(rdr: @StringReader, +fn fatal_span_char(rdr: &StringReader, from_pos: BytePos, to_pos: BytePos, m: ~str, @@ -178,7 +182,7 @@ fn fatal_span_char(rdr: @StringReader, // report a lexical error spanning [`from_pos`, `to_pos`), appending the // offending string to the error message -fn fatal_span_verbose(rdr: @StringReader, +fn fatal_span_verbose(rdr: &StringReader, from_pos: BytePos, to_pos: BytePos, m: ~str) @@ -194,7 +198,7 @@ fn fatal_span_verbose(rdr: @StringReader, // EFFECT: advance peek_tok and peek_span to refer to the next token. // EFFECT: update the interner, maybe. -fn string_advance_token(r: @StringReader) { +fn string_advance_token(r: &StringReader) { match consume_whitespace_and_comments(r) { Some(comment) => { r.peek_span.set(comment.sp); @@ -221,7 +225,7 @@ fn byte_offset(rdr: &StringReader, pos: BytePos) -> BytePos { /// up to but excluding `rdr.last_pos`, meaning the slice does not include /// the character `rdr.curr`. pub fn with_str_from<T>( - rdr: @StringReader, + rdr: &StringReader, start: BytePos, f: |s: &str| -> T) -> T { @@ -231,7 +235,7 @@ pub fn with_str_from<T>( /// Calls `f` with astring slice of the source text spanning from `start` /// up to but excluding `end`. fn with_str_from_to<T>( - rdr: @StringReader, + rdr: &StringReader, start: BytePos, end: BytePos, f: |s: &str| -> T) @@ -247,14 +251,12 @@ pub fn bump(rdr: &StringReader) { rdr.last_pos.set(rdr.pos.get()); let current_byte_offset = byte_offset(rdr, rdr.pos.get()).to_uint(); if current_byte_offset < (rdr.filemap.src).len() { - assert!(rdr.curr.get() != unsafe { - transmute(-1u32) - }); // FIXME: #8971: unsound - let last_char = rdr.curr.get(); + assert!(rdr.curr.get().is_some()); + let last_char = rdr.curr.get().unwrap(); let next = rdr.filemap.src.char_range_at(current_byte_offset); let byte_offset_diff = next.next - current_byte_offset; rdr.pos.set(rdr.pos.get() + Pos::from_uint(byte_offset_diff)); - rdr.curr.set(next.ch); + rdr.curr.set(Some(next.ch)); rdr.col.set(rdr.col.get() + CharPos(1u)); if last_char == '\n' { rdr.filemap.next_line(rdr.last_pos.get()); @@ -266,44 +268,57 @@ pub fn bump(rdr: &StringReader) { Pos::from_uint(current_byte_offset), byte_offset_diff); } } else { - rdr.curr.set(unsafe { transmute(-1u32) }); // FIXME: #8971: unsound + rdr.curr.set(None); } } -pub fn is_eof(rdr: @StringReader) -> bool { - rdr.curr.get() == unsafe { transmute(-1u32) } // FIXME: #8971: unsound +pub fn is_eof(rdr: &StringReader) -> bool { + rdr.curr.get().is_none() } -pub fn nextch(rdr: @StringReader) -> char { +pub fn nextch(rdr: &StringReader) -> Option<char> { let offset = byte_offset(rdr, rdr.pos.get()).to_uint(); if offset < (rdr.filemap.src).len() { - return rdr.filemap.src.char_at(offset); - } else { return unsafe { transmute(-1u32) }; } // FIXME: #8971: unsound + Some(rdr.filemap.src.char_at(offset)) + } else { + None + } +} +pub fn nextch_is(rdr: &StringReader, c: char) -> bool { + nextch(rdr) == Some(c) } -fn hex_digit_val(c: char) -> int { - if in_range(c, '0', '9') { return (c as int) - ('0' as int); } - if in_range(c, 'a', 'f') { return (c as int) - ('a' as int) + 10; } - if in_range(c, 'A', 'F') { return (c as int) - ('A' as int) + 10; } +fn hex_digit_val(c: Option<char>) -> int { + let d = c.unwrap_or('\x00'); + + if in_range(c, '0', '9') { return (d as int) - ('0' as int); } + if in_range(c, 'a', 'f') { return (d as int) - ('a' as int) + 10; } + if in_range(c, 'A', 'F') { return (d as int) - ('A' as int) + 10; } fail!(); } -pub fn is_whitespace(c: char) -> bool { - return c == ' ' || c == '\t' || c == '\r' || c == '\n'; +pub fn is_whitespace(c: Option<char>) -> bool { + match c.unwrap_or('\x00') { // None can be null for now... it's not whitespace + ' ' | '\n' | '\t' | '\r' => true, + _ => false + } } -fn in_range(c: char, lo: char, hi: char) -> bool { - return lo <= c && c <= hi +fn in_range(c: Option<char>, lo: char, hi: char) -> bool { + match c { + Some(c) => lo <= c && c <= hi, + _ => false + } } -fn is_dec_digit(c: char) -> bool { return in_range(c, '0', '9'); } +fn is_dec_digit(c: Option<char>) -> bool { return in_range(c, '0', '9'); } -fn is_hex_digit(c: char) -> bool { +fn is_hex_digit(c: Option<char>) -> bool { return in_range(c, '0', '9') || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'); } // EFFECT: eats whitespace and comments. // returns a Some(sugared-doc-attr) if one exists, None otherwise. -fn consume_whitespace_and_comments(rdr: @StringReader) +fn consume_whitespace_and_comments(rdr: &StringReader) -> Option<TokenAndSpan> { while is_whitespace(rdr.curr.get()) { bump(rdr); } return consume_any_line_comment(rdr); @@ -316,17 +331,17 @@ pub fn is_line_non_doc_comment(s: &str) -> bool { // PRECONDITION: rdr.curr is not whitespace // EFFECT: eats any kind of comment. // returns a Some(sugared-doc-attr) if one exists, None otherwise -fn consume_any_line_comment(rdr: @StringReader) +fn consume_any_line_comment(rdr: &StringReader) -> Option<TokenAndSpan> { - if rdr.curr.get() == '/' { + if rdr.curr_is('/') { match nextch(rdr) { - '/' => { + Some('/') => { bump(rdr); bump(rdr); // line comments starting with "///" or "//!" are doc-comments - if rdr.curr.get() == '/' || rdr.curr.get() == '!' { + if rdr.curr_is('/') || rdr.curr_is('!') { let start_bpos = rdr.pos.get() - BytePos(3); - while rdr.curr.get() != '\n' && !is_eof(rdr) { + while !rdr.curr_is('\n') && !is_eof(rdr) { bump(rdr); } let ret = with_str_from(rdr, start_bpos, |string| { @@ -345,16 +360,16 @@ fn consume_any_line_comment(rdr: @StringReader) return ret; } } else { - while rdr.curr.get() != '\n' && !is_eof(rdr) { bump(rdr); } + while !rdr.curr_is('\n') && !is_eof(rdr) { bump(rdr); } } // Restart whitespace munch. return consume_whitespace_and_comments(rdr); } - '*' => { bump(rdr); bump(rdr); return consume_block_comment(rdr); } + Some('*') => { bump(rdr); bump(rdr); return consume_block_comment(rdr); } _ => () } - } else if rdr.curr.get() == '#' { - if nextch(rdr) == '!' { + } else if rdr.curr_is('#') { + if nextch_is(rdr, '!') { // I guess this is the only way to figure out if // we're at the beginning of the file... let cmap = @CodeMap::new(); @@ -364,7 +379,7 @@ fn consume_any_line_comment(rdr: @StringReader) } let loc = cmap.lookup_char_pos_adj(rdr.last_pos.get()); if loc.line == 1u && loc.col == CharPos(0u) { - while rdr.curr.get() != '\n' && !is_eof(rdr) { bump(rdr); } + while !rdr.curr_is('\n') && !is_eof(rdr) { bump(rdr); } return consume_whitespace_and_comments(rdr); } } @@ -377,9 +392,9 @@ pub fn is_block_non_doc_comment(s: &str) -> bool { } // might return a sugared-doc-attr -fn consume_block_comment(rdr: @StringReader) -> Option<TokenAndSpan> { +fn consume_block_comment(rdr: &StringReader) -> Option<TokenAndSpan> { // block comments starting with "/**" or "/*!" are doc-comments - let is_doc_comment = rdr.curr.get() == '*' || rdr.curr.get() == '!'; + let is_doc_comment = rdr.curr_is('*') || rdr.curr_is('!'); let start_bpos = rdr.pos.get() - BytePos(if is_doc_comment {3} else {2}); let mut level: int = 1; @@ -391,11 +406,11 @@ fn consume_block_comment(rdr: @StringReader) -> Option<TokenAndSpan> { ~"unterminated block comment" }; fatal_span(rdr, start_bpos, rdr.last_pos.get(), msg); - } else if rdr.curr.get() == '/' && nextch(rdr) == '*' { + } else if rdr.curr_is('/') && nextch_is(rdr, '*') { level += 1; bump(rdr); bump(rdr); - } else if rdr.curr.get() == '*' && nextch(rdr) == '/' { + } else if rdr.curr_is('*') && nextch_is(rdr, '/') { level -= 1; bump(rdr); bump(rdr); @@ -424,13 +439,14 @@ fn consume_block_comment(rdr: @StringReader) -> Option<TokenAndSpan> { if res.is_some() { res } else { consume_whitespace_and_comments(rdr) } } -fn scan_exponent(rdr: @StringReader, start_bpos: BytePos) -> Option<~str> { - let mut c = rdr.curr.get(); +fn scan_exponent(rdr: &StringReader, start_bpos: BytePos) -> Option<~str> { + // \x00 hits the `return None` case immediately, so this is fine. + let mut c = rdr.curr.get().unwrap_or('\x00'); let mut rslt = ~""; if c == 'e' || c == 'E' { rslt.push_char(c); bump(rdr); - c = rdr.curr.get(); + c = rdr.curr.get().unwrap_or('\x00'); if c == '-' || c == '+' { rslt.push_char(c); bump(rdr); @@ -445,14 +461,14 @@ fn scan_exponent(rdr: @StringReader, start_bpos: BytePos) -> Option<~str> { } else { return None::<~str>; } } -fn scan_digits(rdr: @StringReader, radix: uint) -> ~str { +fn scan_digits(rdr: &StringReader, radix: uint) -> ~str { let mut rslt = ~""; loop { let c = rdr.curr.get(); - if c == '_' { bump(rdr); continue; } - match char::to_digit(c, radix) { + if c == Some('_') { bump(rdr); continue; } + match c.and_then(|cc| char::to_digit(cc, radix)) { Some(_) => { - rslt.push_char(c); + rslt.push_char(c.unwrap()); bump(rdr); } _ => return rslt @@ -460,7 +476,7 @@ fn scan_digits(rdr: @StringReader, radix: uint) -> ~str { }; } -fn check_float_base(rdr: @StringReader, start_bpos: BytePos, last_bpos: BytePos, +fn check_float_base(rdr: &StringReader, start_bpos: BytePos, last_bpos: BytePos, base: uint) { match base { 16u => fatal_span(rdr, start_bpos, last_bpos, @@ -473,11 +489,11 @@ fn check_float_base(rdr: @StringReader, start_bpos: BytePos, last_bpos: BytePos, } } -fn scan_number(c: char, rdr: @StringReader) -> token::Token { +fn scan_number(c: char, rdr: &StringReader) -> token::Token { let mut num_str; let mut base = 10u; let mut c = c; - let mut n = nextch(rdr); + let mut n = nextch(rdr).unwrap_or('\x00'); let start_bpos = rdr.last_pos.get(); if c == '0' && n == 'x' { bump(rdr); @@ -493,7 +509,7 @@ fn scan_number(c: char, rdr: @StringReader) -> token::Token { base = 2u; } num_str = scan_digits(rdr, base); - c = rdr.curr.get(); + c = rdr.curr.get().unwrap_or('\x00'); nextch(rdr); if c == 'u' || c == 'i' { enum Result { Signed(ast::IntTy), Unsigned(ast::UintTy) } @@ -503,13 +519,13 @@ fn scan_number(c: char, rdr: @StringReader) -> token::Token { else { Unsigned(ast::TyU) } }; bump(rdr); - c = rdr.curr.get(); + c = rdr.curr.get().unwrap_or('\x00'); if c == '8' { bump(rdr); tp = if signed { Signed(ast::TyI8) } else { Unsigned(ast::TyU8) }; } - n = nextch(rdr); + n = nextch(rdr).unwrap_or('\x00'); if c == '1' && n == '6' { bump(rdr); bump(rdr); @@ -542,8 +558,7 @@ fn scan_number(c: char, rdr: @StringReader) -> token::Token { } } let mut is_float = false; - if rdr.curr.get() == '.' && !(ident_start(nextch(rdr)) || nextch(rdr) == - '.') { + if rdr.curr_is('.') && !(ident_start(nextch(rdr)) || nextch_is(rdr, '.')) { is_float = true; bump(rdr); let dec_part = scan_digits(rdr, 10u); @@ -558,10 +573,10 @@ fn scan_number(c: char, rdr: @StringReader) -> token::Token { None => () } - if rdr.curr.get() == 'f' { + if rdr.curr_is('f') { bump(rdr); - c = rdr.curr.get(); - n = nextch(rdr); + c = rdr.curr.get().unwrap_or('\x00'); + n = nextch(rdr).unwrap_or('\x00'); if c == '3' && n == '2' { bump(rdr); bump(rdr); @@ -599,22 +614,27 @@ fn scan_number(c: char, rdr: @StringReader) -> token::Token { } } -fn scan_numeric_escape(rdr: @StringReader, n_hex_digits: uint) -> char { +fn scan_numeric_escape(rdr: &StringReader, n_hex_digits: uint) -> char { let mut accum_int = 0; let mut i = n_hex_digits; let start_bpos = rdr.last_pos.get(); - while i != 0u { + while i != 0u && !is_eof(rdr) { let n = rdr.curr.get(); if !is_hex_digit(n) { fatal_span_char(rdr, rdr.last_pos.get(), rdr.pos.get(), ~"illegal character in numeric character escape", - n); + n.unwrap()); } bump(rdr); accum_int *= 16; accum_int += hex_digit_val(n); i -= 1u; } + if i != 0 && is_eof(rdr) { + fatal_span(rdr, start_bpos, rdr.last_pos.get(), + ~"unterminated numeric character escape"); + } + match char::from_u32(accum_int as u32) { Some(x) => x, None => fatal_span(rdr, start_bpos, rdr.last_pos.get(), @@ -622,14 +642,18 @@ fn scan_numeric_escape(rdr: @StringReader, n_hex_digits: uint) -> char { } } -fn ident_start(c: char) -> bool { +fn ident_start(c: Option<char>) -> bool { + let c = match c { Some(c) => c, None => return false }; + (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c > '\x7f' && char::is_XID_start(c)) } -fn ident_continue(c: char) -> bool { +fn ident_continue(c: Option<char>) -> bool { + let c = match c { Some(c) => c, None => return false }; + (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') @@ -640,9 +664,9 @@ fn ident_continue(c: char) -> bool { // return the next token from the string // EFFECT: advances the input past that token // EFFECT: updates the interner -fn next_token_inner(rdr: @StringReader) -> token::Token { +fn next_token_inner(rdr: &StringReader) -> token::Token { let c = rdr.curr.get(); - if ident_start(c) && nextch(rdr) != '"' && nextch(rdr) != '#' { + if ident_start(c) && !nextch_is(rdr, '"') && !nextch_is(rdr, '#') { // Note: r as in r" or r#" is part of a raw string literal, // not an identifier, and is handled further down. @@ -655,7 +679,7 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { if string == "_" { token::UNDERSCORE } else { - let is_mod_name = rdr.curr.get() == ':' && nextch(rdr) == ':'; + let is_mod_name = rdr.curr_is(':') && nextch_is(rdr, ':'); // FIXME: perform NFKC normalization here. (Issue #2253) token::IDENT(str_to_ident(string), is_mod_name) @@ -663,16 +687,16 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { }) } if is_dec_digit(c) { - return scan_number(c, rdr); + return scan_number(c.unwrap(), rdr); } - fn binop(rdr: @StringReader, op: token::BinOp) -> token::Token { + fn binop(rdr: &StringReader, op: token::BinOp) -> token::Token { bump(rdr); - if rdr.curr.get() == '=' { + if rdr.curr_is('=') { bump(rdr); return token::BINOPEQ(op); } else { return token::BINOP(op); } } - match c { + match c.expect("next_token_inner called at EOF") { @@ -683,9 +707,9 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { ',' => { bump(rdr); return token::COMMA; } '.' => { bump(rdr); - return if rdr.curr.get() == '.' { + return if rdr.curr_is('.') { bump(rdr); - if rdr.curr.get() == '.' { + if rdr.curr_is('.') { bump(rdr); token::DOTDOTDOT } else { @@ -706,7 +730,7 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { '~' => { bump(rdr); return token::TILDE; } ':' => { bump(rdr); - if rdr.curr.get() == ':' { + if rdr.curr_is(':') { bump(rdr); return token::MOD_SEP; } else { return token::COLON; } @@ -721,10 +745,10 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { // Multi-byte tokens. '=' => { bump(rdr); - if rdr.curr.get() == '=' { + if rdr.curr_is('=') { bump(rdr); return token::EQEQ; - } else if rdr.curr.get() == '>' { + } else if rdr.curr_is('>') { bump(rdr); return token::FAT_ARROW; } else { @@ -733,19 +757,19 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { } '!' => { bump(rdr); - if rdr.curr.get() == '=' { + if rdr.curr_is('=') { bump(rdr); return token::NE; } else { return token::NOT; } } '<' => { bump(rdr); - match rdr.curr.get() { + match rdr.curr.get().unwrap_or('\x00') { '=' => { bump(rdr); return token::LE; } '<' => { return binop(rdr, token::SHL); } '-' => { bump(rdr); - match rdr.curr.get() { + match rdr.curr.get().unwrap_or('\x00') { '>' => { bump(rdr); return token::DARROW; } _ => { return token::LARROW; } } @@ -755,7 +779,7 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { } '>' => { bump(rdr); - match rdr.curr.get() { + match rdr.curr.get().unwrap_or('\x00') { '=' => { bump(rdr); return token::GE; } '>' => { return binop(rdr, token::SHR); } _ => { return token::GT; } @@ -765,12 +789,14 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { // Either a character constant 'a' OR a lifetime name 'abc bump(rdr); let start = rdr.last_pos.get(); - let mut c2 = rdr.curr.get(); + + // the eof will be picked up by the final `'` check below + let mut c2 = rdr.curr.get().unwrap_or('\x00'); bump(rdr); // If the character is an ident start not followed by another single // quote, then this is a lifetime name: - if ident_start(c2) && rdr.curr.get() != '\'' { + if ident_start(Some(c2)) && !rdr.curr_is('\'') { while ident_continue(rdr.curr.get()) { bump(rdr); } @@ -799,19 +825,24 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { let escaped_pos = rdr.last_pos.get(); bump(rdr); match escaped { - 'n' => { c2 = '\n'; } - 'r' => { c2 = '\r'; } - 't' => { c2 = '\t'; } - '\\' => { c2 = '\\'; } - '\'' => { c2 = '\''; } - '"' => { c2 = '"'; } - '0' => { c2 = '\x00'; } - 'x' => { c2 = scan_numeric_escape(rdr, 2u); } - 'u' => { c2 = scan_numeric_escape(rdr, 4u); } - 'U' => { c2 = scan_numeric_escape(rdr, 8u); } - c2 => { - fatal_span_char(rdr, escaped_pos, rdr.last_pos.get(), - ~"unknown character escape", c2); + None => {} + Some(e) => { + c2 = match e { + 'n' => '\n', + 'r' => '\r', + 't' => '\t', + '\\' => '\\', + '\'' => '\'', + '"' => '"', + '0' => '\x00', + 'x' => scan_numeric_escape(rdr, 2u), + 'u' => scan_numeric_escape(rdr, 4u), + 'U' => scan_numeric_escape(rdr, 8u), + c2 => { + fatal_span_char(rdr, escaped_pos, rdr.last_pos.get(), + ~"unknown character escape", c2) + } + } } } } @@ -821,7 +852,7 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { } _ => {} } - if rdr.curr.get() != '\'' { + if !rdr.curr_is('\'') { fatal_span_verbose(rdr, // Byte offsetting here is okay because the // character before position `start` is an @@ -837,17 +868,22 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { let mut accum_str = ~""; let start_bpos = rdr.last_pos.get(); bump(rdr); - while rdr.curr.get() != '"' { + while !rdr.curr_is('"') { if is_eof(rdr) { fatal_span(rdr, start_bpos, rdr.last_pos.get(), ~"unterminated double quote string"); } - let ch = rdr.curr.get(); + let ch = rdr.curr.get().unwrap(); bump(rdr); match ch { '\\' => { - let escaped = rdr.curr.get(); + if is_eof(rdr) { + fatal_span(rdr, start_bpos, rdr.last_pos.get(), + ~"unterminated double quote string"); + } + + let escaped = rdr.curr.get().unwrap(); let escaped_pos = rdr.last_pos.get(); bump(rdr); match escaped { @@ -884,15 +920,19 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { let start_bpos = rdr.last_pos.get(); bump(rdr); let mut hash_count = 0u; - while rdr.curr.get() == '#' { + while rdr.curr_is('#') { bump(rdr); hash_count += 1; } - if rdr.curr.get() != '"' { + + if is_eof(rdr) { + fatal_span(rdr, start_bpos, rdr.last_pos.get(), + ~"unterminated raw string"); + } else if !rdr.curr_is('"') { fatal_span_char(rdr, start_bpos, rdr.last_pos.get(), ~"only `#` is allowed in raw string delimitation; \ found illegal character", - rdr.curr.get()); + rdr.curr.get().unwrap()); } bump(rdr); let content_start_bpos = rdr.last_pos.get(); @@ -902,11 +942,11 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { fatal_span(rdr, start_bpos, rdr.last_pos.get(), ~"unterminated raw string"); } - if rdr.curr.get() == '"' { + if rdr.curr_is('"') { content_end_bpos = rdr.last_pos.get(); for _ in range(0, hash_count) { bump(rdr); - if rdr.curr.get() != '#' { + if !rdr.curr_is('#') { continue 'outer; } } @@ -922,14 +962,14 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { return token::LIT_STR_RAW(str_content, hash_count); } '-' => { - if nextch(rdr) == '>' { + if nextch_is(rdr, '>') { bump(rdr); bump(rdr); return token::RARROW; } else { return binop(rdr, token::MINUS); } } '&' => { - if nextch(rdr) == '&' { + if nextch_is(rdr, '&') { bump(rdr); bump(rdr); return token::ANDAND; @@ -937,7 +977,7 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { } '|' => { match nextch(rdr) { - '|' => { bump(rdr); bump(rdr); return token::OROR; } + Some('|') => { bump(rdr); bump(rdr); return token::OROR; } _ => { return binop(rdr, token::OR); } } } @@ -953,7 +993,7 @@ fn next_token_inner(rdr: @StringReader) -> token::Token { } } -fn consume_whitespace(rdr: @StringReader) { +fn consume_whitespace(rdr: &StringReader) { while is_whitespace(rdr.curr.get()) && !is_eof(rdr) { bump(rdr); } } @@ -968,15 +1008,14 @@ mod test { // represents a testing reader (incl. both reader and interner) struct Env { - string_reader: @StringReader + string_reader: StringReader } // open a string reader for the given string fn setup(teststr: ~str) -> Env { let cm = CodeMap::new(); let fm = cm.new_filemap(~"zebra.rs", teststr); - let span_handler = - diagnostic::mk_span_handler(diagnostic::mk_handler(None),@cm); + let span_handler = diagnostic::mk_span_handler(diagnostic::mk_handler(), @cm); Env { string_reader: new_string_reader(span_handler,fm) } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index faebd97e7c2..6ddb4bbc11f 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -14,7 +14,7 @@ use ast; use codemap::{Span, CodeMap, FileMap}; use codemap; -use diagnostic::{SpanHandler, mk_span_handler, mk_handler, Emitter}; +use diagnostic::{SpanHandler, mk_span_handler, mk_handler}; use parse::attr::ParserAttr; use parse::parser::Parser; @@ -45,11 +45,11 @@ pub struct ParseSess { included_mod_stack: RefCell<~[Path]>, } -pub fn new_parse_sess(demitter: Option<@Emitter>) -> @ParseSess { +pub fn new_parse_sess() -> @ParseSess { let cm = @CodeMap::new(); @ParseSess { cm: cm, - span_diagnostic: mk_span_handler(mk_handler(demitter), cm), + span_diagnostic: mk_span_handler(mk_handler(), cm), included_mod_stack: RefCell::new(~[]), } } @@ -74,7 +74,7 @@ pub fn parse_crate_from_file( cfg: ast::CrateConfig, sess: @ParseSess ) -> ast::Crate { - new_parser_from_file(sess, /*bad*/ cfg.clone(), input).parse_crate_mod() + new_parser_from_file(sess, cfg, input).parse_crate_mod() // why is there no p.abort_if_errors here? } @@ -94,7 +94,7 @@ pub fn parse_crate_from_source_str(name: ~str, sess: @ParseSess) -> ast::Crate { let mut p = new_parser_from_source_str(sess, - /*bad*/ cfg.clone(), + cfg, name, source); maybe_aborted(p.parse_crate_mod(),p) @@ -106,7 +106,7 @@ pub fn parse_crate_attrs_from_source_str(name: ~str, sess: @ParseSess) -> ~[ast::Attribute] { let mut p = new_parser_from_source_str(sess, - /*bad*/ cfg.clone(), + cfg, name, source); let (inner, _) = maybe_aborted(p.parse_inner_attrs_and_next(),p); @@ -261,7 +261,7 @@ pub fn filemap_to_tts(sess: @ParseSess, filemap: @FileMap) // parsing tt's probably shouldn't require a parser at all. let cfg = ~[]; let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap); - let mut p1 = Parser(sess, cfg, srdr as @lexer::Reader); + let mut p1 = Parser(sess, cfg, ~srdr); p1.parse_all_token_trees() } @@ -270,7 +270,7 @@ pub fn tts_to_parser(sess: @ParseSess, tts: ~[ast::TokenTree], cfg: ast::CrateConfig) -> Parser { let trdr = lexer::new_tt_reader(sess.span_diagnostic, None, tts); - Parser(sess, cfg, trdr as @lexer::Reader) + Parser(sess, cfg, ~trdr) } // abort if necessary diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index b85d89cf804..091fbf82b0d 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -76,7 +76,7 @@ impl ParserObsoleteMethods for Parser { let (kind_str, desc) = match kind { ObsoleteSwap => ( "swap", - "Use std::util::{swap, replace} instead" + "use std::util::{swap, replace} instead" ), ObsoleteUnsafeBlock => ( "non-standalone unsafe block", diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b80c222d4dc..fd8b945a177 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -48,7 +48,7 @@ use ast::{RetStyle, Return, BiShl, BiShr, Stmt, StmtDecl}; use ast::{StmtExpr, StmtSemi, StmtMac, StructDef, StructField}; use ast::{StructVariantKind, BiSub}; use ast::StrStyle; -use ast::{SelfBox, SelfRegion, SelfStatic, SelfUniq, SelfValue}; +use ast::{SelfRegion, SelfStatic, SelfUniq, SelfValue}; use ast::{TokenTree, TraitMethod, TraitRef, TTDelim, TTSeq, TTTok}; use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot, TyBox}; use ast::{TypeField, TyFixedLengthVec, TyClosure, TyBareFn, TyTypeof}; @@ -285,7 +285,7 @@ struct ParsedItemsAndViewItems { /* ident is handled by common.rs */ -pub fn Parser(sess: @ParseSess, cfg: ast::CrateConfig, rdr: @Reader) +pub fn Parser(sess: @ParseSess, cfg: ast::CrateConfig, rdr: ~Reader:) -> Parser { let tok0 = rdr.next_token(); let interner = get_ident_interner(); @@ -339,7 +339,7 @@ pub struct Parser { tokens_consumed: uint, restriction: restriction, quote_depth: uint, // not (yet) related to the quasiquoter - reader: @Reader, + reader: ~Reader:, interner: @token::IdentInterner, /// The set of seen errors about obsolete syntax. Used to suppress /// extra detail when the same error is seen twice @@ -431,7 +431,7 @@ impl Parser { && self.look_ahead(1, |t| *t == token::RBRACE) { // matched; signal non-fatal error and recover. self.span_err(self.span, - "Unit-like struct construction is written with no trailing `{ }`"); + "unit-like struct construction is written with no trailing `{ }`"); self.eat(&token::LBRACE); self.eat(&token::RBRACE); true @@ -1601,7 +1601,7 @@ impl Parser { }; } _ => { - self.fatal(format!("Expected a lifetime name")); + self.fatal(format!("expected a lifetime name")); } } } @@ -1771,7 +1771,7 @@ impl Parser { self.commit_expr_expecting(*es.last().unwrap(), token::RPAREN); return if es.len() == 1 && !trailing_comma { - self.mk_expr(lo, self.span.hi, ExprParen(es[0])) + self.mk_expr(lo, hi, ExprParen(es[0])) } else { self.mk_expr(lo, hi, ExprTup(es)) @@ -1994,7 +1994,7 @@ impl Parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_expr() ); - hi = self.span.hi; + hi = self.last_span.hi; es.unshift(e); let nd = self.mk_method_call(i, tys, es, NoSugar); @@ -2137,7 +2137,7 @@ impl Parser { } // There shouldn't really be a span, but it's easier for the test runner // if we give it one - self.fatal("This file contains an un-closed delimiter "); + self.fatal("this file contains an un-closed delimiter "); } token::LPAREN | token::LBRACE | token::LBRACKET => { let close_delim = token::flip_delimiter(&self.token); @@ -2510,7 +2510,7 @@ impl Parser { parse_decl: |&mut Parser| -> P<FnDecl>, parse_body: |&mut Parser| -> @Expr) -> @Expr { - let lo = self.last_span.lo; + let lo = self.span.lo; let decl = parse_decl(self); let body = parse_body(self); let fakeblock = P(ast::Block { @@ -3580,19 +3580,6 @@ impl Parser { // that may have a self type. fn parse_fn_decl_with_self(&mut self, parse_arg_fn: |&mut Parser| -> Arg) -> (ExplicitSelf, P<FnDecl>) { - fn maybe_parse_explicit_self(explicit_self: ast::ExplicitSelf_, - p: &mut Parser) - -> ast::ExplicitSelf_ { - // We need to make sure it isn't a type - if p.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) { - p.bump(); - p.expect_self_ident(); - explicit_self - } else { - SelfStatic - } - } - fn maybe_parse_borrowed_explicit_self(this: &mut Parser) -> ast::ExplicitSelf_ { // The following things are possible to see here: @@ -3650,11 +3637,15 @@ impl Parser { token::BINOP(token::AND) => { maybe_parse_borrowed_explicit_self(self) } - token::AT => { - maybe_parse_explicit_self(SelfBox, self) - } token::TILDE => { - maybe_parse_explicit_self(SelfUniq, self) + // We need to make sure it isn't a type + if self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) { + self.bump(); + self.expect_self_ident(); + SelfUniq + } else { + SelfStatic + } } token::IDENT(..) if self.is_self_ident() => { self.bump(); @@ -3966,7 +3957,7 @@ impl Parser { } if fields.len() == 0 { let string = get_ident_interner().get(class_name.name); - self.fatal(format!("Unit-like struct definition should be written as `struct {};`", + self.fatal(format!("unit-like struct definition should be written as `struct {};`", string.as_slice())); } self.bump(); @@ -4209,10 +4200,10 @@ impl Parser { let mut err = ~"circular modules: "; let len = included_mod_stack.get().len(); for p in included_mod_stack.get().slice(i, len).iter() { - p.display().with_str(|s| err.push_str(s)); + err.push_str(p.display().as_maybe_owned().as_slice()); err.push_str(" -> "); } - path.display().with_str(|s| err.push_str(s)); + err.push_str(path.display().as_maybe_owned().as_slice()); self.span_fatal(id_sp, err); } None => () diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 090774ec76f..d32411b4f05 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -588,8 +588,8 @@ impl BytesContainer for InternedString { } impl fmt::Show for InternedString { - fn fmt(obj: &InternedString, f: &mut fmt::Formatter) -> fmt::Result { - write!(f.buf, "{}", obj.string.as_slice()) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f.buf, "{}", self.string.as_slice()) } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e291583d121..7f7f57b13a9 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -35,11 +35,11 @@ use std::io; use std::io::MemWriter; // The &mut State is stored here to prevent recursive type. -pub enum AnnNode<'a,'b> { - NodeBlock(&'b mut State, &'a ast::Block), - NodeItem(&'b mut State, &'a ast::Item), - NodeExpr(&'b mut State, &'a ast::Expr), - NodePat(&'b mut State, &'a ast::Pat), +pub enum AnnNode<'a, 'b> { + NodeBlock(&'a mut State<'a>, &'b ast::Block), + NodeItem(&'a mut State<'a>, &'b ast::Item), + NodeExpr(&'a mut State<'a>, &'b ast::Expr), + NodePat(&'a mut State<'a>, &'b ast::Pat), } pub trait PpAnn { @@ -56,7 +56,7 @@ pub struct CurrentCommentAndLiteral { cur_lit: uint, } -pub struct State { +pub struct State<'a> { s: pp::Printer, cm: Option<@CodeMap>, intr: @token::IdentInterner, @@ -64,7 +64,7 @@ pub struct State { literals: Option<~[comments::Literal]>, cur_cmnt_and_lit: CurrentCommentAndLiteral, boxes: RefCell<~[pp::Breaks]>, - ann: @PpAnn + ann: &'a PpAnn } pub fn ibox(s: &mut State, u: uint) -> io::IoResult<()> { @@ -83,15 +83,15 @@ pub fn end(s: &mut State) -> io::IoResult<()> { pp::end(&mut s.s) } -pub fn rust_printer(writer: ~io::Writer, intr: @IdentInterner) -> State { - return rust_printer_annotated(writer, intr, @NoAnn as @PpAnn); +pub fn rust_printer(writer: ~io::Writer, intr: @IdentInterner) -> State<'static> { + rust_printer_annotated(writer, intr, &NoAnn) } -pub fn rust_printer_annotated(writer: ~io::Writer, - intr: @IdentInterner, - ann: @PpAnn) - -> State { - return State { +pub fn rust_printer_annotated<'a>(writer: ~io::Writer, + intr: @IdentInterner, + ann: &'a PpAnn) + -> State<'a> { + State { s: pp::mk_printer(writer, default_columns), cm: None, intr: intr, @@ -103,7 +103,7 @@ pub fn rust_printer_annotated(writer: ~io::Writer, }, boxes: RefCell::new(~[]), ann: ann - }; + } } pub static indent_unit: uint = 4u; @@ -120,7 +120,7 @@ pub fn print_crate(cm: @CodeMap, filename: ~str, input: &mut io::Reader, out: ~io::Writer, - ann: @PpAnn, + ann: &PpAnn, is_expanded: bool) -> io::IoResult<()> { let (cmnts, lits) = comments::gather_comments_and_literals( span_diagnostic, @@ -1844,9 +1844,6 @@ fn print_explicit_self(s: &mut State, if_ok!(print_mutability(s, m)); if_ok!(word(&mut s.s, "self")); } - ast::SelfBox => { - if_ok!(word(&mut s.s, "@self")); - } } return Ok(true); } diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index aa22f47221b..8c7ad028a8e 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -18,7 +18,7 @@ use parse::token; // map a string to tts, using a made-up filename: return both the TokenTree's // and the ParseSess pub fn string_to_tts_and_sess (source_str : ~str) -> (~[ast::TokenTree], @ParseSess) { - let ps = new_parse_sess(None); + let ps = new_parse_sess(); (filemap_to_tts(ps,string_to_filemap(ps,source_str,~"bogofile")),ps) } @@ -29,7 +29,7 @@ pub fn string_to_tts(source_str : ~str) -> ~[ast::TokenTree] { } pub fn string_to_parser_and_sess(source_str: ~str) -> (Parser,@ParseSess) { - let ps = new_parse_sess(None); + let ps = new_parse_sess(); (new_parser_from_source_str(ps,~[],~"bogofile",source_str),ps) } diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 6803bb1eaf9..f6040612961 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -68,7 +68,7 @@ impl<T> SmallVector<T> { match *self { One(ref v) if idx == 0 => v, Many(ref vs) => &vs[idx], - _ => fail!("Out of bounds access") + _ => fail!("out of bounds access") } } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 2a6c14f0eae..0c6ecf73f6a 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -186,7 +186,7 @@ fn walk_explicit_self<E: Clone, V: Visitor<E>>(visitor: &mut V, explicit_self: &ExplicitSelf, env: E) { match explicit_self.node { - SelfStatic | SelfValue | SelfBox | SelfUniq => {} + SelfStatic | SelfValue | SelfUniq => {} SelfRegion(ref lifetime, _) => { visitor.visit_opt_lifetime_ref(explicit_self.span, lifetime, env) } diff --git a/src/test/auxiliary/extern_mod_ordering_lib.rs b/src/test/auxiliary/extern_mod_ordering_lib.rs index d04351203da..cf00f077e07 100644 --- a/src/test/auxiliary/extern_mod_ordering_lib.rs +++ b/src/test/auxiliary/extern_mod_ordering_lib.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type="lib"]; pub mod extern_mod_ordering_lib { diff --git a/src/test/auxiliary/impl_privacy_xc_1.rs b/src/test/auxiliary/impl_privacy_xc_1.rs index 4752c5a3bac..356990e1e01 100644 --- a/src/test/auxiliary/impl_privacy_xc_1.rs +++ b/src/test/auxiliary/impl_privacy_xc_1.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "lib"]; pub struct Fish { diff --git a/src/test/auxiliary/impl_privacy_xc_2.rs b/src/test/auxiliary/impl_privacy_xc_2.rs index 7ef36b1fb66..92e6ca1cc48 100644 --- a/src/test/auxiliary/impl_privacy_xc_2.rs +++ b/src/test/auxiliary/impl_privacy_xc_2.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "lib"]; pub struct Fish { diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index c7ffa4a39ac..cb0eac704d9 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -8,14 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; #[crate_id="a"]; #[crate_type = "lib"]; pub trait i<T> { } -pub fn f<T>() -> @i<T> { +pub fn f<T>() -> ~i<T> { impl<T> i<T> for () { } - @() as @i<T> + ~() as ~i<T> } diff --git a/src/test/auxiliary/issue_3907_1.rs b/src/test/auxiliary/issue_3907_1.rs index 4cc36773f52..25d2e3399cf 100644 --- a/src/test/auxiliary/issue_3907_1.rs +++ b/src/test/auxiliary/issue_3907_1.rs @@ -1,3 +1,13 @@ +// 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. + pub trait Foo { fn bar(); } diff --git a/src/test/auxiliary/kinds_in_metadata.rs b/src/test/auxiliary/kinds_in_metadata.rs index a8f8dbf318d..387767f374f 100644 --- a/src/test/auxiliary/kinds_in_metadata.rs +++ b/src/test/auxiliary/kinds_in_metadata.rs @@ -1,3 +1,13 @@ +// 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. + /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ diff --git a/src/test/auxiliary/newtype_struct_xc.rs b/src/test/auxiliary/newtype_struct_xc.rs index e0d2541dbe3..3833b549b5f 100644 --- a/src/test/auxiliary/newtype_struct_xc.rs +++ b/src/test/auxiliary/newtype_struct_xc.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type="lib"]; pub struct Au(int); diff --git a/src/test/auxiliary/no_std_crate.rs b/src/test/auxiliary/no_std_crate.rs index 70f1b76e246..0160c7d3cb3 100644 --- a/src/test/auxiliary/no_std_crate.rs +++ b/src/test/auxiliary/no_std_crate.rs @@ -1,3 +1,13 @@ +// 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. + #[no_std]; pub fn foo() {} diff --git a/src/test/auxiliary/packed.rs b/src/test/auxiliary/packed.rs index 150de8d314d..54b2658e380 100644 --- a/src/test/auxiliary/packed.rs +++ b/src/test/auxiliary/packed.rs @@ -1,3 +1,13 @@ +// 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. + #[packed] pub struct S { a: u8, diff --git a/src/test/auxiliary/private_variant_xc.rs b/src/test/auxiliary/private_variant_xc.rs index e1ecbf8c543..f9308ff7497 100644 --- a/src/test/auxiliary/private_variant_xc.rs +++ b/src/test/auxiliary/private_variant_xc.rs @@ -1,3 +1,13 @@ +// 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. + pub enum Foo { Bar, priv Baz, diff --git a/src/test/auxiliary/static_fn_trait_xc_aux.rs b/src/test/auxiliary/static_fn_trait_xc_aux.rs index a0c9edac5e1..8785a8085dc 100644 --- a/src/test/auxiliary/static_fn_trait_xc_aux.rs +++ b/src/test/auxiliary/static_fn_trait_xc_aux.rs @@ -1,3 +1,13 @@ +// 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. + pub mod num { pub trait Num2 { fn from_int2(n: int) -> Self; diff --git a/src/test/auxiliary/static_mut_xc.rs b/src/test/auxiliary/static_mut_xc.rs index 8dc45c681bf..5660fd5b61f 100644 --- a/src/test/auxiliary/static_mut_xc.rs +++ b/src/test/auxiliary/static_mut_xc.rs @@ -1 +1,11 @@ +// 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. + pub static mut a: int = 3; diff --git a/src/test/auxiliary/trait_default_method_xc_aux.rs b/src/test/auxiliary/trait_default_method_xc_aux.rs index 0012d3e36c6..f9f8a6be7d8 100644 --- a/src/test/auxiliary/trait_default_method_xc_aux.rs +++ b/src/test/auxiliary/trait_default_method_xc_aux.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_id="trait_default_method_xc_aux"]; pub struct Something { x: int } diff --git a/src/test/auxiliary/trait_default_method_xc_aux_2.rs b/src/test/auxiliary/trait_default_method_xc_aux_2.rs index 849709dfd22..145f84e558f 100644 --- a/src/test/auxiliary/trait_default_method_xc_aux_2.rs +++ b/src/test/auxiliary/trait_default_method_xc_aux_2.rs @@ -1,3 +1,13 @@ +// 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. + // aux-build:trait_default_method_xc_aux.rs extern mod aux = "trait_default_method_xc_aux"; diff --git a/src/test/auxiliary/use_from_trait_xc.rs b/src/test/auxiliary/use_from_trait_xc.rs index d5abfd5754c..19e53fcc61a 100644 --- a/src/test/auxiliary/use_from_trait_xc.rs +++ b/src/test/auxiliary/use_from_trait_xc.rs @@ -1,3 +1,13 @@ +// 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. + pub trait Trait { fn foo(); } diff --git a/src/test/auxiliary/xc_conditions_4.rs b/src/test/auxiliary/xc_conditions_4.rs deleted file mode 100644 index 569f22d3644..00000000000 --- a/src/test/auxiliary/xc_conditions_4.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 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. - -#[crate_type="lib"]; - -#[deriving(Eq)] -pub enum Color { - Red, Green, Blue -} - -condition! { - pub oops: (int,f64,~str) -> Color; -} - -pub trait Thunk<T> { - fn call(self) -> T; -} - -pub fn callback<T,TH:Thunk<T>>(t:TH) -> T { - t.call() -} diff --git a/src/test/auxiliary/xc_private_method_lib.rs b/src/test/auxiliary/xc_private_method_lib.rs index 8290f62bada..a9e5775fb4e 100644 --- a/src/test/auxiliary/xc_private_method_lib.rs +++ b/src/test/auxiliary/xc_private_method_lib.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type="lib"]; pub struct Struct { diff --git a/src/test/auxiliary/xcrate_static_addresses.rs b/src/test/auxiliary/xcrate_static_addresses.rs index f0df2b1e71e..b6cbae2d2af 100644 --- a/src/test/auxiliary/xcrate_static_addresses.rs +++ b/src/test/auxiliary/xcrate_static_addresses.rs @@ -24,9 +24,3 @@ pub fn verify_same2(a: &'static int) { let b = global2 as *int as uint; assert_eq!(a, b); } - -condition!{ pub test: int -> (); } - -pub fn raise() { - test::cond.raise(3); -} diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index 4c75ca494ff..ed3874b1a6f 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -9,9 +9,10 @@ // except according to those terms. extern mod extra; +extern mod collections; use extra::time; -use extra::treemap::TreeMap; +use collections::TreeMap; use std::hashmap::{HashMap, HashSet}; use std::os; use std::rand::{Rng, IsaacRng, SeedableRng}; diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index c8f5dda41d8..eb985f8f7eb 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -11,9 +11,10 @@ // except according to those terms. extern mod extra; +extern mod collections; -use extra::bitv::BitvSet; -use extra::treemap::TreeSet; +use collections::bitv::BitvSet; +use collections::TreeSet; use std::hashmap::HashSet; use std::os; use std::rand; diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index 4ffe1aed32f..e9e59924acc 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -1,3 +1,13 @@ +// 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. + // Perlin noise benchmark from https://gist.github.com/1170424 use std::f64; diff --git a/src/test/bench/rt-messaging-ping-pong.rs b/src/test/bench/rt-messaging-ping-pong.rs index 0412a9596f0..b42644f39cb 100644 --- a/src/test/bench/rt-messaging-ping-pong.rs +++ b/src/test/bench/rt-messaging-ping-pong.rs @@ -1,3 +1,13 @@ +// 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. + // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index b5697310fce..0b76e128587 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test reading from os::args()[1] - bogus! use std::from_str::FromStr; diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 3719e76b30f..cb24550e277 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test reading from os::args()[1] - bogus! use std::cast::transmute; diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 94569dc5ac0..be8daf34df7 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test extern mod extra; diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 733269f2a5f..ce49b8b2141 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -1,3 +1,13 @@ +// 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. + use std::os; static PI: f64 = 3.141592653589793; diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 040c8526ee0..86a2043527e 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -19,8 +19,9 @@ */ extern mod extra; +extern mod getopts; -use extra::{time, getopts}; +use extra::time; use std::os; use std::result::{Ok, Err}; use std::task; @@ -52,7 +53,7 @@ struct Config { } fn parse_opts(argv: ~[~str]) -> Config { - let opts = ~[getopts::optflag("stress")]; + let opts = ~[getopts::optflag("", "stress", "")]; let opt_args = argv.slice(1, argv.len()); diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index e1b1f59298e..58f667b929f 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -11,8 +11,9 @@ // Microbenchmark for the smallintmap library extern mod extra; +extern mod collections; -use extra::smallintmap::SmallIntMap; +use collections::SmallIntMap; use std::os; use std::uint; diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 58fdadc2064..42b564edbc5 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -11,8 +11,9 @@ #[feature(managed_boxes)]; extern mod extra; +extern mod collections; -use extra::list::{List, Cons, Nil}; +use collections::list::{List, Cons, Nil}; use extra::time::precise_time_s; use std::os; use std::task; diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index 052900102c9..fe4045e4410 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-pretty // xfail-test linked failure diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index 7b15942a08f..1741210f9ed 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -27,7 +27,8 @@ fn main() { assert_eq!(z, 21); let forty: fish = fish{a: @40}; let two: fish = fish{a: @2}; - let answer: int = forty.a + two.a; //~ ERROR binary operation `+` cannot be applied to type `@int` + let answer: int = forty.a + two.a; + //~^ ERROR binary operation `+` cannot be applied to type `@int` info!("{:?}", answer); assert_eq!(answer, 42); } diff --git a/src/test/compile-fail/bad-char-literals3.rs b/src/test/compile-fail/bad-char-literals3.rs index 9bbe5c75b17..6aa7f3ed06d 100644 --- a/src/test/compile-fail/bad-char-literals3.rs +++ b/src/test/compile-fail/bad-char-literals3.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-cr fn main() { // note that this is a literal "\r" byte - ' '; - //~^ ERROR: character constant must be escaped + ' +'; //~^ ERROR: character constant must be escaped } diff --git a/src/test/compile-fail/bad-char-literals4.rs b/src/test/compile-fail/bad-char-literals4.rs index 675ff742d5c..1e1a99270e7 100644 --- a/src/test/compile-fail/bad-char-literals4.rs +++ b/src/test/compile-fail/bad-char-literals4.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-tab fn main() { // note that this is a literal tab character here ' '; diff --git a/src/test/compile-fail/bad-match.rs b/src/test/compile-fail/bad-match.rs index 041f84bc6ee..39c3ed3e2a3 100644 --- a/src/test/compile-fail/bad-match.rs +++ b/src/test/compile-fail/bad-match.rs @@ -1,3 +1,13 @@ +// 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. + // error-pattern: expected fn main() { diff --git a/src/test/compile-fail/bad-mid-path-type-params.rs b/src/test/compile-fail/bad-mid-path-type-params.rs index 82eddf669af..b02397c510a 100644 --- a/src/test/compile-fail/bad-mid-path-type-params.rs +++ b/src/test/compile-fail/bad-mid-path-type-params.rs @@ -1,3 +1,15 @@ +// 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. + +// xfail-tidy-linelength + #[no_std]; struct S<T> { @@ -29,10 +41,12 @@ impl Trait<int> for S2 { } fn foo<'a>() { - let _ = S::new::<int,f64>(1, 1.0); //~ ERROR the impl referenced by this path needs 1 type parameter, but 0 type parameters were supplied - let _ = S::<'a,int>::new::<f64>(1, 1.0); //~ ERROR expected 0 lifetime parameter(s) - let _: S2 = Trait::new::<int,f64>(1, 1.0); //~ ERROR the trait referenced by this path needs 1 type parameter, but 0 type parameters were supplied - let _: S2 = Trait::<'a,int>::new::<f64>(1, 1.0); //~ ERROR expected 0 lifetime parameter(s) + let _ = S::new::<int,f64>(1, 1.0); + //~^ ERROR the impl referenced by this path needs 1 type parameter, but 0 type parameters were supplied + let _ = S::<'a,int>::new::<f64>(1, 1.0); //~ ERROR expected 0 lifetime parameter(s) + let _: S2 = Trait::new::<int,f64>(1, 1.0); + //~^ ERROR the trait referenced by this path needs 1 type parameter, but 0 type parameters were supplied + let _: S2 = Trait::<'a,int>::new::<f64>(1, 1.0); //~ ERROR expected 0 lifetime parameter(s) } fn main() {} diff --git a/src/test/compile-fail/borrowck-anon-fields-struct.rs b/src/test/compile-fail/borrowck-anon-fields-struct.rs index 46215d6b164..514dd584c6a 100644 --- a/src/test/compile-fail/borrowck-anon-fields-struct.rs +++ b/src/test/compile-fail/borrowck-anon-fields-struct.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that we are able to distinguish when loans borrow different // anonymous fields of a tuple vs the same anonymous field. diff --git a/src/test/compile-fail/borrowck-anon-fields-tuple.rs b/src/test/compile-fail/borrowck-anon-fields-tuple.rs index de2a8d83268..ebaed01756f 100644 --- a/src/test/compile-fail/borrowck-anon-fields-tuple.rs +++ b/src/test/compile-fail/borrowck-anon-fields-tuple.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that we are able to distinguish when loans borrow different // anonymous fields of a tuple vs the same anonymous field. diff --git a/src/test/compile-fail/borrowck-anon-fields-variant.rs b/src/test/compile-fail/borrowck-anon-fields-variant.rs index da0a9323d2c..12624a49f7a 100644 --- a/src/test/compile-fail/borrowck-anon-fields-variant.rs +++ b/src/test/compile-fail/borrowck-anon-fields-variant.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that we are able to distinguish when loans borrow different // anonymous fields of an enum variant vs the same anonymous field. diff --git a/src/test/compile-fail/borrowck-move-by-capture.rs b/src/test/compile-fail/borrowck-move-by-capture.rs index ac565e9bfd6..5af1f8312aa 100644 --- a/src/test/compile-fail/borrowck-move-by-capture.rs +++ b/src/test/compile-fail/borrowck-move-by-capture.rs @@ -1,3 +1,13 @@ +// 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. + pub fn main() { // FIXME(#2202) - Due to the way that borrowck treats closures, // you get two error reports here. diff --git a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs index 7615036300f..63f88347090 100644 --- a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs +++ b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs @@ -1,3 +1,13 @@ +// 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. + fn with(f: |&~str|) {} fn arg_item(&_x: &~str) {} diff --git a/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs b/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs index 6e6a779840e..53b5d866b81 100644 --- a/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs +++ b/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs @@ -1,3 +1,13 @@ +// 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. + fn call_f(f: proc() -> int) -> int { f() } diff --git a/src/test/compile-fail/borrowck-move-mut-base-ptr.rs b/src/test/compile-fail/borrowck-move-mut-base-ptr.rs index 565629b1c30..0015ddf368e 100644 --- a/src/test/compile-fail/borrowck-move-mut-base-ptr.rs +++ b/src/test/compile-fail/borrowck-move-mut-base-ptr.rs @@ -1,3 +1,13 @@ +// 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 attempt to move `&mut` pointer while pointee is borrowed // yields an error. // diff --git a/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs b/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs index 06b77686d2e..c4c05444285 100644 --- a/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs +++ b/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs @@ -1,3 +1,13 @@ +// 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. + struct S {f:~str} impl Drop for S { fn drop(&mut self) { println!("{}", self.f); } diff --git a/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs b/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs index 4faee14e8c7..66d16f88172 100644 --- a/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs +++ b/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs @@ -1,3 +1,13 @@ +// 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. + struct S(~str); impl Drop for S { fn drop(&mut self) { } diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs index 4b6a2eca1af..27b831f3d2b 100644 --- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs +++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs @@ -1,3 +1,13 @@ +// 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 we do not permit moves from &[] matched by a vec pattern. #[deriving(Clone)] diff --git a/src/test/compile-fail/borrowck-object-lifetime.rs b/src/test/compile-fail/borrowck-object-lifetime.rs index ce762e351f9..daeb5b72857 100644 --- a/src/test/compile-fail/borrowck-object-lifetime.rs +++ b/src/test/compile-fail/borrowck-object-lifetime.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait Foo { fn borrowed<'a>(&'a self) -> &'a (); } @@ -18,14 +16,6 @@ fn borrowed_receiver<'a>(x: &'a Foo) -> &'a () { x.borrowed() } -fn managed_receiver(x: @Foo) -> &() { - x.borrowed() //~ ERROR cannot root managed value long enough -} - -fn managed_receiver_1(x: @Foo) { - *x.borrowed() -} - fn owned_receiver(x: ~Foo) -> &() { x.borrowed() //~ ERROR borrowed value does not live long enough } diff --git a/src/test/compile-fail/borrowck-object-mutability.rs b/src/test/compile-fail/borrowck-object-mutability.rs index 1d1b993f5d1..d4203dc9916 100644 --- a/src/test/compile-fail/borrowck-object-mutability.rs +++ b/src/test/compile-fail/borrowck-object-mutability.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait Foo { fn borrowed(&self); fn borrowed_mut(&mut self); @@ -25,11 +23,6 @@ fn borrowed_mut_receiver(x: &mut Foo) { x.borrowed_mut(); } -fn managed_receiver(x: @Foo) { - x.borrowed(); - x.borrowed_mut(); //~ ERROR cannot borrow -} - fn owned_receiver(x: ~Foo) { x.borrowed(); x.borrowed_mut(); //~ ERROR cannot borrow diff --git a/src/test/compile-fail/borrowck-reborrow-from-shorter-lived-andmut.rs b/src/test/compile-fail/borrowck-reborrow-from-shorter-lived-andmut.rs index 85ddfd9424c..0e1c4758c1b 100644 --- a/src/test/compile-fail/borrowck-reborrow-from-shorter-lived-andmut.rs +++ b/src/test/compile-fail/borrowck-reborrow-from-shorter-lived-andmut.rs @@ -16,7 +16,8 @@ struct S<'a> { } fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { - S { pointer: &mut *p.pointer } //~ ERROR lifetime of `p` is too short to guarantee its contents can be safely reborrowed + S { pointer: &mut *p.pointer } + //~^ ERROR lifetime of `p` is too short to guarantee its contents can be safely reborrowed } fn main() { diff --git a/src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs b/src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs index 3c01045369f..1822cd4a892 100644 --- a/src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs +++ b/src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs @@ -1,3 +1,13 @@ +// 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. + #[allow(dead_code)]; fn main() { // Original borrow ends at end of function diff --git a/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs b/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs index ab6f70945be..06b66c2627c 100644 --- a/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs +++ b/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs @@ -1,3 +1,13 @@ +// 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 attempt to swap `&mut` pointer while pointee is borrowed // yields an error. // diff --git a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs index ca20d68e4cd..97f781cffc9 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs @@ -1,3 +1,13 @@ +// 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. + fn a() -> &[int] { let vec = ~[1, 2, 3, 4]; let tail = match vec { diff --git a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs index 635ce77bb8a..da692e330b6 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs @@ -1,3 +1,13 @@ +// 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. + fn a() { let mut v = ~[1, 2, 3]; match v { diff --git a/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs b/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs index 7246b6688fd..909af7da960 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { let mut a = [1, 2, 3, 4]; let t = match a { diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index 02ba1b9d2ff..be66dcf372e 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -1,3 +1,13 @@ +// 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. + fn a() { let mut vec = ~[~1, ~2, ~3]; match vec { diff --git a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs index e542238d035..cf20d57ac58 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs @@ -1,3 +1,13 @@ +// 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. + fn a() -> &int { let vec = ~[1, 2, 3, 4]; let tail = match vec { diff --git a/src/test/compile-fail/box-static-bound.rs b/src/test/compile-fail/box-static-bound.rs index 160f73f4a58..45a42f82145 100644 --- a/src/test/compile-fail/box-static-bound.rs +++ b/src/test/compile-fail/box-static-bound.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(managed_boxes)]; fn f<T>(x: T) -> @T { diff --git a/src/test/compile-fail/by-move-pattern-binding.rs b/src/test/compile-fail/by-move-pattern-binding.rs index f05931d7fb4..c789c83d9ad 100644 --- a/src/test/compile-fail/by-move-pattern-binding.rs +++ b/src/test/compile-fail/by-move-pattern-binding.rs @@ -1,3 +1,13 @@ +// 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. + enum E { Foo, Bar(~str) diff --git a/src/test/compile-fail/class-cast-to-trait.rs b/src/test/compile-fail/class-cast-to-trait.rs index 4abd9898d87..18f6fc25149 100644 --- a/src/test/compile-fail/class-cast-to-trait.rs +++ b/src/test/compile-fail/class-cast-to-trait.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait noisy { fn speak(&self); } @@ -59,6 +57,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } fn main() { - let nyan : @noisy = @cat(0, 2, ~"nyan") as @noisy; + let nyan: ~noisy = ~cat(0, 2, ~"nyan") as ~noisy; nyan.eat(); //~ ERROR does not implement any method in scope named `eat` } diff --git a/src/test/compile-fail/closure-bounds-not-builtin.rs b/src/test/compile-fail/closure-bounds-not-builtin.rs index 4afab8db546..6b25e4be2d9 100644 --- a/src/test/compile-fail/closure-bounds-not-builtin.rs +++ b/src/test/compile-fail/closure-bounds-not-builtin.rs @@ -1,3 +1,13 @@ +// 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. + trait Foo {} diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index 77281b26554..9747a44cef0 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -1,3 +1,13 @@ +// 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. + fn take_any(_: ||:) { } diff --git a/src/test/compile-fail/closure-reform-bad.rs b/src/test/compile-fail/closure-reform-bad.rs index 44c62442ff4..a5168c46045 100644 --- a/src/test/compile-fail/closure-reform-bad.rs +++ b/src/test/compile-fail/closure-reform-bad.rs @@ -1,3 +1,13 @@ +// 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. + /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ diff --git a/src/test/compile-fail/closure-that-fails.rs b/src/test/compile-fail/closure-that-fails.rs index fc8e2d4d853..60c80f872ec 100644 --- a/src/test/compile-fail/closure-that-fails.rs +++ b/src/test/compile-fail/closure-that-fails.rs @@ -1,3 +1,13 @@ +// 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. + fn foo(f: || -> !) {} fn main() { diff --git a/src/test/compile-fail/column-offset-1-based.rs b/src/test/compile-fail/column-offset-1-based.rs index 8c100fd9718..5b38b17ad95 100644 --- a/src/test/compile-fail/column-offset-1-based.rs +++ b/src/test/compile-fail/column-offset-1-based.rs @@ -1 +1,11 @@ -# //~ ERROR 1:1: 1:2 error: expected item +// 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. + +# //~ ERROR 11:1: 11:2 error: expected item diff --git a/src/test/compile-fail/conflicting-implementations-aux.rs b/src/test/compile-fail/conflicting-implementations-aux.rs index e39059124a0..3a1f696193e 100644 --- a/src/test/compile-fail/conflicting-implementations-aux.rs +++ b/src/test/compile-fail/conflicting-implementations-aux.rs @@ -17,7 +17,8 @@ use trait_impl_conflict::Foo; impl<A> Foo for A { //~^ ERROR conflicting implementations for trait `trait_impl_conflict::Foo` -//~^^ ERROR cannot provide an extension implementation where both trait and type are not defined in this crate +//~^^ ERROR cannot provide an extension implementation where both trait and type +// are not defined in this crate } fn main() { diff --git a/src/test/compile-fail/dead-code-ret.rs b/src/test/compile-fail/dead-code-ret.rs index 1d59406d1bc..7860e19ea3e 100644 --- a/src/test/compile-fail/dead-code-ret.rs +++ b/src/test/compile-fail/dead-code-ret.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // xfail'd because the lint pass doesn't know to ignore standard library diff --git a/src/test/run-fail/unwind-box-trait.rs b/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs index 2139508c9e4..582c95b746b 100644 --- a/src/test/run-fail/unwind-box-trait.rs +++ b/src/test/compile-fail/deriving-span-Show-enum-struct-variant.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,24 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; +// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py' -// error-pattern:fail +#[feature(struct_variant)]; +extern mod extra; -fn failfn() { - fail!(); -} -trait i { - fn foo(&self); -} +struct Error; -impl i for ~int { - fn foo(&self) { } +#[deriving(Show)] +enum Enum { + A { + x: Error //~ ERROR + } } -fn main() { - let x = @~0 as @i; - failfn(); - error!("{:?}", x); -} +fn main() {} diff --git a/src/test/compile-fail/deriving-span-Show-enum.rs b/src/test/compile-fail/deriving-span-Show-enum.rs new file mode 100644 index 00000000000..92efe01fa38 --- /dev/null +++ b/src/test/compile-fail/deriving-span-Show-enum.rs @@ -0,0 +1,26 @@ +// 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. + +// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py' + +#[feature(struct_variant)]; +extern mod extra; + + +struct Error; + +#[deriving(Show)] +enum Enum { + A( + Error //~ ERROR + ) +} + +fn main() {} diff --git a/src/test/run-pass/boxed-trait-with-vstore.rs b/src/test/compile-fail/deriving-span-Show-struct.rs index aab5053693c..7eff82f9d13 100644 --- a/src/test/run-pass/boxed-trait-with-vstore.rs +++ b/src/test/compile-fail/deriving-span-Show-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,19 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; +// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py' -trait Foo { - fn foo(@self); -} +#[feature(struct_variant)]; +extern mod extra; -impl Foo for int { - fn foo(@self) { - println!("Hello world!"); - } -} -pub fn main() { - let x = @3 as @Foo; - x.foo(); +struct Error; + +#[deriving(Show)] +struct Struct { + x: Error //~ ERROR } + +fn main() {} diff --git a/src/test/run-pass/xc_conditions_client_2.rs b/src/test/compile-fail/deriving-span-Show-tuple-struct.rs index b3164f1f0aa..600a0400350 100644 --- a/src/test/run-pass/xc_conditions_client_2.rs +++ b/src/test/compile-fail/deriving-span-Show-tuple-struct.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,12 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-fast -// aux-build:xc_conditions_2.rs +// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py' -extern mod xc_conditions_2; -use xcc = xc_conditions_2; +#[feature(struct_variant)]; +extern mod extra; -pub fn main() { - xcc::oops::cond.trap(|_| 1).inside(|| xcc::oops::cond.raise(1)); -} + +struct Error; + +#[deriving(Show)] +struct Struct( + Error //~ ERROR +); + +fn main() {} diff --git a/src/test/compile-fail/does-nothing.rs b/src/test/compile-fail/does-nothing.rs index 9d2b68ddb81..23b9f048242 100644 --- a/src/test/compile-fail/does-nothing.rs +++ b/src/test/compile-fail/does-nothing.rs @@ -1,2 +1,12 @@ +// 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. + // error-pattern: unresolved name `this_does_nothing_what_the`. fn main() { info!("doing"); this_does_nothing_what_the; info!("boing"); } diff --git a/src/test/compile-fail/eval-enum.rs b/src/test/compile-fail/eval-enum.rs index f92dad961d1..92b7b601e4d 100644 --- a/src/test/compile-fail/eval-enum.rs +++ b/src/test/compile-fail/eval-enum.rs @@ -1,3 +1,13 @@ +// 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. + enum test { div_zero = 1/0, //~ERROR expected constant: attempted to divide by zero rem_zero = 1%0 //~ERROR expected constant: attempted remainder with a divisor of zero diff --git a/src/test/compile-fail/extenv-not-defined-default.rs b/src/test/compile-fail/extenv-not-defined-default.rs index 24e447eec6d..d99d4dc33a2 100644 --- a/src/test/compile-fail/extenv-not-defined-default.rs +++ b/src/test/compile-fail/extenv-not-defined-default.rs @@ -8,4 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { env!("__HOPEFULLY_NOT_DEFINED__"); } //~ ERROR: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined +fn main() { + env!("__HOPEFULLY_NOT_DEFINED__"); + //~^ ERROR: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined +} diff --git a/src/test/compile-fail/generic-impl-less-params-with-defaults.rs b/src/test/compile-fail/generic-impl-less-params-with-defaults.rs index 28e7a37778a..a95124239a9 100644 --- a/src/test/compile-fail/generic-impl-less-params-with-defaults.rs +++ b/src/test/compile-fail/generic-impl-less-params-with-defaults.rs @@ -17,6 +17,8 @@ impl<A, B, C = (A, B)> Foo<A, B, C> { } fn main() { - Foo::<int>::new(); //~ ERROR the impl referenced by this path needs at least 2 type parameters, but 1 type parameter were supplied - //~^ ERROR not enough type parameters provided: expected at least 2, found 1 + Foo::<int>::new(); + //~^ ERROR the impl referenced by this path needs at least 2 type parameters, + // but 1 was supplied + //~^^^ ERROR not enough type parameters provided: expected at least 2, found 1 } diff --git a/src/test/compile-fail/generic-impl-more-params-with-defaults.rs b/src/test/compile-fail/generic-impl-more-params-with-defaults.rs index 10404680cdd..c6ee8a870ee 100644 --- a/src/test/compile-fail/generic-impl-more-params-with-defaults.rs +++ b/src/test/compile-fail/generic-impl-more-params-with-defaults.rs @@ -19,6 +19,8 @@ impl<T, A = Heap> Vec<T, A> { } fn main() { - Vec::<int, Heap, bool>::new(); //~ ERROR the impl referenced by this path needs at most 2 type parameters, but 3 type parameters were supplied - //~^ ERROR too many type parameters provided: expected at most 2, found 3 + Vec::<int, Heap, bool>::new(); + //~^ ERROR the impl referenced by this path needs at most 2 type parameters, + // but 3 were supplied + //~^^^ ERROR too many type parameters provided: expected at most 2, found 3 } diff --git a/src/test/compile-fail/generic-type-more-params-with-defaults.rs b/src/test/compile-fail/generic-type-more-params-with-defaults.rs index 65c0d09ccf4..b4c80bc1e3d 100644 --- a/src/test/compile-fail/generic-type-more-params-with-defaults.rs +++ b/src/test/compile-fail/generic-type-more-params-with-defaults.rs @@ -15,5 +15,6 @@ struct Heap; struct Vec<T, A = Heap>; fn main() { - let _: Vec<int, Heap, bool>; //~ ERROR wrong number of type arguments: expected at most 2 but found 3 + let _: Vec<int, Heap, bool>; + //~^ ERROR wrong number of type arguments: expected at most 2 but found 3 } diff --git a/src/test/compile-fail/invalid-crate-type.rs b/src/test/compile-fail/invalid-crate-type.rs index 2a80760cd1b..e1398b2a361 100644 --- a/src/test/compile-fail/invalid-crate-type.rs +++ b/src/test/compile-fail/invalid-crate-type.rs @@ -1,3 +1,13 @@ +// 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. + // regression test for issue 11256 #[crate_type="foo"]; //~ ERROR invalid `crate_type` value diff --git a/src/test/compile-fail/issue-2354.rs b/src/test/compile-fail/issue-2354.rs index 9761bd3317c..a2bb56fdf5f 100644 --- a/src/test/compile-fail/issue-2354.rs +++ b/src/test/compile-fail/issue-2354.rs @@ -19,4 +19,4 @@ fn bar() { while (i < 1000) {} } -fn main() {} //~ ERROR This file contains an un-closed delimiter +fn main() {} //~ ERROR this file contains an un-closed delimiter diff --git a/src/test/compile-fail/issue-2718-a.rs b/src/test/compile-fail/issue-2718-a.rs index 8afaf8995c2..b78e01f2b7a 100644 --- a/src/test/compile-fail/issue-2718-a.rs +++ b/src/test/compile-fail/issue-2718-a.rs @@ -18,7 +18,8 @@ pub struct send_packet<T> { mod pingpong { use send_packet; pub type ping = send_packet<pong>; - pub struct pong(send_packet<ping>); //~ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable + pub struct pong(send_packet<ping>); + //~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable } fn main() {} diff --git a/src/test/compile-fail/issue-3008-1.rs b/src/test/compile-fail/issue-3008-1.rs index 6d8dec687cd..3613fb8ccbe 100644 --- a/src/test/compile-fail/issue-3008-1.rs +++ b/src/test/compile-fail/issue-3008-1.rs @@ -9,7 +9,8 @@ // except according to those terms. enum foo { foo(bar) } -enum bar { bar_none, bar_some(bar) } //~ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable +enum bar { bar_none, bar_some(bar) } +//~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable fn main() { } diff --git a/src/test/compile-fail/issue-3008-2.rs b/src/test/compile-fail/issue-3008-2.rs index 88ebf610aaf..db3124214bd 100644 --- a/src/test/compile-fail/issue-3008-2.rs +++ b/src/test/compile-fail/issue-3008-2.rs @@ -9,8 +9,9 @@ // except according to those terms. enum foo { foo(bar) } -struct bar { x: bar } //~ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable -//~^ ERROR this type cannot be instantiated without an instance of itself +struct bar { x: bar } +//~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +//~^^ ERROR this type cannot be instantiated without an instance of itself fn main() { } diff --git a/src/test/compile-fail/issue-3008-3.rs b/src/test/compile-fail/issue-3008-3.rs index 8680ee8707e..b8ef57e2dd3 100644 --- a/src/test/compile-fail/issue-3008-3.rs +++ b/src/test/compile-fail/issue-3008-3.rs @@ -9,7 +9,8 @@ // except according to those terms. enum E1 { V1(E2<E1>), } -enum E2<T> { V2(E2<E1>), } //~ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable +enum E2<T> { V2(E2<E1>), } +//~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable fn main() { } diff --git a/src/test/compile-fail/issue-3038.rs b/src/test/compile-fail/issue-3038.rs index d0c7a07859e..691bd3b4211 100644 --- a/src/test/compile-fail/issue-3038.rs +++ b/src/test/compile-fail/issue-3038.rs @@ -20,16 +20,16 @@ fn main() let _z = match g(1, 2) { g(x, x) => { info!("{:?}", x + x); } - //~^ ERROR Identifier `x` is bound more than once in the same pattern + //~^ ERROR identifier `x` is bound more than once in the same pattern }; let _z = match i(l(1, 2), m(3, 4)) { - i(l(x, _), m(_, x)) //~ ERROR Identifier `x` is bound more than once in the same pattern + i(l(x, _), m(_, x)) //~ ERROR identifier `x` is bound more than once in the same pattern => { error!("{:?}", x + x); } }; let _z = match (1, 2) { - (x, x) => { x } //~ ERROR Identifier `x` is bound more than once in the same pattern + (x, x) => { x } //~ ERROR identifier `x` is bound more than once in the same pattern }; } diff --git a/src/test/compile-fail/issue-3477.rs b/src/test/compile-fail/issue-3477.rs index 23e680fd851..df9af9c6bcc 100644 --- a/src/test/compile-fail/issue-3477.rs +++ b/src/test/compile-fail/issue-3477.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { let _p: char = 100; //~ ERROR mismatched types: expected `char` but found } diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index fe57d7171a6..9f60cceb152 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -17,7 +17,8 @@ trait PTrait { impl PTrait for P { fn getChildOption(&self) -> Option<@P> { - static childVal: @P = self.child.get(); //~ ERROR attempt to use a non-constant value in a constant + static childVal: @P = self.child.get(); + //~^ ERROR attempt to use a non-constant value in a constant fail!(); } } diff --git a/src/test/compile-fail/issue-3680.rs b/src/test/compile-fail/issue-3680.rs index de2165ff633..f6b5be349d0 100644 --- a/src/test/compile-fail/issue-3680.rs +++ b/src/test/compile-fail/issue-3680.rs @@ -10,6 +10,8 @@ fn main() { match None { - Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<<generic #1>>` but found `std::result::Result<<generic #2>,<generic #3>>` + Err(_) => () + //~^ ERROR mismatched types: expected `std::option::Option<<generic #1>>` + // but found `std::result::Result<<generic #2>,<generic #3>>` } } diff --git a/src/test/compile-fail/issue-3779.rs b/src/test/compile-fail/issue-3779.rs index 79360597f72..19a7ed05bf4 100644 --- a/src/test/compile-fail/issue-3779.rs +++ b/src/test/compile-fail/issue-3779.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct S { //~ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +struct S { + //~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable element: Option<S> } diff --git a/src/test/compile-fail/issue-3953.rs b/src/test/compile-fail/issue-3953.rs index 308a8819355..cfb10d39201 100644 --- a/src/test/compile-fail/issue-3953.rs +++ b/src/test/compile-fail/issue-3953.rs @@ -10,7 +10,7 @@ use std::cmp::Eq; -trait Hahaha: Eq + Eq + Eq + Eq + Eq + //~ ERROR Duplicate supertrait +trait Hahaha: Eq + Eq + Eq + Eq + Eq + //~ ERROR duplicate supertrait Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + Eq + diff --git a/src/test/compile-fail/issue-4517.rs b/src/test/compile-fail/issue-4517.rs index 0fbc79b1bc7..b280365a7ba 100644 --- a/src/test/compile-fail/issue-4517.rs +++ b/src/test/compile-fail/issue-4517.rs @@ -1,6 +1,18 @@ +// 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. + fn bar(int_param: int) {} fn main() { - let foo: [u8, ..4] = [1u8, ..4u8]; - bar(foo); //~ ERROR mismatched types: expected `int` but found `[u8, .. 4]` (expected int but found vector) + let foo: [u8, ..4] = [1u8, ..4u8]; + bar(foo); + //~^ ERROR mismatched types: expected `int` but found `[u8, .. 4]` + // (expected int but found vector) } diff --git a/src/test/compile-fail/issue-4968.rs b/src/test/compile-fail/issue-4968.rs index 5739f3dc46b..ec1f62c33fc 100644 --- a/src/test/compile-fail/issue-4968.rs +++ b/src/test/compile-fail/issue-4968.rs @@ -12,5 +12,7 @@ static A: (int,int) = (4,2); fn main() { - match 42 { A => () } //~ ERROR mismatched types: expected `<generic integer #0>` but found `(int,int)` (expected integral variable but found tuple) + match 42 { A => () } + //~^ ERROR mismatched types: expected `<generic integer #0>` but found `(int,int)` + // (expected integral variable but found tuple) } diff --git a/src/test/compile-fail/issue-5100.rs b/src/test/compile-fail/issue-5100.rs index 25efa108ae3..ae523e1a9c4 100644 --- a/src/test/compile-fail/issue-5100.rs +++ b/src/test/compile-fail/issue-5100.rs @@ -17,15 +17,19 @@ fn main() { } match (true, false) { - (true, false, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found tuple (expected a tuple with 2 elements but found one with 3 elements) + (true, false, false) => () + //~^ ERROR mismatched types: expected `(bool,bool)` but found tuple + // (expected a tuple with 2 elements but found one with 3 elements) } match (true, false) { - ~(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found a ~-box pattern + ~(true, false) => () + //~^ ERROR mismatched types: expected `(bool,bool)` but found a ~-box pattern } match (true, false) { - &(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found an &-pointer pattern + &(true, false) => () + //~^ ERROR mismatched types: expected `(bool,bool)` but found an &-pointer pattern } diff --git a/src/test/compile-fail/issue-5153.rs b/src/test/compile-fail/issue-5153.rs index 619ce688d08..5228e03b8bd 100644 --- a/src/test/compile-fail/issue-5153.rs +++ b/src/test/compile-fail/issue-5153.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - -// error-pattern: type `@Foo:'static` does not implement any method in scope named `foo` +// error-pattern: type `&Foo<no-bounds>` does not implement any method in scope named `foo` trait Foo { fn foo(~self); @@ -21,5 +19,5 @@ impl Foo for int { } fn main() { - (@5 as @Foo).foo(); + (&5 as &Foo).foo(); } diff --git a/src/test/compile-fail/issue-5239-1.rs b/src/test/compile-fail/issue-5239-1.rs index 399dd453f75..88b08655caa 100644 --- a/src/test/compile-fail/issue-5239-1.rs +++ b/src/test/compile-fail/issue-5239-1.rs @@ -11,5 +11,6 @@ // Regression test for issue #5239 fn main() { - let x: |int| -> int = |ref x| { x += 1; }; //~ ERROR binary assignment operation `+=` cannot be applied to type `&int` + let x: |int| -> int = |ref x| { x += 1; }; + //~^ ERROR binary assignment operation `+=` cannot be applied to type `&int` } diff --git a/src/test/compile-fail/issue-5806.rs b/src/test/compile-fail/issue-5806.rs index 676e8897dde..8ac2429a331 100644 --- a/src/test/compile-fail/issue-5806.rs +++ b/src/test/compile-fail/issue-5806.rs @@ -1,3 +1,13 @@ +// 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. + // opyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. diff --git a/src/test/compile-fail/issue-6596.rs b/src/test/compile-fail/issue-6596.rs index 339f21d10c3..235a8003958 100644 --- a/src/test/compile-fail/issue-6596.rs +++ b/src/test/compile-fail/issue-6596.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(macro_rules)]; // error-pattern: unknown macro variable `nonexistent` diff --git a/src/test/compile-fail/issue-6762.rs b/src/test/compile-fail/issue-6762.rs index 22bb660a080..bdb8c7299c5 100644 --- a/src/test/compile-fail/issue-6762.rs +++ b/src/test/compile-fail/issue-6762.rs @@ -1,3 +1,13 @@ +// 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. + //xfail-test // Creating a stack closure which references an owned pointer and then diff --git a/src/test/compile-fail/issue-6804.rs b/src/test/compile-fail/issue-6804.rs index 23d9f3199c1..60f16275fc4 100644 --- a/src/test/compile-fail/issue-6804.rs +++ b/src/test/compile-fail/issue-6804.rs @@ -1,3 +1,13 @@ +// 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. + #[allow(dead_code)]; // Matching against NaN should result in a warning diff --git a/src/test/compile-fail/issue-6977.rs b/src/test/compile-fail/issue-6977.rs index 6c062b0f3f7..d0ff116b42f 100644 --- a/src/test/compile-fail/issue-6977.rs +++ b/src/test/compile-fail/issue-6977.rs @@ -1,3 +1,13 @@ +// 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. + // Trying to create a fixed-length vector with a negative size fn main() { diff --git a/src/test/compile-fail/issue-7013.rs b/src/test/compile-fail/issue-7013.rs index cf7cb1a5a53..05d7b878d76 100644 --- a/src/test/compile-fail/issue-7013.rs +++ b/src/test/compile-fail/issue-7013.rs @@ -36,7 +36,8 @@ struct A fn main() { - let a = A {v: ~B{v: None} as ~Foo}; //~ ERROR cannot pack type `~B`, which does not fulfill `Send` + let a = A {v: ~B{v: None} as ~Foo}; + //~^ ERROR cannot pack type `~B`, which does not fulfill `Send` let v = Rc::new(RefCell::new(a)); let w = v.clone(); let b = v.borrow(); diff --git a/src/test/compile-fail/issue-7246.rs b/src/test/compile-fail/issue-7246.rs index ce31ac2e8fa..74bc1ac0d86 100644 --- a/src/test/compile-fail/issue-7246.rs +++ b/src/test/compile-fail/issue-7246.rs @@ -13,7 +13,7 @@ use std::ptr; pub unsafe fn g() { - return; + return; if *ptr::null() {}; //~ ERROR unreachable } diff --git a/src/test/compile-fail/issue-897-2.rs b/src/test/compile-fail/issue-897-2.rs index c39c258c701..5c777880751 100644 --- a/src/test/compile-fail/issue-897-2.rs +++ b/src/test/compile-fail/issue-897-2.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // xfail'd because the lint pass doesn't know to ignore standard library // stuff. diff --git a/src/test/compile-fail/keyword-super.rs b/src/test/compile-fail/keyword-super.rs index 3c9c403e83d..0a4ec841bd3 100644 --- a/src/test/compile-fail/keyword-super.rs +++ b/src/test/compile-fail/keyword-super.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { let super: int; //~ ERROR found `super` in ident position } diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs index de277b4c36e..1557aff6689 100644 --- a/src/test/compile-fail/kindck-destructor-owned.rs +++ b/src/test/compile-fail/kindck-destructor-owned.rs @@ -1,10 +1,21 @@ +// 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. + #[feature(managed_boxes)]; struct Foo { f: @int, } -impl Drop for Foo { //~ ERROR cannot implement a destructor on a structure that does not satisfy Send +impl Drop for Foo { + //~^ ERROR cannot implement a destructor on a structure that does not satisfy Send fn drop(&mut self) { } } diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index e996a0468e4..234043a8799 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // xfail'd because to_foo() doesn't work. diff --git a/src/test/compile-fail/kindck-owned-trait.rs b/src/test/compile-fail/kindck-owned-trait.rs deleted file mode 100644 index 87e9769d97e..00000000000 --- a/src/test/compile-fail/kindck-owned-trait.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 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. - -#[feature(managed_boxes)]; - -trait foo { fn foo(&self); } - -fn to_foo<T:Clone + foo>(t: T) -> @foo { - @t as @foo - //~^ ERROR value may contain references; add `'static` bound - //~^^ ERROR cannot pack type - //~^^^ ERROR value may contain references -} - -fn to_foo2<T:Clone + foo + 'static>(t: T) -> @foo { - @t as @foo -} - -fn main() {} diff --git a/src/test/compile-fail/lint-heap-memory.rs b/src/test/compile-fail/lint-heap-memory.rs index 8899f3f5dbb..fa359dcd538 100644 --- a/src/test/compile-fail/lint-heap-memory.rs +++ b/src/test/compile-fail/lint-heap-memory.rs @@ -23,8 +23,6 @@ fn main() { @2; //~ ERROR type uses managed - fn f(_: @Clone) {} //~ ERROR type uses managed - ~2; //~ ERROR type uses owned ~[1]; //~ ERROR type uses owned //~^ ERROR type uses owned diff --git a/src/test/compile-fail/lint-type-overflow.rs b/src/test/compile-fail/lint-type-overflow.rs index 27cd2bae125..e6c535925a4 100644 --- a/src/test/compile-fail/lint-type-overflow.rs +++ b/src/test/compile-fail/lint-type-overflow.rs @@ -34,9 +34,9 @@ fn main() { test(1000); //~ error: literal out of range for its type let x = 128_i8; //~ error: literal out of range for its type - let x = 127_i8; - let x = -128_i8; - let x = -(128_i8); + let x = 127_i8; + let x = -128_i8; + let x = -(128_i8); let x = -129_i8; //~ error: literal out of range for its type let x: i32 = 2147483647; // should be OK diff --git a/src/test/compile-fail/liveness-return-last-stmt-semi.rs b/src/test/compile-fail/liveness-return-last-stmt-semi.rs index dc131698b90..1b32c008af1 100644 --- a/src/test/compile-fail/liveness-return-last-stmt-semi.rs +++ b/src/test/compile-fail/liveness-return-last-stmt-semi.rs @@ -12,8 +12,9 @@ #[feature(macro_rules)]; -macro_rules! test ( () => { fn foo() -> int { 1i; } } ) //~ ERROR not all control paths return a value - //~^ NOTE consider removing this semicolon +macro_rules! test ( () => { fn foo() -> int { 1i; } } ) + //~^ ERROR not all control paths return a value + //~^^ NOTE consider removing this semicolon fn no_return() -> int {} //~ ERROR not all control paths return a value diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index 6140b81b7d0..7a2d89ecfc7 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // xfail'd because lint is messed up with the new visitor transition diff --git a/src/test/compile-fail/macro-inner-attributes.rs b/src/test/compile-fail/macro-inner-attributes.rs index d8fbb8b879c..104438848c4 100644 --- a/src/test/compile-fail/macro-inner-attributes.rs +++ b/src/test/compile-fail/macro-inner-attributes.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(macro_rules)]; macro_rules! test ( ($nm:ident, diff --git a/src/test/compile-fail/macro-outer-attributes.rs b/src/test/compile-fail/macro-outer-attributes.rs index cd3c9df6a72..6bd184ce6a6 100644 --- a/src/test/compile-fail/macro-outer-attributes.rs +++ b/src/test/compile-fail/macro-outer-attributes.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(macro_rules)]; macro_rules! test ( ($nm:ident, diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index 0a1eab913be..a3b5a1264f7 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -8,16 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - use std::container::Map; use std::hashmap::HashMap; // Test that trait types printed in error msgs include the type arguments. fn main() { - let x: @HashMap<~str, ~str> = @HashMap::new(); - let x: @Map<~str, ~str> = x; - let y: @Map<uint, ~str> = @x; - //~^ ERROR failed to find an implementation of trait std::container::Map<uint,~str> for @std::container::Map<~str,~str>:'static + let x: ~HashMap<~str, ~str> = ~HashMap::new(); + let x: ~Map<~str, ~str> = x; + let y: ~Map<uint, ~str> = ~x; + //~^ ERROR failed to find an implementation of trait std::container::Map<uint,~str> + // for ~std::container::Map<~str,~str>:Send } diff --git a/src/test/compile-fail/match-ill-type1.rs b/src/test/compile-fail/match-ill-type1.rs index 4d2b95b61ea..5ffcb26e12e 100644 --- a/src/test/compile-fail/match-ill-type1.rs +++ b/src/test/compile-fail/match-ill-type1.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { match 1 { 1..2u => 1, //~ ERROR mismatched types in range diff --git a/src/test/compile-fail/match-ill-type2.rs b/src/test/compile-fail/match-ill-type2.rs index 020ccde8452..d8d665e2af6 100644 --- a/src/test/compile-fail/match-ill-type2.rs +++ b/src/test/compile-fail/match-ill-type2.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { match 1 { 1 => 1, //~ ERROR mismatched types between arms diff --git a/src/test/compile-fail/match-struct.rs b/src/test/compile-fail/match-struct.rs index 6e9bf603aef..1ebb8ed5ddc 100644 --- a/src/test/compile-fail/match-struct.rs +++ b/src/test/compile-fail/match-struct.rs @@ -1,3 +1,13 @@ +// 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. + struct S { a: int } enum E { C(int) } diff --git a/src/test/compile-fail/match-vec-fixed.rs b/src/test/compile-fail/match-vec-fixed.rs index b3e139805a0..e778dd18e68 100644 --- a/src/test/compile-fail/match-vec-fixed.rs +++ b/src/test/compile-fail/match-vec-fixed.rs @@ -1,3 +1,13 @@ +// 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. + fn a() { let v = [1, 2, 3]; match v { diff --git a/src/test/compile-fail/match-vec-invalid.rs b/src/test/compile-fail/match-vec-invalid.rs index 2cf2d5b93b0..5a50cb48da6 100644 --- a/src/test/compile-fail/match-vec-invalid.rs +++ b/src/test/compile-fail/match-vec-invalid.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { let a = ~[]; match a { diff --git a/src/test/compile-fail/match-vec-mismatch-2.rs b/src/test/compile-fail/match-vec-mismatch-2.rs index 6ea0300cf1e..c3a06aa0e2c 100644 --- a/src/test/compile-fail/match-vec-mismatch-2.rs +++ b/src/test/compile-fail/match-vec-mismatch-2.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { match () { [()] => { } //~ ERROR mismatched types: expected `()` but found a vector pattern diff --git a/src/test/compile-fail/match-vec-mismatch.rs b/src/test/compile-fail/match-vec-mismatch.rs index 5eca6546ea9..56c7264e36e 100644 --- a/src/test/compile-fail/match-vec-mismatch.rs +++ b/src/test/compile-fail/match-vec-mismatch.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { match ~"foo" { ['f', 'o', ..] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern diff --git a/src/test/compile-fail/match-vec-unreachable.rs b/src/test/compile-fail/match-vec-unreachable.rs index 88cf4537f10..d595effcb4b 100644 --- a/src/test/compile-fail/match-vec-unreachable.rs +++ b/src/test/compile-fail/match-vec-unreachable.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { let x: ~[(int, int)] = ~[]; match x { diff --git a/src/test/compile-fail/moves-based-on-type-access-to-field.rs b/src/test/compile-fail/moves-based-on-type-access-to-field.rs index 1a2beedff93..f07d4fcf70c 100644 --- a/src/test/compile-fail/moves-based-on-type-access-to-field.rs +++ b/src/test/compile-fail/moves-based-on-type-access-to-field.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that if you move from `x.f` or `x[0]`, `x` is inaccessible. // Also tests that we give a more specific error message. diff --git a/src/test/compile-fail/moves-based-on-type-block-bad.rs b/src/test/compile-fail/moves-based-on-type-block-bad.rs index 3cad214a44a..4172d03d3de 100644 --- a/src/test/compile-fail/moves-based-on-type-block-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-block-bad.rs @@ -1,3 +1,13 @@ +// 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. + struct S { x: ~E } diff --git a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs index fe9c7ede83a..ca22907062b 100644 --- a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs @@ -1,3 +1,13 @@ +// 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. + use std::task; fn main() { diff --git a/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs b/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs index b70c9e11f34..2cadb3422e5 100644 --- a/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs +++ b/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that references to move-by-default values trigger moves when // they occur as part of various kinds of expressions. diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index 4e2391ea25f..4c62e47965e 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that references to move-by-default values trigger moves when // they occur as part of various kinds of expressions. diff --git a/src/test/compile-fail/moves-based-on-type-match-bindings.rs b/src/test/compile-fail/moves-based-on-type-match-bindings.rs index 42944a206b3..6ea4b488738 100644 --- a/src/test/compile-fail/moves-based-on-type-match-bindings.rs +++ b/src/test/compile-fail/moves-based-on-type-match-bindings.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that bindings to move-by-default values trigger moves of the // discriminant. Also tests that the compiler explains the move in // terms of the binding, not the discriminant. diff --git a/src/test/compile-fail/moves-sru-moved-field.rs b/src/test/compile-fail/moves-sru-moved-field.rs index 57c1cb5ecc6..a4cbb30f93f 100644 --- a/src/test/compile-fail/moves-sru-moved-field.rs +++ b/src/test/compile-fail/moves-sru-moved-field.rs @@ -1,3 +1,13 @@ +// 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. + type Noncopyable = proc(); struct Foo { diff --git a/src/test/compile-fail/multiple-macro-registrars.rs b/src/test/compile-fail/multiple-macro-registrars.rs index 7802c13bd3a..82b1438d6fe 100644 --- a/src/test/compile-fail/multiple-macro-registrars.rs +++ b/src/test/compile-fail/multiple-macro-registrars.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: Multiple macro registration functions found +// error-pattern: multiple macro registration functions found #[feature(macro_registrar)]; diff --git a/src/test/compile-fail/mutable-enum-indirect.rs b/src/test/compile-fail/mutable-enum-indirect.rs index 0e14de61ff7..501b17b202c 100644 --- a/src/test/compile-fail/mutable-enum-indirect.rs +++ b/src/test/compile-fail/mutable-enum-indirect.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that an `&` pointer to something inherently mutable is itself // to be considered mutable. diff --git a/src/test/compile-fail/new-box-syntax-bad.rs b/src/test/compile-fail/new-box-syntax-bad.rs index 942c8621207..4b00334899d 100644 --- a/src/test/compile-fail/new-box-syntax-bad.rs +++ b/src/test/compile-fail/new-box-syntax-bad.rs @@ -1,3 +1,13 @@ +// 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. + /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ diff --git a/src/test/compile-fail/no_crate_type.rs b/src/test/compile-fail/no_crate_type.rs index 9ba006e8c44..51ca71ae2cc 100644 --- a/src/test/compile-fail/no_crate_type.rs +++ b/src/test/compile-fail/no_crate_type.rs @@ -1,3 +1,13 @@ +// 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. + // regresion test for issue 11256 #[crate_type]; //~ ERROR `crate_type` requires a value diff --git a/src/test/compile-fail/no_freeze-enum.rs b/src/test/compile-fail/no_freeze-enum.rs index 9b7189d02bb..e27b9dd85b4 100644 --- a/src/test/compile-fail/no_freeze-enum.rs +++ b/src/test/compile-fail/no_freeze-enum.rs @@ -16,5 +16,7 @@ fn bar<T: Freeze>(_: T) {} fn main() { let x = A(marker::NoFreeze); - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Freeze` + bar(x); + //~^ ERROR instantiating a type parameter with an incompatible type `Foo`, + // which does not fulfill `Freeze` } diff --git a/src/test/compile-fail/no_freeze-rc.rs b/src/test/compile-fail/no_freeze-rc.rs index a963446b84c..b814a71dcbe 100644 --- a/src/test/compile-fail/no_freeze-rc.rs +++ b/src/test/compile-fail/no_freeze-rc.rs @@ -15,5 +15,7 @@ fn bar<T: Freeze>(_: T) {} fn main() { let x = Rc::new(RefCell::new(5)); - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Freeze` + bar(x); + //~^ ERROR instantiating a type parameter with an incompatible type + // `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Freeze` } diff --git a/src/test/compile-fail/no_freeze-struct.rs b/src/test/compile-fail/no_freeze-struct.rs index 9ac7966e704..c85574438ba 100644 --- a/src/test/compile-fail/no_freeze-struct.rs +++ b/src/test/compile-fail/no_freeze-struct.rs @@ -16,5 +16,7 @@ fn bar<T: Freeze>(_: T) {} fn main() { let x = Foo { a: 5, m: marker::NoFreeze }; - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Freeze` + bar(x); + //~^ ERROR instantiating a type parameter with an incompatible type `Foo`, + // which does not fulfill `Freeze` } diff --git a/src/test/compile-fail/no_send-enum.rs b/src/test/compile-fail/no_send-enum.rs index 7a5ad743d21..4395151cbc1 100644 --- a/src/test/compile-fail/no_send-enum.rs +++ b/src/test/compile-fail/no_send-enum.rs @@ -18,5 +18,7 @@ fn bar<T: Send>(_: T) {} fn main() { let x = A(marker::NoSend); - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Send` + bar(x); + //~^ ERROR instantiating a type parameter with an incompatible type `Foo`, + // which does not fulfill `Send` } diff --git a/src/test/compile-fail/no_send-rc.rs b/src/test/compile-fail/no_send-rc.rs index d884ff7f231..20f1cbc47bc 100644 --- a/src/test/compile-fail/no_send-rc.rs +++ b/src/test/compile-fail/no_send-rc.rs @@ -14,5 +14,7 @@ fn bar<T: Send>(_: T) {} fn main() { let x = Rc::new(5); - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<int>`, which does not fulfill `Send` + bar(x); + //~^ ERROR instantiating a type parameter with an incompatible type `std::rc::Rc<int>`, + // which does not fulfill `Send` } diff --git a/src/test/compile-fail/no_send-struct.rs b/src/test/compile-fail/no_send-struct.rs index 7617602cbfb..5b083374c51 100644 --- a/src/test/compile-fail/no_send-struct.rs +++ b/src/test/compile-fail/no_send-struct.rs @@ -19,5 +19,7 @@ fn bar<T: Send>(_: T) {} fn main() { let x = Foo { a: 5, ns: marker::NoSend }; - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Send` + bar(x); + //~^ ERROR instantiating a type parameter with an incompatible type `Foo`, + // which does not fulfill `Send` } diff --git a/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs b/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs index 883ba5b0eaa..a4eba4b4cbf 100644 --- a/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs +++ b/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs @@ -11,5 +11,6 @@ enum State { ST_NULL, ST_WHITESPACE } fn main() { - ~[ST_NULL, ..(ST_WHITESPACE as uint)]; //~ ERROR expected constant integer for repeat count but found variable + ~[ST_NULL, ..(ST_WHITESPACE as uint)]; + //~^ ERROR expected constant integer for repeat count but found variable } diff --git a/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs b/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs index 857b53a2c22..2a9a0358cc6 100644 --- a/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs +++ b/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs @@ -12,6 +12,7 @@ fn main() { fn bar(n: int) { - let _x: [int, ..n]; //~ ERROR expected constant expr for vector length: Non-constant path in constant expr + let _x: [int, ..n]; + //~^ ERROR expected constant expr for vector length: non-constant path in constant expr } } diff --git a/src/test/compile-fail/non-exhaustive-match.rs b/src/test/compile-fail/non-exhaustive-match.rs index 51aa576fc94..eac0dcb310e 100644 --- a/src/test/compile-fail/non-exhaustive-match.rs +++ b/src/test/compile-fail/non-exhaustive-match.rs @@ -35,7 +35,8 @@ fn main() { (_, a) => {} (b, b) => {} } - match ~[Some(42), None, Some(21)] { //~ ERROR non-exhaustive patterns: vectors of length 0 not covered + match ~[Some(42), None, Some(21)] { + //~^ ERROR non-exhaustive patterns: vectors of length 0 not covered [Some(..), None, ..tail] => {} [Some(..), Some(..), ..tail] => {} [None] => {} diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs index 916bb74edb2..95f92380816 100644 --- a/src/test/compile-fail/object-does-not-impl-trait.rs +++ b/src/test/compile-fail/object-does-not-impl-trait.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - -// Test that an object type `@Foo` is not considered to implement the +// Test that an object type `~Foo` is not considered to implement the // trait `Foo`. Issue #5087. trait Foo {} fn take_foo<F:Foo>(f: F) {} -fn take_object(f: @Foo) { take_foo(f); } //~ ERROR failed to find an implementation of trait +fn take_object(f: ~Foo) { take_foo(f); } //~ ERROR failed to find an implementation of trait fn main() {} diff --git a/src/test/compile-fail/object-pointer-types.rs b/src/test/compile-fail/object-pointer-types.rs index 2270cb6f498..ab2aa928c26 100644 --- a/src/test/compile-fail/object-pointer-types.rs +++ b/src/test/compile-fail/object-pointer-types.rs @@ -8,35 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait Foo { fn borrowed(&self); fn borrowed_mut(&mut self); - fn managed(@self); - fn owned(~self); } fn borrowed_receiver(x: &Foo) { x.borrowed(); x.borrowed_mut(); // See [1] - x.managed(); //~ ERROR does not implement any method x.owned(); //~ ERROR does not implement any method } fn borrowed_mut_receiver(x: &mut Foo) { x.borrowed(); x.borrowed_mut(); - x.managed(); //~ ERROR does not implement any method - x.owned(); //~ ERROR does not implement any method -} - -fn managed_receiver(x: @Foo) { - x.borrowed(); - x.borrowed_mut(); // See [1] - x.managed(); x.owned(); //~ ERROR does not implement any method } diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs index 9dae4be5b51..a26733ebcee 100644 --- a/src/test/compile-fail/pattern-tyvar-2.rs +++ b/src/test/compile-fail/pattern-tyvar-2.rs @@ -14,6 +14,7 @@ extern mod extra; enum bar { t1((), Option<~[int]>), t2, } // n.b. my change changes this error message, but I think it's right -- tjc -fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { fail!(); } } } //~ ERROR binary operation `*` cannot be applied to +fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { fail!(); } } } +//~^ ERROR binary operation `*` cannot be applied to fn main() { } diff --git a/src/test/compile-fail/private-method-inherited.rs b/src/test/compile-fail/private-method-inherited.rs index bc27027e886..c6419991b11 100644 --- a/src/test/compile-fail/private-method-inherited.rs +++ b/src/test/compile-fail/private-method-inherited.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that inherited visibility applies to methods. mod a { diff --git a/src/test/compile-fail/private-variant-xc.rs b/src/test/compile-fail/private-variant-xc.rs index c3946b33010..357e650ffce 100644 --- a/src/test/compile-fail/private-variant-xc.rs +++ b/src/test/compile-fail/private-variant-xc.rs @@ -1,3 +1,13 @@ +// 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. + // aux-build:private_variant_xc.rs // xfail-test diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs index b7be0dd7b9b..2cd96735a07 100644 --- a/src/test/compile-fail/regions-addr-of-self.rs +++ b/src/test/compile-fail/regions-addr-of-self.rs @@ -14,7 +14,8 @@ struct dog { impl dog { pub fn chase_cat(&mut self) { - let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime + let p: &'static mut uint = &mut self.cats_chased; + //~^ ERROR cannot infer an appropriate lifetime *p += 1u; } diff --git a/src/test/compile-fail/regions-addr-of-upvar-self.rs b/src/test/compile-fail/regions-addr-of-upvar-self.rs index 2f60898cfee..c8fe60a2490 100644 --- a/src/test/compile-fail/regions-addr-of-upvar-self.rs +++ b/src/test/compile-fail/regions-addr-of-upvar-self.rs @@ -17,7 +17,8 @@ struct dog { impl dog { pub fn chase_cat(&mut self) { let _f = || { - let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer an appropriate lifetime + let p: &'static mut uint = &mut self.food; + //~^ ERROR cannot infer an appropriate lifetime *p = 3u; }; } diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs index 09801d37ee9..817a4265a99 100644 --- a/src/test/compile-fail/regions-fn-bound.rs +++ b/src/test/compile-fail/regions-fn-bound.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // xfail'd because the first error does not show up. diff --git a/src/test/compile-fail/regions-freevar.rs b/src/test/compile-fail/regions-freevar.rs index 493b9c466bd..940a7f9afbb 100644 --- a/src/test/compile-fail/regions-freevar.rs +++ b/src/test/compile-fail/regions-freevar.rs @@ -12,7 +12,8 @@ fn wants_static_fn(_x: 'static ||) {} fn main() { let i = 3; - wants_static_fn(|| { //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements + wants_static_fn(|| { + //~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements info!("i={}", i); }) } diff --git a/src/test/compile-fail/regions-infer-paramd-method.rs b/src/test/compile-fail/regions-infer-paramd-method.rs index 62a65596f06..db091092589 100644 --- a/src/test/compile-fail/regions-infer-paramd-method.rs +++ b/src/test/compile-fail/regions-infer-paramd-method.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // xfail'd due to problems with by value self. diff --git a/src/test/compile-fail/regions-ref-in-fn-arg.rs b/src/test/compile-fail/regions-ref-in-fn-arg.rs index 9574f05fa58..8c8404f7abc 100644 --- a/src/test/compile-fail/regions-ref-in-fn-arg.rs +++ b/src/test/compile-fail/regions-ref-in-fn-arg.rs @@ -1,3 +1,13 @@ +// 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. + fn arg_item(~ref x: ~int) -> &'static int { x //~^ ERROR borrowed value does not live long enough } diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index 8e6b821294b..7aa545ab1b9 100644 --- a/src/test/compile-fail/regions-trait-1.rs +++ b/src/test/compile-fail/regions-trait-1.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - struct ctxt { v: uint } trait get_ctxt { @@ -29,12 +27,12 @@ impl<'a> get_ctxt for has_ctxt<'a> { } -fn get_v(gc: @get_ctxt) -> uint { +fn get_v(gc: ~get_ctxt) -> uint { gc.get_ctxt().v } fn main() { let ctxt = ctxt { v: 22u }; let hc = has_ctxt { c: &ctxt }; - assert_eq!(get_v(@hc as @get_ctxt), 22u); + assert_eq!(get_v(~hc as ~get_ctxt), 22u); } diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs index 01195d0ac94..6cd22799d42 100644 --- a/src/test/compile-fail/regions-trait-3.rs +++ b/src/test/compile-fail/regions-trait-3.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // xfail'd due to problems with by-value self. diff --git a/src/test/compile-fail/resolve-inconsistent-binding-mode.rs b/src/test/compile-fail/resolve-inconsistent-binding-mode.rs index 351daf461d2..a230e813a48 100644 --- a/src/test/compile-fail/resolve-inconsistent-binding-mode.rs +++ b/src/test/compile-fail/resolve-inconsistent-binding-mode.rs @@ -14,21 +14,24 @@ enum opts { fn matcher1(x: opts) { match x { - a(ref i) | b(i) => {} //~ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 + a(ref i) | b(i) => {} + //~^ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 c(_) => {} } } fn matcher2(x: opts) { match x { - a(ref i) | b(i) => {} //~ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 + a(ref i) | b(i) => {} + //~^ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 c(_) => {} } } fn matcher4(x: opts) { match x { - a(ref mut i) | b(ref i) => {} //~ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 + a(ref mut i) | b(ref i) => {} + //~^ ERROR variable `i` is bound with different mode in pattern #2 than in pattern #1 c(_) => {} } } diff --git a/src/test/compile-fail/selftype-traittype.rs b/src/test/compile-fail/selftype-traittype.rs index d6c97806201..73df5c3967c 100644 --- a/src/test/compile-fail/selftype-traittype.rs +++ b/src/test/compile-fail/selftype-traittype.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait add { fn plus(&self, x: Self) -> Self; } -fn do_add(x: @add, y: @add) -> @add { +fn do_add(x: ~add, y: ~add) -> ~add { x.plus(y) //~ ERROR cannot call a method whose type contains a self-type through an object } diff --git a/src/test/compile-fail/simd-type.rs b/src/test/compile-fail/simd-type.rs index 266c2a9c453..6a57ee76cdf 100644 --- a/src/test/compile-fail/simd-type.rs +++ b/src/test/compile-fail/simd-type.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(simd)]; #[simd] diff --git a/src/test/compile-fail/static-assert.rs b/src/test/compile-fail/static-assert.rs index 4f7f7dd7408..d9e3846c506 100644 --- a/src/test/compile-fail/static-assert.rs +++ b/src/test/compile-fail/static-assert.rs @@ -1,3 +1,13 @@ +// 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. + #[allow(dead_code)]; #[static_assert] diff --git a/src/test/compile-fail/static-assert2.rs b/src/test/compile-fail/static-assert2.rs index ceaa3889179..30c6f05bd60 100644 --- a/src/test/compile-fail/static-assert2.rs +++ b/src/test/compile-fail/static-assert2.rs @@ -1,3 +1,13 @@ +// 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. + #[allow(dead_code)]; #[static_assert] diff --git a/src/test/compile-fail/static-method-privacy.rs b/src/test/compile-fail/static-method-privacy.rs index b637037f60e..5e175aa0fee 100644 --- a/src/test/compile-fail/static-method-privacy.rs +++ b/src/test/compile-fail/static-method-privacy.rs @@ -1,3 +1,13 @@ +// 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. + mod a { pub struct S; impl S { diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index 35f5ac1bb18..ed9d3cd74d0 100644 --- a/src/test/compile-fail/static-region-bound.rs +++ b/src/test/compile-fail/static-region-bound.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(managed_boxes)]; fn f<T:'static>(_: T) {} diff --git a/src/test/compile-fail/static-vec-repeat-not-constant.rs b/src/test/compile-fail/static-vec-repeat-not-constant.rs index 7721e18537e..03be2cc8f0f 100644 --- a/src/test/compile-fail/static-vec-repeat-not-constant.rs +++ b/src/test/compile-fail/static-vec-repeat-not-constant.rs @@ -10,6 +10,7 @@ fn foo() -> int { 23 } -static a: [int, ..2] = [foo(), ..2]; //~ ERROR: function calls in constants are limited to struct and enum constructors +static a: [int, ..2] = [foo(), ..2]; +//~^ ERROR: function calls in constants are limited to struct and enum constructors fn main() {} diff --git a/src/test/compile-fail/staticness-mismatch.rs b/src/test/compile-fail/staticness-mismatch.rs index 9bcf0777bbd..a6082d31480 100644 --- a/src/test/compile-fail/staticness-mismatch.rs +++ b/src/test/compile-fail/staticness-mismatch.rs @@ -14,7 +14,8 @@ trait foo { } impl foo for int { - fn bar(&self) {} //~ ERROR method `bar` has a `&self` declaration in the impl, but not in the trait + fn bar(&self) {} + //~^ ERROR method `bar` has a `&self` declaration in the impl, but not in the trait } fn main() {} diff --git a/src/test/compile-fail/struct-no-fields-2.rs b/src/test/compile-fail/struct-no-fields-2.rs index 63e38e35447..cd555f8d917 100644 --- a/src/test/compile-fail/struct-no-fields-2.rs +++ b/src/test/compile-fail/struct-no-fields-2.rs @@ -12,7 +12,7 @@ struct Foo; fn f2() { let _end_stmt = Foo { }; - //~^ ERROR: Unit-like struct construction is written with no trailing `{ }` + //~^ ERROR: unit-like struct construction is written with no trailing `{ }` } fn main() {} diff --git a/src/test/compile-fail/struct-no-fields-3.rs b/src/test/compile-fail/struct-no-fields-3.rs index 33077d4f1b3..2595c5e8acf 100644 --- a/src/test/compile-fail/struct-no-fields-3.rs +++ b/src/test/compile-fail/struct-no-fields-3.rs @@ -12,7 +12,7 @@ struct Foo; fn g3() { let _mid_tuple = (Foo { }, 2); - //~^ ERROR: Unit-like struct construction is written with no trailing `{ }` + //~^ ERROR: unit-like struct construction is written with no trailing `{ }` } fn main() {} diff --git a/src/test/compile-fail/struct-no-fields-4.rs b/src/test/compile-fail/struct-no-fields-4.rs index 6b73cb769ee..fee5c35e850 100644 --- a/src/test/compile-fail/struct-no-fields-4.rs +++ b/src/test/compile-fail/struct-no-fields-4.rs @@ -12,7 +12,7 @@ struct Foo; fn h4() { let _end_of_tuple = (3, Foo { }); - //~^ ERROR: Unit-like struct construction is written with no trailing `{ }` + //~^ ERROR: unit-like struct construction is written with no trailing `{ }` } fn main() {} diff --git a/src/test/compile-fail/struct-no-fields-5.rs b/src/test/compile-fail/struct-no-fields-5.rs index 81c050e61cb..bd196e881aa 100644 --- a/src/test/compile-fail/struct-no-fields-5.rs +++ b/src/test/compile-fail/struct-no-fields-5.rs @@ -12,7 +12,7 @@ struct Foo; fn i5() { let _end_of_block = { Foo { } }; - //~^ ERROR: Unit-like struct construction is written with no trailing `{ }` + //~^ ERROR: unit-like struct construction is written with no trailing `{ }` } fn main() {} diff --git a/src/test/compile-fail/struct-no-fields.rs b/src/test/compile-fail/struct-no-fields.rs index 6142ec0653c..ee853ade18e 100644 --- a/src/test/compile-fail/struct-no-fields.rs +++ b/src/test/compile-fail/struct-no-fields.rs @@ -9,6 +9,6 @@ // except according to those terms. struct Foo {} -//~^ ERROR: Unit-like struct definition should be written as `struct Foo;` +//~^ ERROR: unit-like struct definition should be written as `struct Foo;` fn main() {} diff --git a/src/test/compile-fail/super-at-top-level.rs b/src/test/compile-fail/super-at-top-level.rs index 9ec92e6dbfa..7176d5f92f9 100644 --- a/src/test/compile-fail/super-at-top-level.rs +++ b/src/test/compile-fail/super-at-top-level.rs @@ -1,3 +1,13 @@ +// 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. + use super::f; //~ ERROR failed to resolve import fn main() { diff --git a/src/test/compile-fail/syntax-extension-bytes-non-ascii-char-literal.rs b/src/test/compile-fail/syntax-extension-bytes-non-ascii-char-literal.rs index 8bdc643f288..f5b4342ceb7 100644 --- a/src/test/compile-fail/syntax-extension-bytes-non-ascii-char-literal.rs +++ b/src/test/compile-fail/syntax-extension-bytes-non-ascii-char-literal.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let vec = bytes!('λ'); //~ ERROR Non-ascii char literal in bytes! + let vec = bytes!('λ'); //~ ERROR non-ascii char literal in bytes! } diff --git a/src/test/compile-fail/syntax-extension-bytes-non-literal.rs b/src/test/compile-fail/syntax-extension-bytes-non-literal.rs index fed6bdc9470..281a5630f82 100644 --- a/src/test/compile-fail/syntax-extension-bytes-non-literal.rs +++ b/src/test/compile-fail/syntax-extension-bytes-non-literal.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let vec = bytes!(foo); //~ ERROR Non-literal in bytes! + let vec = bytes!(foo); //~ ERROR non-literal in bytes! } diff --git a/src/test/compile-fail/syntax-extension-bytes-too-large-integer-literal.rs b/src/test/compile-fail/syntax-extension-bytes-too-large-integer-literal.rs index 8acb280dfde..25688d7d17a 100644 --- a/src/test/compile-fail/syntax-extension-bytes-too-large-integer-literal.rs +++ b/src/test/compile-fail/syntax-extension-bytes-too-large-integer-literal.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let vec = bytes!(1024); //~ ERROR Too large integer literal in bytes! + let vec = bytes!(1024); //~ ERROR too large integer literal in bytes! } diff --git a/src/test/compile-fail/syntax-extension-bytes-too-large-u8-literal.rs b/src/test/compile-fail/syntax-extension-bytes-too-large-u8-literal.rs index b7d69a3054f..d1c8a2c0913 100644 --- a/src/test/compile-fail/syntax-extension-bytes-too-large-u8-literal.rs +++ b/src/test/compile-fail/syntax-extension-bytes-too-large-u8-literal.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let vec = bytes!(1024u8); //~ ERROR Too large u8 literal in bytes! + let vec = bytes!(1024u8); //~ ERROR too large u8 literal in bytes! } diff --git a/src/test/compile-fail/syntax-extension-bytes-too-small-integer-literal.rs b/src/test/compile-fail/syntax-extension-bytes-too-small-integer-literal.rs index cec2dc0a8e0..ef45ea06003 100644 --- a/src/test/compile-fail/syntax-extension-bytes-too-small-integer-literal.rs +++ b/src/test/compile-fail/syntax-extension-bytes-too-small-integer-literal.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let vec = bytes!(-1024); //~ ERROR Non-literal in bytes + let vec = bytes!(-1024); //~ ERROR non-literal in bytes } diff --git a/src/test/compile-fail/syntax-extension-bytes-too-small-u8-literal.rs b/src/test/compile-fail/syntax-extension-bytes-too-small-u8-literal.rs index 2df55a6436c..b8ba73559aa 100644 --- a/src/test/compile-fail/syntax-extension-bytes-too-small-u8-literal.rs +++ b/src/test/compile-fail/syntax-extension-bytes-too-small-u8-literal.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let vec = bytes!(-1024u8); //~ ERROR Non-literal in bytes + let vec = bytes!(-1024u8); //~ ERROR non-literal in bytes } diff --git a/src/test/compile-fail/syntax-extension-bytes-unsupported-literal.rs b/src/test/compile-fail/syntax-extension-bytes-unsupported-literal.rs index 2d7ff386b7c..142566fe8ab 100644 --- a/src/test/compile-fail/syntax-extension-bytes-unsupported-literal.rs +++ b/src/test/compile-fail/syntax-extension-bytes-unsupported-literal.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let vec = bytes!(45f64); //~ ERROR Unsupported literal in bytes! + let vec = bytes!(45f64); //~ ERROR unsupported literal in bytes! } diff --git a/src/test/compile-fail/trait-bounds-sugar.rs b/src/test/compile-fail/trait-bounds-sugar.rs index d907022da71..b9fb94e09ed 100644 --- a/src/test/compile-fail/trait-bounds-sugar.rs +++ b/src/test/compile-fail/trait-bounds-sugar.rs @@ -8,32 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - // Tests for "default" bounds inferred for traits with no bounds list. -trait Foo { -} +trait Foo {} fn a(_x: ~Foo) { // should be same as ~Foo:Send } -fn b(_x: @Foo) { // should be same as ~Foo:'static -} - -fn c(_x: &'static Foo) { // should be same as &'static Foo:'static +fn b(_x: &'static Foo) { // should be same as &'static Foo:'static } -fn d(x: ~Foo:Freeze) { +fn c(x: ~Foo:Freeze) { a(x); //~ ERROR expected bounds `Send` } -fn e(x: @Foo:Freeze) { +fn d(x: &'static Foo:Freeze) { b(x); //~ ERROR expected bounds `'static` } -fn f(x: &'static Foo:Freeze) { - c(x); //~ ERROR expected bounds `'static` -} - -fn main() { } +fn main() {} diff --git a/src/test/compile-fail/trait-coercion-generic-bad.rs b/src/test/compile-fail/trait-coercion-generic-bad.rs index 2d73158add2..297d36c3a0e 100644 --- a/src/test/compile-fail/trait-coercion-generic-bad.rs +++ b/src/test/compile-fail/trait-coercion-generic-bad.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - struct Struct { person: &'static str } @@ -25,8 +23,8 @@ impl Trait<&'static str> for Struct { } fn main() { - let s: @Trait<int> = @Struct { person: "Fred" }; //~ ERROR expected Trait<int>, but found Trait<&'static str> + let s: ~Trait<int> = ~Struct { person: "Fred" }; //~^ ERROR expected Trait<int>, but found Trait<&'static str> + //~^^ ERROR expected Trait<int>, but found Trait<&'static str> s.f(1); } - diff --git a/src/test/compile-fail/trait-coercion-generic-regions.rs b/src/test/compile-fail/trait-coercion-generic-regions.rs index 1ea18a7c75b..2aeebc0f1a8 100644 --- a/src/test/compile-fail/trait-coercion-generic-regions.rs +++ b/src/test/compile-fail/trait-coercion-generic-regions.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - struct Struct { person: &'static str } @@ -27,6 +25,6 @@ impl Trait<&'static str> for Struct { fn main() { let person = ~"Fred"; let person: &str = person; //~ ERROR borrowed value does not live long enough - let s: @Trait<&'static str> = @Struct { person: person }; + let s: ~Trait<&'static str> = ~Struct { person: person }; } diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index 3006b6e5acf..acac7ae9556 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } impl bar for int { fn dup(&self) -> int { *self } fn blah<X>(&self) {} } impl bar for uint { fn dup(&self) -> uint { *self } fn blah<X>(&self) {} } @@ -17,5 +15,5 @@ impl bar for uint { fn dup(&self) -> uint { *self } fn blah<X>(&self) {} } fn main() { 10i.dup::<int>(); //~ ERROR does not take type parameters 10i.blah::<int, int>(); //~ ERROR incorrect number of type parameters - (@10 as @bar).dup(); //~ ERROR contains a self-type + (~10 as ~bar).dup(); //~ ERROR contains a self-type } diff --git a/src/test/compile-fail/tuple-arity-mismatch.rs b/src/test/compile-fail/tuple-arity-mismatch.rs index 60184464085..677c4943043 100644 --- a/src/test/compile-fail/tuple-arity-mismatch.rs +++ b/src/test/compile-fail/tuple-arity-mismatch.rs @@ -13,5 +13,6 @@ fn first((value, _): (int, f64)) -> int { value } fn main() { - let y = first ((1,2,3)); //~ ERROR expected a tuple with 2 elements but found one with 3 elements + let y = first ((1,2,3)); + //~^ ERROR expected a tuple with 2 elements but found one with 3 elements } diff --git a/src/test/compile-fail/type-parameter-names.rs b/src/test/compile-fail/type-parameter-names.rs index 7c41c5d12e6..da8478de985 100644 --- a/src/test/compile-fail/type-parameter-names.rs +++ b/src/test/compile-fail/type-parameter-names.rs @@ -1,3 +1,13 @@ +// 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 we print out the names of type parameters correctly in // our error messages. diff --git a/src/test/compile-fail/uninhabited-enum-cast.rs b/src/test/compile-fail/uninhabited-enum-cast.rs index 606a86f188f..fad20a7e373 100644 --- a/src/test/compile-fail/uninhabited-enum-cast.rs +++ b/src/test/compile-fail/uninhabited-enum-cast.rs @@ -1,3 +1,13 @@ +// 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. + enum E {} fn f(e: E) { diff --git a/src/test/compile-fail/unop-neg-bool.rs b/src/test/compile-fail/unop-neg-bool.rs index 6f1f1aba459..316e17c54ad 100644 --- a/src/test/compile-fail/unop-neg-bool.rs +++ b/src/test/compile-fail/unop-neg-bool.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { -true; //~ ERROR cannot apply unary operator `-` to type `bool` } diff --git a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs index bef6165d120..d79461a577e 100644 --- a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs +++ b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-linelength + struct Number { n: i64 } @@ -32,6 +34,6 @@ fn main() { let n = ~Number { n: 42 }; let mut l = ~List { list: ~[] }; l.push(n); - //^~ NOTE: `n` moved here because it has type `~Number`, which is non-copyable (perhaps you meant to use clone()?) - let x = n.to_str(); //~ ERROR: use of moved value: `n` + let x = n.to_str(); + //~^ ERROR: use of moved value: `n` } diff --git a/src/test/compile-fail/use-after-move-self-based-on-type.rs b/src/test/compile-fail/use-after-move-self-based-on-type.rs index b98827409a8..b93fc2680cd 100644 --- a/src/test/compile-fail/use-after-move-self-based-on-type.rs +++ b/src/test/compile-fail/use-after-move-self-based-on-type.rs @@ -1,3 +1,13 @@ +// 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. + struct S { x: int, } diff --git a/src/test/compile-fail/use-after-move-self.rs b/src/test/compile-fail/use-after-move-self.rs index 69a0b94c348..56e5fdce3cf 100644 --- a/src/test/compile-fail/use-after-move-self.rs +++ b/src/test/compile-fail/use-after-move-self.rs @@ -1,3 +1,13 @@ +// 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. + struct S { x: ~int } diff --git a/src/test/compile-fail/use-from-trait-xc.rs b/src/test/compile-fail/use-from-trait-xc.rs index 3ac3e8c832d..a4db5457750 100644 --- a/src/test/compile-fail/use-from-trait-xc.rs +++ b/src/test/compile-fail/use-from-trait-xc.rs @@ -1,3 +1,13 @@ +// 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. + // aux-build:use_from_trait_xc.rs extern mod use_from_trait_xc; diff --git a/src/test/compile-fail/use-from-trait.rs b/src/test/compile-fail/use-from-trait.rs index 4514d925c82..8f8d96f8024 100644 --- a/src/test/compile-fail/use-from-trait.rs +++ b/src/test/compile-fail/use-from-trait.rs @@ -1,3 +1,13 @@ +// 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. + use Trait::foo; //~ ERROR cannot import from a trait or type implementation //~^ ERROR failed to resolve import use Foo::new; //~ ERROR cannot import from a trait or type implementation diff --git a/src/test/compile-fail/variadic-ffi.rs b/src/test/compile-fail/variadic-ffi.rs index 3156cd9af32..d0599c2ba4b 100644 --- a/src/test/compile-fail/variadic-ffi.rs +++ b/src/test/compile-fail/variadic-ffi.rs @@ -24,10 +24,14 @@ fn main() { foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied let x: extern "C" unsafe fn(f: int, x: u8) = foo; - //~^ ERROR: mismatched types: expected `extern "C" unsafe fn(int, u8)` but found `extern "C" unsafe fn(int, u8, ...)` (expected non-variadic fn but found variadic function) + //~^ ERROR: mismatched types: expected `extern "C" unsafe fn(int, u8)` + // but found `extern "C" unsafe fn(int, u8, ...)` + // (expected non-variadic fn but found variadic function) let y: extern "C" unsafe fn(f: int, x: u8, ...) = bar; - //~^ ERROR: mismatched types: expected `extern "C" unsafe fn(int, u8, ...)` but found `extern "C" extern fn(int, u8)` (expected variadic fn but found non-variadic function) + //~^ ERROR: mismatched types: expected `extern "C" unsafe fn(int, u8, ...)` + // but found `extern "C" extern fn(int, u8)` + // (expected variadic fn but found non-variadic function) foo(1, 2, 3f32); //~ ERROR: can't pass an f32 to variadic function, cast to c_double foo(1, 2, true); //~ ERROR: can't pass bool to variadic function, cast to c_int diff --git a/src/test/compile-fail/xc-private-method2.rs b/src/test/compile-fail/xc-private-method2.rs index c2eaa9287f4..012245f9451 100644 --- a/src/test/compile-fail/xc-private-method2.rs +++ b/src/test/compile-fail/xc-private-method2.rs @@ -14,7 +14,9 @@ extern mod xc_private_method_lib; fn main() { - let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct(); //~ ERROR method `meth_struct` is private + let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct(); + //~^ ERROR method `meth_struct` is private - let _ = xc_private_method_lib::Variant1(20).meth_enum(); //~ ERROR method `meth_enum` is private + let _ = xc_private_method_lib::Variant1(20).meth_enum(); + //~^ ERROR method `meth_enum` is private } diff --git a/src/test/debug-info/basic-types-metadata.rs b/src/test/debug-info/basic-types-metadata.rs index 0e48b5db7ce..a67279254de 100644 --- a/src/test/debug-info/basic-types-metadata.rs +++ b/src/test/debug-info/basic-types-metadata.rs @@ -45,7 +45,7 @@ // debugger:whatis f64 // check:type = f64 // debugger:info functions _yyy -// check:[...]![...]_yyy()(); +// check:[...]![...]_yyy([...])([...]); // debugger:detach // debugger:quit diff --git a/src/test/debug-info/borrowed-enum.rs b/src/test/debug-info/borrowed-enum.rs index ae80cdd7822..e6094fdef9f 100644 --- a/src/test/debug-info/borrowed-enum.rs +++ b/src/test/debug-info/borrowed-enum.rs @@ -31,8 +31,8 @@ // the size of the discriminant value is machine dependent, this has be taken into account when // datatype layout should be predictable as in this case. enum ABC { - TheA { x: i64, y: i64 }, - TheB (i64, i32, i32), + TheA { x: i64, y: i64 }, + TheB (i64, i32, i32), } // This is a special case since it does not have the implicit discriminant field. @@ -42,10 +42,10 @@ enum Univariant { fn main() { - // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 - // 0b01111100011111000111110001111100 = 2088533116 - // 0b0111110001111100 = 31868 - // 0b01111100 = 124 + // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 + // 0b01111100011111000111110001111100 = 2088533116 + // 0b0111110001111100 = 31868 + // 0b01111100 = 124 let the_a = TheA { x: 0, y: 8970181431921507452 }; let the_a_ref: &ABC = &the_a; diff --git a/src/test/debug-info/destructured-fn-argument.rs b/src/test/debug-info/destructured-fn-argument.rs index 0485a5ba022..ed711e2ca0b 100644 --- a/src/test/debug-info/destructured-fn-argument.rs +++ b/src/test/debug-info/destructured-fn-argument.rs @@ -232,7 +232,8 @@ fn different_order_of_struct_fields(Struct { b: s, a: t }: Struct ) { } fn complex_nesting(((u, v ), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue ): - ((i16, i32), ((i64, (i32, Struct, )), Struct ), u16)) { + ((i16, i32), ((i64, (i32, Struct, )), Struct ), u16)) +{ zzz(); } diff --git a/src/test/debug-info/generic-method-on-generic-struct.rs b/src/test/debug-info/generic-method-on-generic-struct.rs index 767293c3dc8..f71106cacb1 100644 --- a/src/test/debug-info/generic-method-on-generic-struct.rs +++ b/src/test/debug-info/generic-method-on-generic-struct.rs @@ -64,38 +64,6 @@ // check:$15 = -10.5 // debugger:continue -// MANAGED BY REF -// debugger:finish -// debugger:print *self -// check:$16 = {x = -1} -// debugger:print arg1 -// check:$17 = -11 -// debugger:print arg2 -// check:$18 = -12.5 -// debugger:continue - -// MANAGED BY VAL -// debugger:finish -// debugger:print self -// check:$19 = {x = -1} -// debugger:print arg1 -// check:$20 = -13 -// debugger:print *arg2 -// check:$21 = {-14, 14} -// debugger:continue - -// MANAGED SELF -// debugger:finish -// debugger:print self->val -// check:$22 = {x = -1} -// debugger:print arg1 -// check:$23 = -15 -// debugger:print *arg2 -// check:$24 = {-16, 16.5} -// debugger:continue - -#[feature(managed_boxes)]; - struct Struct<T> { x: T } @@ -116,11 +84,6 @@ impl<T1> Struct<T1> { zzz(); arg1 } - - fn self_managed<T2>(@self, arg1: int, arg2: T2) -> int { - zzz(); - arg1 - } } fn main() { @@ -132,11 +95,6 @@ fn main() { let _ = owned.self_by_ref(-5, -6_i32); let _ = owned.self_by_val(-7, -8_i64); let _ = owned.self_owned(-9, -10.5_f32); - - let managed = @Struct { x: -1_i16 }; - let _ = managed.self_by_ref(-11, -12.5_f64); - let _ = managed.self_by_val(-13, &(-14, 14)); - let _ = managed.self_managed(-15, &(-16, 16.5)); } fn zzz() {()} diff --git a/src/test/debug-info/generic-struct-style-enum.rs b/src/test/debug-info/generic-struct-style-enum.rs index cd7bd57795c..5930af11567 100644 --- a/src/test/debug-info/generic-struct-style-enum.rs +++ b/src/test/debug-info/generic-struct-style-enum.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-linelength // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info diff --git a/src/test/debug-info/generic-tuple-style-enum.rs b/src/test/debug-info/generic-tuple-style-enum.rs index 03f1a695667..0a737ffe073 100644 --- a/src/test/debug-info/generic-tuple-style-enum.rs +++ b/src/test/debug-info/generic-tuple-style-enum.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-linelength // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info diff --git a/src/test/debug-info/include_string.rs b/src/test/debug-info/include_string.rs index a13dde22710..74064bb5782 100644 --- a/src/test/debug-info/include_string.rs +++ b/src/test/debug-info/include_string.rs @@ -24,7 +24,7 @@ #[allow(unused_variable)]; -// This test case makes sure that debug info does not ICE when include_str is +// This test case makes sure that debug info does not ICE when include_str is // used multiple times (see issue #11322). fn main() { diff --git a/src/test/debug-info/issue11600.rs b/src/test/debug-info/issue11600.rs index 425aff8d441..00e240d147c 100644 --- a/src/test/debug-info/issue11600.rs +++ b/src/test/debug-info/issue11600.rs @@ -1,3 +1,13 @@ +// 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. + fn main() { let args : ~[~str] = ::std::os::args(); ::std::io::println(args[0]); diff --git a/src/test/debug-info/managed-enum.rs b/src/test/debug-info/managed-enum.rs index 5ab39e00eb3..ef94fd3e331 100644 --- a/src/test/debug-info/managed-enum.rs +++ b/src/test/debug-info/managed-enum.rs @@ -31,8 +31,8 @@ // the size of the discriminant value is machine dependent, this has be taken into account when // datatype layout should be predictable as in this case. enum ABC { - TheA { x: i64, y: i64 }, - TheB (i64, i32, i32), + TheA { x: i64, y: i64 }, + TheB (i64, i32, i32), } // This is a special case since it does not have the implicit discriminant field. @@ -46,10 +46,10 @@ fn main() { // repeated byte. This way each interpretation of the union should look the same, no matter if // this is a big or little endian machine. - // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 - // 0b01111100011111000111110001111100 = 2088533116 - // 0b0111110001111100 = 31868 - // 0b01111100 = 124 + // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 + // 0b01111100011111000111110001111100 = 2088533116 + // 0b0111110001111100 = 31868 + // 0b01111100 = 124 let the_a = @TheA { x: 0, y: 8970181431921507452 }; // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441 diff --git a/src/test/debug-info/method-on-enum.rs b/src/test/debug-info/method-on-enum.rs index 272da1690fd..79594c5d389 100644 --- a/src/test/debug-info/method-on-enum.rs +++ b/src/test/debug-info/method-on-enum.rs @@ -64,37 +64,6 @@ // check:$15 = -10 // debugger:continue -// MANAGED BY REF -// debugger:finish -// debugger:print *self -// check:$16 = {{Variant2, [...]}, {Variant2, 117901063}} -// debugger:print arg1 -// check:$17 = -11 -// debugger:print arg2 -// check:$18 = -12 -// debugger:continue - -// MANAGED BY VAL -// debugger:finish -// debugger:print self -// check:$19 = {{Variant2, [...]}, {Variant2, 117901063}} -// debugger:print arg1 -// check:$20 = -13 -// debugger:print arg2 -// check:$21 = -14 -// debugger:continue - -// MANAGED SELF -// debugger:finish -// debugger:print self->val -// check:$22 = {{Variant2, [...]}, {Variant2, 117901063}} -// debugger:print arg1 -// check:$23 = -15 -// debugger:print arg2 -// check:$24 = -16 -// debugger:continue - -#[feature(managed_boxes)]; #[feature(struct_variant)]; enum Enum { @@ -118,11 +87,6 @@ impl Enum { zzz(); arg1 + arg2 } - - fn self_managed(@self, arg1: int, arg2: int) -> int { - zzz(); - arg1 + arg2 - } } fn main() { @@ -134,11 +98,6 @@ fn main() { let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); - - let managed = @Variant2(117901063); - let _ = managed.self_by_ref(-11, -12); - let _ = managed.self_by_val(-13, -14); - let _ = managed.self_managed(-15, -16); } fn zzz() {()} diff --git a/src/test/debug-info/method-on-generic-struct.rs b/src/test/debug-info/method-on-generic-struct.rs index ebfdea04377..fc78aba707f 100644 --- a/src/test/debug-info/method-on-generic-struct.rs +++ b/src/test/debug-info/method-on-generic-struct.rs @@ -64,38 +64,6 @@ // check:$15 = -10 // debugger:continue -// MANAGED BY REF -// debugger:finish -// debugger:print *self -// check:$16 = {x = -1} -// debugger:print arg1 -// check:$17 = -11 -// debugger:print arg2 -// check:$18 = -12 -// debugger:continue - -// MANAGED BY VAL -// debugger:finish -// debugger:print self -// check:$19 = {x = -1} -// debugger:print arg1 -// check:$20 = -13 -// debugger:print arg2 -// check:$21 = -14 -// debugger:continue - -// MANAGED SELF -// debugger:finish -// debugger:print self->val -// check:$22 = {x = -1} -// debugger:print arg1 -// check:$23 = -15 -// debugger:print arg2 -// check:$24 = -16 -// debugger:continue - -#[feature(managed_boxes)]; - struct Struct<T> { x: T } @@ -116,11 +84,6 @@ impl<T> Struct<T> { zzz(); arg1 + arg2 } - - fn self_managed(@self, arg1: int, arg2: int) -> int { - zzz(); - arg1 + arg2 - } } fn main() { @@ -132,11 +95,6 @@ fn main() { let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); - - let managed = @Struct { x: -1_i16 }; - let _ = managed.self_by_ref(-11, -12); - let _ = managed.self_by_val(-13, -14); - let _ = managed.self_managed(-15, -16); } fn zzz() {()} diff --git a/src/test/debug-info/method-on-struct.rs b/src/test/debug-info/method-on-struct.rs index e88e5a5ca63..035ebf9caeb 100644 --- a/src/test/debug-info/method-on-struct.rs +++ b/src/test/debug-info/method-on-struct.rs @@ -64,38 +64,6 @@ // check:$15 = -10 // debugger:continue -// MANAGED BY REF -// debugger:finish -// debugger:print *self -// check:$16 = {x = 300} -// debugger:print arg1 -// check:$17 = -11 -// debugger:print arg2 -// check:$18 = -12 -// debugger:continue - -// MANAGED BY VAL -// debugger:finish -// debugger:print self -// check:$19 = {x = 300} -// debugger:print arg1 -// check:$20 = -13 -// debugger:print arg2 -// check:$21 = -14 -// debugger:continue - -// MANAGED SELF -// debugger:finish -// debugger:print self->val -// check:$22 = {x = 300} -// debugger:print arg1 -// check:$23 = -15 -// debugger:print arg2 -// check:$24 = -16 -// debugger:continue - -#[feature(managed_boxes)]; - struct Struct { x: int } @@ -116,11 +84,6 @@ impl Struct { zzz(); self.x + arg1 + arg2 } - - fn self_managed(@self, arg1: int, arg2: int) -> int { - zzz(); - self.x + arg1 + arg2 - } } fn main() { @@ -132,11 +95,6 @@ fn main() { let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); - - let managed = @Struct { x: 300 }; - let _ = managed.self_by_ref(-11, -12); - let _ = managed.self_by_val(-13, -14); - let _ = managed.self_managed(-15, -16); } fn zzz() {()} diff --git a/src/test/debug-info/method-on-trait.rs b/src/test/debug-info/method-on-trait.rs index fd58cc1a7d3..7cd5a845cba 100644 --- a/src/test/debug-info/method-on-trait.rs +++ b/src/test/debug-info/method-on-trait.rs @@ -64,38 +64,6 @@ // check:$15 = -10 // debugger:continue -// MANAGED BY REF -// debugger:finish -// debugger:print *self -// check:$16 = {x = 300} -// debugger:print arg1 -// check:$17 = -11 -// debugger:print arg2 -// check:$18 = -12 -// debugger:continue - -// MANAGED BY VAL -// debugger:finish -// debugger:print self -// check:$19 = {x = 300} -// debugger:print arg1 -// check:$20 = -13 -// debugger:print arg2 -// check:$21 = -14 -// debugger:continue - -// MANAGED SELF -// debugger:finish -// debugger:print self->val -// check:$22 = {x = 300} -// debugger:print arg1 -// check:$23 = -15 -// debugger:print arg2 -// check:$24 = -16 -// debugger:continue - -#[feature(managed_boxes)]; - struct Struct { x: int } @@ -104,7 +72,6 @@ trait Trait { fn self_by_ref(&self, arg1: int, arg2: int) -> int; fn self_by_val(self, arg1: int, arg2: int) -> int; fn self_owned(~self, arg1: int, arg2: int) -> int; - fn self_managed(@self, arg1: int, arg2: int) -> int; } impl Trait for Struct { @@ -123,11 +90,6 @@ impl Trait for Struct { zzz(); self.x + arg1 + arg2 } - - fn self_managed(@self, arg1: int, arg2: int) -> int { - zzz(); - self.x + arg1 + arg2 - } } fn main() { @@ -139,11 +101,6 @@ fn main() { let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); - - let managed = @Struct { x: 300 }; - let _ = managed.self_by_ref(-11, -12); - let _ = managed.self_by_val(-13, -14); - let _ = managed.self_managed(-15, -16); } fn zzz() {()} diff --git a/src/test/debug-info/method-on-tuple-struct.rs b/src/test/debug-info/method-on-tuple-struct.rs index 98dbff988e7..029a5cd4c91 100644 --- a/src/test/debug-info/method-on-tuple-struct.rs +++ b/src/test/debug-info/method-on-tuple-struct.rs @@ -64,38 +64,6 @@ // check:$15 = -10 // debugger:continue -// MANAGED BY REF -// debugger:finish -// debugger:print *self -// check:$16 = {300, -300.5} -// debugger:print arg1 -// check:$17 = -11 -// debugger:print arg2 -// check:$18 = -12 -// debugger:continue - -// MANAGED BY VAL -// debugger:finish -// debugger:print self -// check:$19 = {300, -300.5} -// debugger:print arg1 -// check:$20 = -13 -// debugger:print arg2 -// check:$21 = -14 -// debugger:continue - -// MANAGED SELF -// debugger:finish -// debugger:print self->val -// check:$22 = {300, -300.5} -// debugger:print arg1 -// check:$23 = -15 -// debugger:print arg2 -// check:$24 = -16 -// debugger:continue - -#[feature(managed_boxes)]; - struct TupleStruct(int, f64); impl TupleStruct { @@ -114,11 +82,6 @@ impl TupleStruct { zzz(); arg1 + arg2 } - - fn self_managed(@self, arg1: int, arg2: int) -> int { - zzz(); - arg1 + arg2 - } } fn main() { @@ -130,11 +93,6 @@ fn main() { let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); - - let managed = @TupleStruct(300, -300.5); - let _ = managed.self_by_ref(-11, -12); - let _ = managed.self_by_val(-13, -14); - let _ = managed.self_managed(-15, -16); } fn zzz() {()} diff --git a/src/test/debug-info/multiple-functions-equal-var-names.rs b/src/test/debug-info/multiple-functions-equal-var-names.rs index b0d9b0aa884..29a7de4a316 100644 --- a/src/test/debug-info/multiple-functions-equal-var-names.rs +++ b/src/test/debug-info/multiple-functions-equal-var-names.rs @@ -31,26 +31,26 @@ #[allow(unused_variable)]; fn function_one() { - let abc = 10101; - zzz(); + let abc = 10101; + zzz(); } fn function_two() { - let abc = 20202; - zzz(); + let abc = 20202; + zzz(); } fn function_three() { - let abc = 30303; - zzz(); + let abc = 30303; + zzz(); } fn main() { - function_one(); - function_two(); - function_three(); + function_one(); + function_two(); + function_three(); } fn zzz() {()} diff --git a/src/test/debug-info/multiple-functions.rs b/src/test/debug-info/multiple-functions.rs index 29d67c17684..f5abe6e249d 100644 --- a/src/test/debug-info/multiple-functions.rs +++ b/src/test/debug-info/multiple-functions.rs @@ -31,26 +31,26 @@ #[allow(unused_variable)]; fn function_one() { - let a = 10101; - zzz(); + let a = 10101; + zzz(); } fn function_two() { - let b = 20202; - zzz(); + let b = 20202; + zzz(); } fn function_three() { - let c = 30303; - zzz(); + let c = 30303; + zzz(); } fn main() { - function_one(); - function_two(); - function_three(); + function_one(); + function_two(); + function_three(); } fn zzz() {()} diff --git a/src/test/debug-info/packed-struct-with-destructor.rs b/src/test/debug-info/packed-struct-with-destructor.rs index 1a0532887bf..5e6480fa8c5 100644 --- a/src/test/debug-info/packed-struct-with-destructor.rs +++ b/src/test/debug-info/packed-struct-with-destructor.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-linelength // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info diff --git a/src/test/debug-info/packed-struct.rs b/src/test/debug-info/packed-struct.rs index 6ee2574ca74..795b9d275dd 100644 --- a/src/test/debug-info/packed-struct.rs +++ b/src/test/debug-info/packed-struct.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-linelength // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info diff --git a/src/test/debug-info/self-in-default-method.rs b/src/test/debug-info/self-in-default-method.rs index d5f735e77f4..9f0b0ea8414 100644 --- a/src/test/debug-info/self-in-default-method.rs +++ b/src/test/debug-info/self-in-default-method.rs @@ -64,38 +64,6 @@ // check:$15 = -10 // debugger:continue -// MANAGED BY REF -// debugger:finish -// debugger:print *self -// check:$16 = {x = 300} -// debugger:print arg1 -// check:$17 = -11 -// debugger:print arg2 -// check:$18 = -12 -// debugger:continue - -// MANAGED BY VAL -// debugger:finish -// debugger:print self -// check:$19 = {x = 300} -// debugger:print arg1 -// check:$20 = -13 -// debugger:print arg2 -// check:$21 = -14 -// debugger:continue - -// MANAGED SELF -// debugger:finish -// debugger:print self->val -// check:$22 = {x = 300} -// debugger:print arg1 -// check:$23 = -15 -// debugger:print arg2 -// check:$24 = -16 -// debugger:continue - -#[feature(managed_boxes)]; - struct Struct { x: int } @@ -115,11 +83,6 @@ trait Trait { zzz(); arg1 + arg2 } - - fn self_managed(@self, arg1: int, arg2: int) -> int { - zzz(); - arg1 + arg2 - } } impl Trait for Struct {} @@ -133,11 +96,6 @@ fn main() { let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); - - let managed = @Struct { x: 300 }; - let _ = managed.self_by_ref(-11, -12); - let _ = managed.self_by_val(-13, -14); - let _ = managed.self_managed(-15, -16); } fn zzz() {()} diff --git a/src/test/debug-info/self-in-generic-default-method.rs b/src/test/debug-info/self-in-generic-default-method.rs index e7a6ee77610..5ae88b3d0ce 100644 --- a/src/test/debug-info/self-in-generic-default-method.rs +++ b/src/test/debug-info/self-in-generic-default-method.rs @@ -64,38 +64,6 @@ // check:$15 = -10.5 // debugger:continue -// MANAGED BY REF -// debugger:finish -// debugger:print *self -// check:$16 = {x = 897} -// debugger:print arg1 -// check:$17 = -11 -// debugger:print arg2 -// check:$18 = -12.5 -// debugger:continue - -// MANAGED BY VAL -// debugger:finish -// debugger:print self -// check:$19 = {x = 897} -// debugger:print arg1 -// check:$20 = -13 -// debugger:print *arg2 -// check:$21 = {-14, 14} -// debugger:continue - -// MANAGED SELF -// debugger:finish -// debugger:print self->val -// check:$22 = {x = 897} -// debugger:print arg1 -// check:$23 = -15 -// debugger:print *arg2 -// check:$24 = {-16, 16.5} -// debugger:continue - -#[feature(managed_boxes)]; - struct Struct { x: int } @@ -116,11 +84,6 @@ trait Trait { zzz(); arg1 } - - fn self_managed<T>(@self, arg1: int, arg2: T) -> int { - zzz(); - arg1 - } } impl Trait for Struct {} @@ -134,11 +97,6 @@ fn main() { let _ = owned.self_by_ref(-5, -6_i32); let _ = owned.self_by_val(-7, -8_i64); let _ = owned.self_owned(-9, -10.5_f32); - - let managed = @Struct { x: 897 }; - let _ = managed.self_by_ref(-11, -12.5_f64); - let _ = managed.self_by_val(-13, &(-14, 14)); - let _ = managed.self_managed(-15, &(-16, 16.5)); } fn zzz() {()} diff --git a/src/test/debug-info/struct-in-enum.rs b/src/test/debug-info/struct-in-enum.rs index 98ded437273..b706ad1c38c 100644 --- a/src/test/debug-info/struct-in-enum.rs +++ b/src/test/debug-info/struct-in-enum.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-linelength // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info @@ -28,9 +29,9 @@ #[allow(unused_variable)]; struct Struct { - x: u32, - y: i32, - z: i16 + x: u32, + y: i32, + z: i16 } // The first element is to ensure proper alignment, irrespective of the machines word size. Since @@ -42,7 +43,7 @@ enum Regular { } enum Univariant { - TheOnlyCase(Struct) + TheOnlyCase(Struct) } fn main() { diff --git a/src/test/debug-info/struct-style-enum.rs b/src/test/debug-info/struct-style-enum.rs index fbdf99dd241..d7804da7894 100644 --- a/src/test/debug-info/struct-style-enum.rs +++ b/src/test/debug-info/struct-style-enum.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-linelength // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info diff --git a/src/test/debug-info/trait-pointers.rs b/src/test/debug-info/trait-pointers.rs index 4bdfc6bfaf6..de46e1aea58 100644 --- a/src/test/debug-info/trait-pointers.rs +++ b/src/test/debug-info/trait-pointers.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info @@ -32,6 +30,5 @@ impl Trait for Struct {} fn main() { let stack_struct = Struct { a:0, b: 1.0 }; let reference: &Trait = &stack_struct as &Trait; - let managed: @Trait = @Struct { a:2, b: 3.0 } as @Trait; let unique: ~Trait = ~Struct { a:2, b: 3.0 } as ~Trait; } diff --git a/src/test/debug-info/tuple-style-enum.rs b/src/test/debug-info/tuple-style-enum.rs index e6a89adbd9c..c9d577a2491 100644 --- a/src/test/debug-info/tuple-style-enum.rs +++ b/src/test/debug-info/tuple-style-enum.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-tidy-linelength // xfail-android: FIXME(#10381) // compile-flags:-Z extra-debug-info @@ -40,7 +41,7 @@ enum Regular { } enum Univariant { - TheOnlyCase(i64) + TheOnlyCase(i64) } fn main() { diff --git a/src/test/debug-info/unique-enum.rs b/src/test/debug-info/unique-enum.rs index 66fa8e183e9..647a6e55f98 100644 --- a/src/test/debug-info/unique-enum.rs +++ b/src/test/debug-info/unique-enum.rs @@ -31,8 +31,8 @@ // the size of the discriminant value is machine dependent, this has be taken into account when // datatype layout should be predictable as in this case. enum ABC { - TheA { x: i64, y: i64 }, - TheB (i64, i32, i32), + TheA { x: i64, y: i64 }, + TheB (i64, i32, i32), } // This is a special case since it does not have the implicit discriminant field. @@ -46,10 +46,10 @@ fn main() { // repeated byte. This way each interpretation of the union should look the same, no matter if // this is a big or little endian machine. - // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 - // 0b01111100011111000111110001111100 = 2088533116 - // 0b0111110001111100 = 31868 - // 0b01111100 = 124 + // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 + // 0b01111100011111000111110001111100 = 2088533116 + // 0b0111110001111100 = 31868 + // 0b01111100 = 124 let the_a = ~TheA { x: 0, y: 8970181431921507452 }; // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441 diff --git a/src/test/pretty/block-comment-wchar.pp b/src/test/pretty/block-comment-wchar.pp index 15e6e52e3ba..4ddf0c5816e 100644 --- a/src/test/pretty/block-comment-wchar.pp +++ b/src/test/pretty/block-comment-wchar.pp @@ -11,7 +11,8 @@ // This is meant as a test case for Issue 3961. // // Test via: rustc --pretty normal src/test/pretty/block-comment-wchar.rs -// +// xfail-tidy-cr +// xfail-tidy-tab // pp-exact:block-comment-wchar.pp fn f() { fn nested() { diff --git a/src/test/pretty/block-comment-wchar.rs b/src/test/pretty/block-comment-wchar.rs index 98b9fd05077..0c2daa06f83 100644 --- a/src/test/pretty/block-comment-wchar.rs +++ b/src/test/pretty/block-comment-wchar.rs @@ -11,7 +11,8 @@ // This is meant as a test case for Issue 3961. // // Test via: rustc --pretty normal src/test/pretty/block-comment-wchar.rs -// +// xfail-tidy-cr +// xfail-tidy-tab // pp-exact:block-comment-wchar.pp fn f() { fn nested() { diff --git a/src/test/pretty/closure-reform-pretty.rs b/src/test/pretty/closure-reform-pretty.rs index 5169652a6c0..a9d0d1f67d5 100644 --- a/src/test/pretty/closure-reform-pretty.rs +++ b/src/test/pretty/closure-reform-pretty.rs @@ -1,3 +1,13 @@ +// 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. + // Any copyright is dedicated to the Public Domain. // http://creativecommons.org/publicdomain/zero/1.0/ diff --git a/src/test/pretty/empty-impl.rs b/src/test/pretty/empty-impl.rs index 685cdcdaead..f22f1b40952 100644 --- a/src/test/pretty/empty-impl.rs +++ b/src/test/pretty/empty-impl.rs @@ -1,3 +1,13 @@ +// 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. + trait X { } impl X for uint { } diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index 4a402132254..c5f24160db5 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -1,3 +1,13 @@ +// 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. + // pp-exact trait Tr { } diff --git a/src/test/pretty/struct-tuple.rs b/src/test/pretty/struct-tuple.rs index 20d1678ee41..acd534ccbfa 100644 --- a/src/test/pretty/struct-tuple.rs +++ b/src/test/pretty/struct-tuple.rs @@ -1,3 +1,13 @@ +// 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. + // pp-exact struct Foo; struct Bar(int, int); diff --git a/src/test/run-fail/assert-as-macro.rs b/src/test/run-fail/assert-as-macro.rs index f715e21f781..c52c11b1b91 100644 --- a/src/test/run-fail/assert-as-macro.rs +++ b/src/test/run-fail/assert-as-macro.rs @@ -1,3 +1,13 @@ +// 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. + // error-pattern:assertion failed: 1 == 2 fn main() { diff --git a/src/test/run-fail/assert-eq-macro-fail.rs b/src/test/run-fail/assert-eq-macro-fail.rs index a31bd25a6f1..7cebfc723de 100644 --- a/src/test/run-fail/assert-eq-macro-fail.rs +++ b/src/test/run-fail/assert-eq-macro-fail.rs @@ -1,3 +1,13 @@ +// 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. + // error-pattern:assertion failed: `(left == right) && (right == left)` (left: `14`, right: `15`) #[deriving(Eq)] diff --git a/src/test/run-fail/die-macro-expr.rs b/src/test/run-fail/die-macro-expr.rs index 8ff62d5a43d..7f7eddd86cf 100644 --- a/src/test/run-fail/die-macro-expr.rs +++ b/src/test/run-fail/die-macro-expr.rs @@ -1,3 +1,13 @@ +// 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. + // error-pattern:test fn main() { diff --git a/src/test/run-fail/die-macro-pure.rs b/src/test/run-fail/die-macro-pure.rs index bb62a7e8bef..f1d9b15c42a 100644 --- a/src/test/run-fail/die-macro-pure.rs +++ b/src/test/run-fail/die-macro-pure.rs @@ -1,3 +1,13 @@ +// 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. + // error-pattern:test fn f() { diff --git a/src/test/run-fail/die-macro.rs b/src/test/run-fail/die-macro.rs index 71cc7317e6e..82e790c5d9f 100644 --- a/src/test/run-fail/die-macro.rs +++ b/src/test/run-fail/die-macro.rs @@ -1,3 +1,13 @@ +// 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. + // error-pattern:test fn main() { diff --git a/src/test/run-fail/fail-task-name-send-str.rs b/src/test/run-fail/fail-task-name-send-str.rs index ca2472cfa55..ea530fe9f69 100644 --- a/src/test/run-fail/fail-task-name-send-str.rs +++ b/src/test/run-fail/fail-task-name-send-str.rs @@ -12,7 +12,7 @@ fn main() { let mut t = ::std::task::task(); - t.name("send name".to_send_str()); + t.name("send name".into_maybe_owned()); t.try(proc() { fail!("test"); 3 diff --git a/src/test/auxiliary/xc_conditions.rs b/src/test/run-fail/unimplemented-macro-fail.rs index 927602de169..7eff1fee625 100644 --- a/src/test/auxiliary/xc_conditions.rs +++ b/src/test/run-fail/unimplemented-macro-fail.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,12 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[crate_type="lib"]; - -condition! { - pub oops: int -> int; -} - -pub fn trouble() -> int { - oops::cond.raise(1) -} +// error-pattern:not yet implemented +fn main() { unimplemented!() } diff --git a/src/test/auxiliary/xc_conditions_3.rs b/src/test/run-fail/unreachable-macro-fail.rs index afe9de7abb9..07e05c6fed9 100644 --- a/src/test/auxiliary/xc_conditions_3.rs +++ b/src/test/run-fail/unreachable-macro-fail.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,14 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[crate_type="lib"]; - -condition! { - pub oops: int -> int; -} - -pub fn guard(k: extern fn() -> int, x: int) -> int { - oops::cond.trap(|i| i*x).inside(|| { - k() - }) -} +// error-pattern:internal error: entered unreachable code +fn main() { unreachable!() } diff --git a/src/test/run-make/c-dynamic-dylib/bar.rs b/src/test/run-make/c-dynamic-dylib/bar.rs index 7c4aca1e028..fa21dfac47c 100644 --- a/src/test/run-make/c-dynamic-dylib/bar.rs +++ b/src/test/run-make/c-dynamic-dylib/bar.rs @@ -1,3 +1,13 @@ +// 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. + extern mod foo; fn main() { diff --git a/src/test/run-make/c-dynamic-dylib/foo.rs b/src/test/run-make/c-dynamic-dylib/foo.rs index 0c4a6f7df4b..5c24e69d79f 100644 --- a/src/test/run-make/c-dynamic-dylib/foo.rs +++ b/src/test/run-make/c-dynamic-dylib/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "dylib"]; #[link(name = "cfoo")] diff --git a/src/test/run-make/c-dynamic-rlib/bar.rs b/src/test/run-make/c-dynamic-rlib/bar.rs index 7c4aca1e028..fa21dfac47c 100644 --- a/src/test/run-make/c-dynamic-rlib/bar.rs +++ b/src/test/run-make/c-dynamic-rlib/bar.rs @@ -1,3 +1,13 @@ +// 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. + extern mod foo; fn main() { diff --git a/src/test/run-make/c-dynamic-rlib/foo.rs b/src/test/run-make/c-dynamic-rlib/foo.rs index e64811af9c7..1f13d610144 100644 --- a/src/test/run-make/c-dynamic-rlib/foo.rs +++ b/src/test/run-make/c-dynamic-rlib/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "rlib"]; #[link(name = "cfoo")] diff --git a/src/test/run-make/c-link-to-rust-dylib/foo.rs b/src/test/run-make/c-link-to-rust-dylib/foo.rs index 6b6a786ef54..0f8ca1e6ef1 100644 --- a/src/test/run-make/c-link-to-rust-dylib/foo.rs +++ b/src/test/run-make/c-link-to-rust-dylib/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "dylib"]; #[no_mangle] diff --git a/src/test/run-make/c-link-to-rust-staticlib/foo.rs b/src/test/run-make/c-link-to-rust-staticlib/foo.rs index 3da09eb6bb6..4cb7a749385 100644 --- a/src/test/run-make/c-link-to-rust-staticlib/foo.rs +++ b/src/test/run-make/c-link-to-rust-staticlib/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "staticlib"]; #[no_mangle] diff --git a/src/test/run-make/c-static-dylib/bar.rs b/src/test/run-make/c-static-dylib/bar.rs index 7c4aca1e028..fa21dfac47c 100644 --- a/src/test/run-make/c-static-dylib/bar.rs +++ b/src/test/run-make/c-static-dylib/bar.rs @@ -1,3 +1,13 @@ +// 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. + extern mod foo; fn main() { diff --git a/src/test/run-make/c-static-dylib/foo.rs b/src/test/run-make/c-static-dylib/foo.rs index 0c4a6f7df4b..5c24e69d79f 100644 --- a/src/test/run-make/c-static-dylib/foo.rs +++ b/src/test/run-make/c-static-dylib/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "dylib"]; #[link(name = "cfoo")] diff --git a/src/test/run-make/c-static-rlib/bar.rs b/src/test/run-make/c-static-rlib/bar.rs index 7c4aca1e028..fa21dfac47c 100644 --- a/src/test/run-make/c-static-rlib/bar.rs +++ b/src/test/run-make/c-static-rlib/bar.rs @@ -1,3 +1,13 @@ +// 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. + extern mod foo; fn main() { diff --git a/src/test/run-make/c-static-rlib/foo.rs b/src/test/run-make/c-static-rlib/foo.rs index e64811af9c7..1f13d610144 100644 --- a/src/test/run-make/c-static-rlib/foo.rs +++ b/src/test/run-make/c-static-rlib/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "rlib"]; #[link(name = "cfoo")] diff --git a/src/test/run-make/crate-data-smoke/Makefile b/src/test/run-make/crate-data-smoke/Makefile index 09ae0998202..5009ed15ee6 100644 --- a/src/test/run-make/crate-data-smoke/Makefile +++ b/src/test/run-make/crate-data-smoke/Makefile @@ -4,7 +4,7 @@ all: [ `$(RUSTC) --crate-id crate.rs` = "foo#0.10-pre" ] [ `$(RUSTC) --crate-name crate.rs` = "foo" ] [ `$(RUSTC) --crate-file-name crate.rs` = "foo" ] - [ `$(RUSTC) --crate-file-name --lib --test crate.rs` = "foo" ] + [ `$(RUSTC) --crate-file-name --crate-type=lib --test crate.rs` = "foo" ] [ `$(RUSTC) --crate-file-name --test lib.rs` = "mylib" ] $(RUSTC) --crate-file-name lib.rs $(RUSTC) --crate-file-name rlib.rs diff --git a/src/test/run-make/crate-data-smoke/crate.rs b/src/test/run-make/crate-data-smoke/crate.rs index 6fef49ac8da..71b54f6c341 100644 --- a/src/test/run-make/crate-data-smoke/crate.rs +++ b/src/test/run-make/crate-data-smoke/crate.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_id = "foo#0.10-pre"]; // Querying about the crate metadata should *not* parse the entire crate, it diff --git a/src/test/run-make/crate-data-smoke/lib.rs b/src/test/run-make/crate-data-smoke/lib.rs index 11c5682389e..546d987b90c 100644 --- a/src/test/run-make/crate-data-smoke/lib.rs +++ b/src/test/run-make/crate-data-smoke/lib.rs @@ -1,2 +1,12 @@ +// 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. + #[crate_id = "mylib"]; #[crate_type = "lib"]; diff --git a/src/test/run-make/crate-data-smoke/rlib.rs b/src/test/run-make/crate-data-smoke/rlib.rs index 26a1de1806a..c94f7df4c92 100644 --- a/src/test/run-make/crate-data-smoke/rlib.rs +++ b/src/test/run-make/crate-data-smoke/rlib.rs @@ -1,2 +1,12 @@ +// 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. + #[crate_id = "mylib"]; #[crate_type = "rlib"]; diff --git a/src/test/run-make/dep-info-custom/Makefile b/src/test/run-make/dep-info-custom/Makefile index 7a1f99ac2d5..72ce26ee6c6 100644 --- a/src/test/run-make/dep-info-custom/Makefile +++ b/src/test/run-make/dep-info-custom/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: - $(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --lib lib.rs + $(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs sleep 1 touch foo.rs -rm -f $(TMPDIR)/done diff --git a/src/test/run-make/dep-info-custom/Makefile.foo b/src/test/run-make/dep-info-custom/Makefile.foo index 95e736deb41..302bb84908b 100644 --- a/src/test/run-make/dep-info-custom/Makefile.foo +++ b/src/test/run-make/dep-info-custom/Makefile.foo @@ -1,7 +1,7 @@ -LIB := $(shell $(RUSTC) --crate-file-name --lib lib.rs) +LIB := $(shell $(RUSTC) --crate-file-name --crate-type=lib lib.rs) $(TMPDIR)/$(LIB): - $(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --lib lib.rs + $(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs touch $(TMPDIR)/done -include $(TMPDIR)/custom-deps-file.d diff --git a/src/test/run-make/dep-info-custom/bar.rs b/src/test/run-make/dep-info-custom/bar.rs index c5c0bc606cd..4c79f7e2855 100644 --- a/src/test/run-make/dep-info-custom/bar.rs +++ b/src/test/run-make/dep-info-custom/bar.rs @@ -1 +1,11 @@ +// 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. + pub fn bar() {} diff --git a/src/test/run-make/dep-info-custom/foo.rs b/src/test/run-make/dep-info-custom/foo.rs index b76b4321d62..2661b1f4eb4 100644 --- a/src/test/run-make/dep-info-custom/foo.rs +++ b/src/test/run-make/dep-info-custom/foo.rs @@ -1 +1,11 @@ +// 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. + pub fn foo() {} diff --git a/src/test/run-make/dep-info-custom/lib.rs b/src/test/run-make/dep-info-custom/lib.rs index 937118269a7..b8868771130 100644 --- a/src/test/run-make/dep-info-custom/lib.rs +++ b/src/test/run-make/dep-info-custom/lib.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_id="foo#0.1"]; pub mod foo; diff --git a/src/test/run-make/dep-info/Makefile b/src/test/run-make/dep-info/Makefile index 36a43b4c455..00a59383176 100644 --- a/src/test/run-make/dep-info/Makefile +++ b/src/test/run-make/dep-info/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: - $(RUSTC) --dep-info --lib lib.rs + $(RUSTC) --dep-info --crate-type=lib lib.rs sleep 1 touch foo.rs -rm -f $(TMPDIR)/done diff --git a/src/test/run-make/dep-info/Makefile.foo b/src/test/run-make/dep-info/Makefile.foo index 2a1ce715e28..2b43dd0ec70 100644 --- a/src/test/run-make/dep-info/Makefile.foo +++ b/src/test/run-make/dep-info/Makefile.foo @@ -1,7 +1,7 @@ -LIB := $(shell $(RUSTC) --crate-file-name --lib lib.rs) +LIB := $(shell $(RUSTC) --crate-file-name --crate-type=lib lib.rs) $(TMPDIR)/$(LIB): - $(RUSTC) --dep-info --lib lib.rs + $(RUSTC) --dep-info --crate-type=lib lib.rs touch $(TMPDIR)/done --include $(TMPDIR)/lib.d +-include $(TMPDIR)/foo.d diff --git a/src/test/run-make/dep-info/bar.rs b/src/test/run-make/dep-info/bar.rs index c5c0bc606cd..4c79f7e2855 100644 --- a/src/test/run-make/dep-info/bar.rs +++ b/src/test/run-make/dep-info/bar.rs @@ -1 +1,11 @@ +// 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. + pub fn bar() {} diff --git a/src/test/run-make/dep-info/foo.rs b/src/test/run-make/dep-info/foo.rs index b76b4321d62..2661b1f4eb4 100644 --- a/src/test/run-make/dep-info/foo.rs +++ b/src/test/run-make/dep-info/foo.rs @@ -1 +1,11 @@ +// 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. + pub fn foo() {} diff --git a/src/test/run-make/dep-info/lib.rs b/src/test/run-make/dep-info/lib.rs index 937118269a7..b8868771130 100644 --- a/src/test/run-make/dep-info/lib.rs +++ b/src/test/run-make/dep-info/lib.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_id="foo#0.1"]; pub mod foo; diff --git a/src/test/run-make/duplicate-output-flavors/Makefile b/src/test/run-make/duplicate-output-flavors/Makefile index a93a7ce8448..d40b6862a01 100644 --- a/src/test/run-make/duplicate-output-flavors/Makefile +++ b/src/test/run-make/duplicate-output-flavors/Makefile @@ -1,4 +1,4 @@ include ../tools.mk all: - $(RUSTC) --rlib foo.rs + $(RUSTC) --crate-type=rlib foo.rs diff --git a/src/test/run-make/duplicate-output-flavors/foo.rs b/src/test/run-make/duplicate-output-flavors/foo.rs index 3cdacc96ee9..fbe967786e2 100644 --- a/src/test/run-make/duplicate-output-flavors/foo.rs +++ b/src/test/run-make/duplicate-output-flavors/foo.rs @@ -1 +1,11 @@ +// 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. + #[crate_type = "rlib"]; diff --git a/src/test/run-make/dylib-chain/m1.rs b/src/test/run-make/dylib-chain/m1.rs index 69ea8dcecfc..dd7f5f14e40 100644 --- a/src/test/run-make/dylib-chain/m1.rs +++ b/src/test/run-make/dylib-chain/m1.rs @@ -1,2 +1,12 @@ +// 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. + #[crate_type = "dylib"]; pub fn m1() {} diff --git a/src/test/run-make/dylib-chain/m2.rs b/src/test/run-make/dylib-chain/m2.rs index 2f5d75a3872..98e9a9ee950 100644 --- a/src/test/run-make/dylib-chain/m2.rs +++ b/src/test/run-make/dylib-chain/m2.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "dylib"]; extern mod m1; diff --git a/src/test/run-make/dylib-chain/m3.rs b/src/test/run-make/dylib-chain/m3.rs index cc4ff2cff74..b963a4c4f0a 100644 --- a/src/test/run-make/dylib-chain/m3.rs +++ b/src/test/run-make/dylib-chain/m3.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "dylib"]; extern mod m2; diff --git a/src/test/run-make/dylib-chain/m4.rs b/src/test/run-make/dylib-chain/m4.rs index c52d1f7fcbc..ea2975d6b6e 100644 --- a/src/test/run-make/dylib-chain/m4.rs +++ b/src/test/run-make/dylib-chain/m4.rs @@ -1,3 +1,13 @@ +// 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. + extern mod m3; fn main() { m3::m3() } diff --git a/src/test/run-make/ls-metadata/foo.rs b/src/test/run-make/ls-metadata/foo.rs index f328e4d9d04..8ae3d072362 100644 --- a/src/test/run-make/ls-metadata/foo.rs +++ b/src/test/run-make/ls-metadata/foo.rs @@ -1 +1,11 @@ +// 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. + fn main() {} diff --git a/src/test/run-make/lto-smoke-c/foo.rs b/src/test/run-make/lto-smoke-c/foo.rs index 3da09eb6bb6..4cb7a749385 100644 --- a/src/test/run-make/lto-smoke-c/foo.rs +++ b/src/test/run-make/lto-smoke-c/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "staticlib"]; #[no_mangle] diff --git a/src/test/run-make/lto-smoke/lib.rs b/src/test/run-make/lto-smoke/lib.rs index 3cdacc96ee9..fbe967786e2 100644 --- a/src/test/run-make/lto-smoke/lib.rs +++ b/src/test/run-make/lto-smoke/lib.rs @@ -1 +1,11 @@ +// 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. + #[crate_type = "rlib"]; diff --git a/src/test/run-make/lto-smoke/main.rs b/src/test/run-make/lto-smoke/main.rs index a3ed6772926..61ee2481c2c 100644 --- a/src/test/run-make/lto-smoke/main.rs +++ b/src/test/run-make/lto-smoke/main.rs @@ -1,3 +1,13 @@ +// 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. + extern mod lib; fn main() {} diff --git a/src/test/run-make/mixing-deps/both.rs b/src/test/run-make/mixing-deps/both.rs index 89d7b6452c9..358b6512ae5 100644 --- a/src/test/run-make/mixing-deps/both.rs +++ b/src/test/run-make/mixing-deps/both.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "rlib"]; #[crate_type = "dylib"]; diff --git a/src/test/run-make/mixing-deps/dylib.rs b/src/test/run-make/mixing-deps/dylib.rs index 130bc2fe803..9aafd086480 100644 --- a/src/test/run-make/mixing-deps/dylib.rs +++ b/src/test/run-make/mixing-deps/dylib.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "dylib"]; extern mod both; diff --git a/src/test/run-make/mixing-deps/prog.rs b/src/test/run-make/mixing-deps/prog.rs index da90f8731f4..5d21c01c631 100644 --- a/src/test/run-make/mixing-deps/prog.rs +++ b/src/test/run-make/mixing-deps/prog.rs @@ -1,3 +1,13 @@ +// 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. + extern mod dylib; extern mod both; diff --git a/src/test/run-make/mixing-libs/Makefile b/src/test/run-make/mixing-libs/Makefile index eb00c801390..533a6933a6d 100644 --- a/src/test/run-make/mixing-libs/Makefile +++ b/src/test/run-make/mixing-libs/Makefile @@ -3,7 +3,7 @@ all: $(RUSTC) rlib.rs $(RUSTC) dylib.rs && exit 1 || exit 0 - $(RUSTC) rlib.rs --dylib + $(RUSTC) rlib.rs --crate-type=dylib $(RUSTC) dylib.rs rm $(call DYLIB,rlib-*) $(RUSTC) prog.rs && exit 1 || exit 0 diff --git a/src/test/run-make/mixing-libs/dylib.rs b/src/test/run-make/mixing-libs/dylib.rs index 9652cb27641..8bdff1d8f08 100644 --- a/src/test/run-make/mixing-libs/dylib.rs +++ b/src/test/run-make/mixing-libs/dylib.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "dylib"]; extern mod rlib; diff --git a/src/test/run-make/mixing-libs/prog.rs b/src/test/run-make/mixing-libs/prog.rs index ec67dea0ab0..9a97ddfd1b5 100644 --- a/src/test/run-make/mixing-libs/prog.rs +++ b/src/test/run-make/mixing-libs/prog.rs @@ -1,3 +1,13 @@ +// 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. + extern mod dylib; extern mod rlib; diff --git a/src/test/run-make/mixing-libs/rlib.rs b/src/test/run-make/mixing-libs/rlib.rs index 32c322f3f59..8ed6dbd865b 100644 --- a/src/test/run-make/mixing-libs/rlib.rs +++ b/src/test/run-make/mixing-libs/rlib.rs @@ -1,2 +1,12 @@ +// 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. + #[crate_type = "rlib"]; pub fn rlib() {} diff --git a/src/test/run-make/no-intermediate-extras/Makefile b/src/test/run-make/no-intermediate-extras/Makefile index 89186b2ad4d..258cbf04c61 100644 --- a/src/test/run-make/no-intermediate-extras/Makefile +++ b/src/test/run-make/no-intermediate-extras/Makefile @@ -3,5 +3,5 @@ -include ../tools.mk all: - $(RUSTC) --rlib --test foo.rs + $(RUSTC) --crate-type=rlib --test foo.rs rm $(TMPDIR)/foo.bc && exit 1 || exit 0 diff --git a/src/test/run-make/output-type-permutations/Makefile b/src/test/run-make/output-type-permutations/Makefile new file mode 100644 index 00000000000..72f96b21fa8 --- /dev/null +++ b/src/test/run-make/output-type-permutations/Makefile @@ -0,0 +1,42 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib + rm $(TMPDIR)/$(call RLIB_GLOB,bar) + rm $(TMPDIR)/$(call DYLIB_GLOB,bar) + rm $(TMPDIR)/$(call STATICLIB_GLOB,bar) + $(RUSTC) foo.rs --crate-type=bin + rm $(TMPDIR)/bar + $(RUSTC) foo.rs --emit=asm,ir,bc,obj,link + rm $(TMPDIR)/bar.ll + rm $(TMPDIR)/bar.bc + rm $(TMPDIR)/bar.s + rm $(TMPDIR)/bar.o + rm $(TMPDIR)/bar + $(RUSTC) foo.rs --emit=asm,ir,bc,obj,link --crate-type=staticlib + rm $(TMPDIR)/bar.ll + rm $(TMPDIR)/bar.bc + rm $(TMPDIR)/bar.s + rm $(TMPDIR)/bar.o + rm $(TMPDIR)/$(call STATICLIB_GLOB,bar) + $(RUSTC) foo.rs --emit=asm -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=bc -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=ir -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=obj -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=link -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=bc,link --crate-type=rlib + rm $(TMPDIR)/bar.bc + rm $(TMPDIR)/$(call RLIB_GLOB,bar) diff --git a/src/test/auxiliary/xc_conditions_2.rs b/src/test/run-make/output-type-permutations/foo.rs index 16a5bb56343..5565ae3186c 100644 --- a/src/test/auxiliary/xc_conditions_2.rs +++ b/src/test/run-make/output-type-permutations/foo.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[crate_type="lib"]; +#[crate_id = "bar"]; -condition! { - pub oops: int -> int; -} +fn main() {} diff --git a/src/test/run-make/prefer-dylib/Makefile b/src/test/run-make/prefer-dylib/Makefile index 8229547176a..6fb7434e68a 100644 --- a/src/test/run-make/prefer-dylib/Makefile +++ b/src/test/run-make/prefer-dylib/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: - $(RUSTC) bar.rs --dylib --rlib + $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib $(RUSTC) foo.rs -Z prefer-dynamic $(call RUN,foo) rm $(TMPDIR)/*bar* diff --git a/src/test/run-make/prefer-dylib/bar.rs b/src/test/run-make/prefer-dylib/bar.rs index c5c0bc606cd..4c79f7e2855 100644 --- a/src/test/run-make/prefer-dylib/bar.rs +++ b/src/test/run-make/prefer-dylib/bar.rs @@ -1 +1,11 @@ +// 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. + pub fn bar() {} diff --git a/src/test/run-make/prefer-dylib/foo.rs b/src/test/run-make/prefer-dylib/foo.rs index f86ef62a9fe..2c22cea09aa 100644 --- a/src/test/run-make/prefer-dylib/foo.rs +++ b/src/test/run-make/prefer-dylib/foo.rs @@ -1,3 +1,13 @@ +// 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. + extern mod bar; fn main() { diff --git a/src/test/run-make/prefer-rlib/Makefile b/src/test/run-make/prefer-rlib/Makefile index eedb70c4efd..c6a239eef08 100644 --- a/src/test/run-make/prefer-rlib/Makefile +++ b/src/test/run-make/prefer-rlib/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: - $(RUSTC) bar.rs --dylib --rlib + $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib ls $(TMPDIR)/$(call RLIB_GLOB,bar) $(RUSTC) foo.rs rm $(TMPDIR)/*bar* diff --git a/src/test/run-make/prefer-rlib/bar.rs b/src/test/run-make/prefer-rlib/bar.rs index c5c0bc606cd..4c79f7e2855 100644 --- a/src/test/run-make/prefer-rlib/bar.rs +++ b/src/test/run-make/prefer-rlib/bar.rs @@ -1 +1,11 @@ +// 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. + pub fn bar() {} diff --git a/src/test/run-make/prefer-rlib/foo.rs b/src/test/run-make/prefer-rlib/foo.rs index f86ef62a9fe..2c22cea09aa 100644 --- a/src/test/run-make/prefer-rlib/foo.rs +++ b/src/test/run-make/prefer-rlib/foo.rs @@ -1,3 +1,13 @@ +// 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. + extern mod bar; fn main() { diff --git a/src/test/run-make/prune-link-args/empty.rs b/src/test/run-make/prune-link-args/empty.rs index 45590d86ba6..a9e231b0ea8 100644 --- a/src/test/run-make/prune-link-args/empty.rs +++ b/src/test/run-make/prune-link-args/empty.rs @@ -1 +1,11 @@ +// 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. + fn main() { } diff --git a/src/test/run-make/rlib-chain/m1.rs b/src/test/run-make/rlib-chain/m1.rs index 1a244efd4dd..ddf90e9157b 100644 --- a/src/test/run-make/rlib-chain/m1.rs +++ b/src/test/run-make/rlib-chain/m1.rs @@ -1,2 +1,12 @@ +// 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. + #[crate_type = "rlib"]; pub fn m1() {} diff --git a/src/test/run-make/rlib-chain/m2.rs b/src/test/run-make/rlib-chain/m2.rs index 96f77122083..612e59d1082 100644 --- a/src/test/run-make/rlib-chain/m2.rs +++ b/src/test/run-make/rlib-chain/m2.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "rlib"]; extern mod m1; diff --git a/src/test/run-make/rlib-chain/m3.rs b/src/test/run-make/rlib-chain/m3.rs index cb8d7529160..7545eed6f01 100644 --- a/src/test/run-make/rlib-chain/m3.rs +++ b/src/test/run-make/rlib-chain/m3.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "rlib"]; extern mod m2; diff --git a/src/test/run-make/rlib-chain/m4.rs b/src/test/run-make/rlib-chain/m4.rs index c52d1f7fcbc..ea2975d6b6e 100644 --- a/src/test/run-make/rlib-chain/m4.rs +++ b/src/test/run-make/rlib-chain/m4.rs @@ -1,3 +1,13 @@ +// 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. + extern mod m3; fn main() { m3::m3() } diff --git a/src/test/run-make/rustdoc-hidden-line/foo.rs b/src/test/run-make/rustdoc-hidden-line/foo.rs index 69c7683780b..d9b7810cc86 100644 --- a/src/test/run-make/rustdoc-hidden-line/foo.rs +++ b/src/test/run-make/rustdoc-hidden-line/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_id="foo#0.1"]; /// The '# ' lines should be removed from the output, but the #[deriving] should be diff --git a/src/test/run-make/rustdoc-smoke/foo.rs b/src/test/run-make/rustdoc-smoke/foo.rs index ef407ed2987..818ec1e5eb7 100644 --- a/src/test/run-make/rustdoc-smoke/foo.rs +++ b/src/test/run-make/rustdoc-smoke/foo.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_id = "foo#0.1"]; //! Very docs diff --git a/src/test/run-make/simple-dylib/Makefile b/src/test/run-make/simple-dylib/Makefile index d4f215c69f0..84e6e079e6f 100644 --- a/src/test/run-make/simple-dylib/Makefile +++ b/src/test/run-make/simple-dylib/Makefile @@ -1,5 +1,5 @@ -include ../tools.mk all: - $(RUSTC) bar.rs --dylib + $(RUSTC) bar.rs --crate-type=dylib $(RUSTC) foo.rs $(call RUN,foo) diff --git a/src/test/run-make/simple-dylib/bar.rs b/src/test/run-make/simple-dylib/bar.rs index c5c0bc606cd..4c79f7e2855 100644 --- a/src/test/run-make/simple-dylib/bar.rs +++ b/src/test/run-make/simple-dylib/bar.rs @@ -1 +1,11 @@ +// 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. + pub fn bar() {} diff --git a/src/test/run-make/simple-dylib/foo.rs b/src/test/run-make/simple-dylib/foo.rs index f86ef62a9fe..2c22cea09aa 100644 --- a/src/test/run-make/simple-dylib/foo.rs +++ b/src/test/run-make/simple-dylib/foo.rs @@ -1,3 +1,13 @@ +// 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. + extern mod bar; fn main() { diff --git a/src/test/run-make/simple-rlib/Makefile b/src/test/run-make/simple-rlib/Makefile index e8909ef134b..7b156cb8748 100644 --- a/src/test/run-make/simple-rlib/Makefile +++ b/src/test/run-make/simple-rlib/Makefile @@ -1,5 +1,5 @@ -include ../tools.mk all: - $(RUSTC) bar.rs --rlib + $(RUSTC) bar.rs --crate-type=rlib $(RUSTC) foo.rs $(call RUN,foo) diff --git a/src/test/run-make/simple-rlib/bar.rs b/src/test/run-make/simple-rlib/bar.rs index c5c0bc606cd..4c79f7e2855 100644 --- a/src/test/run-make/simple-rlib/bar.rs +++ b/src/test/run-make/simple-rlib/bar.rs @@ -1 +1,11 @@ +// 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. + pub fn bar() {} diff --git a/src/test/run-make/simple-rlib/foo.rs b/src/test/run-make/simple-rlib/foo.rs index f86ef62a9fe..2c22cea09aa 100644 --- a/src/test/run-make/simple-rlib/foo.rs +++ b/src/test/run-make/simple-rlib/foo.rs @@ -1,3 +1,13 @@ +// 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. + extern mod bar; fn main() { diff --git a/src/test/run-make/static-unwinding/lib.rs b/src/test/run-make/static-unwinding/lib.rs index 4e2cdb6c222..9fe2f947c70 100644 --- a/src/test/run-make/static-unwinding/lib.rs +++ b/src/test/run-make/static-unwinding/lib.rs @@ -1,3 +1,13 @@ +// 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. + #[crate_type = "rlib"]; pub static mut statik: int = 0; diff --git a/src/test/run-make/static-unwinding/main.rs b/src/test/run-make/static-unwinding/main.rs index 96dabf8f076..c47d2058393 100644 --- a/src/test/run-make/static-unwinding/main.rs +++ b/src/test/run-make/static-unwinding/main.rs @@ -1,3 +1,13 @@ +// 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. + extern mod lib; use std::task; diff --git a/src/test/run-make/volatile-intrinsics/Makefile b/src/test/run-make/volatile-intrinsics/Makefile index fc19412e2ef..bf79ca68c94 100644 --- a/src/test/run-make/volatile-intrinsics/Makefile +++ b/src/test/run-make/volatile-intrinsics/Makefile @@ -5,6 +5,6 @@ all: $(RUSTC) main.rs $(call RUN,main) # ... and the loads/stores must not be optimized out. - $(RUSTC) main.rs --emit-llvm -S + $(RUSTC) main.rs --emit=ir grep "load volatile" $(TMPDIR)/main.ll grep "store volatile" $(TMPDIR)/main.ll diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index 6c4cc9de414..5683a2b6698 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - struct pair<A,B> { a: A, b: B } @@ -29,11 +27,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> { } } -fn f<A:Clone + 'static>(a: A, b: u16) -> @Invokable<A> { - @Invoker { +fn f<A:Clone + 'static>(a: A, b: u16) -> ~Invokable:<A> { + ~Invoker { a: a, b: b, - } as @Invokable<A> + } as ~Invokable:<A> } pub fn main() { diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs deleted file mode 100644 index e00f4142643..00000000000 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2012 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. - -#[feature(managed_boxes)]; - -use std::cell::RefCell; - -struct Pair<A,B> { - a: A, b: B -} - -struct RecEnum<A>(Rec<A>); -struct Rec<A> { - val: A, - rec: Option<@RefCell<RecEnum<A>>> -} - -fn make_cycle<A:'static>(a: A) { - let g: @RefCell<RecEnum<A>> = @RefCell::new(RecEnum(Rec {val: a, rec: None})); - { - let mut gb = g.borrow_mut(); - let gg = gb.get(); - let RecEnum(ref mut gg) = *gg; - gg.rec = Some(g); - } -} - -struct Invoker<A,B> { - a: A, - b: B, -} - -trait Invokable<A,B> { - fn f(&self) -> (A, B); -} - -impl<A:Clone,B:Clone> Invokable<A,B> for Invoker<A,B> { - fn f(&self) -> (A, B) { - (self.a.clone(), self.b.clone()) - } -} - -fn f<A:Send + Clone + 'static, - B:Send + Clone + 'static>( - a: A, - b: B) - -> @Invokable<A,B> { - @Invoker { - a: a, - b: b, - } as @Invokable<A,B> -} - -pub fn main() { - let x = 22_u8; - let y = 44_u64; - let z = f(~x, y); - make_cycle(z); - let (a, b) = z.f(); - info!("a={} b={}", *a as uint, b as uint); - assert_eq!(*a, x); - assert_eq!(b, y); -} diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index b3b09988cc3..6f0bba72025 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -8,17 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait double { - fn double(@self) -> uint; + fn double(~self) -> uint; } impl double for uint { - fn double(@self) -> uint { *self * 2u } + fn double(~self) -> uint { *self * 2u } } pub fn main() { - let x = @(@3u as @double); + let x = ~(~3u as ~double); assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs index 036bbcd48a5..a03ac80a3f1 100644 --- a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs +++ b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs @@ -8,17 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait double { - fn double(@self) -> uint; + fn double(~self) -> uint; } -impl double for @uint { - fn double(@self) -> uint { **self * 2u } +impl double for ~uint { + fn double(~self) -> uint { **self * 2u } } pub fn main() { - let x = @@@@@3u; + let x = ~~~~~3u; assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index 79784688d49..7835eaae510 100644 --- a/src/test/run-pass/autoderef-method-twice.rs +++ b/src/test/run-pass/autoderef-method-twice.rs @@ -8,17 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait double { - fn double(@self) -> uint; + fn double(~self) -> uint; } impl double for uint { - fn double(@self) -> uint { *self * 2u } + fn double(~self) -> uint { *self * 2u } } pub fn main() { - let x = @@3u; + let x = ~~3u; assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index 1a04abe3196..81469e5454a 100644 --- a/src/test/run-pass/autoderef-method.rs +++ b/src/test/run-pass/autoderef-method.rs @@ -8,17 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait double { - fn double(@self) -> uint; + fn double(~self) -> uint; } impl double for uint { - fn double(@self) -> uint { *self * 2u } + fn double(~self) -> uint { *self * 2u } } pub fn main() { - let x = @3u; + let x = ~3u; assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index a3e11d27f27..8839c53f14c 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -10,8 +10,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern mod extra; -use extra::bitv::Bitv; +extern mod collections; +use collections::Bitv; fn bitv_test() { let mut v1 = ~Bitv::new(31, false); diff --git a/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs b/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs index 1490d679049..88e0d24ffe1 100644 --- a/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs +++ b/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs @@ -1,3 +1,13 @@ +// 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. + // Check that we do not ICE when compiling this // macro, which reuses the expression `$id` diff --git a/src/test/run-pass/borrowck-move-by-capture-ok.rs b/src/test/run-pass/borrowck-move-by-capture-ok.rs index 5e8a92cd1c2..8ceef830948 100644 --- a/src/test/run-pass/borrowck-move-by-capture-ok.rs +++ b/src/test/run-pass/borrowck-move-by-capture-ok.rs @@ -1,3 +1,13 @@ +// 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. + pub fn main() { let bar = ~3; let h: proc() -> int = proc() *bar; diff --git a/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs b/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs index e8c3b2480d9..0650b03b485 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs @@ -1,3 +1,13 @@ +// 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. + // exec-env:RUST_POISON_ON_FREE=1 // Test that we root `x` even though it is found in immutable memory, diff --git a/src/test/run-pass/can-copy-pod.rs b/src/test/run-pass/can-copy-pod.rs index 03341e6f946..a6a56a68c5a 100644 --- a/src/test/run-pass/can-copy-pod.rs +++ b/src/test/run-pass/can-copy-pod.rs @@ -1,3 +1,13 @@ +// 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. + /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index 258ed4fb30b..bfc6550523b 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -8,21 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - // xfail-fast // aux-build:cci_class_cast.rs extern mod cci_class_cast; use std::to_str::ToStr; use cci_class_cast::kitty::cat; -fn print_out(thing: @ToStr, expected: ~str) { +fn print_out(thing: ~ToStr, expected: ~str) { let actual = thing.to_str(); info!("{}", actual); assert_eq!(actual, expected); } pub fn main() { - let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr; + let nyan: ~ToStr = ~cat(0u, 2, ~"nyan") as ~ToStr; print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 3e9765f0b2b..e93b3266b25 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - // xfail-fast struct cat { meows : uint, @@ -58,13 +56,13 @@ impl ToStr for cat { } } -fn print_out(thing: @ToStr, expected: ~str) { +fn print_out(thing: ~ToStr, expected: ~str) { let actual = thing.to_str(); info!("{}", actual); assert_eq!(actual, expected); } pub fn main() { - let nyan : @ToStr = @cat(0u, 2, ~"nyan") as @ToStr; + let nyan: ~ToStr = ~cat(0u, 2, ~"nyan") as ~ToStr; print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/cleanup-arm-conditional.rs b/src/test/run-pass/cleanup-arm-conditional.rs index afe1489ce23..c53375c1f5b 100644 --- a/src/test/run-pass/cleanup-arm-conditional.rs +++ b/src/test/run-pass/cleanup-arm-conditional.rs @@ -1,3 +1,13 @@ +// 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. + // 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. diff --git a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs index 53a009ecc13..ec422a54b3a 100644 --- a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -1,3 +1,13 @@ +// 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 cleanup of rvalue temporary that occurs while `~` construction // is in progress. This scenario revealed a rather terrible bug. The // ingredients are: diff --git a/src/test/run-pass/cleanup-shortcircuit.rs b/src/test/run-pass/cleanup-shortcircuit.rs index 982a0d92c4c..4df457fd862 100644 --- a/src/test/run-pass/cleanup-shortcircuit.rs +++ b/src/test/run-pass/cleanup-shortcircuit.rs @@ -1,3 +1,13 @@ +// 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. + // 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. diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index a1624e206ca..6ba665e4005 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - // If we use GEPi rathern than GEP_tup_like when // storing closure data (as we used to do), the u64 would // overwrite the u16. @@ -33,11 +31,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> { } } -fn f<A:Clone + 'static>(a: A, b: u16) -> @Invokable<A> { - @Invoker { +fn f<A:Clone + 'static>(a: A, b: u16) -> ~Invokable:<A> { + ~Invoker { a: a, b: b, - } as @Invokable<A> + } as ~Invokable:<A> } pub fn main() { diff --git a/src/test/run-pass/closure-reform.rs b/src/test/run-pass/closure-reform.rs index 3ed77cd9fb7..51511009bee 100644 --- a/src/test/run-pass/closure-reform.rs +++ b/src/test/run-pass/closure-reform.rs @@ -1,3 +1,13 @@ +// 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. + /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ diff --git a/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs b/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs index e40272bb7a4..0bbabcb8599 100644 --- a/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs +++ b/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs @@ -1,3 +1,13 @@ +// 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. + fn negate(x: &int) -> int { -*x } diff --git a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs index 52fa1399363..419df84bdf5 100644 --- a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs @@ -1,3 +1,13 @@ +// 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. + struct SpeechMaker { speeches: uint } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs index b31f0eab2e2..f6abfda03e3 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs @@ -1,3 +1,13 @@ +// 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. + fn sum(x: &[int]) -> int { let mut sum = 0; for y in x.iter() { sum += *y; } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index 8a271a4d65f..dee2b6f2568 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -1,3 +1,13 @@ +// 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. + fn bar(v: &mut [uint]) -> ~[uint] { v.to_owned() } diff --git a/src/test/run-pass/coerce-reborrow-mut-ptr-arg.rs b/src/test/run-pass/coerce-reborrow-mut-ptr-arg.rs index f8650c856c6..4a680027b46 100644 --- a/src/test/run-pass/coerce-reborrow-mut-ptr-arg.rs +++ b/src/test/run-pass/coerce-reborrow-mut-ptr-arg.rs @@ -1,3 +1,13 @@ +// 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. + struct SpeechMaker { speeches: uint } diff --git a/src/test/run-pass/coerce-reborrow-mut-ptr-rcvr.rs b/src/test/run-pass/coerce-reborrow-mut-ptr-rcvr.rs index 3adb805581d..2f866955ff4 100644 --- a/src/test/run-pass/coerce-reborrow-mut-ptr-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-mut-ptr-rcvr.rs @@ -1,3 +1,13 @@ +// 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. + struct SpeechMaker { speeches: uint } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs index 356c1596186..0e205617173 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs @@ -1,3 +1,13 @@ +// 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. + fn reverse(v: &mut [uint]) { v.reverse(); } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs index 556d70f3c88..3deb31efd31 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs @@ -1,3 +1,13 @@ +// 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. + fn bar(v: &mut [uint]) { v.reverse(); v.reverse(); diff --git a/src/test/run-pass/const-struct-offsets.rs b/src/test/run-pass/const-struct-offsets.rs index 2bb0516cad4..b79d9d6beba 100644 --- a/src/test/run-pass/const-struct-offsets.rs +++ b/src/test/run-pass/const-struct-offsets.rs @@ -1,3 +1,13 @@ +// 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. + enum Foo { IntVal(i32), Int64Val(i64) diff --git a/src/test/run-pass/deriving-enum-single-variant.rs b/src/test/run-pass/deriving-enum-single-variant.rs index ebbdc157c7d..075a9431b19 100644 --- a/src/test/run-pass/deriving-enum-single-variant.rs +++ b/src/test/run-pass/deriving-enum-single-variant.rs @@ -1,3 +1,13 @@ +// 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. + type task_id = int; #[deriving(Eq)] diff --git a/src/test/run-pass/deriving-global.rs b/src/test/run-pass/deriving-global.rs index a7a3784877c..832474c714d 100644 --- a/src/test/run-pass/deriving-global.rs +++ b/src/test/run-pass/deriving-global.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-fast #7103 `extern mod` does not work on check-fast // xfail-pretty - does not converge diff --git a/src/test/run-pass/deriving-show.rs b/src/test/run-pass/deriving-show.rs new file mode 100644 index 00000000000..40965615506 --- /dev/null +++ b/src/test/run-pass/deriving-show.rs @@ -0,0 +1,42 @@ +// 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. + +#[feature(struct_variant, macro_rules)]; + +#[deriving(Show)] +struct Unit; + +#[deriving(Show)] +struct Tuple(int, uint); + +#[deriving(Show)] +struct Struct { x: int, y: uint } + +#[deriving(Show)] +enum Enum { + Nullary, + Variant(int, uint), + StructVariant { x: int, y : uint } +} + +macro_rules! t { + ($x:expr, $expected:expr) => { + assert_eq!(format!("{}", $x), $expected.to_owned()) + } +} + +pub fn main() { + t!(Unit, "Unit"); + t!(Tuple(1, 2), "Tuple(1, 2)"); + t!(Struct { x: 1, y: 2 }, "Struct { x: 1, y: 2 }"); + t!(Nullary, "Nullary"); + t!(Variant(1, 2), "Variant(1, 2)"); + t!(StructVariant { x: 1, y: 2 }, "StructVariant { x: 1, y: 2 }"); +} diff --git a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs index 83c8679027b..38ecd6db63c 100644 --- a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs +++ b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(struct_variant)]; #[deriving(Eq)] diff --git a/src/test/run-pass/die-macro.rs b/src/test/run-pass/die-macro.rs index f08e5f054a9..0d58cae7036 100644 --- a/src/test/run-pass/die-macro.rs +++ b/src/test/run-pass/die-macro.rs @@ -1,3 +1,13 @@ +// 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. + // Just testing that fail!() type checks in statement or expr #[allow(unreachable_code)]; diff --git a/src/test/run-pass/enum-discr.rs b/src/test/run-pass/enum-discr.rs index 28f38829167..1d7ec0aa1bc 100644 --- a/src/test/run-pass/enum-discr.rs +++ b/src/test/run-pass/enum-discr.rs @@ -1,3 +1,13 @@ +// 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. + enum Animal { Cat = 0u, Dog = 1u, diff --git a/src/test/run-pass/enum-variants.rs b/src/test/run-pass/enum-variants.rs index 69f3c881388..43bcd284dc2 100644 --- a/src/test/run-pass/enum-variants.rs +++ b/src/test/run-pass/enum-variants.rs @@ -1,3 +1,13 @@ +// 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. + #[allow(dead_assignment)]; #[allow(unused_variable)]; #[feature(struct_variant)]; diff --git a/src/test/run-pass/explicit-self-objects-box.rs b/src/test/run-pass/explicit-self-objects-box.rs deleted file mode 100644 index faf2a61ca78..00000000000 --- a/src/test/run-pass/explicit-self-objects-box.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 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. - -#[feature(managed_boxes)]; - -trait Foo { - fn f(@self); -} - -struct S { - x: int -} - -impl Foo for S { - fn f(@self) { - assert_eq!(self.x, 3); - } -} - -pub fn main() { - let x = @S { x: 3 }; - let y = x as @Foo; - y.f(); - y.f(); - y.f(); - y.f(); -} diff --git a/src/test/run-pass/explicit-self-objects-simple.rs b/src/test/run-pass/explicit-self-objects-simple.rs deleted file mode 100644 index ca64516a7ef..00000000000 --- a/src/test/run-pass/explicit-self-objects-simple.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 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. - -#[feature(managed_boxes)]; - -trait Foo { - fn f(&self); -} - -struct S { - x: int -} - -impl Foo for S { - fn f(&self) { - assert_eq!(self.x, 3); - } -} - -pub fn main() { - let x = @S { x: 3 }; - let y = x as @Foo; - y.f(); -} diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index 65e6e384c5f..1076fc1662f 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - static tau: f64 = 2.0*3.14159265358979323; struct Point {x: f64, y: f64} @@ -49,7 +47,7 @@ struct thing { #[deriving(Clone)] struct A { - a: @int + a: int } fn thing(x: A) -> thing { @@ -59,26 +57,20 @@ fn thing(x: A) -> thing { } impl thing { - pub fn foo(@self) -> int { *self.x.a } - pub fn bar(~self) -> int { *self.x.a } - pub fn quux(&self) -> int { *self.x.a } + pub fn bar(~self) -> int { self.x.a } + pub fn quux(&self) -> int { self.x.a } pub fn baz<'a>(&'a self) -> &'a A { &self.x } - pub fn spam(self) -> int { *self.x.a } + pub fn spam(self) -> int { self.x.a } } trait Nus { fn f(&self); } impl Nus for thing { fn f(&self) {} } pub fn main() { - - let x = @thing(A {a: @10}); - assert_eq!(x.foo(), 10); - assert_eq!(x.quux(), 10); - - let y = ~thing(A {a: @10}); + let y = ~thing(A {a: 10}); assert_eq!(y.clone().bar(), 10); assert_eq!(y.quux(), 10); - let z = thing(A {a: @11}); + let z = thing(A {a: 11}); assert_eq!(z.spam(), 11); } diff --git a/src/test/run-pass/expr-repeat-vstore.rs b/src/test/run-pass/expr-repeat-vstore.rs index c841297e19f..c34c902b814 100644 --- a/src/test/run-pass/expr-repeat-vstore.rs +++ b/src/test/run-pass/expr-repeat-vstore.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(managed_boxes)]; pub fn main() { diff --git a/src/test/run-pass/extern-mod-ordering-exe.rs b/src/test/run-pass/extern-mod-ordering-exe.rs index 17731d9ec94..3437f5621e4 100644 --- a/src/test/run-pass/extern-mod-ordering-exe.rs +++ b/src/test/run-pass/extern-mod-ordering-exe.rs @@ -1,3 +1,13 @@ +// 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. + // aux-build:extern_mod_ordering_lib.rs // xfail-fast diff --git a/src/test/run-pass/extern-pub.rs b/src/test/run-pass/extern-pub.rs index b146f32ec1e..28025728472 100644 --- a/src/test/run-pass/extern-pub.rs +++ b/src/test/run-pass/extern-pub.rs @@ -1,3 +1,13 @@ +// 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. + extern { pub fn free(p: *u8); } diff --git a/src/test/run-pass/foreign-call-no-runtime.rs b/src/test/run-pass/foreign-call-no-runtime.rs index daaaac93791..130f04b3fb2 100644 --- a/src/test/run-pass/foreign-call-no-runtime.rs +++ b/src/test/run-pass/foreign-call-no-runtime.rs @@ -1,3 +1,13 @@ +// 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. + use std::cast; use std::libc; use std::unstable::run_in_bare_thread; diff --git a/src/test/run-pass/func-arg-incomplete-pattern.rs b/src/test/run-pass/func-arg-incomplete-pattern.rs index cba12e9199b..6dc9ef2fa4b 100644 --- a/src/test/run-pass/func-arg-incomplete-pattern.rs +++ b/src/test/run-pass/func-arg-incomplete-pattern.rs @@ -1,3 +1,13 @@ +// 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 we do not leak when the arg pattern must drop part of the // argument (in this case, the `y` field). diff --git a/src/test/run-pass/func-arg-ref-pattern.rs b/src/test/run-pass/func-arg-ref-pattern.rs index 1b7d641fa82..11df22d7433 100644 --- a/src/test/run-pass/func-arg-ref-pattern.rs +++ b/src/test/run-pass/func-arg-ref-pattern.rs @@ -1,3 +1,13 @@ +// 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. + // exec-env:RUST_POISON_ON_FREE=1 // Test argument patterns where we create refs to the inside of `~` diff --git a/src/test/run-pass/func-arg-wild-pattern.rs b/src/test/run-pass/func-arg-wild-pattern.rs index ec58198d4a3..97ba561baea 100644 --- a/src/test/run-pass/func-arg-wild-pattern.rs +++ b/src/test/run-pass/func-arg-wild-pattern.rs @@ -1,3 +1,13 @@ +// 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 we can compile code that uses a `_` in function argument // patterns. diff --git a/src/test/run-pass/generic-newtype-struct.rs b/src/test/run-pass/generic-newtype-struct.rs index d6aa69c4c13..f87e11cbb61 100644 --- a/src/test/run-pass/generic-newtype-struct.rs +++ b/src/test/run-pass/generic-newtype-struct.rs @@ -1,3 +1,13 @@ +// 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. + struct S<T>(T); pub fn main() { diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs index bff51d32333..76db4a01829 100644 --- a/src/test/run-pass/generic-object.rs +++ b/src/test/run-pass/generic-object.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait Foo<T> { fn get(&self) -> T; } @@ -25,7 +23,7 @@ impl Foo<int> for S { } pub fn main() { - let x = @S { x: 1 }; - let y = x as @Foo<int>; + let x = ~S { x: 1 }; + let y = x as ~Foo<int>; assert_eq!(y.get(), 1); } diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index bfc14006565..db8098a79ac 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -10,13 +10,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern mod extra; +extern mod getopts; -use extra::getopts::{optopt, getopts}; +use getopts::{optopt, getopts}; pub fn main() { let args = ~[]; - let opts = ~[optopt("b")]; + let opts = ~[optopt("b", "", "something", "SMTHNG")]; match getopts(args, opts) { Ok(ref m) => diff --git a/src/test/run-pass/guards-not-exhaustive.rs b/src/test/run-pass/guards-not-exhaustive.rs index 4d30fbe1559..4496769ec56 100644 --- a/src/test/run-pass/guards-not-exhaustive.rs +++ b/src/test/run-pass/guards-not-exhaustive.rs @@ -1,3 +1,13 @@ +// 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. + enum Q { R(Option<uint>) } fn xyzzy(q: Q) -> uint { diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index b66446b0cfe..4a82007f060 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -23,12 +23,12 @@ struct A; struct B; impl fmt::Signed for A { - fn fmt(_: &A, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.buf.write("aloha".as_bytes()) } } impl fmt::Signed for B { - fn fmt(_: &B, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.buf.write("adios".as_bytes()) } } diff --git a/src/test/run-pass/impl-privacy-xc-1.rs b/src/test/run-pass/impl-privacy-xc-1.rs index 19d3caf818d..96d1b8b38d6 100644 --- a/src/test/run-pass/impl-privacy-xc-1.rs +++ b/src/test/run-pass/impl-privacy-xc-1.rs @@ -1,3 +1,13 @@ +// 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. + // aux-build:impl_privacy_xc_1.rs // xfail-fast diff --git a/src/test/run-pass/impl-privacy-xc-2.rs b/src/test/run-pass/impl-privacy-xc-2.rs index 306294fa76d..06df8da3c38 100644 --- a/src/test/run-pass/impl-privacy-xc-2.rs +++ b/src/test/run-pass/impl-privacy-xc-2.rs @@ -1,3 +1,13 @@ +// 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. + // aux-build:impl_privacy_xc_2.rs // xfail-fast diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index cef183e5f33..88fab664e69 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -14,7 +14,8 @@ // notes on this test case: // On Thu, Apr 18, 2013 at 6:30 PM, John Clements <clements@brinckerhoff.org> wrote: -// the "issue-2185.rs" test was xfailed with a ref to #2263. Issue #2263 is now fixed, so I tried it again, and after adding some &self parameters, I got this error: +// the "issue-2185.rs" test was xfailed with a ref to #2263. Issue #2263 is now fixed, +// so I tried it again, and after adding some &self parameters, I got this error: // // Running /usr/local/bin/rustc: // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait @@ -26,10 +27,15 @@ // issue-2185.rs:21 fn iter(&self, blk: |A|) { self(blk); } // issue-2185.rs:22 } // -// … so it looks like it's just not possible to implement both the generic iterable<uint> and iterable<A> for the type iterable<uint>. Is it okay if I just remove this test? +// … so it looks like it's just not possible to implement both +// the generic iterable<uint> and iterable<A> for the type iterable<uint>. +// Is it okay if I just remove this test? // // but Niko responded: -// think it's fine to remove this test, just because it's old and cruft and not hard to reproduce. *However* it should eventually be possible to implement the same interface for the same type multiple times with different type parameters, it's just that our current trait implementation has accidental limitations. +// think it's fine to remove this test, just because it's old and cruft and not hard to reproduce. +// *However* it should eventually be possible to implement the same interface for the same type +// multiple times with different type parameters, it's just that our current trait implementation +// has accidental limitations. // so I'm leaving it in. // actually, it looks like this is related to bug #3429. I'll rename this bug. diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 6ba253ca461..9e03023a9e9 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait clam<A> { fn chowder(&self, y: A); } @@ -28,13 +26,13 @@ fn foo<A>(b: A) -> foo<A> { } } -fn f<A>(x: @clam<A>, a: A) { +fn f<A>(x: ~clam<A>, a: A) { x.chowder(a); } pub fn main() { let c = foo(42); - let d: @clam<int> = @c as @clam<int>; + let d: ~clam<int> = ~c as ~clam<int>; f(d, c.x); } diff --git a/src/test/run-pass/issue-2380-b.rs b/src/test/run-pass/issue-2380-b.rs index 0c41d071ab0..d61622e6b0f 100644 --- a/src/test/run-pass/issue-2380-b.rs +++ b/src/test/run-pass/issue-2380-b.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - // xfail-fast // aux-build:issue-2380.rs diff --git a/src/test/run-pass/issue-2383.rs b/src/test/run-pass/issue-2383.rs index 0314c7fed02..e7eea698ae7 100644 --- a/src/test/run-pass/issue-2383.rs +++ b/src/test/run-pass/issue-2383.rs @@ -10,9 +10,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern mod extra; -use extra::ringbuf::RingBuf; -use extra::container::Deque; +extern mod collections; +use collections::RingBuf; +use collections::Deque; pub fn main() { let mut q = RingBuf::new(); diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 4b932e2e57e..a2a9228091e 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -8,19 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait hax { } impl<A> hax for A { } -fn perform_hax<T:'static>(x: @T) -> @hax { - @x as @hax +fn perform_hax<T: 'static>(x: ~T) -> ~hax: { + ~x as ~hax: } fn deadcode() { - perform_hax(@~"deadcode"); + perform_hax(~~"deadcode"); } pub fn main() { - let _ = perform_hax(@42); + let _ = perform_hax(~42); } diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index b1c357538ab..327f2cb897f 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -8,19 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait hax { } impl<A> hax for A { } -fn perform_hax<T:'static>(x: @T) -> @hax { - @x as @hax +fn perform_hax<T: 'static>(x: ~T) -> ~hax: { + ~x as ~hax: } fn deadcode() { - perform_hax(@~"deadcode"); + perform_hax(~~"deadcode"); } pub fn main() { - perform_hax(@42); + perform_hax(~42); } diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index f3c74cd9295..bb288e88b20 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -53,7 +53,8 @@ fn add_interface(_store: int, managed_ip: ~str, data: extra::json::Json) -> (~st } } -fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, extra::json::Json>) -> ~[(~str, object)] +fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, extra::json::Json>) +-> ~[(~str, object)] { match device.get(&~"interfaces") { diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index 269093c010c..8cf9436ef51 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - //type t = { a: int }; // type t = { a: bool }; type t = bool; @@ -24,10 +22,10 @@ impl it for t { pub fn main() { // let x = ({a: 4i} as it); - // let y = @({a: 4i}); - // let z = @({a: 4i} as it); - // let z = @({a: true} as it); - let z = @(@true as @it); + // let y = ~({a: 4i}); + // let z = ~({a: 4i} as it); + // let z = ~({a: true} as it); + let z = ~(~true as ~it); // x.f(); // y.f(); // (*z).f(); diff --git a/src/test/run-pass/issue-3211.rs b/src/test/run-pass/issue-3211.rs index 63a457be9f0..6921ba649e6 100644 --- a/src/test/run-pass/issue-3211.rs +++ b/src/test/run-pass/issue-3211.rs @@ -1,3 +1,13 @@ +// 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. + pub fn main() { let mut x = 0; for _ in range(0, 4096) { x += 1; } diff --git a/src/test/run-pass/issue-3250.rs b/src/test/run-pass/issue-3250.rs index 0a93b89a94d..255f6b1635c 100644 --- a/src/test/run-pass/issue-3250.rs +++ b/src/test/run-pass/issue-3250.rs @@ -1,3 +1,13 @@ +// 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. + #[auto_serialize] type t = (uint, uint); diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index e092d45ce68..9e20de16ae1 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -13,31 +13,31 @@ extern mod extra; enum Token { - Text(@~str), - ETag(@~[~str], @~str), - UTag(@~[~str], @~str), - Section(@~[~str], bool, @~[Token], @~str, @~str, @~str, @~str, @~str), - IncompleteSection(@~[~str], bool, @~str, bool), - Partial(@~str, @~str, @~str), + Text(@~str), + ETag(@~[~str], @~str), + UTag(@~[~str], @~str), + Section(@~[~str], bool, @~[Token], @~str, @~str, @~str, @~str, @~str), + IncompleteSection(@~[~str], bool, @~str, bool), + Partial(@~str, @~str, @~str), } fn check_strs(actual: &str, expected: &str) -> bool { - if actual != expected - { - println!("Found {}, but expected {}", actual, expected); - return false; - } - return true; + if actual != expected + { + println!("Found {}, but expected {}", actual, expected); + return false; + } + return true; } pub fn main() { - // assert!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")")); - // assert!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")")); +// assert!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")")); +// assert!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")")); - let t = Text(@~"foo"); - let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo"); - let v = format!("{:?}", u); // this is the line that causes the seg fault - assert!(v.len() > 0); + let t = Text(@~"foo"); + let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo"); + let v = format!("{:?}", u); // this is the line that causes the seg fault + assert!(v.len() > 0); } diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 54f865a6cd5..f60d8b2de64 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -41,8 +41,6 @@ struct Rect { size: Size, } -// TODO: operators - // Contains the information needed to do shape rendering via ASCII art. struct AsciiArt { width: uint, diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index bcda2e27614..9f6b1578b95 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -1,3 +1,13 @@ +// 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. + extern mod extra; use std::comm::Chan; diff --git a/src/test/run-pass/issue-3702.rs b/src/test/run-pass/issue-3702.rs index 6f2d0481aec..43f2e764e69 100644 --- a/src/test/run-pass/issue-3702.rs +++ b/src/test/run-pass/issue-3702.rs @@ -8,14 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - pub fn main() { trait Text { fn to_str(&self) -> ~str; } - fn to_string(t: @Text) { + fn to_string(t: ~Text) { println!("{}", t.to_str()); } diff --git a/src/test/run-pass/issue-3794.rs b/src/test/run-pass/issue-3794.rs index f6c531334c9..8cc7d275789 100644 --- a/src/test/run-pass/issue-3794.rs +++ b/src/test/run-pass/issue-3794.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait T { fn print(&self); } @@ -33,9 +31,9 @@ fn print_s(s: &S) { } pub fn main() { - let s: @S = @S { s: 5 }; + let s: ~S = ~S { s: 5 }; print_s(s); - let t: @T = s as @T; + let t: ~T = s as ~T; print_t(t); } diff --git a/src/test/run-pass/issue-4120.rs b/src/test/run-pass/issue-4120.rs index deb8e0a3b07..d0968633d9f 100644 --- a/src/test/run-pass/issue-4120.rs +++ b/src/test/run-pass/issue-4120.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // XFAIL'd due to Valgrind complaining about TLS loss. diff --git a/src/test/run-pass/issue-4401.rs b/src/test/run-pass/issue-4401.rs index 72390cfdad7..35675225aae 100644 --- a/src/test/run-pass/issue-4401.rs +++ b/src/test/run-pass/issue-4401.rs @@ -1,3 +1,13 @@ +// 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. + pub fn main() { let mut count = 0; for _ in range(0, 999_999) { count += 1; } diff --git a/src/test/run-pass/issue-5239-2.rs b/src/test/run-pass/issue-5239-2.rs index eabc1cfeb59..863acc5c0c3 100644 --- a/src/test/run-pass/issue-5239-2.rs +++ b/src/test/run-pass/issue-5239-2.rs @@ -10,7 +10,7 @@ // Regression test for issue #5239 -pub fn main() { +pub fn main() { let _f: |int| -> int = |ref x: int| { *x }; let foo = 10; assert!(_f(foo) == 10); diff --git a/src/test/run-pass/issue-5572.rs b/src/test/run-pass/issue-5572.rs index d1a1fbf0940..d71e30eb64a 100644 --- a/src/test/run-pass/issue-5572.rs +++ b/src/test/run-pass/issue-5572.rs @@ -1,3 +1,13 @@ +// 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. + fn foo<T: ::std::cmp::Eq>(_t: T) { } pub fn main() { } diff --git a/src/test/run-pass/issue-7563.rs b/src/test/run-pass/issue-7563.rs index f15c6de9778..11d392f1fb1 100644 --- a/src/test/run-pass/issue-7563.rs +++ b/src/test/run-pass/issue-7563.rs @@ -1,3 +1,13 @@ +// 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. + trait IDummy { fn do_nothing(&self); } diff --git a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs index 2e59111e689..cf1f979acb4 100644 --- a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs +++ b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - /* #7673 Polymorphically creating traits barely works @@ -24,7 +22,3 @@ impl<T: 'static> A for T {} fn owned1<T: 'static>(a: T) { ~a as ~A:; } /* note `:` */ fn owned2<T: 'static>(a: ~T) { a as ~A:; } fn owned3<T: 'static>(a: ~T) { ~a as ~A:; } - -fn managed1<T: 'static>(a: T) { @a as @A; } -fn managed2<T: 'static>(a: @T) { a as @A; } -fn managed3<T: 'static>(a: @T) { @a as @A; } diff --git a/src/test/run-pass/issue-7911.rs b/src/test/run-pass/issue-7911.rs index a21e6e04abc..6f4618a3b3b 100644 --- a/src/test/run-pass/issue-7911.rs +++ b/src/test/run-pass/issue-7911.rs @@ -10,7 +10,7 @@ // xfail-pretty -// (Closes #7911) Test that we can use the same self expression +// (Closes #7911) Test that we can use the same self expression // with different mutability in macro in two methods #[allow(unused_variable)]; // unused foobar_immut + foobar_mut diff --git a/src/test/run-pass/issue-9129.rs b/src/test/run-pass/issue-9129.rs index bc6702c6df6..3cb6f525cbc 100644 --- a/src/test/run-pass/issue-9129.rs +++ b/src/test/run-pass/issue-9129.rs @@ -10,11 +10,11 @@ // xfail-pretty -#[feature(managed_boxes, macro_rules)]; +#[feature(macro_rules)]; -pub trait bomb { fn boom(@self, Ident); } +pub trait bomb { fn boom(&self, Ident); } pub struct S; -impl bomb for S { fn boom(@self, _: Ident) { } } +impl bomb for S { fn boom(&self, _: Ident) { } } pub struct Ident { name: uint } @@ -26,7 +26,7 @@ fn Ident_new() -> Ident { Ident {name: 0x6789ABCD } } -pub fn light_fuse(fld: @bomb) { +pub fn light_fuse(fld: ~bomb) { int3!(); let f = || { int3!(); @@ -36,6 +36,6 @@ pub fn light_fuse(fld: @bomb) { } pub fn main() { - let b = @S as @bomb; + let b = ~S as ~bomb; light_fuse(b); } diff --git a/src/test/run-pass/ivec-tag.rs b/src/test/run-pass/ivec-tag.rs index aa009a91aec..302ea5a4b01 100644 --- a/src/test/run-pass/ivec-tag.rs +++ b/src/test/run-pass/ivec-tag.rs @@ -1,3 +1,13 @@ +// 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. + use std::task; fn producer(c: &Chan<~[u8]>) { diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index dab8a83ea36..0a7e164ca5b 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -8,23 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - trait repeat<A> { fn get(&self) -> A; } -impl<A:Clone + 'static> repeat<A> for @A { +impl<A:Clone + 'static> repeat<A> for ~A { fn get(&self) -> A { (**self).clone() } } -fn repeater<A:Clone + 'static>(v: @A) -> @repeat:<A> { +fn repeater<A:Clone + 'static>(v: ~A) -> ~repeat:<A> { // Note: owned kind is not necessary as A appears in the trait type - @v as @repeat:<A> // No + ~v as ~repeat:<A> // No } pub fn main() { let x = 3; - let y = repeater(@x); + let y = repeater(~x); assert_eq!(x, y.get()); } diff --git a/src/test/run-pass/kinds-in-metadata.rs b/src/test/run-pass/kinds-in-metadata.rs index 857cfccee9b..12eff66f72d 100644 --- a/src/test/run-pass/kinds-in-metadata.rs +++ b/src/test/run-pass/kinds-in-metadata.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-fast // aux-build:kinds_in_metadata.rs diff --git a/src/test/run-pass/let-destruct-ref.rs b/src/test/run-pass/let-destruct-ref.rs index fdb2805ae18..c58fd89bb41 100644 --- a/src/test/run-pass/let-destruct-ref.rs +++ b/src/test/run-pass/let-destruct-ref.rs @@ -1,3 +1,13 @@ +// 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. + pub fn main() { let x = ~"hello"; let ref y = x; diff --git a/src/test/run-pass/link-section.rs b/src/test/run-pass/link-section.rs index 0a1d28b2ef1..38b5a858aff 100644 --- a/src/test/run-pass/link-section.rs +++ b/src/test/run-pass/link-section.rs @@ -1,3 +1,13 @@ +// 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. + #[cfg(not(target_os = "macos"))] #[link_section=".moretext"] fn i_live_in_more_text() -> &'static str { diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index 77bac4d12fc..a96c01e56d9 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -10,8 +10,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern mod extra; -use extra::list; +extern mod collections; +use collections::list; #[deriving(Clone)] enum foo { diff --git a/src/test/run-pass/logging-only-prints-once.rs b/src/test/run-pass/logging-only-prints-once.rs index dccdc8ae3ba..8c6a366220c 100644 --- a/src/test/run-pass/logging-only-prints-once.rs +++ b/src/test/run-pass/logging-only-prints-once.rs @@ -17,8 +17,8 @@ use std::fmt; struct Foo(Cell<int>); impl fmt::Show for Foo { - fn fmt(f: &Foo, _fmt: &mut fmt::Formatter) -> fmt::Result { - let Foo(ref f) = *f; + fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result { + let Foo(ref f) = *self; assert!(f.get() == 0); f.set(1); Ok(()) diff --git a/src/test/run-pass/match-drop-strs-issue-4541.rs b/src/test/run-pass/match-drop-strs-issue-4541.rs index dbc88f02369..5fbe6b4aa63 100644 --- a/src/test/run-pass/match-drop-strs-issue-4541.rs +++ b/src/test/run-pass/match-drop-strs-issue-4541.rs @@ -1,3 +1,13 @@ +// 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. + // Tests a tricky scenario involving string matching, // copying, and moving to ensure that we don't segfault // or double-free, as we were wont to do in the past. diff --git a/src/test/run-pass/match-range-static.rs b/src/test/run-pass/match-range-static.rs index 0bf0d6e41fa..039b3f9a26c 100644 --- a/src/test/run-pass/match-range-static.rs +++ b/src/test/run-pass/match-range-static.rs @@ -1,3 +1,13 @@ +// 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. + static s: int = 1; static e: int = 42; diff --git a/src/test/run-pass/match-vec-rvalue.rs b/src/test/run-pass/match-vec-rvalue.rs index a6e61fbacd4..20693897236 100644 --- a/src/test/run-pass/match-vec-rvalue.rs +++ b/src/test/run-pass/match-vec-rvalue.rs @@ -1,3 +1,13 @@ +// 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. + // Tests that matching rvalues with drops does not crash. pub fn main() { diff --git a/src/test/run-pass/mid-path-type-params.rs b/src/test/run-pass/mid-path-type-params.rs index bc4f4273dfb..4a04a71f9a0 100644 --- a/src/test/run-pass/mid-path-type-params.rs +++ b/src/test/run-pass/mid-path-type-params.rs @@ -1,3 +1,13 @@ +// 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. + struct S<T> { contents: T, } diff --git a/src/test/run-pass/morestack-address.rs b/src/test/run-pass/morestack-address.rs deleted file mode 100644 index ec678df357a..00000000000 --- a/src/test/run-pass/morestack-address.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 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. - -mod rusti { - #[nolink] - extern "rust-intrinsic" { - pub fn morestack_addr() -> *(); - } -} - -pub fn main() { - unsafe { - let addr = rusti::morestack_addr(); - assert!(addr.is_not_null()); - error!("{}", addr); - } -} diff --git a/src/test/run-pass/move-out-of-field.rs b/src/test/run-pass/move-out-of-field.rs index 6cf207e5cbc..2041c69cecc 100644 --- a/src/test/run-pass/move-out-of-field.rs +++ b/src/test/run-pass/move-out-of-field.rs @@ -1,3 +1,13 @@ +// 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. + struct StringBuffer { s: ~str } diff --git a/src/test/run-pass/move-self.rs b/src/test/run-pass/move-self.rs index 1bb45b867c3..854beea7002 100644 --- a/src/test/run-pass/move-self.rs +++ b/src/test/run-pass/move-self.rs @@ -1,3 +1,13 @@ +// 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. + struct S { x: ~str } diff --git a/src/test/run-pass/moves-based-on-type-capture-clause.rs b/src/test/run-pass/moves-based-on-type-capture-clause.rs index eb347ab28ff..6751cca798a 100644 --- a/src/test/run-pass/moves-based-on-type-capture-clause.rs +++ b/src/test/run-pass/moves-based-on-type-capture-clause.rs @@ -1,3 +1,13 @@ +// 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. + use std::task; pub fn main() { diff --git a/src/test/run-pass/multiple-trait-bounds.rs b/src/test/run-pass/multiple-trait-bounds.rs index cdfa93d3094..fc052b6a389 100644 --- a/src/test/run-pass/multiple-trait-bounds.rs +++ b/src/test/run-pass/multiple-trait-bounds.rs @@ -1,3 +1,13 @@ +// 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. + fn f<T:Eq + Ord>(_: T) { } diff --git a/src/test/run-pass/new-box-syntax.rs b/src/test/run-pass/new-box-syntax.rs index d237c4d9a4e..7a90ea436e0 100644 --- a/src/test/run-pass/new-box-syntax.rs +++ b/src/test/run-pass/new-box-syntax.rs @@ -1,3 +1,13 @@ +// 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. + /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ diff --git a/src/test/run-pass/new-impl-syntax.rs b/src/test/run-pass/new-impl-syntax.rs index c1cdb3c1b23..6def21a389a 100644 --- a/src/test/run-pass/new-impl-syntax.rs +++ b/src/test/run-pass/new-impl-syntax.rs @@ -1,3 +1,13 @@ +// 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. + struct Thingy { x: int, y: int diff --git a/src/test/run-pass/newtype-struct-with-dtor.rs b/src/test/run-pass/newtype-struct-with-dtor.rs index cbbfc387de3..ca79c304802 100644 --- a/src/test/run-pass/newtype-struct-with-dtor.rs +++ b/src/test/run-pass/newtype-struct-with-dtor.rs @@ -1,3 +1,13 @@ +// 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. + use std::libc::c_int; use std::libc; diff --git a/src/test/run-pass/newtype-struct-xc-2.rs b/src/test/run-pass/newtype-struct-xc-2.rs index cedf1d42c3d..7c1e1e05098 100644 --- a/src/test/run-pass/newtype-struct-xc-2.rs +++ b/src/test/run-pass/newtype-struct-xc-2.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-fast // aux-build:newtype_struct_xc.rs diff --git a/src/test/run-pass/newtype-struct-xc.rs b/src/test/run-pass/newtype-struct-xc.rs index 2280b335f3f..3237db1288e 100644 --- a/src/test/run-pass/newtype-struct-xc.rs +++ b/src/test/run-pass/newtype-struct-xc.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-fast // aux-build:newtype_struct_xc.rs diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index 408c6c037cc..e6fe0873d62 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -12,9 +12,9 @@ #[feature(managed_boxes)]; -extern mod extra; +extern mod collections; -use extra::list::{List, Cons, Nil, head, is_empty}; +use collections::list::{List, Cons, Nil, head, is_empty}; fn pure_length_go<T:Clone>(ls: @List<T>, acc: uint) -> uint { match *ls { Nil => { acc } Cons(_, tl) => { pure_length_go(tl, acc + 1u) } } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index 7d8d5d635f9..5d688c1f030 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-test // xfail'd due to a bug in move detection for macros. diff --git a/src/test/run-pass/objects-coerce-from-managed-to-borrowed.rs b/src/test/run-pass/objects-coerce-from-managed-to-borrowed.rs deleted file mode 100644 index 52792c8c427..00000000000 --- a/src/test/run-pass/objects-coerce-from-managed-to-borrowed.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 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. - -#[feature(managed_boxes)]; - -// Test that we can coerce an `@Object` to an `&Object` - -trait Foo { - fn foo(&self) -> uint; -} - -impl Foo for uint { - fn foo(&self) -> uint { - *self - } -} - -fn do_it_imm(obj: &Foo, v: uint) { - let y = obj.foo(); - assert_eq!(v, y); -} - -pub fn main() { - let x = @22u as @Foo; - do_it_imm(x, 22u); -} diff --git a/src/test/run-pass/packed-struct-size-xc.rs b/src/test/run-pass/packed-struct-size-xc.rs index 336df24586a..94984db4df1 100644 --- a/src/test/run-pass/packed-struct-size-xc.rs +++ b/src/test/run-pass/packed-struct-size-xc.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-fast // aux-build:packed.rs diff --git a/src/test/run-pass/pub-extern-privacy.rs b/src/test/run-pass/pub-extern-privacy.rs index c5d63133633..742df0f5c6d 100644 --- a/src/test/run-pass/pub-extern-privacy.rs +++ b/src/test/run-pass/pub-extern-privacy.rs @@ -1,3 +1,13 @@ +// 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. + use std::cast::transmute; mod a { diff --git a/src/test/run-pass/raw-str.rs b/src/test/run-pass/raw-str.rs index bfe53260439..95a6d1e5941 100644 --- a/src/test/run-pass/raw-str.rs +++ b/src/test/run-pass/raw-str.rs Binary files differdiff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 6a817bf03d4..fbd58de1a7e 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -408,9 +408,9 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> { } fn visit_trait(&mut self, name: &str) -> bool { - self.align_to::<@TyVisitor>(); + self.align_to::<~TyVisitor>(); if ! self.inner().visit_trait(name) { return false; } - self.bump_past::<@TyVisitor>(); + self.bump_past::<~TyVisitor>(); true } diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 91e69028103..a0d6fc4c157 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -114,7 +114,8 @@ impl TyVisitor for MyVisitor { _disr_val: Disr, _n_fields: uint, _name: &str) -> bool { true } - fn visit_enum_variant_field(&mut self, _i: uint, _offset: uint, _inner: *TyDesc) -> bool { true } + fn visit_enum_variant_field(&mut self, _i: uint, _offset: uint, _inner: *TyDesc) + -> bool { true } fn visit_leave_enum_variant(&mut self, _variant: uint, _disr_val: Disr, @@ -128,7 +129,8 @@ impl TyVisitor for MyVisitor { fn visit_enter_fn(&mut self, _purity: uint, _proto: uint, _n_inputs: uint, _retstyle: uint) -> bool { true } fn visit_fn_input(&mut self, _i: uint, _mode: uint, _inner: *TyDesc) -> bool { true } - fn visit_fn_output(&mut self, _retstyle: uint, _variadic: bool, _inner: *TyDesc) -> bool { true } + fn visit_fn_output(&mut self, _retstyle: uint, _variadic: bool, _inner: *TyDesc) + -> bool { true } fn visit_leave_fn(&mut self, _purity: uint, _proto: uint, _n_inputs: uint, _retstyle: uint) -> bool { true } diff --git a/src/test/run-pass/self-type-param.rs b/src/test/run-pass/self-type-param.rs index d90ec51bedf..5c4e2f5ebd5 100644 --- a/src/test/run-pass/self-type-param.rs +++ b/src/test/run-pass/self-type-param.rs @@ -1,3 +1,13 @@ +// 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. + trait MyTrait { fn f(&self) -> Self; } diff --git a/src/test/run-pass/send_str_hashmap.rs b/src/test/run-pass/send_str_hashmap.rs index dc7e51c3c23..8599f9d3836 100644 --- a/src/test/run-pass/send_str_hashmap.rs +++ b/src/test/run-pass/send_str_hashmap.rs @@ -13,45 +13,44 @@ use std::cmp::{TotalEq, Ord, TotalOrd, Equiv}; use std::cmp::Equal; use std::container::{Container, Map, MutableMap}; use std::default::Default; -use std::send_str::{SendStr, SendStrOwned, SendStrStatic}; -use std::str::Str; +use std::str::{Str, SendStr, Owned, Slice}; use std::to_str::ToStr; use std::hashmap::HashMap; use std::option::Some; pub fn main() { let mut map: HashMap<SendStr, uint> = HashMap::new(); - assert!(map.insert(SendStrStatic("foo"), 42)); - assert!(!map.insert(SendStrOwned(~"foo"), 42)); - assert!(!map.insert(SendStrStatic("foo"), 42)); - assert!(!map.insert(SendStrOwned(~"foo"), 42)); + assert!(map.insert(Slice("foo"), 42)); + assert!(!map.insert(Owned(~"foo"), 42)); + assert!(!map.insert(Slice("foo"), 42)); + assert!(!map.insert(Owned(~"foo"), 42)); - assert!(!map.insert(SendStrStatic("foo"), 43)); - assert!(!map.insert(SendStrOwned(~"foo"), 44)); - assert!(!map.insert(SendStrStatic("foo"), 45)); - assert!(!map.insert(SendStrOwned(~"foo"), 46)); + assert!(!map.insert(Slice("foo"), 43)); + assert!(!map.insert(Owned(~"foo"), 44)); + assert!(!map.insert(Slice("foo"), 45)); + assert!(!map.insert(Owned(~"foo"), 46)); let v = 46; - assert_eq!(map.find(&SendStrOwned(~"foo")), Some(&v)); - assert_eq!(map.find(&SendStrStatic("foo")), Some(&v)); + assert_eq!(map.find(&Owned(~"foo")), Some(&v)); + assert_eq!(map.find(&Slice("foo")), Some(&v)); let (a, b, c, d) = (50, 51, 52, 53); - assert!(map.insert(SendStrStatic("abc"), a)); - assert!(map.insert(SendStrOwned(~"bcd"), b)); - assert!(map.insert(SendStrStatic("cde"), c)); - assert!(map.insert(SendStrOwned(~"def"), d)); + assert!(map.insert(Slice("abc"), a)); + assert!(map.insert(Owned(~"bcd"), b)); + assert!(map.insert(Slice("cde"), c)); + assert!(map.insert(Owned(~"def"), d)); - assert!(!map.insert(SendStrStatic("abc"), a)); - assert!(!map.insert(SendStrOwned(~"bcd"), b)); - assert!(!map.insert(SendStrStatic("cde"), c)); - assert!(!map.insert(SendStrOwned(~"def"), d)); + assert!(!map.insert(Slice("abc"), a)); + assert!(!map.insert(Owned(~"bcd"), b)); + assert!(!map.insert(Slice("cde"), c)); + assert!(!map.insert(Owned(~"def"), d)); - assert!(!map.insert(SendStrOwned(~"abc"), a)); - assert!(!map.insert(SendStrStatic("bcd"), b)); - assert!(!map.insert(SendStrOwned(~"cde"), c)); - assert!(!map.insert(SendStrStatic("def"), d)); + assert!(!map.insert(Owned(~"abc"), a)); + assert!(!map.insert(Slice("bcd"), b)); + assert!(!map.insert(Owned(~"cde"), c)); + assert!(!map.insert(Slice("def"), d)); assert_eq!(map.find_equiv(&("abc")), Some(&a)); assert_eq!(map.find_equiv(&("bcd")), Some(&b)); @@ -63,13 +62,13 @@ pub fn main() { assert_eq!(map.find_equiv(&(~"cde")), Some(&c)); assert_eq!(map.find_equiv(&(~"def")), Some(&d)); - assert_eq!(map.find_equiv(&SendStrStatic("abc")), Some(&a)); - assert_eq!(map.find_equiv(&SendStrStatic("bcd")), Some(&b)); - assert_eq!(map.find_equiv(&SendStrStatic("cde")), Some(&c)); - assert_eq!(map.find_equiv(&SendStrStatic("def")), Some(&d)); + assert_eq!(map.find_equiv(&Slice("abc")), Some(&a)); + assert_eq!(map.find_equiv(&Slice("bcd")), Some(&b)); + assert_eq!(map.find_equiv(&Slice("cde")), Some(&c)); + assert_eq!(map.find_equiv(&Slice("def")), Some(&d)); - assert_eq!(map.find_equiv(&SendStrOwned(~"abc")), Some(&a)); - assert_eq!(map.find_equiv(&SendStrOwned(~"bcd")), Some(&b)); - assert_eq!(map.find_equiv(&SendStrOwned(~"cde")), Some(&c)); - assert_eq!(map.find_equiv(&SendStrOwned(~"def")), Some(&d)); + assert_eq!(map.find_equiv(&Owned(~"abc")), Some(&a)); + assert_eq!(map.find_equiv(&Owned(~"bcd")), Some(&b)); + assert_eq!(map.find_equiv(&Owned(~"cde")), Some(&c)); + assert_eq!(map.find_equiv(&Owned(~"def")), Some(&d)); } diff --git a/src/test/run-pass/send_str_treemap.rs b/src/test/run-pass/send_str_treemap.rs index 23ad0ac3091..1b7d7bf0b4b 100644 --- a/src/test/run-pass/send_str_treemap.rs +++ b/src/test/run-pass/send_str_treemap.rs @@ -8,64 +8,63 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern mod extra; +extern mod collections; use std::clone::{Clone, DeepClone}; use std::cmp::{TotalEq, Ord, TotalOrd, Equiv}; use std::cmp::Equal; use std::container::{Container, Map, MutableMap}; use std::default::Default; -use std::send_str::{SendStr, SendStrOwned, SendStrStatic}; -use std::str::Str; +use std::str::{Str, SendStr, Owned, Slice}; use std::to_str::ToStr; -use self::extra::treemap::TreeMap; +use self::collections::TreeMap; use std::option::Some; pub fn main() { let mut map: TreeMap<SendStr, uint> = TreeMap::new(); - assert!(map.insert(SendStrStatic("foo"), 42)); - assert!(!map.insert(SendStrOwned(~"foo"), 42)); - assert!(!map.insert(SendStrStatic("foo"), 42)); - assert!(!map.insert(SendStrOwned(~"foo"), 42)); + assert!(map.insert(Slice("foo"), 42)); + assert!(!map.insert(Owned(~"foo"), 42)); + assert!(!map.insert(Slice("foo"), 42)); + assert!(!map.insert(Owned(~"foo"), 42)); - assert!(!map.insert(SendStrStatic("foo"), 43)); - assert!(!map.insert(SendStrOwned(~"foo"), 44)); - assert!(!map.insert(SendStrStatic("foo"), 45)); - assert!(!map.insert(SendStrOwned(~"foo"), 46)); + assert!(!map.insert(Slice("foo"), 43)); + assert!(!map.insert(Owned(~"foo"), 44)); + assert!(!map.insert(Slice("foo"), 45)); + assert!(!map.insert(Owned(~"foo"), 46)); let v = 46; - assert_eq!(map.find(&SendStrOwned(~"foo")), Some(&v)); - assert_eq!(map.find(&SendStrStatic("foo")), Some(&v)); + assert_eq!(map.find(&Owned(~"foo")), Some(&v)); + assert_eq!(map.find(&Slice("foo")), Some(&v)); let (a, b, c, d) = (50, 51, 52, 53); - assert!(map.insert(SendStrStatic("abc"), a)); - assert!(map.insert(SendStrOwned(~"bcd"), b)); - assert!(map.insert(SendStrStatic("cde"), c)); - assert!(map.insert(SendStrOwned(~"def"), d)); + assert!(map.insert(Slice("abc"), a)); + assert!(map.insert(Owned(~"bcd"), b)); + assert!(map.insert(Slice("cde"), c)); + assert!(map.insert(Owned(~"def"), d)); - assert!(!map.insert(SendStrStatic("abc"), a)); - assert!(!map.insert(SendStrOwned(~"bcd"), b)); - assert!(!map.insert(SendStrStatic("cde"), c)); - assert!(!map.insert(SendStrOwned(~"def"), d)); + assert!(!map.insert(Slice("abc"), a)); + assert!(!map.insert(Owned(~"bcd"), b)); + assert!(!map.insert(Slice("cde"), c)); + assert!(!map.insert(Owned(~"def"), d)); - assert!(!map.insert(SendStrOwned(~"abc"), a)); - assert!(!map.insert(SendStrStatic("bcd"), b)); - assert!(!map.insert(SendStrOwned(~"cde"), c)); - assert!(!map.insert(SendStrStatic("def"), d)); + assert!(!map.insert(Owned(~"abc"), a)); + assert!(!map.insert(Slice("bcd"), b)); + assert!(!map.insert(Owned(~"cde"), c)); + assert!(!map.insert(Slice("def"), d)); - assert_eq!(map.find(&SendStrStatic("abc")), Some(&a)); - assert_eq!(map.find(&SendStrStatic("bcd")), Some(&b)); - assert_eq!(map.find(&SendStrStatic("cde")), Some(&c)); - assert_eq!(map.find(&SendStrStatic("def")), Some(&d)); + assert_eq!(map.find(&Slice("abc")), Some(&a)); + assert_eq!(map.find(&Slice("bcd")), Some(&b)); + assert_eq!(map.find(&Slice("cde")), Some(&c)); + assert_eq!(map.find(&Slice("def")), Some(&d)); - assert_eq!(map.find(&SendStrOwned(~"abc")), Some(&a)); - assert_eq!(map.find(&SendStrOwned(~"bcd")), Some(&b)); - assert_eq!(map.find(&SendStrOwned(~"cde")), Some(&c)); - assert_eq!(map.find(&SendStrOwned(~"def")), Some(&d)); + assert_eq!(map.find(&Owned(~"abc")), Some(&a)); + assert_eq!(map.find(&Owned(~"bcd")), Some(&b)); + assert_eq!(map.find(&Owned(~"cde")), Some(&c)); + assert_eq!(map.find(&Owned(~"def")), Some(&d)); - assert!(map.pop(&SendStrStatic("foo")).is_some()); + assert!(map.pop(&Slice("foo")).is_some()); assert_eq!(map.move_iter().map(|(k, v)| k.to_str() + v.to_str()) .to_owned_vec() .concat(), diff --git a/src/test/run-pass/signal-exit-status.rs b/src/test/run-pass/signal-exit-status.rs index 0e8ca4d9942..f4686ee1ba7 100644 --- a/src/test/run-pass/signal-exit-status.rs +++ b/src/test/run-pass/signal-exit-status.rs @@ -1,3 +1,13 @@ +// 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. + // copyright 2013 the rust project developers. see the copyright // file at the top-level directory of this distribution and at // http://rust-lang.org/copyright. diff --git a/src/test/run-pass/simd-type.rs b/src/test/run-pass/simd-type.rs index 029478b4d59..0893f943995 100644 --- a/src/test/run-pass/simd-type.rs +++ b/src/test/run-pass/simd-type.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-fast feature doesn't work #[feature(simd)]; diff --git a/src/test/run-pass/smallest-hello-world.rs b/src/test/run-pass/smallest-hello-world.rs index 11cef9d480a..59526ae6e01 100644 --- a/src/test/run-pass/smallest-hello-world.rs +++ b/src/test/run-pass/smallest-hello-world.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - FIXME(#8538) some kind of problem linking induced by extern "C" fns that I do not understand +// xfail-test - FIXME(#8538) some kind of problem linking induced by extern "C" fns // xfail-fast - check-fast doesn't like this // Smallest hello world with no runtime diff --git a/src/test/run-pass/static-assert.rs b/src/test/run-pass/static-assert.rs index 93c8d67c9c0..f8fd81b9365 100644 --- a/src/test/run-pass/static-assert.rs +++ b/src/test/run-pass/static-assert.rs @@ -1,3 +1,13 @@ +// 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. + #[static_assert] static b: bool = true; diff --git a/src/test/run-pass/static-fn-trait-xc.rs b/src/test/run-pass/static-fn-trait-xc.rs index ef40d2789e4..0cafa632130 100644 --- a/src/test/run-pass/static-fn-trait-xc.rs +++ b/src/test/run-pass/static-fn-trait-xc.rs @@ -1,3 +1,13 @@ +// 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. + // aux-build:static_fn_trait_xc_aux.rs // xfail-fast diff --git a/src/test/run-pass/static-methods-in-traits2.rs b/src/test/run-pass/static-methods-in-traits2.rs index a73978ce73c..d0448de2c49 100644 --- a/src/test/run-pass/static-methods-in-traits2.rs +++ b/src/test/run-pass/static-methods-in-traits2.rs @@ -1,3 +1,13 @@ +// 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. + pub trait Number: NumConv { fn from<T:Number>(n: T) -> Self; } diff --git a/src/test/run-pass/struct-field-assignability.rs b/src/test/run-pass/struct-field-assignability.rs index da00e1595de..e15a4f419ae 100644 --- a/src/test/run-pass/struct-field-assignability.rs +++ b/src/test/run-pass/struct-field-assignability.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(managed_boxes)]; struct Foo<'a> { diff --git a/src/test/run-pass/struct-new-as-field-name.rs b/src/test/run-pass/struct-new-as-field-name.rs index fb93c560e0d..21eb0ae99b4 100644 --- a/src/test/run-pass/struct-new-as-field-name.rs +++ b/src/test/run-pass/struct-new-as-field-name.rs @@ -1,3 +1,13 @@ +// 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. + struct Foo { new: int, } diff --git a/src/test/run-pass/super.rs b/src/test/run-pass/super.rs index b5eb6e85045..95aeff425e8 100644 --- a/src/test/run-pass/super.rs +++ b/src/test/run-pass/super.rs @@ -1,3 +1,13 @@ +// 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. + pub mod a { pub fn f() {} pub mod b { diff --git a/src/test/run-pass/trait-coercion-generic.rs b/src/test/run-pass/trait-coercion-generic.rs index f6ccf987fcb..2d8a42005df 100644 --- a/src/test/run-pass/trait-coercion-generic.rs +++ b/src/test/run-pass/trait-coercion-generic.rs @@ -8,10 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - -use std::io::println; - trait Trait<T> { fn f(&self, x: T); } @@ -27,18 +23,11 @@ impl Trait<&'static str> for Struct { } } -fn f(x: @Trait<&'static str>) { - x.f("Sue"); -} - pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: @Trait<&'static str> = @a; - b.f("Fred"); - let c: ~Trait<&'static str> = ~a; - c.f("Mary"); - let d: &Trait<&'static str> = &a; - d.f("Joe"); - f(@a); + let b: ~Trait<&'static str> = ~a; + b.f("Mary"); + let c: &Trait<&'static str> = &a; + c.f("Joe"); } diff --git a/src/test/run-pass/trait-coercion.rs b/src/test/run-pass/trait-coercion.rs index 365831eda83..ea6d59a9068 100644 --- a/src/test/run-pass/trait-coercion.rs +++ b/src/test/run-pass/trait-coercion.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - use std::io; trait Trait { @@ -27,23 +25,16 @@ impl Trait for Struct { } } -fn f(x: @Trait) { - x.f(); -} - fn foo(mut a: ~Writer) { a.write(bytes!("Hello\n")); } pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: @Trait = @a; + let b: ~Trait = ~a; b.f(); - let c: ~Trait = ~a; + let c: &Trait = &a; c.f(); - let d: &Trait = &a; - d.f(); - f(@a); let out = io::stdout(); foo(~out); diff --git a/src/test/run-pass/trait-default-method-xc-2.rs b/src/test/run-pass/trait-default-method-xc-2.rs index 58066adc4bd..6e722a8d5da 100644 --- a/src/test/run-pass/trait-default-method-xc-2.rs +++ b/src/test/run-pass/trait-default-method-xc-2.rs @@ -1,3 +1,13 @@ +// 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. + // xfail-fast // aux-build:trait_default_method_xc_aux.rs // aux-build:trait_default_method_xc_aux_2.rs diff --git a/src/test/run-pass/trait-default-method-xc.rs b/src/test/run-pass/trait-default-method-xc.rs index 3323b3c952a..30309fb14b2 100644 --- a/src/test/run-pass/trait-default-method-xc.rs +++ b/src/test/run-pass/trait-default-method-xc.rs @@ -1,9 +1,16 @@ -#[feature(managed_boxes)]; +// 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. // xfail-fast // aux-build:trait_default_method_xc_aux.rs - extern mod aux = "trait_default_method_xc_aux"; use aux::{A, TestEquality, Something}; use aux::B; @@ -66,7 +73,7 @@ pub fn main () { assert_eq!(g(0i, 3.14, 1), (3.14, 1)); assert_eq!(g(false, 3.14, 1), (3.14, 1)); - let obj = @0i as @A; + let obj = ~0i as ~A; assert_eq!(obj.h(), 11); diff --git a/src/test/run-pass/trait-inheritance-self-in-supertype.rs b/src/test/run-pass/trait-inheritance-self-in-supertype.rs index fac29e68525..63ac921e2a5 100644 --- a/src/test/run-pass/trait-inheritance-self-in-supertype.rs +++ b/src/test/run-pass/trait-inheritance-self-in-supertype.rs @@ -1,3 +1,13 @@ +// 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 for issue #4183: use of Self in supertraits. use std::num; diff --git a/src/test/run-pass/trait-inheritance-self.rs b/src/test/run-pass/trait-inheritance-self.rs index c1683082ae7..07b0929968d 100644 --- a/src/test/run-pass/trait-inheritance-self.rs +++ b/src/test/run-pass/trait-inheritance-self.rs @@ -1,3 +1,13 @@ +// 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. + trait Foo<T> { fn f(&self, x: &T); } diff --git a/src/test/run-pass/trait-object-generics.rs b/src/test/run-pass/trait-object-generics.rs index fdae975a637..e2422a1dcf5 100644 --- a/src/test/run-pass/trait-object-generics.rs +++ b/src/test/run-pass/trait-object-generics.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[feature(managed_boxes)]; - // test for #8664 pub trait Trait2<A> { @@ -19,7 +17,8 @@ pub trait Trait2<A> { pub struct Impl<A1, A2, A3> { /* * With A2 we get the ICE: - * task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1', /home/tortue/rust_compiler_newest/src/librustc/middle/subst.rs:58 + * task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1', + * src/librustc/middle/subst.rs:58 */ t: ~Trait2<A2> } @@ -42,7 +41,7 @@ impl<V> Trait<u8,V> for () { fn method(&self, _x: Type<(u8,V)>) -> int { 0 } } -pub fn main () { - let a = @() as @Trait<u8, u8>; +pub fn main() { + let a = ~() as ~Trait<u8, u8>; assert_eq!(a.method(Constant), 0); } diff --git a/src/test/run-pass/typeck-macro-interaction-issue-8852.rs b/src/test/run-pass/typeck-macro-interaction-issue-8852.rs index a4512e99ce0..be9e5fcbdf3 100644 --- a/src/test/run-pass/typeck-macro-interaction-issue-8852.rs +++ b/src/test/run-pass/typeck-macro-interaction-issue-8852.rs @@ -1,3 +1,13 @@ +// 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. + #[feature(macro_rules)]; enum T { diff --git a/src/test/run-pass/unnamed_argument_mode.rs b/src/test/run-pass/unnamed_argument_mode.rs index 948824834df..3a5e0dd8ae3 100644 --- a/src/test/run-pass/unnamed_argument_mode.rs +++ b/src/test/run-pass/unnamed_argument_mode.rs @@ -1,3 +1,13 @@ +// 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. + fn good(_a: &int) { } diff --git a/src/test/run-pass/vec-matching-autoslice.rs b/src/test/run-pass/vec-matching-autoslice.rs index 68d2ce36463..0ca210af037 100644 --- a/src/test/run-pass/vec-matching-autoslice.rs +++ b/src/test/run-pass/vec-matching-autoslice.rs @@ -1,3 +1,13 @@ +// 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. + pub fn main() { let x = ~[1, 2, 3]; match x { diff --git a/src/test/run-pass/vec-matching-fixed.rs b/src/test/run-pass/vec-matching-fixed.rs index ed88dc3008a..17633f12ce5 100644 --- a/src/test/run-pass/vec-matching-fixed.rs +++ b/src/test/run-pass/vec-matching-fixed.rs @@ -1,3 +1,13 @@ +// 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. + fn a() { let x = [1, 2, 3]; match x { diff --git a/src/test/run-pass/vec-matching-fold.rs b/src/test/run-pass/vec-matching-fold.rs index 75c48da8d81..5ba42b68f27 100644 --- a/src/test/run-pass/vec-matching-fold.rs +++ b/src/test/run-pass/vec-matching-fold.rs @@ -1,3 +1,13 @@ +// 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. + fn foldl<T,U:Clone>(values: &[T], initial: U, function: |partial: U, element: &T| -> U) diff --git a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs index d90abe31b27..fbdcc1ab69c 100644 --- a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs +++ b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs @@ -1,3 +1,13 @@ +// 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. + pub fn main() { let x = &[1, 2, 3, 4, 5]; if !x.is_empty() { diff --git a/src/test/run-pass/vec-matching.rs b/src/test/run-pass/vec-matching.rs index 16c68afa47b..ced3baf3c3c 100644 --- a/src/test/run-pass/vec-matching.rs +++ b/src/test/run-pass/vec-matching.rs @@ -1,3 +1,13 @@ +// 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. + fn a() { let x = ~[1]; match x { diff --git a/src/test/run-pass/vec-tail-matching.rs b/src/test/run-pass/vec-tail-matching.rs index 1ab9e17523d..d42b2959dba 100644 --- a/src/test/run-pass/vec-tail-matching.rs +++ b/src/test/run-pass/vec-tail-matching.rs @@ -1,3 +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. + + struct Foo { string: ~str } diff --git a/src/test/run-pass/while-with-break.rs b/src/test/run-pass/while-with-break.rs index 61a13a42fa0..57bc3bda963 100644 --- a/src/test/run-pass/while-with-break.rs +++ b/src/test/run-pass/while-with-break.rs @@ -1,4 +1,12 @@ - +// 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. pub fn main() { diff --git a/src/test/run-pass/xc_conditions_client.rs b/src/test/run-pass/xc_conditions_client.rs deleted file mode 100644 index 99df4b771c5..00000000000 --- a/src/test/run-pass/xc_conditions_client.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 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. - -// xfail-fast -// aux-build:xc_conditions.rs - -extern mod xc_conditions; -use xc_conditions::oops; -use xc_conditions::trouble; - -// Tests of cross-crate conditions; the condition is -// defined in lib, and we test various combinations -// of `trap` and `raise` in the client or the lib where -// the condition was defined. Also in test #4 we use -// more complex features (generics, traits) in -// combination with the condition. -// -// trap raise -// ------------ -// xc_conditions : client lib -// xc_conditions_2: client client -// xc_conditions_3: lib client -// xc_conditions_4: client client (with traits) -// -// the trap=lib, raise=lib case isn't tested since -// there's no cross-crate-ness to test in that case. - -pub fn main() { - oops::cond.trap(|_i| 12345).inside(|| { - let x = trouble(); - assert_eq!(x,12345); - }) -} diff --git a/src/test/run-pass/xc_conditions_client_3.rs b/src/test/run-pass/xc_conditions_client_3.rs deleted file mode 100644 index 7d16572c139..00000000000 --- a/src/test/run-pass/xc_conditions_client_3.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012 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. - -// xfail-fast -// aux-build:xc_conditions_3.rs - -extern mod xc_conditions_3; -use xcc = xc_conditions_3; - -pub fn main() { - assert_eq!(xcc::guard(a, 1), 40); -} - -pub fn a() -> int { - assert_eq!(xcc::oops::cond.raise(7), 7); - xcc::guard(b, 2) -} - -pub fn b() -> int { - assert_eq!(xcc::oops::cond.raise(8), 16); - xcc::guard(c, 3) -} - -pub fn c() -> int { - assert_eq!(xcc::oops::cond.raise(9), 27); - xcc::guard(d, 4) -} - -pub fn d() -> int { - xcc::oops::cond.raise(10) -} diff --git a/src/test/run-pass/xc_conditions_client_4.rs b/src/test/run-pass/xc_conditions_client_4.rs deleted file mode 100644 index e8eea00e492..00000000000 --- a/src/test/run-pass/xc_conditions_client_4.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012 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. - -// xfail-fast -// aux-build:xc_conditions_4.rs - -extern mod xc_conditions_4; -use xcc = xc_conditions_4; - -struct SThunk { - x: int -} - -impl xcc::Thunk<xcc::Color> for SThunk { - fn call(self) -> xcc::Color { - xcc::oops::cond.raise((self.x, 1.23, ~"oh no")) - } -} - -pub fn main() { - xcc::oops::cond.trap(|_| xcc::Red).inside(|| { - let t = SThunk { x : 10 }; - assert_eq!(xcc::callback(t), xcc::Red) - }) -} diff --git a/src/test/run-pass/xcrate-static-addresses.rs b/src/test/run-pass/xcrate-static-addresses.rs index 2ea8ab864e1..8fdeba84fb7 100644 --- a/src/test/run-pass/xcrate-static-addresses.rs +++ b/src/test/run-pass/xcrate-static-addresses.rs @@ -18,11 +18,4 @@ use other = xcrate_static_addresses; pub fn main() { other::verify_same(&other::global); other::verify_same2(other::global2); - - // Previously this fail'd because there were two addresses that were being - // used when declaring constants. - other::test::cond.trap(|_| { - }).inside(|| { - other::raise(); - }) } |
