about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-11-07 02:26:45 +0000
committerbors <bors@rust-lang.org>2015-11-07 02:26:45 +0000
commitbb9b5f5edeb91fa7fc9bd7c220d69985e0175ba2 (patch)
tree3b8244879018938a1650fcebe24e0d2949ee4d25 /src
parent1e3e7e73c6086bead3949476c4f0c8231e6a0fc8 (diff)
parentd9dd67d90829ae2ce9422b264a1971e8e9c45c5a (diff)
downloadrust-bb9b5f5edeb91fa7fc9bd7c220d69985e0175ba2.tar.gz
rust-bb9b5f5edeb91fa7fc9bd7c220d69985e0175ba2.zip
Auto merge of #29666 - Manishearth:rollup, r=Manishearth
- Successful merges: #29617, #29622, #29656, #29659, #29660
- Failed merges:
Diffstat (limited to 'src')
m---------src/compiler-rt0
-rw-r--r--src/doc/trpl/concurrency.md12
-rw-r--r--src/doc/trpl/dining-philosophers.md23
-rw-r--r--src/doc/trpl/strings.md26
-rw-r--r--src/doc/trpl/the-stack-and-the-heap.md4
-rw-r--r--src/librustc/metadata/csearch.rs5
-rw-r--r--src/librustc/metadata/decoder.rs8
-rw-r--r--src/librustc_trans/trans/base.rs3
-rw-r--r--src/test/run-make/issue-14500/foo.c3
-rw-r--r--src/test/run-make/issue-14500/foo.rs3
10 files changed, 67 insertions, 20 deletions
diff --git a/src/compiler-rt b/src/compiler-rt
-Subproject 93d0384373750b52996fd7f8249adaae39f562d
+Subproject b6087e82ba1384c4af3adf2dc68e92316f0d4ca
diff --git a/src/doc/trpl/concurrency.md b/src/doc/trpl/concurrency.md
index 7b3f13a3ed2..cc6cfc2f4a0 100644
--- a/src/doc/trpl/concurrency.md
+++ b/src/doc/trpl/concurrency.md
@@ -121,6 +121,7 @@ languages. It will not compile:
 
 ```ignore
 use std::thread;
+use std::time::Duration;
 
 fn main() {
     let mut data = vec![1, 2, 3];
@@ -131,7 +132,7 @@ fn main() {
         });
     }
 
-    thread::sleep_ms(50);
+    thread::sleep(Duration::from_millis(50));
 }
 ```
 
@@ -165,6 +166,7 @@ indivisible operations which can't have data races.
 ```ignore
 use std::thread;
 use std::sync::Arc;
+use std::time::Duration;
 
 fn main() {
     let mut data = Arc::new(vec![1, 2, 3]);
@@ -176,7 +178,7 @@ fn main() {
         });
     }
 
-    thread::sleep_ms(50);
+    thread::sleep(Duration::from_millis(50));
 }
 ```
 
@@ -207,6 +209,7 @@ Here's the working version:
 ```rust
 use std::sync::{Arc, Mutex};
 use std::thread;
+use std::time::Duration;
 
 fn main() {
     let data = Arc::new(Mutex::new(vec![1, 2, 3]));
@@ -219,7 +222,7 @@ fn main() {
         });
     }
 
-    thread::sleep_ms(50);
+    thread::sleep(Duration::from_millis(50));
 }
 ```
 
@@ -241,6 +244,7 @@ Let's examine the body of the thread more closely:
 ```rust
 # use std::sync::{Arc, Mutex};
 # use std::thread;
+# use std::time::Duration;
 # fn main() {
 #     let data = Arc::new(Mutex::new(vec![1, 2, 3]));
 #     for i in 0..3 {
@@ -250,7 +254,7 @@ thread::spawn(move || {
     data[i] += 1;
 });
 #     }
-#     thread::sleep_ms(50);
+#     thread::sleep(Duration::from_millis(50));
 # }
 ```
 
diff --git a/src/doc/trpl/dining-philosophers.md b/src/doc/trpl/dining-philosophers.md
index e81ae4648ad..5f66a5b9e29 100644
--- a/src/doc/trpl/dining-philosophers.md
+++ b/src/doc/trpl/dining-philosophers.md
@@ -264,6 +264,7 @@ eat. Here’s the next version:
 
 ```rust
 use std::thread;
+use std::time::Duration;
 
 struct Philosopher {
     name: String,
@@ -279,7 +280,7 @@ impl Philosopher {
     fn eat(&self) {
         println!("{} is eating.", self.name);
 
-        thread::sleep_ms(1000);
+        thread::sleep(Duration::from_millis(1000));
 
         println!("{} is done eating.", self.name);
     }
@@ -313,13 +314,13 @@ from the standard library, and so we need to `use` it.
     fn eat(&self) {
         println!("{} is eating.", self.name);
 
-        thread::sleep_ms(1000);
+        thread::sleep(Duration::from_millis(1000));
 
         println!("{} is done eating.", self.name);
     }
 ```
 
-We now print out two messages, with a `sleep_ms()` in the middle. This will
+We now print out two messages, with a `sleep` in the middle. This will
 simulate the time it takes a philosopher to eat.
 
 If you run this program, you should see each philosopher eat in turn:
@@ -345,6 +346,7 @@ Here’s the next iteration:
 
 ```rust
 use std::thread;
+use std::time::Duration;
 
 struct Philosopher {
     name: String,
@@ -360,7 +362,7 @@ impl Philosopher {
     fn eat(&self) {
         println!("{} is eating.", self.name);
 
-        thread::sleep_ms(1000);
+        thread::sleep(Duration::from_millis(1000));
 
         println!("{} is done eating.", self.name);
     }
@@ -493,6 +495,7 @@ Let’s modify the program to use the `Table`:
 
 ```rust
 use std::thread;
+use std::time::Duration;
 use std::sync::{Mutex, Arc};
 
 struct Philosopher {
@@ -512,12 +515,12 @@ impl Philosopher {
 
     fn eat(&self, table: &Table) {
         let _left = table.forks[self.left].lock().unwrap();
-        thread::sleep_ms(150);
+        thread::sleep(Duration::from_millis(150));
         let _right = table.forks[self.right].lock().unwrap();
 
         println!("{} is eating.", self.name);
 
-        thread::sleep_ms(1000);
+        thread::sleep(Duration::from_millis(1000));
 
         println!("{} is done eating.", self.name);
     }
@@ -598,12 +601,12 @@ We now need to construct those `left` and `right` values, so we add them to
 ```rust,ignore
 fn eat(&self, table: &Table) {
     let _left = table.forks[self.left].lock().unwrap();
-    thread::sleep_ms(150);
+    thread::sleep(Duration::from_millis(150));
     let _right = table.forks[self.right].lock().unwrap();
 
     println!("{} is eating.", self.name);
 
-    thread::sleep_ms(1000);
+    thread::sleep(Duration::from_millis(1000));
 
     println!("{} is done eating.", self.name);
 }
@@ -614,8 +617,8 @@ We have three new lines. We’ve added an argument, `table`. We access the
 the fork at that particular index. That gives us access to the `Mutex` at that
 index, and we call `lock()` on it. If the mutex is currently being accessed by
 someone else, we’ll block until it becomes available. We have also a call to
-`thread::sleep_ms` between the moment first fork is picked and the moment the
-second forked is picked, as the process  of picking up the fork is not
+`thread::sleep` between the moment the first fork is picked and the moment the
+second forked is picked, as the process of picking up the fork is not
 immediate.
 
 The call to `lock()` might fail, and if it does, we want to crash. In this
diff --git a/src/doc/trpl/strings.md b/src/doc/trpl/strings.md
index 18483664989..f61b4d8ed8d 100644
--- a/src/doc/trpl/strings.md
+++ b/src/doc/trpl/strings.md
@@ -24,9 +24,29 @@ compiled program, and exists for the entire duration it runs. The `greeting`
 binding is a reference to this statically allocated string. String slices
 have a fixed size, and cannot be mutated.
 
-A `String`, on the other hand, is a heap-allocated string. This string is
-growable, and is also guaranteed to be UTF-8. `String`s are commonly created by
-converting from a string slice using the `to_string` method.
+String literals can span multiple lines. There are two forms. The first will
+include the newline and the leading spaces:
+
+```rust
+let s = "foo
+    bar";
+
+assert_eq!("foo\n        bar", s);
+```
+
+The second, with a `\`, does not trim the spaces:
+
+```rust
+let s = "foo\
+    bar"; 
+
+assert_eq!("foobar", s);
+```
+
+Rust has more than just `&str`s though. A `String`, is a heap-allocated string.
+This string is growable, and is also guaranteed to be UTF-8. `String`s are
+commonly created by converting from a string slice using the `to_string`
+method.
 
 ```rust
 let mut s = "Hello".to_string(); // mut s: String
diff --git a/src/doc/trpl/the-stack-and-the-heap.md b/src/doc/trpl/the-stack-and-the-heap.md
index 0bc2ca263d5..f835322ee71 100644
--- a/src/doc/trpl/the-stack-and-the-heap.md
+++ b/src/doc/trpl/the-stack-and-the-heap.md
@@ -74,7 +74,9 @@ visualize what’s going on with memory. Your operating system presents a view o
 memory to your program that’s pretty simple: a huge list of addresses, from 0
 to a large number, representing how much RAM your computer has. For example, if
 you have a gigabyte of RAM, your addresses go from `0` to `1,073,741,823`. That
-number comes from 2<sup>30</sup>, the number of bytes in a gigabyte.
+number comes from 2<sup>30</sup>, the number of bytes in a gigabyte. [^gigabyte]
+
+[^gigabyte]: ‘Gigabyte’ can mean two things: 10^9, or 2^30. The SI standard resolved this by stating that ‘gigabyte’ is 10^9, and ‘gibibyte’ is 2^30. However, very few people use this terminology, and rely on context to differentiate. We follow in that tradition here.
 
 This memory is kind of like a giant array: addresses start at zero and go
 up to the final number. So here’s a diagram of our first stack frame:
diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs
index e04df51dc68..09dec375a69 100644
--- a/src/librustc/metadata/csearch.rs
+++ b/src/librustc/metadata/csearch.rs
@@ -344,6 +344,11 @@ pub fn is_const_fn(cstore: &cstore::CStore, did: DefId) -> bool {
     decoder::is_const_fn(&*cdata, did.index)
 }
 
+pub fn is_static(cstore: &cstore::CStore, did: DefId) -> bool {
+    let cdata = cstore.get_crate_data(did.krate);
+    decoder::is_static(&*cdata, did.index)
+}
+
 pub fn is_impl(cstore: &cstore::CStore, did: DefId) -> bool {
     let cdata = cstore.get_crate_data(did.krate);
     decoder::is_impl(&*cdata, did.index)
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs
index 0780252fc88..b102213eff0 100644
--- a/src/librustc/metadata/decoder.rs
+++ b/src/librustc/metadata/decoder.rs
@@ -1425,6 +1425,14 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool {
     }
 }
 
+pub fn is_static(cdata: Cmd, id: DefIndex) -> bool {
+    let item_doc = cdata.lookup_item(id);
+    match item_family(item_doc) {
+        ImmStatic | MutStatic => true,
+        _ => false,
+    }
+}
+
 pub fn is_impl(cdata: Cmd, id: DefIndex) -> bool {
     let item_doc = cdata.lookup_item(id);
     match item_family(item_doc) {
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs
index a536060efbd..4a99f2142d7 100644
--- a/src/librustc_trans/trans/base.rs
+++ b/src/librustc_trans/trans/base.rs
@@ -2875,7 +2875,8 @@ pub fn trans_crate<'tcx>(tcx: &ty::ctxt<'tcx>,
         sess.cstore.iter_crate_data(|cnum, _| {
             let syms = csearch::get_reachable_ids(&sess.cstore, cnum);
             reachable_symbols.extend(syms.into_iter().filter(|did| {
-                csearch::is_extern_fn(&sess.cstore, *did, shared_ccx.tcx())
+                csearch::is_extern_fn(&sess.cstore, *did, shared_ccx.tcx()) ||
+                csearch::is_static(&sess.cstore, *did)
             }).map(|did| {
                 csearch::get_symbol(&sess.cstore, did)
             }));
diff --git a/src/test/run-make/issue-14500/foo.c b/src/test/run-make/issue-14500/foo.c
index 25098ac479d..e84b5509c50 100644
--- a/src/test/run-make/issue-14500/foo.c
+++ b/src/test/run-make/issue-14500/foo.c
@@ -9,8 +9,9 @@
 // except according to those terms.
 
 extern void foo();
+extern char FOO_STATIC;
 
 int main() {
     foo();
-    return 0;
+    return (int)FOO_STATIC;
 }
diff --git a/src/test/run-make/issue-14500/foo.rs b/src/test/run-make/issue-14500/foo.rs
index ceca907403f..a91d8d6a21d 100644
--- a/src/test/run-make/issue-14500/foo.rs
+++ b/src/test/run-make/issue-14500/foo.rs
@@ -10,3 +10,6 @@
 
 #[no_mangle]
 pub extern fn foo() {}
+
+#[no_mangle]
+pub static FOO_STATIC: u8 = 0;