`RefCell::get` can be a bit surprising, because it actually clones the wrapped value. This removes `RefCell::get` and replaces all the users with `RefCell::borrow()` when it can, and `RefCell::borrow().clone()` when it can't. It removes `RefCell::set` for consistency. This closes #13182.
It also fixes an infinite loop in a test when debugging is on.
To build from the [tarball] do:
- $ curl -O http://static.rust-lang.org/dist/rust-0.10.tar.gz
- $ tar -xzf rust-0.10.tar.gz
- $ cd rust-0.10
+ $ curl -O http://static.rust-lang.org/dist/rust-nightly.tar.gz
+ $ tar -xzf rust-nightly.tar.gz
+ $ cd rust-nightly
Or to build from the [repo] do:
4. Enjoy!
[repo]: https://github.com/mozilla/rust
-[tarball]: http://static.rust-lang.org/dist/rust-0.10.tar.gz
-[tutorial]: http://static.rust-lang.org/doc/0.10/tutorial.html
+[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz
+[tutorial]: http://static.rust-lang.org/doc/nightly/tutorial.html
## Notes
-.TH RUSTC "1" "March 2014" "rustc 0.10" "User Commands"
+.TH RUSTC "1" "March 2014" "rustc 0.11-pre" "User Commands"
.SH NAME
rustc \- rust compiler
.SH SYNOPSIS
-.TH RUSTDOC "1" "March 2014" "rustdoc 0.10" "User Commands"
+.TH RUSTDOC "1" "March 2014" "rustdoc 0.11-pre" "User Commands"
.SH NAME
rustdoc \- generate documentation from Rust source code
.SH SYNOPSIS
$(2) += doc/$(1)/index.html
doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1))
@$$(call E, rustdoc $$@)
- $$(Q)$$(RUSTDOC) --cfg stage2 $$<
+ $$(Q)$$(RUSTDOC) --cfg dox --cfg stage2 $$<
endef
$(foreach crate,$(DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),DOC_TARGETS)))
######################################################################
# The version number
-CFG_RELEASE_NUM=0.10
-CFG_RELEASE_LABEL=
+CFG_RELEASE_NUM=0.11
+CFG_RELEASE_LABEL=-pre
ifndef CFG_ENABLE_NIGHTLY
# This is the normal version string
ifeq ($(2),$$(CFG_BUILD))
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): $$(DOCTESTDEP_$(1)_$(2)_$(3)_$(4))
@$$(call E, run doc-$(4) [$(2)])
- $$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test $$< --test-args "$$(TESTARGS)" && touch $$@
+ $$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --cfg dox --test $$< --test-args "$$(TESTARGS)" && touch $$@
else
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)):
touch $$@
use std::io::process::{ProcessExit, Process, ProcessConfig, ProcessOutput};
#[cfg(target_os = "win32")]
-fn target_env(lib_path: &str, prog: &str) -> Vec<(~str,~str)> {
-
- let mut env = os::env();
+fn target_env(lib_path: &str, prog: &str) -> Vec<(~str, ~str)> {
+ let env = os::env();
// Make sure we include the aux directory in the path
assert!(prog.ends_with(".exe"));
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ".libaux";
- env = env.map(|pair| {
- let (k,v) = (*pair).clone();
- if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
- else { (k,v) }
- });
+ let mut new_env: Vec<_> = env.move_iter().map(|(k, v)| {
+ let new_v = if "PATH" == k {
+ format!("{};{};{}", v, lib_path, aux_path)
+ } else {
+ v
+ };
+ (k, new_v)
+ }).collect();
if prog.ends_with("rustc.exe") {
- env.push((~"RUST_THREADS", ~"1"));
+ new_env.push((~"RUST_THREADS", ~"1"));
}
- return env;
+ return new_env;
}
#[cfg(target_os = "linux")]
c
}
} ).collect();
- str::from_chars( c )
+ str::from_chars(c.as_slice())
}
#[cfg(target_os = "win32")]
~~~~
po4a --copyright-holder="The Rust Project Developers" \
--package-name="Rust" \
- --package-version="0.10" \
+ --package-version="0.11-pre" \
-M UTF-8 -L UTF-8 \
src/doc/po4a.conf
~~~~
-(the version number must be changed if it is not 0.10 now.)
+(the version number must be changed if it is not 0.11-pre now.)
Now you can translate documents with .po files, commonly used with gettext. If
you are not familiar with gettext-based translation, please read the online
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#: src/doc/complement-cheatsheet.md:8
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use [`ToStr`](http://static.rust-lang.org/doc/master/std/to_str/trait.ToStr."
"html)."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:13
#: src/doc/complement-cheatsheet.md:17
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use [`FromStr`](http://static.rust-lang.org/doc/master/std/from_str/trait."
"FromStr.html), and its helper function, [`from_str`](http://static.rust-lang."
"org/doc/master/std/from_str/fn.from_str.html)."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:22
#: src/doc/complement-cheatsheet.md:26
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use [`ToStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait."
"ToStrRadix.html)."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:29
#: src/doc/complement-cheatsheet.md:37
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use [`FromStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait."
"FromStrRadix.html), and its helper function, [`from_str_radix`](http://"
"static.rust-lang.org/doc/master/std/num/fn.from_str_radix.html)."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:40
#: src/doc/complement-cheatsheet.md:50
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use [`File::open`](http://static.rust-lang.org/doc/master/std/io/fs/struct."
"File.html#method.open) to create a [`File`](http://static.rust-lang.org/doc/"
"master/std/io/fs/struct.File.html) struct, which implements the [`Reader`]"
"(http://static.rust-lang.org/doc/master/std/io/trait.Reader.html) trait."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:54
#: src/doc/complement-cheatsheet.md:63
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use the [`lines`](http://static.rust-lang.org/doc/master/std/io/trait.Buffer."
"html#method.lines) method on a [`BufferedReader`](http://static.rust-lang."
"org/doc/master/std/io/buffered/struct.BufferedReader.html)."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:67
#: src/doc/complement-cheatsheet.md:81
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use the [`find_str`](http://static.rust-lang.org/doc/master/std/str/trait."
"StrSlice.html#tymethod.find_str) method."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:88 src/doc/guide-container.md:4
#: src/doc/complement-cheatsheet.md:92
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"The [`Container`](http://static.rust-lang.org/doc/master/std/container/trait."
"Container.html) trait provides the `len` method."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:104
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use the [`iter`](http://static.rust-lang.org/doc/master/std/vec/trait."
"ImmutableVector.html#tymethod.iter) method."
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:113
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"(See also [`mut_iter`](http://static.rust-lang.org/doc/master/std/vec/trait."
"MutableVector.html#tymethod.mut_iter) which yields `&mut int` and "
"OwnedVector.html#tymethod.move_iter) which yields `int` while consuming the "
"`values` vector.)"
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/complement-cheatsheet.md:115 src/doc/rust.md:3019
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-02-03 08:13+0900\n"
"Last-Translator: Automatically generated\n"
#: src/doc/complement-usage-faq.md:18
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid "[1]:http://doc.rust-lang.org/doc/master/rust.html#logging-system"
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-02-03 08:13+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-14 21:02+0900\n"
"Last-Translator: Automatically generated\n"
#
msgid ""
msgstr ""
-"Project-Id-Version: Rust 0.10\n"
+"Project-Id-Version: Rust 0.11-pre\n"
"POT-Creation-Date: 2014-02-03 08:13+0900\n"
"PO-Revision-Date: 2014-01-13 12:01+0900\n"
"Last-Translator: Automatically generated\n"
#: src/doc/tutorial.md:112
#, fuzzy
#| msgid ""
-#| "~~~~ {.notrust} $ curl -O http://static.rust-lang.org/dist/rust-0.7.tar."
-#| "gz $ tar -xzf rust-0.7.tar.gz $ cd rust-0.7 $ ./configure $ make && make "
+#| "~~~~ {.notrust} $ curl -O http://static.rust-lang.org/dist/rust-nightly.tar."
+#| "gz $ tar -xzf rust-nightly.tar.gz $ cd rust-nightly $ ./configure $ make && make "
#| "install ~~~~"
msgid ""
-"~~~~ {.notrust} $ curl -O http://static.rust-lang.org/dist/rust-0.10.tar.gz $ "
-"tar -xzf rust-0.10.tar.gz $ cd rust-0.10 $ ./configure $ make && make install "
+"~~~~ {.notrust} $ curl -O http://static.rust-lang.org/dist/rust-nightly.tar.gz $ "
+"tar -xzf rust-nightly.tar.gz $ cd rust-nightly $ ./configure $ make && make install "
"~~~~"
msgstr ""
"~~~~ {.notrust}\n"
-"$ curl -O http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"$ tar -xzf rust-0.7.tar.gz $ cd rust-0.7 $ ./configure\n"
+"$ curl -O http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"$ tar -xzf rust-nightly.tar.gz $ cd rust-nightly $ ./configure\n"
"$ make && make install\n"
"~~~~"
#: src/doc/tutorial.md:125
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.10.tar.gz [win-exe]: "
-"http://static.rust-lang.org/dist/rust-0.10-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+"http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/tutorial.md:127
#: src/doc/tutorial.md:385
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"[transmute]: http://static.rust-lang.org/doc/master/std/cast/fn.transmute."
"html"
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/tutorial.md:387
#: src/doc/tutorial.md:412
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"[pf]: http://en.cppreference.com/w/cpp/io/c/fprintf [fmt]: http://static."
"rust-lang.org/doc/master/std/fmt/index.html"
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/tutorial.md:416
#: src/doc/tutorial.md:944
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"[gc]: http://static.rust-lang.org/doc/master/std/gc/struct.Gc.html [rc]: "
"http://static.rust-lang.org/doc/master/std/rc/struct.Rc.html"
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/tutorial.md:946
#: src/doc/tutorial.md:1461
#, fuzzy
#| msgid ""
-#| "[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz [win-exe]: "
-#| "http://static.rust-lang.org/dist/rust-0.7-install.exe"
+#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
+#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"[refcell]: http://static.rust-lang.org/doc/master/std/cell/struct.RefCell."
"html"
msgstr ""
-"[tarball]: http://static.rust-lang.org/dist/rust-0.7.tar.gz\n"
-"[win-exe]: http://static.rust-lang.org/dist/rust-0.7-install.exe"
+"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
+"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
#. type: Plain text
#: src/doc/tutorial.md:1463
Attributes on the anonymous crate module define important metadata that influences
the behavior of the compiler.
-~~~~
-// Package ID
-#[ crate_id = "projx#2.5" ];
+~~~~ {.rust}
+// Crate ID
+#![crate_id = "projx#2.5"]
// Additional metadata attributes
-#[ desc = "Project X" ];
-#[ license = "BSD" ];
-#[ comment = "This is a comment on Project X." ];
+#![desc = "Project X"]
+#![license = "BSD"]
+#![comment = "This is a comment on Project X."]
// Specify the output type
-#[ crate_type = "lib" ];
+#![crate_type = "lib"]
// Turn on a warning
-#[ warn(non_camel_case_types) ];
+#![warn(non_camel_case_types)]
~~~~
A crate that contains a `main` function can be compiled to an executable.
extern crate ruststd = "std"; // linking to 'std' under another name
-extern crate foo = "some/where/rust-foo#foo:1.0"; // a full package ID for external tools
+extern crate foo = "some/where/rust-foo#foo:1.0"; // a full crate ID for external tools
~~~~
##### Use declarations
An example of what will and will not work for `use` items:
~~~~
-# #[allow(unused_imports)];
+# #![allow(unused_imports)]
use foo::native::start; // good: foo is at the root of the crate
use foo::baz::foobaz; // good: foo is at the root of the crate
extern { }
~~~~
-The type of a function
-declared in an extern block
-is `extern "abi" fn(A1, ..., An) -> R`,
-where `A1...An` are the declared types of its arguments
-and `R` is the decalred return type.
+The type of a function declared in an extern block is `extern "abi" fn(A1,
+..., An) -> R`, where `A1...An` are the declared types of its arguments and
+`R` is the declared return type.
## Visibility and Privacy
## Attributes
~~~~ {.notrust .ebnf .gram}
-attribute : '#' '[' attr_list ']' ;
+attribute : '#' '!' ? '[' attr_list ']' ;
attr_list : attr [ ',' attr_list ]* ;
attr : ident [ '=' literal
| '(' attr_list ')' ] ? ;
~~~~
Static entities in Rust -- crates, modules and items -- may have _attributes_
-applied to them. ^[Attributes in Rust are modeled on Attributes in ECMA-335,
-C#]
-An attribute is a general, free-form metadatum that is interpreted according to name, convention, and language and compiler version.
-Attributes may appear as any of
+applied to them. Attributes in Rust are modeled on Attributes in ECMA-335,
+with the syntax coming from ECMA-334 (C#). An attribute is a general,
+free-form metadatum that is interpreted according to name, convention, and
+language and compiler version. Attributes may appear as any of:
* A single identifier, the attribute name
-* An identifier followed by the equals sign '=' and a literal, providing a key/value pair
+* An identifier followed by the equals sign '=' and a literal, providing a
+ key/value pair
* An identifier followed by a parenthesized list of sub-attribute arguments
-Attributes terminated by a semi-colon apply to the entity that the attribute is declared
-within. Attributes that are not terminated by a semi-colon apply to the next entity.
+Attributes with a bang ("!") after the hash ("#") apply to the item that the
+attribute is declared within. Attributes that do not have a bang after the
+hash apply to the item that follows the attribute.
An example of attributes:
-~~~~ {.ignore}
+~~~~ {.rust}
// General metadata applied to the enclosing module or crate.
-#[license = "BSD"];
+#![license = "BSD"]
// A function marked as a unit test
#[test]
fn test_foo() {
- ...
+ /* ... */
}
// A conditionally-compiled module
#[cfg(target_os="linux")]
mod bar {
- ...
+ /* ... */
}
// A lint attribute used to suppress a warning/error
#[allow(non_camel_case_types)]
-pub type int8_t = i8;
-~~~~
-
-> **Note:** In future versions of Rust, user-provided extensions to the compiler
-> will be able to interpret attributes. When this facility is provided, the
-> compiler will distinguish between language-reserved and user-available
-> attributes.
-
-At present, only the Rust compiler interprets attributes, so all attribute names
-are effectively reserved. Some significant attributes include:
-
-* The `doc` attribute, for documenting code in-place.
-* The `cfg` attribute, for conditional-compilation by build-configuration (see
- [Conditional compilation](#conditional-compilation)).
-* The `crate_id` attribute, for describing the package ID of a crate.
-* The `lang` attribute, for custom definitions of traits and functions that are
- known to the Rust compiler (see [Language items](#language-items)).
-* The `link` attribute, for describing linkage metadata for a extern blocks.
-* The `test` attribute, for marking functions as unit tests.
-* The `allow`, `warn`, `forbid`, and `deny` attributes, for
- controlling lint checks (see [Lint check attributes](#lint-check-attributes)).
-* The `deriving` attribute, for automatically generating implementations of
- certain traits.
-* The `inline` attribute, for expanding functions at caller location (see
- [Inline attributes](#inline-attributes)).
-* The `static_assert` attribute, for asserting that a static bool is true at
- compiletime.
-* The `thread_local` attribute, for defining a `static mut` as a thread-local.
- Note that this is only a low-level building block, and is not local to a
- *task*, nor does it provide safety.
-
-Other attributes may be added or removed during development of the language.
+type int8_t = i8;
+~~~~
+
+> **Note:** At some point in the future, the compiler will distinguish between
+> language-reserved and user-available attributes. Until then, there is
+> effectively no difference between an attribute handled by a loadable syntax
+> extension and the compiler.
+
+### Crate-only attributes
+
+- `crate_id` - specify the this crate's crate ID.
+- `crate_type` - see [linkage](#linkage).
+- `feature` - see [compiler features](#compiler-features).
+- `no_main` - disable emitting the `main` symbol. Useful when some other
+ object being linked to defines `main`.
+- `no_start` - disable linking to the `native` crate, which specifies the
+ "start" language item.
+- `no_std` - disable linking to the `std` crate.
+
+### Module-only attributes
+
+- `macro_escape` - macros defined in this module will be visible in the
+ module's parent, after this module has been included.
+- `no_implicit_prelude` - disable injecting `use std::prelude::*` in this
+ module.
+- `path` - specifies the file to load the module from. `#[path="foo.rs"] mod
+ bar;` is equivalent to `mod bar { /* contents of foo.rs */ }`. The path is
+ taken relative to the directory that the current module is in.
+
+### Function-only attributes
+
+- `macro_registrar` - when using loadable syntax extensions, mark this
+ function as the registration point for the current crate's syntax
+ extensions.
+- `main` - indicates that this function should be passed to the entry point,
+ rather than the function in the crate root named `main`.
+- `start` - indicates that this function should be used as the entry point,
+ overriding the "start" language item. See the "start" [language
+ item](#language-items) for more details.
+
+### Static-only attributes
+
+- `address_insignificant` - references to this static may alias with
+ references to other statics, potentially of unrelated type.
+- `thread_local` - on a `static mut`, this signals that the value of this
+ static may change depending on the current thread. The exact consequences of
+ this are implementation-defined.
+
+### FFI attributes
+
+On an `extern` block, the following attributes are interpreted:
+
+- `link_args` - specify arguments to the linker, rather than just the library
+ name and type. This is feature gated and the exact behavior is
+ implementation-defined (due to variety of linker invocation syntax).
+- `link` - indicate that a native library should be linked to for the
+ declarations in this block to be linked correctly. See [external
+ blocks](#external-blocks)
+
+On declarations inside an `extern` block, the following attributes are
+interpreted:
+
+- `link_name` - the name of the symbol that this function or static should be
+ imported as.
+- `linkage` - on a static, this specifies the [linkage
+ type](http://llvm.org/docs/LangRef.html#linkage-types).
+
+### Miscellaneous attributes
+
+- `link_section` - on statics and functions, this specifies the section of the
+ object file that this item's contents will be placed into.
+- `macro_export` - export a macro for cross-crate usage.
+- `no_mangle` - on any item, do not apply the standard name mangling. Set the
+ symbol for this item to its identifier.
+- `packed` - on structs or enums, eliminate any padding that would be used to
+ align fields.
+- `repr` - on C-like enums, this sets the underlying type used for
+ representation. Useful for FFI. Takes one argument, which is the primitive
+ type this enum should be represented for, or `C`, which specifies that it
+ should be the default `enum` size of the C ABI for that platform. Note that
+ enum representation in C is undefined, and this may be incorrect when the C
+ code is compiled with certain flags.
+- `simd` - on certain tuple structs, derive the arithmetic operators, which
+ lower to the target's SIMD instructions, if any.
+- `static_assert` - on statics whose type is `bool`, terminates compilation
+ with an error if it is not initialized to `true`.
+- `unsafe_destructor` - allow implementations of the "drop" language item
+ where the type it is implemented for does not implement the "send" language
+ item.
+- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
+ destructors from being run twice. Destructors might be run multiple times on
+ the same object with this attribute.
### Conditional compilation
form). Additionally, one can reverse a condition by enclosing it in a
`not(...)`, like e. g. `#[cfg(not(target_os = "win32"))]`.
-To pass a configuration option which triggers a `#[cfg(identifier)]` one can use
-`rustc --cfg identifier`. In addition to that, the following configurations are
-pre-defined by the compiler:
+The following configurations must be defined by the implementation:
* `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"`
`"mips"`, or `"arm"`.
* `target_os = "..."`. Operating system of the target, examples include
`"win32"`, `"macos"`, `"linux"`, `"android"` or `"freebsd"`.
* `target_word_size = "..."`. Target word size in bits. This is set to `"32"`
- for 32-bit CPU targets, and likewise set to `"64"` for 64-bit CPU targets.
- * `test`. Only set in test builds (`rustc --test`).
+ for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit
+ pointers.
* `unix`. See `target_family`.
* `windows`. See `target_family`.
* `deny(C)` signals an error after encountering a violation of `C`,
* `allow(C)` overrides the check for `C` so that violations will go
unreported,
- * `forbid(C)` is the same as `deny(C)`, but also forbids uses of
- `allow(C)` within the entity.
+ * `forbid(C)` is the same as `deny(C)`, but also forbids changing the lint
+ level afterwards.
The lint checks supported by the compiler can be found via `rustc -W help`,
along with their default settings.
### Language items
-Some primitive Rust operations are defined in Rust code,
-rather than being implemented directly in C or assembly language.
-The definitions of these operations have to be easy for the compiler to find.
-The `lang` attribute makes it possible to declare these operations.
-For example, the `str` module in the Rust standard library defines the string equality function:
+Some primitive Rust operations are defined in Rust code, rather than being
+implemented directly in C or assembly language. The definitions of these
+operations have to be easy for the compiler to find. The `lang` attribute
+makes it possible to declare these operations. For example, the `str` module
+in the Rust standard library defines the string equality function:
~~~~ {.ignore}
#[lang="str_eq"]
A complete list of the built-in language items follows:
-#### Traits
+#### Built-in Traits
-`const`
- : Cannot be mutated.
-`owned`
- : Are uniquely owned.
-`durable`
- : Contain references.
+`send`
+ : Able to be sent across task boundaries.
+`sized`
+ : Has a size known at compile time.
+`copy`
+ : Types that do not move ownership when used by-value.
+`share`
+ : Able to be safely shared between tasks when aliased.
`drop`
- : Have finalizers.
+ : Have destructors.
+
+#### Operators
+
+These language items are traits:
+
`add`
: Elements can be added (for example, integers and floats).
`sub`
: Elements can be compared for equality.
`ord`
: Elements have a partial ordering.
+`deref`
+ : `*` can be applied, yielding a reference to another type
+`deref_mut`
+ : `*` can be applied, yielding a mutable reference to another type
+
-#### Operations
+These are functions:
`str_eq`
- : Compare two strings for equality.
+ : Compare two strings (`&str`) for equality.
`uniq_str_eq`
- : Compare two owned strings for equality.
-`annihilate`
- : Destroy a box before freeing it.
-`log_type`
- : Generically print a string representation of any type.
+ : Compare two owned strings (`~str`) for equality.
+`strdup_uniq`
+ : Return a new unique string
+ containing a copy of the contents of a unique string.
+
+#### Types
+
+`unsafe`
+ : A type whose contents can be mutated through an immutable reference
+`type_id`
+ : The type returned by the `type_id` intrinsic.
+
+#### Marker types
+
+These types help drive the compiler's analysis
+
+`covariant_type`
+ : The type parameter should be considered covariant
+`contravariant_type`
+ : The type parameter should be considered contravariant
+`invariant_type`
+ : The type parameter should be considered invariant
+`covariant_lifetime`
+ : The lifetime parameter should be considered covariant
+`contravariant_lifetime`
+ : The lifetime parameter should be considered contravariant
+`invariant_lifetime`
+ : The lifetime parameter should be considered invariant
+`no_send_bound`
+ : This type does not implement "send", even if eligible
+`no_copy_bound`
+ : This type does not implement "copy", even if eligible
+`no_share_bound`
+ : This type does not implement "share", even if eligible
+`managed_bound`
+ : This type implements "managed"
+
`fail_`
: Abort the program with an error.
`fail_bounds_check`
: Allocate memory on the managed heap.
`free`
: Free memory that was allocated on the managed heap.
-`borrow_as_imm`
- : Create an immutable reference to a mutable value.
-`return_to_mut`
- : Release a reference created with `return_to_mut`
-`check_not_borrowed`
- : Fail if a value has existing references to it.
-`strdup_uniq`
- : Return a new unique string
- containing a copy of the contents of a unique string.
> **Note:** This list is likely to become out of date. We should auto-generate it
> from `librustc/middle/lang_items.rs`.
* `Show`, to format a value using the `{}` formatter.
### Stability
+
One can indicate the stability of an API using the following attributes:
* `deprecated`: This item should no longer be used, e.g. it has been
string that will be displayed when the lint flags the use of an item.
~~~~ {.ignore}
-#[warn(unstable)];
+#![warn(unstable)]
#[deprecated="replaced by `best`"]
fn bad() {
quality" or "almost production ready", but may not be stable enough to be
considered a full-fleged language feature.
-For this reason, rust recognizes a special crate-level attribute of the form:
+For this reason, Rust recognizes a special crate-level attribute of the form:
~~~~ {.ignore}
-#[feature(feature1, feature2, feature3)]
+#![feature(feature1, feature2, feature3)]
~~~~
This directive informs the compiler that the feature list: `feature1`,
crate-level, not at a module-level. Without this directive, all features are
considered off, and using the features will result in a compiler error.
-The currently implemented features of the compiler are:
+The currently implemented features of the reference compiler are:
* `macro_rules` - The definition of new macros. This does not encompass
macro-invocation, that is always enabled by default, this only
that demonstrates all four of them:
~~~~
-#[feature(phase)];
+#![feature(phase)]
#[phase(syntax, link)] extern crate log;
fn main() {
should work.
~~~~ {.notrust}
-$ curl -O http://static.rust-lang.org/dist/rust-0.10.tar.gz
-$ tar -xzf rust-0.10.tar.gz
-$ cd rust-0.10
+$ curl -O http://static.rust-lang.org/dist/rust-nightly.tar.gz
+$ tar -xzf rust-nightly.tar.gz
+$ cd rust-nightly
$ ./configure
$ make && make install
~~~~
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
API-documentation tool.
-[tarball]: http://static.rust-lang.org/dist/rust-0.10.tar.gz
-[win-exe]: http://static.rust-lang.org/dist/rust-0.10-install.exe
+[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz
+[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe
## Compiling your first program
~~~~
We can use this simple definition to allocate points in many different
-ways. For example, in this code, each of these three local variables
+ways. For example, in this code, each of these local variables
contains a point, but allocated in a different location:
~~~
# struct Point { x: f64, y: f64 }
let on_the_stack : Point = Point { x: 3.0, y: 4.0 };
-let managed_box : @Point = @Point { x: 5.0, y: 1.0 };
let owned_box : ~Point = ~Point { x: 7.0, y: 9.0 };
~~~
Suppose we want to write a procedure that computes the distance
-between any two points, no matter where they are stored. For example,
-we might like to compute the distance between `on_the_stack` and
-`managed_box`, or between `managed_box` and `owned_box`. One option is
+between any two points, no matter where they are stored. One option is
to define a function that takes two arguments of type point—that is,
it takes the points by value. But this will cause the points to be
copied when we call the function. For points, this is probably not so
~~~
# struct Point{ x: f64, y: f64 };
# let on_the_stack : Point = Point { x: 3.0, y: 4.0 };
-# let managed_box : @Point = @Point { x: 5.0, y: 1.0 };
# let owned_box : ~Point = ~Point { x: 7.0, y: 9.0 };
# fn compute_distance(p1: &Point, p2: &Point) -> f64 { 0.0 }
-compute_distance(&on_the_stack, managed_box);
-compute_distance(managed_box, owned_box);
+compute_distance(&on_the_stack, owned_box);
~~~
Here the `&` operator is used to take the address of the variable
`on_the_stack`, because we are creating an alias: that is, another
route to the same data.
-In the case of the boxes `managed_box` and `owned_box`, however, no
+In the case of `owned_box`, however, no
explicit action is necessary. The compiler will automatically convert
-a box like `@point` or `~point` to a reference like
+a box `~point` to a reference like
`&point`. This is another form of borrowing; in this case, the
-contents of the managed/owned box are being lent out.
+contents of the owned box are being lent out.
Whenever a value is borrowed, there are some limitations on what you
can do with the original. For example, if the contents of a variable
box or pointer, similarly to C.
~~~
-let managed = @10;
let owned = ~20;
let borrowed = &30;
-let sum = *managed + *owned + *borrowed;
+let sum = *owned + *borrowed;
~~~
Dereferenced mutable pointers may appear on the left hand side of
points to.
~~~
-let managed = @10;
-let mut owned = ~20;
+let mut owned = ~10;
-let mut value = 30;
+let mut value = 20;
let borrowed = &mut value;
*owned = *borrowed + 100;
-*borrowed = *managed + 1000;
+*borrowed = *owned + 1000;
~~~
Pointers have high operator precedence, but lower precedence than the
Owned closures, written `proc`,
hold on to things that can safely be sent between
-processes. They copy the values they close over, much like managed
-closures, but they also own them: that is, no other code can access
+processes. They copy the values they close over,
+but they also own them: that is, no other code can access
them. Owned closures are used in concurrent code, particularly
for spawning [tasks][tasks].
# fn draw_value(self) { /* ... */ }
# }
# let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0);
-// As with typical function arguments, managed and owned pointers
+// As with typical function arguments, owned pointers
// are automatically converted to references
(@s).draw_reference();
* `Send` - Sendable types.
Types are sendable
-unless they contain managed boxes, managed closures, or references.
+unless they contain references.
* `Share` - Types that are *threadsafe*
These are types that are safe to be used across several threads with access to
have the `'static` lifetime. (For more on named lifetimes and their uses,
see the [references and lifetimes guide][lifetimes].)
-> ***Note:*** These two traits were referred to as 'kinds' in earlier
+> ***Note:*** These built-in traits were referred to as 'kinds' in earlier
> iterations of the language, and often still are.
Additionally, the `Drop` trait is used to define destructors. This
function, and the module `farm`. The module `farm` also contains two functions and a third module `barn`,
which contains a function `hay`.
-(In case you already stumbled over `extern crate`: It isn't directly related to a bare `mod`, we'll get to it later. )
-
## Paths and visibility
We've now defined a nice module hierarchy. But how do we access the items in it from our `main` function?
The path you give to `use` is per default global, meaning relative to the crate root,
no matter how deep the module hierarchy is, or whether the module body it's written in
-is contained in its own file (remember: files are irrelevant).
+is contained in its own file. (Remember: files are irrelevant.)
-This is different to other languages, where you often only find a single import construct that combines the semantic
+This is different from other languages, where you often only find a single import construct that combines the semantic
of `mod foo;` and `use`-statements, and which tend to work relative to the source file or use an absolute file path
-- Rubys `require` or C/C++'s `#include` come to mind.
+- Ruby's `require` or C/C++'s `#include` come to mind.
However, it's also possible to import things relative to the module of the `use`-statement:
Adding a `super::` in front of the path will start in the parent module,
of the module `farm` to access a function from `barn` without needing
to know that `barn` exists.
-In other words, you can use them to decouple an public api from their internal implementation.
+In other words, you can use it to decouple a public api from its internal implementation.
## Using libraries
}
~~~
-Despite its name, `extern crate` is a distinct construct from regular `mod` declarations:
A statement of the form `extern crate foo;` will cause `rustc` to search for the crate `foo`,
and if it finds a matching binary it lets you use it from inside your crate.
;; but the "else" or "{" should align with the beginning
;; of the expression it's in.)
(looking-at "\\<else\\>\\|{")
-
+
(save-excursion
(rust-rewind-irrelevant)
;; Point is now at the end of the previous ine
;; Special types
(,(regexp-opt rust-special-types 'words) . font-lock-type-face)
- ;; Attributes like `#[bar(baz)]`
- (,(rust-re-grab (concat "#\\[" rust-re-ident "[^]]*\\]"))
+ ;; Attributes like `#[bar(baz)]` or `#![bar(baz)]`
+ (,(rust-re-grab (concat "#\\!?[" rust-re-ident "[^]]*\\]"))
1 font-lock-preprocessor-face)
;; Syntax extension invocations like `foo!`, highlight including the !
</context>
<context id="attribute" style-ref="attribute" class="attribute">
- <start extended="true">\#\[</start>
+ <start extended="true">\#!?\[</start>
<end>\]</end>
<include>
<context ref="def:in-comment"/>
<!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">
<!ENTITY rustIntSuf "([iu](8|16|32|64)?)?">
]>
-<language name="Rust" version="0.10" kateversion="2.4" section="Sources" extensions="*.rs" mimetype="text/x-rust" priority="15">
+<language name="Rust" version="0.11-pre" kateversion="2.4" section="Sources" extensions="*.rs" mimetype="text/x-rust" priority="15">
<highlighting>
<list name="fn">
<item> fn </item>
<RegExpr String="[0-9][0-9_]*\.[0-9_]*([eE][+-]?[0-9_]+)?(f32|f64|f)?" attribute="Number" context="#stay"/>
<RegExpr String="[0-9][0-9_]*&rustIntSuf;" attribute="Number" context="#stay"/>
<Detect2Chars char="#" char1="[" attribute="Attribute" context="Attribute" beginRegion="Attribute"/>
+ <Detect2Chars char="#" char1="!" char2="[" attribute="Attribute" context="Attribute" beginRegion="Attribute"/>
<RegExpr String="&rustIdent;::" attribute="Scope"/>
<RegExpr String="&rustIdent;!" attribute="Macro"/>
<RegExpr String="'&rustIdent;(?!')" attribute="Lifetime"/>
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
//! of individual objects while the arena itself is still alive. The benefit
//! of an arena is very fast allocation; just a pointer bump.
-#![crate_id = "arena#0.10"]
+#![crate_id = "arena#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")]
#![allow(missing_doc)]
-#![feature(managed_boxes)]
-
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
extern crate collections;
for i in range(0u, 10) {
// Arena allocate something with drop glue to make sure it
// doesn't leak.
- arena.alloc(|| @i);
+ arena.alloc(|| Rc::new(i));
// Allocate something with funny size and alignment, to keep
// things interesting.
arena.alloc(|| [0u8, 1u8, 2u8]);
for i in range(0u, 10) {
// Arena allocate something with drop glue to make sure it
// doesn't leak.
- arena.alloc(|| { @i });
+ arena.alloc(|| { Rc::new(i) });
// Allocate something with funny size and alignment, to keep
// things interesting.
arena.alloc(|| { [0u8, 1u8, 2u8] });
}
// Now, fail while allocating
- arena.alloc::<@int>(|| {
+ arena.alloc::<Rc<int>>(|| {
// Now fail.
fail!();
});
* Collection types.
*/
-#![crate_id = "collections#0.10"]
+#![crate_id = "collections#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
*/
-#![crate_id = "flate#0.10"]
+#![crate_id = "flate#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
*/
-#![crate_id = "fourcc#0.10"]
+#![crate_id = "fourcc#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
//! }
//! ~~~
-#![crate_id = "getopts#0.10"]
+#![crate_id = "getopts#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
* `glob`/`fnmatch` functions.
*/
-#![crate_id = "glob#0.10"]
+#![crate_id = "glob#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
//! pool.shutdown();
//! ```
-#![crate_id = "green#0.10"]
+#![crate_id = "green#0.11-pre"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
*/
-#![crate_id = "hexfloat#0.10"]
+#![crate_id = "hexfloat#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
*/
-#![crate_id = "log#0.10"]
+#![crate_id = "log#0.11-pre"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
//! }
//! ```
-#![crate_id = "native#0.10"]
+#![crate_id = "native#0.11-pre"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![feature(macro_rules)]
-#![crate_id = "num#0.10"]
+#![crate_id = "num#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
/// Generate Normal Random
/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
/// College, Oxford
-pub struct Exp1(f64);
+pub struct Exp1(pub f64);
// This could be done via `-rng.gen::<f64>().ln()` but that is slower.
impl Rand for Exp1 {
/// Generate Normal Random
/// Samples*](http://www.doornik.com/research/ziggurat.pdf). Nuffield
/// College, Oxford
-pub struct StandardNormal(f64);
+pub struct StandardNormal(pub f64);
impl Rand for StandardNormal {
fn rand<R:Rng>(rng: &mut R) -> StandardNormal {
```
*/
-#![crate_id = "rand#0.10"]
+#![crate_id = "rand#0.11-pre"]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
/// let Open01(val) = random::<Open01<f32>>();
/// println!("f32 from (0,1): {}", val);
/// ```
-pub struct Open01<F>(F);
+pub struct Open01<F>(pub F);
/// A wrapper for generating floating point numbers uniformly in the
/// closed interval `[0,1]` (including both endpoints).
/// let Closed01(val) = random::<Closed01<f32>>();
/// println!("f32 from [0,1]: {}", val);
/// ```
-pub struct Closed01<F>(F);
+pub struct Closed01<F>(pub F);
#[cfg(test)]
mod test {
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
}).collect();
ast::ForeignMod {
- abis: nm.abis,
+ abi: nm.abi,
view_items: filtered_view_items,
items: filtered_items
}
("macro_registrar", Active),
("log_syntax", Active),
("trace_macros", Active),
+ ("concat_idents", Active),
+
("simd", Active),
("default_type_params", Active),
("quote", Active),
stable enough for use and is subject to change");
}
+ else if id == token::str_to_ident("concat_idents") {
+ self.gate_feature("concat_idents", path.span, "`concat_idents` is not \
+ stable enough for use and is subject to change");
+ }
+
else {
for "e in quotes.iter() {
if id == token::str_to_ident(quote) {
use syntax::parse::token;
use syntax::util::small_vector::SmallVector;
-pub static VERSION: &'static str = "0.10";
+pub static VERSION: &'static str = "0.11-pre";
pub fn maybe_inject_crates_ref(sess: &Session, krate: ast::Crate)
-> ast::Crate {
*/
-#![crate_id = "rustc#0.10"]
+#![crate_id = "rustc#0.11-pre"]
#![comment = "The Rust compiler"]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
-> Bool;
/** Moves the section iterator to point to the next section. */
pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
- /** Returns the current section name. */
- pub fn LLVMGetSectionName(SI: SectionIteratorRef) -> *c_char;
/** Returns the current section size. */
pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
/** Returns the current section contents as a string buffer. */
pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
pub fn LLVMVersionMinor() -> c_int;
+
+ pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
+ data: *mut *c_char) -> c_int;
}
}
fn visit_item(e: &Env, i: &ast::Item) {
match i.node {
ast::ItemForeignMod(ref fm) => {
- if fm.abis.is_rust() || fm.abis.is_intrinsic() {
+ if fm.abi == abi::Rust || fm.abi == abi::RustIntrinsic {
return;
}
let cdata = cstore.get_crate_data(crate_num);
decoder::get_exported_macros(cdata)
}
+
+pub fn get_tuple_struct_definition_if_ctor(cstore: &cstore::CStore,
+ def_id: ast::DefId)
+ -> Option<ast::DefId>
+{
+ let cdata = cstore.get_crate_data(def_id.krate);
+ decoder::get_tuple_struct_definition_if_ctor(cdata, def_id.node)
+}
/// If node_id is the constructor of a tuple struct, retrieve the NodeId of
/// the actual type definition, otherwise, return None
pub fn get_tuple_struct_definition_if_ctor(cdata: Cmd,
- node_id: ast::NodeId) -> Option<ast::NodeId> {
+ node_id: ast::NodeId)
+ -> Option<ast::DefId>
+{
let item = lookup_item(node_id, cdata.data());
let mut ret = None;
reader::tagged_docs(item, tag_items_data_item_is_tuple_struct_ctor, |_| {
ret = Some(item_reqd_and_translated_parent_item(cdata.cnum, item));
false
});
- ret.map(|x| x.node)
+ ret
}
pub fn get_item_attrs(cdata: Cmd,
- node_id: ast::NodeId,
+ orig_node_id: ast::NodeId,
f: |Vec<@ast::MetaItem> |) {
// The attributes for a tuple struct are attached to the definition, not the ctor;
// we assume that someone passing in a tuple struct ctor is actually wanting to
// look at the definition
- let node_id = get_tuple_struct_definition_if_ctor(cdata, node_id).unwrap_or(node_id);
+ let node_id = get_tuple_struct_definition_if_ctor(cdata, orig_node_id);
+ let node_id = node_id.map(|x| x.node).unwrap_or(orig_node_id);
let item = lookup_item(node_id, cdata.data());
reader::tagged_docs(item, tag_attributes, |attributes| {
reader::tagged_docs(attributes, tag_attribute, |attribute| {
use std::io::MemWriter;
use std::str;
use collections::HashMap;
-use syntax::abi::AbiSet;
+use syntax::abi;
use syntax::ast::*;
use syntax::ast;
use syntax::ast_map::{PathElem, PathElems};
nitem: &ForeignItem,
index: @RefCell<Vec<entry<i64>> >,
path: PathElems,
- abi: AbiSet) {
+ abi: abi::Abi) {
index.borrow_mut().push(entry {
val: nitem.id as i64,
pos: ebml_w.writer.tell().unwrap(),
encode_bounds_and_type(ebml_w, ecx,
&lookup_item_type(ecx.tcx,local_def(nitem.id)));
encode_name(ebml_w, nitem.ident.name);
- if abi.is_intrinsic() {
+ if abi == abi::RustIntrinsic {
(ecx.encode_inlined_item)(ecx, ebml_w, IIForeignRef(nitem));
} else {
encode_symbol(ecx, ebml_w, nitem.id);
let mut ebml_w = unsafe {
ebml_w.unsafe_clone()
};
- let abis = ecx.tcx.map.get_foreign_abis(ni.id);
+ let abi = ecx.tcx.map.get_foreign_abi(ni.id);
ecx.tcx.map.with_path(ni.id, |path| {
encode_info_for_foreign_item(ecx, &mut ebml_w,
ni, index,
- path, abis);
+ path, abi);
});
}
use std::cmp;
use std::io;
use std::os::consts::{macos, freebsd, linux, android, win32};
+use std::ptr;
use std::rc::Rc;
-use std::str;
use std::slice;
+use std::str;
use collections::{HashMap, HashSet};
use flate;
};
let si = mk_section_iter(of.llof);
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
- let name_buf = llvm::LLVMGetSectionName(si.llsi);
- let name = str::raw::from_c_str(name_buf);
+ let mut name_buf = ptr::null();
+ let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
+ let name = str::raw::from_buf_len(name_buf as *u8, name_len as uint);
debug!("get_metadata_section: name {}", name);
if read_meta_section_name(os) == name {
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
use std::str;
use std::uint;
-use syntax::abi::AbiSet;
use syntax::abi;
use syntax::ast;
use syntax::ast::*;
}
}
-fn parse_abi_set(st: &mut PState) -> AbiSet {
+fn parse_abi_set(st: &mut PState) -> abi::Abi {
assert_eq!(next(st), '[');
- let mut abis = AbiSet::empty();
- while peek(st) != ']' {
- scan(st, |c| c == ',', |bytes| {
- let abi_str = str::from_utf8(bytes).unwrap().to_owned();
- let abi = abi::lookup(abi_str).expect(abi_str);
- abis.add(abi);
- });
- }
- assert_eq!(next(st), ']');
- return abis;
+ scan(st, |c| c == ']', |bytes| {
+ let abi_str = str::from_utf8(bytes).unwrap().to_owned();
+ abi::lookup(abi_str).expect(abi_str)
+ })
}
fn parse_onceness(c: char) -> ast::Onceness {
let sig = parse_sig(st, |x,y| conv(x,y));
ty::BareFnTy {
purity: purity,
- abis: abi,
+ abi: abi,
sig: sig
}
}
use middle::ty::param_ty;
use middle::ty;
-use syntax::abi::AbiSet;
+use syntax::abi::Abi;
use syntax::ast;
use syntax::ast::*;
use syntax::diagnostic::SpanHandler;
}
}
-fn enc_abi_set(w: &mut MemWriter, abis: AbiSet) {
+fn enc_abi(w: &mut MemWriter, abi: Abi) {
mywrite!(w, "[");
- abis.each(|abi| {
- mywrite!(w, "{},", abi.name());
- true
- });
+ mywrite!(w, "{}", abi.name());
mywrite!(w, "]")
}
pub fn enc_bare_fn_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::BareFnTy) {
enc_purity(w, ft.purity);
- enc_abi_set(w, ft.abis);
+ enc_abi(w, ft.abi);
enc_fn_sig(w, cx, &ft.sig);
}
}
#[deriving(Eq)]
-pub struct NodeIndex(uint);
+pub struct NodeIndex(pub uint);
pub static InvalidNodeIndex: NodeIndex = NodeIndex(uint::MAX);
#[deriving(Eq)]
-pub struct EdgeIndex(uint);
+pub struct EdgeIndex(pub uint);
pub static InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::MAX);
// Use a private field here to guarantee no more instances are created:
use std::u64;
use std::u8;
use collections::SmallIntMap;
+use syntax::abi;
use syntax::ast_map;
use syntax::ast_util::IdVisitingOperation;
use syntax::attr::{AttrMetaMethods, AttributeMethods};
}
match it.node {
- ast::ItemForeignMod(ref nmod) if !nmod.abis.is_intrinsic() => {
+ ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
for ni in nmod.items.iter() {
match ni.node {
ast::ForeignItemFn(decl, _) => check_foreign_fn(cx, decl),
use std::mem::replace;
+use metadata::csearch;
use middle::lint;
use middle::resolve;
use middle::ty;
DisallowedBy(ast::NodeId),
}
+enum FieldName {
+ UnnamedField(uint), // index
+ // FIXME #6993: change type (and name) from Ident to Name
+ NamedField(ast::Ident),
+}
+
impl<'a> PrivacyVisitor<'a> {
// used when debugging
fn nodestr(&self, id: ast::NodeId) -> ~str {
}
// Checks that a field is in scope.
- // FIXME #6993: change type (and name) from Ident to Name
- fn check_field(&mut self, span: Span, id: ast::DefId, ident: ast::Ident) {
- for field in ty::lookup_struct_fields(self.tcx, id).iter() {
- if field.name != ident.name { continue; }
- if field.vis == ast::Public { break }
- if !is_local(field.id) ||
- !self.private_accessible(field.id.node) {
- self.tcx.sess.span_err(span,
- format!("field `{}` is private",
- token::get_ident(ident)))
+ fn check_field(&mut self, span: Span, id: ast::DefId,
+ name: FieldName) {
+ let fields = ty::lookup_struct_fields(self.tcx, id);
+ let field = match name {
+ NamedField(ident) => {
+ fields.iter().find(|f| f.name == ident.name).unwrap()
}
- break;
+ UnnamedField(idx) => fields.get(idx)
+ };
+ if field.vis == ast::Public { return }
+ if !is_local(field.id) || !self.private_accessible(field.id.node) {
+ let msg = match name {
+ NamedField(name) => format!("field `{}` is private",
+ token::get_ident(name)),
+ UnnamedField(idx) => format!("field \\#{} is private", idx + 1),
+ };
+ self.tcx.sess.span_err(span, msg);
}
}
_ => {},
}
}
- // If an import is not used in either namespace, we still want to check
- // that it could be legal. Therefore we check in both namespaces and only
- // report an error if both would be illegal. We only report one error,
- // even if it is illegal to import from both namespaces.
+ // If an import is not used in either namespace, we still
+ // want to check that it could be legal. Therefore we check
+ // in both namespaces and only report an error if both would
+ // be illegal. We only report one error, even if it is
+ // illegal to import from both namespaces.
match (value_priv, check_value, type_priv, check_type) {
(Some(p), resolve::Unused, None, _) |
(None, _, Some(p), resolve::Unused) => {
// is whether the trait itself is accessible or not.
MethodParam(MethodParam { trait_id: trait_id, .. }) |
MethodObject(MethodObject { trait_id: trait_id, .. }) => {
- self.report_error(self.ensure_public(span, trait_id, None, "source trait"));
+ self.report_error(self.ensure_public(span, trait_id, None,
+ "source trait"));
}
}
}
match ty::get(ty::expr_ty_adjusted(self.tcx, base,
&*self.method_map.borrow())).sty {
ty::ty_struct(id, _) => {
- self.check_field(expr.span, id, ident);
+ self.check_field(expr.span, id, NamedField(ident));
}
_ => {}
}
match ty::get(ty::expr_ty(self.tcx, expr)).sty {
ty::ty_struct(id, _) => {
for field in (*fields).iter() {
- self.check_field(expr.span, id, field.ident.node);
+ self.check_field(expr.span, id,
+ NamedField(field.ident.node));
}
}
ty::ty_enum(_, _) => {
ast::DefVariant(_, variant_id, _) => {
for field in fields.iter() {
self.check_field(expr.span, variant_id,
- field.ident.node);
+ NamedField(field.ident.node));
}
}
_ => self.tcx.sess.span_bug(expr.span,
struct type?!"),
}
}
+ ast::ExprPath(..) => {
+ let guard = |did: ast::DefId| {
+ let fields = ty::lookup_struct_fields(self.tcx, did);
+ let any_priv = fields.iter().any(|f| {
+ f.vis != ast::Public && (
+ !is_local(f.id) ||
+ !self.private_accessible(f.id.node))
+ });
+ if any_priv {
+ self.tcx.sess.span_err(expr.span,
+ "cannot invoke tuple struct constructor \
+ with private fields");
+ }
+ };
+ match self.tcx.def_map.borrow().find(&expr.id) {
+ Some(&ast::DefStruct(did)) => {
+ guard(if is_local(did) {
+ local_def(self.tcx.map.get_parent(did.node))
+ } else {
+ // "tuple structs" with zero fields (such as
+ // `pub struct Foo;`) don't have a ctor_id, hence
+ // the unwrap_or to the same struct id.
+ let maybe_did =
+ csearch::get_tuple_struct_definition_if_ctor(
+ &self.tcx.sess.cstore, did);
+ maybe_did.unwrap_or(did)
+ })
+ }
+ // Tuple struct constructors across crates are identified as
+ // DefFn types, so we explicitly handle that case here.
+ Some(&ast::DefFn(did, _)) if !is_local(did) => {
+ match csearch::get_tuple_struct_definition_if_ctor(
+ &self.tcx.sess.cstore, did) {
+ Some(did) => guard(did),
+ None => {}
+ }
+ }
+ _ => {}
+ }
+ }
_ => {}
}
match ty::get(ty::pat_ty(self.tcx, pattern)).sty {
ty::ty_struct(id, _) => {
for field in fields.iter() {
- self.check_field(pattern.span, id, field.ident);
+ self.check_field(pattern.span, id,
+ NamedField(field.ident));
}
}
ty::ty_enum(_, _) => {
Some(&ast::DefVariant(_, variant_id, _)) => {
for field in fields.iter() {
self.check_field(pattern.span, variant_id,
- field.ident);
+ NamedField(field.ident));
}
}
_ => self.tcx.sess.span_bug(pattern.span,
struct type?!"),
}
}
+
+ // Patterns which bind no fields are allowable (the path is check
+ // elsewhere).
+ ast::PatEnum(_, Some(ref fields)) => {
+ match ty::get(ty::pat_ty(self.tcx, pattern)).sty {
+ ty::ty_struct(id, _) => {
+ for (i, field) in fields.iter().enumerate() {
+ match field.node {
+ ast::PatWild(..) => continue,
+ _ => {}
+ }
+ self.check_field(field.span, id, UnnamedField(i));
+ }
+ }
+ ty::ty_enum(..) => {
+ // enum fields have no privacy at this time
+ }
+ _ => {}
+ }
+
+ }
_ => {}
}
let name = csearch::get_symbol(&ccx.sess().cstore, did);
match ty::get(t).sty {
ty::ty_bare_fn(ref fn_ty) => {
- match fn_ty.abis.for_target(ccx.sess().targ_cfg.os,
- ccx.sess().targ_cfg.arch) {
+ match fn_ty.abi.for_target(ccx.sess().targ_cfg.os,
+ ccx.sess().targ_cfg.arch) {
Some(Rust) | Some(RustIntrinsic) => {
get_extern_rust_fn(ccx,
fn_ty.sig.inputs.as_slice(),
did)
}
Some(..) | None => {
- let c = foreign::llvm_calling_convention(ccx, fn_ty.abis);
+ let c = foreign::llvm_calling_convention(ccx, fn_ty.abi);
let cconv = c.unwrap_or(lib::llvm::CCallConv);
let llty = type_of_fn_from_ty(ccx, t);
get_extern_fn(&mut *ccx.externs.borrow_mut(), ccx.llmod,
pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
let _icx = push_ctxt("trans_item");
match item.node {
- ast::ItemFn(decl, purity, _abis, ref generics, body) => {
+ ast::ItemFn(decl, purity, _abi, ref generics, body) => {
if purity == ast::ExternFn {
let llfndecl = get_item_val(ccx, item.id);
foreign::trans_rust_fn_with_foreign_abi(
-> ValueRef {
let f = match ty::get(node_type).sty {
ty::ty_bare_fn(ref f) => {
- assert!(f.abis.is_rust() || f.abis.is_intrinsic());
+ assert!(f.abi == Rust || f.abi == RustIntrinsic);
f
}
_ => fail!("expected bare rust fn or an intrinsic")
match ni.node {
ast::ForeignItemFn(..) => {
- let abis = ccx.tcx.map.get_foreign_abis(id);
- foreign::register_foreign_item_fn(ccx, abis, ni)
+ let abi = ccx.tcx.map.get_foreign_abi(id);
+ foreign::register_foreign_item_fn(ccx, abi, ni)
}
ast::ForeignItemStatic(..) => {
foreign::register_static(ccx, ni)
use middle::trans::value::{Users, Value};
use std::iter::{Filter, Map};
-pub struct BasicBlock(BasicBlockRef);
+pub struct BasicBlock(pub BasicBlockRef);
pub type Preds<'a> = Map<'a, Value, BasicBlock, Filter<'a, Value, Users>>;
use middle::trans::type_::Type;
use syntax::ast;
-use syntax::abi::AbiSet;
+use synabi = syntax::abi;
use syntax::ast_map;
pub struct MethodData {
match map_node {
ast_map::NodeForeignItem(_) => {
- tcx.map.get_foreign_abis(def_id.node).is_intrinsic()
+ tcx.map.get_foreign_abi(def_id.node) == synabi::RustIntrinsic
}
_ => false
}
};
let (abi, ret_ty) = match ty::get(callee_ty).sty {
- ty::ty_bare_fn(ref f) => (f.abis, f.sig.output),
- ty::ty_closure(ref f) => (AbiSet::Rust(), f.sig.output),
+ ty::ty_bare_fn(ref f) => (f.abi, f.sig.output),
+ ty::ty_closure(ref f) => (synabi::Rust, f.sig.output),
_ => fail!("expected bare rust fn or closure in trans_call_inner")
};
- let is_rust_fn =
- abi.is_rust() ||
- abi.is_intrinsic();
+ let is_rust_fn = abi == synabi::Rust || abi == synabi::RustIntrinsic;
// Generate a location to store the result. If the user does
// not care about the result, just make a stack slot.
// This is a 'c-like' raw string, which differs from
// our boxed-and-length-annotated strings.
-pub fn C_cstr(cx: &CrateContext, s: InternedString) -> ValueRef {
+pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> ValueRef {
unsafe {
match cx.const_cstr_cache.borrow().find(&s) {
Some(&llval) => return llval,
let sc = llvm::LLVMConstStringInContext(cx.llcx,
s.get().as_ptr() as *c_char,
s.get().len() as c_uint,
- False);
+ !null_terminated as Bool);
let gsym = token::gensym("str");
let g = format!("str{}", gsym).with_c_str(|buf| {
pub fn C_str_slice(cx: &CrateContext, s: InternedString) -> ValueRef {
unsafe {
let len = s.get().len();
- let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s), Type::i8p(cx).to_ref());
+ let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s, false), Type::i8p(cx).to_ref());
C_struct(cx, [cs, C_uint(cx, len)], false)
}
}
-> (ValueRef, ValueRef) {
let loc = bcx.sess().codemap().lookup_char_pos(span.lo);
let filename_cstr = C_cstr(bcx.ccx(),
- token::intern_and_get_ident(loc.file.name));
+ token::intern_and_get_ident(loc.file.name), true);
let filename = build::PointerCast(bcx, filename_cstr, Type::i8p(bcx.ccx()));
let line = C_int(bcx.ccx(), loc.line as int);
(filename, line)
fail_str: InternedString)
-> &'a Block<'a> {
let ccx = bcx.ccx();
- let v_fail_str = C_cstr(ccx, fail_str);
+ let v_fail_str = C_cstr(ccx, fail_str, true);
let _icx = push_ctxt("trans_fail_value");
let loc = bcx.sess().codemap().lookup_char_pos(sp.lo);
- let v_filename = C_cstr(ccx, token::intern_and_get_ident(loc.file.name));
+ let v_filename = C_cstr(ccx, token::intern_and_get_ident(loc.file.name), true);
let v_line = loc.line as int;
let v_str = PointerCast(bcx, v_fail_str, Type::i8p(ccx));
let v_filename = PointerCast(bcx, v_filename, Type::i8p(ccx));
let i8_t = ty::mk_i8();
match *vstore {
ty::vstore_fixed(len) => {
- fixed_vec_metadata(cx, i8_t, len + 1, usage_site_span)
+ fixed_vec_metadata(cx, i8_t, len, usage_site_span)
},
ty::vstore_uniq => {
let vec_metadata = vec_metadata(cx, i8_t, usage_site_span);
use util::common::indenter;
use util::ppaux::Repr;
use util::nodemap::NodeMap;
-use middle::trans::machine::llsize_of;
+use middle::trans::machine::{llsize_of, llsize_of_alloc};
use middle::trans::type_::Type;
use std::slice;
let size = llsize_of(bcx.ccx(), llty);
let Result { bcx: bcx, val: val } = malloc_raw_dyn(bcx, contents_ty,
heap_exchange, size);
- let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
- fcx.schedule_free_value(cleanup::CustomScope(custom_cleanup_scope),
- val, heap_exchange);
- let bcx = trans_into(bcx, contents, SaveIn(val));
- fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
- immediate_rvalue_bcx(bcx, val, box_ty).to_expr_datumblock()
+ // 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(bcx.ccx(), llty) == 0 {
+ let bcx = trans_into(bcx, contents, SaveIn(val));
+ immediate_rvalue_bcx(bcx, val, box_ty).to_expr_datumblock()
+ } else {
+ let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
+ fcx.schedule_free_value(cleanup::CustomScope(custom_cleanup_scope),
+ val, heap_exchange);
+ let bcx = trans_into(bcx, contents, SaveIn(val));
+ fcx.pop_custom_cleanup_scope(custom_cleanup_scope);
+ immediate_rvalue_bcx(bcx, val, box_ty).to_expr_datumblock()
+ }
} else {
let base::MallocResult { bcx, smart_ptr: bx, body } =
base::malloc_general(bcx, contents_ty, heap);
use middle::ty;
use std::cmp;
use std::libc::c_uint;
-use syntax::abi::{Cdecl, Aapcs, C, AbiSet, Win64};
+use syntax::abi::{Cdecl, Aapcs, C, Win64, Abi};
use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall, System};
use syntax::codemap::Span;
use syntax::parse::token::{InternedString, special_idents};
// Calls to external functions
pub fn llvm_calling_convention(ccx: &CrateContext,
- abis: AbiSet) -> Option<CallConv> {
+ abi: Abi) -> Option<CallConv> {
let os = ccx.sess().targ_cfg.os;
let arch = ccx.sess().targ_cfg.arch;
- abis.for_target(os, arch).map(|abi| {
+ abi.for_target(os, arch).map(|abi| {
match abi {
RustIntrinsic => {
// Intrinsics are emitted by monomorphic fn
}
}
-pub fn register_foreign_item_fn(ccx: &CrateContext, abis: AbiSet,
+pub fn register_foreign_item_fn(ccx: &CrateContext, abi: Abi,
foreign_item: &ast::ForeignItem) -> ValueRef {
/*!
* Registers a foreign function found in a library.
* Just adds a LLVM global.
*/
- debug!("register_foreign_item_fn(abis={}, \
+ debug!("register_foreign_item_fn(abi={}, \
path={}, \
foreign_item.id={})",
- abis.repr(ccx.tcx()),
+ abi.repr(ccx.tcx()),
ccx.tcx.map.path_to_str(foreign_item.id),
foreign_item.id);
- let cc = match llvm_calling_convention(ccx, abis) {
+ let cc = match llvm_calling_convention(ccx, abi) {
Some(cc) => cc,
None => {
ccx.sess().span_fatal(foreign_item.span,
format!("ABI `{}` has no suitable calling convention \
for target architecture",
- abis.user_string(ccx.tcx())));
+ abi.user_string(ccx.tcx())));
}
};
ccx.tn.val_to_str(llfn),
ccx.tn.val_to_str(llretptr));
- let (fn_abis, fn_sig) = match ty::get(callee_ty).sty {
- ty::ty_bare_fn(ref fn_ty) => (fn_ty.abis, fn_ty.sig.clone()),
+ let (fn_abi, fn_sig) = match ty::get(callee_ty).sty {
+ ty::ty_bare_fn(ref fn_ty) => (fn_ty.abi, fn_ty.sig.clone()),
_ => ccx.sess().bug("trans_native_call called on non-function type")
};
let llsig = foreign_signature(ccx, &fn_sig, passed_arg_tys.as_slice());
llargs_foreign.push(llarg_foreign);
}
- let cc = match llvm_calling_convention(ccx, fn_abis) {
+ let cc = match llvm_calling_convention(ccx, fn_abi) {
Some(cc) => cc,
None => {
// FIXME(#8357) We really ought to report a span here
ccx.sess().fatal(
format!("ABI string `{}` has no suitable ABI \
for target architecture",
- fn_abis.user_string(ccx.tcx())));
+ fn_abi.user_string(ccx.tcx())));
}
};
for &foreign_item in foreign_mod.items.iter() {
match foreign_item.node {
ast::ForeignItemFn(..) => {
- let abis = foreign_mod.abis;
- if !(abis.is_rust() || abis.is_intrinsic()) {
- register_foreign_item_fn(ccx, abis, foreign_item);
+ match foreign_mod.abi {
+ Rust | RustIntrinsic => {}
+ abi => { register_foreign_item_fn(ccx, abi, foreign_item); }
}
}
_ => {}
let t = ty::node_id_to_type(ccx.tcx(), node_id);
let (cconv, output) = match ty::get(t).sty {
ty::ty_bare_fn(ref fn_ty) => {
- let c = llvm_calling_convention(ccx, fn_ty.abis);
+ let c = llvm_calling_convention(ccx, fn_ty.abi);
(c.unwrap_or(lib::llvm::CCallConv), fn_ty.sig.output)
}
_ => fail!("expected bare fn in register_rust_fn_with_foreign_abi")
// normal Rust function. This will be the type of the wrappee fn.
let f = match ty::get(t).sty {
ty::ty_bare_fn(ref f) => {
- assert!(!f.abis.is_rust() && !f.abis.is_intrinsic());
+ assert!(f.abi != Rust && f.abi != RustIntrinsic);
f
}
_ => {
use util::ppaux::Repr;
use std::c_str::ToCStr;
+use syntax::abi::Rust;
use syntax::parse::token;
use syntax::{ast, ast_map, visit};
debug!("(translating trait callee) loading method");
// Replace the self type (&Self or ~Self) with an opaque pointer.
let llcallee_ty = match ty::get(callee_ty).sty {
- ty::ty_bare_fn(ref f) if f.abis.is_rust() => {
+ ty::ty_bare_fn(ref f) if f.abi == Rust => {
type_of_rust_fn(ccx, true, f.sig.inputs.slice_from(1), f.sig.output)
}
_ => {
use middle::typeck;
use util::ppaux::Repr;
+use syntax::abi;
use syntax::ast;
use syntax::ast_map;
use syntax::ast_util::local_def;
match map_node {
ast_map::NodeForeignItem(_) => {
- if !ccx.tcx.map.get_foreign_abis(fn_id.node).is_intrinsic() {
+ if ccx.tcx.map.get_foreign_abi(fn_id.node) != abi::RustIntrinsic {
// Foreign externs don't have to be monomorphized.
return (get_item_val(ccx, fn_id.node), true);
}
let f = match ty::get(mono_ty).sty {
ty::ty_bare_fn(ref f) => {
- assert!(f.abis.is_rust() || f.abis.is_intrinsic());
+ assert!(f.abi == abi::Rust || f.abi == abi::RustIntrinsic);
f
}
_ => fail!("expected bare rust fn or an intrinsic")
let str_ty = ty::mk_str(bcx.tcx(), str_vstore);
let scratch = rvalue_scratch_datum(bcx, str_ty, "");
let len = C_uint(bcx.ccx(), s.get().len());
- let c_str = PointerCast(bcx, C_cstr(bcx.ccx(), s), Type::i8p(bcx.ccx()));
+ let c_str = PointerCast(bcx, C_cstr(bcx.ccx(), s, false), Type::i8p(bcx.ccx()));
Store(bcx, c_str, GEPi(bcx, scratch.val, [ 0, 0 ]));
Store(bcx, len, GEPi(bcx, scratch.val, [ 0, 1 ]));
scratch.val
unsafe {
let bytes = str_lit.get().len();
let llbytes = C_uint(bcx.ccx(), bytes);
- let llcstr = C_cstr(bcx.ccx(), str_lit);
+ let llcstr = C_cstr(bcx.ccx(), str_lit, false);
let llcstr = llvm::LLVMConstPointerCast(llcstr, Type::i8p(bcx.ccx()).to_ref());
Store(bcx, llcstr,
GEPi(bcx, lldest, [0u, abi::slice_elt_base]));
ast::ExprLit(lit) => {
match lit.node {
ast::LitStr(ref s, _) => {
- let llptrval = C_cstr(bcx.ccx(), (*s).clone());
+ let llptrval = C_cstr(bcx.ccx(), (*s).clone(), false);
let llptrval = PointerCast(bcx,
llptrval,
Type::i8p(bcx.ccx()));
SaveIn(lldest) => {
let bytes = s.get().len();
let llbytes = C_uint(bcx.ccx(), bytes);
- let llcstr = C_cstr(bcx.ccx(), (*s).clone());
+ let llcstr = C_cstr(bcx.ccx(), (*s).clone(), false);
base::call_memcpy(bcx,
lldest,
llcstr,
use middle::trans::type_::Type;
+use syntax::abi;
use syntax::ast;
use syntax::owned_slice::OwnedSlice;
type_of_rust_fn(cx, true, f.sig.inputs.as_slice(), f.sig.output)
}
ty::ty_bare_fn(ref f) => {
- if f.abis.is_rust() || f.abis.is_intrinsic() {
+ if f.abi == abi::Rust || f.abi == abi::RustIntrinsic {
type_of_rust_fn(cx,
false,
f.sig.inputs.as_slice(),
use middle::trans::common::Block;
use std::libc::c_uint;
-pub struct Value(ValueRef);
+pub struct Value(pub ValueRef);
macro_rules! opt_val ( ($e:expr) => (
unsafe {
use syntax::parse::token::InternedString;
use syntax::{ast, ast_map};
use syntax::owned_slice::OwnedSlice;
-use syntax::abi::AbiSet;
+use syntax::abi;
use syntax;
use collections::enum_set::{EnumSet, CLike};
#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct BareFnTy {
pub purity: ast::Purity,
- pub abis: AbiSet,
- pub sig: FnSig
+ pub abi: abi::Abi,
+ pub sig: FnSig,
}
#[deriving(Clone, Eq, TotalEq, Hash)]
terr_mismatch,
terr_purity_mismatch(expected_found<Purity>),
terr_onceness_mismatch(expected_found<Onceness>),
- terr_abi_mismatch(expected_found<AbiSet>),
+ terr_abi_mismatch(expected_found<abi::Abi>),
terr_mutability,
terr_sigil_mismatch(expected_found<ast::Sigil>),
terr_box_mutability,
}
#[deriving(Clone, Eq, TotalEq, Hash)]
-pub struct TyVid(uint);
+pub struct TyVid(pub uint);
#[deriving(Clone, Eq, TotalEq, Hash)]
-pub struct IntVid(uint);
+pub struct IntVid(pub uint);
#[deriving(Clone, Eq, TotalEq, Hash)]
-pub struct FloatVid(uint);
+pub struct FloatVid(pub uint);
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct RegionVid {
mk_bare_fn(cx,
BareFnTy {
purity: ast::ImpureFn,
- abis: AbiSet::Rust(),
+ abi: abi::Rust,
sig: FnSig {
binder_id: binder_id,
inputs: input_args,
ty_bare_fn(ref b) => {
byte!(14);
hash!(b.purity);
- hash!(b.abis);
+ hash!(b.abi);
}
ty_closure(ref c) => {
byte!(15);
fty: &ty::BareFnTy)
-> ty::BareFnTy {
ty::BareFnTy { sig: self.fold_sig(&fty.sig),
- abis: fty.abis,
+ abi: fty.abi,
purity: fty.purity }
}
use middle::typeck::lookup_def_tcx;
use util::ppaux::Repr;
-use syntax::abi::AbiSet;
+use syntax::abi;
use syntax::{ast, ast_util};
use syntax::codemap::Span;
use syntax::owned_slice::OwnedSlice;
ty::mk_tup(tcx, flds)
}
ast::TyBareFn(ref bf) => {
- if bf.decl.variadic && !bf.abis.is_c() {
+ if bf.decl.variadic && bf.abi != abi::C {
tcx.sess.span_err(ast_ty.span,
"variadic function must have C calling convention");
}
ty::mk_bare_fn(tcx, ty_of_bare_fn(this, ast_ty.id, bf.purity,
- bf.abis, bf.decl))
+ bf.abi, bf.decl))
}
ast::TyClosure(ref f) => {
if f.sigil == ast::ManagedSigil {
untransformed_self_ty: ty::t,
explicit_self: ast::ExplicitSelf,
decl: &ast::FnDecl) -> ty::BareFnTy {
- ty_of_method_or_bare_fn(this, id, purity, AbiSet::Rust(), Some(SelfInfo {
+ ty_of_method_or_bare_fn(this, id, purity, abi::Rust, Some(SelfInfo {
untransformed_self_ty: untransformed_self_ty,
explicit_self: explicit_self
}), decl)
}
pub fn ty_of_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
- purity: ast::Purity, abi: AbiSet,
+ purity: ast::Purity, abi: abi::Abi,
decl: &ast::FnDecl) -> ty::BareFnTy {
ty_of_method_or_bare_fn(this, id, purity, abi, None, decl)
}
fn ty_of_method_or_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
- purity: ast::Purity, abi: AbiSet,
+ purity: ast::Purity, abi: abi::Abi,
opt_self_info: Option<SelfInfo>,
decl: &ast::FnDecl) -> ty::BareFnTy {
debug!("ty_of_method_or_bare_fn");
return ty::BareFnTy {
purity: purity,
- abis: abi,
+ abi: abi,
sig: ty::FnSig {
binder_id: id,
inputs: self_and_input_tys,
let fty = ty::mk_bare_fn(tcx, ty::BareFnTy {
sig: fn_sig,
purity: bare_fn_ty.purity,
- abis: bare_fn_ty.abis.clone(),
+ abi: bare_fn_ty.abi.clone(),
});
debug!("after replacing bound regions, fty={}", self.ty_to_str(fty));
use std::result;
use std::slice;
use std::vec::Vec;
-use syntax::abi::AbiSet;
+use syntax::abi;
use syntax::ast::{Provided, Required};
use syntax::ast;
use syntax::ast_util::local_def;
check_bounds_are_used(ccx, t.span, &generics.ty_params, tpt_ty);
}
ast::ItemForeignMod(ref m) => {
- if m.abis.is_intrinsic() {
+ if m.abi == abi::RustIntrinsic {
for item in m.items.iter() {
check_intrinsic_type(ccx, *item);
}
match item.node {
ast::ForeignItemFn(ref fn_decl, _) => {
- if fn_decl.variadic && !m.abis.is_c() {
+ if fn_decl.variadic && m.abi != abi::C {
ccx.tcx.sess.span_err(
item.span, "variadic function must have C calling convention");
}
};
let fty = ty::mk_bare_fn(tcx, ty::BareFnTy {
purity: ast::UnsafeFn,
- abis: AbiSet::Intrinsic(),
+ abi: abi::RustIntrinsic,
sig: FnSig {binder_id: it.id,
inputs: inputs,
output: output,
use std::rc::Rc;
use collections::HashSet;
-use syntax::abi::AbiSet;
+use syntax::abi;
use syntax::ast::{RegionTyParamBound, TraitTyParamBound};
use syntax::ast;
use syntax::ast_map;
match self.tcx.map.find(id.node) {
Some(ast_map::NodeItem(item)) => ty_of_item(self, item),
Some(ast_map::NodeForeignItem(foreign_item)) => {
- let abis = self.tcx.map.get_foreign_abis(id.node);
- ty_of_foreign_item(self, foreign_item, abis)
+ let abi = self.tcx.map.get_foreign_abi(id.node);
+ ty_of_foreign_item(self, foreign_item, abi)
}
x => {
self.tcx.sess.bug(format!("unexpected sort of node \
fn ensure_generics_abi(ccx: &CrateCtxt,
span: Span,
- abis: AbiSet,
+ abi: abi::Abi,
generics: &ast::Generics) {
if generics.ty_params.len() > 0 &&
- !(abis.is_rust() || abis.is_intrinsic()) {
+ !(abi == abi::Rust || abi == abi::RustIntrinsic) {
ccx.tcx.sess.span_err(span,
"foreign functions may not use type parameters");
}
// map, and I regard each time that I use it as a personal and
// moral failing, but at the moment it seems like the only
// convenient way to extract the ABI. - ndm
- let abis = ccx.tcx.map.get_foreign_abis(i.id);
+ let abi = ccx.tcx.map.get_foreign_abi(i.id);
- let tpt = ty_of_foreign_item(ccx, i, abis);
+ let tpt = ty_of_foreign_item(ccx, i, abi);
write_ty_to_tcx(ccx.tcx, i.id, tpt.ty);
ccx.tcx.tcache.borrow_mut().insert(local_def(i.id), tpt);
pub fn ty_of_foreign_item(ccx: &CrateCtxt,
it: &ast::ForeignItem,
- abis: AbiSet) -> ty::ty_param_bounds_and_ty
+ abi: abi::Abi) -> ty::ty_param_bounds_and_ty
{
match it.node {
ast::ForeignItemFn(fn_decl, ref generics) => {
fn_decl,
local_def(it.id),
generics,
- abis)
+ abi)
}
ast::ForeignItemStatic(t, _) => {
ty::ty_param_bounds_and_ty {
decl: &ast::FnDecl,
def_id: ast::DefId,
ast_generics: &ast::Generics,
- abis: AbiSet)
+ abi: abi::Abi)
-> ty::ty_param_bounds_and_ty {
for i in decl.inputs.iter() {
let t_fn = ty::mk_bare_fn(
ccx.tcx,
ty::BareFnTy {
- abis: abis,
+ abi: abi,
purity: ast::UnsafeFn,
sig: ty::FnSig {binder_id: def_id.node,
inputs: input_tys,
use middle::typeck::infer::resolve::try_resolve_tvar_shallow;
use util::common::indenter;
+use syntax::abi;
use syntax::ast::MutImmutable;
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<'f>(CombineFields<'f>);
+pub struct Coerce<'f>(pub CombineFields<'f>);
impl<'f> Coerce<'f> {
pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> {
debug!("coerce_from_bare_fn(a={}, b={})",
a.inf_str(self.get_ref().infcx), b.inf_str(self.get_ref().infcx));
- if !fn_ty_a.abis.is_rust() || fn_ty_a.purity != ast::ImpureFn {
+ if fn_ty_a.abi != abi::Rust || fn_ty_a.purity != ast::ImpureFn {
return self.subtype(a, b);
}
use syntax::ast::{Onceness, Purity};
use syntax::ast;
use syntax::owned_slice::OwnedSlice;
-use syntax::abi::AbiSet;
+use syntax::abi;
pub trait Combine {
fn infcx<'a>(&'a self) -> &'a InferCtxt<'a>;
fn bare_fn_tys(&self, a: &ty::BareFnTy,
b: &ty::BareFnTy) -> cres<ty::BareFnTy> {
let purity = if_ok!(self.purities(a.purity, b.purity));
- let abi = if_ok!(self.abis(a.abis, b.abis));
+ let abi = if_ok!(self.abi(a.abi, b.abi));
let sig = if_ok!(self.fn_sigs(&a.sig, &b.sig));
Ok(ty::BareFnTy {purity: purity,
- abis: abi,
+ abi: abi,
sig: sig})
}
fn purities(&self, a: Purity, b: Purity) -> cres<Purity>;
- fn abis(&self, a: AbiSet, b: AbiSet) -> cres<AbiSet> {
+ fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<abi::Abi> {
if a == b {
Ok(a)
} else {
use util::common::{indenter};
use util::ppaux::mt_to_str;
-pub struct Glb<'f>(CombineFields<'f>); // "greatest lower bound" (common subtype)
+pub struct Glb<'f>(pub CombineFields<'f>); // "greatest lower bound" (common subtype)
impl<'f> Glb<'f> {
pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> { let Glb(ref v) = *self; v }
use syntax::ast::{Onceness, Purity};
use util::ppaux::mt_to_str;
-pub struct Lub<'f>(CombineFields<'f>); // least-upper-bound: common supertype
+pub struct Lub<'f>(pub CombineFields<'f>); // least-upper-bound: common supertype
impl<'f> Lub<'f> {
pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> { let Lub(ref v) = *self; v }
use syntax::ast::{Onceness, Purity};
-pub struct Sub<'f>(CombineFields<'f>); // "subtype", "subregion" etc
+pub struct Sub<'f>(pub CombineFields<'f>); // "subtype", "subregion" etc
impl<'f> Sub<'f> {
pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> { let Sub(ref v) = *self; v }
}
let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy {
purity: ast::ImpureFn,
- abis: abi::AbiSet::Rust(),
+ abi: abi::Rust,
sig: ty::FnSig {
binder_id: main_id,
inputs: Vec::new(),
let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy {
purity: ast::ImpureFn,
- abis: abi::AbiSet::Rust(),
+ abi: abi::Rust,
sig: ty::FnSig {
binder_id: start_id,
inputs: vec!(
use middle::ty;
use middle::typeck;
-use syntax::abi::AbiSet;
+use syntax::abi;
use syntax::ast_map;
use syntax::codemap::{Span, Pos};
use syntax::parse::token;
}
fn bare_fn_to_str(cx: &ctxt,
purity: ast::Purity,
- abis: AbiSet,
+ abi: abi::Abi,
ident: Option<ast::Ident>,
sig: &ty::FnSig)
-> ~str {
- let mut s = if abis.is_rust() {
+ let mut s = if abi == abi::Rust {
~""
} else {
- format!("extern {} ", abis.to_str())
+ format!("extern {} ", abi.to_str())
};
match purity {
closure_to_str(cx, *f)
}
ty_bare_fn(ref f) => {
- bare_fn_to_str(cx, f.purity, f.abis, None, &f.sig)
+ bare_fn_to_str(cx, f.purity, f.abi, None, &f.sig)
}
ty_infer(infer_ty) => infer_ty.to_str(),
ty_err => ~"[type error]",
impl Repr for ty::BareFnTy {
fn repr(&self, tcx: &ctxt) -> ~str {
- format!("BareFnTy \\{purity: {:?}, abis: {}, sig: {}\\}",
+ format!("BareFnTy \\{purity: {:?}, abi: {}, sig: {}\\}",
self.purity,
- self.abis.to_str(),
+ self.abi.to_str(),
self.sig.repr(tcx))
}
}
}
}
-impl Repr for AbiSet {
+impl Repr for abi::Abi {
fn repr(&self, _tcx: &ctxt) -> ~str {
self.to_str()
}
}
-impl UserString for AbiSet {
+impl UserString for abi::Abi {
fn user_string(&self, _tcx: &ctxt) -> ~str {
self.to_str()
}
type_params: Vec::new(),
},
decl: self.decl.clean(),
- abi: self.abis.to_str(),
+ abi: self.abi.to_str(),
}
}
}
/// Wrapper struct which will emit the HTML-escaped version of the contained
/// string when passed to a format string.
-pub struct Escape<'a>(&'a str);
+pub struct Escape<'a>(pub &'a str);
impl<'a> fmt::Show for Escape<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
/// Helper to render an optional visibility with a space after it (if the
/// visibility is preset)
-pub struct VisSpace(Option<ast::Visibility>);
+pub struct VisSpace(pub Option<ast::Visibility>);
/// Similarly to VisSpace, this structure is used to render a purity with a
/// space after it.
-pub struct PuritySpace(ast::Purity);
+pub struct PuritySpace(pub ast::Purity);
/// Wrapper struct for properly emitting a method declaration.
-pub struct Method<'a>(&'a clean::SelfTy, &'a clean::FnDecl);
+pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
impl VisSpace {
pub fn get(&self) -> Option<ast::Visibility> {
/// A unit struct which has the `fmt::Show` trait implemented. When
/// formatted, this struct will emit the HTML corresponding to the rendered
/// version of the contained markdown string.
-pub struct Markdown<'a>(&'a str);
+pub struct Markdown<'a>(pub &'a str);
/// A unit struct like `Markdown`, that renders the markdown with a
/// table of contents.
-pub struct MarkdownWithToc<'a>(&'a str);
+pub struct MarkdownWithToc<'a>(pub &'a str);
static OUTPUT_UNIT: libc::size_t = 64;
static MKDEXT_NO_INTRA_EMPHASIS: libc::c_uint = 1 << 0;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![crate_id = "rustdoc#0.10"]
+#![crate_id = "rustdoc#0.11-pre"]
#![desc = "rustdoc, the Rust documentation extractor"]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
let markdown_input = input.ends_with(".md") || input.ends_with(".markdown");
let output = matches.opt_str("o").map(|s| Path::new(s));
+ let cfgs = matches.opt_strs("cfg");
match (should_test, markdown_input) {
(true, true) => {
libs,
test_args.move_iter().collect())
}
- (true, false) => return test::run(input, libs, test_args),
+ (true, false) => return test::run(input, cfgs.move_iter().collect(),
+ libs, test_args),
(false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
&matches),
use rustc::driver::driver;
use rustc::driver::session;
use rustc::metadata::creader::Loader;
+use syntax::ast;
+use syntax::codemap::{CodeMap, dummy_spanned};
use syntax::diagnostic;
-use syntax::codemap::CodeMap;
+use syntax::parse::token;
use core;
use clean;
use passes;
use visit_ast::RustdocVisitor;
-pub fn run(input: &str, libs: HashSet<Path>, mut test_args: Vec<~str>) -> int {
+pub fn run(input: &str, cfgs: Vec<~str>,
+ libs: HashSet<Path>, mut test_args: Vec<~str>) -> int {
let input_path = Path::new(input);
let input = driver::FileInput(input_path.clone());
Some(input_path),
span_diagnostic_handler);
- let cfg = driver::build_configuration(&sess);
+ let mut cfg = driver::build_configuration(&sess);
+ cfg.extend(cfgs.move_iter().map(|cfg_| {
+ let cfg_ = token::intern_and_get_ident(cfg_);
+ @dummy_spanned(ast::MetaWord(cfg_))
+ }));
let krate = driver::phase_1_parse_input(&sess, cfg, &input);
let (krate, _) = driver::phase_2_configure_and_expand(&sess, &mut Loader::new(&sess), krate,
&from_str("rustdoc-test").unwrap());
fn maketest(s: &str, cratename: &str, loose_feature_gating: bool) -> ~str {
let mut prog = ~r"
-#[deny(warnings)];
-#[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
-
-// FIXME: remove when ~[] disappears from tests.
-#[allow(deprecated_owned_vector)];
+#![deny(warnings)]
+#![allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)]
";
if loose_feature_gating {
// FIXME #12773: avoid inserting these when the tutorial & manual
// etc. have been updated to not use them so prolifically.
- prog.push_str("#[ feature(macro_rules, globs, struct_variant, managed_boxes) ];\n");
+ prog.push_str("#![feature(macro_rules, globs, struct_variant, managed_boxes) ]\n");
}
if !s.contains("extern crate") {
//! Rust AST Visitor. Extracts useful information and massages it into a form
//! usable for clean
-use syntax::abi::AbiSet;
+use syntax::abi;
use syntax::ast;
use syntax::ast_util;
use syntax::ast_map;
}
pub fn visit_fn(&mut self, item: &ast::Item, fd: &ast::FnDecl,
- purity: &ast::Purity, _abi: &AbiSet,
+ purity: &ast::Purity, _abi: &abi::Abi,
gen: &ast::Generics) -> Function {
debug!("Visiting fn");
Function {
*/
-#![crate_id = "rustuv#0.10"]
+#![crate_id = "rustuv#0.11-pre"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
//! An example version number with all five components is
//! `0.8.1-rc.3.0+20130922.linux`.
-#![crate_id = "semver#0.10"]
+#![crate_id = "semver#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
/// Contains configuration parameters for `to_base64`.
pub struct Config {
/// Character set to use
- char_set: CharacterSet,
+ pub char_set: CharacterSet,
/// True to pad output with `=` characters
- pad: bool,
+ pub pad: bool,
/// `Some(len)` to wrap lines at `len`, `None` to disable line wrapping
- line_length: Option<uint>
+ pub line_length: Option<uint>
}
/// Configuration for RFC 4648 standard base64 encoding
Core encoding and decoding interfaces.
*/
-#![crate_id = "serialize#0.10"]
+#![crate_id = "serialize#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
//!
//! use std::prelude::*;
-#![crate_id = "std#0.10"]
+#![crate_id = "std#0.11-pre"]
#![comment = "The Rust standard library"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")]
#![feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
- simd, linkage, default_type_params, phase)]
+ simd, linkage, default_type_params, phase, concat_idents)]
// Don't link to std. We are std.
#![no_std]
// #![deny(missing_doc)] // NOTE: uncomment after a stage0 snap
#![allow(missing_doc)] // NOTE: remove after a stage0 snap
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
+#![allow(unknown_features)] // NOTE: remove after a stage0 snap
// When testing libstd, bring in libuv as the I/O backend so tests can print
// things and all of the std::io tests have an I/O interface to run on top
pub use to_str;
pub use ty;
pub use unstable;
+ pub use vec;
}
if log_enabled!($lvl) { println!($($args)*) }
)
)
+
+/// Built-in macros to the compiler itself.
+///
+/// These macros do not have any corresponding definition with a `macro_rules!`
+/// macro, but are documented here. Their implementations can be found hardcoded
+/// into libsyntax itself.
+#[cfg(dox)]
+pub mod builtin {
+ /// The core macro for formatted string creation & output.
+ ///
+ /// This macro takes as its first argument a callable expression which will
+ /// receive as its first argument a value of type `&fmt::Arguments`. This
+ /// value can be passed to the functions in `std::fmt` for performing useful
+ /// functions. All other formatting macros (`format!`, `write!`,
+ /// `println!`, etc) are proxied through this one.
+ ///
+ /// For more information, see the documentation in `std::fmt`.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// use std::fmt;
+ ///
+ /// let s = format_args!(fmt::format, "hello {}", "world");
+ /// assert_eq!(s, format!("hello {}", "world"));
+ ///
+ /// format_args!(|args| {
+ /// // pass `args` to another function, etc.
+ /// }, "hello {}", "world");
+ /// ```
+ #[macro_export]
+ macro_rules! format_args( ($closure:expr, $fmt:expr $($args:tt)*) => ({
+ /* compiler built-in */
+ }) )
+
+ /// Inspect an environment variable at compile time.
+ ///
+ /// This macro will expand to the value of the named environment variable at
+ /// compile time, yielding an expression of type `&'static str`.
+ ///
+ /// If the environment variable is not defined, then a compilation error
+ /// will be emitted. To not emit a compile error, use the `option_env!`
+ /// macro instead.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// let user: &'static str = env!("USER");
+ /// println!("the user who compiled this code is: {}", user);
+ /// ```
+ #[macro_export]
+ macro_rules! env( ($name:expr) => ({ /* compiler built-in */ }) )
+
+ /// Optionally inspect an environment variable at compile time.
+ ///
+ /// If the named environment variable is present at compile time, this will
+ /// expand into an expression of type `Option<&'static str>` whose value is
+ /// `Some` of the value of the environment variable. If the environment
+ /// variable is not present, then this will expand to `None`.
+ ///
+ /// A compile time error is never emitted when using this macro regardless
+ /// of whether the environment variable is present or not.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// let key: Option<&'static str> = option_env!("SECRET_KEY");
+ /// println!("the secret key might be: {}", key);
+ /// ```
+ #[macro_export]
+ macro_rules! option_env( ($name:expr) => ({ /* compiler built-in */ }) )
+
+ /// Concatenate literals into a static byte slice.
+ ///
+ /// This macro takes any number of comma-separated literal expressions,
+ /// yielding an expression of type `&'static [u8]` which is the
+ /// concatenation (left to right) of all the literals in their byte format.
+ ///
+ /// This extension currently only supports string literals, character
+ /// literals, and integers less than 256. The byte slice returned is the
+ /// utf8-encoding of strings and characters.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// let rust = bytes!("r", 'u', "st");
+ /// assert_eq!(rust[1], 'u' as u8);
+ /// ```
+ #[macro_export]
+ macro_rules! bytes( ($($e:expr),*) => ({ /* compiler built-in */ }) )
+
+ /// Concatenate identifiers into one identifier.
+ ///
+ /// This macro takes any number of comma-separated identifiers, and
+ /// concatenates them all into one, yielding an expression which is a new
+ /// identifier. Note that hygiene makes it such that this macro cannot
+ /// capture local variables, and macros are only allowed in item,
+ /// statement or expression position, meaning this macro may be difficult to
+ /// use in some situations.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// fn foobar() -> int { 23 }
+ ///
+ /// let f = concat_idents!(foo, bar);
+ /// println!("{}", f());
+ /// ```
+ #[macro_export]
+ macro_rules! concat_idents( ($($e:ident),*) => ({ /* compiler built-in */ }) )
+
+ /// Concatenates literals into a static string slice.
+ ///
+ /// This macro takes any number of comma-separated literals, yielding an
+ /// expression of type `&'static str` which represents all of the literals
+ /// concatenated left-to-right.
+ ///
+ /// Integer and floating point literals are stringified in order to be
+ /// concatenated.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// let s = concat!("test", 10, 'b', true);
+ /// assert_eq!(s, "test10btrue");
+ /// ```
+ #[macro_export]
+ macro_rules! concat( ($($e:expr),*) => ({ /* compiler built-in */ }) )
+
+ /// A macro which expands to the line number on which it was invoked.
+ ///
+ /// The expanded expression has type `uint`, and the returned line is not
+ /// the invocation of the `line!()` macro itself, but rather the first macro
+ /// invocation leading up to the invocation of the `line!()` macro.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// let current_line = line!();
+ /// println!("defined on line: {}", current_line);
+ /// ```
+ #[macro_export]
+ macro_rules! line( () => ({ /* compiler built-in */ }) )
+
+ /// A macro which expands to the column number on which it was invoked.
+ ///
+ /// The expanded expression has type `uint`, and the returned column is not
+ /// the invocation of the `col!()` macro itself, but rather the first macro
+ /// invocation leading up to the invocation of the `col!()` macro.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// let current_col = col!();
+ /// println!("defined on column: {}", current_col);
+ /// ```
+ #[macro_export]
+ macro_rules! col( () => ({ /* compiler built-in */ }) )
+
+ /// A macro which expands to the file name from which it was invoked.
+ ///
+ /// The expanded expression has type `&'static str`, and the returned file
+ /// is not the invocation of the `file!()` macro itself, but rather the
+ /// first macro invocation leading up to the invocation of the `file!()`
+ /// macro.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// let this_file = file!();
+ /// println!("defined in file: {}", this_file);
+ /// ```
+ #[macro_export]
+ macro_rules! file( () => ({ /* compiler built-in */ }) )
+
+ /// A macro which stringifies its argument.
+ ///
+ /// This macro will yield an expression of type `&'static str` which is the
+ /// stringification of all the tokens passed to the macro. No restrictions
+ /// are placed on the syntax of the macro invocation itself.
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// let one_plus_one = stringify!(1 + 1);
+ /// assert_eq!(one_plus_one, "1 + 1");
+ /// ```
+ #[macro_export]
+ macro_rules! stringify( ($t:tt) => ({ /* compiler built-in */ }) )
+
+ /// Includes a utf8-encoded file as a string.
+ ///
+ /// This macro will yield an expression of type `&'static str` which is the
+ /// contents of the filename specified. The file is located relative to the
+ /// current file (similarly to how modules are found),
+ ///
+ /// # Example
+ ///
+ /// ```rust,ignore
+ /// let secret_key = include_str!("secret-key.ascii");
+ /// ```
+ #[macro_export]
+ macro_rules! include_str( ($file:expr) => ({ /* compiler built-in */ }) )
+
+ /// Includes a file as a byte slice.
+ ///
+ /// This macro will yield an expression of type `&'static [u8]` which is
+ /// the contents of the filename specified. The file is located relative to
+ /// the current file (similarly to how modules are found),
+ ///
+ /// # Example
+ ///
+ /// ```rust,ignore
+ /// let secret_key = include_bin!("secret-key.bin");
+ /// ```
+ #[macro_export]
+ macro_rules! include_bin( ($file:expr) => ({ /* compiler built-in */ }) )
+
+ /// Expands to a string that represents the current module path.
+ ///
+ /// The current module path can be thought of as the hierarchy of modules
+ /// leading back up to the crate root. The first component of the path
+ /// returned is the name of the crate currently being compiled.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// mod test {
+ /// pub fn foo() {
+ /// assert!(module_path!().ends_with("test"));
+ /// }
+ /// }
+ ///
+ /// test::foo();
+ /// ```
+ #[macro_export]
+ macro_rules! module_path( () => ({ /* compiler built-in */ }) )
+
+ /// Boolean evaluation of configuration flags.
+ ///
+ /// In addition to the `#[cfg]` attribute, this macro is provided to allow
+ /// boolean expression evaluation of configuration flags. This frequently
+ /// leads to less duplicated code.
+ ///
+ /// The syntax given to this macro is the same syntax as the `cfg`
+ /// attribute.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// let my_directory = if cfg!(windows) {
+ /// "windows-specific-directory"
+ /// } else {
+ /// "unix-directory"
+ /// };
+ /// ```
+ #[macro_export]
+ macro_rules! cfg( ($cfg:tt) => ({ /* compiler built-in */ }) )
+}
#[cfg(not(test))]
#[lang="exchange_malloc"]
#[inline]
-pub unsafe fn exchange_malloc(size: uint) -> *u8 {
- malloc_raw(size) as *u8
+pub unsafe fn exchange_malloc(size: uint) -> *mut u8 {
+ // The compiler never calls `exchange_free` on ~ZeroSizeType, so zero-size
+ // allocations can point to this `static`. It would be incorrect to use a null
+ // pointer, due to enums assuming types like unique pointers are never null.
+ static EMPTY: () = ();
+
+ if size == 0 {
+ &EMPTY as *() as *mut u8
+ } else {
+ malloc_raw(size)
+ }
}
// FIXME: #7496
}
pub struct GarbageCollector;
-pub struct LocalStorage(Option<local_data::Map>);
+pub struct LocalStorage(pub Option<local_data::Map>);
/// A handle to a blocked task. Usually this means having the ~Task pointer by
/// ownership, but if the task is killable, a killer can steal it at any time.
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
pub fn fetch_sub(&self, val: int, order: Ordering) -> int {
unsafe { atomic_sub(self.v.get(), val, order) }
}
+
+ /// Bitwise and with the current value, returning the previous
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::atomics::{AtomicUint, SeqCst};
+ ///
+ /// let foo = AtomicUint::new(0b101101);
+ /// assert_eq!(0b101101, foo.fetch_and(0b110011, SeqCst));
+ /// assert_eq!(0b100001, foo.load(SeqCst));
+ #[inline]
+ pub fn fetch_and(&self, val: int, order: Ordering) -> int {
+ unsafe { atomic_and(self.v.get(), val, order) }
+ }
+
+ /// Bitwise or with the current value, returning the previous
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::atomics::{AtomicUint, SeqCst};
+ ///
+ /// let foo = AtomicUint::new(0b101101);
+ /// assert_eq!(0b101101, foo.fetch_or(0b110011, SeqCst));
+ /// assert_eq!(0b111111, foo.load(SeqCst));
+ #[inline]
+ pub fn fetch_or(&self, val: int, order: Ordering) -> int {
+ unsafe { atomic_or(self.v.get(), val, order) }
+ }
+
+ /// Bitwise xor with the current value, returning the previous
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::atomics::{AtomicUint, SeqCst};
+ ///
+ /// let foo = AtomicUint::new(0b101101);
+ /// assert_eq!(0b101101, foo.fetch_xor(0b110011, SeqCst));
+ /// assert_eq!(0b011110, foo.load(SeqCst));
+ #[inline]
+ pub fn fetch_xor(&self, val: int, order: Ordering) -> int {
+ unsafe { atomic_xor(self.v.get(), val, order) }
+ }
}
impl AtomicUint {
pub fn fetch_sub(&self, val: uint, order: Ordering) -> uint {
unsafe { atomic_sub(self.v.get(), val, order) }
}
+
+ /// Bitwise and with the current value, returning the previous
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::atomics::{AtomicUint, SeqCst};
+ ///
+ /// let foo = AtomicUint::new(0b101101);
+ /// assert_eq!(0b101101, foo.fetch_and(0b110011, SeqCst));
+ /// assert_eq!(0b100001, foo.load(SeqCst));
+ #[inline]
+ pub fn fetch_and(&self, val: uint, order: Ordering) -> uint {
+ unsafe { atomic_and(self.v.get(), val, order) }
+ }
+
+ /// Bitwise or with the current value, returning the previous
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::atomics::{AtomicUint, SeqCst};
+ ///
+ /// let foo = AtomicUint::new(0b101101);
+ /// assert_eq!(0b101101, foo.fetch_or(0b110011, SeqCst));
+ /// assert_eq!(0b111111, foo.load(SeqCst));
+ #[inline]
+ pub fn fetch_or(&self, val: uint, order: Ordering) -> uint {
+ unsafe { atomic_or(self.v.get(), val, order) }
+ }
+
+ /// Bitwise xor with the current value, returning the previous
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::atomics::{AtomicUint, SeqCst};
+ ///
+ /// let foo = AtomicUint::new(0b101101);
+ /// assert_eq!(0b101101, foo.fetch_xor(0b110011, SeqCst));
+ /// assert_eq!(0b011110, foo.load(SeqCst));
+ #[inline]
+ pub fn fetch_xor(&self, val: uint, order: Ordering) -> uint {
+ unsafe { atomic_xor(self.v.get(), val, order) }
+ }
}
impl<T> AtomicPtr<T> {
assert_eq!(a.load(SeqCst),false);
}
+ #[test]
+ fn uint_and() {
+ let x = AtomicUint::new(0xf731);
+ assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731);
+ assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
+ }
+
+ #[test]
+ fn uint_or() {
+ let x = AtomicUint::new(0xf731);
+ assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731);
+ assert_eq!(x.load(SeqCst), 0xf731 | 0x137f);
+ }
+
+ #[test]
+ fn uint_xor() {
+ let x = AtomicUint::new(0xf731);
+ assert_eq!(x.fetch_xor(0x137f, SeqCst), 0xf731);
+ assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
+ }
+
+ #[test]
+ fn int_and() {
+ let x = AtomicInt::new(0xf731);
+ assert_eq!(x.fetch_and(0x137f, SeqCst), 0xf731);
+ assert_eq!(x.load(SeqCst), 0xf731 & 0x137f);
+ }
+
+ #[test]
+ fn int_or() {
+ let x = AtomicInt::new(0xf731);
+ assert_eq!(x.fetch_or(0x137f, SeqCst), 0xf731);
+ assert_eq!(x.load(SeqCst), 0xf731 | 0x137f);
+ }
+
+ #[test]
+ fn int_xor() {
+ let x = AtomicInt::new(0xf731);
+ assert_eq!(x.fetch_xor(0x137f, SeqCst), 0xf731);
+ assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
+ }
+
static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
static mut S_INT : AtomicInt = INIT_ATOMIC_INT;
static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT;
#[experimental]
#[simd]
-pub struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8);
+pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
+ pub i8, pub i8, pub i8, pub i8,
+ pub i8, pub i8, pub i8, pub i8,
+ pub i8, pub i8, pub i8, pub i8);
#[experimental]
#[simd]
-pub struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
+pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
+ pub i16, pub i16, pub i16, pub i16);
#[experimental]
#[simd]
-pub struct i32x4(i32, i32, i32, i32);
+pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
#[experimental]
#[simd]
-pub struct i64x2(i64, i64);
+pub struct i64x2(pub i64, pub i64);
#[experimental]
#[simd]
-pub struct u8x16(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8);
+pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
+ pub u8, pub u8, pub u8, pub u8,
+ pub u8, pub u8, pub u8, pub u8,
+ pub u8, pub u8, pub u8, pub u8);
#[experimental]
#[simd]
-pub struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16);
+pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
+ pub u16, pub u16, pub u16, pub u16);
#[experimental]
#[simd]
-pub struct u32x4(u32, u32, u32, u32);
+pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
#[experimental]
#[simd]
-pub struct u64x2(u64, u64);
+pub struct u64x2(pub u64, pub u64);
#[experimental]
#[simd]
-pub struct f32x4(f32, f32, f32, f32);
+pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
#[experimental]
#[simd]
-pub struct f64x2(f64, f64);
+pub struct f64x2(pub f64, pub f64);
impl<T:Clone> Clone for Vec<T> {
fn clone(&self) -> Vec<T> {
- let mut vector = Vec::with_capacity(self.len());
- for element in self.iter() {
- vector.push((*element).clone())
+ self.iter().map(|x| x.clone()).collect()
+ }
+
+ fn clone_from(&mut self, other: &Vec<T>) {
+ // drop anything in self that will not be overwritten
+ if self.len() > other.len() {
+ self.truncate(other.len())
}
- vector
+
+ // reuse the contained values' allocations/resources.
+ for (place, thing) in self.mut_iter().zip(other.iter()) {
+ place.clone_from(thing)
+ }
+
+ // self.len <= other.len due to the truncate above, so the
+ // slice here is always in-bounds.
+ let len = self.len();
+ self.extend(other.slice_from(len).iter().map(|x| x.clone()));
}
}
assert!(values == Vec::from_slice([2u8, 3, 5, 6, 7]));
}
+
+ #[test]
+ fn test_clone() {
+ let v: Vec<int> = vec!();
+ let w = vec!(1, 2, 3);
+
+ assert_eq!(v, v.clone());
+
+ let z = w.clone();
+ assert_eq!(w, z);
+ // they should be disjoint in memory.
+ assert!(w.as_ptr() != z.as_ptr())
+ }
+
+ #[test]
+ fn test_clone_from() {
+ let mut v = vec!();
+ let three = vec!(~1, ~2, ~3);
+ let two = vec!(~4, ~5);
+ // zero, long
+ v.clone_from(&three);
+ assert_eq!(v, three);
+
+ // equal
+ v.clone_from(&three);
+ assert_eq!(v, three);
+
+ // long, short
+ v.clone_from(&two);
+ assert_eq!(v, two);
+
+ // short, long
+ v.clone_from(&three);
+ assert_eq!(v, three)
+ }
}
* Concurrency-enabled mechanisms and primitives.
*/
-#![crate_id = "sync#0.10"]
+#![crate_id = "sync#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
// except according to those terms.
use std::fmt;
-use std::fmt::Show;
#[deriving(Eq)]
pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, }
-#[deriving(Eq, TotalEq, Hash)]
+#[deriving(Eq, TotalEq, Hash, Encodable, Decodable, Clone)]
pub enum Abi {
// NB: This ordering MUST match the AbiDatas array below.
// (This is ensured by the test indices_are_correct().)
Archs(u32) // Multiple architectures (bitset)
}
-#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
-pub struct AbiSet {
- bits: u32 // each bit represents one of the abis below
-}
-
static AbiDatas: &'static [AbiData] = &[
// Platform-specific ABIs
AbiData {abi: Cdecl, name: "cdecl", abi_arch: Archs(IntelBits)},
self.data().name
}
- pub fn for_target(&self, os: Os, arch: Architecture) -> Abi {
- match (*self, os, arch) {
+ pub fn for_target(&self, os: Os, arch: Architecture) -> Option<Abi> {
+ // If this ABI isn't actually for the specified architecture, then we
+ // short circuit early
+ match self.data().abi_arch {
+ Archs(a) if a & arch.bit() == 0 => return None,
+ Archs(_) | RustArch | AllArch => {}
+ }
+ // Transform this ABI as appropriate for the requested os/arch
+ // combination.
+ Some(match (*self, os, arch) {
(System, OsWin32, X86) => Stdcall,
(System, _, _) => C,
(me, _, _) => me,
- }
+ })
}
}
}
}
-impl AbiSet {
- pub fn from(abi: Abi) -> AbiSet {
- AbiSet { bits: (1 << abi.index()) }
- }
-
- #[inline]
- pub fn Rust() -> AbiSet {
- AbiSet::from(Rust)
- }
-
- #[inline]
- pub fn C() -> AbiSet {
- AbiSet::from(C)
- }
-
- #[inline]
- pub fn Intrinsic() -> AbiSet {
- AbiSet::from(RustIntrinsic)
- }
-
- pub fn default() -> AbiSet {
- AbiSet::C()
- }
-
- pub fn empty() -> AbiSet {
- AbiSet { bits: 0 }
- }
-
- #[inline]
- pub fn is_rust(&self) -> bool {
- self.bits == 1 << Rust.index()
- }
-
- #[inline]
- pub fn is_c(&self) -> bool {
- self.bits == 1 << C.index()
- }
-
- #[inline]
- pub fn is_intrinsic(&self) -> bool {
- self.bits == 1 << RustIntrinsic.index()
- }
-
- pub fn contains(&self, abi: Abi) -> bool {
- (self.bits & (1 << abi.index())) != 0
- }
-
- pub fn subset_of(&self, other_abi_set: AbiSet) -> bool {
- (self.bits & other_abi_set.bits) == self.bits
- }
-
- pub fn add(&mut self, abi: Abi) {
- self.bits |= 1 << abi.index();
- }
-
- pub fn each(&self, op: |abi: Abi| -> bool) -> bool {
- each_abi(|abi| !self.contains(abi) || op(abi))
- }
-
- pub fn is_empty(&self) -> bool {
- self.bits == 0
- }
-
- pub fn for_target(&self, os: Os, arch: Architecture) -> Option<Abi> {
- // NB---Single platform ABIs come first
-
- let mut res = None;
-
- self.each(|abi| {
- let data = abi.data();
- match data.abi_arch {
- Archs(a) if (a & arch.bit()) != 0 => { res = Some(abi); false }
- Archs(_) => { true }
- RustArch | AllArch => { res = Some(abi); false }
- }
- });
-
- res.map(|r| r.for_target(os, arch))
- }
-
- pub fn check_valid(&self) -> Option<(Abi, Abi)> {
- let mut abis = Vec::new();
- self.each(|abi| { abis.push(abi); true });
-
- for (i, abi) in abis.iter().enumerate() {
- let data = abi.data();
- for other_abi in abis.slice(0, i).iter() {
- let other_data = other_abi.data();
- debug!("abis=({:?},{:?}) datas=({:?},{:?})",
- abi, data.abi_arch,
- other_abi, other_data.abi_arch);
- match (&data.abi_arch, &other_data.abi_arch) {
- (&AllArch, &AllArch) => {
- // Two cross-architecture ABIs
- return Some((*abi, *other_abi));
- }
- (_, &RustArch) |
- (&RustArch, _) => {
- // Cannot combine Rust or Rust-Intrinsic with
- // anything else.
- return Some((*abi, *other_abi));
- }
- (&Archs(is), &Archs(js)) if (is & js) != 0 => {
- // Two ABIs for same architecture
- return Some((*abi, *other_abi));
- }
- _ => {}
- }
- }
- }
-
- return None;
- }
-}
-
impl fmt::Show for Abi {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.data().name.fmt(f)
- }
-}
-
-impl fmt::Show for AbiSet {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(f.buf, "\""));
- let mut first = true;
- self.each(|abi| {
- if first { first = false; }
- else { let _ = write!(f.buf, " "); }
- let _ = write!(f.buf, "{}", abi.data().name);
- true
- });
- write!(f.buf, "\"")
+ write!(f.buf, "\"{}\"", self.name())
}
}
assert!(abi.is_none());
}
-#[cfg(test)]
-fn cannot_combine(n: Abi, m: Abi) {
- let mut set = AbiSet::empty();
- set.add(n);
- set.add(m);
- match set.check_valid() {
- Some((a, b)) => {
- assert!((n == a && m == b) ||
- (m == a && n == b));
- }
- None => {
- fail!("invalid match not detected");
- }
- }
-}
-
-#[cfg(test)]
-fn can_combine(n: Abi, m: Abi) {
- let mut set = AbiSet::empty();
- set.add(n);
- set.add(m);
- match set.check_valid() {
- Some((_, _)) => {
- fail!("valid match declared invalid");
- }
- None => {}
- }
-}
-
-#[test]
-fn cannot_combine_cdecl_and_stdcall() {
- cannot_combine(Cdecl, Stdcall);
-}
-
-#[test]
-fn cannot_combine_c_and_rust() {
- cannot_combine(C, Rust);
-}
-
-#[test]
-fn cannot_combine_rust_and_cdecl() {
- cannot_combine(Rust, Cdecl);
-}
-
-#[test]
-fn cannot_combine_rust_intrinsic_and_cdecl() {
- cannot_combine(RustIntrinsic, Cdecl);
-}
-
-#[test]
-fn can_combine_system_and_cdecl() {
- can_combine(System, Cdecl);
-}
-
-#[test]
-fn can_combine_c_and_stdcall() {
- can_combine(C, Stdcall);
-}
-
-#[test]
-fn can_combine_aapcs_and_stdcall() {
- can_combine(Aapcs, Stdcall);
-}
-
-#[test]
-fn abi_to_str_stdcall_aaps() {
- let mut set = AbiSet::empty();
- set.add(Aapcs);
- set.add(Stdcall);
- assert!(set.to_str() == ~"\"stdcall aapcs\"");
-}
-
-#[test]
-fn abi_to_str_c_aaps() {
- let mut set = AbiSet::empty();
- set.add(Aapcs);
- set.add(C);
- debug!("set = {}", set.to_str());
- assert!(set.to_str() == ~"\"aapcs C\"");
-}
-
-#[test]
-fn abi_to_str_rust() {
- let mut set = AbiSet::empty();
- set.add(Rust);
- debug!("set = {}", set.to_str());
- assert!(set.to_str() == ~"\"Rust\"");
-}
-
#[test]
fn indices_are_correct() {
for (i, abi_data) in AbiDatas.iter().enumerate() {
assert_eq!(ArmBits, bits);
}
-#[cfg(test)]
-fn get_arch(abis: &[Abi], os: Os, arch: Architecture) -> Option<Abi> {
- let mut set = AbiSet::empty();
- for &abi in abis.iter() {
- set.add(abi);
- }
- set.for_target(os, arch)
-}
-
-#[test]
-fn pick_multiplatform() {
- assert_eq!(get_arch([C, Cdecl], OsLinux, X86), Some(Cdecl));
- assert_eq!(get_arch([C, Cdecl], OsLinux, X86_64), Some(Cdecl));
- assert_eq!(get_arch([C, Cdecl], OsLinux, Arm), Some(C));
-}
-
#[test]
fn pick_uniplatform() {
- assert_eq!(get_arch([Stdcall], OsLinux, X86), Some(Stdcall));
- assert_eq!(get_arch([Stdcall], OsLinux, Arm), None);
- assert_eq!(get_arch([System], OsLinux, X86), Some(C));
- assert_eq!(get_arch([System], OsWin32, X86), Some(Stdcall));
- assert_eq!(get_arch([System], OsWin32, X86_64), Some(C));
- assert_eq!(get_arch([System], OsWin32, Arm), Some(C));
- assert_eq!(get_arch([Stdcall], OsWin32, X86), Some(Stdcall));
- assert_eq!(get_arch([Stdcall], OsWin32, X86_64), Some(Stdcall));
+ assert_eq!(Stdcall.for_target(OsLinux, X86), Some(Stdcall));
+ assert_eq!(Stdcall.for_target(OsLinux, Arm), None);
+ assert_eq!(System.for_target(OsLinux, X86), Some(C));
+ assert_eq!(System.for_target(OsWin32, X86), Some(Stdcall));
+ assert_eq!(System.for_target(OsWin32, X86_64), Some(C));
+ assert_eq!(System.for_target(OsWin32, Arm), Some(C));
+ assert_eq!(Stdcall.for_target(OsWin32, X86), Some(Stdcall));
+ assert_eq!(Stdcall.for_target(OsWin32, X86_64), Some(Stdcall));
}
// The Rust abstract syntax tree.
use codemap::{Span, Spanned, DUMMY_SP};
-use abi::AbiSet;
+use abi::Abi;
use ast_util;
use owned_slice::OwnedSlice;
use parse::token::{InternedString, special_idents, str_to_ident};
ExprVstore(@Expr, ExprVstore),
// First expr is the place; second expr is the value.
ExprBox(@Expr, @Expr),
- ExprVec(Vec<@Expr> , Mutability),
- ExprCall(@Expr, Vec<@Expr> ),
- ExprMethodCall(Ident, Vec<P<Ty>> , Vec<@Expr> ),
- ExprTup(Vec<@Expr> ),
+ ExprVec(Vec<@Expr>, Mutability),
+ ExprCall(@Expr, Vec<@Expr>),
+ ExprMethodCall(Ident, Vec<P<Ty>>, Vec<@Expr>),
+ ExprTup(Vec<@Expr>),
ExprBinary(BinOp, @Expr, @Expr),
ExprUnary(UnOp, @Expr),
ExprLit(@Lit),
// Conditionless loop (can be exited with break, cont, or ret)
// FIXME #6993: change to Option<Name>
ExprLoop(P<Block>, Option<Ident>),
- ExprMatch(@Expr, Vec<Arm> ),
+ ExprMatch(@Expr, Vec<Arm>),
ExprFnBlock(P<FnDecl>, P<Block>),
ExprProc(P<FnDecl>, P<Block>),
ExprBlock(P<Block>),
ExprAssign(@Expr, @Expr),
ExprAssignOp(BinOp, @Expr, @Expr),
- ExprField(@Expr, Ident, Vec<P<Ty>> ),
+ ExprField(@Expr, Ident, Vec<P<Ty>>),
ExprIndex(@Expr, @Expr),
/// Expression that looks like a "name". For example,
#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct BareFnTy {
pub purity: Purity,
- pub abis: AbiSet,
+ pub abi: Abi,
pub lifetimes: Vec<Lifetime>,
pub decl: P<FnDecl>
}
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct ForeignMod {
- pub abis: AbiSet,
+ pub abi: Abi,
pub view_items: Vec<ViewItem>,
pub items: Vec<@ForeignItem>,
}
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Item_ {
ItemStatic(P<Ty>, Mutability, @Expr),
- ItemFn(P<FnDecl>, Purity, AbiSet, Generics, P<Block>),
+ ItemFn(P<FnDecl>, Purity, Abi, Generics, P<Block>),
ItemMod(Mod),
ItemForeignMod(ForeignMod),
ItemTy(P<Ty>, Generics),
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use abi::AbiSet;
+use abi;
use ast::*;
use ast_util;
use codemap::Span;
// HACK(eddyb) move this into libstd (value wrapper for slice::Items).
#[deriving(Clone)]
-pub struct Values<'a, T>(slice::Items<'a, T>);
+pub struct Values<'a, T>(pub slice::Items<'a, T>);
impl<'a, T: Copy> Iterator<T> for Values<'a, T> {
fn next(&mut self) -> Option<T> {
}
}
- pub fn get_foreign_abis(&self, id: NodeId) -> AbiSet {
+ pub fn get_foreign_abi(&self, id: NodeId) -> abi::Abi {
let parent = self.get_parent(id);
- let abis = match self.find_entry(parent) {
+ let abi = match self.find_entry(parent) {
Some(EntryItem(_, i)) => match i.node {
- ItemForeignMod(ref nm) => Some(nm.abis),
+ ItemForeignMod(ref nm) => Some(nm.abi),
_ => None
},
// Wrong but OK, because the only inlined foreign items are intrinsics.
- Some(RootInlinedParent(_)) => Some(AbiSet::Intrinsic()),
+ Some(RootInlinedParent(_)) => Some(abi::RustIntrinsic),
_ => None
};
- match abis {
- Some(abis) => abis,
+ match abi {
+ Some(abi) => abi,
None => fail!("expected foreign mod or inlined parent, found {}",
self.node_to_str(parent))
}
/// A byte offset. Keep this small (currently 32-bits), as AST contains
/// a lot of them.
#[deriving(Clone, Eq, TotalEq, Hash, Ord, Show)]
-pub struct BytePos(u32);
+pub struct BytePos(pub u32);
/// A character offset. Because of multibyte utf8 characters, a byte offset
/// is not equivalent to a character offset. The CodeMap will convert BytePos
/// values to CharPos values as necessary.
#[deriving(Eq, Hash, Ord, Show)]
-pub struct CharPos(uint);
+pub struct CharPos(pub uint);
// FIXME: Lots of boilerplate in these impls, but so far my attempts to fix
// have been unsuccessful
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use abi::AbiSet;
+use abi;
use ast::{P, Ident};
use ast;
use ast_util;
Vec::new(),
ast::ItemFn(self.fn_decl(inputs, output),
ast::ImpureFn,
- AbiSet::Rust(),
+ abi::Rust,
generics,
body))
}
TyBareFn(@BareFnTy {
lifetimes: f.lifetimes.iter().map(|l| fold_lifetime(l, self)).collect(),
purity: f.purity,
- abis: f.abis,
+ abi: f.abi,
decl: self.fold_fn_decl(f.decl)
})
}
fn fold_foreign_mod(&mut self, nm: &ForeignMod) -> ForeignMod {
ast::ForeignMod {
- abis: nm.abis,
+ abi: nm.abi,
view_items: nm.view_items
.iter()
.map(|x| self.fold_view_item(x))
*/
-#![crate_id = "syntax#0.10"]
+#![crate_id = "syntax#0.11-pre"]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
variadic: false
}),
ast::ImpureFn,
- abi::AbiSet::Rust(),
+ abi::Rust,
ast::Generics{ // no idea on either of these:
lifetimes: Vec::new(),
ty_params: OwnedSlice::empty(),
#![macro_escape]
use abi;
-use abi::AbiSet;
use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil};
use ast::{BareFnTy, ClosureTy};
use ast::{RegionTyParamBound, TraitTyParamBound};
*/
- let abis = if self.eat_keyword(keywords::Extern) {
- self.parse_opt_abis().unwrap_or(AbiSet::C())
+ let abi = if self.eat_keyword(keywords::Extern) {
+ self.parse_opt_abi().unwrap_or(abi::C)
} else {
- AbiSet::Rust()
+ abi::Rust
};
let purity = self.parse_unsafety();
self.expect_keyword(keywords::Fn);
let (decl, lifetimes) = self.parse_ty_fn_decl(true);
return TyBareFn(@BareFnTy {
- abis: abis,
+ abi: abi,
purity: purity,
lifetimes: lifetimes,
decl: decl
}
// parse an item-position function declaration.
- fn parse_item_fn(&mut self, purity: Purity, abis: AbiSet) -> ItemInfo {
+ fn parse_item_fn(&mut self, purity: Purity, abi: abi::Abi) -> ItemInfo {
let (ident, generics) = self.parse_fn_header();
let decl = self.parse_fn_decl(false);
let (inner_attrs, body) = self.parse_inner_attrs_and_block();
- (ident, ItemFn(decl, purity, abis, generics, body), Some(inner_attrs))
+ (ident, ItemFn(decl, purity, abi, generics, body), Some(inner_attrs))
}
// parse a method in a trait impl, starting with `attrs` attributes.
// at this point, this is essentially a wrapper for
// parse_foreign_items.
fn parse_foreign_mod_items(&mut self,
- abis: AbiSet,
+ abi: abi::Abi,
first_item_attrs: Vec<Attribute> )
-> ForeignMod {
let ParsedItemsAndViewItems {
}
assert!(self.token == token::RBRACE);
ast::ForeignMod {
- abis: abis,
+ abi: abi,
view_items: view_items,
items: foreign_items
}
/// extern {}
fn parse_item_foreign_mod(&mut self,
lo: BytePos,
- opt_abis: Option<AbiSet>,
+ opt_abi: Option<abi::Abi>,
visibility: Visibility,
attrs: Vec<Attribute> )
-> ItemOrViewItem {
self.expect(&token::LBRACE);
- let abis = opt_abis.unwrap_or(AbiSet::C());
+ let abi = opt_abi.unwrap_or(abi::C);
let (inner, next) = self.parse_inner_attrs_and_next();
- let m = self.parse_foreign_mod_items(abis, next);
+ let m = self.parse_foreign_mod_items(abi, next);
self.expect(&token::RBRACE);
let item = self.mk_item(lo,
// Parses a string as an ABI spec on an extern type or module. Consumes
// the `extern` keyword, if one is found.
- fn parse_opt_abis(&mut self) -> Option<AbiSet> {
+ fn parse_opt_abi(&mut self) -> Option<abi::Abi> {
match self.token {
- token::LIT_STR(s)
- | token::LIT_STR_RAW(s, _) => {
+ token::LIT_STR(s) | token::LIT_STR_RAW(s, _) => {
self.bump();
let identifier_string = token::get_ident(s);
let the_string = identifier_string.get();
- let mut abis = AbiSet::empty();
- for word in the_string.words() {
- match abi::lookup(word) {
- Some(abi) => {
- if abis.contains(abi) {
- self.span_err(
- self.span,
- format!("ABI `{}` appears twice",
- word));
- } else {
- abis.add(abi);
- }
- }
-
- None => {
- self.span_err(
- self.span,
- format!("illegal ABI: \
- expected one of [{}], \
- found `{}`",
- abi::all_names().connect(", "),
- word));
- }
- }
- }
- Some(abis)
+ match abi::lookup(the_string) {
+ Some(abi) => Some(abi),
+ None => {
+ self.span_err(
+ self.span,
+ format!("illegal ABI: \
+ expected one of [{}], \
+ found `{}`",
+ abi::all_names().connect(", "),
+ the_string));
+ None
+ }
+ }
}
- _ => {
- None
- }
- }
+ _ => None,
+ }
}
// parse one of the items or view items allowed by the
return self.parse_item_extern_crate(lo, visibility, attrs);
}
- let opt_abis = self.parse_opt_abis();
+ let opt_abi = self.parse_opt_abi();
if self.eat_keyword(keywords::Fn) {
// EXTERN FUNCTION ITEM
- let abis = opt_abis.unwrap_or(AbiSet::C());
+ let abi = opt_abi.unwrap_or(abi::C);
let (ident, item_, extra_attrs) =
- self.parse_item_fn(ExternFn, abis);
+ self.parse_item_fn(ExternFn, abi);
let item = self.mk_item(lo,
self.last_span.hi,
ident,
maybe_append(attrs, extra_attrs));
return IoviItem(item);
} else if self.token == token::LBRACE {
- return self.parse_item_foreign_mod(lo, opt_abis, visibility, attrs);
+ return self.parse_item_foreign_mod(lo, opt_abi, visibility, attrs);
}
let token_str = self.this_token_to_str();
// FUNCTION ITEM
self.bump();
let (ident, item_, extra_attrs) =
- self.parse_item_fn(ImpureFn, AbiSet::Rust());
+ self.parse_item_fn(ImpureFn, abi::Rust);
let item = self.mk_item(lo,
self.last_span.hi,
ident,
self.bump();
self.expect_keyword(keywords::Fn);
let (ident, item_, extra_attrs) =
- self.parse_item_fn(UnsafeFn, AbiSet::Rust());
+ self.parse_item_fn(UnsafeFn, abi::Rust);
let item = self.mk_item(lo,
self.last_span.hi,
ident,
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use abi::AbiSet;
+use abi;
use ast::{P, RegionTyParamBound, TraitTyParamBound, Required, Provided};
use ast;
use ast_util;
opt_explicit_self: Option<ast::ExplicitSelf_>,
generics: &ast::Generics) -> ~str {
to_str(|s| {
- try!(s.print_fn(decl, Some(purity), AbiSet::Rust(),
+ try!(s.print_fn(decl, Some(purity), abi::Rust,
name, generics, opt_explicit_self, ast::Inherited));
try!(s.end()); // Close the head box
s.end() // Close the outer box
lifetimes: f.lifetimes.clone(),
ty_params: OwnedSlice::empty()
};
- try!(self.print_ty_fn(Some(f.abis), None, &None,
+ try!(self.print_ty_fn(Some(f.abi), None, &None,
f.purity, ast::Many, f.decl, None, &None,
Some(&generics), None));
}
try!(self.print_outer_attributes(item.attrs.as_slice()));
match item.node {
ast::ForeignItemFn(decl, ref generics) => {
- try!(self.print_fn(decl, None, AbiSet::Rust(), item.ident, generics,
+ try!(self.print_fn(decl, None, abi::Rust, item.ident, generics,
None, item.vis));
try!(self.end()); // end head-ibox
try!(word(&mut self.s, ";"));
}
ast::ItemForeignMod(ref nmod) => {
try!(self.head("extern"));
- try!(self.word_nbsp(nmod.abis.to_str()));
+ try!(self.word_nbsp(nmod.abi.to_str()));
try!(self.bopen());
try!(self.print_foreign_mod(nmod, item.attrs.as_slice()));
try!(self.bclose(item.span));
try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(meth.span.lo));
try!(self.print_outer_attributes(meth.attrs.as_slice()));
- try!(self.print_fn(meth.decl, Some(meth.purity), AbiSet::Rust(),
+ try!(self.print_fn(meth.decl, Some(meth.purity), abi::Rust,
meth.ident, &meth.generics, Some(meth.explicit_self.node),
meth.vis));
try!(word(&mut self.s, " "));
pub fn print_fn(&mut self,
decl: &ast::FnDecl,
purity: Option<ast::Purity>,
- abis: AbiSet,
+ abi: abi::Abi,
name: ast::Ident,
generics: &ast::Generics,
opt_explicit_self: Option<ast::ExplicitSelf_>,
vis: ast::Visibility) -> IoResult<()> {
try!(self.head(""));
- try!(self.print_fn_header_info(opt_explicit_self, purity, abis,
- ast::Many, None, vis));
+ try!(self.print_fn_header_info(opt_explicit_self, purity, abi,
+ ast::Many, None, vis));
try!(self.nbsp());
try!(self.print_ident(name));
try!(self.print_generics(generics));
}
pub fn print_ty_fn(&mut self,
- opt_abis: Option<AbiSet>,
+ opt_abi: Option<abi::Abi>,
opt_sigil: Option<ast::Sigil>,
opt_region: &Option<ast::Lifetime>,
purity: ast::Purity,
if opt_sigil == Some(ast::OwnedSigil) && onceness == ast::Once {
try!(word(&mut self.s, "proc"));
} else if opt_sigil == Some(ast::BorrowedSigil) {
- try!(self.print_extern_opt_abis(opt_abis));
+ try!(self.print_extern_opt_abi(opt_abi));
for lifetime in opt_region.iter() {
try!(self.print_lifetime(lifetime));
}
try!(self.print_purity(purity));
try!(self.print_onceness(onceness));
} else {
- try!(self.print_opt_abis_and_extern_if_nondefault(opt_abis));
+ try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi));
try!(self.print_opt_sigil(opt_sigil));
try!(self.print_opt_lifetime(opt_region));
try!(self.print_purity(purity));
}
}
- pub fn print_opt_abis_and_extern_if_nondefault(&mut self,
- opt_abis: Option<AbiSet>)
+ pub fn print_opt_abi_and_extern_if_nondefault(&mut self,
+ opt_abi: Option<abi::Abi>)
-> IoResult<()> {
- match opt_abis {
- Some(abis) if !abis.is_rust() => {
+ match opt_abi {
+ Some(abi::Rust) => Ok(()),
+ Some(abi) => {
try!(self.word_nbsp("extern"));
- self.word_nbsp(abis.to_str())
+ self.word_nbsp(abi.to_str())
}
- Some(_) | None => Ok(())
+ None => Ok(())
}
}
- pub fn print_extern_opt_abis(&mut self,
- opt_abis: Option<AbiSet>) -> IoResult<()> {
- match opt_abis {
- Some(abis) => {
+ pub fn print_extern_opt_abi(&mut self,
+ opt_abi: Option<abi::Abi>) -> IoResult<()> {
+ match opt_abi {
+ Some(abi) => {
try!(self.word_nbsp("extern"));
- self.word_nbsp(abis.to_str())
+ self.word_nbsp(abi.to_str())
}
None => Ok(())
}
pub fn print_fn_header_info(&mut self,
_opt_explicit_self: Option<ast::ExplicitSelf_>,
opt_purity: Option<ast::Purity>,
- abis: AbiSet,
+ abi: abi::Abi,
onceness: ast::Onceness,
opt_sigil: Option<ast::Sigil>,
vis: ast::Visibility) -> IoResult<()> {
try!(word(&mut self.s, visibility_qualified(vis, "")));
- if abis != AbiSet::Rust() {
+ if abi != abi::Rust {
try!(self.word_nbsp("extern"));
- try!(self.word_nbsp(abis.to_str()));
+ try!(self.word_nbsp(abi.to_str()));
if opt_purity != Some(ast::ExternFn) {
try!(self.print_opt_purity(opt_purity));
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use abi::AbiSet;
+use abi::Abi;
use ast::*;
use ast;
use codemap::Span;
pub enum FnKind<'a> {
// fn foo() or extern "Abi" fn foo()
- FkItemFn(Ident, &'a Generics, Purity, AbiSet),
+ FkItemFn(Ident, &'a Generics, Purity, Abi),
// fn foo(&self)
FkMethod(Ident, &'a Generics, &'a Method),
//! Simple ANSI color library
-#![crate_id = "term#0.10"]
+#![crate_id = "term#0.11-pre"]
#![comment = "Simple ANSI color library"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
// running tests while providing a base that other test frameworks may
// build off of.
-#![crate_id = "test#0.10"]
+#![crate_id = "test#0.11-pre"]
#![comment = "Rust internal test library only used by rustc"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![crate_id = "time#0.10"]
+#![crate_id = "time#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
//! Types/fns concerning URLs (see RFC 3986)
-#![crate_id = "url#0.10"]
+#![crate_id = "url#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
*/
-#![crate_id = "uuid#0.10"]
+#![crate_id = "uuid#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![crate_id = "workcache#0.10"]
+#![crate_id = "workcache#0.11-pre"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#include "rustllvm.h"
#include "llvm/Object/Archive.h"
+#include "llvm/Object/ObjectFile.h"
//===----------------------------------------------------------------------===
//
LLVMVersionMinor() {
return LLVM_VERSION_MINOR;
}
+
+// Note that the two following functions look quite similar to the
+// LLVMGetSectionName function. Sadly, it appears that this function only
+// returns a char* pointer, which isn't guaranteed to be null-terminated. The
+// function provided by LLVM doesn't return the length, so we've created our own
+// function which returns the length as well as the data pointer.
+//
+// For an example of this not returning a null terminated string, see
+// lib/Object/COFFObjectFile.cpp in the getSectionName function. One of the
+// branches explicitly creates a StringRef without a null terminator, and then
+// that's returned.
+
+inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
+ return reinterpret_cast<section_iterator*>(SI);
+}
+
+extern "C" int
+LLVMRustGetSectionName(LLVMSectionIteratorRef SI, const char **ptr) {
+ StringRef ret;
+ if (error_code ec = (*unwrap(SI))->getName(ret))
+ report_fatal_error(ec.message());
+ *ptr = ret.data();
+ return ret.size();
+}
+++ /dev/null
-LLVMRustCreateMemoryBufferWithContentsOfFile
-LLVMRustWriteOutputFile
-LLVMRustGetLastError
-LLVMRustConstSmallInt
-LLVMRustConstInt
-LLVMRustPrintPassTimings
-LLVMRustStartMultithreading
-LLVMCreateObjectFile
-LLVMDisposeObjectFile
-LLVMDisposeExecutionEngine
-LLVMGetSections
-LLVMDisposeSectionIterator
-LLVMIsSectionIteratorAtEnd
-LLVMMoveToNextSection
-LLVMGetSectionName
-LLVMGetSectionSize
-LLVMGetSectionContents
-LLVMABIAlignmentOfType
-LLVMABISizeOfType
-LLVMAddAggressiveDCEPass
-LLVMAddAlias
-LLVMAddArgumentPromotionPass
-LLVMAddAttribute
-LLVMAddBasicAliasAnalysisPass
-LLVMAddCFGSimplificationPass
-LLVMAddCase
-LLVMAddClause
-LLVMAddConstantMergePass
-LLVMAddConstantPropagationPass
-LLVMAddCorrelatedValuePropagationPass
-LLVMAddDeadArgEliminationPass
-LLVMAddDeadStoreEliminationPass
-LLVMAddDemoteMemoryToRegisterPass
-LLVMAddDestination
-LLVMAddEarlyCSEPass
-LLVMAddFunction
-LLVMAddFunctionAttr
-LLVMAddFunctionAttrString
-LLVMAddFunctionAttrsPass
-LLVMAddFunctionInliningPass
-LLVMAddGVNPass
-LLVMAddGlobal
-LLVMAddGlobalDCEPass
-LLVMAddGlobalInAddressSpace
-LLVMAddGlobalOptimizerPass
-LLVMAddIPConstantPropagationPass
-LLVMAddIPSCCPPass
-LLVMAddIncoming
-LLVMAddIndVarSimplifyPass
-LLVMAddInstrAttribute
-LLVMAddInstructionCombiningPass
-LLVMAddInternalizePass
-LLVMAddJumpThreadingPass
-LLVMAddLICMPass
-LLVMAddLoopDeletionPass
-LLVMAddLoopIdiomPass
-LLVMAddLoopRotatePass
-LLVMAddLoopUnrollPass
-LLVMAddLoopUnswitchPass
-LLVMAddMemCpyOptPass
-LLVMAddNamedMetadataOperand
-LLVMAddPromoteMemoryToRegisterPass
-LLVMAddPruneEHPass
-LLVMAddReassociatePass
-LLVMAddSCCPPass
-LLVMAddScalarReplAggregatesPass
-LLVMAddScalarReplAggregatesPassSSA
-LLVMAddScalarReplAggregatesPassWithThreshold
-LLVMAddSimplifyLibCallsPass
-LLVMAddStripDeadPrototypesPass
-LLVMAddStripSymbolsPass
-LLVMAddTailCallEliminationPass
-LLVMAddTargetData
-LLVMAddTypeBasedAliasAnalysisPass
-LLVMAddVerifierPass
-LLVMAlignOf
-LLVMAppendBasicBlock
-LLVMAppendBasicBlockInContext
-LLVMArrayType
-LLVMBasicBlockAsValue
-LLVMBlockAddress
-LLVMBuildAShr
-LLVMBuildAtomicLoad
-LLVMBuildAtomicStore
-LLVMBuildAtomicCmpXchg
-LLVMBuildAtomicRMW
-LLVMBuildAtomicFence
-LLVMBuildAdd
-LLVMBuildAggregateRet
-LLVMBuildAlloca
-LLVMBuildAnd
-LLVMBuildArrayAlloca
-LLVMBuildArrayMalloc
-LLVMBuildBinOp
-LLVMBuildBitCast
-LLVMBuildBr
-LLVMBuildCall
-LLVMBuildCast
-LLVMBuildCondBr
-LLVMBuildExactSDiv
-LLVMBuildExtractElement
-LLVMBuildExtractValue
-LLVMBuildFAdd
-LLVMBuildFCmp
-LLVMBuildFDiv
-LLVMBuildFMul
-LLVMBuildFNeg
-LLVMBuildFPCast
-LLVMBuildFPExt
-LLVMBuildFPToSI
-LLVMBuildFPToUI
-LLVMBuildFPTrunc
-LLVMBuildFRem
-LLVMBuildFSub
-LLVMBuildFree
-LLVMBuildGEP
-LLVMBuildGlobalString
-LLVMBuildGlobalStringPtr
-LLVMBuildICmp
-LLVMBuildInBoundsGEP
-LLVMBuildIndirectBr
-LLVMBuildInsertElement
-LLVMBuildInsertValue
-LLVMBuildIntCast
-LLVMBuildIntToPtr
-LLVMBuildInvoke
-LLVMBuildIsNotNull
-LLVMBuildIsNull
-LLVMBuildLandingPad
-LLVMBuildLShr
-LLVMBuildLoad
-LLVMBuildMalloc
-LLVMBuildMul
-LLVMBuildNSWAdd
-LLVMBuildNSWMul
-LLVMBuildNSWNeg
-LLVMBuildNSWSub
-LLVMBuildNUWAdd
-LLVMBuildNUWMul
-LLVMBuildNUWNeg
-LLVMBuildNUWSub
-LLVMBuildNeg
-LLVMBuildNot
-LLVMBuildOr
-LLVMBuildPhi
-LLVMBuildPointerCast
-LLVMBuildPtrDiff
-LLVMBuildPtrToInt
-LLVMBuildResume
-LLVMBuildRet
-LLVMBuildRetVoid
-LLVMBuildSDiv
-LLVMBuildSExt
-LLVMBuildSExtOrBitCast
-LLVMBuildSIToFP
-LLVMBuildSRem
-LLVMBuildSelect
-LLVMBuildShl
-LLVMBuildShuffleVector
-LLVMBuildStore
-LLVMBuildStructGEP
-LLVMBuildSub
-LLVMBuildSwitch
-LLVMBuildTrunc
-LLVMBuildTruncOrBitCast
-LLVMBuildUDiv
-LLVMBuildUIToFP
-LLVMBuildURem
-LLVMBuildUnreachable
-LLVMBuildVAArg
-LLVMBuildXor
-LLVMBuildZExt
-LLVMBuildZExtOrBitCast
-LLVMByteOrder
-LLVMCallFrameAlignmentOfType
-LLVMClearInsertionPosition
-LLVMConstAShr
-LLVMConstAdd
-LLVMConstAllOnes
-LLVMConstAnd
-LLVMConstArray
-LLVMConstBitCast
-LLVMConstExactSDiv
-LLVMConstExtractElement
-LLVMConstExtractValue
-LLVMConstFAdd
-LLVMConstFCmp
-LLVMConstFDiv
-LLVMConstFMul
-LLVMConstFNeg
-LLVMConstFPCast
-LLVMConstFPExt
-LLVMConstFPToSI
-LLVMConstFPToUI
-LLVMConstFPTrunc
-LLVMConstFRem
-LLVMConstFSub
-LLVMConstGEP
-LLVMConstICmp
-LLVMConstInBoundsGEP
-LLVMConstInlineAsm
-LLVMConstInsertElement
-LLVMConstInsertValue
-LLVMConstInt
-LLVMConstIntCast
-LLVMConstIntGetSExtValue
-LLVMConstIntGetZExtValue
-LLVMConstIntOfArbitraryPrecision
-LLVMConstIntOfString
-LLVMConstIntOfStringAndSize
-LLVMConstIntToPtr
-LLVMConstLShr
-LLVMConstMul
-LLVMConstNSWAdd
-LLVMConstNSWMul
-LLVMConstNSWNeg
-LLVMConstNSWSub
-LLVMConstNUWAdd
-LLVMConstNUWMul
-LLVMConstNUWNeg
-LLVMConstNUWSub
-LLVMConstNeg
-LLVMConstNot
-LLVMConstNull
-LLVMConstOr
-LLVMConstPointerCast
-LLVMConstPointerNull
-LLVMConstPtrToInt
-LLVMConstReal
-LLVMConstRealOfString
-LLVMConstRealOfStringAndSize
-LLVMConstSDiv
-LLVMConstSExt
-LLVMConstSExtOrBitCast
-LLVMConstSIToFP
-LLVMConstSRem
-LLVMConstSelect
-LLVMConstShl
-LLVMConstShuffleVector
-LLVMConstString
-LLVMConstStringInContext
-LLVMConstStruct
-LLVMConstStructInContext
-LLVMConstSub
-LLVMConstTrunc
-LLVMConstTruncOrBitCast
-LLVMConstUDiv
-LLVMConstUIToFP
-LLVMConstURem
-LLVMConstVector
-LLVMConstXor
-LLVMConstZExt
-LLVMConstZExtOrBitCast
-LLVMContextCreate
-LLVMContextDispose
-LLVMCopyStringRepOfTargetData
-LLVMCountBasicBlocks
-LLVMCountIncoming
-LLVMCountParamTypes
-LLVMCountParams
-LLVMCountStructElementTypes
-LLVMCreateBuilder
-LLVMCreateBuilderInContext
-LLVMCreateFunctionPassManager
-LLVMCreateFunctionPassManagerForModule
-LLVMCreateMemoryBufferWithContentsOfFile
-LLVMCreateMemoryBufferWithSTDIN
-LLVMCreateModuleProviderForExistingModule
-LLVMCreateObjectFile
-LLVMCreatePassManager
-LLVMCreateTargetData
-LLVMDeleteBasicBlock
-LLVMDeleteFunction
-LLVMDeleteGlobal
-LLVMDisposeBuilder
-LLVMDisposeMemoryBuffer
-LLVMDisposeMessage
-LLVMDisposeModule
-LLVMDisposeModuleProvider
-LLVMDisposeObjectFile
-LLVMDisposePassManager
-LLVMDisposeSectionIterator
-LLVMDisposeTargetData
-LLVMDoubleType
-LLVMDoubleTypeInContext
-LLVMDumpModule
-LLVMDumpValue
-LLVMElementAtOffset
-LLVMFP128Type
-LLVMFP128TypeInContext
-LLVMFinalizeFunctionPassManager
-LLVMFloatType
-LLVMFloatTypeInContext
-LLVMFunctionType
-LLVMGetAlignment
-LLVMGetArrayLength
-LLVMGetAttribute
-LLVMGetBasicBlockParent
-LLVMGetBasicBlocks
-LLVMGetBitcodeModule
-LLVMGetBitcodeModuleInContext
-LLVMGetBitcodeModuleProvider
-LLVMGetBitcodeModuleProviderInContext
-LLVMGetConstOpcode
-LLVMGetCurrentDebugLocation
-LLVMGetDataLayout
-LLVMGetElementType
-LLVMGetEntryBasicBlock
-LLVMGetFirstBasicBlock
-LLVMGetFirstFunction
-LLVMGetFirstGlobal
-LLVMGetFirstInstruction
-LLVMGetFirstParam
-LLVMGetFirstUse
-LLVMGetFunctionAttr
-LLVMGetFunctionCallConv
-LLVMGetGC
-LLVMGetGlobalContext
-LLVMGetGlobalParent
-LLVMGetGlobalPassRegistry
-LLVMGetIncomingBlock
-LLVMGetIncomingValue
-LLVMGetInitializer
-LLVMGetInsertBlock
-LLVMGetInstructionCallConv
-LLVMGetInstructionParent
-LLVMGetIntTypeWidth
-LLVMGetIntrinsicID
-LLVMGetLastBasicBlock
-LLVMGetLastFunction
-LLVMGetLastGlobal
-LLVMGetLastInstruction
-LLVMGetLastParam
-LLVMGetLinkage
-LLVMGetMDKindID
-LLVMGetMDKindIDInContext
-LLVMGetMetadata
-LLVMGetModuleContext
-LLVMGetNamedFunction
-LLVMGetNamedGlobal
-LLVMGetNextBasicBlock
-LLVMGetNextFunction
-LLVMGetNextGlobal
-LLVMGetNextInstruction
-LLVMGetNextParam
-LLVMGetNextUse
-LLVMGetNumOperands
-LLVMGetOperand
-LLVMGetOrInsertFunction
-LLVMGetParam
-LLVMGetParamParent
-LLVMGetParamTypes
-LLVMGetParams
-LLVMGetPointerAddressSpace
-LLVMGetPointerToGlobal
-LLVMGetPreviousBasicBlock
-LLVMGetPreviousFunction
-LLVMGetPreviousGlobal
-LLVMGetPreviousInstruction
-LLVMGetPreviousParam
-LLVMGetReturnType
-LLVMGetSection
-LLVMGetSectionContents
-LLVMGetSectionName
-LLVMGetSectionSize
-LLVMGetSections
-LLVMGetStructElementTypes
-LLVMGetTarget
-LLVMGetTypeContext
-LLVMGetTypeKind
-LLVMGetUndef
-LLVMGetUsedValue
-LLVMGetUser
-LLVMGetValueName
-LLVMGetVectorSize
-LLVMGetVisibility
-LLVMHasMetadata
-LLVMInitializeCodeGen
-LLVMInitializeFunctionPassManager
-LLVMInitializeIPA
-LLVMInitializeInstCombine
-LLVMInitializeScalarOpts
-LLVMInitializeTarget
-LLVMInitializeTransformUtils
-LLVMInitializeARMAsmParser
-LLVMInitializeMipsAsmParser
-LLVMInitializeX86AsmParser
-LLVMInitializeARMAsmPrinter
-LLVMInitializeMipsAsmPrinter
-LLVMInitializeX86AsmPrinter
-LLVMInitializeARMDisassembler
-LLVMInitializeMipsDisassembler
-LLVMInitializeX86Disassembler
-LLVMInitializeARMTarget
-LLVMInitializeMipsTarget
-LLVMInitializeX86Target
-LLVMInitializeARMTargetMC
-LLVMInitializeMipsTargetMC
-LLVMInitializeX86TargetMC
-LLVMInitializeARMTargetInfo
-LLVMInitializeMipsTargetInfo
-LLVMInitializeX86TargetInfo
-LLVMInsertBasicBlock
-LLVMInsertBasicBlockInContext
-LLVMInsertIntoBuilder
-LLVMInsertIntoBuilderWithName
-LLVMInstructionEraseFromParent
-LLVMInt16Type
-LLVMInt16TypeInContext
-LLVMInt1Type
-LLVMInt1TypeInContext
-LLVMInt32Type
-LLVMInt32TypeInContext
-LLVMInt64Type
-LLVMInt64TypeInContext
-LLVMInt8Type
-LLVMInt8TypeInContext
-LLVMIntPtrType
-LLVMIntType
-LLVMIntTypeInContext
-LLVMIsAAllocaInst
-LLVMIsAArgument
-LLVMIsABasicBlock
-LLVMIsABinaryOperator
-LLVMIsABitCastInst
-LLVMIsABranchInst
-LLVMIsACallInst
-LLVMIsACastInst
-LLVMIsACmpInst
-LLVMIsAConstant
-LLVMIsAConstantAggregateZero
-LLVMIsAConstantArray
-LLVMIsAConstantExpr
-LLVMIsAConstantFP
-LLVMIsAConstantInt
-LLVMIsAConstantPointerNull
-LLVMIsAConstantStruct
-LLVMIsAConstantVector
-LLVMIsADbgDeclareInst
-LLVMIsADbgInfoIntrinsic
-LLVMIsAExtractElementInst
-LLVMIsAExtractValueInst
-LLVMIsAFCmpInst
-LLVMIsAFPExtInst
-LLVMIsAFPToSIInst
-LLVMIsAFPToUIInst
-LLVMIsAFPTruncInst
-LLVMIsAFunction
-LLVMIsAGetElementPtrInst
-LLVMIsAGlobalAlias
-LLVMIsAGlobalValue
-LLVMIsAGlobalVariable
-LLVMIsAICmpInst
-LLVMIsAInlineAsm
-LLVMIsAInsertElementInst
-LLVMIsAInsertValueInst
-LLVMIsAInstruction
-LLVMIsAIntToPtrInst
-LLVMIsAIntrinsicInst
-LLVMIsAInvokeInst
-LLVMIsALoadInst
-LLVMIsAMemCpyInst
-LLVMIsAMemIntrinsic
-LLVMIsAMemMoveInst
-LLVMIsAMemSetInst
-LLVMIsAPHINode
-LLVMIsAPtrToIntInst
-LLVMIsAReturnInst
-LLVMIsASExtInst
-LLVMIsASIToFPInst
-LLVMIsASelectInst
-LLVMIsAShuffleVectorInst
-LLVMIsAStoreInst
-LLVMIsASwitchInst
-LLVMIsATerminatorInst
-LLVMIsATruncInst
-LLVMIsAUIToFPInst
-LLVMIsAUnaryInstruction
-LLVMIsAUndefValue
-LLVMIsAUnreachableInst
-LLVMIsAUser
-LLVMIsAVAArgInst
-LLVMIsAZExtInst
-LLVMIsConstant
-LLVMIsDeclaration
-LLVMIsFunctionVarArg
-LLVMIsGlobalConstant
-LLVMIsNull
-LLVMIsPackedStruct
-LLVMIsSectionIteratorAtEnd
-LLVMIsTailCall
-LLVMIsThreadLocal
-LLVMIsUndef
-LLVMLabelType
-LLVMLabelTypeInContext
-LLVMLinkInInterpreter
-LLVMMDNode
-LLVMMDNodeInContext
-LLVMMDString
-LLVMMDStringInContext
-LLVMMetadataTypeInContext
-LLVMModuleCreateWithName
-LLVMModuleCreateWithNameInContext
-LLVMMoveBasicBlockAfter
-LLVMMoveBasicBlockBefore
-LLVMMoveToNextSection
-LLVMOffsetOfElement
-LLVMPPCFP128Type
-LLVMPPCFP128TypeInContext
-LLVMParseBitcode
-LLVMParseBitcodeInContext
-LLVMPassManagerBuilderCreate
-LLVMPassManagerBuilderDispose
-LLVMPassManagerBuilderPopulateModulePassManager
-LLVMPassManagerBuilderSetDisableSimplifyLibCalls
-LLVMPassManagerBuilderSetDisableUnitAtATime
-LLVMPassManagerBuilderPopulateFunctionPassManager
-LLVMPassManagerBuilderSetDisableUnrollLoops
-LLVMPassManagerBuilderSetOptLevel
-LLVMPassManagerBuilderSetSizeLevel
-LLVMPassManagerBuilderUseInlinerWithThreshold
-LLVMPointerSize
-LLVMPointerType
-LLVMPositionBuilder
-LLVMPositionBuilderAtEnd
-LLVMPositionBuilderBefore
-LLVMPreferredAlignmentOfGlobal
-LLVMPreferredAlignmentOfType
-LLVMRemoveAttribute
-LLVMRemoveFunctionAttr
-LLVMRemoveInstrAttribute
-LLVMReplaceAllUsesWith
-LLVMRunFunctionPassManager
-LLVMRunPassManager
-LLVMSetAlignment
-LLVMSetCleanup
-LLVMSetCurrentDebugLocation
-LLVMSetDataLayout
-LLVMSetDebug
-LLVMSetFunctionCallConv
-LLVMSetGC
-LLVMSetGlobalConstant
-LLVMSetInitializer
-LLVMSetInstDebugLocation
-LLVMSetInstrParamAlignment
-LLVMSetInstructionCallConv
-LLVMSetLinkage
-LLVMSetMetadata
-LLVMSetModuleInlineAsm
-LLVMSetOperand
-LLVMSetParamAlignment
-LLVMSetSection
-LLVMSetTailCall
-LLVMSetTarget
-LLVMSetThreadLocal
-LLVMSetValueName
-LLVMSetVisibility
-LLVMSizeOf
-LLVMSizeOfTypeInBits
-LLVMStoreSizeOfType
-LLVMStructType
-LLVMStructTypeInContext
-LLVMTypeOf
-LLVMValueAsBasicBlock
-LLVMValueIsBasicBlock
-LLVMVectorType
-LLVMVerifyFunction
-LLVMVerifyModule
-LLVMViewFunctionCFG
-LLVMViewFunctionCFGOnly
-LLVMVoidType
-LLVMVoidTypeInContext
-LLVMWriteBitcodeToFD
-LLVMWriteBitcodeToFile
-LLVMWriteBitcodeToFileHandle
-LLVMX86FP80Type
-LLVMX86FP80TypeInContext
-LLVMX86MMXType
-LLVMX86MMXTypeInContext
-LLVMConstNamedStruct
-LLVMStructCreateNamed
-LLVMStructSetBody
-LLVMInlineAsm
-LLVMInitializePasses
-LLVMDIBuilderCreate
-LLVMDIBuilderDispose
-LLVMDIBuilderFinalize
-LLVMDIBuilderCreateCompileUnit
-LLVMDIBuilderCreateStaticVariable
-LLVMDIBuilderCreateLocalVariable
-LLVMDIBuilderCreateFunction
-LLVMDIBuilderCreateFile
-LLVMDIBuilderCreateLexicalBlock
-LLVMDIBuilderCreateBasicType
-LLVMDIBuilderCreatePointerType
-LLVMDIBuilderCreateMemberType
-LLVMDIBuilderCreateStructType
-LLVMDIBuilderGetOrCreateSubrange
-LLVMDIBuilderCreateArrayType
-LLVMDIBuilderCreateVectorType
-LLVMDIBuilderCreateSubroutineType
-LLVMDIBuilderGetOrCreateArray
-LLVMDIBuilderInsertDeclareAtEnd
-LLVMDIBuilderInsertDeclareBefore
-LLVMDIBuilderCreateEnumerator
-LLVMDIBuilderCreateEnumerationType
-LLVMDIBuilderCreateUnionType
-LLVMDIBuilderCreateTemplateTypeParameter
-LLVMDIBuilderCreateOpDeref
-LLVMDIBuilderCreateOpPlus
-LLVMDIBuilderCreateComplexVariable
-LLVMDIBuilderCreateNameSpace
-LLVMDICompositeTypeSetTypeArray
-LLVMSetUnnamedAddr
-LLVMRustAddPass
-LLVMRustAddAnalysisPasses
-LLVMRustAddLibraryInfo
-LLVMRustCreateTargetMachine
-LLVMRustRunFunctionPassManager
-LLVMRustPrintModule
-LLVMRustDisposeTargetMachine
-LLVMRustAddBuilderLibraryInfo
-LLVMRustSetLLVMOptions
-LLVMRustPrintPasses
-LLVMRustSetNormalizedTarget
-LLVMRustAddAlwaysInlinePass
-LLVMAddReturnAttribute
-LLVMRemoveReturnAttribute
-LLVMTypeToString
-LLVMAddColdAttribute
-LLVMCreateMemoryBufferWithMemoryRange
-LLVMCreateMemoryBufferWithMemoryRangeCopy
-LLVMPassManagerBuilderPopulateLTOPassManager
-LLVMRustLinkInExternalBitcode
-LLVMRustRunRestrictionPass
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub struct Closed01<F>(F);
+pub struct Closed01<F>(pub F);
pub trait Bar { fn new() -> Self; }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub struct A<'a>(&'a int);
+pub struct A<'a>(pub &'a int);
// no-prefer-dynamic
-#[crate_id = "collections#0.10"];
+#[crate_id = "collections#0.11-pre"];
#[crate_type = "dylib"];
// no-prefer-dynamic
-#[crate_id = "collections#0.10"];
+#[crate_id = "collections#0.11-pre"];
#[crate_type = "rlib"];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub struct V2<T>(T, T);
+pub struct V2<T>(pub T, pub T);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub struct Wrap<A>(A);
+pub struct Wrap<A>(pub A);
// except according to those terms.
-pub struct S(());
+pub struct S(pub ());
impl S {
pub fn foo(&self) { }
}
#[deprecated]
-pub struct DeprecatedTupleStruct(int);
+pub struct DeprecatedTupleStruct(pub int);
#[experimental]
-pub struct ExperimentalTupleStruct(int);
+pub struct ExperimentalTupleStruct(pub int);
#[unstable]
-pub struct UnstableTupleStruct(int);
-pub struct UnmarkedTupleStruct(int);
+pub struct UnstableTupleStruct(pub int);
+pub struct UnmarkedTupleStruct(pub int);
#[stable]
-pub struct StableTupleStruct(int);
+pub struct StableTupleStruct(pub int);
#[frozen]
-pub struct FrozenTupleStruct(int);
+pub struct FrozenTupleStruct(pub int);
#[locked]
-pub struct LockedTupleStruct(int);
+pub struct LockedTupleStruct(pub int);
#[crate_type="lib"];
-pub struct Au(int);
+pub struct Au(pub int);
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-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 struct A(());
+pub struct B(int);
+pub struct C(pub int, int);
+pub struct D(pub int);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![no_start]
+
+extern crate green;
+extern crate rustuv;
+
use std::task::spawn;
use std::os;
use std::uint;
// Very simple spawn rate test. Spawn N tasks that do nothing and
// return.
+#[start]
+fn start(argc: int, argv: **u8) -> int {
+ green::start(argc, argv, rustuv::event_loop, main)
+}
+
fn main() {
let args = os::args();
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-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() {
+ concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
+}
// immediately, so that we get more errors listed at a time.
#![feature(asm)]
-#![feature(trace_macros)]
+#![feature(trace_macros, concat_idents)]
#[deriving(Default, //~ ERROR
Rand, //~ ERROR
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-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:privacy-tuple-struct.rs
+// ignore-fast
+
+extern crate other = "privacy-tuple-struct";
+
+mod a {
+ pub struct A(());
+ pub struct B(int);
+ pub struct C(pub int, int);
+ pub struct D(pub int);
+
+ fn test() {
+ let a = A(());
+ let b = B(2);
+ let c = C(2, 3);
+ let d = D(4);
+
+ let A(()) = a;
+ let A(_) = a;
+ match a { A(()) => {} }
+ match a { A(_) => {} }
+
+ let B(_) = b;
+ let B(_b) = b;
+ match b { B(_) => {} }
+ match b { B(_b) => {} }
+ match b { B(1) => {} B(_) => {} }
+
+ let C(_, _) = c;
+ let C(_a, _) = c;
+ let C(_, _b) = c;
+ let C(_a, _b) = c;
+ match c { C(_, _) => {} }
+ match c { C(_a, _) => {} }
+ match c { C(_, _b) => {} }
+ match c { C(_a, _b) => {} }
+
+ let D(_) = d;
+ let D(_d) = d;
+ match d { D(_) => {} }
+ match d { D(_d) => {} }
+ match d { D(1) => {} D(_) => {} }
+
+ let a2 = A;
+ let b2 = B;
+ let c2 = C;
+ let d2 = D;
+ }
+}
+
+fn this_crate() {
+ let a = a::A(()); //~ ERROR: cannot invoke tuple struct constructor
+ let b = a::B(2); //~ ERROR: cannot invoke tuple struct constructor
+ let c = a::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
+ let d = a::D(4);
+
+ let a::A(()) = a; //~ ERROR: field #1 is private
+ let a::A(_) = a;
+ match a { a::A(()) => {} } //~ ERROR: field #1 is private
+ match a { a::A(_) => {} }
+
+ let a::B(_) = b;
+ let a::B(_b) = b; //~ ERROR: field #1 is private
+ match b { a::B(_) => {} }
+ match b { a::B(_b) => {} } //~ ERROR: field #1 is private
+ match b { a::B(1) => {} a::B(_) => {} } //~ ERROR: field #1 is private
+
+ let a::C(_, _) = c;
+ let a::C(_a, _) = c;
+ let a::C(_, _b) = c; //~ ERROR: field #2 is private
+ let a::C(_a, _b) = c; //~ ERROR: field #2 is private
+ match c { a::C(_, _) => {} }
+ match c { a::C(_a, _) => {} }
+ match c { a::C(_, _b) => {} } //~ ERROR: field #2 is private
+ match c { a::C(_a, _b) => {} } //~ ERROR: field #2 is private
+
+ let a::D(_) = d;
+ let a::D(_d) = d;
+ match d { a::D(_) => {} }
+ match d { a::D(_d) => {} }
+ match d { a::D(1) => {} a::D(_) => {} }
+
+ let a2 = a::A; //~ ERROR: cannot invoke tuple struct constructor
+ let b2 = a::B; //~ ERROR: cannot invoke tuple struct constructor
+ let c2 = a::C; //~ ERROR: cannot invoke tuple struct constructor
+ let d2 = a::D;
+}
+
+fn xcrate() {
+ let a = other::A(()); //~ ERROR: cannot invoke tuple struct constructor
+ let b = other::B(2); //~ ERROR: cannot invoke tuple struct constructor
+ let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
+ let d = other::D(4);
+
+ let other::A(()) = a; //~ ERROR: field #1 is private
+ let other::A(_) = a;
+ match a { other::A(()) => {} } //~ ERROR: field #1 is private
+ match a { other::A(_) => {} }
+
+ let other::B(_) = b;
+ let other::B(_b) = b; //~ ERROR: field #1 is private
+ match b { other::B(_) => {} }
+ match b { other::B(_b) => {} } //~ ERROR: field #1 is private
+ match b { other::B(1) => {} other::B(_) => {} } //~ ERROR: field #1 is private
+
+ let other::C(_, _) = c;
+ let other::C(_a, _) = c;
+ let other::C(_, _b) = c; //~ ERROR: field #2 is private
+ let other::C(_a, _b) = c; //~ ERROR: field #2 is private
+ match c { other::C(_, _) => {} }
+ match c { other::C(_a, _) => {} }
+ match c { other::C(_, _b) => {} } //~ ERROR: field #2 is private
+ match c { other::C(_a, _b) => {} } //~ ERROR: field #2 is private
+
+ let other::D(_) = d;
+ let other::D(_d) = d;
+ match d { other::D(_) => {} }
+ match d { other::D(_d) => {} }
+ match d { other::D(1) => {} other::D(_) => {} }
+
+ let a2 = other::A; //~ ERROR: cannot invoke tuple struct constructor
+ let b2 = other::B; //~ ERROR: cannot invoke tuple struct constructor
+ let c2 = other::C; //~ ERROR: cannot invoke tuple struct constructor
+ let d2 = other::D;
+}
+
+fn main() {}
// this now fails (correctly, I claim) because hygiene prevents
// the assembled identifier from being a reference to the binding.
+#![feature(concat_idents)]
pub fn main() {
let asdf_fdsa = ~"<.<";
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
// check:type = f64
// debugger:continue
-#[allow(unused_variable)];
+#![allow(unused_variable)]
+#![allow(dead_code)]
+
static B: bool = false;
static I: int = -1;
// about UTF-32 character encoding and will print a rust char as only
// its numerical value.
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
// about UTF-32 character encoding and will print a rust char as only
// its numerical value.
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
// debugger:print 'c-style-enum::MANUAL_THREE'
// check:$18 = OneMillion
-#[allow(unused_variable)];
+#![allow(unused_variable)]
+#![allow(dead_code)]
enum AutoDiscriminant {
One,
// debugger:rbreak zzz
// debugger:run
// debugger:finish
-// debugger:print string1
-// check:$1 = [...]"some text to include in another file as string 1", length = 48}
-// debugger:print string2
-// check:$2 = [...]"some text to include in another file as string 2", length = 48}
-// debugger:print string3
-// check:$3 = [...]"some text to include in another file as string 3", length = 48}
+// debugger:print string1.length
+// check:$1 = 48
+// debugger:print string2.length
+// check:$2 = 48
+// debugger:print string3.length
+// check:$3 = 48
// debugger:continue
#[allow(unused_variable)];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-win32
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-win32
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-win32
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-win32
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-win32: FIXME #10474
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-win32: FIXME #13256
// ignore-android: FIXME(#10381)
// compile-flags:-g
-include ../tools.mk
all:
- [ `$(RUSTC) --crate-id crate.rs` = "foo#0.10" ]
+ [ `$(RUSTC) --crate-id crate.rs` = "foo#0.11-pre" ]
[ `$(RUSTC) --crate-name crate.rs` = "foo" ]
[ `$(RUSTC) --crate-file-name crate.rs` = "foo" ]
[ `$(RUSTC) --crate-file-name --crate-type=lib --test crate.rs` = "foo" ]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#[crate_id = "foo#0.10"];
+#[crate_id = "foo#0.11-pre"];
// Querying about the crate metadata should *not* parse the entire crate, it
// only needs the crate attributes (which are guaranteed to be at the top) be
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// ignore-win32 FIXME #13259
// ignore-fast this is executing itself
-#[no_uv];
+#![no_uv]
extern crate native;
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-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() {
+ assert!(Some(~()).is_some());
+
+ struct Foo;
+ assert!(Some(~Foo).is_some());
+
+ let xs: ~[()] = ~[];
+ assert!(Some(xs).is_some());
+}
// except according to those terms.
// ignore-fast
+// ignore-win32 dynamic_lib can read dllexported symbols only
// ignore-linux apparently dlsym doesn't work on program symbols?
// ignore-android apparently dlsym doesn't work on program symbols?
// ignore-freebsd apparently dlsym doesn't work on program symbols?
#[no_std];
extern crate std;
extern crate zed = "std";
-extern crate bar = "std#0.10";
+extern crate bar = "std#0.11-pre";
use std::str;