Skip to content

Commit 0051ac5

Browse files
Merge remote-tracking branch 'upstream/master'
Conflicts: src/doc/trpl/ownership.md
2 parents 14e3885 + 50aada7 commit 0051ac5

File tree

26 files changed

+182
-67
lines changed

26 files changed

+182
-67
lines changed

AUTHORS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ Luke Francl <[email protected]>
518518
Luke Metz <[email protected]>
519519
Luke Steensen <[email protected]>
520520
Luqman Aden <[email protected]>
521+
Łukasz Niemier <[email protected]>
521522
Magnus Auvinen <[email protected]>
522523
Mahmut Bulut <[email protected]>
523524
Makoto Nakashima <[email protected]>
@@ -997,5 +998,4 @@ xales <[email protected]>
997998
998999
9991000
1000-
Łukasz Niemier <[email protected]>
10011001

configure

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ err() {
1919
exit 1
2020
}
2121

22+
run() {
23+
msg "$@"
24+
"$@"
25+
}
26+
2227
need_ok() {
2328
if [ $? -ne 0 ]
2429
then
@@ -36,8 +41,7 @@ need_cmd() {
3641
make_dir() {
3742
if [ ! -d $1 ]
3843
then
39-
msg "mkdir -p $1"
40-
mkdir -p $1
44+
run mkdir -p $1
4145
fi
4246
}
4347

@@ -46,8 +50,7 @@ copy_if_changed() {
4650
then
4751
msg "leaving $2 unchanged"
4852
else
49-
msg "cp $1 $2"
50-
cp -f $1 $2
53+
run cp -f $1 $2
5154
chmod u-w $2 # make copied artifact read-only
5255
fi
5356
}
@@ -57,8 +60,7 @@ move_if_changed() {
5760
then
5861
msg "leaving $2 unchanged"
5962
else
60-
msg "mv $1 $2"
61-
mv -f $1 $2
63+
run mv -f $1 $2
6264
chmod u-w $2 # make moved artifact read-only
6365
fi
6466
}
@@ -733,6 +735,20 @@ then
733735
probe CFG_JAVAC javac
734736
fi
735737

738+
# the valgrind rpass tests will fail if you don't have a valgrind, but they're
739+
# only disabled if you opt out.
740+
if [ -z "$CFG_VALGRIND" ]
741+
then
742+
# If the user has explicitly asked for valgrind tests, then fail
743+
if [ -n "$CFG_ENABLE_VALGRIND" ] && [ -n "$CFG_ENABLE_VALGRIND_PROVIDED" ]
744+
then
745+
err "No valgrind present, but valgrind tests explicitly requested"
746+
else
747+
CFG_DISABLE_VALGRIND_RPASS=1
748+
putvar CFG_DISABLE_VALGRIND_RPASS
749+
fi
750+
fi
751+
736752
if [ ! -z "$CFG_GDB" ]
737753
then
738754
# Store GDB's version
@@ -844,7 +860,7 @@ then
844860
CFG_OSX_GCC_VERSION=$("$CFG_GCC" --version 2>&1 | grep "Apple LLVM version")
845861
if [ $? -eq 0 ]
846862
then
847-
step_msg "on OS X 10.9, forcing use of clang"
863+
step_msg "on OS X >=10.9, forcing use of clang"
848864
CFG_ENABLE_CLANG=1
849865
else
850866
if [ $("$CFG_GCC" --version 2>&1 | grep -c ' 4\.[0-6]') -ne 0 ]; then

mk/dist.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ PKG_FILES := \
5252
doc \
5353
driver \
5454
etc \
55+
error-index-generator \
5556
$(foreach crate,$(CRATES),lib$(crate)) \
5657
libcollectionstest \
5758
libcoretest \

mk/main.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ ifndef CFG_DISABLE_VALGRIND_RPASS
195195
$(info cfg: valgrind-rpass command set to $(CFG_VALGRIND))
196196
CFG_VALGRIND_RPASS :=$(CFG_VALGRIND)
197197
else
198+
$(info cfg: disabling valgrind run-pass tests)
198199
CFG_VALGRIND_RPASS :=
199200
endif
200201

src/doc/trpl/guessing-game.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,10 @@ rand="0.3.0"
358358
The `[dependencies]` section of `Cargo.toml` is like the `[package]` section:
359359
everything that follows it is part of it, until the next section starts.
360360
Cargo uses the dependencies section to know what dependencies on external
361-
crates you have, and what versions you require. In this case, we’ve used `*`,
362-
which means that we’ll use the latest version of `rand`. Cargo understands
363-
[Semantic Versioning][semver], which is a standard for writing version
364-
numbers. If we wanted a specific version or range of versions, we could be
365-
more specific here. [Cargo’s documentation][cargodoc] contains more details.
361+
crates you have, and what versions you require. In this case, we’ve used version `0.3.0`.
362+
Cargo understands [Semantic Versioning][semver], which is a standard for writing version
363+
numbers. If we wanted to use the latest version we could use `*` or we could use a range
364+
of versions. [Cargo’s documentation][cargodoc] contains more details.
366365

367366
[semver]: http://semver.org
368367
[cargodoc]: http://doc.crates.io/crates-io.html
@@ -410,7 +409,7 @@ $ cargo build
410409
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
411410
```
412411

413-
So, we told Cargo we wanted any version of `rand`, and so it fetched the latest
412+
So, we told Cargo we wanted any `0.3.x` version of `rand`, and so it fetched the latest
414413
version at the time this was written, `v0.3.8`. But what happens when next
415414
week, version `v0.3.9` comes out, with an important bugfix? While getting
416415
bugfixes is important, what if `0.3.9` contains a regression that breaks our

src/doc/trpl/lifetimes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn main() {
116116
}
117117
```
118118

119-
[struct]: structs.html
119+
[structs]: structs.html
120120

121121
As you can see, `struct`s can also have lifetimes. In a similar way to functions,
122122

src/doc/trpl/method-syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ struct CircleBuilder {
188188
189189
impl CircleBuilder {
190190
fn new() -> CircleBuilder {
191-
CircleBuilder { x: 0.0, y: 0.0, radius: 0.0, }
191+
CircleBuilder { x: 0.0, y: 0.0, radius: 1.0, }
192192
}
193193
194194
fn x(&mut self, coordinate: f64) -> &mut CircleBuilder {

src/doc/trpl/mutability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ safety, and the mechanism by which Rust guarantees it, the
8585
> You may have one or the other of these two kinds of borrows, but not both at
8686
> the same time:
8787
>
88-
> * 0 to N references (`&T`) to a resource.
88+
> * one or more references (`&T`) to a resource.
8989
> * exactly one mutable reference (`&mut T`)
9090
9191
[ownership]: ownership.html

src/doc/trpl/ownership.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ deterministically, at the end of the scope.
5959

6060
[vect]: ../std/vec/struct.Vec.html
6161
[heap]: the-stack-and-the-heap.html
62+
[bindings]: variable-bindings.html
6263

6364
# Move semantics
6465

@@ -123,7 +124,7 @@ let v2 = v;
123124
The first line creates some data for the vector on the [stack][sh], `v`. The
124125
vector’s data, however, is stored on the [heap][sh], and so the vector contains a
125126
pointer to that data. When we move `v` to `v2`, it creates a copy of that pointer,
126-
for `v2`. This would mean two pointers to the content of the vector on the
127+
for `v2`. Which would mean two pointers to the content of the vector on the
127128
heap. That would be a problem: it would violate Rust’s safety guarantees by
128129
introducing a data race. Therefore, Rust forbids using `v` after we’ve done the
129130
move.

src/doc/trpl/traits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Here’s the error:
192192
```text
193193
error: type `std::fs::File` does not implement any method in scope named `write`
194194
195-
let result = f.write(bwhatever);
195+
let result = f.write(b"whatever");
196196
^~~~~~~~~~~~~~~~~~
197197
```
198198

src/libcollections/slice.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
#![stable(feature = "rust1", since = "1.0.0")]
8181

8282
use alloc::boxed::Box;
83-
use core::convert::AsRef;
8483
use core::clone::Clone;
8584
use core::cmp::Ordering::{self, Greater, Less};
8685
use core::cmp::{self, Ord, PartialEq};
@@ -1024,25 +1023,25 @@ pub trait SliceConcatExt<T: ?Sized> {
10241023
fn connect(&self, sep: &T) -> Self::Output;
10251024
}
10261025

1027-
impl<T: Clone, V: AsRef<[T]>> SliceConcatExt<T> for [V] {
1026+
impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
10281027
type Output = Vec<T>;
10291028

10301029
fn concat(&self) -> Vec<T> {
1031-
let size = self.iter().fold(0, |acc, v| acc + v.as_ref().len());
1030+
let size = self.iter().fold(0, |acc, v| acc + v.borrow().len());
10321031
let mut result = Vec::with_capacity(size);
10331032
for v in self {
1034-
result.push_all(v.as_ref())
1033+
result.push_all(v.borrow())
10351034
}
10361035
result
10371036
}
10381037

10391038
fn connect(&self, sep: &T) -> Vec<T> {
1040-
let size = self.iter().fold(0, |acc, v| acc + v.as_ref().len());
1039+
let size = self.iter().fold(0, |acc, v| acc + v.borrow().len());
10411040
let mut result = Vec::with_capacity(size + self.len());
10421041
let mut first = true;
10431042
for v in self {
10441043
if first { first = false } else { result.push(sep.clone()) }
1045-
result.push_all(v.as_ref())
1044+
result.push_all(v.borrow())
10461045
}
10471046
result
10481047
}

src/libcollections/str.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ use core::str::pattern::Pattern;
5959
use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};
6060
use rustc_unicode::str::{UnicodeStr, Utf16Encoder};
6161

62-
use core::convert::AsRef;
6362
use vec_deque::VecDeque;
6463
use borrow::{Borrow, ToOwned};
6564
use string::String;
@@ -83,7 +82,7 @@ pub use core::str::pattern;
8382
Section: Creating a string
8483
*/
8584

86-
impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
85+
impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
8786
type Output = String;
8887

8988
fn concat(&self) -> String {
@@ -92,11 +91,11 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
9291
}
9392

9493
// `len` calculation may overflow but push_str will check boundaries
95-
let len = self.iter().map(|s| s.as_ref().len()).sum();
94+
let len = self.iter().map(|s| s.borrow().len()).sum();
9695
let mut result = String::with_capacity(len);
9796

9897
for s in self {
99-
result.push_str(s.as_ref())
98+
result.push_str(s.borrow())
10099
}
101100

102101
result
@@ -115,7 +114,7 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
115114
// this is wrong without the guarantee that `self` is non-empty
116115
// `len` calculation may overflow but push_str but will check boundaries
117116
let len = sep.len() * (self.len() - 1)
118-
+ self.iter().map(|s| s.as_ref().len()).sum::<usize>();
117+
+ self.iter().map(|s| s.borrow().len()).sum::<usize>();
119118
let mut result = String::with_capacity(len);
120119
let mut first = true;
121120

@@ -125,7 +124,7 @@ impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
125124
} else {
126125
result.push_str(sep);
127126
}
128-
result.push_str(s.as_ref());
127+
result.push_str(s.borrow());
129128
}
130129
result
131130
}

src/libcollections/string.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,14 @@ impl AsRef<str> for String {
10571057
}
10581058
}
10591059

1060+
#[stable(feature = "rust1", since = "1.0.0")]
1061+
impl AsRef<[u8]> for String {
1062+
#[inline]
1063+
fn as_ref(&self) -> &[u8] {
1064+
self.as_bytes()
1065+
}
1066+
}
1067+
10601068
#[stable(feature = "rust1", since = "1.0.0")]
10611069
impl<'a> From<&'a str> for String {
10621070
#[cfg(not(test))]

src/libcollections/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ impl<T> Vec<T> {
647647
// zero-size types consume no memory, so we can't rely on the
648648
// address space running out
649649
self.len = self.len.checked_add(1).expect("length overflow");
650-
unsafe { mem::forget(value); }
650+
mem::forget(value);
651651
return
652652
}
653653

@@ -994,7 +994,7 @@ impl<T> Vec<T> {
994994
num_u: 0,
995995
marker: PhantomData,
996996
};
997-
unsafe { mem::forget(vec); }
997+
mem::forget(vec);
998998

999999
while pv.num_t != 0 {
10001000
unsafe {

src/libcore/intrinsics.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ extern "rust-intrinsic" {
232232
pub fn uninit<T>() -> T;
233233

234234
/// Moves a value out of scope without running drop glue.
235-
///
236-
/// `forget` is unsafe because the caller is responsible for
237-
/// ensuring the argument is deallocated already.
238-
#[stable(feature = "rust1", since = "1.0.0")]
239235
pub fn forget<T>(_: T) -> ();
240236

241237
/// Unsafely transforms a value of one type into a value of another type.

0 commit comments

Comments
 (0)