-.TH RUSTC "1" "March 2014" "rustc 0.11-pre" "User Commands"
+.TH RUSTC "1" "March 2014" "rustc 0.11.0" "User Commands"
.SH NAME
rustc \- The Rust compiler
.SH SYNOPSIS
-.TH RUSTDOC "1" "March 2014" "rustdoc 0.11-pre" "User Commands"
+.TH RUSTDOC "1" "March 2014" "rustdoc 0.11.0" "User Commands"
.SH NAME
rustdoc \- generate documentation from Rust source code
.SH SYNOPSIS
# The version number
CFG_RELEASE_NUM=0.11.0
-CFG_RELEASE_LABEL=-pre
+CFG_RELEASE_LABEL=
ifndef CFG_ENABLE_NIGHTLY
# This is the normal version string
~~~~
po4a --copyright-holder="The Rust Project Developers" \
--package-name="Rust" \
- --package-version="0.11.0-pre" \
+ --package-version="0.11.0" \
-M UTF-8 -L UTF-8 \
src/doc/po4a.conf
~~~~
-(the version number must be changed if it is not 0.11.0-pre now.)
+(the version number must be changed if it is not 0.11.0 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
You can re-run this script any time you want to update Rust. Which, at this
point, is often. Rust is still pre-1.0, and so people assume that you're using
-a very recent Rust.
+a very recent Rust.
This brings me to one other point: some people, and somewhat rightfully so, get
very upset when we tell you to `curl | sudo sh`. And they should be! Basically,
```
fn main() {
-
+
}
```
```{bash}
$ cargo build
Compiling hello_world v0.1.0 (file:/home/yourname/projects/hello_world)
-$ ./target/hello_world
+$ ./target/hello_world
Hello, world!
```
-moz-column-count: 2;
-webkit-column-count: 2;
font-size: 15px;
+ margin: 0 0 1em 0;
}
p {
margin: 0 0 1em 0;
nav ul {
list-style-type: none;
- margin: 0 0 20px 0;
+ margin: 0;
padding-left: 0px;
}
#### Moved and copied types
When a [local variable](#memory-slots) is used
-as an [rvalue](#lvalues-rvalues-and-temporaries)
+as an [rvalue](#lvalues,-rvalues-and-temporaries)
the variable will either be moved or copied, depending on its type.
For types that contain [owning pointers](#pointer-types)
or values that implement the special trait `Drop`,
### Path expressions
A [path](#paths) used as an expression context denotes either a local variable or an item.
-Path expressions are [lvalues](#lvalues-rvalues-and-temporaries).
+Path expressions are [lvalues](#lvalues,-rvalues-and-temporaries).
### Tuple expressions
(Struct {a: 10, b: 20}).a;
~~~~
-A field access is an [lvalue](#lvalues-rvalues-and-temporaries) referring to the value of that field.
+A field access is an [lvalue](#lvalues,-rvalues-and-temporaries) referring to the value of that field.
When the type providing the field inherits mutabilty, it can be [assigned](#assignment-expressions) to.
Also, if the type of the expression to the left of the dot is a pointer,
[Vector](#vector-types)-typed expressions can be indexed by writing a
square-bracket-enclosed expression (the index) after them. When the
-vector is mutable, the resulting [lvalue](#lvalues-rvalues-and-temporaries) can be assigned to.
+vector is mutable, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can be assigned to.
Indices are zero-based, and may be of any integral type. Vector access
is bounds-checked at run-time. When the check fails, it will put the
: Negation. May only be applied to numeric types.
* `*`
: Dereference. When applied to a [pointer](#pointer-types) it denotes the pointed-to location.
- For pointers to mutable locations, the resulting [lvalue](#lvalues-rvalues-and-temporaries) can be assigned to.
+ For pointers to mutable locations, the resulting [lvalue](#lvalues,-rvalues-and-temporaries) can be assigned to.
On non-pointer types, it calls the `deref` method of the `std::ops::Deref` trait, or the
`deref_mut` method of the `std::ops::DerefMut` trait (if implemented by the type and required
for an outer expression that will or could mutate the dereference), and produces the
#### Assignment expressions
-An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) expression followed by an
-equals sign (`=`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.
+An _assignment expression_ consists of an [lvalue](#lvalues,-rvalues-and-temporaries) expression followed by an
+equals sign (`=`) and an [rvalue](#lvalues,-rvalues-and-temporaries) expression.
Evaluating an assignment expression [either copies or moves](#moved-and-copied-types) its right-hand operand to its left-hand operand.
~~~~
A `match` behaves differently depending on whether or not the head expression
-is an [lvalue or an rvalue](#lvalues-rvalues-and-temporaries).
+is an [lvalue or an rvalue](#lvalues,-rvalues-and-temporaries).
If the head expression is an rvalue, it is
first evaluated into a temporary location, and the resulting value
is sequentially compared to the patterns in the arms until a match
: These point to memory _owned by some other value_.
References arise by (automatic) conversion from owning pointers, managed pointers,
or by applying the borrowing operator `&` to some other value,
- including [lvalues, rvalues or temporaries](#lvalues-rvalues-and-temporaries).
+ including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
References are written `&content`, or in some cases `&'f content` for some lifetime-variable `f`,
for example `&int` means a reference to an integer.
Copying a reference is a "shallow" operation:
A task's stack contains slots.
A _slot_ is a component of a stack frame, either a function parameter,
-a [temporary](#lvalues-rvalues-and-temporaries), or a local variable.
+a [temporary](#lvalues,-rvalues-and-temporaries), or a local variable.
A _local variable_ (or *stack-local* allocation) holds a value directly,
allocated within the stack's memory. The value is a part of the stack frame.
~~~{.ignore}
// `b/mod.rs`
pub mod c;
-pub fn foo() { println!("Foo!"; }
+pub fn foo() { println!("Foo!"); }
~~~
~~~{.ignore}
<!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">
<!ENTITY rustIntSuf "([iu](8|16|32|64)?)?">
]>
-<language name="Rust" version="0.11.0-pre" kateversion="2.4" section="Sources" extensions="*.rs" mimetype="text/x-rust" priority="15">
+<language name="Rust" version="0.11.0" kateversion="2.4" section="Sources" extensions="*.rs" mimetype="text/x-rust" priority="15">
<highlighting>
<list name="fn">
<item> fn </item>
//! by libc malloc/free. The `libc_heap` module is defined to be wired up to
//! the system malloc/free.
-#![crate_id = "alloc#0.11.0-pre"]
+#![crate_id = "alloc#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
//! arena but can only hold objects of a single type, and Arena, which is a
//! more complex, slower Arena which can hold objects of any type.
-#![crate_id = "arena#0.11.0-pre"]
+#![crate_id = "arena#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(unsafe_destructor)]
#![allow(missing_doc)]
* Collection types.
*/
-#![crate_id = "collections#0.11.0-pre"]
+#![crate_id = "collections#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
// Since libcore defines many fundamental lang items, all tests live in a
// separate crate, libcoretest, to avoid bizarre issues.
-#![crate_id = "core#0.11.0-pre"]
+#![crate_id = "core#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![no_std]
pub mod slice;
pub mod str;
pub mod tuple;
+// FIXME #15320: primitive documentation needs top-level modules, this
+// should be `core::tuple::unit`.
+#[path = "tuple/unit.rs"]
+pub mod unit;
pub mod fmt;
#[doc(hidden)]
+++ /dev/null
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! Operations on tuples
-//!
-//! To access a single element of a tuple one can use the following
-//! methods:
-//!
-//! * `valN` - returns a value of _N_-th element
-//! * `refN` - returns a reference to _N_-th element
-//! * `mutN` - returns a mutable reference to _N_-th element
-//!
-//! Indexing starts from zero, so `val0` returns first value, `val1`
-//! returns second value, and so on. In general, a tuple with _S_
-//! elements provides aforementioned methods suffixed with numbers
-//! from `0` to `S-1`. Traits which contain these methods are
-//! implemented for tuples with up to 12 elements.
-//!
-//! If every type inside a tuple implements one of the following
-//! traits, then a tuple itself also implements it.
-//!
-//! * `Clone`
-//! * `PartialEq`
-//! * `Eq`
-//! * `PartialOrd`
-//! * `Ord`
-//! * `Default`
-//!
-//! # Examples
-//!
-//! Using methods:
-//!
-//! ```
-//! let pair = ("pi", 3.14f64);
-//! assert_eq!(pair.val0(), "pi");
-//! assert_eq!(pair.val1(), 3.14f64);
-//! ```
-//!
-//! Using traits implemented for tuples:
-//!
-//! ```
-//! use std::default::Default;
-//!
-//! let a = (1i, 2i);
-//! let b = (3i, 4i);
-//! assert!(a != b);
-//!
-//! let c = b.clone();
-//! assert!(b == c);
-//!
-//! let d : (u32, f32) = Default::default();
-//! assert_eq!(d, (0u32, 0.0f32));
-//! ```
-
-#![doc(primitive = "tuple")]
-
-use clone::Clone;
-use cmp::*;
-use default::Default;
-use option::{Option, Some};
-
-// macro for implementing n-ary tuple functions and operations
-macro_rules! tuple_impls {
- ($(
- $Tuple:ident {
- $(($valN:ident, $refN:ident, $mutN:ident) -> $T:ident {
- ($($x:ident),+) => $ret:expr
- })+
- }
- )+) => {
- $(
- #[allow(missing_doc)]
- pub trait $Tuple<$($T),+> {
- $(fn $valN(self) -> $T;)+
- $(fn $refN<'a>(&'a self) -> &'a $T;)+
- $(fn $mutN<'a>(&'a mut self) -> &'a mut $T;)+
- }
-
- impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) {
- $(
- #[inline]
- #[allow(unused_variable)]
- fn $valN(self) -> $T {
- let ($($x,)+) = self; $ret
- }
-
- #[inline]
- #[allow(unused_variable)]
- fn $refN<'a>(&'a self) -> &'a $T {
- let ($(ref $x,)+) = *self; $ret
- }
-
- #[inline]
- #[allow(unused_variable)]
- fn $mutN<'a>(&'a mut self) -> &'a mut $T {
- let ($(ref mut $x,)+) = *self; $ret
- }
- )+
- }
-
- #[unstable]
- impl<$($T:Clone),+> Clone for ($($T,)+) {
- fn clone(&self) -> ($($T,)+) {
- ($(self.$refN().clone(),)+)
- }
- }
-
- impl<$($T:PartialEq),+> PartialEq for ($($T,)+) {
- #[inline]
- fn eq(&self, other: &($($T,)+)) -> bool {
- $(*self.$refN() == *other.$refN())&&+
- }
- #[inline]
- fn ne(&self, other: &($($T,)+)) -> bool {
- $(*self.$refN() != *other.$refN())||+
- }
- }
-
- impl<$($T:Eq),+> Eq for ($($T,)+) {}
-
- impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
- #[inline]
- fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
- lexical_partial_cmp!($(self.$refN(), other.$refN()),+)
- }
- #[inline]
- fn lt(&self, other: &($($T,)+)) -> bool {
- lexical_ord!(lt, $(self.$refN(), other.$refN()),+)
- }
- #[inline]
- fn le(&self, other: &($($T,)+)) -> bool {
- lexical_ord!(le, $(self.$refN(), other.$refN()),+)
- }
- #[inline]
- fn ge(&self, other: &($($T,)+)) -> bool {
- lexical_ord!(ge, $(self.$refN(), other.$refN()),+)
- }
- #[inline]
- fn gt(&self, other: &($($T,)+)) -> bool {
- lexical_ord!(gt, $(self.$refN(), other.$refN()),+)
- }
- }
-
- impl<$($T:Ord),+> Ord for ($($T,)+) {
- #[inline]
- fn cmp(&self, other: &($($T,)+)) -> Ordering {
- lexical_cmp!($(self.$refN(), other.$refN()),+)
- }
- }
-
- impl<$($T:Default),+> Default for ($($T,)+) {
- #[inline]
- fn default() -> ($($T,)+) {
- ($({ let x: $T = Default::default(); x},)+)
- }
- }
- )+
- }
-}
-
-// Constructs an expression that performs a lexical ordering using method $rel.
-// The values are interleaved, so the macro invocation for
-// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_ord!(lt, a1, b1, a2, b2,
-// a3, b3)` (and similarly for `lexical_cmp`)
-macro_rules! lexical_ord {
- ($rel: ident, $a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
- if *$a != *$b { lexical_ord!($rel, $a, $b) }
- else { lexical_ord!($rel, $($rest_a, $rest_b),+) }
- };
- ($rel: ident, $a:expr, $b:expr) => { (*$a) . $rel ($b) };
-}
-
-macro_rules! lexical_partial_cmp {
- ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
- match ($a).partial_cmp($b) {
- Some(Equal) => lexical_partial_cmp!($($rest_a, $rest_b),+),
- ordering => ordering
- }
- };
- ($a:expr, $b:expr) => { ($a).partial_cmp($b) };
-}
-
-macro_rules! lexical_cmp {
- ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
- match ($a).cmp($b) {
- Equal => lexical_cmp!($($rest_a, $rest_b),+),
- ordering => ordering
- }
- };
- ($a:expr, $b:expr) => { ($a).cmp($b) };
-}
-
-tuple_impls! {
- Tuple1 {
- (val0, ref0, mut0) -> A { (a) => a }
- }
- Tuple2 {
- (val0, ref0, mut0) -> A { (a, b) => a }
- (val1, ref1, mut1) -> B { (a, b) => b }
- }
- Tuple3 {
- (val0, ref0, mut0) -> A { (a, b, c) => a }
- (val1, ref1, mut1) -> B { (a, b, c) => b }
- (val2, ref2, mut2) -> C { (a, b, c) => c }
- }
- Tuple4 {
- (val0, ref0, mut0) -> A { (a, b, c, d) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d) => d }
- }
- Tuple5 {
- (val0, ref0, mut0) -> A { (a, b, c, d, e) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d, e) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d, e) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d, e) => d }
- (val4, ref4, mut4) -> E { (a, b, c, d, e) => e }
- }
- Tuple6 {
- (val0, ref0, mut0) -> A { (a, b, c, d, e, f) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d, e, f) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d, e, f) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d, e, f) => d }
- (val4, ref4, mut4) -> E { (a, b, c, d, e, f) => e }
- (val5, ref5, mut5) -> F { (a, b, c, d, e, f) => f }
- }
- Tuple7 {
- (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g) => d }
- (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g) => e }
- (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g) => f }
- (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g) => g }
- }
- Tuple8 {
- (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h) => d }
- (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h) => e }
- (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h) => f }
- (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h) => g }
- (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h) => h }
- }
- Tuple9 {
- (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i) => d }
- (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i) => e }
- (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i) => f }
- (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i) => g }
- (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i) => h }
- (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i) => i }
- }
- Tuple10 {
- (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j) => d }
- (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j) => e }
- (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j) => f }
- (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j) => g }
- (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j) => h }
- (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j) => i }
- (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j) => j }
- }
- Tuple11 {
- (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j, k) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j, k) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j, k) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j, k) => d }
- (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j, k) => e }
- (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j, k) => f }
- (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j, k) => g }
- (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j, k) => h }
- (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j, k) => i }
- (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j, k) => j }
- (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k) => k }
- }
- Tuple12 {
- (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j, k, l) => a }
- (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j, k, l) => b }
- (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j, k, l) => c }
- (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j, k, l) => d }
- (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j, k, l) => e }
- (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j, k, l) => f }
- (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j, k, l) => g }
- (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j, k, l) => h }
- (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j, k, l) => i }
- (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j, k, l) => j }
- (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k, l) => k }
- (val11, ref11, mut11) -> L { (a, b, c, d, e, f, g, h, i, j, k, l) => l }
- }
-}
-
--- /dev/null
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Operations on tuples
+//!
+//! To access a single element of a tuple one can use the following
+//! methods:
+//!
+//! * `valN` - returns a value of _N_-th element
+//! * `refN` - returns a reference to _N_-th element
+//! * `mutN` - returns a mutable reference to _N_-th element
+//!
+//! Indexing starts from zero, so `val0` returns first value, `val1`
+//! returns second value, and so on. In general, a tuple with _S_
+//! elements provides aforementioned methods suffixed with numbers
+//! from `0` to `S-1`. Traits which contain these methods are
+//! implemented for tuples with up to 12 elements.
+//!
+//! If every type inside a tuple implements one of the following
+//! traits, then a tuple itself also implements it.
+//!
+//! * `Clone`
+//! * `PartialEq`
+//! * `Eq`
+//! * `PartialOrd`
+//! * `Ord`
+//! * `Default`
+//!
+//! # Examples
+//!
+//! Using methods:
+//!
+//! ```
+//! let pair = ("pi", 3.14f64);
+//! assert_eq!(pair.val0(), "pi");
+//! assert_eq!(pair.val1(), 3.14f64);
+//! ```
+//!
+//! Using traits implemented for tuples:
+//!
+//! ```
+//! use std::default::Default;
+//!
+//! let a = (1i, 2i);
+//! let b = (3i, 4i);
+//! assert!(a != b);
+//!
+//! let c = b.clone();
+//! assert!(b == c);
+//!
+//! let d : (u32, f32) = Default::default();
+//! assert_eq!(d, (0u32, 0.0f32));
+//! ```
+
+#![doc(primitive = "tuple")]
+
+pub use unit;
+
+use clone::Clone;
+use cmp::*;
+use default::Default;
+use option::{Option, Some};
+
+// macro for implementing n-ary tuple functions and operations
+macro_rules! tuple_impls {
+ ($(
+ $Tuple:ident {
+ $(($valN:ident, $refN:ident, $mutN:ident) -> $T:ident {
+ ($($x:ident),+) => $ret:expr
+ })+
+ }
+ )+) => {
+ $(
+ #[allow(missing_doc)]
+ pub trait $Tuple<$($T),+> {
+ $(fn $valN(self) -> $T;)+
+ $(fn $refN<'a>(&'a self) -> &'a $T;)+
+ $(fn $mutN<'a>(&'a mut self) -> &'a mut $T;)+
+ }
+
+ impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) {
+ $(
+ #[inline]
+ #[allow(unused_variable)]
+ fn $valN(self) -> $T {
+ let ($($x,)+) = self; $ret
+ }
+
+ #[inline]
+ #[allow(unused_variable)]
+ fn $refN<'a>(&'a self) -> &'a $T {
+ let ($(ref $x,)+) = *self; $ret
+ }
+
+ #[inline]
+ #[allow(unused_variable)]
+ fn $mutN<'a>(&'a mut self) -> &'a mut $T {
+ let ($(ref mut $x,)+) = *self; $ret
+ }
+ )+
+ }
+
+ #[unstable]
+ impl<$($T:Clone),+> Clone for ($($T,)+) {
+ fn clone(&self) -> ($($T,)+) {
+ ($(self.$refN().clone(),)+)
+ }
+ }
+
+ impl<$($T:PartialEq),+> PartialEq for ($($T,)+) {
+ #[inline]
+ fn eq(&self, other: &($($T,)+)) -> bool {
+ $(*self.$refN() == *other.$refN())&&+
+ }
+ #[inline]
+ fn ne(&self, other: &($($T,)+)) -> bool {
+ $(*self.$refN() != *other.$refN())||+
+ }
+ }
+
+ impl<$($T:Eq),+> Eq for ($($T,)+) {}
+
+ impl<$($T:PartialOrd + PartialEq),+> PartialOrd for ($($T,)+) {
+ #[inline]
+ fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
+ lexical_partial_cmp!($(self.$refN(), other.$refN()),+)
+ }
+ #[inline]
+ fn lt(&self, other: &($($T,)+)) -> bool {
+ lexical_ord!(lt, $(self.$refN(), other.$refN()),+)
+ }
+ #[inline]
+ fn le(&self, other: &($($T,)+)) -> bool {
+ lexical_ord!(le, $(self.$refN(), other.$refN()),+)
+ }
+ #[inline]
+ fn ge(&self, other: &($($T,)+)) -> bool {
+ lexical_ord!(ge, $(self.$refN(), other.$refN()),+)
+ }
+ #[inline]
+ fn gt(&self, other: &($($T,)+)) -> bool {
+ lexical_ord!(gt, $(self.$refN(), other.$refN()),+)
+ }
+ }
+
+ impl<$($T:Ord),+> Ord for ($($T,)+) {
+ #[inline]
+ fn cmp(&self, other: &($($T,)+)) -> Ordering {
+ lexical_cmp!($(self.$refN(), other.$refN()),+)
+ }
+ }
+
+ impl<$($T:Default),+> Default for ($($T,)+) {
+ #[inline]
+ fn default() -> ($($T,)+) {
+ ($({ let x: $T = Default::default(); x},)+)
+ }
+ }
+ )+
+ }
+}
+
+// Constructs an expression that performs a lexical ordering using method $rel.
+// The values are interleaved, so the macro invocation for
+// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_ord!(lt, a1, b1, a2, b2,
+// a3, b3)` (and similarly for `lexical_cmp`)
+macro_rules! lexical_ord {
+ ($rel: ident, $a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+ if *$a != *$b { lexical_ord!($rel, $a, $b) }
+ else { lexical_ord!($rel, $($rest_a, $rest_b),+) }
+ };
+ ($rel: ident, $a:expr, $b:expr) => { (*$a) . $rel ($b) };
+}
+
+macro_rules! lexical_partial_cmp {
+ ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+ match ($a).partial_cmp($b) {
+ Some(Equal) => lexical_partial_cmp!($($rest_a, $rest_b),+),
+ ordering => ordering
+ }
+ };
+ ($a:expr, $b:expr) => { ($a).partial_cmp($b) };
+}
+
+macro_rules! lexical_cmp {
+ ($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => {
+ match ($a).cmp($b) {
+ Equal => lexical_cmp!($($rest_a, $rest_b),+),
+ ordering => ordering
+ }
+ };
+ ($a:expr, $b:expr) => { ($a).cmp($b) };
+}
+
+tuple_impls! {
+ Tuple1 {
+ (val0, ref0, mut0) -> A { (a) => a }
+ }
+ Tuple2 {
+ (val0, ref0, mut0) -> A { (a, b) => a }
+ (val1, ref1, mut1) -> B { (a, b) => b }
+ }
+ Tuple3 {
+ (val0, ref0, mut0) -> A { (a, b, c) => a }
+ (val1, ref1, mut1) -> B { (a, b, c) => b }
+ (val2, ref2, mut2) -> C { (a, b, c) => c }
+ }
+ Tuple4 {
+ (val0, ref0, mut0) -> A { (a, b, c, d) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d) => d }
+ }
+ Tuple5 {
+ (val0, ref0, mut0) -> A { (a, b, c, d, e) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d, e) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d, e) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d, e) => d }
+ (val4, ref4, mut4) -> E { (a, b, c, d, e) => e }
+ }
+ Tuple6 {
+ (val0, ref0, mut0) -> A { (a, b, c, d, e, f) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d, e, f) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d, e, f) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d, e, f) => d }
+ (val4, ref4, mut4) -> E { (a, b, c, d, e, f) => e }
+ (val5, ref5, mut5) -> F { (a, b, c, d, e, f) => f }
+ }
+ Tuple7 {
+ (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g) => d }
+ (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g) => e }
+ (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g) => f }
+ (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g) => g }
+ }
+ Tuple8 {
+ (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h) => d }
+ (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h) => e }
+ (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h) => f }
+ (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h) => g }
+ (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h) => h }
+ }
+ Tuple9 {
+ (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i) => d }
+ (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i) => e }
+ (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i) => f }
+ (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i) => g }
+ (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i) => h }
+ (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i) => i }
+ }
+ Tuple10 {
+ (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j) => d }
+ (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j) => e }
+ (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j) => f }
+ (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j) => g }
+ (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j) => h }
+ (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j) => i }
+ (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j) => j }
+ }
+ Tuple11 {
+ (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j, k) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j, k) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j, k) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j, k) => d }
+ (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j, k) => e }
+ (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j, k) => f }
+ (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j, k) => g }
+ (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j, k) => h }
+ (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j, k) => i }
+ (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j, k) => j }
+ (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k) => k }
+ }
+ Tuple12 {
+ (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j, k, l) => a }
+ (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j, k, l) => b }
+ (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j, k, l) => c }
+ (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j, k, l) => d }
+ (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j, k, l) => e }
+ (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j, k, l) => f }
+ (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j, k, l) => g }
+ (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j, k, l) => h }
+ (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j, k, l) => i }
+ (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j, k, l) => j }
+ (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k, l) => k }
+ (val11, ref11, mut11) -> L { (a, b, c, d, e, f, g, h, i, j, k, l) => l }
+ }
+}
+
--- /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.
+
+#![doc(primitive = "unit")]
+
+//! The `()` type, sometimes called "unit" or "nil".
+//!
+//! The `()` type has exactly one value `()`, and is used when there
+//! is no other meaningful value that could be returned. `()` is most
+//! commonly seen implicitly: functions without a `-> ...` implicitly
+//! have return type `()`, that is, these are equivalent:
+//!
+//! ```rust
+//! fn long() -> () {}
+//!
+//! fn short() {}
+//! ```
+//!
+//! The semicolon `;` can be used to discard the result of an
+//! expression at the end of a block, making the expression (and thus
+//! the block) evaluate to `()`. For example,
+//!
+//! ```rust
+//! fn returns_i64() -> i64 {
+//! 1i64
+//! }
+//! fn returns_unit() {
+//! 1i64;
+//! }
+//!
+//! let is_i64 = {
+//! returns_i64()
+//! };
+//! let is_unit = {
+//! returns_i64();
+//! };
+//! ```
//! Additionally, it is not guaranteed that functionality such as reflection
//! will persist into the future.
-#![crate_id = "debug#0.11.0-pre"]
+#![crate_id = "debug#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![experimental]
#![feature(managed_boxes, macro_rules)]
#![allow(experimental)]
*/
-#![crate_id = "flate#0.11.0-pre"]
+#![crate_id = "flate#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(phase)]
#[cfg(test)] #[phase(plugin, link)] extern crate log;
//! Parsing does not happen at runtime: structures of `std::fmt::rt` are
//! generated instead.
-#![crate_id = "fmt_macros#0.11.0-pre"]
+#![crate_id = "fmt_macros#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
*/
-#![crate_id = "fourcc#0.11.0-pre"]
+#![crate_id = "fourcc#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(plugin_registrar, managed_boxes)]
//! }
//! ~~~
-#![crate_id = "getopts#0.11.0-pre"]
+#![crate_id = "getopts#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(globs, phase)]
#![deny(missing_doc)]
* `glob`/`fnmatch` functions.
*/
-#![crate_id = "glob#0.11.0-pre"]
+#![crate_id = "glob#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
use std::cell::Cell;
*/
-#![crate_id = "graphviz#0.11.0-pre"]
+#![crate_id = "graphviz#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![experimental]
//! pool.shutdown();
//! ```
-#![crate_id = "green#0.11.0-pre"]
+#![crate_id = "green#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
// NB this does *not* include globs, please keep it that way.
*/
-#![crate_id = "hexfloat#0.11.0-pre"]
+#![crate_id = "hexfloat#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(plugin_registrar, managed_boxes)]
extern crate syntax;
// except according to those terms.
#![feature(globs)]
-#![crate_id = "libc#0.11.0-pre"]
+#![crate_id = "libc#0.11.0"]
#![experimental]
#![no_std] // we don't need std, and we can't have std, since it doesn't exist
// yet. std depends on us.
#![crate_type = "rlib"]
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+ html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
+ html_playground_url = "http://play.rust-lang.org/")]
/*!
* Bindings for the C standard library and other platform libraries
*/
-#![crate_id = "log#0.11.0-pre"]
+#![crate_id = "log#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules)]
pub static FIONBIO: libc::c_long = 0x8004667e;
static FD_SETSIZE: uint = 64;
pub static MSG_DONTWAIT: libc::c_int = 0;
+pub static ERROR_ILLEGAL_CHARACTER: libc::c_int = 582;
+pub static ENABLE_ECHO_INPUT: libc::DWORD = 0x4;
+pub static ENABLE_EXTENDED_FLAGS: libc::DWORD = 0x80;
+pub static ENABLE_INSERT_MODE: libc::DWORD = 0x20;
+pub static ENABLE_LINE_INPUT: libc::DWORD = 0x2;
+pub static ENABLE_PROCESSED_INPUT: libc::DWORD = 0x1;
+pub static ENABLE_QUICK_EDIT_MODE: libc::DWORD = 0x40;
#[repr(C)]
pub struct WSADATA {
})
}
}
+
+extern "system" {
+ // FIXME - pInputControl should be PCONSOLE_READCONSOLE_CONTROL
+ pub fn ReadConsoleW(hConsoleInput: libc::HANDLE,
+ lpBuffer: libc::LPVOID,
+ nNumberOfCharsToRead: libc::DWORD,
+ lpNumberOfCharsRead: libc::LPDWORD,
+ pInputControl: libc::LPVOID) -> libc::BOOL;
+
+ pub fn WriteConsoleW(hConsoleOutput: libc::HANDLE,
+ lpBuffer: libc::types::os::arch::extra::LPCVOID,
+ nNumberOfCharsToWrite: libc::DWORD,
+ lpNumberOfCharsWritten: libc::LPDWORD,
+ lpReserved: libc::LPVOID) -> libc::BOOL;
+
+ pub fn GetConsoleMode(hConsoleHandle: libc::HANDLE,
+ lpMode: libc::LPDWORD) -> libc::BOOL;
+
+ pub fn SetConsoleMode(hConsoleHandle: libc::HANDLE,
+ lpMode: libc::DWORD) -> libc::BOOL;
+}
#[path = "pipe_win32.rs"]
pub mod pipe;
+#[cfg(windows)]
+#[path = "tty_win32.rs"]
+mod tty;
+
#[cfg(unix)] #[path = "c_unix.rs"] mod c;
#[cfg(windows)] #[path = "c_win32.rs"] mod c;
fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<rtio::RtioPipe + Send>> {
Ok(box file::FileDesc::new(fd, true) as Box<rtio::RtioPipe + Send>)
}
+ #[cfg(unix)]
fn tty_open(&mut self, fd: c_int, _readable: bool)
-> IoResult<Box<rtio::RtioTTY + Send>> {
- #[cfg(unix)] use ERROR = libc::ENOTTY;
- #[cfg(windows)] use ERROR = libc::ERROR_INVALID_HANDLE;
if unsafe { libc::isatty(fd) } != 0 {
Ok(box file::FileDesc::new(fd, true) as Box<rtio::RtioTTY + Send>)
} else {
Err(IoError {
- code: ERROR as uint,
+ code: libc::ENOTTY as uint,
+ extra: 0,
+ detail: None,
+ })
+ }
+ }
+ #[cfg(windows)]
+ fn tty_open(&mut self, fd: c_int, _readable: bool)
+ -> IoResult<Box<rtio::RtioTTY + Send>> {
+ if tty::is_tty(fd) {
+ Ok(box tty::WindowsTTY::new(fd) as Box<rtio::RtioTTY + Send>)
+ } else {
+ Err(IoError {
+ code: libc::ERROR_INVALID_HANDLE as uint,
extra: 0,
detail: None,
})
}
}
-
-// Note: although the last parameter isn't used there is no way now to
-// convert it to unit type, because LLVM dies in SjLj preparation
-// step (unfortunately iOS uses SjLJ exceptions)
-//
-// It's definitely a temporary workaround just to get it working.
-// So far it looks like an LLVM issue and it was reported:
-// http://llvm.org/bugs/show_bug.cgi?id=19855
-// Actually this issue is pretty common while compiling for armv7 iOS
-// and in most cases it is simply solved by using --opt-level=2 (or -O)
-//
-// For this specific case unfortunately turning optimizations wasn't
-// enough.
-fn helper(input: libc::c_int, messages: Receiver<Req>, _: int) {
+fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
let mut set: c::fd_set = unsafe { mem::zeroed() };
let mut fd = FileDesc::new(input, true);
pub fn new() -> IoResult<Timer> {
// See notes above regarding using int return value
// instead of ()
- unsafe { HELPER.boot(|| {0}, helper); }
+ unsafe { HELPER.boot(|| {}, helper); }
static mut ID: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
let id = unsafe { ID.fetch_add(1, atomics::Relaxed) };
--- /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.
+
+//! Windows specific console TTY implementation
+//!
+//! This module contains the implementation of a Windows specific console TTY.
+//! Also converts between UTF-16 and UTF-8. Windows has very poor support for
+//! UTF-8 and some functions will fail. In particular ReadFile and ReadConsole
+//! will fail when the codepage is set to UTF-8 and a unicode character is
+//! entered.
+//!
+//! FIXME
+//! This implementation does not account for codepoints that are split across
+//! multiple reads and writes. Also, this implementation does not expose a way
+//! to read/write UTF-16 directly. When/if Rust receives a Reader/Writer
+//! wrapper that performs encoding/decoding, this implementation should switch
+//! to working in raw UTF-16, with such a wrapper around it.
+
+use super::c::{ReadConsoleW, WriteConsoleW, GetConsoleMode, SetConsoleMode};
+use super::c::{ERROR_ILLEGAL_CHARACTER};
+use super::c::{ENABLE_ECHO_INPUT, ENABLE_EXTENDED_FLAGS};
+use super::c::{ENABLE_INSERT_MODE, ENABLE_LINE_INPUT};
+use super::c::{ENABLE_PROCESSED_INPUT, ENABLE_QUICK_EDIT_MODE};
+use libc::{c_int, HANDLE, LPDWORD, DWORD, LPVOID};
+use libc::{get_osfhandle, CloseHandle};
+use libc::types::os::arch::extra::LPCVOID;
+use std::io::MemReader;
+use std::ptr;
+use std::rt::rtio::{IoResult, IoError, RtioTTY};
+use std::str::{from_utf16, from_utf8};
+
+fn invalid_encoding() -> IoError {
+ IoError {
+ code: ERROR_ILLEGAL_CHARACTER as uint,
+ extra: 0,
+ detail: Some("text was not valid unicode".to_string()),
+ }
+}
+
+pub fn is_tty(fd: c_int) -> bool {
+ let mut out: DWORD = 0;
+ // If this function doesn't fail then fd is a TTY
+ match unsafe { GetConsoleMode(get_osfhandle(fd) as HANDLE,
+ &mut out as LPDWORD) } {
+ 0 => false,
+ _ => true,
+ }
+}
+
+pub struct WindowsTTY {
+ closeme: bool,
+ handle: HANDLE,
+ utf8: MemReader,
+}
+
+impl WindowsTTY {
+ pub fn new(fd: c_int) -> WindowsTTY {
+ // If the file descriptor is one of stdin, stderr, or stdout
+ // then it should not be closed by us
+ let closeme = match fd {
+ 0..2 => false,
+ _ => true,
+ };
+ let handle = unsafe { get_osfhandle(fd) as HANDLE };
+ WindowsTTY {
+ handle: handle,
+ utf8: MemReader::new(Vec::new()),
+ closeme: closeme,
+ }
+ }
+}
+
+impl Drop for WindowsTTY {
+ fn drop(&mut self) {
+ if self.closeme {
+ // Nobody cares about the return value
+ let _ = unsafe { CloseHandle(self.handle) };
+ }
+ }
+}
+
+impl RtioTTY for WindowsTTY {
+ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
+ // Read more if the buffer is empty
+ if self.utf8.eof() {
+ let mut utf16 = Vec::from_elem(0x1000, 0u16);
+ let mut num: DWORD = 0;
+ match unsafe { ReadConsoleW(self.handle,
+ utf16.as_mut_ptr() as LPVOID,
+ utf16.len() as u32,
+ &mut num as LPDWORD,
+ ptr::mut_null()) } {
+ 0 => return Err(super::last_error()),
+ _ => (),
+ };
+ utf16.truncate(num as uint);
+ let utf8 = match from_utf16(utf16.as_slice()) {
+ Some(utf8) => utf8.into_bytes(),
+ None => return Err(invalid_encoding()),
+ };
+ self.utf8 = MemReader::new(utf8);
+ }
+ // MemReader shouldn't error here since we just filled it
+ Ok(self.utf8.read(buf).unwrap())
+ }
+
+ fn write(&mut self, buf: &[u8]) -> IoResult<()> {
+ let utf16 = match from_utf8(buf) {
+ Some(utf8) => utf8.to_utf16(),
+ None => return Err(invalid_encoding()),
+ };
+ let mut num: DWORD = 0;
+ match unsafe { WriteConsoleW(self.handle,
+ utf16.as_ptr() as LPCVOID,
+ utf16.len() as u32,
+ &mut num as LPDWORD,
+ ptr::mut_null()) } {
+ 0 => Err(super::last_error()),
+ _ => Ok(()),
+ }
+ }
+
+ fn set_raw(&mut self, raw: bool) -> IoResult<()> {
+ // FIXME
+ // Somebody needs to decide on which of these flags we want
+ match unsafe { SetConsoleMode(self.handle,
+ match raw {
+ true => 0,
+ false => ENABLE_ECHO_INPUT | ENABLE_EXTENDED_FLAGS |
+ ENABLE_INSERT_MODE | ENABLE_LINE_INPUT |
+ ENABLE_PROCESSED_INPUT | ENABLE_QUICK_EDIT_MODE,
+ }) } {
+ 0 => Err(super::last_error()),
+ _ => Ok(()),
+ }
+ }
+
+ fn get_winsize(&mut self) -> IoResult<(int, int)> {
+ // FIXME
+ // Get console buffer via CreateFile with CONOUT$
+ // Make a CONSOLE_SCREEN_BUFFER_INFO
+ // Call GetConsoleScreenBufferInfo
+ // Maybe call GetLargestConsoleWindowSize instead?
+ Err(super::unimpl())
+ }
+
+ // Let us magically declare this as a TTY
+ fn isatty(&self) -> bool { true }
+}
//! }
//! ```
-#![crate_id = "native#0.11.0-pre"]
+#![crate_id = "native#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![deny(unused_result, unused_must_use)]
#![allow(non_camel_case_types, deprecated)]
#![feature(macro_rules)]
-#![crate_id = "num#0.11.0-pre"]
+#![crate_id = "num#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![allow(deprecated)] // from_str_radix
//! is not recommended to use this library directly, but rather the official
//! interface through `std::rand`.
-#![crate_id = "rand#0.11.0-pre"]
+#![crate_id = "rand#0.11.0"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, phase, globs)]
//! characters in the search text and `m` is the number of instructions in a
//! compiled expression.
-#![crate_id = "regex#0.11.0-pre"]
+#![crate_id = "regex#0.11.0"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![experimental]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, phase)]
//! This crate provides the `regex!` macro. Its use is documented in the
//! `regex` crate.
-#![crate_id = "regex_macros#0.11.0-pre"]
+#![crate_id = "regex_macros#0.11.0"]
#![crate_type = "dylib"]
#![experimental]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(plugin_registrar, managed_boxes, quote)]
#[inline]
fn groups<'r>(&'r mut self, i: uint) -> &'r mut Captures {
- &'r mut self.queue[i].groups
+ &mut self.queue[i].groups
}
}
}
//! necessary. It is an error to include this library when also linking with
//! the system libc library.
-#![crate_id = "rlibc#0.11.0-pre"]
+#![crate_id = "rlibc#0.11.0"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(intrinsics)]
#![no_std]
}
None
}
-static os_names : &'static [(&'static str, abi::Os)] = &'static [
+static os_names : &'static [(&'static str, abi::Os)] = &[
("mingw32", abi::OsWin32),
("win32", abi::OsWin32),
("darwin", abi::OsMacos),
}
None
}
-static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'static [
+static architecture_abis : &'static [(&'static str, abi::Architecture)] = &[
("i386", abi::X86),
("i486", abi::X86),
("i586", abi::X86),
use std::mem;
use std::gc::{Gc, GC};
-pub static VERSION: &'static str = "0.11.0-pre";
+pub static VERSION: &'static str = "0.11.0";
pub fn maybe_inject_crates_ref(sess: &Session, krate: ast::Crate)
-> ast::Crate {
*/
-#![crate_id = "rustc#0.11.0-pre"]
+#![crate_id = "rustc#0.11.0"]
#![experimental]
#![comment = "The Rust compiler"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![allow(deprecated)]
#![feature(macro_rules, globs, struct_variant, managed_boxes, quote)]
}
fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) {
- static ATTRIBUTE_WHITELIST: &'static [&'static str] = &'static [
+ static ATTRIBUTE_WHITELIST: &'static [&'static str] = &[
// FIXME: #14408 whitelist docs since rustdoc looks at them
"doc",
"unstable",
];
- static CRATE_ATTRS: &'static [&'static str] = &'static [
+ static CRATE_ATTRS: &'static [&'static str] = &[
"crate_type",
"feature",
"no_start",
Slice(uint)
}
-#[deriving(Clone)]
+#[deriving(Clone, PartialEq)]
enum Usefulness {
- Useful(Vec<Gc<Pat>>),
+ Useful,
+ UsefulWithWitness(Vec<Gc<Pat>>),
NotUseful
}
LeaveOutWitness
}
-impl Usefulness {
- fn useful(self) -> Option<Vec<Gc<Pat>>> {
- match self {
- Useful(pats) => Some(pats),
- _ => None
- }
- }
-}
-
impl<'a> Visitor<()> for MatchCheckCtxt<'a> {
fn visit_expr(&mut self, ex: &Expr, _: ()) {
check_expr(self, ex);
let v = vec!(*pat);
match is_useful(cx, &seen, v.as_slice(), LeaveOutWitness) {
NotUseful => cx.tcx.sess.span_err(pat.span, "unreachable pattern"),
- _ => ()
+ Useful => (),
+ UsefulWithWitness(_) => unreachable!()
}
if arm.guard.is_none() {
let Matrix(mut rows) = seen;
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, m: &Matrix) {
match is_useful(cx, m, [wild()], ConstructWitness) {
- Useful(pats) => {
+ UsefulWithWitness(pats) => {
let witness = match pats.as_slice() {
[witness] => witness,
[] => wild(),
}
NotUseful => {
// This is good, wildcard pattern isn't reachable
- }
+ },
+ _ => unreachable!()
}
}
// Note: is_useful doesn't work on empty types, as the paper notes.
// So it assumes that v is non-empty.
-fn is_useful(cx: &MatchCheckCtxt, m @ &Matrix(ref rows): &Matrix,
+fn is_useful(cx: &MatchCheckCtxt, matrix @ &Matrix(ref rows): &Matrix,
v: &[Gc<Pat>], witness: WitnessPreference) -> Usefulness {
- debug!("{:}", m);
+ debug!("{:}", matrix);
if rows.len() == 0u {
- return Useful(vec!());
+ return match witness {
+ ConstructWitness => UsefulWithWitness(vec!()),
+ LeaveOutWitness => Useful
+ };
}
if rows.get(0).len() == 0u {
return NotUseful;
let constructors = pat_constructors(cx, v[0], left_ty, max_slice_length);
if constructors.is_empty() {
- match missing_constructor(cx, m, left_ty, max_slice_length) {
+ match missing_constructor(cx, matrix, left_ty, max_slice_length) {
None => {
- all_constructors(cx, left_ty, max_slice_length).move_iter().filter_map(|c| {
- is_useful_specialized(cx, m, v, c.clone(),
- left_ty, witness).useful().map(|pats| {
- Useful(match witness {
- ConstructWitness => {
- let arity = constructor_arity(cx, &c, left_ty);
- let subpats = {
- let pat_slice = pats.as_slice();
- Vec::from_fn(arity, |i| {
- pat_slice.get(i).map(|p| p.clone())
- .unwrap_or_else(|| wild())
- })
- };
- let mut result = vec!(construct_witness(cx, &c, subpats, left_ty));
- result.extend(pats.move_iter().skip(arity));
- result
- }
- LeaveOutWitness => vec!()
- })
- })
- }).nth(0).unwrap_or(NotUseful)
+ all_constructors(cx, left_ty, max_slice_length).move_iter().map(|c| {
+ match is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness) {
+ UsefulWithWitness(pats) => UsefulWithWitness({
+ let arity = constructor_arity(cx, &c, left_ty);
+ let subpats = {
+ let pat_slice = pats.as_slice();
+ Vec::from_fn(arity, |i| {
+ pat_slice.get(i).map(|p| p.clone())
+ .unwrap_or_else(|| wild())
+ })
+ };
+ let mut result = vec!(construct_witness(cx, &c, subpats, left_ty));
+ result.extend(pats.move_iter().skip(arity));
+ result
+ }),
+ result => result
+ }
+ }).find(|result| result != &NotUseful).unwrap_or(NotUseful)
},
Some(constructor) => {
let matrix = Matrix(rows.iter().filter_map(|r|
default(cx, r.as_slice())).collect());
match is_useful(cx, &matrix, v.tail(), witness) {
- Useful(pats) => Useful(match witness {
- ConstructWitness => {
- let arity = constructor_arity(cx, &constructor, left_ty);
- let wild_pats = Vec::from_elem(arity, wild());
- let enum_pat = construct_witness(cx, &constructor, wild_pats, left_ty);
- (vec!(enum_pat)).append(pats.as_slice())
- }
- LeaveOutWitness => vec!()
- }),
+ UsefulWithWitness(pats) => {
+ let arity = constructor_arity(cx, &constructor, left_ty);
+ let wild_pats = Vec::from_elem(arity, wild());
+ let enum_pat = construct_witness(cx, &constructor, wild_pats, left_ty);
+ UsefulWithWitness(vec!(enum_pat).append(pats.as_slice()))
+ },
result => result
}
}
}
} else {
- constructors.move_iter().filter_map(|c| {
- is_useful_specialized(cx, m, v, c.clone(), left_ty, witness)
- .useful().map(|pats| Useful(pats))
- }).nth(0).unwrap_or(NotUseful)
+ constructors.move_iter().map(|c|
+ is_useful_specialized(cx, matrix, v, c.clone(), left_ty, witness)
+ ).find(|result| result != &NotUseful).unwrap_or(NotUseful)
}
}
let const_expr = lookup_const_by_id(cx.tcx, did).unwrap();
vec!(ConstantValue(eval_const_expr(cx.tcx, &*const_expr)))
},
+ Some(&DefStruct(_)) => vec!(Single),
Some(&DefVariant(_, id, _)) => vec!(Variant(id)),
_ => vec!()
},
}
}
-fn is_wild(cx: &MatchCheckCtxt, p: Gc<Pat>) -> bool {
- let pat = raw_pat(p);
- match pat.node {
- PatWild | PatWildMulti => true,
- PatIdent(_, _, _) =>
- match cx.tcx.def_map.borrow().find(&pat.id) {
- Some(&DefVariant(_, _, _)) | Some(&DefStatic(..)) => false,
- _ => true
- },
- PatVec(ref before, Some(_), ref after) =>
- before.is_empty() && after.is_empty(),
- _ => false
- }
-}
-
/// This computes the arity of a constructor. The arity of a constructor
/// is how many subpattern patterns of that constructor should be expanded to.
///
}
fn default(cx: &MatchCheckCtxt, r: &[Gc<Pat>]) -> Option<Vec<Gc<Pat>>> {
- if is_wild(cx, r[0]) {
+ if pat_is_binding_or_wild(&cx.tcx.def_map, &*raw_pat(r[0])) {
Some(Vec::from_slice(r.tail()))
} else {
None
fn is_refutable(cx: &MatchCheckCtxt, pat: Gc<Pat>) -> Option<Gc<Pat>> {
let pats = Matrix(vec!(vec!(pat)));
- is_useful(cx, &pats, [wild()], ConstructWitness)
- .useful()
- .map(|pats| {
+ match is_useful(cx, &pats, [wild()], ConstructWitness) {
+ UsefulWithWitness(pats) => {
assert_eq!(pats.len(), 1);
- pats.get(0).clone()
- })
+ Some(pats.get(0).clone())
+ },
+ NotUseful => None,
+ Useful => unreachable!()
+ }
}
// Legality of move bindings checking
use middle::trans::common::*;
use middle::trans::consts;
use middle::trans::controlflow;
-use middle::trans::datum;
use middle::trans::datum::*;
use middle::trans::expr::Dest;
use middle::trans::expr;
use syntax::codemap::Span;
use syntax::parse::token::InternedString;
-// An option identifying a literal: either a unit-like struct or an
-// expression.
+// An option identifying a literal: either an expression or a DefId of a static expression.
enum Lit {
- UnitLikeStructLit(ast::NodeId), // the node ID of the pattern
ExprLit(Gc<ast::Expr>),
ConstLit(ast::DefId), // the def ID of the constant
}
fn lit_to_expr(tcx: &ty::ctxt, a: &Lit) -> Gc<ast::Expr> {
match *a {
ExprLit(existing_a_expr) => existing_a_expr,
- ConstLit(a_const) => const_eval::lookup_const_by_id(tcx, a_const).unwrap(),
- UnitLikeStructLit(_) => fail!("lit_to_expr: unexpected struct lit"),
+ ConstLit(a_const) => const_eval::lookup_const_by_id(tcx, a_const).unwrap()
}
}
fn opt_eq(tcx: &ty::ctxt, a: &Opt, b: &Opt) -> bool {
match (a, b) {
- (&lit(UnitLikeStructLit(a)), &lit(UnitLikeStructLit(b))) => a == b,
(&lit(a), &lit(b)) => {
let a_expr = lit_to_expr(tcx, &a);
let b_expr = lit_to_expr(tcx, &b);
let lit_datum = unpack_datum!(bcx, lit_datum.to_appropriate_datum(bcx));
return single_result(Result::new(bcx, lit_datum.val));
}
- lit(UnitLikeStructLit(pat_id)) => {
- let struct_ty = ty::node_id_to_type(bcx.tcx(), pat_id);
- let datum = datum::rvalue_scratch_datum(bcx, struct_ty, "");
- return single_result(Result::new(bcx, datum.val));
- }
lit(l @ ConstLit(ref def_id)) => {
let lit_ty = ty::node_id_to_type(bcx.tcx(), lit_to_expr(bcx.tcx(), &l).id);
let (llval, _) = consts::get_const_val(bcx.ccx(), *def_id);
let variant = ty::enum_variant_with_id(ccx.tcx(), enum_id, var_id);
var(variant.disr_val, adt::represent_node(bcx, pat_id), var_id)
}
- def::DefFn(..) | def::DefStruct(_) => {
- lit(UnitLikeStructLit(pat_id))
- }
_ => {
ccx.sess().bug("non-variant or struct in variant_opt()");
}
let _indenter = indenter();
let ctor = match opt {
- &lit(UnitLikeStructLit(_)) => check_match::Single,
&lit(x) => check_match::ConstantValue(const_eval::eval_const_expr(
bcx.tcx(), lit_to_expr(bcx.tcx(), &x))),
&range(ref lo, ref hi) => check_match::ConstantRange(
add_to_set(ccx.tcx(), &mut found, lit(ExprLit(l)));
}
ast::PatIdent(..) => {
- // This is one of: an enum variant, a unit-like struct, or a
- // variable binding.
+ // This is either an enum variant or a variable binding.
let opt_def = ccx.tcx.def_map.borrow().find_copy(&cur.id);
match opt_def {
- Some(def::DefVariant(..)) | Some(def::DefStruct(..)) => {
+ Some(def::DefVariant(..)) => {
add_to_set(ccx.tcx(), &mut found,
variant_opt(bcx, cur.id));
}
let pat = *br.pats.get(col);
match pat.node {
ast::PatTup(_) => true,
- ast::PatStruct(_, _, _) | ast::PatEnum(_, _) =>
+ ast::PatEnum(..) | ast::PatIdent(_, _, None) | ast::PatStruct(..) =>
match bcx.tcx().def_map.borrow().find(&pat.id) {
Some(&def::DefFn(..)) |
Some(&def::DefStruct(..)) => true,
use middle::trans::base::push_ctxt;
use middle::trans::base;
use middle::trans::build::*;
-use middle::trans::builder::noname;
use middle::trans::cabi;
use middle::trans::common::*;
use middle::trans::machine;
"the block".with_c_str(
|s| llvm::LLVMAppendBasicBlockInContext(ccx.llcx, llwrapfn, s));
- let builder = ccx.builder.b;
- llvm::LLVMPositionBuilderAtEnd(builder, the_block);
+ let builder = ccx.builder();
+ builder.position_at_end(the_block);
// Array for the arguments we will pass to the rust function.
let mut llrust_args = Vec::new();
debug!("out pointer, foreign={}",
ccx.tn.val_to_str(llforeign_outptr));
let llrust_retptr =
- llvm::LLVMBuildBitCast(builder,
- llforeign_outptr,
- llrust_ret_ty.ptr_to().to_ref(),
- noname());
+ builder.bitcast(llforeign_outptr, llrust_ret_ty.ptr_to());
debug!("out pointer, foreign={} (casted)",
ccx.tn.val_to_str(llrust_retptr));
llrust_args.push(llrust_retptr);
}
None => {
- let slot = {
- "return_alloca".with_c_str(
- |s| llvm::LLVMBuildAlloca(builder,
- llrust_ret_ty.to_ref(),
- s))
- };
+ let slot = builder.alloca(llrust_ret_ty, "return_alloca");
debug!("out pointer, \
allocad={}, \
llrust_ret_ty={}, \
// pointer). It makes adapting types easier, since we can
// always just bitcast pointers.
if !foreign_indirect {
- let lltemp =
- llvm::LLVMBuildAlloca(
- builder, val_ty(llforeign_arg).to_ref(), noname());
- llvm::LLVMBuildStore(
- builder, llforeign_arg, lltemp);
+ let lltemp = builder.alloca(val_ty(llforeign_arg), "");
+ builder.store(llforeign_arg, lltemp);
llforeign_arg = lltemp;
}
// Rust expects.
if llforeign_arg_ty.cast.is_some() {
assert!(!foreign_indirect);
- llforeign_arg = llvm::LLVMBuildBitCast(
- builder, llforeign_arg,
- llrust_ty.ptr_to().to_ref(), noname());
+ llforeign_arg = builder.bitcast(llforeign_arg, llrust_ty.ptr_to());
}
let llrust_arg = if rust_indirect {
llforeign_arg
} else {
- llvm::LLVMBuildLoad(builder, llforeign_arg, noname())
+ builder.load(llforeign_arg)
};
debug!("llrust_arg {}{}: {}", "#",
// Perform the call itself
debug!("calling llrustfn = {}, t = {}", ccx.tn.val_to_str(llrustfn), t.repr(ccx.tcx()));
- let llrust_ret_val = llvm::LLVMBuildCall(builder, llrustfn, llrust_args.as_ptr(),
- llrust_args.len() as c_uint, noname());
-
let attributes = base::get_fn_llvm_attributes(ccx, t);
- for &(idx, attr) in attributes.iter() {
- llvm::LLVMAddCallSiteAttribute(llrust_ret_val, idx as c_uint, attr);
- }
+ let llrust_ret_val = builder.call(llrustfn, llrust_args.as_slice(), attributes.as_slice());
// Get the return value where the foreign fn expects it.
let llforeign_ret_ty = match tys.fn_ty.ret_ty.cast {
None if !tys.ret_def => {
// Function returns `()` or `bot`, which in Rust is the LLVM
// type "{}" but in foreign ABIs is "Void".
- llvm::LLVMBuildRetVoid(builder);
+ builder.ret_void();
}
None if rust_uses_outptr => {
// Rust uses an outpointer, but the foreign ABI does not. Load.
let llrust_outptr = return_alloca.unwrap();
let llforeign_outptr_casted =
- llvm::LLVMBuildBitCast(builder,
- llrust_outptr,
- llforeign_ret_ty.ptr_to().to_ref(),
- noname());
- let llforeign_retval =
- llvm::LLVMBuildLoad(builder, llforeign_outptr_casted, noname());
- llvm::LLVMBuildRet(builder, llforeign_retval);
+ builder.bitcast(llrust_outptr, llforeign_ret_ty.ptr_to());
+ let llforeign_retval = builder.load(llforeign_outptr_casted);
+ builder.ret(llforeign_retval);
}
None if llforeign_ret_ty != llrust_ret_ty => {
// right now we just use a temp memory location and
// bitcast the pointer, which is the same thing the
// old wrappers used to do.
- let lltemp =
- llvm::LLVMBuildAlloca(
- builder, llforeign_ret_ty.to_ref(), noname());
- let lltemp_casted =
- llvm::LLVMBuildBitCast(builder,
- lltemp,
- llrust_ret_ty.ptr_to().to_ref(),
- noname());
- llvm::LLVMBuildStore(
- builder, llrust_ret_val, lltemp_casted);
- let llforeign_retval =
- llvm::LLVMBuildLoad(builder, lltemp, noname());
- llvm::LLVMBuildRet(builder, llforeign_retval);
+ let lltemp = builder.alloca(llforeign_ret_ty, "");
+ let lltemp_casted = builder.bitcast(lltemp, llrust_ret_ty.ptr_to());
+ builder.store(llrust_ret_val, lltemp_casted);
+ let llforeign_retval = builder.load(lltemp);
+ builder.ret(llforeign_retval);
}
None => {
// Neither ABI uses an outpointer, and the types
// match. Easy peasy.
- llvm::LLVMBuildRet(builder, llrust_ret_val);
+ builder.ret(llrust_ret_val);
}
Some(llforeign_outptr) if !rust_uses_outptr => {
// Foreign ABI requires an out pointer, but Rust doesn't.
// Store Rust return value.
let llforeign_outptr_casted =
- llvm::LLVMBuildBitCast(builder,
- llforeign_outptr,
- llrust_retptr_ty.to_ref(),
- noname());
- llvm::LLVMBuildStore(
- builder, llrust_ret_val, llforeign_outptr_casted);
- llvm::LLVMBuildRetVoid(builder);
+ builder.bitcast(llforeign_outptr, llrust_retptr_ty);
+ builder.store(llrust_ret_val, llforeign_outptr_casted);
+ builder.ret_void();
}
Some(_) => {
// Both ABIs use outpointers. Easy peasy.
- llvm::LLVMBuildRetVoid(builder);
+ builder.ret_void();
}
}
}
}
}
- (&ty::ty_param(ref a_p), &ty::ty_param(ref b_p)) if a_p.idx == b_p.idx => {
+ (&ty::ty_param(ref a_p), &ty::ty_param(ref b_p)) if
+ a_p.idx == b_p.idx && a_p.space == b_p.space => {
Ok(a)
}
F32, F64,
Char,
Bool,
- Nil,
+ Unit,
Str,
Slice,
PrimitiveTuple,
"u32" => Some(U32),
"u64" => Some(U64),
"bool" => Some(Bool),
- "nil" => Some(Nil),
+ "unit" => Some(Unit),
"char" => Some(Char),
"str" => Some(Str),
"f32" => Some(F32),
Str => "str",
Bool => "bool",
Char => "char",
- Nil => "()",
+ Unit => "()",
Slice => "slice",
PrimitiveTuple => "tuple",
}
pub fn to_url_str(&self) -> &'static str {
match *self {
- Nil => "nil",
+ Unit => "unit",
other => other.to_str(),
}
}
fn clean(&self) -> Type {
use syntax::ast::*;
match self.node {
- TyNil => Primitive(Nil),
+ TyNil => Primitive(Unit),
TyPtr(ref m) => RawPointer(m.mutbl.clean(), box m.ty.clean()),
TyRptr(ref l, ref m) =>
BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(),
fn clean(&self) -> Type {
match ty::get(*self).sty {
ty::ty_bot => Bottom,
- ty::ty_nil => Primitive(Nil),
+ ty::ty_nil => Primitive(Unit),
ty::ty_bool => Primitive(Bool),
ty::ty_char => Primitive(Char),
ty::ty_int(ast::TyI) => Primitive(Int),
},
args = decl.decl.inputs,
arrow = match decl.decl.output {
- clean::Primitive(clean::Nil) => "".to_string(),
+ clean::Primitive(clean::Unit) => "".to_string(),
_ => format!(" -> {}", decl.decl.output),
},
bounds = {
m.collect::<Vec<String>>().connect(" + "))
},
arrow = match decl.decl.output {
- clean::Primitive(clean::Nil) => "".to_string(),
+ clean::Primitive(clean::Unit) => "".to_string(),
_ => format!(" -> {}", decl.decl.output)
})
}
write!(f, "({args}){arrow}",
args = self.inputs,
arrow = match self.output {
- clean::Primitive(clean::Nil) => "".to_string(),
+ clean::Primitive(clean::Unit) => "".to_string(),
_ => format!(" -> {}", self.output),
})
}
write!(f, "({args}){arrow}",
args = args,
arrow = match d.output {
- clean::Primitive(clean::Nil) => "".to_string(),
+ clean::Primitive(clean::Unit) => "".to_string(),
_ => format!(" -> {}", d.output),
})
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![crate_id = "rustdoc#0.11.0-pre"]
+#![crate_id = "rustdoc#0.11.0"]
#![experimental]
#![desc = "rustdoc, the Rust documentation extractor"]
#![license = "MIT/ASL2"]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![crate_id = "rustrt#0.11.0-pre"]
+#![crate_id = "rustrt#0.11.0"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)]
#![feature(linkage, lang_items, unsafe_destructor)]
*/
-#![crate_id = "rustuv#0.11.0-pre"]
+#![crate_id = "rustuv#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+ html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
+ html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, unsafe_destructor)]
#![deny(unused_result, unused_must_use)]
//! An example version number with all five components is
//! `0.8.1-rc.3.0+20130922.linux`.
-#![crate_id = "semver#0.11.0-pre"]
+#![crate_id = "semver#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
use std::char;
use std::cmp;
pub type EncodeResult = io::IoResult<()>;
pub type DecodeResult<T> = Result<T, DecoderError>;
-fn escape_str(s: &str) -> String {
- let mut escaped = String::from_str("\"");
- for c in s.chars() {
- match c {
- '"' => escaped.push_str("\\\""),
- '\\' => escaped.push_str("\\\\"),
- '\x08' => escaped.push_str("\\b"),
- '\x0c' => escaped.push_str("\\f"),
- '\n' => escaped.push_str("\\n"),
- '\r' => escaped.push_str("\\r"),
- '\t' => escaped.push_str("\\t"),
- _ => escaped.push_char(c),
+pub fn escape_bytes(wr: &mut io::Writer, bytes: &[u8]) -> Result<(), io::IoError> {
+ try!(wr.write_str("\""));
+
+ let mut start = 0;
+
+ for (i, byte) in bytes.iter().enumerate() {
+ let escaped = match *byte {
+ b'"' => "\\\"",
+ b'\\' => "\\\\",
+ b'\x08' => "\\b",
+ b'\x0c' => "\\f",
+ b'\n' => "\\n",
+ b'\r' => "\\r",
+ b'\t' => "\\t",
+ _ => { continue; }
+ };
+
+ if start < i {
+ try!(wr.write(bytes.slice(start, i)));
}
- };
- escaped.push_char('"');
- escaped
+
+ try!(wr.write_str(escaped));
+
+ start = i + 1;
+ }
+
+ if start != bytes.len() {
+ try!(wr.write(bytes.slice_from(start)));
+ }
+
+ wr.write_str("\"")
+}
+
+fn escape_str(writer: &mut io::Writer, v: &str) -> Result<(), io::IoError> {
+ escape_bytes(writer, v.as_bytes())
+}
+
+fn escape_char(writer: &mut io::Writer, v: char) -> Result<(), io::IoError> {
+ let mut buf = [0, .. 4];
+ v.encode_utf8(buf);
+ escape_bytes(writer, buf)
+}
+
+fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
+ static len: uint = 16;
+ static buf: [u8, ..len] = [b' ', ..len];
+
+ while n >= len {
+ try!(wr.write(buf));
+ n -= len;
+ }
+
+ if n > 0 {
+ wr.write(buf.slice_to(n))
+ } else {
+ Ok(())
+ }
}
fn fmt_number_or_null(v: f64) -> String {
}
}
-fn spaces(n: uint) -> String {
- String::from_char(n, ' ')
-}
-
/// A structure for implementing serialization to JSON.
pub struct Encoder<'a> {
writer: &'a mut io::Writer,
fn emit_f32(&mut self, v: f32) -> EncodeResult { self.emit_f64(v as f64) }
fn emit_char(&mut self, v: char) -> EncodeResult {
- self.emit_str(str::from_char(v).as_slice())
+ escape_char(self.writer, v)
}
fn emit_str(&mut self, v: &str) -> EncodeResult {
- write!(self.writer, "{}", escape_str(v))
+ escape_str(self.writer, v)
}
fn emit_enum(&mut self, _name: &str, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
// Bunny => "Bunny"
// Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
if cnt == 0 {
- write!(self.writer, "{}", escape_str(name))
+ escape_str(self.writer, name)
} else {
try!(write!(self.writer, "{{\"variant\":"));
- try!(write!(self.writer, "{}", escape_str(name)));
+ try!(escape_str(self.writer, name));
try!(write!(self.writer, ",\"fields\":["));
try!(f(self));
write!(self.writer, "]}}")
idx: uint,
f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
if idx != 0 { try!(write!(self.writer, ",")); }
- try!(write!(self.writer, "{}:", escape_str(name)));
+ try!(escape_str(self.writer, name));
+ try!(write!(self.writer, ":"));
f(self)
}
}
fn emit_char(&mut self, v: char) -> EncodeResult {
- self.emit_str(str::from_char(v).as_slice())
+ escape_char(self.writer, v)
}
fn emit_str(&mut self, v: &str) -> EncodeResult {
- write!(self.writer, "{}", escape_str(v))
+ escape_str(self.writer, v)
}
fn emit_enum(&mut self,
cnt: uint,
f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
if cnt == 0 {
- write!(self.writer, "{}", escape_str(name))
+ escape_str(self.writer, name)
} else {
self.indent += 2;
- try!(write!(self.writer, "[\n{}{},\n", spaces(self.indent),
- escape_str(name)));
+ try!(write!(self.writer, "[\n"));
+ try!(spaces(self.writer, self.indent));
+ try!(escape_str(self.writer, name));
+ try!(write!(self.writer, ",\n"));
try!(f(self));
self.indent -= 2;
- write!(self.writer, "\n{}]", spaces(self.indent))
+ try!(write!(self.writer, "\n"));
+ try!(spaces(self.writer, self.indent));
+ write!(self.writer, "]")
}
}
if idx != 0 {
try!(write!(self.writer, ",\n"));
}
- try!(write!(self.writer, "{}", spaces(self.indent)));
+ try!(spaces(self.writer, self.indent));
f(self)
}
self.indent += 2;
try!(f(self));
self.indent -= 2;
- write!(self.writer, "\n{}}}", spaces(self.indent))
+ try!(write!(self.writer, "\n"));
+ try!(spaces(self.writer, self.indent));
+ write!(self.writer, "}}")
}
}
} else {
try!(write!(self.writer, ",\n"));
}
- try!(write!(self.writer, "{}{}: ", spaces(self.indent), escape_str(name)));
+ try!(spaces(self.writer, self.indent));
+ try!(escape_str(self.writer, name));
+ try!(write!(self.writer, ": "));
f(self)
}
self.indent += 2;
try!(f(self));
self.indent -= 2;
- write!(self.writer, "\n{}]", spaces(self.indent))
+ try!(write!(self.writer, "\n"));
+ try!(spaces(self.writer, self.indent));
+ write!(self.writer, "]")
}
}
} else {
try!(write!(self.writer, ",\n"));
}
- try!(write!(self.writer, "{}", spaces(self.indent)));
+ try!(spaces(self.writer, self.indent));
f(self)
}
self.indent += 2;
try!(f(self));
self.indent -= 2;
- write!(self.writer, "\n{}}}", spaces(self.indent))
+ try!(write!(self.writer, "\n"));
+ try!(spaces(self.writer, self.indent));
+ write!(self.writer, "}}")
}
}
} else {
try!(write!(self.writer, ",\n"));
}
- try!(write!(self.writer, "{}", spaces(self.indent)));
+ try!(spaces(self.writer, self.indent));
// ref #12967, make sure to wrap a key in double quotes,
// in the event that its of a type that omits them (eg numbers)
let mut buf = MemWriter::new();
/// Provides access to the current position in the logical structure of the
/// JSON stream.
pub fn stack<'l>(&'l self) -> &'l Stack {
- return &'l self.stack;
+ return &self.stack;
}
fn eof(&self) -> bool { self.ch.is_none() }
Core encoding and decoding interfaces.
*/
-#![crate_id = "serialize#0.11.0-pre"]
+#![crate_id = "serialize#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, managed_boxes, default_type_params, phase)]
unsafe {
debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
- (&'a *self.keys.offset(idx),
- &'a *self.vals.offset(idx))
+ (&*self.keys.offset(idx), &*self.vals.offset(idx))
}
}
unsafe {
debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
- (&'a *self.keys.offset(idx),
- &'a mut *self.vals.offset(idx))
+ (&*self.keys.offset(idx), &mut *self.vals.offset(idx))
}
}
unsafe {
debug_assert!(*self.hashes.offset(idx) != EMPTY_BUCKET);
(transmute(self.hashes.offset(idx)),
- &'a mut *self.keys.offset(idx),
- &'a mut *self.vals.offset(idx))
+ &mut *self.keys.offset(idx), &mut *self.vals.offset(idx))
}
}
//! all the standard macros, such as `assert!`, `fail!`, `println!`,
//! and `format!`, also available to all Rust code.
-#![crate_id = "std#0.11.0-pre"]
+#![crate_id = "std#0.11.0"]
#![unstable]
#![comment = "The Rust standard library"]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, globs, managed_boxes, linkage)]
pub use core::raw;
pub use core::simd;
pub use core::tuple;
+// FIXME #15320: primitive documentation needs top-level modules, this
+// should be `std::tuple::unit`.
+pub use core::unit;
#[cfg(not(test))] pub use core::ty;
pub use core::result;
pub use core::option;
use slice::{MutableVector};
extern {
- fn backtrace(buf: *mut *const libc::c_void,
+ fn backtrace(buf: *mut *mut libc::c_void,
sz: libc::c_int) -> libc::c_int;
}
try!(writeln!(w, "stack backtrace:"));
// 100 lines should be enough
static SIZE: libc::c_int = 100;
- let mut buf: [*const libc::c_void, ..SIZE] = unsafe {mem::zeroed()};
+ let mut buf: [*mut libc::c_void, ..SIZE] = unsafe {mem::zeroed()};
let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE) as uint};
// skipping the first one as it is write itself
//! use this crate specifically. Instead, its functionality is reexported
//! through `std::sync`.
-#![crate_id = "sync#0.11.0-pre"]
+#![crate_id = "sync#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(phase, globs, macro_rules, unsafe_destructor)]
*/
-#![crate_id = "syntax#0.11.0-pre"]
+#![crate_id = "syntax#0.11.0"]
#![experimental]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(macro_rules, globs, managed_boxes, default_type_params, phase)]
#![feature(quote, unsafe_destructor)]
}
token::BINOP(token::AND) | token::ANDAND => {
self.expect_and();
- let _lt = self.parse_opt_lifetime();
let m = self.parse_mutability();
let e = self.parse_prefix_expr();
hi = e.span.hi;
//! [win]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%28v=vs.85%29.aspx
//! [ti]: https://en.wikipedia.org/wiki/Terminfo
-#![crate_id = "term#0.11.0-pre"]
+#![crate_id = "term#0.11.0"]
#![experimental]
#![comment = "Simple ANSI color library"]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules, phase)]
// These are the orders ncurses uses in its compiled format (as of 5.9). Not sure if portable.
-pub static boolfnames: &'static[&'static str] = &'static["auto_left_margin", "auto_right_margin",
+pub static boolfnames: &'static[&'static str] = &["auto_left_margin", "auto_right_margin",
"no_esc_ctlc", "ceol_standout_glitch", "eat_newline_glitch", "erase_overstrike", "generic_type",
"hard_copy", "has_meta_key", "has_status_line", "insert_null_glitch", "memory_above",
"memory_below", "move_insert_mode", "move_standout_mode", "over_strike", "status_line_esc_ok",
"no_correctly_working_cr", "gnu_has_meta_key", "linefeed_is_newline", "has_hardware_tabs",
"return_does_clr_eol"];
-pub static boolnames: &'static[&'static str] = &'static["bw", "am", "xsb", "xhp", "xenl", "eo",
+pub static boolnames: &'static[&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo",
"gn", "hc", "km", "hs", "in", "db", "da", "mir", "msgr", "os", "eslok", "xt", "hz", "ul", "xon",
"nxon", "mc5i", "chts", "nrrmc", "npc", "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy",
"xvpa", "sam", "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "OTpt", "OTxr"];
-pub static numfnames: &'static[&'static str] = &'static[ "columns", "init_tabs", "lines",
+pub static numfnames: &'static[&'static str] = &[ "columns", "init_tabs", "lines",
"lines_of_memory", "magic_cookie_glitch", "padding_baud_rate", "virtual_terminal",
"width_status_line", "num_labels", "label_height", "label_width", "max_attributes",
"maximum_windows", "max_colors", "max_pairs", "no_color_video", "buffer_capacity",
"bit_image_entwining", "bit_image_type", "magic_cookie_glitch_ul", "carriage_return_delay",
"new_line_delay", "backspace_delay", "horizontal_tab_delay", "number_of_function_keys"];
-pub static numnames: &'static[&'static str] = &'static[ "cols", "it", "lines", "lm", "xmc", "pb",
+pub static numnames: &'static[&'static str] = &[ "cols", "it", "lines", "lm", "xmc", "pb",
"vt", "wsl", "nlab", "lh", "lw", "ma", "wnum", "colors", "pairs", "ncv", "bufsz", "spinv",
"spinh", "maddr", "mjump", "mcs", "mls", "npins", "orc", "orl", "orhi", "orvi", "cps", "widcs",
"btns", "bitwin", "bitype", "UTug", "OTdC", "OTdN", "OTdB", "OTdT", "OTkn"];
-pub static stringfnames: &'static[&'static str] = &'static[ "back_tab", "bell", "carriage_return",
+pub static stringfnames: &'static[&'static str] = &[ "back_tab", "bell", "carriage_return",
"change_scroll_region", "clear_all_tabs", "clear_screen", "clr_eol", "clr_eos",
"column_address", "command_character", "cursor_address", "cursor_down", "cursor_home",
"cursor_invisible", "cursor_left", "cursor_mem_address", "cursor_normal", "cursor_right",
"acs_lrcorner", "acs_ltee", "acs_rtee", "acs_btee", "acs_ttee", "acs_hline", "acs_vline",
"acs_plus", "memory_lock", "memory_unlock", "box_chars_1"];
-pub static stringnames: &'static[&'static str] = &'static[ "cbt", "_", "cr", "csr", "tbc", "clear",
+pub static stringnames: &'static[&'static str] = &[ "cbt", "_", "cr", "csr", "tbc", "clear",
"_", "_", "hpa", "cmdch", "cup", "cud1", "home", "civis", "cub1", "mrcup", "cnorm", "cuf1",
"ll", "cuu1", "cvvis", "dch1", "dl1", "dsl", "hd", "smacs", "blink", "bold", "smcup", "smdc",
"dim", "smir", "invis", "prot", "rev", "smso", "smul", "ech", "rmacs", "sgr0", "rmcup", "rmdc",
// running tests while providing a base that other test frameworks may
// build off of.
-#![crate_id = "test#0.11.0-pre"]
+#![crate_id = "test#0.11.0"]
#![experimental]
#![comment = "Rust internal test library only used by rustc"]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/")]
+ html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(asm, macro_rules, phase)]
//! Simple time handling.
-#![crate_id = "time#0.11.0-pre"]
+#![crate_id = "time#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(phase)]
}
/**
- * Return a string of the current time in the form
- * "Thu Jan 1 00:00:00 1970".
+ * Returns a time string formatted according to the `asctime` format in ISO
+ * C, in the local timezone.
+ *
+ * Example: "Thu Jan 1 00:00:00 1970"
+ */
+ pub fn ctime(&self) -> String {
+ self.to_local().asctime()
+ }
+
+ /**
+ * Returns a time string formatted according to the `asctime` format in ISO
+ * C.
+ *
+ * Example: "Thu Jan 1 00:00:00 1970"
*/
- pub fn ctime(&self) -> String { self.strftime("%c") }
+ pub fn asctime(&self) -> String {
+ self.strftime("%c")
+ }
/// Formats the time according to the format string.
pub fn strftime(&self, format: &str) -> String {
assert_eq!(strptime("360", "%Y-%m-%d"), Err("Invalid year".to_string()))
}
+ fn test_asctime() {
+ set_time_zone();
+
+ let time = Timespec::new(1234567890, 54321);
+ let utc = at_utc(time);
+ let local = at(time);
+
+ debug!("test_ctime: {:?} {:?}", utc.asctime(), local.asctime());
+
+ assert_eq!(utc.asctime(), "Fri Feb 13 23:31:30 2009".to_string());
+ assert_eq!(local.asctime(), "Fri Feb 13 15:31:30 2009".to_string());
+ }
+
fn test_ctime() {
set_time_zone();
debug!("test_ctime: {:?} {:?}", utc.ctime(), local.ctime());
- assert_eq!(utc.ctime(), "Fri Feb 13 23:31:30 2009".to_string());
+ assert_eq!(utc.ctime(), "Fri Feb 13 15:31:30 2009".to_string());
assert_eq!(local.ctime(), "Fri Feb 13 15:31:30 2009".to_string());
}
assert_eq!(local.strftime("%z"), "-0800".to_string());
assert_eq!(local.strftime("%%"), "%".to_string());
+ assert_eq!(local.asctime(), "Fri Feb 13 15:31:30 2009".to_string());
assert_eq!(local.ctime(), "Fri Feb 13 15:31:30 2009".to_string());
assert_eq!(local.rfc822z(), "Fri, 13 Feb 2009 15:31:30 -0800".to_string());
assert_eq!(local.rfc3339(), "2009-02-13T15:31:30-08:00".to_string());
- assert_eq!(utc.ctime(), "Fri Feb 13 23:31:30 2009".to_string());
+ assert_eq!(utc.asctime(), "Fri Feb 13 23:31:30 2009".to_string());
+ assert_eq!(utc.ctime(), "Fri Feb 13 15:31:30 2009".to_string());
assert_eq!(utc.rfc822(), "Fri, 13 Feb 2009 23:31:30 GMT".to_string());
assert_eq!(utc.rfc822z(), "Fri, 13 Feb 2009 23:31:30 -0000".to_string());
assert_eq!(utc.rfc3339(), "2009-02-13T23:31:30Z".to_string());
test_to_timespec();
test_conversions();
test_strptime();
+ test_asctime();
test_ctime();
test_strftime();
test_timespec_eq_ord();
//! Types/fns concerning URLs (see RFC 3986)
-#![crate_id = "url#0.11.0-pre"]
+#![crate_id = "url#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(default_type_params)]
*/
-#![crate_id = "uuid#0.11.0-pre"]
+#![crate_id = "uuid#0.11.0"]
#![experimental]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![license = "MIT/ASL2"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
- html_root_url = "http://doc.rust-lang.org/",
+ html_root_url = "http://doc.rust-lang.org/0.11.0/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(default_type_params)]
// no-prefer-dynamic
-#![crate_id = "url#0.11.0-pre"]
+#![crate_id = "url#0.11.0"]
#![crate_type = "dylib"]
// no-prefer-dynamic
-#![crate_id = "url#0.11.0-pre"]
+#![crate_id = "url#0.11.0"]
#![crate_type = "rlib"]
static STATIC2: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
static STATIC3: MyUnsafe<int> = MyUnsafe{value: STATIC2};
-static STATIC4: &'static Unsafe<int> = &'static STATIC2;
+static STATIC4: &'static Unsafe<int> = &STATIC2;
//~^ ERROR borrow of immutable static items with unsafe interior is not allowed
struct Wrap<T> {
field2: Variant4("str".to_string())
};
-static STATIC15: &'static [Box<MyOwned>] = &'static [box MyOwned, box MyOwned];
+static STATIC15: &'static [Box<MyOwned>] = &[box MyOwned, box MyOwned];
//~^ ERROR static items are not allowed to have custom pointers
//~^^ ERROR static items are not allowed to have custom pointers
static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) =
- (&'static box MyOwned, &'static box MyOwned);
+ (&box MyOwned, &box MyOwned);
//~^ ERROR static items are not allowed to have custom pointers
//~^^ ERROR static items are not allowed to have custom pointers
--- /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.
+
+use std::num::Num;
+
+trait BrokenAdd: Num {
+ fn broken_add<T>(&self, rhs: T) -> Self {
+ *self + rhs //~ ERROR mismatched types
+ }
+}
+
+impl<T: Num> BrokenAdd for T {}
+
+pub fn main() {
+ let foo: u8 = 0u8;
+ let x: u8 = foo.broken_add("hello darkness my old friend".to_string());
+ println!("{}", x);
+}
--- /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.
+
+trait Tr<T> {
+ fn op(T) -> Self;
+}
+
+// these compile as if Self: Tr<U>, even tho only Self: Tr<Self or T>
+trait A: Tr<Self> {
+ fn test<U>(u: U) -> Self {
+ Tr::op(u) //~ ERROR expected Tr<U>, but found Tr<Self>
+ }
+}
+trait B<T>: Tr<T> {
+ fn test<U>(u: U) -> Self {
+ Tr::op(u) //~ ERROR expected Tr<U>, but found Tr<T>
+ }
+}
+
+impl<T> Tr<T> for T {
+ fn op(t: T) -> T { t }
+}
+impl<T> A for T {}
+
+fn main() {
+ std::io::println(A::test((&7306634593706211700, 8)));
+}
+
--- /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.
+
+trait Tr {
+ fn test<X>(u: X) -> Self {
+ u //~ ERROR mismatched types
+ }
+}
+
+fn main() {}
+
-include ../tools.mk
all:
- [ `$(RUSTC) --crate-id crate.rs` = "foo#0.11.0-pre" ]
+ [ `$(RUSTC) --crate-id crate.rs` = "foo#0.11.0" ]
[ `$(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.11.0-pre"]
+#![crate_id = "foo#0.11.0"]
// 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
--- /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.
+
+struct S;
+
+fn main() {
+ match Some(&S) {
+ Some(&S) => {},
+ _x => unreachable!()
+ }
+ match Some(&S) {
+ Some(&S) => {},
+ None => unreachable!()
+ }
+}
// except according to those terms.
struct T (&'static [int]);
-static t : T = T (&'static [5, 4, 3]);
+static t : T = T (&[5, 4, 3]);
pub fn main () {
let T(ref v) = t;
assert_eq!(v[0], 5);
static instance: UninterpretedOption_NamePart = UninterpretedOption_NamePart {
name_part: None,
};
- &'static instance
+ &instance
}
}
// size of struct may be not equal to size of struct, and
// compiler crashes in internal assertion check.
};
- &'static instance
+ &instance
}
fn non_default_instance() -> &'static Request {
foo: TestSome(0x1020304050607080),
bar: 19,
};
- &'static instance
+ &instance
}
pub fn main() {
// This test checks that the `_` type placeholder works
// correctly for enabling type inference.
-static CONSTEXPR: *const int = &'static 413 as *const _;
+static CONSTEXPR: *const int = &413 as *const _;
pub fn main() {
let x: Vec<_> = range(0u, 5).collect();
#![no_std]
extern crate std;
extern crate zed = "std";
-extern crate bar = "std#0.11.0-pre";
+extern crate bar = "std#0.11.0";
use std::str;