Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #25525

Merged
merged 49 commits into from
May 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6a045b9
Move tracking of the next NodeId from syntax's ParseSess to rustc's S…
eddyb May 13, 2015
f786437
syntax: refactor (Span)Handler and ParseSess constructors to be methods.
eddyb May 13, 2015
6a59d18
syntax: replace sess.span_diagnostic.cm with sess.codemap().
eddyb May 13, 2015
0d50b04
syntax::parse: optimize file_to_filemap to read a string directly.
eddyb May 13, 2015
07d4f77
syntax: abstract over the file loading mechanism.
eddyb May 13, 2015
eeeb2cc
Allow for better optimizations of iterators for zero-sized types
dotdash May 15, 2015
0e21beb
libs: Move favicon URLs to HTTPS
alexcrichton May 15, 2015
3709e8f
Fix quotation mark in ruby example.
jeremyschlatter May 15, 2015
0909ce3
libstd: Path docs: `file` is now `file_name`
Ryman May 15, 2015
e30909d
Small typo in the docs
emilio May 16, 2015
d5394d0
Correct two small typos in the Dining Philosophers example.
WillEngler May 16, 2015
89eee9a
Change my email
achanda May 16, 2015
84d6dcb
Test that associated types are not required as type parameters
rpjohnst May 16, 2015
f641bd8
Fix deadlinks in complement-lang-faq.md
sumito3478 May 16, 2015
8e82c21
more friend error message for in fn arg
XuefengWu May 4, 2015
1e39d9b
change Self type error message
XuefengWu May 10, 2015
5cf6b02
fix typo for copyright year and trait capitalise
XuefengWu May 16, 2015
574a8cd
fix trait capitalise typo in test file
XuefengWu May 16, 2015
7fe60c1
fix error message in test
XuefengWu May 16, 2015
6e8e6a4
Update rust-inside-other-languages.md
huachaohuang May 16, 2015
76fa4f4
Update the shown installed rust version to 1.0
coffeejunk May 16, 2015
e095e39
Update windows install links to 1.0
coffeejunk May 16, 2015
6403a2f
Auto merge of #25462 - alexcrichton:favicon-https, r=nrc
bors May 16, 2015
d332aea
Auto merge of #25434 - dotdash:gep, r=alexcrichton
bors May 16, 2015
0d707d1
Auto merge of #25485 - XuefengWu:24968_err_msg_parse_self_type_2, r=nrc
bors May 16, 2015
bf15d04
Make a test compatible with the beta channel
brson May 16, 2015
2da9efe
Auto merge of #25463 - jeremyschlatter:master, r=alexcrichton
bors May 16, 2015
ba02739
Avoid calling a variable 'string' when discussing strings.
Wilfred May 16, 2015
b6e755d
fs::walk_dir example without unstable features
johshoff May 16, 2015
8cc9878
test/compile-fail: fix expected error message for non-UTF8 source.
eddyb May 16, 2015
e840393
Make `Arc` support DSTs
ftxqxd May 16, 2015
ce8fb6c
Fixed reserve_exact example
May 16, 2015
c23a9d4
Auto merge of #25387 - eddyb:syn-file-loader, r=nikomatsakis
bors May 17, 2015
4f83c4b
Auto merge of #25458 - P1start:arc-dst, r=huonw
bors May 17, 2015
e1f73b8
Simplify CString doc comment
bstrie May 17, 2015
e8d29a9
Rollup merge of #25465 - Ryman:patch-2, r=alexcrichton
Manishearth May 17, 2015
e06eb1c
Rollup merge of #25469 - ecoal95:patch-1, r=alexcrichton
Manishearth May 17, 2015
a25925a
Rollup merge of #25472 - WillEngler:book-tiny-typo-fixes, r=alexcrichton
Manishearth May 17, 2015
27676ea
Rollup merge of #25474 - achanda:fix_email, r=nikomatsakis
Manishearth May 17, 2015
bea1bba
Rollup merge of #25476 - rpjohnst:master, r=huonw
Manishearth May 17, 2015
4d3db38
Rollup merge of #25484 - sumito3478:fix-deadlink-in-complement-lang-f…
Manishearth May 17, 2015
b40fcf5
Rollup merge of #25490 - huachaohuang:patch-1, r=alexcrichton
Manishearth May 17, 2015
094d29c
Rollup merge of #25493 - coffeejunk:update_installed_rust_version, r=…
Manishearth May 17, 2015
b3706de
Rollup merge of #25503 - brson:betafix, r=cmr
Manishearth May 17, 2015
1fd0a84
Rollup merge of #25506 - Wilfred:master, r=alexcrichton
Manishearth May 17, 2015
4e12a92
Rollup merge of #25508 - johshoff:visit_dirs_example, r=alexcrichton
Manishearth May 17, 2015
8fa9474
Rollup merge of #25510 - thelostt:patch-1, r=alexcrichton
Manishearth May 17, 2015
99ed2c9
Rollup merge of #25516 - bstrie:cstrdoc, r=alexcrichton
Manishearth May 17, 2015
a0815c8
Rollup merge of #25522 - alexcrichton:reexport-incoming, r=sfackler
Manishearth May 17, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Aaron Raimist <aaron@aaronraimist.com>
Aaron Todd <github@opprobrio.us>
Aaron Turon <aturon@mozilla.com>
Aaron Weiss <aaronweiss74@gmail.com>
Abhishek Chanda <abhishek@cloudscaling.com>
Abhishek Chanda <abhishek.becs@gmail.com>
Adam Bozanich <adam.boz@gmail.com>
Adam Jacob <adam@opscode.com>
Adam Roben <adam@roben.org>
Expand Down
8 changes: 4 additions & 4 deletions src/doc/complement-lang-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
There aren't many large programs yet. The Rust [compiler][rustc], 60,000+ lines at the time of writing, is written in Rust. As the oldest body of Rust code it has gone through many iterations of the language, and some parts are nicer to look at than others. It may not be the best code to learn from, but [borrowck] and [resolve] were written recently.

[rustc]: /~https://github.com/rust-lang/rust/tree/master/src/librustc
[resolve]: /~https://github.com/rust-lang/rust/blob/master/src/librustc/middle/resolve.rs
[borrowck]: /~https://github.com/rust-lang/rust/blob/master/src/librustc/middle/borrowck/
[resolve]: /~https://github.com/rust-lang/rust/tree/master/src/librustc_resolve
[borrowck]: /~https://github.com/rust-lang/rust/tree/master/src/librustc_borrowck/borrowck

A research browser engine called [Servo][servo], currently 30,000+ lines across more than a dozen crates, will be exercising a lot of Rust's distinctive type-system and concurrency features, and integrating many native libraries.

Expand All @@ -20,8 +20,8 @@ Some examples that demonstrate different aspects of the language:
* The standard library's [json] module. Enums and pattern matching

[sprocketnes]: /~https://github.com/pcwalton/sprocketnes
[hash]: /~https://github.com/rust-lang/rust/blob/master/src/libstd/hash/mod.rs
[HashMap]: /~https://github.com/rust-lang/rust/blob/master/src/libcollections/hashmap.rs
[hash]: /~https://github.com/rust-lang/rust/tree/master/src/libcore/hash
[HashMap]: /~https://github.com/rust-lang/rust/tree/master/src/libstd/collections/hash
[json]: /~https://github.com/rust-lang/rust/blob/master/src/libserialize/json.rs

You may also be interested in browsing [trending Rust repositories][github-rust] on GitHub.
Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/dining-philosophers.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ from the standard library, and so we need to `use` it.
We now print out two messages, with a `sleep_ms()` 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:
If you run this program, you should see each philosopher eat in turn:

```text
Baruch Spinoza is eating.
Expand Down Expand Up @@ -480,7 +480,7 @@ struct Table {
}
```

This `Table` has an vector of `Mutex`es. A mutex is a way to control
This `Table` has a vector of `Mutex`es. A mutex is a way to control
concurrency: only one thread can access the contents at once. This is exactly
the property we need with our forks. We use an empty tuple, `()`, inside the
mutex, since we’re not actually going to use the value, just hold onto it.
Expand Down
6 changes: 3 additions & 3 deletions src/doc/trpl/installing-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ $ sh rustup.sh
If you're on Windows, please download either the [32-bit installer][win32] or
the [64-bit installer][win64] and run it.

[win32]: https://static.rust-lang.org/dist/rust-1.0.0-beta-i686-pc-windows-gnu.msi
[win64]: https://static.rust-lang.org/dist/rust-1.0.0-beta-x86_64-pc-windows-gnu.msi
[win32]: https://static.rust-lang.org/dist/rust-1.0.0-i686-pc-windows-gnu.msi
[win64]: https://static.rust-lang.org/dist/rust-1.0.0-x86_64-pc-windows-gnu.msi

## Uninstalling

Expand Down Expand Up @@ -74,7 +74,7 @@ $ rustc --version
You should see the version number, commit hash, commit date and build date:

```bash
rustc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02)
rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
```

If you did, Rust has been installed successfully! Congrats!
Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/rust-inside-other-languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn process() {
let handles: Vec<_> = (0..10).map(|_| {
thread::spawn(|| {
let mut _x = 0;
for _ in (0..5_000_001) {
for _ in (0..5_000_000) {
_x += 1
}
})
Expand Down Expand Up @@ -217,7 +217,7 @@ end

Hello.process

puts "done!
puts "done!"
```

Before we can run this, we need to install the `ffi` gem:
Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Rust has two main types of strings: `&str` and `String`. Let’s talk about
`&'static str`:

```rust
let string = "Hello there."; // string: &'static str
let greeting = "Hello there."; // greeting: &'static str
```

This string is statically allocated, meaning that it’s saved inside our
compiled program, and exists for the entire duration it runs. The `string`
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.

Expand Down
6 changes: 2 additions & 4 deletions src/grammar/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,9 @@ fn main() {
let options = config::basic_options();
let session = session::build_session(options, None,
syntax::diagnostics::registry::Registry::new(&[]));
let filemap = parse::string_to_filemap(&session.parse_sess,
code,
String::from_str("<n/a>"));
let filemap = session.parse_sess.codemap().new_filemap(String::from_str("<n/a>"), code);
let mut lexer = lexer::StringReader::new(session.diagnostic(), filemap);
let ref cm = lexer.span_diagnostic.cm;
let cm = session.codemap();

// ANTLR
let mut token_file = File::open(&Path::new(&args.next().unwrap())).unwrap();
Expand Down
86 changes: 50 additions & 36 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ use core::atomic;
use core::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst};
use core::fmt;
use core::cmp::Ordering;
use core::mem::{min_align_of, size_of};
use core::mem::{min_align_of_val, size_of_val};
use core::intrinsics::drop_in_place;
use core::mem;
use core::nonzero::NonZero;
use core::ops::Deref;
use core::ptr;
use core::ops::{Deref, CoerceUnsized};
use core::marker::Unsize;
use core::hash::{Hash, Hasher};
use heap::deallocate;

Expand Down Expand Up @@ -118,15 +119,16 @@ use heap::deallocate;
/// ```
#[unsafe_no_drop_flag]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Arc<T> {
pub struct Arc<T: ?Sized> {
// FIXME #12808: strange name to try to avoid interfering with
// field accesses of the contained type via Deref
_ptr: NonZero<*mut ArcInner<T>>,
}

unsafe impl<T: Sync + Send> Send for Arc<T> { }
unsafe impl<T: Sync + Send> Sync for Arc<T> { }
unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> { }
unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> { }

impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}

/// A weak pointer to an `Arc`.
///
Expand All @@ -135,30 +137,30 @@ unsafe impl<T: Sync + Send> Sync for Arc<T> { }
#[unsafe_no_drop_flag]
#[unstable(feature = "alloc",
reason = "Weak pointers may not belong in this module.")]
pub struct Weak<T> {
pub struct Weak<T: ?Sized> {
// FIXME #12808: strange name to try to avoid interfering with
// field accesses of the contained type via Deref
_ptr: NonZero<*mut ArcInner<T>>,
}

unsafe impl<T: Sync + Send> Send for Weak<T> { }
unsafe impl<T: Sync + Send> Sync for Weak<T> { }
unsafe impl<T: ?Sized + Sync + Send> Send for Weak<T> { }
unsafe impl<T: ?Sized + Sync + Send> Sync for Weak<T> { }

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: fmt::Debug> fmt::Debug for Weak<T> {
impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "(Weak)")
}
}

struct ArcInner<T> {
struct ArcInner<T: ?Sized> {
strong: atomic::AtomicUsize,
weak: atomic::AtomicUsize,
data: T,
}

unsafe impl<T: Sync + Send> Send for ArcInner<T> {}
unsafe impl<T: Sync + Send> Sync for ArcInner<T> {}
unsafe impl<T: ?Sized + Sync + Send> Send for ArcInner<T> {}
unsafe impl<T: ?Sized + Sync + Send> Sync for ArcInner<T> {}

impl<T> Arc<T> {
/// Constructs a new `Arc<T>`.
Expand All @@ -182,7 +184,9 @@ impl<T> Arc<T> {
};
Arc { _ptr: unsafe { NonZero::new(mem::transmute(x)) } }
}
}

impl<T: ?Sized> Arc<T> {
/// Downgrades the `Arc<T>` to a `Weak<T>` reference.
///
/// # Examples
Expand All @@ -204,7 +208,7 @@ impl<T> Arc<T> {
}
}

impl<T> Arc<T> {
impl<T: ?Sized> Arc<T> {
#[inline]
fn inner(&self) -> &ArcInner<T> {
// This unsafety is ok because while this arc is alive we're guaranteed
Expand All @@ -222,24 +226,24 @@ impl<T> Arc<T> {

// Destroy the data at this time, even though we may not free the box
// allocation itself (there may still be weak pointers lying around).
drop(ptr::read(&self.inner().data));
drop_in_place(&mut (*ptr).data);

if self.inner().weak.fetch_sub(1, Release) == 1 {
atomic::fence(Acquire);
deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(), min_align_of::<ArcInner<T>>())
deallocate(ptr as *mut u8, size_of_val(&*ptr), min_align_of_val(&*ptr))
}
}
}

/// Get the number of weak references to this value.
#[inline]
#[unstable(feature = "alloc")]
pub fn weak_count<T>(this: &Arc<T>) -> usize { this.inner().weak.load(SeqCst) - 1 }
pub fn weak_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().weak.load(SeqCst) - 1 }

/// Get the number of strong references to this value.
#[inline]
#[unstable(feature = "alloc")]
pub fn strong_count<T>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst) }
pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst) }


/// Returns a mutable reference to the contained value if the `Arc<T>` is unique.
Expand All @@ -264,7 +268,7 @@ pub fn strong_count<T>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst
/// ```
#[inline]
#[unstable(feature = "alloc")]
pub fn get_mut<T>(this: &mut Arc<T>) -> Option<&mut T> {
pub fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T> {
if strong_count(this) == 1 && weak_count(this) == 0 {
// This unsafety is ok because we're guaranteed that the pointer
// returned is the *only* pointer that will ever be returned to T. Our
Expand All @@ -279,7 +283,7 @@ pub fn get_mut<T>(this: &mut Arc<T>) -> Option<&mut T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Clone for Arc<T> {
impl<T: ?Sized> Clone for Arc<T> {
/// Makes a clone of the `Arc<T>`.
///
/// This increases the strong reference count.
Expand Down Expand Up @@ -313,7 +317,7 @@ impl<T> Clone for Arc<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Deref for Arc<T> {
impl<T: ?Sized> Deref for Arc<T> {
type Target = T;

#[inline]
Expand Down Expand Up @@ -356,7 +360,7 @@ impl<T: Clone> Arc<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Drop for Arc<T> {
impl<T: ?Sized> Drop for Arc<T> {
/// Drops the `Arc<T>`.
///
/// This will decrement the strong reference count. If the strong reference
Expand Down Expand Up @@ -390,7 +394,7 @@ impl<T> Drop for Arc<T> {
// it's run more than once)
let ptr = *self._ptr;
// if ptr.is_null() { return }
if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return }
if ptr as usize == 0 || ptr as usize == mem::POST_DROP_USIZE { return }

// Because `fetch_sub` is already atomic, we do not need to synchronize
// with other threads unless we are going to delete the object. This
Expand Down Expand Up @@ -424,7 +428,7 @@ impl<T> Drop for Arc<T> {

#[unstable(feature = "alloc",
reason = "Weak pointers may not belong in this module.")]
impl<T> Weak<T> {
impl<T: ?Sized> Weak<T> {
/// Upgrades a weak reference to a strong reference.
///
/// Upgrades the `Weak<T>` reference to an `Arc<T>`, if possible.
Expand Down Expand Up @@ -465,7 +469,7 @@ impl<T> Weak<T> {

#[unstable(feature = "alloc",
reason = "Weak pointers may not belong in this module.")]
impl<T> Clone for Weak<T> {
impl<T: ?Sized> Clone for Weak<T> {
/// Makes a clone of the `Weak<T>`.
///
/// This increases the weak reference count.
Expand All @@ -489,7 +493,7 @@ impl<T> Clone for Weak<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Drop for Weak<T> {
impl<T: ?Sized> Drop for Weak<T> {
/// Drops the `Weak<T>`.
///
/// This will decrement the weak reference count.
Expand Down Expand Up @@ -520,21 +524,22 @@ impl<T> Drop for Weak<T> {
let ptr = *self._ptr;

// see comments above for why this check is here
if ptr.is_null() || ptr as usize == mem::POST_DROP_USIZE { return }
if ptr as usize == 0 || ptr as usize == mem::POST_DROP_USIZE { return }

// If we find out that we were the last weak pointer, then its time to
// deallocate the data entirely. See the discussion in Arc::drop() about
// the memory orderings
if self.inner().weak.fetch_sub(1, Release) == 1 {
atomic::fence(Acquire);
unsafe { deallocate(ptr as *mut u8, size_of::<ArcInner<T>>(),
min_align_of::<ArcInner<T>>()) }
unsafe { deallocate(ptr as *mut u8,
size_of_val(&*ptr),
min_align_of_val(&*ptr)) }
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PartialEq> PartialEq for Arc<T> {
impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
/// Equality for two `Arc<T>`s.
///
/// Two `Arc<T>`s are equal if their inner value are equal.
Expand Down Expand Up @@ -566,7 +571,7 @@ impl<T: PartialEq> PartialEq for Arc<T> {
fn ne(&self, other: &Arc<T>) -> bool { *(*self) != *(*other) }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PartialOrd> PartialOrd for Arc<T> {
impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> {
/// Partial comparison for two `Arc<T>`s.
///
/// The two are compared by calling `partial_cmp()` on their inner values.
Expand Down Expand Up @@ -645,21 +650,21 @@ impl<T: PartialOrd> PartialOrd for Arc<T> {
fn ge(&self, other: &Arc<T>) -> bool { *(*self) >= *(*other) }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Ord for Arc<T> {
impl<T: ?Sized + Ord> Ord for Arc<T> {
fn cmp(&self, other: &Arc<T>) -> Ordering { (**self).cmp(&**other) }
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Eq> Eq for Arc<T> {}
impl<T: ?Sized + Eq> Eq for Arc<T> {}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: fmt::Display> fmt::Display for Arc<T> {
impl<T: ?Sized + fmt::Display> fmt::Display for Arc<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: fmt::Debug> fmt::Debug for Arc<T> {
impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
}
Expand All @@ -679,7 +684,7 @@ impl<T: Default> Default for Arc<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Hash> Hash for Arc<T> {
impl<T: ?Sized + Hash> Hash for Arc<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
(**self).hash(state)
}
Expand Down Expand Up @@ -906,4 +911,13 @@ mod tests {
// Make sure deriving works with Arc<T>
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Default)]
struct Foo { inner: Arc<i32> }

#[test]
fn test_unsized() {
let x: Arc<[i32]> = Arc::new([1, 2, 3]);
assert_eq!(format!("{:?}", x), "[1, 2, 3]");
let y = x.clone().downgrade();
drop(x);
assert!(y.upgrade().is_none());
}
}
Loading