Skip to content

Commit 51bdae0

Browse files
committed
---
yaml --- r: 191727 b: refs/heads/tmp c: c785e7e h: refs/heads/master i: 191725: dd2a41c 191723: c344f1e 191719: 2fe458a 191711: 351dedb v: v3
1 parent efb7b89 commit 51bdae0

File tree

44 files changed

+805
-126
lines changed

Some content is hidden

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

44 files changed

+805
-126
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 13fd0a1c68b699a5d85e868cce4af7992fbd0d6c
37+
refs/heads/tmp: c785e7e2a1fd86f5600a49c27ba6ac01a22ca7de
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3939
refs/tags/homu-tmp: 4a5101a42f8ea36bdbe14749e672ab78cb971726

branches/tmp/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
# make check-stage1-rpass TESTNAME=my-shiny-new-test
9898
#
9999
# // Having trouble figuring out which test is failing? Turn off parallel tests
100-
# make check-stage1-std RUST_TEST_TASKS=1
100+
# make check-stage1-std RUST_TEST_THREADS=1
101101
#
102102
# If you really feel like getting your hands dirty, then:
103103
#

branches/tmp/src/compiletest/compiletest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ pub fn run_tests(config: &Config) {
224224
// android debug-info test uses remote debugger
225225
// so, we test 1 task at once.
226226
// also trying to isolate problems with adb_run_wrapper.sh ilooping
227-
env::set_var("RUST_TEST_TASKS","1");
227+
env::set_var("RUST_TEST_THREADS","1");
228228
}
229229

230230
match config.mode {
231231
DebugInfoLldb => {
232232
// Some older versions of LLDB seem to have problems with multiple
233233
// instances running in parallel, so only run one test task at a
234234
// time.
235-
env::set_var("RUST_TEST_TASKS", "1");
235+
env::set_var("RUST_TEST_THREADS", "1");
236236
}
237237
_ => { /* proceed */ }
238238
}

branches/tmp/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
131131
true
132132
});
133133

134-
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_TASKS"] {
134+
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
135135
match env::var(key) {
136136
Ok(val) =>
137137
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -561,38 +561,40 @@ fn main() {
561561
In this case, Rust knows that `x` is being *borrowed* by the `add_one()`
562562
function, and since it's only reading the value, allows it.
563563

564-
We can borrow `x` multiple times, as long as it's not simultaneous:
564+
We can borrow `x` as read-only multiple times, even simultaneously:
565565

566566
```{rust}
567-
fn add_one(x: &i32) -> i32 {
568-
*x + 1
567+
fn add(x: &i32, y: &i32) -> i32 {
568+
*x + *y
569569
}
570570
571571
fn main() {
572572
let x = Box::new(5);
573573
574-
println!("{}", add_one(&*x));
575-
println!("{}", add_one(&*x));
576-
println!("{}", add_one(&*x));
574+
println!("{}", add(&x, &x));
575+
println!("{}", add(&x, &x));
577576
}
578577
```
579578

580-
Or as long as it's not a mutable borrow. This will error:
579+
We can mutably borrow `x` multiple times, but only if x itself is mutable, and
580+
it may not be *simultaneously* borrowed:
581581

582582
```{rust,ignore}
583-
fn add_one(x: &mut i32) -> i32 {
584-
*x + 1
583+
fn increment(x: &mut i32) {
584+
*x += 1;
585585
}
586586
587587
fn main() {
588-
let x = Box::new(5);
588+
// If variable x is not "mut", this will not compile
589+
let mut x = Box::new(5);
589590
590-
println!("{}", add_one(&*x)); // error: cannot borrow immutable dereference
591-
// of `&`-pointer as mutable
591+
increment(&mut x);
592+
increment(&mut x);
593+
println!("{}", x);
592594
}
593595
```
594596

595-
Notice we changed the signature of `add_one()` to request a mutable reference.
597+
Notice the signature of `increment()` requests a mutable reference.
596598

597599
## Best practices
598600

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ offered by the Rust language and libraries. For example, they
9393
- are plain-old-data, that is, they don't move ownership, again unlike
9494
`Box`, hence the Rust compiler cannot protect against bugs like
9595
use-after-free;
96-
- are considered sendable (if their contents is considered sendable),
97-
so the compiler offers no assistance with ensuring their use is
98-
thread-safe; for example, one can concurrently access a `*mut i32`
99-
from two threads without synchronization.
10096
- lack any form of lifetimes, unlike `&`, and so the compiler cannot
10197
reason about dangling pointers; and
10298
- have no guarantees about aliasing or mutability other than mutation

branches/tmp/src/liballoc/arc.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,21 @@ impl<T> Arc<T> {
210210
// contents.
211211
unsafe { &**self._ptr }
212212
}
213+
214+
// Non-inlined part of `drop`.
215+
#[inline(never)]
216+
unsafe fn drop_slow(&mut self) {
217+
let ptr = *self._ptr;
218+
219+
// Destroy the data at this time, even though we may not free the box allocation itself
220+
// (there may still be weak pointers lying around).
221+
drop(ptr::read(&self.inner().data));
222+
223+
if self.inner().weak.fetch_sub(1, Release) == 1 {
224+
atomic::fence(Acquire);
225+
deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(), min_align_of::<ArcInner<T>>())
226+
}
227+
}
213228
}
214229

215230
/// Get the number of weak references to this value.
@@ -325,6 +340,7 @@ impl<T: Sync + Send> Drop for Arc<T> {
325340
///
326341
/// } // implicit drop
327342
/// ```
343+
#[inline]
328344
fn drop(&mut self) {
329345
// This structure has #[unsafe_no_drop_flag], so this drop glue may run more than once (but
330346
// it is guaranteed to be zeroed after the first if it's run more than once)
@@ -353,14 +369,8 @@ impl<T: Sync + Send> Drop for Arc<T> {
353369
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
354370
atomic::fence(Acquire);
355371

356-
// Destroy the data at this time, even though we may not free the box allocation itself
357-
// (there may still be weak pointers lying around).
358-
unsafe { drop(ptr::read(&self.inner().data)); }
359-
360-
if self.inner().weak.fetch_sub(1, Release) == 1 {
361-
atomic::fence(Acquire);
362-
unsafe { deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(),
363-
min_align_of::<ArcInner<T>>()) }
372+
unsafe {
373+
self.drop_slow()
364374
}
365375
}
366376
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ pub trait Int
345345

346346
/// Saturating integer addition. Computes `self + other`, saturating at
347347
/// the numeric bounds instead of overflowing.
348+
///
349+
/// # Examples
350+
///
351+
/// ```
352+
/// use std::num::Int;
353+
///
354+
/// assert_eq!(5u16.saturating_add(65534), 65535);
355+
/// assert_eq!((-5i16).saturating_add(-32767), -32768);
356+
/// assert_eq!(100u32.saturating_add(4294967294), 4294967295);
357+
/// ```
348358
#[stable(feature = "rust1", since = "1.0.0")]
349359
#[inline]
350360
fn saturating_add(self, other: Self) -> Self {
@@ -357,6 +367,16 @@ pub trait Int
357367

358368
/// Saturating integer subtraction. Computes `self - other`, saturating at
359369
/// the numeric bounds instead of overflowing.
370+
///
371+
/// # Examples
372+
///
373+
/// ```
374+
/// use std::num::Int;
375+
///
376+
/// assert_eq!(5u16.saturating_sub(65534), 0);
377+
/// assert_eq!(5i16.saturating_sub(-32767), 32767);
378+
/// assert_eq!(100u32.saturating_sub(4294967294), 0);
379+
/// ```
360380
#[stable(feature = "rust1", since = "1.0.0")]
361381
#[inline]
362382
fn saturating_sub(self, other: Self) -> Self {

branches/tmp/src/libcore/str/pattern.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use super::CharEq;
2525
///
2626
/// The trait itself acts as a builder for an associated
2727
/// `Searcher` type, which does the actual work of finding
28-
/// occurences of the pattern in a string.
28+
/// occurrences of the pattern in a string.
2929
pub trait Pattern<'a>: Sized {
3030
/// Associated searcher for this pattern
3131
type Searcher: Searcher<'a>;
@@ -72,7 +72,7 @@ pub enum SearchStep {
7272
/// Expresses that `haystack[a..b]` has been rejected as a possible match
7373
/// of the pattern.
7474
///
75-
/// Note that there might be more than one `Reject` betwen two `Match`es,
75+
/// Note that there might be more than one `Reject` between two `Match`es,
7676
/// there is no requirement for them to be combined into one.
7777
Reject(usize, usize),
7878
/// Expresses that every byte of the haystack has been visted, ending

branches/tmp/src/librbml/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ pub mod writer {
10611061
}
10621062

10631063
/// Returns the current position while marking it stable, i.e.
1064-
/// generated bytes so far woundn't be affected by relaxation.
1064+
/// generated bytes so far wouldn't be affected by relaxation.
10651065
pub fn mark_stable_position(&mut self) -> u64 {
10661066
let pos = self.writer.seek(SeekFrom::Current(0)).unwrap();
10671067
if self.relax_limit < pos {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,27 @@ impl<'a, 'b, 'tcx> DecodeContext<'a, 'b, 'tcx> {
235235
pub fn tr_span(&self, span: Span) -> Span {
236236
let imported_filemaps = &self.cdata.codemap_import_info[..];
237237

238+
let span = if span.lo > span.hi {
239+
// Currently macro expansion sometimes produces invalid Span values
240+
// where lo > hi. In order not to crash the compiler when trying to
241+
// translate these values, let's transform them into something we
242+
// can handle (and which will produce useful debug locations at
243+
// least some of the time).
244+
// This workaround is only necessary as long as macro expansion is
245+
// not fixed. FIXME(#23480)
246+
codemap::mk_sp(span.lo, span.lo)
247+
} else {
248+
span
249+
};
250+
238251
let filemap_index = {
239252
// Optimize for the case that most spans within a translated item
240253
// originate from the same filemap.
241254
let last_filemap_index = self.last_filemap_index.get();
242255

243256
if span.lo >= imported_filemaps[last_filemap_index].original_start_pos &&
257+
span.lo <= imported_filemaps[last_filemap_index].original_end_pos &&
258+
span.hi >= imported_filemaps[last_filemap_index].original_start_pos &&
244259
span.hi <= imported_filemaps[last_filemap_index].original_end_pos {
245260
last_filemap_index
246261
} else {

branches/tmp/src/librustc_back/tempdir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ impl TempDir {
6161
let path = tmpdir.join(&leaf);
6262
match fs::create_dir(&path) {
6363
Ok(_) => return Ok(TempDir { path: Some(path) }),
64-
Err(ref e) if e.kind() == ErrorKind::PathAlreadyExists => {}
64+
Err(ref e) if e.kind() == ErrorKind::AlreadyExists => {}
6565
Err(e) => return Err(e)
6666
}
6767
}
6868

69-
Err(Error::new(ErrorKind::PathAlreadyExists,
69+
Err(Error::new(ErrorKind::AlreadyExists,
7070
"too many temporary directories already exist",
7171
None))
7272
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub fn arg_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
264264
}
265265

266266
/// Get the LLVM type corresponding to a Rust type, i.e. `middle::ty::Ty`.
267-
/// This is the right LLVM type for an alloca containg a value of that type,
267+
/// This is the right LLVM type for an alloca containing a value of that type,
268268
/// and the pointee of an Lvalue Datum (which is always a LLVM pointer).
269269
/// For unsized types, the returned type is a fat pointer, thus the resulting
270270
/// LLVM type for a `Trait` Lvalue is `{ i8*, void(i8*)** }*`, which is a double

branches/tmp/src/librustc_typeck/check/regionck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
225225
/// }
226226
/// ```
227227
///
228-
/// Here, the region of `b` will be `<R0>`. `<R0>` is constrainted to be some subregion of the
228+
/// Here, the region of `b` will be `<R0>`. `<R0>` is constrained to be some subregion of the
229229
/// block B and some superregion of the call. If we forced it now, we'd choose the smaller
230230
/// region (the call). But that would make the *b illegal. Since we don't resolve, the type
231231
/// of b will be `&<R0>.int` and then `*b` will require that `<R0>` be bigger than the let and

branches/tmp/src/librustc_typeck/check/upvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> {
294294

295295
/// Indicates that `cmt` is being directly mutated (e.g., assigned
296296
/// to). If cmt contains any by-ref upvars, this implies that
297-
/// those upvars must be borrowed using an `&mut` borow.
297+
/// those upvars must be borrowed using an `&mut` borrow.
298298
fn adjust_upvar_borrow_kind_for_mut(&mut self, cmt: mc::cmt<'tcx>) {
299299
debug!("adjust_upvar_borrow_kind_for_mut(cmt={})",
300300
cmt.repr(self.tcx()));

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -692,16 +692,23 @@ fn shortty(item: &clean::Item) -> ItemType {
692692

693693
/// Takes a path to a source file and cleans the path to it. This canonicalizes
694694
/// things like ".." to components which preserve the "top down" hierarchy of a
695-
/// static HTML tree.
695+
/// static HTML tree. Each component in the cleaned path will be passed as an
696+
/// argument to `f`. The very last component of the path (ie the file name) will
697+
/// be passed to `f` if `keep_filename` is true, and ignored otherwise.
696698
// FIXME (#9639): The closure should deal with &[u8] instead of &str
697699
// FIXME (#9639): This is too conservative, rejecting non-UTF-8 paths
698-
fn clean_srcpath<F>(src_root: &Path, p: &Path, mut f: F) where
700+
fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) where
699701
F: FnMut(&str),
700702
{
701703
// make it relative, if possible
702704
let p = p.relative_from(src_root).unwrap_or(p);
703705

704-
for c in p.iter().map(|x| x.to_str().unwrap()) {
706+
let mut iter = p.iter().map(|x| x.to_str().unwrap()).peekable();
707+
while let Some(c) = iter.next() {
708+
if !keep_filename && iter.peek().is_none() {
709+
break;
710+
}
711+
705712
if ".." == c {
706713
f("up");
707714
} else {
@@ -803,7 +810,7 @@ impl<'a> SourceCollector<'a> {
803810
// Create the intermediate directories
804811
let mut cur = self.dst.clone();
805812
let mut root_path = String::from_str("../../");
806-
clean_srcpath(&self.cx.src_root, &p, |component| {
813+
clean_srcpath(&self.cx.src_root, &p, false, |component| {
807814
cur.push(component);
808815
mkdir(&cur).unwrap();
809816
root_path.push_str("../");
@@ -1368,7 +1375,7 @@ impl<'a> Item<'a> {
13681375
if ast_util::is_local(self.item.def_id) {
13691376
let mut path = Vec::new();
13701377
clean_srcpath(&cx.src_root, Path::new(&self.item.source.filename),
1371-
|component| {
1378+
true, |component| {
13721379
path.push(component.to_string());
13731380
});
13741381
let href = if self.item.source.loline == self.item.source.hiline {

branches/tmp/src/librustdoc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#![feature(test)]
3636
#![feature(unicode)]
3737
#![feature(str_words)]
38-
#![feature(io)]
3938
#![feature(file_path)]
4039
#![feature(path_ext)]
4140
#![feature(path_relative_from)]

branches/tmp/src/libserialize/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Core encoding and decoding interfaces.
3131
#![feature(collections)]
3232
#![feature(core)]
3333
#![feature(int_uint)]
34-
#![feature(io)]
3534
#![feature(old_path)]
3635
#![feature(rustc_private)]
3736
#![feature(staged_api)]

branches/tmp/src/libstd/fs/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ pub struct Metadata(fs_imp::FileAttr);
7373
/// will yield instances of `io::Result<DirEntry>`. Through a `DirEntry`
7474
/// information like the entry's path and possibly other metadata can be
7575
/// learned.
76+
///
77+
/// # Failure
78+
///
79+
/// This `io::Result` will be an `Err` if there's some sort of intermittent
80+
/// IO error during iteration.
7681
#[stable(feature = "rust1", since = "1.0.0")]
7782
pub struct ReadDir(fs_imp::ReadDir);
7883

@@ -493,7 +498,7 @@ pub fn copy<P: AsPath, Q: AsPath>(from: P, to: Q) -> io::Result<u64> {
493498
let from = from.as_path();
494499
let to = to.as_path();
495500
if !from.is_file() {
496-
return Err(Error::new(ErrorKind::MismatchedFileTypeForOperation,
501+
return Err(Error::new(ErrorKind::InvalidInput,
497502
"the source path is not an existing file",
498503
None))
499504
}
@@ -1134,7 +1139,7 @@ mod tests {
11341139
let dir = &tmpdir.join("mkdir_error_twice");
11351140
check!(fs::create_dir(dir));
11361141
let e = fs::create_dir(dir).err().unwrap();
1137-
assert_eq!(e.kind(), ErrorKind::PathAlreadyExists);
1142+
assert_eq!(e.kind(), ErrorKind::AlreadyExists);
11381143
}
11391144

11401145
#[test]

branches/tmp/src/libstd/fs/tempdir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ impl TempDir {
6868
let path = tmpdir.join(&leaf);
6969
match fs::create_dir(&path) {
7070
Ok(_) => return Ok(TempDir { path: Some(path) }),
71-
Err(ref e) if e.kind() == ErrorKind::PathAlreadyExists => {}
71+
Err(ref e) if e.kind() == ErrorKind::AlreadyExists => {}
7272
Err(e) => return Err(e)
7373
}
7474
}
7575

76-
Err(Error::new(ErrorKind::PathAlreadyExists,
76+
Err(Error::new(ErrorKind::AlreadyExists,
7777
"too many temporary directories already exist",
7878
None))
7979
}

0 commit comments

Comments
 (0)