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 13 pull requests #36220

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0384722
Add `must_use` to the Reference
Aug 17, 2016
33560ee
add links to interesting items in `std::ptr` documentation
matthew-piziak Aug 21, 2016
89f7e92
demonstrate `RHS != Self` use cases for `Add` and `Sub`
matthew-piziak Aug 18, 2016
7782838
refactor range examples
matthew-piziak Aug 17, 2016
c330046
add `fn main` wrappers to enable Rust Playground "Run" button
matthew-piziak Aug 23, 2016
34be21d
add a note that whitespace alignment is nonidiomatic
matthew-piziak Aug 23, 2016
b5ce02c
remove references to `zero_memory` and `copy_memory`
matthew-piziak Aug 30, 2016
e0279d7
Normalize the function signature of closures
Aatch Aug 31, 2016
9a400f0
replace `../` with `../../std/` to support `core` docs
matthew-piziak Aug 31, 2016
1b04762
Special case a few colors for Windows
Aug 31, 2016
439afcd
Update error message for lifetime of borrowed values
Sep 1, 2016
7d5fa9e
configure: check if any of the arguments contain --help
0xmohit Sep 1, 2016
0f8eb81
Document try!'s error conversion behaviour
skade Aug 29, 2016
7cd4e7f
Fixed E0528 label and unit test
Sep 1, 2016
96283fc
test: Add a min-llvm-version directive
alexcrichton Sep 1, 2016
7f95bb0
Fixed E0529's label and unit test
Sep 2, 2016
3a96fe3
Transition Travis CI to use rustbuild.
frewsxcv Aug 31, 2016
a6cfc58
Rollup merge of #35754 - QuietMisdreavus:must-use-reference, r=Manish…
Sep 2, 2016
fc7c26f
Rollup merge of #35759 - matthew-piziak:refactor-range-examples, r=st…
Sep 2, 2016
dfce548
Rollup merge of #35793 - matthew-piziak:add-rhs-example, r=steveklabnik
Sep 2, 2016
8d4f1c1
Rollup merge of #35880 - matthew-piziak:ptr-linking, r=steveklabnik
Sep 2, 2016
0868aaa
Rollup merge of #36099 - skade:better-try-documentation, r=steveklabnik
Sep 2, 2016
7b36b2f
Rollup merge of #36160 - Aatch:normalize-closure-sig, r=eddyb
Sep 2, 2016
39fde84
Rollup merge of #36171 - jonathandturner:temporary_value, r=nikomatsakis
Sep 2, 2016
0fee067
Rollup merge of #36178 - jonathandturner:windows_colors, r=nikomatsakis
Sep 2, 2016
1bc229f
Rollup merge of #36180 - frewsxcv:patch-33, r=alexcrichton
Sep 2, 2016
8e566f8
Rollup merge of #36190 - 0xmohit:pr/issue-31216, r=alexcrichton
Sep 2, 2016
8b0bb4e
Rollup merge of #36198 - alexcrichton:fix-travis, r=brson
Sep 2, 2016
12c7a91
Rollup merge of #36205 - EugeneGonzalez:E0528, r=jonathandturner
Sep 2, 2016
ec291dc
Rollup merge of #36210 - EugeneGonzalez:E0529, r=jonathandturner
Sep 2, 2016
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ before_install:
script:
- docker run -v `pwd`:/build rust
sh -c "
./configure --llvm-root=/usr/lib/llvm-3.7 &&
./configure --enable-rustbuild --llvm-root=/usr/lib/llvm-3.7 &&
make tidy &&
make check-notidy -j4
make check -j4
"

# Real testing happens on http://buildbot.rust-lang.org/
Expand Down
12 changes: 8 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ abs_path() {
(unset CDPATH && cd "$_path" > /dev/null && pwd)
}

HELP=0
for arg; do
case "$arg" in
--help) HELP=1;;
esac
done

msg "looking for configure programs"
need_cmd cmp
need_cmd mkdir
Expand Down Expand Up @@ -566,11 +573,8 @@ esac


OPTIONS=""
HELP=0
if [ "$1" = "--help" ]
if [ "$HELP" -eq 1 ]
then
HELP=1
shift
echo
echo "Usage: $CFG_SELF [options]"
echo
Expand Down
1 change: 1 addition & 0 deletions mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))

LLVM_ALL_COMPONENTS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --components)
LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)

endef

Expand Down
1 change: 1 addition & 0 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
--lldb-python $$(CFG_LLDB_PYTHON) \
--gdb-version="$(CFG_GDB_VERSION)" \
--lldb-version="$(CFG_LLDB_VERSION)" \
--llvm-version="$$(LLVM_VERSION_$(3))" \
--android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \
--adb-path=$(CFG_ADB) \
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ pub fn compiletest(build: &Build,
if let Some(ref dir) = build.lldb_python_dir {
cmd.arg("--lldb-python-dir").arg(dir);
}
let llvm_config = build.llvm_config(target);
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
cmd.arg("--llvm-version").arg(llvm_version);

cmd.args(&build.flags.args);

Expand All @@ -158,7 +161,6 @@ pub fn compiletest(build: &Build,
// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
if suite == "run-make" {
let llvm_config = build.llvm_config(target);
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
cmd.arg("--cc").arg(build.cc(target))
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
cargo.env("LLVM_RUSTLLVM", "1");
}
cargo.env("LLVM_CONFIG", build.llvm_config(target));
let target_config = build.config.target_config.get(target);
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
cargo.env("CFG_LLVM_ROOT", s);
}
if build.config.llvm_static_stdcpp {
cargo.env("LLVM_STATIC_STDCPP",
compiler_file(build.cxx(target), "libstdc++.a"));
Expand Down
3 changes: 3 additions & 0 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,9 @@ macro scope.
trait of the same name. `{Self}` will be replaced with the type that is supposed
to implement the trait but doesn't. To use this, the `on_unimplemented` feature gate
must be enabled.
- `must_use` - on structs and enums, will warn if a value of this type isn't used or
assigned to a variable. You may also include an optional message by using
`#[must_use = "message"]` which will be given alongside the warning.

### Conditional compilation

Expand Down
15 changes: 10 additions & 5 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,20 @@ extern "rust-intrinsic" {
/// trait objects, because they can't be read out onto the stack and
/// dropped normally.
///
/// * It is friendlier to the optimizer to do this over `ptr::read` when
/// dropping manually allocated memory (e.g. when writing Box/Rc/Vec),
/// as the compiler doesn't need to prove that it's sound to elide the
/// copy.
/// * It is friendlier to the optimizer to do this over [`ptr::read`] when
/// dropping manually allocated memory (e.g. when writing
/// [`Box`]/[`Rc`]/[`Vec`]), as the compiler doesn't need to prove that
/// it's sound to elide the copy.
///
/// # Undefined Behavior
///
/// This has all the same safety problems as `ptr::read` with respect to
/// This has all the same safety problems as [`ptr::read`] with respect to
/// invalid pointers, types, and double drops.
///
/// [`ptr::read`]: fn.read.html
/// [`Box`]: ../boxed/struct.Box.html
/// [`Rc`]: ../rc/struct.Rc.html
/// [`Vec`]: ../vec/struct.Vec.html
#[stable(feature = "drop_in_place", since = "1.8.0")]
pub fn drop_in_place<T: ?Sized>(to_drop: *mut T);

Expand Down
33 changes: 26 additions & 7 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,19 @@ macro_rules! debug_assert_eq {
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
}

/// Helper macro for unwrapping `Result` values while returning early with an
/// error if the value of the expression is `Err`. Can only be used in
/// functions that return `Result` because of the early return of `Err` that
/// it provides.
/// Helper macro for reducing boilerplate code for matching `Result` together
/// with converting downstream errors.
///
/// `try!` matches the given `Result`. In case of the `Ok` variant, the
/// expression has the value of the wrapped value.
///
/// In case of the `Err` variant, it retrieves the inner error. `try!` then
/// performs conversion using `From`. This provides automatic conversion
/// between specialized errors and more general ones. The resulting
/// error is then immediately returned.
///
/// Because of the early return, `try!` can only be used in functions that
/// return `Result`.
///
/// # Examples
///
Expand All @@ -201,18 +210,28 @@ macro_rules! debug_assert_eq {
/// use std::fs::File;
/// use std::io::prelude::*;
///
/// fn write_to_file_using_try() -> Result<(), io::Error> {
/// enum MyError {
/// FileWriteError
/// }
///
/// impl From<io::Error> for MyError {
/// fn from(e: io::Error) -> MyError {
/// MyError::FileWriteError
/// }
/// }
///
/// fn write_to_file_using_try() -> Result<(), MyError> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// try!(file.write_all(b"This is a list of my best friends."));
/// println!("I wrote to the file");
/// Ok(())
/// }
/// // This is equivalent to:
/// fn write_to_file_using_match() -> Result<(), io::Error> {
/// fn write_to_file_using_match() -> Result<(), MyError> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// match file.write_all(b"This is a list of my best friends.") {
/// Ok(v) => v,
/// Err(e) => return Err(e),
/// Err(e) => return Err(From::from(e)),
/// }
/// println!("I wrote to the file");
/// Ok(())
Expand Down
83 changes: 62 additions & 21 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@
//!
//! // `consume_and_return_x` can no longer be invoked at this point
//! ```
//!
//! This example shows the behavior of the various `Range*` structs.
//!
//! ```rust
//! #![feature(inclusive_range_syntax)]
//! fn main() {
//! let arr = [0, 1, 2, 3, 4];
//!
//! assert_eq!(arr[ .. ], [0,1,2,3,4]); // RangeFull
//! assert_eq!(arr[ ..3], [0,1,2 ]); // RangeTo
//! assert_eq!(arr[1.. ], [ 1,2,3,4]); // RangeFrom
//! assert_eq!(arr[1..3], [ 1,2 ]); // Range
//!
//! assert_eq!(arr[ ...3], [0,1,2,3 ]); // RangeToIncusive
//! assert_eq!(arr[1...3], [ 1,2,3 ]); // RangeInclusive
//! }
//! ```
//!
//! Note: whitespace alignment is not idiomatic Rust. An exception is made in
//! this case to facilitate comparison.

#![stable(feature = "rust1", since = "1.0.0")]

Expand Down Expand Up @@ -282,6 +302,12 @@ macro_rules! forward_ref_binop {
/// Point { x: 3, y: 3 });
/// }
/// ```
///
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
/// [std::time::SystemTime] implements `Add<Duration>`, which permits
/// operations of the form `SystemTime = SystemTime + Duration`.
///
/// [std::time::SystemTime]: ../../std/time/struct.SystemTime.html
#[lang = "add"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Add<RHS=Self> {
Expand Down Expand Up @@ -349,6 +375,12 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// Point { x: 1, y: 0 });
/// }
/// ```
///
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
/// [std::time::SystemTime] implements `Sub<Duration>`, which permits
/// operations of the form `SystemTime = SystemTime - Duration`.
///
/// [std::time::SystemTime]: ../../std/time/struct.SystemTime.html
#[lang = "sub"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Sub<RHS=Self> {
Expand Down Expand Up @@ -1986,11 +2018,12 @@ pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
///
/// ```
/// let arr = [0, 1, 2, 3];
/// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
/// assert_eq!(arr[ ..3], [0,1,2 ]);
/// assert_eq!(arr[1.. ], [ 1,2,3]);
/// assert_eq!(arr[1..3], [ 1,2 ]);
/// assert_eq!(arr[ .. ], [0, 1, 2, 3]);
/// ```
///
/// See the [module examples] for the behavior of other range structs.
///
/// [module examples]: ../#Examples
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RangeFull;
Expand All @@ -2015,12 +2048,13 @@ impl fmt::Debug for RangeFull {
/// assert_eq!(3+4+5, (3..6).sum());
///
/// let arr = [0, 1, 2, 3];
/// assert_eq!(arr[ .. ], [0,1,2,3]);
/// assert_eq!(arr[ ..3], [0,1,2 ]);
/// assert_eq!(arr[1.. ], [ 1,2,3]);
/// assert_eq!(arr[1..3], [ 1,2 ]); // Range
/// assert_eq!(arr[1..3], [1, 2]);
/// }
/// ```
///
/// See the [module examples] for the behavior of other range structs.
///
/// [module examples]: ../#Examples
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Range<Idx> {
Expand Down Expand Up @@ -2078,12 +2112,13 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
/// assert_eq!(2+3+4, (2..).take(3).sum());
///
/// let arr = [0, 1, 2, 3];
/// assert_eq!(arr[ .. ], [0,1,2,3]);
/// assert_eq!(arr[ ..3], [0,1,2 ]);
/// assert_eq!(arr[1.. ], [ 1,2,3]); // RangeFrom
/// assert_eq!(arr[1..3], [ 1,2 ]);
/// assert_eq!(arr[1.. ], [1, 2, 3]);
/// }
/// ```
///
/// See the [module examples] for the behavior of other range structs.
///
/// [module examples]: ../#Examples
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RangeFrom<Idx> {
Expand Down Expand Up @@ -2145,11 +2180,12 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
///
/// ```
/// let arr = [0, 1, 2, 3];
/// assert_eq!(arr[ .. ], [0,1,2,3]);
/// assert_eq!(arr[ ..3], [0,1,2 ]); // RangeTo
/// assert_eq!(arr[1.. ], [ 1,2,3]);
/// assert_eq!(arr[1..3], [ 1,2 ]);
/// assert_eq!(arr[ ..3], [0, 1, 2]);
/// ```
///
/// See the [module examples] for the behavior of other range structs.
///
/// [module examples]: ../#Examples
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RangeTo<Idx> {
Expand Down Expand Up @@ -2196,10 +2232,13 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// assert_eq!(3+4+5, (3...5).sum());
///
/// let arr = [0, 1, 2, 3];
/// assert_eq!(arr[ ...2], [0,1,2 ]);
/// assert_eq!(arr[1...2], [ 1,2 ]); // RangeInclusive
/// assert_eq!(arr[1...2], [1, 2]);
/// }
/// ```
///
/// See the [module examples] for the behavior of other range structs.
///
/// [module examples]: ../#Examples
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
pub enum RangeInclusive<Idx> {
Expand Down Expand Up @@ -2297,11 +2336,13 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// array elements up to and including the index indicated by `end`.
///
/// ```
/// #![feature(inclusive_range_syntax)]
/// let arr = [0, 1, 2, 3];
/// assert_eq!(arr[ ...2], [0,1,2 ]); // RangeToInclusive
/// assert_eq!(arr[1...2], [ 1,2 ]);
/// assert_eq!(arr[ ...2], [0, 1, 2]);
/// ```
///
/// See the [module examples] for the behavior of other range structs.
///
/// [module examples]: ../#Examples
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
pub struct RangeToInclusive<Idx> {
Expand Down
28 changes: 18 additions & 10 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,15 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
/// # Safety
///
/// Beyond accepting a raw pointer, this is unsafe because it semantically
/// moves the value out of `src` without preventing further usage of `src`.
/// If `T` is not `Copy`, then care must be taken to ensure that the value at
/// `src` is not used before the data is overwritten again (e.g. with `write`,
/// `zero_memory`, or `copy_memory`). Note that `*src = foo` counts as a use
/// because it will attempt to drop the value previously at `*src`.
/// moves the value out of `src` without preventing further usage of `src`. If
/// `T` is not [`Copy`], then care must be taken to ensure that the value at
/// `src` is not used before the data is overwritten again (e.g. with
/// [`write`]). Note that `*src = foo`
/// counts as a use because it will attempt to drop the value previously at
/// `*src`.
///
/// [`Copy`]: ../marker/trait.Copy.html
/// [`write`]: fn.write.html
///
/// # Examples
///
Expand Down Expand Up @@ -190,11 +194,15 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
/// # Safety
///
/// Beyond accepting a raw pointer, this is unsafe because it semantically
/// moves the value out of `src` without preventing further usage of `src`.
/// If `T` is not `Copy`, then care must be taken to ensure that the value at
/// `src` is not used before the data is overwritten again (e.g. with `write`,
/// `zero_memory`, or `copy_memory`). Note that `*src = foo` counts as a use
/// because it will attempt to drop the value previously at `*src`.
/// moves the value out of `src` without preventing further usage of `src`. If
/// `T` is not [`Copy`], then care must be taken to ensure that the value at
/// `src` is not used before the data is overwritten again (e.g. with
/// [`write`]). Note that `*src = foo`
/// counts as a use because it will attempt to drop the value previously at
/// `*src`.
///
/// [`Copy`]: ../marker/trait.Copy.html
/// [`write`]: fn.write.html
///
/// # Examples
///
Expand Down
Loading