Skip to content

Commit b04df9b

Browse files
committed
---
yaml --- r: 220523 b: refs/heads/tmp c: 0fbceba h: refs/heads/master i: 220521: 1423e41 220519: 72db5c4 v: v3
1 parent 6c30bc5 commit b04df9b

File tree

18 files changed

+318
-119
lines changed

18 files changed

+318
-119
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: c8bab9d06a179028a0d5129aa62f09d694d9cc49
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 3f636c3ccbecffbaa1d6a90753f8296112ada5fd
28+
refs/heads/tmp: 0fbcebaaec518a0a39f0b835cd52e9edfaba9cc2
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1b28ffa5216c845d1cef6b0cb3e5ac7db12025d0
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/doc/trpl/dining-philosophers.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,15 @@ look at `main()` again:
151151
# struct Philosopher {
152152
# name: String,
153153
# }
154-
#
154+
#
155155
# impl Philosopher {
156156
# fn new(name: &str) -> Philosopher {
157157
# Philosopher {
158158
# name: name.to_string(),
159159
# }
160160
# }
161161
# }
162-
#
162+
#
163163
fn main() {
164164
let p1 = Philosopher::new("Judith Butler");
165165
let p2 = Philosopher::new("Gilles Deleuze");
@@ -197,15 +197,15 @@ a method, and then loop through all the philosophers, calling it:
197197
```rust
198198
struct Philosopher {
199199
name: String,
200-
}
200+
}
201201

202-
impl Philosopher {
202+
impl Philosopher {
203203
fn new(name: &str) -> Philosopher {
204204
Philosopher {
205205
name: name.to_string(),
206206
}
207207
}
208-
208+
209209
fn eat(&self) {
210210
println!("{} is done eating.", self.name);
211211
}
@@ -267,15 +267,15 @@ use std::thread;
267267

268268
struct Philosopher {
269269
name: String,
270-
}
270+
}
271271

272-
impl Philosopher {
272+
impl Philosopher {
273273
fn new(name: &str) -> Philosopher {
274274
Philosopher {
275275
name: name.to_string(),
276276
}
277277
}
278-
278+
279279
fn eat(&self) {
280280
println!("{} is eating.", self.name);
281281

@@ -348,9 +348,9 @@ use std::thread;
348348

349349
struct Philosopher {
350350
name: String,
351-
}
351+
}
352352

353-
impl Philosopher {
353+
impl Philosopher {
354354
fn new(name: &str) -> Philosopher {
355355
Philosopher {
356356
name: name.to_string(),
@@ -401,7 +401,7 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
401401
While this is only five lines, they’re a dense five. Let’s break it down.
402402

403403
```rust,ignore
404-
let handles: Vec<_> =
404+
let handles: Vec<_> =
405405
```
406406

407407
We introduce a new binding, called `handles`. We’ve given it this name because
@@ -460,15 +460,15 @@ If you run this program, you’ll see that the philosophers eat out of order!
460460
We have multi-threading!
461461

462462
```text
463+
Judith Butler is eating.
463464
Gilles Deleuze is eating.
464-
Gilles Deleuze is done eating.
465+
Karl Marx is eating.
465466
Emma Goldman is eating.
466-
Emma Goldman is done eating.
467467
Michel Foucault is eating.
468-
Judith Butler is eating.
469468
Judith Butler is done eating.
470-
Karl Marx is eating.
469+
Gilles Deleuze is done eating.
471470
Karl Marx is done eating.
471+
Emma Goldman is done eating.
472472
Michel Foucault is done eating.
473473
```
474474

branches/tmp/src/liballoc/boxed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use core::raw::{TraitObject};
7171
/// The following two examples are equivalent:
7272
///
7373
/// ```
74-
/// #![feature(box_heap)]
74+
/// # #![feature(box_heap)]
7575
/// #![feature(box_syntax)]
7676
/// use std::boxed::HEAP;
7777
///
@@ -162,7 +162,7 @@ impl<T : ?Sized> Box<T> {
162162
///
163163
/// # Examples
164164
/// ```
165-
/// #![feature(box_raw)]
165+
/// # #![feature(box_raw)]
166166
/// use std::boxed;
167167
///
168168
/// let seventeen = Box::new(17u32);

branches/tmp/src/libcore/num/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,15 @@ macro_rules! int_impl {
459459
}
460460
}
461461

462-
/// Wrapping (modular) division. Computes `floor(self / other)`,
462+
/// Wrapping (modular) division. Computes `self / other`,
463463
/// wrapping around at the boundary of the type.
464464
///
465465
/// The only case where such wrapping can occur is when one
466466
/// divides `MIN / -1` on a signed type (where `MIN` is the
467467
/// negative minimal value for the type); this is equivalent
468468
/// to `-MIN`, a positive value that is too large to represent
469469
/// in the type. In such a case, this function returns `MIN`
470-
/// itself..
470+
/// itself.
471471
#[stable(feature = "num_wrapping", since = "1.2.0")]
472472
#[inline(always)]
473473
pub fn wrapping_div(self, rhs: Self) -> Self {
@@ -1031,15 +1031,15 @@ macro_rules! uint_impl {
10311031
}
10321032
}
10331033

1034-
/// Wrapping (modular) division. Computes `floor(self / other)`,
1034+
/// Wrapping (modular) division. Computes `self / other`,
10351035
/// wrapping around at the boundary of the type.
10361036
///
10371037
/// The only case where such wrapping can occur is when one
10381038
/// divides `MIN / -1` on a signed type (where `MIN` is the
10391039
/// negative minimal value for the type); this is equivalent
10401040
/// to `-MIN`, a positive value that is too large to represent
10411041
/// in the type. In such a case, this function returns `MIN`
1042-
/// itself..
1042+
/// itself.
10431043
#[stable(feature = "num_wrapping", since = "1.2.0")]
10441044
#[inline(always)]
10451045
pub fn wrapping_div(self, rhs: Self) -> Self {

branches/tmp/src/libcore/ops.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ pub trait Div<RHS=Self> {
351351
fn div(self, rhs: RHS) -> Self::Output;
352352
}
353353

354-
macro_rules! div_impl {
354+
macro_rules! div_impl_integer {
355355
($($t:ty)*) => ($(
356+
/// This operation rounds towards zero, truncating any
357+
/// fractional part of the exact result.
356358
#[stable(feature = "rust1", since = "1.0.0")]
357359
impl Div for $t {
358360
type Output = $t;
@@ -365,7 +367,23 @@ macro_rules! div_impl {
365367
)*)
366368
}
367369

368-
div_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
370+
div_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
371+
372+
macro_rules! div_impl_float {
373+
($($t:ty)*) => ($(
374+
#[stable(feature = "rust1", since = "1.0.0")]
375+
impl Div for $t {
376+
type Output = $t;
377+
378+
#[inline]
379+
fn div(self, other: $t) -> $t { self / other }
380+
}
381+
382+
forward_ref_binop! { impl Div, div for $t, $t }
383+
)*)
384+
}
385+
386+
div_impl_float! { f32 f64 }
369387

370388
/// The `Rem` trait is used to specify the functionality of `%`.
371389
///
@@ -407,6 +425,8 @@ pub trait Rem<RHS=Self> {
407425

408426
macro_rules! rem_impl {
409427
($($t:ty)*) => ($(
428+
/// This operation satisfies `n % d == n - (n / d) * d`. The
429+
/// result has the same sign as the left operand.
410430
#[stable(feature = "rust1", since = "1.0.0")]
411431
impl Rem for $t {
412432
type Output = $t;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ pub fn simplify_type(tcx: &ty::ctxt,
7171
}
7272
ty::TyBox(_) => {
7373
// treat like we would treat `Box`
74-
let def_id = tcx.lang_items.owned_box().unwrap();
75-
Some(StructSimplifiedType(def_id))
74+
match tcx.lang_items.require_owned_box() {
75+
Ok(def_id) => Some(StructSimplifiedType(def_id)),
76+
Err(msg) => tcx.sess.fatal(&msg),
77+
}
7678
}
7779
ty::TyClosure(def_id, _) => {
7880
Some(ClosureSimplifiedType(def_id))

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ impl LanguageItems {
9090
}
9191
}
9292

93+
pub fn require_owned_box(&self) -> Result<ast::DefId, String> {
94+
self.require(OwnedBoxLangItem)
95+
}
96+
9397
pub fn from_builtin_kind(&self, bound: ty::BuiltinBound)
9498
-> Result<ast::DefId, String>
9599
{

branches/tmp/src/librustc_trans/trans/_match.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,8 @@ impl<'tcx> euv::Delegate<'tcx> for ReassignmentChecker {
13841384
match base_cmt.cat {
13851385
mc::cat_upvar(mc::Upvar { id: ty::UpvarId { var_id: vid, .. }, .. }) |
13861386
mc::cat_local(vid) => {
1387-
self.reassigned |= self.node == vid && Some(field) == self.field
1387+
self.reassigned |= self.node == vid &&
1388+
(self.field.is_none() || Some(field) == self.field)
13881389
},
13891390
_ => {}
13901391
}

branches/tmp/src/librustc_typeck/coherence/orphan.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
7777
self.check_def_id(item, data.principal_def_id());
7878
}
7979
ty::TyBox(..) => {
80-
self.check_def_id(item, self.tcx.lang_items.owned_box().unwrap());
80+
match self.tcx.lang_items.require_owned_box() {
81+
Ok(trait_id) => self.check_def_id(item, trait_id),
82+
Err(msg) => self.tcx.sess.span_fatal(item.span, &msg),
83+
}
8184
}
8285
ty::TyChar => {
8386
self.check_primitive_impl(def_id,

branches/tmp/src/libstd/thread/local.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ mod imp {
275275

276276
use cell::{Cell, UnsafeCell};
277277
use intrinsics;
278+
use ptr;
278279

279280
pub struct Key<T> {
280281
inner: UnsafeCell<Option<T>>,
@@ -327,7 +328,6 @@ mod imp {
327328
#[cfg(target_os = "linux")]
328329
unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
329330
use mem;
330-
use ptr;
331331
use libc;
332332
use sys_common::thread_local as os;
333333

@@ -394,7 +394,24 @@ mod imp {
394394
// destructor as running for this thread so calls to `get` will return
395395
// `None`.
396396
(*ptr).dtor_running.set(true);
397-
intrinsics::drop_in_place((*ptr).inner.get());
397+
398+
// The OSX implementation of TLS apparently had an odd aspect to it
399+
// where the pointer we have may be overwritten while this destructor
400+
// is running. Specifically if a TLS destructor re-accesses TLS it may
401+
// trigger a re-initialization of all TLS variables, paving over at
402+
// least some destroyed ones with initial values.
403+
//
404+
// This means that if we drop a TLS value in place on OSX that we could
405+
// revert the value to its original state halfway through the
406+
// destructor, which would be bad!
407+
//
408+
// Hence, we use `ptr::read` on OSX (to move to a "safe" location)
409+
// instead of drop_in_place.
410+
if cfg!(target_os = "macos") {
411+
ptr::read((*ptr).inner.get());
412+
} else {
413+
intrinsics::drop_in_place((*ptr).inner.get());
414+
}
398415
}
399416
}
400417

branches/tmp/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ fn is_in_follow(_: &ExtCtxt, tok: &Token, frag: &str) -> Result<bool, String> {
501501
},
502502
"path" | "ty" => {
503503
match *tok {
504-
Comma | FatArrow | Colon | Eq | Gt => Ok(true),
504+
Comma | FatArrow | Colon | Eq | Gt | Semi => Ok(true),
505505
Ident(i, _) if i.as_str() == "as" => Ok(true),
506506
_ => Ok(false)
507507
}

branches/tmp/src/libsyntax/parse/lexer/mod.rs

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ impl<'a> StringReader<'a> {
172172
self.span_diagnostic.span_err(sp, m)
173173
}
174174

175+
/// Suggest some help with a given span.
176+
pub fn help_span(&self, sp: Span, m: &str) {
177+
self.span_diagnostic.span_help(sp, m)
178+
}
179+
175180
/// Report a fatal error spanning [`from_pos`, `to_pos`).
176181
fn fatal_span_(&self, from_pos: BytePos, to_pos: BytePos, m: &str) -> ! {
177182
self.fatal_span(codemap::mk_sp(from_pos, to_pos), m)
@@ -182,6 +187,11 @@ impl<'a> StringReader<'a> {
182187
self.err_span(codemap::mk_sp(from_pos, to_pos), m)
183188
}
184189

190+
/// Suggest some help spanning [`from_pos`, `to_pos`).
191+
fn help_span_(&self, from_pos: BytePos, to_pos: BytePos, m: &str) {
192+
self.help_span(codemap::mk_sp(from_pos, to_pos), m)
193+
}
194+
185195
/// Report a lexical error spanning [`from_pos`, `to_pos`), appending an
186196
/// escaped character to the error message
187197
fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) -> ! {
@@ -728,19 +738,24 @@ impl<'a> StringReader<'a> {
728738
return match e {
729739
'n' | 'r' | 't' | '\\' | '\'' | '"' | '0' => true,
730740
'x' => self.scan_byte_escape(delim, !ascii_only),
731-
'u' if self.curr_is('{') => {
732-
let valid = self.scan_unicode_escape(delim);
733-
if valid && ascii_only {
734-
self.err_span_(
735-
escaped_pos,
736-
self.last_pos,
741+
'u' => {
742+
let valid = if self.curr_is('{') {
743+
self.scan_unicode_escape(delim) && !ascii_only
744+
} else {
745+
self.err_span_(start, self.last_pos,
746+
"incorrect unicode escape sequence");
747+
self.help_span_(start, self.last_pos,
748+
"format of unicode escape sequences is `\\u{…}`");
749+
false
750+
};
751+
if ascii_only {
752+
self.err_span_(start, self.last_pos,
737753
"unicode escape sequences cannot be used as a byte or in \
738754
a byte string"
739755
);
740-
false
741-
} else {
742-
valid
743756
}
757+
valid
758+
744759
}
745760
'\n' if delim == '"' => {
746761
self.consume_whitespace();
@@ -757,16 +772,13 @@ impl<'a> StringReader<'a> {
757772
if ascii_only { "unknown byte escape" }
758773
else { "unknown character escape" },
759774
c);
760-
let sp = codemap::mk_sp(escaped_pos, last_pos);
761775
if e == '\r' {
762-
self.span_diagnostic.span_help(
763-
sp,
776+
self.help_span_(escaped_pos, last_pos,
764777
"this is an isolated carriage return; consider checking \
765778
your editor and version control settings")
766779
}
767780
if (e == '{' || e == '}') && !ascii_only {
768-
self.span_diagnostic.span_help(
769-
sp,
781+
self.help_span_(escaped_pos, last_pos,
770782
"if used in a formatting string, \
771783
curly braces are escaped with `{{` and `}}`")
772784
}
@@ -848,14 +860,12 @@ impl<'a> StringReader<'a> {
848860
valid = false;
849861
}
850862

851-
self.bump(); // past the ending }
852-
853863
if valid && (char::from_u32(accum_int).is_none() || count == 0) {
854864
self.err_span_(start_bpos, self.last_pos, "illegal unicode character escape");
855865
valid = false;
856866
}
857867

858-
868+
self.bump(); // past the ending }
859869
valid
860870
}
861871

0 commit comments

Comments
 (0)