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 9 pull requests #45907

Merged
merged 24 commits into from
Nov 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a4e5c91
libtest: Force a newline every 100 dots when testing in quiet mode.
kennytm Nov 3, 2017
1b5aaf2
dist-powerpc64le-linux: Use links from vault.centos.org instead.
kennytm Nov 3, 2017
33400fb
Modify the script to allow for running docker images on Windows 7.
kennytm Oct 31, 2017
d517668
If the linker segfaulted, don't emit it as a warning.
kennytm Nov 4, 2017
51e2247
Abbreviate some stdout/stderr output in compiletest.
kennytm Nov 5, 2017
9cfdaba
Force `gem update --system` before deployment.
kennytm Nov 5, 2017
eee10cc
Try to print the crash logs on macOS on failure.
kennytm Nov 5, 2017
e652144
Add `Option::filter()` according to RFC 2124
LukasKalbertodt Oct 3, 2017
3d480b4
Add missing example for Debug trait
GuillaumeGomez Nov 8, 2017
d0339c7
Fix help for duplicated names: `extern crate (...) as (...)`
estebank Nov 8, 2017
cd32aff
get() example should use get() not get_mut()
jhford Nov 8, 2017
47ed473
fix core for targets with max-atomic-width = 0
japaric Nov 8, 2017
6a92c0f
Allow a trailing comma in assert_eq/ne macro
KamilaBorowska Nov 9, 2017
48655ea
add a bunch of debug logging to transform::inline
arielb1 Nov 9, 2017
0872cda
Fix typo in -Zsaturating-float-casts test
Nov 10, 2017
2c4a0a7
Rollup merge of #45783 - kennytm:compiler-test-fixes, r=alexcrichton
kennytm Nov 10, 2017
de083eb
Rollup merge of #45856 - estebank:issue-45829, r=nikomatsakis
kennytm Nov 10, 2017
65a0fb8
Rollup merge of #45863 - LukasKalbertodt:add-option-filter, r=dtolnay
kennytm Nov 10, 2017
91cdb0f
Rollup merge of #45869 - GuillaumeGomez:debug-doc, r=frewsxcv
kennytm Nov 10, 2017
e26bcbe
Rollup merge of #45878 - jhford:use-get-in-get-example, r=kennytm
kennytm Nov 10, 2017
20e11db
Rollup merge of #45882 - japaric:gh45802, r=kennytm
kennytm Nov 10, 2017
253d18e
Rollup merge of #45887 - xfix:assert-eq-trailling-comma, r=dtolnay
kennytm Nov 10, 2017
9c76885
Rollup merge of #45895 - arielb1:inline-debug, r=eddyb
kennytm Nov 10, 2017
6a9931c
Rollup merge of #45901 - rkruppe:fix-typo, r=kennytm
kennytm Nov 10, 2017
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
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,14 @@ after_failure:

# Random attempt at debugging currently. Just poking around in here to see if
# anything shows up.
- ls $HOME/Library/Logs/DiagnosticReports/
- ls -lat $HOME/Library/Logs/DiagnosticReports/
- find $HOME/Library/Logs/DiagnosticReports/ ! \(
-name '*.stage2-*.crash'
-name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash'
\)
-exec echo -e travis_fold":start:crashlog\n\033[31;1m" {} "\033[0m" \;
-exec head -750 {} \;
-exec echo travis_fold":"end:crashlog \;

# attempt to debug anything killed by the oom killer on linux, just to see if
# it happened
Expand Down Expand Up @@ -286,6 +293,7 @@ before_deploy:
rm -rf obj/build/dist/doc &&
cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT;
fi
- travis_retry gem update --system

deploy:
- provider: s3
Expand Down
2 changes: 2 additions & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 46 additions & 4 deletions src/ci/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,48 @@ Images will output artifacts in an `obj` dir at the root of a repository.
- `scripts` contains files shared by docker images
- `disabled` contains images that are not built on travis

## Docker Toolbox on Windows

For Windows before Windows 10, the docker images can be run on Windows via
[Docker Toolbox]. There are several preparation needs to be made before running
a Docker image.

1. Stop the virtual machine from the terminal with `docker-machine stop`

2. If your Rust source is placed outside of `C:\Users\**`, e.g. if you place the
repository in the `E:\rust` folder, please add a shared folder from
VirtualBox by:

1. Select the "default" virtual machine inside VirtualBox, then click
"Settings"
2. Go to "Shared Folders", click "Add shared foldrer" (the folder icon with
a plus sign), fill in the following information, then click "OK":

* Folder path: `E:\rust`
* Folder name: `e/rust`
* Read-only: ☐ *unchecked*
* Auto-mount: ☑ *checked*
* Make Permanant: ☑ *checked*

3. VirtualBox might not support creating symbolic links inside a shared folder
by default. You can enable it manually by running these from `cmd.exe`:

```bat
cd "C:\Program Files\Oracle\VirtualBox"
VBoxManage setextradata default VBoxInternal2/SharedFoldersEnableSymlinksCreate/e/rust 1
:: ^~~~~~
:: folder name
```

4. Restart the virtual machine from terminal with `docker-machine start`.

To run the image,

1. Launch the "Docker Quickstart Terminal".
2. Execute `./src/ci/docker/run.sh $image_name` as explained at the beginning.

[Docker Toolbox]: https://www.docker.com/products/docker-toolbox

## Cross toolchains

A number of these images take quite a long time to compile as they're building
Expand Down Expand Up @@ -137,7 +179,7 @@ For targets: `armv7-unknown-linux-gnueabihf`
libraries like jemalloc. See the mk/cfg/arm(v7)-uknown-linux-gnueabi{,hf}.mk
file in Rust's source code.

## `aarch64-linux-gnu.config`
### `aarch64-linux-gnu.config`

For targets: `aarch64-unknown-linux-gnu`

Expand All @@ -150,7 +192,7 @@ For targets: `aarch64-unknown-linux-gnu`
- C compiler > gcc version = 5.2.0
- C compiler > C++ = ENABLE -- to cross compile LLVM

## `powerpc-linux-gnu.config`
### `powerpc-linux-gnu.config`

For targets: `powerpc-unknown-linux-gnu`

Expand All @@ -165,7 +207,7 @@ For targets: `powerpc-unknown-linux-gnu`
- C compiler > gcc version = 4.9.3
- C compiler > C++ = ENABLE -- to cross compile LLVM

## `powerpc64-linux-gnu.config`
### `powerpc64-linux-gnu.config`

For targets: `powerpc64-unknown-linux-gnu`

Expand All @@ -184,7 +226,7 @@ For targets: `powerpc64-unknown-linux-gnu`

(+) These CPU options match the configuration of the toolchains in RHEL6.

## `s390x-linux-gnu.config`
### `s390x-linux-gnu.config`

For targets: `s390x-unknown-linux-gnu`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ SYSROOT=/usr/local/$TARGET/sysroot
mkdir -p $SYSROOT
pushd $SYSROOT

centos_base=http://mirror.centos.org/altarch/7/os/ppc64le/Packages
glibc_v=2.17-196.el7
kernel_v=3.10.0-693.el7
centos_base=http://vault.centos.org/altarch/7.3.1611/os/ppc64le/Packages/
glibc_v=2.17-157.el7
kernel_v=3.10.0-514.el7
for package in glibc{,-devel,-headers}-$glibc_v kernel-headers-$kernel_v; do
curl $centos_base/$package.ppc64le.rpm | \
rpm2cpio - | cpio -idm
Expand Down
13 changes: 11 additions & 2 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

set -e

export MSYS_NO_PATHCONV=1

script=`cd $(dirname $0) && pwd`/`basename $0`
image=$1

Expand All @@ -25,12 +27,19 @@ travis_fold start build_docker
travis_time_start

if [ -f "$docker_dir/$image/Dockerfile" ]; then
dockerfile="$docker_dir/$image/Dockerfile"
if [ -x /usr/bin/cygpath ]; then
context="`cygpath -w $docker_dir`"
dockerfile="`cygpath -w $dockerfile`"
else
context="$docker_dir"
fi
retry docker \
build \
--rm \
-t rust-ci \
-f "$docker_dir/$image/Dockerfile" \
"$docker_dir"
-f "$dockerfile" \
"$context"
elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
if [ -n "$TRAVIS_OS_NAME" ]; then
echo Cannot run disabled images on travis!
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,16 @@ impl str {
/// # Examples
///
/// ```
/// let mut v = String::from("🗻∈🌏");
/// let v = String::from("🗻∈🌏");
///
/// assert_eq!(Some("🗻"), v.get(0..4));
///
/// // indices not on UTF-8 sequence boundaries
/// assert!(v.get_mut(1..).is_none());
/// assert!(v.get_mut(..8).is_none());
/// assert!(v.get(1..).is_none());
/// assert!(v.get(..8).is_none());
///
/// // out of bounds
/// assert!(v.get_mut(..42).is_none());
/// assert!(v.get(..42).is_none());
/// ```
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
#[inline]
Expand Down
20 changes: 20 additions & 0 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,26 @@ impl<'a> Display for Arguments<'a> {
#[lang = "debug_trait"]
pub trait Debug {
/// Formats the value using the given formatter.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Position {
/// longitude: f32,
/// latitude: f32,
/// }
///
/// impl fmt::Debug for Position {
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
/// write!(f, "({:?}, {:?})", self.longitude, self.latitude)
/// }
/// }
///
/// assert_eq!("(1.987, 2.983)".to_owned(),
/// format!("{:?}", Position { longitude: 1.987, latitude: 2.983, }));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter) -> Result;
}
Expand Down
6 changes: 6 additions & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ macro_rules! assert_eq {
}
}
});
($left:expr, $right:expr,) => ({
assert_eq!($left, $right)
});
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
(left_val, right_val) => {
Expand Down Expand Up @@ -168,6 +171,9 @@ macro_rules! assert_ne {
}
}
});
($left:expr, $right:expr,) => {
assert_ne!($left, $right)
};
($left:expr, $right:expr, $($arg:tt)+) => ({
match (&($left), &($right)) {
(left_val, right_val) => {
Expand Down
39 changes: 39 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,45 @@ impl<T> Option<T> {
}
}

/// Returns `None` if the option is `None`, otherwise calls `predicate`
/// with the wrapped value and returns:
///
/// - `Some(t)` if `predicate` returns `true` (where `t` is the wrapped
/// value), and
/// - `None` if `predicate` returns `false`.
///
/// This function works similar to `Iterator::filter()`. You can imagine
/// the `Option<T>` being an iterator over one or zero elements. `filter()`
/// lets you decide which elements to keep.
///
/// # Examples
///
/// ```rust
/// #![feature(option_filter)]
///
/// fn is_even(n: &i32) -> bool {
/// n % 2 == 0
/// }
///
/// assert_eq!(None.filter(is_even), None);
/// assert_eq!(Some(3).filter(is_even), None);
/// assert_eq!(Some(4).filter(is_even), Some(4));
/// ```
#[inline]
#[unstable(feature = "option_filter", issue = "45860")]
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
match self {
Some(x) => {
if predicate(&x) {
Some(x)
} else {
None
}
}
None => None,
}
}

/// Returns the option if it contains a value, otherwise returns `optb`.
///
/// # Examples
Expand Down
1 change: 1 addition & 0 deletions src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ impl<T> AtomicPtr<T> {
}
}

#[cfg(target_has_atomic = "ptr")]
#[stable(feature = "atomic_from", since = "1.23.0")]
impl<T> From<*mut T> for AtomicPtr<T> {
#[inline]
Expand Down
29 changes: 23 additions & 6 deletions src/librustc_mir/transform/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const UNKNOWN_SIZE_COST: usize = 10;

pub struct Inline;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
struct CallSite<'tcx> {
callee: DefId,
substs: &'tcx Substs<'tcx>,
Expand Down Expand Up @@ -113,7 +113,9 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
loop {
local_change = false;
while let Some(callsite) = callsites.pop_front() {
debug!("checking whether to inline callsite {:?}", callsite);
if !self.tcx.is_mir_available(callsite.callee) {
debug!("checking whether to inline callsite {:?} - MIR unavailable", callsite);
continue;
}

Expand All @@ -133,10 +135,12 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
};

let start = caller_mir.basic_blocks().len();

debug!("attempting to inline callsite {:?} - mir={:?}", callsite, callee_mir);
if !self.inline_call(callsite, caller_mir, callee_mir) {
debug!("attempting to inline callsite {:?} - failure", callsite);
continue;
}
debug!("attempting to inline callsite {:?} - success", callsite);

// Add callsites from inlined function
for (bb, bb_data) in caller_mir.basic_blocks().iter_enumerated().skip(start) {
Expand Down Expand Up @@ -180,16 +184,19 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
callee_mir: &Mir<'tcx>)
-> bool
{
debug!("should_inline({:?})", callsite);
let tcx = self.tcx;

// Don't inline closures that have captures
// FIXME: Handle closures better
if callee_mir.upvar_decls.len() > 0 {
debug!(" upvar decls present - not inlining");
return false;
}

// Cannot inline generators which haven't been transformed yet
if callee_mir.yield_ty.is_some() {
debug!(" yield ty present - not inlining");
return false;
}

Expand All @@ -201,7 +208,10 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
// there are cases that prevent inlining that we
// need to check for first.
attr::InlineAttr::Always => true,
attr::InlineAttr::Never => return false,
attr::InlineAttr::Never => {
debug!("#[inline(never)] present - not inlining");
return false
}
attr::InlineAttr::Hint => true,
attr::InlineAttr::None => false,
};
Expand All @@ -211,6 +221,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
// reference unexported symbols
if callsite.callee.is_local() {
if callsite.substs.types().count() == 0 && !hinted {
debug!(" callee is an exported function - not inlining");
return false;
}
}
Expand All @@ -232,6 +243,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
if callee_mir.basic_blocks().len() <= 3 {
threshold += threshold / 4;
}
debug!(" final inline threshold = {}", threshold);

// FIXME: Give a bonus to functions with only a single caller

Expand Down Expand Up @@ -327,12 +339,17 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
}
}

debug!("Inline cost for {:?} is {}", callsite.callee, cost);

if let attr::InlineAttr::Always = hint {
debug!("INLINING {:?} because inline(always) [cost={}]", callsite, cost);
true
} else {
cost <= threshold
if cost <= threshold {
debug!("INLINING {:?} [cost={} <= threshold={}]", callsite, cost, threshold);
true
} else {
debug!("NOT inlining {:?} [cost={} > threshold={}]", callsite, cost, threshold);
false
}
}
}

Expand Down
Loading