Skip to content

Commit 7f6d2f6

Browse files
committed
---
yaml --- r: 234758 b: refs/heads/tmp c: b8cfa59 h: refs/heads/master v: v3
1 parent 8b90c4c commit 7f6d2f6

File tree

119 files changed

+199
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+199
-265
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: aed5c3a1c876189c86dfb702bd7a73b209c87ae0
28+
refs/heads/tmp: b8cfa59be0a6b5200e525ff68390ede34698e909
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/doc/trpl/choosing-your-guarantees.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ there's a lot of concurrent access happening.
321321

322322
# Composition
323323

324-
A common gripe when reading Rust code is with types like `Rc<RefCell<Vec<T>>>` (or even more
324+
A common gripe when reading Rust code is with types like `Rc<RefCell<Vec<T>>>` (or even more more
325325
complicated compositions of such types). It's not always clear what the composition does, or why the
326326
author chose one like this (and when one should be using such a composition in one's own code)
327327

branches/tmp/src/doc/trpl/concurrency.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ to help us make sense of code that can possibly be concurrent.
2626
### `Send`
2727

2828
The first trait we're going to talk about is
29-
[`Send`](../std/marker/trait.Send.html). When a type `T` implements `Send`, it
30-
indicates that something of this type is able to have ownership transferred
29+
[`Send`](../std/marker/trait.Send.html). When a type `T` implements `Send`, it indicates
30+
to the compiler that something of this type is able to have ownership transferred
3131
safely between threads.
3232

3333
This is important to enforce certain restrictions. For example, if we have a
@@ -42,19 +42,13 @@ us enforce that it can't leave the current thread.
4242
### `Sync`
4343

4444
The second of these traits is called [`Sync`](../std/marker/trait.Sync.html).
45-
When a type `T` implements `Sync`, it indicates that something
45+
When a type `T` implements `Sync`, it indicates to the compiler that something
4646
of this type has no possibility of introducing memory unsafety when used from
47-
multiple threads concurrently through shared references. This implies that
48-
types which don't have [interior mutability](mutability.html) are inherently
49-
`Sync`, which includes simple primitive types (like `u8`) and aggregate types
50-
containing them.
51-
52-
For sharing references across threads, Rust provides a wrapper type called
53-
`Arc<T>`. `Arc<T>` implements `Send` and `Sync` if and only if `T` implements
54-
both `Send` and `Sync`. For example, an object of type `Arc<RefCell<U>>` cannot
55-
be transferred across threads because
56-
[`RefCell`](choosing-your-guarantees.html#refcell%3Ct%3E) does not implement
57-
`Sync`, consequently `Arc<RefCell<U>>` would not implement `Send`.
47+
multiple threads concurrently.
48+
49+
For example, sharing immutable data with an atomic reference count is
50+
threadsafe. Rust provides a type like this, `Arc<T>`, and it implements `Sync`,
51+
so it is safe to share between threads.
5852

5953
These two traits allow you to use the type system to make strong guarantees
6054
about the properties of your code under concurrency. Before we demonstrate
@@ -76,7 +70,7 @@ fn main() {
7670
}
7771
```
7872

79-
The `thread::spawn()` method accepts a [closure](closures.html), which is executed in a
73+
The `thread::spawn()` method accepts a closure, which is executed in a
8074
new thread. It returns a handle to the thread, that can be used to
8175
wait for the child thread to finish and extract its result:
8276

@@ -221,18 +215,29 @@ fn main() {
221215
}
222216
```
223217

224-
Note that the value of `i` is bound (copied) to the closure and not shared
225-
among the threads.
226218

227-
Also note that [`lock`](../std/sync/struct.Mutex.html#method.lock) method of
228-
[`Mutex`](../std/sync/struct.Mutex.html) has this signature:
219+
If we'd tried to use `Mutex<T>` without wrapping it in an `Arc<T>` we would have
220+
seen another error like:
221+
222+
```text
223+
error: the trait `core::marker::Send` is not implemented for the type `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` [E0277]
224+
thread::spawn(move || {
225+
^~~~~~~~~~~~~
226+
note: `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` cannot be sent between threads safely
227+
thread::spawn(move || {
228+
^~~~~~~~~~~~~
229+
```
230+
231+
You see, [`Mutex`](../std/sync/struct.Mutex.html) has a
232+
[`lock`](../std/sync/struct.Mutex.html#method.lock)
233+
method which has this signature:
229234

230235
```ignore
231236
fn lock(&self) -> LockResult<MutexGuard<T>>
232237
```
233238

234-
and because `Send` is not implemented for `MutexGuard<T>`, the guard cannot
235-
cross thread boundaries, ensuring thread-locality of lock acquire and release.
239+
and because `Send` is not implemented for `MutexGuard<T>`, we couldn't have
240+
transferred the guard across thread boundaries on it's own.
236241

237242
Let's examine the body of the thread more closely:
238243

@@ -312,24 +317,22 @@ use std::sync::mpsc;
312317
fn main() {
313318
let (tx, rx) = mpsc::channel();
314319

315-
for i in 0..10 {
320+
for _ in 0..10 {
316321
let tx = tx.clone();
317322

318323
thread::spawn(move || {
319-
let answer = i * i;
324+
let answer = 42;
320325

321326
tx.send(answer);
322327
});
323328
}
324329

325-
for _ in 0..10 {
326-
println!("{}", rx.recv().unwrap());
327-
}
330+
rx.recv().ok().expect("Could not receive answer");
328331
}
329332
```
330333

331-
Here we create 10 threads, asking each to calculate the square of a number (`i`
332-
at the time of `spawn()`), and then `send()` back the answer over the channel.
334+
A `u32` is `Send` because we can make a copy. So we create a thread, ask it to calculate
335+
the answer, and then it `send()`s us the answer over the channel.
333336

334337

335338
## Panics

branches/tmp/src/libcollectionstest/btree/set.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,15 @@ fn test_zip() {
148148
let y = y;
149149
let mut z = x.iter().zip(&y);
150150

151-
assert_eq!(z.next().unwrap(), (&5, &("bar")));
152-
assert_eq!(z.next().unwrap(), (&11, &("foo")));
153-
assert!(z.next().is_none());
151+
// FIXME: #5801: this needs a type hint to compile...
152+
let result: Option<(&usize, & &'static str)> = z.next();
153+
assert_eq!(result.unwrap(), (&5, &("bar")));
154+
155+
let result: Option<(&usize, & &'static str)> = z.next();
156+
assert_eq!(result.unwrap(), (&11, &("foo")));
157+
158+
let result: Option<(&usize, & &'static str)> = z.next();
159+
assert!(result.is_none());
154160
}
155161

156162
#[test]

branches/tmp/src/libcoretest/cell.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,15 @@ fn unsafe_cell_unsized() {
248248
assert_eq!(unsafe { &mut *cell.get() }, comp);
249249
}
250250

251-
#[test]
252-
fn refcell_unsized() {
253-
let cell: &RefCell<[i32]> = &RefCell::new([1, 2, 3]);
254-
{
255-
let b = &mut *cell.borrow_mut();
256-
b[0] = 4;
257-
b[2] = 5;
258-
}
259-
let comp: &mut [i32] = &mut [4, 2, 5];
260-
assert_eq!(&*cell.borrow(), comp);
261-
}
251+
// FIXME(#25351) needs deeply nested coercions of DST structs.
252+
// #[test]
253+
// fn refcell_unsized() {
254+
// let cell: &RefCell<[i32]> = &RefCell::new([1, 2, 3]);
255+
// {
256+
// let b = &mut *cell.borrow_mut();
257+
// b[0] = 4;
258+
// b[2] = 5;
259+
// }
260+
// let comp: &mut [i32] = &mut [4, 2, 5];
261+
// assert_eq!(&*cell.borrow(), comp);
262+
// }

branches/tmp/src/librustc/diagnostics.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,18 +298,10 @@ const FOO: i32 = { 0 }; // but brackets are useless here
298298
```
299299
"##,
300300

301-
// FIXME(#24111) Change the language here when const fn stabilizes
302301
E0015: r##"
303302
The only functions that can be called in static or constant expressions are
304-
`const` functions, and struct/enum constructors. `const` functions are only
305-
available on a nightly compiler. Rust currently does not support more general
306-
compile-time function execution.
307-
308-
```
309-
const FOO: Option<u8> = Some(1); // enum constructor
310-
struct Bar {x: u8}
311-
const BAR: Bar = Bar {x: 1}; // struct constructor
312-
```
303+
`const` functions. Rust currently does not support more general compile-time
304+
function execution.
313305
314306
See [RFC 911] for more details on the design of `const fn`s.
315307

branches/tmp/src/librustc/lint/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ macro_rules! lint_initializer {
8989
/// Declare a static item of type `&'static Lint`.
9090
#[macro_export]
9191
macro_rules! declare_lint {
92+
// FIXME(#14660): deduplicate
9293
(pub $name:ident, $level:ident, $desc:expr) => (
9394
pub static $name: &'static ::rustc::lint::Lint
9495
= &lint_initializer!($name, $level, $desc);

branches/tmp/src/librustc/middle/check_const.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use util::nodemap::NodeMap;
3939
use rustc_front::hir;
4040
use syntax::ast;
4141
use syntax::codemap::Span;
42-
use syntax::feature_gate::UnstableFeatures;
4342
use rustc_front::visit::{self, FnKind, Visitor};
4443

4544
use std::collections::hash_map::Entry;
@@ -710,21 +709,10 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
710709
if !is_const {
711710
v.add_qualif(ConstQualif::NOT_CONST);
712711
if v.mode != Mode::Var {
713-
// FIXME(#24111) Remove this check when const fn stabilizes
714-
if let UnstableFeatures::Disallow = v.tcx.sess.opts.unstable_features {
715-
span_err!(v.tcx.sess, e.span, E0015,
716-
"function calls in {}s are limited to \
717-
struct and enum constructors", v.msg());
718-
v.tcx.sess.span_note(e.span,
719-
"a limited form of compile-time function \
720-
evaluation is available on a nightly \
721-
compiler via `const fn`");
722-
} else {
723-
span_err!(v.tcx.sess, e.span, E0015,
724-
"function calls in {}s are limited to \
725-
constant functions, \
726-
struct and enum constructors", v.msg());
727-
}
712+
span_err!(v.tcx.sess, e.span, E0015,
713+
"function calls in {}s are limited to \
714+
constant functions, \
715+
struct and enum constructors", v.msg());
728716
}
729717
}
730718
}

branches/tmp/src/librustdoc/html/markdown.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,19 +283,37 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
283283
str::from_utf8(s).unwrap().to_string()
284284
};
285285

286-
// Transform the contents of the header into a hyphenated string
287-
let id = s.split_whitespace().map(|s| s.to_ascii_lowercase())
288-
.collect::<Vec<String>>().join("-");
289-
286+
// Discard '<em>', '<code>' tags and some escaped characters,
287+
// transform the contents of the header into a hyphenated string
288+
// without non-alphanumeric characters other than '-' and '_'.
289+
//
290290
// This is a terrible hack working around how hoedown gives us rendered
291291
// html for text rather than the raw text.
292+
let mut id = s.clone();
293+
let repl_sub = vec!["<em>", "</em>", "<code>", "</code>",
294+
"&lt;", "&gt;", "&amp;", "&#39;", "&quot;"];
295+
for sub in repl_sub {
296+
id = id.replace(sub, "");
297+
}
298+
let id = id.chars().filter_map(|c| {
299+
if c.is_alphanumeric() || c == '-' || c == '_' {
300+
if c.is_ascii() {
301+
Some(c.to_ascii_lowercase())
302+
} else {
303+
Some(c)
304+
}
305+
} else if c.is_whitespace() && c.is_ascii() {
306+
Some('-')
307+
} else {
308+
None
309+
}
310+
}).collect::<String>();
292311

293312
let opaque = unsafe { (*data).opaque as *mut hoedown_html_renderer_state };
294313
let opaque = unsafe { &mut *((*opaque).opaque as *mut MyOpaque) };
295314

296315
// Make sure our hyphenated ID is unique for this page
297316
let id = USED_HEADER_MAP.with(|map| {
298-
let id = id.replace("<code>", "").replace("</code>", "").to_string();
299317
let id = match map.borrow_mut().get_mut(&id) {
300318
None => id,
301319
Some(a) => { *a += 1; format!("{}-{}", id, *a - 1) }

branches/tmp/src/librustdoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ pub fn main_args(args: &[String]) -> isize {
211211
for &(name, _, description) in PASSES {
212212
println!("{:>20} - {}", name, description);
213213
}
214-
println!("\nDefault passes for rustdoc:");
214+
println!("{}", "\nDefault passes for rustdoc:"); // FIXME: #9970
215215
for &name in DEFAULT_PASSES {
216216
println!("{:>20}", name);
217217
}

branches/tmp/src/libserialize/json.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
//! Create a struct called `TestStruct` and serialize and deserialize it to and from JSON using the
7777
//! serialization API, using the derived serialization code.
7878
//!
79-
//! ```rust
79+
//! ```notrust
80+
//! // FIXME(#19470): this cannot be ```rust``` because it fails orphan checking at the moment
8081
//! extern crate serialize;
8182
//! use serialize::json;
8283
//!
@@ -110,7 +111,8 @@
110111
//!
111112
//! ### Simple example of `ToJson` usage
112113
//!
113-
//! ```rust
114+
//! ```notrust
115+
//! // FIXME(#19470): this cannot be ```rust``` because it fails orphan checking at the moment
114116
//! extern crate serialize;
115117
//! use serialize::json::{self, ToJson, Json};
116118
//!
@@ -149,7 +151,8 @@
149151
//!
150152
//! ### Verbose example of `ToJson` usage
151153
//!
152-
//! ```rust
154+
//! ```notrust
155+
//! // FIXME(#19470): this cannot be ```rust``` because it fails orphan checking at the moment
153156
//! extern crate serialize;
154157
//! use std::collections::BTreeMap;
155158
//! use serialize::json::{self, Json, ToJson};

branches/tmp/src/libstd/sync/mutex.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,16 @@ mod tests {
536536
assert_eq!(*lock, 2);
537537
}
538538

539-
#[test]
540-
fn test_mutex_unsized() {
541-
let mutex: &Mutex<[i32]> = &Mutex::new([1, 2, 3]);
542-
{
543-
let b = &mut *mutex.lock().unwrap();
544-
b[0] = 4;
545-
b[2] = 5;
546-
}
547-
let comp: &[i32] = &[4, 2, 5];
548-
assert_eq!(&*mutex.lock().unwrap(), comp);
549-
}
539+
// FIXME(#25351) needs deeply nested coercions of DST structs.
540+
// #[test]
541+
// fn test_mutex_unsized() {
542+
// let mutex: &Mutex<[i32]> = &Mutex::new([1, 2, 3]);
543+
// {
544+
// let b = &mut *mutex.lock().unwrap();
545+
// b[0] = 4;
546+
// b[2] = 5;
547+
// }
548+
// let comp: &[i32] = &[4, 2, 5];
549+
// assert_eq!(&*mutex.lock().unwrap(), comp);
550+
// }
550551
}

branches/tmp/src/libstd/sync/rwlock.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -578,17 +578,18 @@ mod tests {
578578
assert_eq!(*lock, 2);
579579
}
580580

581-
#[test]
582-
fn test_rwlock_unsized() {
583-
let rw: &RwLock<[i32]> = &RwLock::new([1, 2, 3]);
584-
{
585-
let b = &mut *rw.write().unwrap();
586-
b[0] = 4;
587-
b[2] = 5;
588-
}
589-
let comp: &[i32] = &[4, 2, 5];
590-
assert_eq!(&*rw.read().unwrap(), comp);
591-
}
581+
// FIXME(#25351) needs deeply nested coercions of DST structs.
582+
// #[test]
583+
// fn test_rwlock_unsized() {
584+
// let rw: &RwLock<[i32]> = &RwLock::new([1, 2, 3]);
585+
// {
586+
// let b = &mut *rw.write().unwrap();
587+
// b[0] = 4;
588+
// b[2] = 5;
589+
// }
590+
// let comp: &[i32] = &[4, 2, 5];
591+
// assert_eq!(&*rw.read().unwrap(), comp);
592+
// }
592593

593594
#[test]
594595
fn test_rwlock_try_write() {

0 commit comments

Comments
 (0)