Skip to content

Commit c0d326f

Browse files
committed
Auto merge of #45907 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests - Successful merges: #45783, #45856, #45863, #45869, #45878, #45882, #45887, #45895, #45901 - Failed merges:
2 parents d5ff0e6 + 6a9931c commit c0d326f

32 files changed

+563
-64
lines changed

.travis.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,14 @@ after_failure:
253253

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

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

290298
deploy:
291299
- provider: s3

src/Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ci/docker/README.md

+46-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,48 @@ Images will output artifacts in an `obj` dir at the root of a repository.
2222
- `scripts` contains files shared by docker images
2323
- `disabled` contains images that are not built on travis
2424

25+
## Docker Toolbox on Windows
26+
27+
For Windows before Windows 10, the docker images can be run on Windows via
28+
[Docker Toolbox]. There are several preparation needs to be made before running
29+
a Docker image.
30+
31+
1. Stop the virtual machine from the terminal with `docker-machine stop`
32+
33+
2. If your Rust source is placed outside of `C:\Users\**`, e.g. if you place the
34+
repository in the `E:\rust` folder, please add a shared folder from
35+
VirtualBox by:
36+
37+
1. Select the "default" virtual machine inside VirtualBox, then click
38+
"Settings"
39+
2. Go to "Shared Folders", click "Add shared foldrer" (the folder icon with
40+
a plus sign), fill in the following information, then click "OK":
41+
42+
* Folder path: `E:\rust`
43+
* Folder name: `e/rust`
44+
* Read-only: ☐ *unchecked*
45+
* Auto-mount: ☑ *checked*
46+
* Make Permanant: ☑ *checked*
47+
48+
3. VirtualBox might not support creating symbolic links inside a shared folder
49+
by default. You can enable it manually by running these from `cmd.exe`:
50+
51+
```bat
52+
cd "C:\Program Files\Oracle\VirtualBox"
53+
VBoxManage setextradata default VBoxInternal2/SharedFoldersEnableSymlinksCreate/e/rust 1
54+
:: ^~~~~~
55+
:: folder name
56+
```
57+
58+
4. Restart the virtual machine from terminal with `docker-machine start`.
59+
60+
To run the image,
61+
62+
1. Launch the "Docker Quickstart Terminal".
63+
2. Execute `./src/ci/docker/run.sh $image_name` as explained at the beginning.
64+
65+
[Docker Toolbox]: https://www.docker.com/products/docker-toolbox
66+
2567
## Cross toolchains
2668
2769
A number of these images take quite a long time to compile as they're building
@@ -137,7 +179,7 @@ For targets: `armv7-unknown-linux-gnueabihf`
137179
libraries like jemalloc. See the mk/cfg/arm(v7)-uknown-linux-gnueabi{,hf}.mk
138180
file in Rust's source code.
139181
140-
## `aarch64-linux-gnu.config`
182+
### `aarch64-linux-gnu.config`
141183
142184
For targets: `aarch64-unknown-linux-gnu`
143185
@@ -150,7 +192,7 @@ For targets: `aarch64-unknown-linux-gnu`
150192
- C compiler > gcc version = 5.2.0
151193
- C compiler > C++ = ENABLE -- to cross compile LLVM
152194
153-
## `powerpc-linux-gnu.config`
195+
### `powerpc-linux-gnu.config`
154196
155197
For targets: `powerpc-unknown-linux-gnu`
156198
@@ -165,7 +207,7 @@ For targets: `powerpc-unknown-linux-gnu`
165207
- C compiler > gcc version = 4.9.3
166208
- C compiler > C++ = ENABLE -- to cross compile LLVM
167209
168-
## `powerpc64-linux-gnu.config`
210+
### `powerpc64-linux-gnu.config`
169211
170212
For targets: `powerpc64-unknown-linux-gnu`
171213
@@ -184,7 +226,7 @@ For targets: `powerpc64-unknown-linux-gnu`
184226
185227
(+) These CPU options match the configuration of the toolchains in RHEL6.
186228
187-
## `s390x-linux-gnu.config`
229+
### `s390x-linux-gnu.config`
188230
189231
For targets: `s390x-unknown-linux-gnu`
190232

src/ci/docker/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ SYSROOT=/usr/local/$TARGET/sysroot
2323
mkdir -p $SYSROOT
2424
pushd $SYSROOT
2525

26-
centos_base=http://mirror.centos.org/altarch/7/os/ppc64le/Packages
27-
glibc_v=2.17-196.el7
28-
kernel_v=3.10.0-693.el7
26+
centos_base=http://vault.centos.org/altarch/7.3.1611/os/ppc64le/Packages/
27+
glibc_v=2.17-157.el7
28+
kernel_v=3.10.0-514.el7
2929
for package in glibc{,-devel,-headers}-$glibc_v kernel-headers-$kernel_v; do
3030
curl $centos_base/$package.ppc64le.rpm | \
3131
rpm2cpio - | cpio -idm

src/ci/docker/run.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
set -e
1313

14+
export MSYS_NO_PATHCONV=1
15+
1416
script=`cd $(dirname $0) && pwd`/`basename $0`
1517
image=$1
1618

@@ -25,12 +27,19 @@ travis_fold start build_docker
2527
travis_time_start
2628

2729
if [ -f "$docker_dir/$image/Dockerfile" ]; then
30+
dockerfile="$docker_dir/$image/Dockerfile"
31+
if [ -x /usr/bin/cygpath ]; then
32+
context="`cygpath -w $docker_dir`"
33+
dockerfile="`cygpath -w $dockerfile`"
34+
else
35+
context="$docker_dir"
36+
fi
2837
retry docker \
2938
build \
3039
--rm \
3140
-t rust-ci \
32-
-f "$docker_dir/$image/Dockerfile" \
33-
"$docker_dir"
41+
-f "$dockerfile" \
42+
"$context"
3443
elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then
3544
if [ -n "$TRAVIS_OS_NAME" ]; then
3645
echo Cannot run disabled images on travis!

src/liballoc/str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,16 @@ impl str {
363363
/// # Examples
364364
///
365365
/// ```
366-
/// let mut v = String::from("🗻∈🌏");
366+
/// let v = String::from("🗻∈🌏");
367367
///
368368
/// assert_eq!(Some("🗻"), v.get(0..4));
369369
///
370370
/// // indices not on UTF-8 sequence boundaries
371-
/// assert!(v.get_mut(1..).is_none());
372-
/// assert!(v.get_mut(..8).is_none());
371+
/// assert!(v.get(1..).is_none());
372+
/// assert!(v.get(..8).is_none());
373373
///
374374
/// // out of bounds
375-
/// assert!(v.get_mut(..42).is_none());
375+
/// assert!(v.get(..42).is_none());
376376
/// ```
377377
#[stable(feature = "str_checked_slicing", since = "1.20.0")]
378378
#[inline]

src/libcore/fmt/mod.rs

+20
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,26 @@ impl<'a> Display for Arguments<'a> {
525525
#[lang = "debug_trait"]
526526
pub trait Debug {
527527
/// Formats the value using the given formatter.
528+
///
529+
/// # Examples
530+
///
531+
/// ```
532+
/// use std::fmt;
533+
///
534+
/// struct Position {
535+
/// longitude: f32,
536+
/// latitude: f32,
537+
/// }
538+
///
539+
/// impl fmt::Debug for Position {
540+
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
541+
/// write!(f, "({:?}, {:?})", self.longitude, self.latitude)
542+
/// }
543+
/// }
544+
///
545+
/// assert_eq!("(1.987, 2.983)".to_owned(),
546+
/// format!("{:?}", Position { longitude: 1.987, latitude: 2.983, }));
547+
/// ```
528548
#[stable(feature = "rust1", since = "1.0.0")]
529549
fn fmt(&self, f: &mut Formatter) -> Result;
530550
}

src/libcore/macros.rs

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ macro_rules! assert_eq {
120120
}
121121
}
122122
});
123+
($left:expr, $right:expr,) => ({
124+
assert_eq!($left, $right)
125+
});
123126
($left:expr, $right:expr, $($arg:tt)+) => ({
124127
match (&($left), &($right)) {
125128
(left_val, right_val) => {
@@ -168,6 +171,9 @@ macro_rules! assert_ne {
168171
}
169172
}
170173
});
174+
($left:expr, $right:expr,) => {
175+
assert_ne!($left, $right)
176+
};
171177
($left:expr, $right:expr, $($arg:tt)+) => ({
172178
match (&($left), &($right)) {
173179
(left_val, right_val) => {

src/libcore/option.rs

+39
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,45 @@ impl<T> Option<T> {
607607
}
608608
}
609609

610+
/// Returns `None` if the option is `None`, otherwise calls `predicate`
611+
/// with the wrapped value and returns:
612+
///
613+
/// - `Some(t)` if `predicate` returns `true` (where `t` is the wrapped
614+
/// value), and
615+
/// - `None` if `predicate` returns `false`.
616+
///
617+
/// This function works similar to `Iterator::filter()`. You can imagine
618+
/// the `Option<T>` being an iterator over one or zero elements. `filter()`
619+
/// lets you decide which elements to keep.
620+
///
621+
/// # Examples
622+
///
623+
/// ```rust
624+
/// #![feature(option_filter)]
625+
///
626+
/// fn is_even(n: &i32) -> bool {
627+
/// n % 2 == 0
628+
/// }
629+
///
630+
/// assert_eq!(None.filter(is_even), None);
631+
/// assert_eq!(Some(3).filter(is_even), None);
632+
/// assert_eq!(Some(4).filter(is_even), Some(4));
633+
/// ```
634+
#[inline]
635+
#[unstable(feature = "option_filter", issue = "45860")]
636+
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
637+
match self {
638+
Some(x) => {
639+
if predicate(&x) {
640+
Some(x)
641+
} else {
642+
None
643+
}
644+
}
645+
None => None,
646+
}
647+
}
648+
610649
/// Returns the option if it contains a value, otherwise returns `optb`.
611650
///
612651
/// # Examples

src/libcore/sync/atomic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ impl<T> AtomicPtr<T> {
927927
}
928928
}
929929

930+
#[cfg(target_has_atomic = "ptr")]
930931
#[stable(feature = "atomic_from", since = "1.23.0")]
931932
impl<T> From<*mut T> for AtomicPtr<T> {
932933
#[inline]

src/librustc_mir/transform/inline.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const UNKNOWN_SIZE_COST: usize = 10;
3737

3838
pub struct Inline;
3939

40-
#[derive(Copy, Clone)]
40+
#[derive(Copy, Clone, Debug)]
4141
struct CallSite<'tcx> {
4242
callee: DefId,
4343
substs: &'tcx Substs<'tcx>,
@@ -113,7 +113,9 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
113113
loop {
114114
local_change = false;
115115
while let Some(callsite) = callsites.pop_front() {
116+
debug!("checking whether to inline callsite {:?}", callsite);
116117
if !self.tcx.is_mir_available(callsite.callee) {
118+
debug!("checking whether to inline callsite {:?} - MIR unavailable", callsite);
117119
continue;
118120
}
119121

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

135137
let start = caller_mir.basic_blocks().len();
136-
138+
debug!("attempting to inline callsite {:?} - mir={:?}", callsite, callee_mir);
137139
if !self.inline_call(callsite, caller_mir, callee_mir) {
140+
debug!("attempting to inline callsite {:?} - failure", callsite);
138141
continue;
139142
}
143+
debug!("attempting to inline callsite {:?} - success", callsite);
140144

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

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

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

@@ -201,7 +208,10 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
201208
// there are cases that prevent inlining that we
202209
// need to check for first.
203210
attr::InlineAttr::Always => true,
204-
attr::InlineAttr::Never => return false,
211+
attr::InlineAttr::Never => {
212+
debug!("#[inline(never)] present - not inlining");
213+
return false
214+
}
205215
attr::InlineAttr::Hint => true,
206216
attr::InlineAttr::None => false,
207217
};
@@ -211,6 +221,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
211221
// reference unexported symbols
212222
if callsite.callee.is_local() {
213223
if callsite.substs.types().count() == 0 && !hinted {
224+
debug!(" callee is an exported function - not inlining");
214225
return false;
215226
}
216227
}
@@ -232,6 +243,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
232243
if callee_mir.basic_blocks().len() <= 3 {
233244
threshold += threshold / 4;
234245
}
246+
debug!(" final inline threshold = {}", threshold);
235247

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

@@ -327,12 +339,17 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
327339
}
328340
}
329341

330-
debug!("Inline cost for {:?} is {}", callsite.callee, cost);
331-
332342
if let attr::InlineAttr::Always = hint {
343+
debug!("INLINING {:?} because inline(always) [cost={}]", callsite, cost);
333344
true
334345
} else {
335-
cost <= threshold
346+
if cost <= threshold {
347+
debug!("INLINING {:?} [cost={} <= threshold={}]", callsite, cost, threshold);
348+
true
349+
} else {
350+
debug!("NOT inlining {:?} [cost={} > threshold={}]", callsite, cost, threshold);
351+
false
352+
}
336353
}
337354
}
338355

0 commit comments

Comments
 (0)