auto merge of #12848 : alexcrichton/rust/rollup, r=alexcrichton
This commit is contained in:
commit
4d64441bcb
36 changed files with 266 additions and 140 deletions
|
|
@ -147,6 +147,10 @@ SHOULD_BUILD_PDF_DOC_$(1) = 1
|
|||
endef
|
||||
$(foreach docname,$(PDF_DOCS),$(eval $(call DEF_SHOULD_BUILD_PDF_DOC,$(docname))))
|
||||
|
||||
doc/footer.tex: $(D)/footer.inc | doc/
|
||||
@$(call E, pandoc: $@)
|
||||
$(CFG_PANDOC) --from=html --to=latex $< --output=$@
|
||||
|
||||
define DEF_DOC
|
||||
|
||||
# HTML (rustdoc)
|
||||
|
|
@ -163,10 +167,6 @@ doc/$(1).epub: $$(D)/$(1).md | doc/
|
|||
@$$(call E, pandoc: $$@)
|
||||
$$(CFG_PANDOC) $$(PANDOC_EPUB_OPTS) $$< --output=$$@
|
||||
|
||||
doc/footer.tex: $(D)/footer.inc | doc/
|
||||
@$$(call E, pandoc: $$@)
|
||||
$$(CFG_PANDOC) --from=html --to=latex $$< --output=$$@
|
||||
|
||||
# PDF (md =(pandoc)=> tex =(pdflatex)=> pdf)
|
||||
DOC_TARGETS += doc/$(1).tex
|
||||
doc/$(1).tex: $$(D)/$(1).md doc/footer.tex doc/version.tex | doc/
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@ li {list-style-type: none; }
|
|||
* [The `getopts` argument parsing library](getopts/index.html)
|
||||
* [The `glob` file path matching library](glob/index.html)
|
||||
* [The `green` M:N runtime library](green/index.html)
|
||||
* [The `hexfloat` library for hexadecimal floating-point literals](hexfloat/index.html)
|
||||
* [The `native` 1:1 threading runtime](native/index.html)
|
||||
* [The `num` arbitrary precision numerics library](num/index.html)
|
||||
* [The `rand` library for random numbers and distributions](rand/index.html)
|
||||
* [The `rustc` compiler](rustc/index.html)
|
||||
* [The `rustuv` M:N I/O library](rustuv/index.html)
|
||||
* [The `semver` version collation library](semver/index.html)
|
||||
|
|
|
|||
|
|
@ -1472,7 +1472,6 @@ and are instead terminated by a semicolon.
|
|||
|
||||
~~~~
|
||||
# use std::libc::{c_char, FILE};
|
||||
# #[nolink]
|
||||
|
||||
extern {
|
||||
fn fopen(filename: *c_char, mode: *c_char) -> *FILE;
|
||||
|
|
|
|||
|
|
@ -570,6 +570,11 @@ fn indenting_middle_of_line() {
|
|||
pull_me_back_in();
|
||||
}
|
||||
}
|
||||
|
||||
fn indented_already() {
|
||||
|
||||
// The previous line already has its spaces
|
||||
}
|
||||
"
|
||||
|
||||
;; Symbol -> (line column)
|
||||
|
|
@ -596,7 +601,15 @@ fn indenting_middle_of_line() {
|
|||
(after-whitespace-indent-start (13 1))
|
||||
(after-whitespace-indent-target (13 8))
|
||||
(middle-pull-indent-start (15 19))
|
||||
(middle-pull-indent-target (15 12))))
|
||||
(middle-pull-indent-target (15 12))
|
||||
(blank-line-indented-already-bol-start (20 0))
|
||||
(blank-line-indented-already-bol-target (20 4))
|
||||
(blank-line-indented-already-middle-start (20 2))
|
||||
(blank-line-indented-already-middle-target (20 4))
|
||||
(nonblank-line-indented-already-bol-start (21 0))
|
||||
(nonblank-line-indented-already-bol-target (21 4))
|
||||
(nonblank-line-indented-already-middle-start (21 2))
|
||||
(nonblank-line-indented-already-middle-target (21 4))))
|
||||
|
||||
(defun rust-get-buffer-pos (pos-symbol)
|
||||
"Get buffer position from POS-SYMBOL.
|
||||
|
|
@ -793,3 +806,31 @@ All positions are position symbols found in `rust-test-positions-alist'."
|
|||
'middle-pull-indent-start
|
||||
'middle-pull-indent-target
|
||||
#'indent-for-tab-command))
|
||||
|
||||
(ert-deftest indent-line-blank-line-indented-already-bol ()
|
||||
(rust-test-motion
|
||||
rust-test-indent-motion-string
|
||||
'blank-line-indented-already-bol-start
|
||||
'blank-line-indented-already-bol-target
|
||||
#'indent-for-tab-command))
|
||||
|
||||
(ert-deftest indent-line-blank-line-indented-already-middle ()
|
||||
(rust-test-motion
|
||||
rust-test-indent-motion-string
|
||||
'blank-line-indented-already-middle-start
|
||||
'blank-line-indented-already-middle-target
|
||||
#'indent-for-tab-command))
|
||||
|
||||
(ert-deftest indent-line-nonblank-line-indented-already-bol ()
|
||||
(rust-test-motion
|
||||
rust-test-indent-motion-string
|
||||
'nonblank-line-indented-already-bol-start
|
||||
'nonblank-line-indented-already-bol-target
|
||||
#'indent-for-tab-command))
|
||||
|
||||
(ert-deftest indent-line-nonblank-line-indented-already-middle ()
|
||||
(rust-test-motion
|
||||
rust-test-indent-motion-string
|
||||
'nonblank-line-indented-already-middle-start
|
||||
'nonblank-line-indented-already-middle-target
|
||||
#'indent-for-tab-command))
|
||||
|
|
|
|||
|
|
@ -140,14 +140,14 @@
|
|||
;; Otherwise, we are continuing the same expression from the previous line,
|
||||
;; so add one additional indent level
|
||||
(+ baseline rust-indent-offset))))))))))
|
||||
(when (not (eq (current-indentation) indent))
|
||||
;; If we're at the beginning of the line (before or at the current
|
||||
;; indentation), jump with the indentation change. Otherwise, save the
|
||||
;; excursion so that adding the indentations will leave us at the
|
||||
;; equivalent position within the line to where we were before.
|
||||
(if (<= (current-column) (current-indentation))
|
||||
(indent-line-to indent)
|
||||
(save-excursion (indent-line-to indent))))))
|
||||
|
||||
;; If we're at the beginning of the line (before or at the current
|
||||
;; indentation), jump with the indentation change. Otherwise, save the
|
||||
;; excursion so that adding the indentations will leave us at the
|
||||
;; equivalent position within the line to where we were before.
|
||||
(if (<= (current-column) (current-indentation))
|
||||
(indent-line-to indent)
|
||||
(save-excursion (indent-line-to indent)))))
|
||||
|
||||
|
||||
;; Font-locking definitions and helpers
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
use std::cast;
|
||||
use std::container::Container;
|
||||
use std::hash::{Hash, sip};
|
||||
use std::hash::Hash;
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
|
||||
|
|
@ -62,9 +62,9 @@ pub struct LruCache<K, V> {
|
|||
priv tail: *mut LruEntry<K, V>,
|
||||
}
|
||||
|
||||
impl<K: Hash> Hash for KeyRef<K> {
|
||||
fn hash(&self, s: &mut sip::SipState) {
|
||||
unsafe {(*self.k).hash(s)}
|
||||
impl<S, K: Hash<S>> Hash<S> for KeyRef<K> {
|
||||
fn hash(&self, state: &mut S) {
|
||||
unsafe { (*self.k).hash(state) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ Rust extras are part of the standard Rust distribution.
|
|||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")];
|
||||
|
||||
#[feature(macro_rules, globs, managed_boxes, asm)];
|
||||
#[feature(macro_rules, globs, managed_boxes, asm, default_type_params)];
|
||||
|
||||
#[deny(non_camel_case_types)];
|
||||
#[deny(missing_doc)];
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
use std::cmp::Eq;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, sip};
|
||||
use std::hash::Hash;
|
||||
use std::io::BufReader;
|
||||
use std::from_str::FromStr;
|
||||
use std::uint;
|
||||
|
|
@ -849,15 +849,15 @@ impl fmt::Show for Path {
|
|||
}
|
||||
}
|
||||
|
||||
impl Hash for Url {
|
||||
fn hash(&self, s: &mut sip::SipState) {
|
||||
self.to_str().hash(s)
|
||||
impl<S: Writer> Hash<S> for Url {
|
||||
fn hash(&self, state: &mut S) {
|
||||
self.to_str().hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for Path {
|
||||
fn hash(&self, s: &mut sip::SipState) {
|
||||
self.to_str().hash(s)
|
||||
impl<S: Writer> Hash<S> for Path {
|
||||
fn hash(&self, state: &mut S) {
|
||||
self.to_str().hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -832,6 +832,20 @@ impl Scheduler {
|
|||
}
|
||||
|
||||
pub fn maybe_yield(mut ~self, cur: ~GreenTask) {
|
||||
// It's possible for sched tasks to possibly call this function, and it
|
||||
// just means that they're likely sending on channels (which
|
||||
// occasionally call this function). Sched tasks follow different paths
|
||||
// when executing yield_now(), which may possibly trip the assertion
|
||||
// below. For this reason, we just have sched tasks bail out soon.
|
||||
//
|
||||
// Sched tasks have no need to yield anyway because as soon as they
|
||||
// return they'll yield to other threads by falling back to the event
|
||||
// loop. Additionally, we completely control sched tasks, so we can make
|
||||
// sure that they never execute more than enough code.
|
||||
if cur.is_sched() {
|
||||
return cur.put_with_sched(self)
|
||||
}
|
||||
|
||||
// The number of times to do the yield check before yielding, chosen
|
||||
// arbitrarily.
|
||||
rtassert!(self.yield_check_count > 0);
|
||||
|
|
|
|||
|
|
@ -335,7 +335,6 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> {
|
|||
}).map(|path| root.join(path)).collect()
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
fn rust_list_dir_wfd_size() -> libc::size_t;
|
||||
fn rust_list_dir_wfd_fp_buf(wfd: *libc::c_void) -> *u16;
|
||||
|
|
|
|||
|
|
@ -979,7 +979,7 @@ static other_attrs: &'static [&'static str] = &[
|
|||
"macro_export", "must_use",
|
||||
|
||||
//mod-level
|
||||
"path", "link_name", "link_args", "nolink", "macro_escape", "no_implicit_prelude",
|
||||
"path", "link_name", "link_args", "macro_escape", "no_implicit_prelude",
|
||||
|
||||
// fn-level
|
||||
"test", "bench", "should_fail", "ignore", "inline", "lang", "main", "start",
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
|
|||
};
|
||||
|
||||
// Render the HTML
|
||||
let text = format!(r#"<h{lvl} id="{id}"><a
|
||||
let text = format!(r#"<h{lvl} id="{id}" class='section-link'><a
|
||||
href="\#{id}">{sec_len,plural,=0{}other{{sec} }}{}</a></h{lvl}>"#,
|
||||
s, lvl = level, id = id,
|
||||
sec_len = sec.len(), sec = sec);
|
||||
|
|
|
|||
|
|
@ -1064,7 +1064,9 @@ fn item_module(w: &mut Writer, cx: &Context,
|
|||
clean::ForeignStaticItem(..) => ("ffi-statics", "Foreign Statics"),
|
||||
clean::MacroItem(..) => ("macros", "Macros"),
|
||||
};
|
||||
try!(write!(w, "<h2 id='{id}'><a href=\"\\#{id}\">{name}</a></h2>\n<table>",
|
||||
try!(write!(w,
|
||||
"<h2 id='{id}' class='section-link'>\
|
||||
<a href=\"\\#{id}\">{name}</a></h2>\n<table>",
|
||||
id = short, name = name));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -317,16 +317,11 @@ pre.rust .doccomment { color: #4D4D4C; }
|
|||
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
|
||||
pre.rust .lifetime { color: #B76514; }
|
||||
|
||||
h1:hover a:after,
|
||||
h2:hover a:after,
|
||||
h3:hover a:after,
|
||||
h4:hover a:after,
|
||||
h5:hover a:after,
|
||||
h6:hover a:after {
|
||||
h1.section-link:hover a:after,
|
||||
h2.section-link:hover a:after,
|
||||
h3.section-link:hover a:after,
|
||||
h4.section-link:hover a:after,
|
||||
h5.section-link:hover a:after,
|
||||
h6.section-link:hover a:after {
|
||||
content: ' § ';
|
||||
}
|
||||
|
||||
h1.fqn:hover a:after,
|
||||
:hover a.fnname:after {
|
||||
content: none;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -720,10 +720,17 @@ impl Json {
|
|||
}
|
||||
|
||||
/// Attempts to get a nested Json Object for each key in `keys`.
|
||||
/// If any key is found not to exist, get_path will return None.
|
||||
/// If any key is found not to exist, find_path will return None.
|
||||
/// Otherwise, it will return the Json value associated with the final key.
|
||||
pub fn find_path<'a>(&'a self, keys: &[&~str]) -> Option<&'a Json>{
|
||||
keys.iter().fold(Some(self), |target, key| target.map_or(None, |t| t.find(*key)))
|
||||
let mut target = self;
|
||||
for key in keys.iter() {
|
||||
match target.find(*key) {
|
||||
Some(t) => { target = t; },
|
||||
None => return None
|
||||
}
|
||||
}
|
||||
Some(target)
|
||||
}
|
||||
|
||||
/// If the Json value is an Object, performs a depth-first search until
|
||||
|
|
@ -752,10 +759,7 @@ impl Json {
|
|||
|
||||
/// Returns true if the Json value is an Object. Returns false otherwise.
|
||||
pub fn is_object<'a>(&'a self) -> bool {
|
||||
match self {
|
||||
&Object(_) => true,
|
||||
_ => false
|
||||
}
|
||||
self.as_object().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is an Object, returns the associated TreeMap.
|
||||
|
|
@ -769,10 +773,7 @@ impl Json {
|
|||
|
||||
/// Returns true if the Json value is a List. Returns false otherwise.
|
||||
pub fn is_list<'a>(&'a self) -> bool {
|
||||
match self {
|
||||
&List(_) => true,
|
||||
_ => false
|
||||
}
|
||||
self.as_list().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is a List, returns the associated vector.
|
||||
|
|
@ -785,16 +786,13 @@ impl Json {
|
|||
}
|
||||
|
||||
/// Returns true if the Json value is a String. Returns false otherwise.
|
||||
pub fn is_str<'a>(&'a self) -> bool {
|
||||
match self {
|
||||
&String(_) => true,
|
||||
_ => false
|
||||
}
|
||||
pub fn is_string<'a>(&'a self) -> bool {
|
||||
self.as_string().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is a String, returns the associated str.
|
||||
/// Returns None otherwise.
|
||||
pub fn as_str<'a>(&'a self) -> Option<&'a str> {
|
||||
pub fn as_string<'a>(&'a self) -> Option<&'a str> {
|
||||
match *self {
|
||||
String(ref s) => Some(s.as_slice()),
|
||||
_ => None
|
||||
|
|
@ -803,10 +801,7 @@ impl Json {
|
|||
|
||||
/// Returns true if the Json value is a Number. Returns false otherwise.
|
||||
pub fn is_number(&self) -> bool {
|
||||
match self {
|
||||
&Number(_) => true,
|
||||
_ => false
|
||||
}
|
||||
self.as_number().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is a Number, returns the associated f64.
|
||||
|
|
@ -820,10 +815,7 @@ impl Json {
|
|||
|
||||
/// Returns true if the Json value is a Boolean. Returns false otherwise.
|
||||
pub fn is_boolean(&self) -> bool {
|
||||
match self {
|
||||
&Boolean(_) => true,
|
||||
_ => false
|
||||
}
|
||||
self.as_boolean().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is a Boolean, returns the associated bool.
|
||||
|
|
@ -837,10 +829,7 @@ impl Json {
|
|||
|
||||
/// Returns true if the Json value is a Null. Returns false otherwise.
|
||||
pub fn is_null(&self) -> bool {
|
||||
match self {
|
||||
&Null => true,
|
||||
_ => false
|
||||
}
|
||||
self.as_null().is_some()
|
||||
}
|
||||
|
||||
/// If the Json value is a Null, returns ().
|
||||
|
|
@ -2430,20 +2419,20 @@ mod tests {
|
|||
fn test_find(){
|
||||
let json_value = from_str("{\"dog\" : \"cat\"}").unwrap();
|
||||
let found_str = json_value.find(&~"dog");
|
||||
assert!(found_str.is_some() && found_str.unwrap().as_str().unwrap() == &"cat");
|
||||
assert!(found_str.is_some() && found_str.unwrap().as_string().unwrap() == &"cat");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_find_path(){
|
||||
let json_value = from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap();
|
||||
let found_str = json_value.find_path(&[&~"dog", &~"cat", &~"mouse"]);
|
||||
assert!(found_str.is_some() && found_str.unwrap().as_str().unwrap() == &"cheese");
|
||||
assert!(found_str.is_some() && found_str.unwrap().as_string().unwrap() == &"cheese");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search(){
|
||||
let json_value = from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap();
|
||||
let found_str = json_value.search(&~"mouse").and_then(|j| j.as_str());
|
||||
let found_str = json_value.search(&~"mouse").and_then(|j| j.as_string());
|
||||
assert!(found_str.is_some());
|
||||
assert!(found_str.unwrap() == &"cheese");
|
||||
}
|
||||
|
|
@ -2476,15 +2465,15 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_str(){
|
||||
fn test_is_string(){
|
||||
let json_value = from_str("\"dog\"").unwrap();
|
||||
assert!(json_value.is_str());
|
||||
assert!(json_value.is_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_as_str(){
|
||||
fn test_as_string(){
|
||||
let json_value = from_str("\"dog\"").unwrap();
|
||||
let json_str = json_value.as_str();
|
||||
let json_str = json_value.as_string();
|
||||
let expected_str = &"dog";
|
||||
assert_eq!(json_str, Some(expected_str));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,14 +339,19 @@ impl<T: Send> Packet<T> {
|
|||
DATA => Ok(true),
|
||||
|
||||
// If the other end has hung up, then we have complete ownership
|
||||
// of the port. We need to check to see if there was an upgrade
|
||||
// requested, and if so, the other end needs to have its selection
|
||||
// aborted.
|
||||
// of the port. First, check if there was data waiting for us. This
|
||||
// is possible if the other end sent something and then hung up.
|
||||
//
|
||||
// We then need to check to see if there was an upgrade requested,
|
||||
// and if so, the upgraded port needs to have its selection aborted.
|
||||
DISCONNECTED => {
|
||||
assert!(self.data.is_none());
|
||||
match mem::replace(&mut self.upgrade, SendUsed) {
|
||||
GoUp(port) => Err(port),
|
||||
_ => Ok(true),
|
||||
if self.data.is_some() {
|
||||
Ok(true)
|
||||
} else {
|
||||
match mem::replace(&mut self.upgrade, SendUsed) {
|
||||
GoUp(port) => Err(port),
|
||||
_ => Ok(true),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -597,4 +597,56 @@ mod test {
|
|||
unsafe { h.add(); }
|
||||
assert_eq!(s.wait2(false), h.id);
|
||||
})
|
||||
|
||||
test!(fn oneshot_data_waiting() {
|
||||
let (p, c) = Chan::new();
|
||||
let (p2, c2) = Chan::new();
|
||||
spawn(proc() {
|
||||
select! {
|
||||
() = p.recv() => {}
|
||||
}
|
||||
c2.send(());
|
||||
});
|
||||
|
||||
for _ in range(0, 100) { task::deschedule() }
|
||||
c.send(());
|
||||
p2.recv();
|
||||
})
|
||||
|
||||
test!(fn stream_data_waiting() {
|
||||
let (p, c) = Chan::new();
|
||||
let (p2, c2) = Chan::new();
|
||||
c.send(());
|
||||
c.send(());
|
||||
p.recv();
|
||||
p.recv();
|
||||
spawn(proc() {
|
||||
select! {
|
||||
() = p.recv() => {}
|
||||
}
|
||||
c2.send(());
|
||||
});
|
||||
|
||||
for _ in range(0, 100) { task::deschedule() }
|
||||
c.send(());
|
||||
p2.recv();
|
||||
})
|
||||
|
||||
test!(fn shared_data_waiting() {
|
||||
let (p, c) = Chan::new();
|
||||
let (p2, c2) = Chan::new();
|
||||
drop(c.clone());
|
||||
c.send(());
|
||||
p.recv();
|
||||
spawn(proc() {
|
||||
select! {
|
||||
() = p.recv() => {}
|
||||
}
|
||||
c2.send(());
|
||||
});
|
||||
|
||||
for _ in range(0, 100) { task::deschedule() }
|
||||
c.send(());
|
||||
p2.recv();
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,6 +172,40 @@ need to inspect or unwrap the `IoResult<File>` and we simply call `write_line`
|
|||
on it. If `new` returned an `Err(..)` then the followup call to `write_line`
|
||||
will also return an error.
|
||||
|
||||
## `try!`
|
||||
|
||||
Explicit pattern matching on `IoResult`s can get quite verbose, especially
|
||||
when performing many I/O operations. Some examples (like those above) are
|
||||
alleviated with extra methods implemented on `IoResult`, but others have more
|
||||
complex interdependencies among each I/O operation.
|
||||
|
||||
The `try!` macro from `std::macros` is provided as a method of early-return
|
||||
inside `Result`-returning functions. It expands to an early-return on `Err`
|
||||
and otherwise unwraps the contained `Ok` value.
|
||||
|
||||
If you wanted to read several `u32`s from a file and return their product:
|
||||
|
||||
```rust
|
||||
use std::io::{File, IoResult};
|
||||
|
||||
fn file_product(p: &Path) -> IoResult<u32> {
|
||||
let mut f = File::open(p);
|
||||
let x1 = try!(f.read_le_u32());
|
||||
let x2 = try!(f.read_le_u32());
|
||||
|
||||
Ok(x1 * x2)
|
||||
}
|
||||
|
||||
match file_product(&Path::new("numbers.bin")) {
|
||||
Ok(x) => println!("{}", x),
|
||||
Err(e) => println!("Failed to read numbers!")
|
||||
}
|
||||
```
|
||||
|
||||
With `try!` in `file_product`, each `read_le_u32` need not be directly
|
||||
concerned with error handling; instead its caller is responsible for
|
||||
responding to errors that may occur while attempting to read the numbers.
|
||||
|
||||
*/
|
||||
|
||||
#[deny(unused_must_use)];
|
||||
|
|
|
|||
|
|
@ -150,7 +150,6 @@ mod darwin_fd_limit {
|
|||
rlim_cur: rlim_t,
|
||||
rlim_max: rlim_t
|
||||
}
|
||||
#[nolink]
|
||||
extern {
|
||||
// name probably doesn't need to be mut, but the C function doesn't specify const
|
||||
fn sysctl(name: *mut libc::c_int, namelen: libc::c_uint,
|
||||
|
|
|
|||
|
|
@ -3306,7 +3306,6 @@ pub mod funcs {
|
|||
// or anything. The same is not true of POSIX.
|
||||
|
||||
pub mod c95 {
|
||||
#[nolink]
|
||||
pub mod ctype {
|
||||
use libc::types::os::arch::c95::{c_char, c_int};
|
||||
|
||||
|
|
@ -3327,7 +3326,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod stdio {
|
||||
use libc::types::common::c95::{FILE, c_void, fpos_t};
|
||||
use libc::types::os::arch::c95::{c_char, c_int, c_long, size_t};
|
||||
|
|
@ -3383,7 +3381,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod stdlib {
|
||||
use libc::types::common::c95::c_void;
|
||||
use libc::types::os::arch::c95::{c_char, c_double, c_int};
|
||||
|
|
@ -3416,7 +3413,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod string {
|
||||
use libc::types::common::c95::c_void;
|
||||
use libc::types::os::arch::c95::{c_char, c_int, size_t};
|
||||
|
|
@ -3461,7 +3457,6 @@ pub mod funcs {
|
|||
|
||||
#[cfg(target_os = "win32")]
|
||||
pub mod posix88 {
|
||||
#[nolink]
|
||||
pub mod stat_ {
|
||||
use libc::types::os::common::posix01::{stat, utimbuf};
|
||||
use libc::types::os::arch::c95::{c_int, c_char, wchar_t};
|
||||
|
|
@ -3486,7 +3481,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod stdio {
|
||||
use libc::types::common::c95::FILE;
|
||||
use libc::types::os::arch::c95::{c_int, c_char};
|
||||
|
|
@ -3503,7 +3497,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod fcntl {
|
||||
use libc::types::os::arch::c95::{c_int, c_char, wchar_t};
|
||||
extern {
|
||||
|
|
@ -3518,12 +3511,10 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod dirent {
|
||||
// Not supplied at all.
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod unistd {
|
||||
use libc::types::common::c95::c_void;
|
||||
use libc::types::os::arch::c95::{c_int, c_uint, c_char,
|
||||
|
|
@ -3590,7 +3581,6 @@ pub mod funcs {
|
|||
use libc::types::os::arch::posix01::stat;
|
||||
use libc::types::os::arch::posix88::mode_t;
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
pub fn chmod(path: *c_char, mode: mode_t) -> c_int;
|
||||
pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
|
||||
|
|
@ -3618,7 +3608,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod stdio {
|
||||
use libc::types::common::c95::FILE;
|
||||
use libc::types::os::arch::c95::{c_char, c_int};
|
||||
|
|
@ -3631,7 +3620,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod fcntl {
|
||||
use libc::types::os::arch::c95::{c_char, c_int};
|
||||
use libc::types::os::arch::posix88::mode_t;
|
||||
|
|
@ -3644,7 +3632,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod dirent {
|
||||
use libc::types::common::posix88::{DIR, dirent_t};
|
||||
use libc::types::os::arch::c95::{c_char, c_int, c_long};
|
||||
|
|
@ -3678,7 +3665,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod unistd {
|
||||
use libc::types::common::c95::c_void;
|
||||
use libc::types::os::arch::c95::{c_char, c_int, c_long, c_uint};
|
||||
|
|
@ -3748,7 +3734,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod signal {
|
||||
use libc::types::os::arch::c95::{c_int};
|
||||
use libc::types::os::arch::posix88::{pid_t};
|
||||
|
|
@ -3758,7 +3743,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod mman {
|
||||
use libc::types::common::c95::{c_void};
|
||||
use libc::types::os::arch::c95::{size_t, c_int, c_char};
|
||||
|
|
@ -3796,7 +3780,6 @@ pub mod funcs {
|
|||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub mod posix01 {
|
||||
#[nolink]
|
||||
pub mod stat_ {
|
||||
use libc::types::os::arch::c95::{c_char, c_int};
|
||||
use libc::types::os::arch::posix01::stat;
|
||||
|
|
@ -3813,7 +3796,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod unistd {
|
||||
use libc::types::os::arch::c95::{c_char, c_int, size_t};
|
||||
use libc::types::os::arch::posix88::{ssize_t, off_t};
|
||||
|
|
@ -3841,7 +3823,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod wait {
|
||||
use libc::types::os::arch::c95::{c_int};
|
||||
use libc::types::os::arch::posix88::{pid_t};
|
||||
|
|
@ -3852,7 +3833,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod glob {
|
||||
use libc::types::os::arch::c95::{c_char, c_int};
|
||||
use libc::types::os::common::posix01::{glob_t};
|
||||
|
|
@ -3867,7 +3847,6 @@ pub mod funcs {
|
|||
}
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
pub mod mman {
|
||||
use libc::types::common::c95::{c_void};
|
||||
use libc::types::os::arch::c95::{c_int, size_t};
|
||||
|
|
@ -4032,7 +4011,6 @@ pub mod funcs {
|
|||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[nolink]
|
||||
pub mod extra {
|
||||
use libc::types::os::arch::c95::{c_char, c_int};
|
||||
|
||||
|
|
@ -4256,7 +4234,6 @@ pub mod funcs {
|
|||
use libc::types::os::arch::c95::{c_int, c_long};
|
||||
use libc::types::os::arch::c99::intptr_t;
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
#[link_name = "_commit"]
|
||||
pub fn commit(fd: c_int) -> c_int;
|
||||
|
|
|
|||
|
|
@ -615,7 +615,6 @@ pub fn errno() -> int {
|
|||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
fn errno_location() -> *c_int {
|
||||
#[nolink]
|
||||
extern {
|
||||
fn __error() -> *c_int;
|
||||
}
|
||||
|
|
@ -627,7 +626,6 @@ pub fn errno() -> int {
|
|||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "android")]
|
||||
fn errno_location() -> *c_int {
|
||||
#[nolink]
|
||||
extern {
|
||||
fn __errno_location() -> *c_int;
|
||||
}
|
||||
|
|
@ -665,7 +663,6 @@ pub fn last_os_error() -> ~str {
|
|||
#[cfg(target_os = "freebsd")]
|
||||
fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: libc::size_t)
|
||||
-> c_int {
|
||||
#[nolink]
|
||||
extern {
|
||||
fn strerror_r(errnum: c_int, buf: *mut c_char,
|
||||
buflen: libc::size_t) -> c_int;
|
||||
|
|
@ -681,7 +678,6 @@ pub fn last_os_error() -> ~str {
|
|||
#[cfg(target_os = "linux")]
|
||||
fn strerror_r(errnum: c_int, buf: *mut c_char,
|
||||
buflen: libc::size_t) -> c_int {
|
||||
#[nolink]
|
||||
extern {
|
||||
fn __xpg_strerror_r(errnum: c_int,
|
||||
buf: *mut c_char,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use c_str::{CString, ToCStr};
|
|||
use clone::Clone;
|
||||
use cmp::Eq;
|
||||
use from_str::FromStr;
|
||||
use hash::{Hash, sip};
|
||||
use io::Writer;
|
||||
use iter::{AdditiveIterator, Extendable, Iterator, Map};
|
||||
use option::{Option, None, Some};
|
||||
use str;
|
||||
|
|
@ -88,10 +88,10 @@ impl ToCStr for Path {
|
|||
}
|
||||
}
|
||||
|
||||
impl Hash for Path {
|
||||
impl<H: Writer> ::hash::Hash<H> for Path {
|
||||
#[inline]
|
||||
fn hash(&self, s: &mut sip::SipState) {
|
||||
self.repr.hash(s)
|
||||
fn hash(&self, hasher: &mut H) {
|
||||
self.repr.hash(hasher)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use clone::Clone;
|
|||
use container::Container;
|
||||
use cmp::Eq;
|
||||
use from_str::FromStr;
|
||||
use hash::{Hash, sip};
|
||||
use io::Writer;
|
||||
use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Rev, Iterator, Map};
|
||||
use option::{Option, Some, None};
|
||||
use str;
|
||||
|
|
@ -112,10 +112,10 @@ impl ToCStr for Path {
|
|||
}
|
||||
}
|
||||
|
||||
impl Hash for Path {
|
||||
impl<H: Writer> ::hash::Hash<H> for Path {
|
||||
#[inline]
|
||||
fn hash(&self, s: &mut sip::SipState) {
|
||||
self.repr.hash(s)
|
||||
fn hash(&self, hasher: &mut H) {
|
||||
self.repr.hash(hasher)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ use clone::Clone;
|
|||
use cmp::{Eq, TotalEq, Ord, TotalOrd, Equiv, Ordering};
|
||||
use container::{Container, Mutable};
|
||||
use fmt;
|
||||
use hash::{Hash, sip};
|
||||
use io::Writer;
|
||||
use iter::{Iterator, FromIterator, Extendable, range};
|
||||
use iter::{Filter, AdditiveIterator, Map};
|
||||
use iter::{Rev, DoubleEndedIterator, ExactSize};
|
||||
|
|
@ -1331,10 +1331,13 @@ impl<'a> Default for MaybeOwned<'a> {
|
|||
fn default() -> MaybeOwned<'a> { Slice("") }
|
||||
}
|
||||
|
||||
impl<'a> Hash for MaybeOwned<'a> {
|
||||
impl<'a, H: Writer> ::hash::Hash<H> for MaybeOwned<'a> {
|
||||
#[inline]
|
||||
fn hash(&self, s: &mut sip::SipState) {
|
||||
self.as_slice().hash(s)
|
||||
fn hash(&self, hasher: &mut H) {
|
||||
match *self {
|
||||
Slice(s) => s.hash(hasher),
|
||||
Owned(ref s) => s.hash(hasher),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,12 @@ Examples of string representations:
|
|||
#[crate_type = "dylib"];
|
||||
#[license = "MIT/ASL2"];
|
||||
|
||||
#[feature(default_type_params)];
|
||||
|
||||
// NOTE remove the following two attributes after the next snapshot.
|
||||
#[allow(unrecognized_lint)];
|
||||
#[allow(default_type_param_usage)];
|
||||
|
||||
// test harness access
|
||||
#[cfg(test)]
|
||||
extern crate test;
|
||||
|
|
@ -71,7 +77,7 @@ use std::char::Char;
|
|||
use std::default::Default;
|
||||
use std::fmt;
|
||||
use std::from_str::FromStr;
|
||||
use std::hash::{Hash, sip};
|
||||
use std::hash::Hash;
|
||||
use std::num::FromStrRadix;
|
||||
use std::str;
|
||||
use std::vec;
|
||||
|
|
@ -116,9 +122,10 @@ pub struct Uuid {
|
|||
/// The 128-bit number stored in 16 bytes
|
||||
bytes: UuidBytes
|
||||
}
|
||||
impl Hash for Uuid {
|
||||
fn hash(&self, s: &mut sip::SipState) {
|
||||
self.bytes.slice_from(0).hash(s)
|
||||
|
||||
impl<S: Writer> Hash<S> for Uuid {
|
||||
fn hash(&self, state: &mut S) {
|
||||
self.bytes.hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
use std::libc;
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
static mut rust_dbg_static_mut: libc::c_int;
|
||||
pub fn rust_dbg_static_mut_check_four();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
use std::libc;
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
pub fn bare_type1(size: int); //~ ERROR: found rust type
|
||||
pub fn bare_type2(size: uint); //~ ERROR: found rust type
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ the compiler output. */
|
|||
#[feature(link_args)];
|
||||
|
||||
#[link_args = "aFdEfSeVEEE"]
|
||||
#[nolink]
|
||||
extern {}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
mod libc {
|
||||
use std::libc::{c_char, c_long, c_longlong};
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
pub fn atol(x: *c_char) -> c_long;
|
||||
pub fn atoll(x: *c_char) -> c_longlong;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ extern crate extra;
|
|||
mod libc {
|
||||
use std::libc::{c_char, size_t};
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
#[link_name = "strlen"]
|
||||
pub fn my_strlen(str: *c_char) -> size_t;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
mod foo {
|
||||
use std::libc::c_int;
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
pub static errno: c_int;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ pub enum void { }
|
|||
mod bindgen {
|
||||
use super::void;
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
pub fn printf(v: void);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,26 +9,22 @@
|
|||
// except according to those terms.
|
||||
|
||||
mod bar {
|
||||
#[nolink]
|
||||
extern {}
|
||||
}
|
||||
|
||||
mod zed {
|
||||
#[nolink]
|
||||
extern {}
|
||||
}
|
||||
|
||||
mod libc {
|
||||
use std::libc::{c_int, c_void, size_t, ssize_t};
|
||||
|
||||
#[nolink]
|
||||
extern {
|
||||
pub fn write(fd: c_int, buf: *c_void, count: size_t) -> ssize_t;
|
||||
}
|
||||
}
|
||||
|
||||
mod baz {
|
||||
#[nolink]
|
||||
extern {}
|
||||
}
|
||||
|
||||
|
|
|
|||
25
src/test/run-pass/issue-11267.rs
Normal file
25
src/test/run-pass/issue-11267.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Tests that unary structs can be mutably borrowed.
|
||||
|
||||
struct Empty;
|
||||
|
||||
impl Iterator<int> for Empty {
|
||||
fn next(&mut self) -> Option<int> { None }
|
||||
}
|
||||
|
||||
fn do_something_with(a : &mut Iterator<int>) {
|
||||
println!("{}", a.next())
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
do_something_with(&mut Empty);
|
||||
}
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
// Issue #901
|
||||
mod libc {
|
||||
#[nolink]
|
||||
extern {
|
||||
pub fn printf(x: ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#[allow(ctypes)];
|
||||
|
||||
mod libc {
|
||||
#[nolink]
|
||||
extern {
|
||||
pub fn malloc(size: int) -> *u8;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue