From 7c316090ebf216308b36ba1651bc6286b113ebd7 Mon Sep 17 00:00:00 2001 From: newpavlov Date: Tue, 26 Jun 2018 13:34:42 +0300 Subject: [PATCH 01/25] Deprecation of str::slice_uncheked(_mut) --- src/liballoc/str.rs | 8 ++++---- src/liballoc/string.rs | 2 +- src/libcore/str/mod.rs | 28 +++++++++++++++------------- src/libcore/str/pattern.rs | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 32ca8d1fa5eba..2184a84ac7d48 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -266,11 +266,11 @@ impl str { let mut result = String::new(); let mut last_end = 0; for (start, part) in self.match_indices(from) { - result.push_str(unsafe { self.slice_unchecked(last_end, start) }); + result.push_str(unsafe { self.get_unchecked(last_end..start) }); result.push_str(to); last_end = start + part.len(); } - result.push_str(unsafe { self.slice_unchecked(last_end, self.len()) }); + result.push_str(unsafe { self.get_unchecked(last_end..self.len()) }); result } @@ -307,11 +307,11 @@ impl str { let mut result = String::with_capacity(32); let mut last_end = 0; for (start, part) in self.match_indices(pat).take(count) { - result.push_str(unsafe { self.slice_unchecked(last_end, start) }); + result.push_str(unsafe { self.get_unchecked(last_end..start) }); result.push_str(to); last_end = start + part.len(); } - result.push_str(unsafe { self.slice_unchecked(last_end, self.len()) }); + result.push_str(unsafe { self.get_unchecked(last_end..self.len()) }); result } diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index a988b6a26d9df..7dbd86c003851 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1222,7 +1222,7 @@ impl String { while idx < len { let ch = unsafe { - self.slice_unchecked(idx, len).chars().next().unwrap() + self.get_unchecked(idx..len).chars().next().unwrap() }; let ch_len = ch.len_utf8(); diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 5e1a9c25a2190..210fc5fd5a6c2 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1055,7 +1055,7 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> { if !self.finished && (self.allow_trailing_empty || self.end - self.start > 0) { self.finished = true; unsafe { - let string = self.matcher.haystack().slice_unchecked(self.start, self.end); + let string = self.matcher.haystack().get_unchecked(self.start..self.end); Some(string) } } else { @@ -1070,7 +1070,7 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> { let haystack = self.matcher.haystack(); match self.matcher.next_match() { Some((a, b)) => unsafe { - let elt = haystack.slice_unchecked(self.start, a); + let elt = haystack.get_unchecked(self.start..a); self.start = b; Some(elt) }, @@ -1095,13 +1095,13 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> { let haystack = self.matcher.haystack(); match self.matcher.next_match_back() { Some((a, b)) => unsafe { - let elt = haystack.slice_unchecked(b, self.end); + let elt = haystack.get_unchecked(b..self.end); self.end = a; Some(elt) }, None => unsafe { self.finished = true; - Some(haystack.slice_unchecked(self.start, self.end)) + Some(haystack.get_unchecked(self.start..self.end)) }, } } @@ -1222,7 +1222,7 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> { #[inline] fn next(&mut self) -> Option<(usize, &'a str)> { self.0.next_match().map(|(start, end)| unsafe { - (start, self.0.haystack().slice_unchecked(start, end)) + (start, self.0.haystack().get_unchecked(start..end)) }) } @@ -1231,7 +1231,7 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> { where P::Searcher: ReverseSearcher<'a> { self.0.next_match_back().map(|(start, end)| unsafe { - (start, self.0.haystack().slice_unchecked(start, end)) + (start, self.0.haystack().get_unchecked(start..end)) }) } } @@ -1274,7 +1274,7 @@ impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> { fn next(&mut self) -> Option<&'a str> { self.0.next_match().map(|(a, b)| unsafe { // Indices are known to be on utf8 boundaries - self.0.haystack().slice_unchecked(a, b) + self.0.haystack().get_unchecked(a..b) }) } @@ -1284,7 +1284,7 @@ impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> { { self.0.next_match_back().map(|(a, b)| unsafe { // Indices are known to be on utf8 boundaries - self.0.haystack().slice_unchecked(a, b) + self.0.haystack().get_unchecked(a..b) }) } } @@ -2453,6 +2453,7 @@ impl str { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_deprecated(since = "1.28.0", reason = "duplicates `get_unchecked`")] #[inline] pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str { (begin..end).get_unchecked(self) @@ -2483,6 +2484,7 @@ impl str { /// * `begin` and `end` must be byte positions within the string slice. /// * `begin` and `end` must lie on UTF-8 sequence boundaries. #[stable(feature = "str_slice_mut", since = "1.5.0")] + #[rustc_deprecated(since = "1.28.0", reason = "duplicates `get_unchecked`")] #[inline] pub unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str { (begin..end).get_unchecked_mut(self) @@ -2524,8 +2526,8 @@ impl str { // is_char_boundary checks that the index is in [0, .len()] if self.is_char_boundary(mid) { unsafe { - (self.slice_unchecked(0, mid), - self.slice_unchecked(mid, self.len())) + (self.get_unchecked(0..mid), + self.get_unchecked(mid..self.len())) } } else { slice_error_fail(self, 0, mid) @@ -3652,7 +3654,7 @@ impl str { } unsafe { // Searcher is known to return valid indices - self.slice_unchecked(i, j) + self.get_unchecked(i..j) } } @@ -3691,7 +3693,7 @@ impl str { } unsafe { // Searcher is known to return valid indices - self.slice_unchecked(i, self.len()) + self.get_unchecked(i..self.len()) } } @@ -3738,7 +3740,7 @@ impl str { } unsafe { // Searcher is known to return valid indices - self.slice_unchecked(0, j) + self.get_unchecked(0..j) } } diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 464d57a270241..5e63fa9ff354c 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -354,7 +354,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> { #[inline] fn next_back(&mut self) -> SearchStep { let old_finger = self.finger_back; - let slice = unsafe { self.haystack.slice_unchecked(self.finger, old_finger) }; + let slice = unsafe { self.haystack.get_unchecked(self.finger..old_finger) }; let mut iter = slice.chars(); let old_len = iter.iter.len(); if let Some(ch) = iter.next_back() { From aaf2004f78d84e501c92b3a159de61819bd3db25 Mon Sep 17 00:00:00 2001 From: newpavlov Date: Tue, 26 Jun 2018 15:33:57 +0300 Subject: [PATCH 02/25] removed slice_uncheked from src/liballoc/tests/str.rs --- src/liballoc/tests/str.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 75306ac82dfd5..6275c7bb11206 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -177,9 +177,9 @@ fn test_join_for_different_lengths_with_long_separator() { #[test] fn test_unsafe_slice() { - assert_eq!("ab", unsafe {"abc".slice_unchecked(0, 2)}); - assert_eq!("bc", unsafe {"abc".slice_unchecked(1, 3)}); - assert_eq!("", unsafe {"abc".slice_unchecked(1, 1)}); + assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)}); + assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)}); + assert_eq!("", unsafe {"abc".get_unchecked(1..1)}); fn a_million_letter_a() -> String { let mut i = 0; let mut rs = String::new(); @@ -200,7 +200,7 @@ fn test_unsafe_slice() { } let letters = a_million_letter_a(); assert_eq!(half_a_million_letter_a(), - unsafe { letters.slice_unchecked(0, 500000)}); + unsafe { letters.get_unchecked(0..500000)}); } #[test] From f1cc8b2854d5c4342efc295dd7eddeed9343b556 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Tue, 26 Jun 2018 21:24:05 +0300 Subject: [PATCH 03/25] review fix --- src/libcore/str/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 210fc5fd5a6c2..e7bebc891d985 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -2453,7 +2453,7 @@ impl str { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_deprecated(since = "1.28.0", reason = "duplicates `get_unchecked`")] + #[rustc_deprecated(since = "1.29.0", reason = "duplicates `get_unchecked`")] #[inline] pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str { (begin..end).get_unchecked(self) @@ -2484,7 +2484,7 @@ impl str { /// * `begin` and `end` must be byte positions within the string slice. /// * `begin` and `end` must lie on UTF-8 sequence boundaries. #[stable(feature = "str_slice_mut", since = "1.5.0")] - #[rustc_deprecated(since = "1.28.0", reason = "duplicates `get_unchecked`")] + #[rustc_deprecated(since = "1.29.0", reason = "duplicates `get_unchecked_mut`")] #[inline] pub unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str { (begin..end).get_unchecked_mut(self) From c3e2ff8f22bb6978f48ec6dbb3710984eea43ee6 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Sun, 24 Jun 2018 10:09:25 +0900 Subject: [PATCH 04/25] Create Dockerfile based on dist-various-1. --- src/ci/docker/thumb-none/Dockerfile | 127 ++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 src/ci/docker/thumb-none/Dockerfile diff --git a/src/ci/docker/thumb-none/Dockerfile b/src/ci/docker/thumb-none/Dockerfile new file mode 100644 index 0000000000000..b195decfcf574 --- /dev/null +++ b/src/ci/docker/thumb-none/Dockerfile @@ -0,0 +1,127 @@ +FROM ubuntu:16.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + make \ + file \ + curl \ + ca-certificates \ + python2.7 \ + git \ + cmake \ + sudo \ + xz-utils \ + zlib1g-dev \ + g++-arm-linux-gnueabi \ + g++-arm-linux-gnueabihf \ + g++-aarch64-linux-gnu \ + gcc-sparc64-linux-gnu \ + libc6-dev-sparc64-cross \ + bzip2 \ + patch \ + libssl-dev \ + pkg-config \ + gcc-arm-none-eabi \ + libnewlib-arm-none-eabi + +WORKDIR /build + +COPY dist-various-1/build-rumprun.sh /build +RUN ./build-rumprun.sh + +COPY dist-various-1/install-x86_64-redox.sh /build +RUN ./install-x86_64-redox.sh + +COPY dist-various-1/install-mips-musl.sh /build +RUN ./install-mips-musl.sh + +COPY dist-various-1/install-mipsel-musl.sh /build +RUN ./install-mipsel-musl.sh + +# Suppress some warnings in the openwrt toolchains we downloaded +ENV STAGING_DIR=/tmp + +COPY scripts/musl.sh /build +RUN env \ + CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ + CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ + bash musl.sh armv5te && \ + env \ + CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv6 -marm" \ + CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv6 -marm" \ + bash musl.sh arm && \ + env \ + CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm" \ + CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv6 -marm" \ + bash musl.sh armhf && \ + env \ + CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a" \ + CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a" \ + bash musl.sh armv7 && \ + env \ + CC=aarch64-linux-gnu-gcc \ + CXX=aarch64-linux-gnu-g++ \ + bash musl.sh aarch64 && \ + env \ + CC=mips-openwrt-linux-gcc \ + CXX=mips-openwrt-linux-g++ \ + bash musl.sh mips && \ + env \ + CC=mipsel-openwrt-linux-gcc \ + CXX=mipsel-openwrt-linux-g++ \ + bash musl.sh mipsel && \ + rm -rf /build/* + +# FIXME(mozilla/sccache#235) this shouldn't be necessary but is currently +# necessary to disambiguate the mips compiler with the mipsel compiler. We want +# to give these two wrapper scripts (currently identical ones) different hashes +# to ensure that sccache understands that they're different compilers. +RUN \ + echo "# a" >> /usr/local/mips-linux-musl/bin/mips-openwrt-linux-musl-wrapper.sh && \ + echo "# b" >> /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-musl-wrapper.sh + +ENV TARGETS=asmjs-unknown-emscripten +ENV TARGETS=$TARGETS,wasm32-unknown-emscripten +ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd +ENV TARGETS=$TARGETS,mips-unknown-linux-musl +ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl +ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi +ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf +ENV TARGETS=$TARGETS,armv5te-unknown-linux-gnueabi +ENV TARGETS=$TARGETS,armv5te-unknown-linux-musleabi +ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf +ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl +ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu +ENV TARGETS=$TARGETS,x86_64-unknown-redox +ENV TARGETS=$TARGETS,thumbv6m-none-eabi +ENV TARGETS=$TARGETS,thumbv7m-none-eabi +ENV TARGETS=$TARGETS,thumbv7em-none-eabi +ENV TARGETS=$TARGETS,thumbv7em-none-eabihf + +# FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271 +# get fixed and cc update +ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ + CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ + CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ + CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc \ + CC_armv5te_unknown_linux_gnueabi=arm-linux-gnueabi-gcc \ + CFLAGS_armv5te_unknown_linux_gnueabi="-march=armv5te -marm -mfloat-abi=soft" \ + CC_armv5te_unknown_linux_musleabi=arm-linux-gnueabi-gcc \ + CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft" + +ENV RUST_CONFIGURE_ARGS \ + --musl-root-armv5te=/musl-armv5te \ + --musl-root-arm=/musl-arm \ + --musl-root-armhf=/musl-armhf \ + --musl-root-armv7=/musl-armv7 \ + --musl-root-aarch64=/musl-aarch64 \ + --musl-root-mips=/musl-mips \ + --musl-root-mipsel=/musl-mipsel \ + --enable-emscripten \ + --disable-docs + +ENV SCRIPT python2.7 ../x.py dist --target $TARGETS + +# sccache +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh From 44b7a80879114ae8505bfb7ff35d00c5d0e02254 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Sun, 24 Jun 2018 13:53:43 +0900 Subject: [PATCH 05/25] Tweak to run test for thumbv7m target. --- src/ci/docker/thumb-none/Dockerfile | 38 +++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/ci/docker/thumb-none/Dockerfile b/src/ci/docker/thumb-none/Dockerfile index b195decfcf574..bbf55c9ba5318 100644 --- a/src/ci/docker/thumb-none/Dockerfile +++ b/src/ci/docker/thumb-none/Dockerfile @@ -80,23 +80,25 @@ RUN \ echo "# a" >> /usr/local/mips-linux-musl/bin/mips-openwrt-linux-musl-wrapper.sh && \ echo "# b" >> /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-musl-wrapper.sh -ENV TARGETS=asmjs-unknown-emscripten -ENV TARGETS=$TARGETS,wasm32-unknown-emscripten -ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd -ENV TARGETS=$TARGETS,mips-unknown-linux-musl -ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl -ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi -ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf -ENV TARGETS=$TARGETS,armv5te-unknown-linux-gnueabi -ENV TARGETS=$TARGETS,armv5te-unknown-linux-musleabi -ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf -ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl -ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu -ENV TARGETS=$TARGETS,x86_64-unknown-redox -ENV TARGETS=$TARGETS,thumbv6m-none-eabi -ENV TARGETS=$TARGETS,thumbv7m-none-eabi -ENV TARGETS=$TARGETS,thumbv7em-none-eabi -ENV TARGETS=$TARGETS,thumbv7em-none-eabihf +# ENV TARGETS=asmjs-unknown-emscripten +# ENV TARGETS=$TARGETS,wasm32-unknown-emscripten +# ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd +# ENV TARGETS=$TARGETS,mips-unknown-linux-musl +# ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl +# ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi +# ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf +# ENV TARGETS=$TARGETS,armv5te-unknown-linux-gnueabi +# ENV TARGETS=$TARGETS,armv5te-unknown-linux-musleabi +# ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf +# ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl +# ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu +# ENV TARGETS=$TARGETS,x86_64-unknown-redox +# ENV TARGETS=$TARGETS,thumbv6m-none-eabi +# ENV TARGETS=$TARGETS,thumbv7m-none-eabi +# ENV TARGETS=$TARGETS,thumbv7em-none-eabi +# ENV TARGETS=$TARGETS,thumbv7em-none-eabihf + +ENV TARGETS=thumbv7m-none-eabi # FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271 # get fixed and cc update @@ -120,7 +122,7 @@ ENV RUST_CONFIGURE_ARGS \ --enable-emscripten \ --disable-docs -ENV SCRIPT python2.7 ../x.py dist --target $TARGETS +ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/run-make # sccache COPY scripts/sccache.sh /scripts/ From 990a2ff2d8de617fa0fcbc7087f72b6be43d22c0 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Sun, 24 Jun 2018 16:24:57 +0900 Subject: [PATCH 06/25] Remove the comment line that harmed. --- src/ci/docker/thumb-none/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ci/docker/thumb-none/Dockerfile b/src/ci/docker/thumb-none/Dockerfile index bbf55c9ba5318..f3ee60c296f8d 100644 --- a/src/ci/docker/thumb-none/Dockerfile +++ b/src/ci/docker/thumb-none/Dockerfile @@ -119,7 +119,6 @@ ENV RUST_CONFIGURE_ARGS \ --musl-root-aarch64=/musl-aarch64 \ --musl-root-mips=/musl-mips \ --musl-root-mipsel=/musl-mipsel \ - --enable-emscripten \ --disable-docs ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/run-make From 808bcfbe53cec7aa6d728148fc2fcb3a4c951009 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Thu, 12 Jul 2018 19:49:55 +0300 Subject: [PATCH 07/25] deprecation message improvement --- src/libcore/str/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index e7bebc891d985..d642f3d696fc2 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -2453,7 +2453,7 @@ impl str { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_deprecated(since = "1.29.0", reason = "duplicates `get_unchecked`")] + #[rustc_deprecated(since = "1.29.0", reason = "use `get_unchecked(begin..end)` instead")] #[inline] pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str { (begin..end).get_unchecked(self) @@ -2484,7 +2484,7 @@ impl str { /// * `begin` and `end` must be byte positions within the string slice. /// * `begin` and `end` must lie on UTF-8 sequence boundaries. #[stable(feature = "str_slice_mut", since = "1.5.0")] - #[rustc_deprecated(since = "1.29.0", reason = "duplicates `get_unchecked_mut`")] + #[rustc_deprecated(since = "1.29.0", reason = "use `get_unchecked_mut(begin..end)` instead")] #[inline] pub unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str { (begin..end).get_unchecked_mut(self) From bbc89b2512e8ec9ee5e16d4faa88a69aa35c6754 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Wed, 18 Jul 2018 00:40:55 +0900 Subject: [PATCH 08/25] Fix rust issue #52163 --- src/bootstrap/test.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 6254f98165665..12a845c3d6db7 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -966,7 +966,9 @@ impl Step for Compiletest { builder.ensure(compile::Rustc { compiler, target }); } - builder.ensure(compile::Test { compiler, target }); + if builder.no_std(target) == Some(false) { + builder.ensure(compile::Test { compiler, target }); + } builder.ensure(native::TestHelpers { target }); builder.ensure(RemoteCopyLibs { compiler, target }); From e15c7bd0abdf73e5bfaadbd3f6e4150fda0edc56 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Wed, 18 Jul 2018 00:59:49 +0900 Subject: [PATCH 09/25] Add IMAGE `thumb-none` to .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ba8a39f355c4b..e231acb86cbcf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -162,6 +162,8 @@ matrix: if: branch = auto - env: IMAGE=wasm32-unknown if: branch = auto + - env: IMAGE=thumb-none + if: branch = auto - env: IMAGE=x86_64-gnu if: branch = auto - env: IMAGE=x86_64-gnu-full-bootstrap From d8e64e1540998de71020a01434859ccf4702581b Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Wed, 18 Jul 2018 01:15:04 +0900 Subject: [PATCH 10/25] Adjust TARGETS. --- src/ci/docker/thumb-none/Dockerfile | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/ci/docker/thumb-none/Dockerfile b/src/ci/docker/thumb-none/Dockerfile index f3ee60c296f8d..8625aae9a75fd 100644 --- a/src/ci/docker/thumb-none/Dockerfile +++ b/src/ci/docker/thumb-none/Dockerfile @@ -80,25 +80,10 @@ RUN \ echo "# a" >> /usr/local/mips-linux-musl/bin/mips-openwrt-linux-musl-wrapper.sh && \ echo "# b" >> /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-musl-wrapper.sh -# ENV TARGETS=asmjs-unknown-emscripten -# ENV TARGETS=$TARGETS,wasm32-unknown-emscripten -# ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd -# ENV TARGETS=$TARGETS,mips-unknown-linux-musl -# ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl -# ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi -# ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf -# ENV TARGETS=$TARGETS,armv5te-unknown-linux-gnueabi -# ENV TARGETS=$TARGETS,armv5te-unknown-linux-musleabi -# ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf -# ENV TARGETS=$TARGETS,aarch64-unknown-linux-musl -# ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu -# ENV TARGETS=$TARGETS,x86_64-unknown-redox -# ENV TARGETS=$TARGETS,thumbv6m-none-eabi -# ENV TARGETS=$TARGETS,thumbv7m-none-eabi -# ENV TARGETS=$TARGETS,thumbv7em-none-eabi -# ENV TARGETS=$TARGETS,thumbv7em-none-eabihf - +# ENV TARGETS=thumbv6m-none-eabi ENV TARGETS=thumbv7m-none-eabi +ENV TARGETS=$TARGETS,thumbv7em-none-eabi +ENV TARGETS=$TARGETS,thumbv7em-none-eabihf # FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271 # get fixed and cc update From 355b99f954b743a89ab3d2fa22e7a09e82ebfe72 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Wed, 18 Jul 2018 01:42:53 +0900 Subject: [PATCH 11/25] Cleanup Dockerfile. --- src/ci/docker/thumb-none/Dockerfile | 79 ----------------------------- 1 file changed, 79 deletions(-) diff --git a/src/ci/docker/thumb-none/Dockerfile b/src/ci/docker/thumb-none/Dockerfile index 8625aae9a75fd..354c022305e9b 100644 --- a/src/ci/docker/thumb-none/Dockerfile +++ b/src/ci/docker/thumb-none/Dockerfile @@ -12,11 +12,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ sudo \ xz-utils \ zlib1g-dev \ - g++-arm-linux-gnueabi \ - g++-arm-linux-gnueabihf \ - g++-aarch64-linux-gnu \ - gcc-sparc64-linux-gnu \ - libc6-dev-sparc64-cross \ bzip2 \ patch \ libssl-dev \ @@ -24,86 +19,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-arm-none-eabi \ libnewlib-arm-none-eabi -WORKDIR /build - -COPY dist-various-1/build-rumprun.sh /build -RUN ./build-rumprun.sh - -COPY dist-various-1/install-x86_64-redox.sh /build -RUN ./install-x86_64-redox.sh - -COPY dist-various-1/install-mips-musl.sh /build -RUN ./install-mips-musl.sh - -COPY dist-various-1/install-mipsel-musl.sh /build -RUN ./install-mipsel-musl.sh - -# Suppress some warnings in the openwrt toolchains we downloaded -ENV STAGING_DIR=/tmp - -COPY scripts/musl.sh /build -RUN env \ - CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ - CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv5te -marm -mfloat-abi=soft" \ - bash musl.sh armv5te && \ - env \ - CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv6 -marm" \ - CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv6 -marm" \ - bash musl.sh arm && \ - env \ - CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm" \ - CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv6 -marm" \ - bash musl.sh armhf && \ - env \ - CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv7-a" \ - CXX=arm-linux-gnueabihf-g++ CXXFLAGS="-march=armv7-a" \ - bash musl.sh armv7 && \ - env \ - CC=aarch64-linux-gnu-gcc \ - CXX=aarch64-linux-gnu-g++ \ - bash musl.sh aarch64 && \ - env \ - CC=mips-openwrt-linux-gcc \ - CXX=mips-openwrt-linux-g++ \ - bash musl.sh mips && \ - env \ - CC=mipsel-openwrt-linux-gcc \ - CXX=mipsel-openwrt-linux-g++ \ - bash musl.sh mipsel && \ - rm -rf /build/* - -# FIXME(mozilla/sccache#235) this shouldn't be necessary but is currently -# necessary to disambiguate the mips compiler with the mipsel compiler. We want -# to give these two wrapper scripts (currently identical ones) different hashes -# to ensure that sccache understands that they're different compilers. -RUN \ - echo "# a" >> /usr/local/mips-linux-musl/bin/mips-openwrt-linux-musl-wrapper.sh && \ - echo "# b" >> /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-musl-wrapper.sh - # ENV TARGETS=thumbv6m-none-eabi ENV TARGETS=thumbv7m-none-eabi ENV TARGETS=$TARGETS,thumbv7em-none-eabi ENV TARGETS=$TARGETS,thumbv7em-none-eabihf -# FIXME: remove armv5te vars after https://github.com/alexcrichton/cc-rs/issues/271 -# get fixed and cc update -ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ - CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ - CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ - CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc \ - CC_armv5te_unknown_linux_gnueabi=arm-linux-gnueabi-gcc \ - CFLAGS_armv5te_unknown_linux_gnueabi="-march=armv5te -marm -mfloat-abi=soft" \ - CC_armv5te_unknown_linux_musleabi=arm-linux-gnueabi-gcc \ - CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft" - ENV RUST_CONFIGURE_ARGS \ - --musl-root-armv5te=/musl-armv5te \ - --musl-root-arm=/musl-arm \ - --musl-root-armhf=/musl-armhf \ - --musl-root-armv7=/musl-armv7 \ - --musl-root-aarch64=/musl-aarch64 \ - --musl-root-mips=/musl-mips \ - --musl-root-mipsel=/musl-mipsel \ --disable-docs ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/run-make From 0b3b8bf15c9f6be35c2f7cf1f282d81859dd05d2 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Wed, 18 Jul 2018 18:14:47 +0900 Subject: [PATCH 12/25] Use `dist-various-1` Dockerfile. --- .travis.yml | 2 -- src/ci/docker/dist-various-1/Dockerfile | 9 ++++++- src/ci/docker/thumb-none/Dockerfile | 34 ------------------------- 3 files changed, 8 insertions(+), 37 deletions(-) delete mode 100644 src/ci/docker/thumb-none/Dockerfile diff --git a/.travis.yml b/.travis.yml index e231acb86cbcf..ba8a39f355c4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -162,8 +162,6 @@ matrix: if: branch = auto - env: IMAGE=wasm32-unknown if: branch = auto - - env: IMAGE=thumb-none - if: branch = auto - env: IMAGE=x86_64-gnu if: branch = auto - env: IMAGE=x86_64-gnu-full-bootstrap diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile index b195decfcf574..e57209b9c65b3 100644 --- a/src/ci/docker/dist-various-1/Dockerfile +++ b/src/ci/docker/dist-various-1/Dockerfile @@ -80,6 +80,11 @@ RUN \ echo "# a" >> /usr/local/mips-linux-musl/bin/mips-openwrt-linux-musl-wrapper.sh && \ echo "# b" >> /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-musl-wrapper.sh +# ENV RUN_MAKE_TARGETS=thumbv6m-none-eabi +ENV RUN_MAKE_TARGETS=thumbv7m-none-eabi +ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7em-none-eabi +ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7em-none-eabihf + ENV TARGETS=asmjs-unknown-emscripten ENV TARGETS=$TARGETS,wasm32-unknown-emscripten ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd @@ -120,7 +125,9 @@ ENV RUST_CONFIGURE_ARGS \ --enable-emscripten \ --disable-docs -ENV SCRIPT python2.7 ../x.py dist --target $TARGETS +ENV SCRIPT \ + python2.7 ../x.py test --target $RUN_MAKE_TARGETS src/test/run-make && \ + python2.7 ../x.py dist --target $TARGETS # sccache COPY scripts/sccache.sh /scripts/ diff --git a/src/ci/docker/thumb-none/Dockerfile b/src/ci/docker/thumb-none/Dockerfile deleted file mode 100644 index 354c022305e9b..0000000000000 --- a/src/ci/docker/thumb-none/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update && apt-get install -y --no-install-recommends \ - g++ \ - make \ - file \ - curl \ - ca-certificates \ - python2.7 \ - git \ - cmake \ - sudo \ - xz-utils \ - zlib1g-dev \ - bzip2 \ - patch \ - libssl-dev \ - pkg-config \ - gcc-arm-none-eabi \ - libnewlib-arm-none-eabi - -# ENV TARGETS=thumbv6m-none-eabi -ENV TARGETS=thumbv7m-none-eabi -ENV TARGETS=$TARGETS,thumbv7em-none-eabi -ENV TARGETS=$TARGETS,thumbv7em-none-eabihf - -ENV RUST_CONFIGURE_ARGS \ - --disable-docs - -ENV SCRIPT python2.7 ../x.py test --target $TARGETS src/test/run-make - -# sccache -COPY scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh From 76300903bc1020159297cdb929434bc488f99e85 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Wed, 18 Jul 2018 18:17:37 +0900 Subject: [PATCH 13/25] Re-include `thumbv6m-none-eabi` to `run-make` target --- src/ci/docker/dist-various-1/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile index e57209b9c65b3..702f9b2886e70 100644 --- a/src/ci/docker/dist-various-1/Dockerfile +++ b/src/ci/docker/dist-various-1/Dockerfile @@ -80,8 +80,8 @@ RUN \ echo "# a" >> /usr/local/mips-linux-musl/bin/mips-openwrt-linux-musl-wrapper.sh && \ echo "# b" >> /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-musl-wrapper.sh -# ENV RUN_MAKE_TARGETS=thumbv6m-none-eabi -ENV RUN_MAKE_TARGETS=thumbv7m-none-eabi +ENV RUN_MAKE_TARGETS=thumbv6m-none-eabi +ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7m-none-eabi ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7em-none-eabi ENV RUN_MAKE_TARGETS=$RUN_MAKE_TARGETS,thumbv7em-none-eabihf From ce756321ba888c7701cb81febd1de2bd98f87724 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 18 Jul 2018 12:50:13 -0700 Subject: [PATCH 14/25] Document that Unique::empty() and NonNull::dangling() aren't sentinel values The documentation of Unique::empty() and NonNull::dangling() could potentially suggest that they work as sentinel values indicating a not-yet-initialized pointer. However, they both declare a non-null pointer equal to the alignment of the type, which could potentially reference a valid value of that type (specifically, the first such valid value in memory). Explicitly document that the return value of these functions does not work as a sentinel value. --- src/libcore/ptr.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 0af642258c277..d8e061496d915 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2703,6 +2703,11 @@ impl Unique { /// /// This is useful for initializing types which lazily allocate, like /// `Vec::new` does. + /// + /// Note that the pointer value may potentially represent a valid pointer to + /// a `T`, which means this must not be used as a "not yet initialized" + /// sentinel value. Types that lazily allocate must track initialization by + /// some other means. // FIXME: rename to dangling() to match NonNull? pub const fn empty() -> Self { unsafe { @@ -2834,6 +2839,11 @@ impl NonNull { /// /// This is useful for initializing types which lazily allocate, like /// `Vec::new` does. + /// + /// Note that the pointer value may potentially represent a valid pointer to + /// a `T`, which means this must not be used as a "not yet initialized" + /// sentinel value. Types that lazily allocate must track initialization by + /// some other means. #[stable(feature = "nonnull", since = "1.25.0")] pub fn dangling() -> Self { unsafe { From 3074c42bfea93dbe694fc06e36404674d3cb0aae Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 18 Jul 2018 21:10:25 -0700 Subject: [PATCH 15/25] Fix links in rustdoc book. Due to a change in how mdbook generates section anchors, headers with non-alphabetic characters now start with "a". --- src/doc/rustdoc/src/passes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustdoc/src/passes.md b/src/doc/rustdoc/src/passes.md index de7c10292680c..615b3dca199f1 100644 --- a/src/doc/rustdoc/src/passes.md +++ b/src/doc/rustdoc/src/passes.md @@ -5,8 +5,8 @@ Rustdoc has a concept called "passes". These are transformations that In addition to the passes below, check out the docs for these flags: -* [`--passes`](command-line-arguments.html#--passes-add-more-rustdoc-passes) -* [`--no-defaults`](command-line-arguments.html#--no-defaults-dont-run-default-passes) +* [`--passes`](command-line-arguments.html#a--passes-add-more-rustdoc-passes) +* [`--no-defaults`](command-line-arguments.html#a--no-defaults-dont-run-default-passes) ## Default passes From e1ef8ba1427fb31329a4703eb3ef3e72ed0e7425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 18 Jul 2018 12:35:20 -0700 Subject: [PATCH 16/25] Reword when `_` couldn't be inferred --- src/librustc/infer/error_reporting/need_type_info.rs | 9 ++++++++- src/test/ui/error-codes/E0282.stderr | 2 +- src/test/ui/issue-12187-1.stderr | 2 +- src/test/ui/issue-12187-2.stderr | 2 +- src/test/ui/issue-15965.stderr | 2 +- src/test/ui/issue-18159.stderr | 2 +- src/test/ui/issue-20261.stderr | 2 +- src/test/ui/issue-2151.stderr | 2 +- src/test/ui/issue-23041.stderr | 2 +- src/test/ui/issue-24013.stderr | 2 +- src/test/ui/issue-7813.stderr | 2 +- .../ui/span/issue-42234-unknown-receiver-type.stderr | 2 +- .../ui/span/method-and-field-eager-resolution.stderr | 4 ++-- .../ui/type-check/cannot_infer_local_or_array.stderr | 2 +- 14 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index 04d14f40b850b..dbcb63addb846 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -97,7 +97,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let name = self.extract_type_name(&ty); let mut err_span = span; - let mut labels = vec![(span, format!("cannot infer type for `{}`", name))]; + let mut labels = vec![( + span, + if &name == "_" { + "cannot infer type".to_string() + } else { + format!("cannot infer type for `{}`", name) + }, + )]; let mut local_visitor = FindLocalByTypeVisitor { infcx: &self, diff --git a/src/test/ui/error-codes/E0282.stderr b/src/test/ui/error-codes/E0282.stderr index f1319f4139585..6862e2d8688fd 100644 --- a/src/test/ui/error-codes/E0282.stderr +++ b/src/test/ui/error-codes/E0282.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | let x = "hello".chars().rev().collect(); //~ ERROR E0282 | ^ | | - | cannot infer type for `_` + | cannot infer type | consider giving `x` a type error: aborting due to previous error diff --git a/src/test/ui/issue-12187-1.stderr b/src/test/ui/issue-12187-1.stderr index 7d4df2901fe3c..94afd6aab574f 100644 --- a/src/test/ui/issue-12187-1.stderr +++ b/src/test/ui/issue-12187-1.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | let &v = new(); | -^ | || - | |cannot infer type for `_` + | |cannot infer type | consider giving the pattern a type error: aborting due to previous error diff --git a/src/test/ui/issue-12187-2.stderr b/src/test/ui/issue-12187-2.stderr index f7ecbd4477293..90b41e397c6d0 100644 --- a/src/test/ui/issue-12187-2.stderr +++ b/src/test/ui/issue-12187-2.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | let &v = new(); | -^ | || - | |cannot infer type for `_` + | |cannot infer type | consider giving the pattern a type error: aborting due to previous error diff --git a/src/test/ui/issue-15965.stderr b/src/test/ui/issue-15965.stderr index 216c6460c77d1..3162556986e2b 100644 --- a/src/test/ui/issue-15965.stderr +++ b/src/test/ui/issue-15965.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | / { return () } LL | | //~^ ERROR type annotations needed [E0282] LL | | () - | |______^ cannot infer type for `_` + | |______^ cannot infer type | = note: type must be known at this point diff --git a/src/test/ui/issue-18159.stderr b/src/test/ui/issue-18159.stderr index 894660f1ebfbd..084e859111bf1 100644 --- a/src/test/ui/issue-18159.stderr +++ b/src/test/ui/issue-18159.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | let x; //~ ERROR type annotations needed | ^ | | - | cannot infer type for `_` + | cannot infer type | consider giving `x` a type error: aborting due to previous error diff --git a/src/test/ui/issue-20261.stderr b/src/test/ui/issue-20261.stderr index a7a7ea7c69b69..6cdddcff92913 100644 --- a/src/test/ui/issue-20261.stderr +++ b/src/test/ui/issue-20261.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | for (ref i,) in [].iter() { | --------- the element type for this iterator is not specified LL | i.clone(); - | ^^^^^ cannot infer type for `_` + | ^^^^^ cannot infer type | = note: type must be known at this point diff --git a/src/test/ui/issue-2151.stderr b/src/test/ui/issue-2151.stderr index 592c4f424b048..516c5287b319a 100644 --- a/src/test/ui/issue-2151.stderr +++ b/src/test/ui/issue-2151.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | let x = panic!(); | - consider giving `x` a type LL | x.clone(); //~ ERROR type annotations needed - | ^ cannot infer type for `_` + | ^ cannot infer type | = note: type must be known at this point diff --git a/src/test/ui/issue-23041.stderr b/src/test/ui/issue-23041.stderr index f89bce09c7ed3..e97a97fec09f2 100644 --- a/src/test/ui/issue-23041.stderr +++ b/src/test/ui/issue-23041.stderr @@ -2,7 +2,7 @@ error[E0282]: type annotations needed --> $DIR/issue-23041.rs:16:22 | LL | b.downcast_ref::_>(); //~ ERROR E0282 - | ^^^^^^^^ cannot infer type for `_` + | ^^^^^^^^ cannot infer type error: aborting due to previous error diff --git a/src/test/ui/issue-24013.stderr b/src/test/ui/issue-24013.stderr index 324e705e5a1dd..5729bdf2064f5 100644 --- a/src/test/ui/issue-24013.stderr +++ b/src/test/ui/issue-24013.stderr @@ -2,7 +2,7 @@ error[E0282]: type annotations needed --> $DIR/issue-24013.rs:15:20 | LL | unsafe {swap::<&mut _>(transmute(&a), transmute(&b))}; - | ^^^^^^ cannot infer type for `_` + | ^^^^^^ cannot infer type error: aborting due to previous error diff --git a/src/test/ui/issue-7813.stderr b/src/test/ui/issue-7813.stderr index 34837e90e4f79..3ab01982057b4 100644 --- a/src/test/ui/issue-7813.stderr +++ b/src/test/ui/issue-7813.stderr @@ -2,7 +2,7 @@ error[E0282]: type annotations needed --> $DIR/issue-7813.rs:12:13 | LL | let v = &[]; //~ ERROR type annotations needed - | - ^^^ cannot infer type for `_` + | - ^^^ cannot infer type | | | consider giving `v` a type diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr index e1e13e9256dcd..d2d5a4a4b1265 100644 --- a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr +++ b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr @@ -13,7 +13,7 @@ error[E0282]: type annotations needed | LL | / data.iter() //~ ERROR 22:5: 23:20: type annotations needed LL | | .sum::<_>() - | |___________________^ cannot infer type for `_` + | |___________________^ cannot infer type | = note: type must be known at this point diff --git a/src/test/ui/span/method-and-field-eager-resolution.stderr b/src/test/ui/span/method-and-field-eager-resolution.stderr index 21e19828a99cf..8a8c1e467b9fa 100644 --- a/src/test/ui/span/method-and-field-eager-resolution.stderr +++ b/src/test/ui/span/method-and-field-eager-resolution.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | let mut x = Default::default(); | ----- consider giving `x` a type LL | x.0; - | ^ cannot infer type for `_` + | ^ cannot infer type | = note: type must be known at this point @@ -14,7 +14,7 @@ error[E0282]: type annotations needed LL | let mut x = Default::default(); | ----- consider giving `x` a type LL | x[0]; - | ^ cannot infer type for `_` + | ^ cannot infer type | = note: type must be known at this point diff --git a/src/test/ui/type-check/cannot_infer_local_or_array.stderr b/src/test/ui/type-check/cannot_infer_local_or_array.stderr index 90191ae67451f..bfdd614e50d31 100644 --- a/src/test/ui/type-check/cannot_infer_local_or_array.stderr +++ b/src/test/ui/type-check/cannot_infer_local_or_array.stderr @@ -2,7 +2,7 @@ error[E0282]: type annotations needed --> $DIR/cannot_infer_local_or_array.rs:12:13 | LL | let x = []; //~ ERROR type annotations needed - | - ^^ cannot infer type for `_` + | - ^^ cannot infer type | | | consider giving `x` a type From 70e7e7d409e9282ae738de6473559af8c47fddf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 20 Jul 2018 09:17:55 -0700 Subject: [PATCH 17/25] Fix new test --- src/test/ui/issue-51116.rs | 2 +- src/test/ui/issue-51116.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/issue-51116.rs b/src/test/ui/issue-51116.rs index 34217c6236c43..c01559b11261c 100644 --- a/src/test/ui/issue-51116.rs +++ b/src/test/ui/issue-51116.rs @@ -15,7 +15,7 @@ fn main() { //~^ NOTE the element type for this iterator is not specified *tile = 0; //~^ ERROR type annotations needed - //~| NOTE cannot infer type for `_` + //~| NOTE cannot infer type //~| NOTE type must be known at this point } } diff --git a/src/test/ui/issue-51116.stderr b/src/test/ui/issue-51116.stderr index 0c38688340bf3..fc84ee9028d3b 100644 --- a/src/test/ui/issue-51116.stderr +++ b/src/test/ui/issue-51116.stderr @@ -5,7 +5,7 @@ LL | for tile in row { | --- the element type for this iterator is not specified LL | //~^ NOTE the element type for this iterator is not specified LL | *tile = 0; - | ^^^^^ cannot infer type for `_` + | ^^^^^ cannot infer type | = note: type must be known at this point From a18be44d6318b04a604d1a9b3f965fbdaab8abf6 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 21 Jul 2018 02:49:34 +0300 Subject: [PATCH 18/25] Avoid using `#[macro_export]` for documenting builtin macros --- src/libcore/macros.rs | 49 ++++++++++++----------------------- src/librustc/hir/lowering.rs | 3 ++- src/librustdoc/clean/mod.rs | 12 ++++----- src/libstd/macros.rs | 34 ++++++++++++------------ src/libsyntax/feature_gate.rs | 3 ++- 5 files changed, 43 insertions(+), 58 deletions(-) diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index c830c22ee5f50..83f9dfea8f267 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -543,6 +543,7 @@ macro_rules! unimplemented { /// into libsyntax itself. /// /// For more information, see documentation for `std`'s macros. +#[cfg(dox)] mod builtin { /// Unconditionally causes compilation to fail with the given error message when encountered. @@ -551,8 +552,7 @@ mod builtin { /// /// [`std::compile_error!`]: ../std/macro.compile_error.html #[stable(feature = "compile_error_macro", since = "1.20.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }); ($msg:expr,) => ({ /* compiler built-in */ }); @@ -564,8 +564,7 @@ mod builtin { /// /// [`std::format_args!`]: ../std/macro.format_args.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! format_args { ($fmt:expr) => ({ /* compiler built-in */ }); ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ }); @@ -577,8 +576,7 @@ mod builtin { /// /// [`std::env!`]: ../std/macro.env.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }); ($name:expr,) => ({ /* compiler built-in */ }); @@ -590,8 +588,7 @@ mod builtin { /// /// [`std::option_env!`]: ../std/macro.option_env.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }); ($name:expr,) => ({ /* compiler built-in */ }); @@ -603,8 +600,7 @@ mod builtin { /// /// [`std::concat_idents!`]: ../std/macro.concat_idents.html #[unstable(feature = "concat_idents_macro", issue = "29599")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! concat_idents { ($($e:ident),+) => ({ /* compiler built-in */ }); ($($e:ident,)+) => ({ /* compiler built-in */ }); @@ -616,8 +612,7 @@ mod builtin { /// /// [`std::concat!`]: ../std/macro.concat.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }); ($($e:expr,)*) => ({ /* compiler built-in */ }); @@ -629,8 +624,7 @@ mod builtin { /// /// [`std::line!`]: ../std/macro.line.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! line { () => ({ /* compiler built-in */ }) } /// A macro which expands to the column number on which it was invoked. @@ -639,8 +633,7 @@ mod builtin { /// /// [`std::column!`]: ../std/macro.column.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! column { () => ({ /* compiler built-in */ }) } /// A macro which expands to the file name from which it was invoked. @@ -649,8 +642,7 @@ mod builtin { /// /// [`std::file!`]: ../std/macro.file.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! file { () => ({ /* compiler built-in */ }) } /// A macro which stringifies its arguments. @@ -659,8 +651,7 @@ mod builtin { /// /// [`std::stringify!`]: ../std/macro.stringify.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) } /// Includes a utf8-encoded file as a string. @@ -669,8 +660,7 @@ mod builtin { /// /// [`std::include_str!`]: ../std/macro.include_str.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }); ($file:expr,) => ({ /* compiler built-in */ }); @@ -682,8 +672,7 @@ mod builtin { /// /// [`std::include_bytes!`]: ../std/macro.include_bytes.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }); ($file:expr,) => ({ /* compiler built-in */ }); @@ -695,8 +684,7 @@ mod builtin { /// /// [`std::module_path!`]: ../std/macro.module_path.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! module_path { () => ({ /* compiler built-in */ }) } /// Boolean evaluation of configuration flags, at compile-time. @@ -705,8 +693,7 @@ mod builtin { /// /// [`std::cfg!`]: ../std/macro.cfg.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) } /// Parse a file as an expression or an item according to the context. @@ -715,8 +702,7 @@ mod builtin { /// /// [`std::include!`]: ../std/macro.include.html #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] - #[cfg(dox)] + #[rustc_doc_only_macro] macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }); ($file:expr,) => ({ /* compiler built-in */ }); @@ -727,9 +713,8 @@ mod builtin { /// For more information, see the documentation for [`std::assert!`]. /// /// [`std::assert!`]: ../std/macro.assert.html - #[macro_export] + #[rustc_doc_only_macro] #[stable(feature = "rust1", since = "1.0.0")] - #[cfg(dox)] macro_rules! assert { ($cond:expr) => ({ /* compiler built-in */ }); ($cond:expr,) => ({ /* compiler built-in */ }); diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 99db718bdf80f..8e27a9914f485 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -3191,7 +3191,8 @@ impl<'a> LoweringContext<'a> { let mut vis = self.lower_visibility(&i.vis, None); let attrs = self.lower_attrs(&i.attrs); if let ItemKind::MacroDef(ref def) = i.node { - if !def.legacy || attr::contains_name(&i.attrs, "macro_export") { + if !def.legacy || attr::contains_name(&i.attrs, "macro_export") || + attr::contains_name(&i.attrs, "rustc_doc_only_macro") { let body = self.lower_token_stream(def.stream()); self.exported_macros.push(hir::MacroDef { name, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index b7edf73f7ceda..44a1cfa6246ec 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1253,15 +1253,13 @@ fn macro_resolve(cx: &DocContext, path_str: &str) -> Option { .resolve_macro_to_def_inner(mark, &path, MacroKind::Bang, false); if let Ok(def) = res { if let SyntaxExtension::DeclMacro { .. } = *resolver.get_macro(def) { - Some(def) - } else { - None + return Some(def); } - } else if let Some(def) = resolver.all_macros.get(&Symbol::intern(path_str)) { - Some(*def) - } else { - None } + if let Some(def) = resolver.all_macros.get(&Symbol::intern(path_str)) { + return Some(*def); + } + None } #[derive(Debug)] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 75f038407c127..57ae5d3f86204 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -303,7 +303,7 @@ macro_rules! assert_approx_eq { /// macro, but are documented here. Their implementations can be found hardcoded /// into libsyntax itself. #[cfg(dox)] -pub mod builtin { +mod builtin { /// Unconditionally causes compilation to fail with the given error message when encountered. /// @@ -341,7 +341,7 @@ pub mod builtin { /// /// [`panic!`]: ../std/macro.panic.html #[stable(feature = "compile_error_macro", since = "1.20.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }); ($msg:expr,) => ({ /* compiler built-in */ }); @@ -393,7 +393,7 @@ pub mod builtin { /// assert_eq!(s, format!("hello {}", "world")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! format_args { ($fmt:expr) => ({ /* compiler built-in */ }); ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ }); @@ -431,7 +431,7 @@ pub mod builtin { /// error: what's that?! /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }); ($name:expr,) => ({ /* compiler built-in */ }); @@ -457,7 +457,7 @@ pub mod builtin { /// println!("the secret key might be: {:?}", key); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }); ($name:expr,) => ({ /* compiler built-in */ }); @@ -488,7 +488,7 @@ pub mod builtin { /// # } /// ``` #[unstable(feature = "concat_idents_macro", issue = "29599")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! concat_idents { ($($e:ident),+) => ({ /* compiler built-in */ }); ($($e:ident,)+) => ({ /* compiler built-in */ }); @@ -510,7 +510,7 @@ pub mod builtin { /// assert_eq!(s, "test10btrue"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }); ($($e:expr,)*) => ({ /* compiler built-in */ }); @@ -538,7 +538,7 @@ pub mod builtin { /// println!("defined on line: {}", current_line); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! line { () => ({ /* compiler built-in */ }) } /// A macro which expands to the column number on which it was invoked. @@ -563,7 +563,7 @@ pub mod builtin { /// println!("defined on column: {}", current_col); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! column { () => ({ /* compiler built-in */ }) } /// A macro which expands to the file name from which it was invoked. @@ -587,7 +587,7 @@ pub mod builtin { /// println!("defined in file: {}", this_file); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! file { () => ({ /* compiler built-in */ }) } /// A macro which stringifies its arguments. @@ -606,7 +606,7 @@ pub mod builtin { /// assert_eq!(one_plus_one, "1 + 1"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) } /// Includes a utf8-encoded file as a string. @@ -640,7 +640,7 @@ pub mod builtin { /// /// Compiling 'main.rs' and running the resulting binary will print "adiรณs". #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }); ($file:expr,) => ({ /* compiler built-in */ }); @@ -677,7 +677,7 @@ pub mod builtin { /// /// Compiling 'main.rs' and running the resulting binary will print "adiรณs". #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }); ($file:expr,) => ({ /* compiler built-in */ }); @@ -701,7 +701,7 @@ pub mod builtin { /// test::foo(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! module_path { () => ({ /* compiler built-in */ }) } /// Boolean evaluation of configuration flags, at compile-time. @@ -723,7 +723,7 @@ pub mod builtin { /// }; /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) } /// Parse a file as an expression or an item according to the context. @@ -766,7 +766,7 @@ pub mod builtin { /// Compiling 'main.rs' and running the resulting binary will print /// "๐Ÿ™ˆ๐Ÿ™Š๐Ÿ™‰๐Ÿ™ˆ๐Ÿ™Š๐Ÿ™‰". #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }); ($file:expr,) => ({ /* compiler built-in */ }); @@ -819,7 +819,7 @@ pub mod builtin { /// assert!(a + b == 30, "a = {}, b = {}", a, b); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[macro_export] + #[rustc_doc_only_macro] macro_rules! assert { ($cond:expr) => ({ /* compiler built-in */ }); ($cond:expr,) => ({ /* compiler built-in */ }); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index d35249b6343f4..6164a2bf42f97 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -686,7 +686,8 @@ pub fn deprecated_attributes() -> Vec<&'static (&'static str, AttributeType, Att } pub fn is_builtin_attr(attr: &ast::Attribute) -> bool { - BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name)) + BUILTIN_ATTRIBUTES.iter().any(|&(builtin_name, _, _)| attr.check_name(builtin_name)) || + attr.name().as_str().starts_with("rustc_") } // Attributes that have a special meaning to rustc or rustdoc From c581b96f39a8c9e75261ae735d976e989488e637 Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Sat, 21 Jul 2018 11:49:52 +0200 Subject: [PATCH 19/25] Typo --- src/libstd/path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 2d86862927884..0c60129494d5c 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1836,7 +1836,7 @@ impl Path { /// * On Unix, a path has a root if it begins with `/`. /// /// * On Windows, a path has a root if it: - /// * has no prefix and begins with a separator, e.g. `\\windows` + /// * has no prefix and begins with a separator, e.g. `\windows` /// * has a prefix followed by a separator, e.g. `c:\windows` but not `c:windows` /// * has any non-disk prefix, e.g. `\\server\share` /// From 3f00b1c07b30c711777132744ec27bf8bb28609d Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Sat, 21 Jul 2018 22:39:35 +0900 Subject: [PATCH 20/25] Treat no_std(target) == None case correctly. --- src/bootstrap/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 12a845c3d6db7..38bba40aa654b 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -966,7 +966,7 @@ impl Step for Compiletest { builder.ensure(compile::Rustc { compiler, target }); } - if builder.no_std(target) == Some(false) { + if builder.no_std(target) != Some(true) { builder.ensure(compile::Test { compiler, target }); } builder.ensure(native::TestHelpers { target }); From 50720ba7066345a2c5d576c9ae8d0cfc9d1cfb50 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Sat, 21 Jul 2018 22:23:50 +0800 Subject: [PATCH 21/25] Add missing backtick --- src/librustc_mir/borrow_check/nll/universal_regions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index 8590e3d0765f0..e0aacdb05cec1 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -57,7 +57,7 @@ pub struct UniversalRegions<'tcx> { /// externals, then locals. So things from: /// - `FIRST_GLOBAL_INDEX..first_extern_index` are global; /// - `first_extern_index..first_local_index` are external; and - /// - first_local_index..num_universals` are local. + /// - `first_local_index..num_universals` are local. first_extern_index: usize, /// See `first_extern_index`. From ab0092e0d4d704db70d985ffc205db04f80c2e02 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Jul 2018 15:19:39 -0600 Subject: [PATCH 22/25] Run the error index tool against the sysroot libdir Previously when building the error index tool in stage 0 we would attempt to use stage 0 libraries, but because it depends on rustdoc, those don't exist: rustdoc is built against stage 1 libraries. This patch aligns those two and passes the stage 1 libdir to the error index. --- src/bootstrap/tool.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 42c65b750d33c..0969e5abe07dc 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -275,7 +275,7 @@ pub fn prepare_tool_cargo( macro_rules! tool { ($($name:ident, $path:expr, $tool_name:expr, $mode:expr $(,llvm_tools = $llvm:expr)*;)+) => { - #[derive(Copy, Clone)] + #[derive(Copy, PartialEq, Eq, Clone)] pub enum Tool { $( $name, @@ -640,7 +640,7 @@ impl<'a> Builder<'a> { fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) { let host = &compiler.host; let mut lib_paths: Vec = vec![ - if compiler.stage == 0 { + if compiler.stage == 0 && tool != Tool::ErrorIndex { self.build.rustc_snapshot_libdir() } else { PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)) From e6fc62a1ef6cfb545d4f33914a4440c6bbcbf9eb Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Wed, 4 Jul 2018 02:48:30 -0700 Subject: [PATCH 23/25] Don't use SIMD in mem::swap for types smaller than the block size LLVM isn't able to remove the alloca for the unaligned block in the SIMD tail in some cases, so doing this helps SRoA work in cases where it currently doesn't. Found in the `replace_with` RFC discussion. --- src/libcore/mem.rs | 2 +- src/libcore/ptr.rs | 13 +++++++++++++ src/test/codegen/swap-small-types.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/test/codegen/swap-small-types.rs diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 8fb4e0d6a02e3..a0fe6e9880606 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -638,7 +638,7 @@ pub unsafe fn uninitialized() -> T { #[stable(feature = "rust1", since = "1.0.0")] pub fn swap(x: &mut T, y: &mut T) { unsafe { - ptr::swap_nonoverlapping(x, y, 1); + ptr::swap_nonoverlapping_one(x, y); } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 0af642258c277..f1405b58e1b32 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -187,6 +187,19 @@ pub unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) { swap_nonoverlapping_bytes(x, y, len) } +#[inline] +pub(crate) unsafe fn swap_nonoverlapping_one(x: *mut T, y: *mut T) { + // For types smaller than the block optimization below, + // just swap directly to avoid pessimizing codegen. + if mem::size_of::() < 32 { + let z = read(x); + copy_nonoverlapping(y, x, 1); + write(y, z); + } else { + swap_nonoverlapping(x, y, 1); + } +} + #[inline] unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { // The approach here is to utilize simd to swap x & y efficiently. Testing reveals diff --git a/src/test/codegen/swap-small-types.rs b/src/test/codegen/swap-small-types.rs new file mode 100644 index 0000000000000..f34a1d669bda9 --- /dev/null +++ b/src/test/codegen/swap-small-types.rs @@ -0,0 +1,26 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -O + +#![crate_type = "lib"] + +use std::mem::swap; + +type RGB48 = [u16; 3]; + +// CHECK-LABEL: @swap_rgb48 +#[no_mangle] +pub fn swap_rgb48(x: &mut RGB48, y: &mut RGB48) { +// CHECK-NOT: alloca +// CHECK: load i48 +// CHECK: store i48 + swap(x, y) +} From c9482f724f2c6369a56faddd3ba4c1f00545a086 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 21 Jul 2018 23:12:46 -0700 Subject: [PATCH 24/25] Only run the test on x86_64 Smaller platforms don't merge the loads the same way. --- src/test/codegen/swap-small-types.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/codegen/swap-small-types.rs b/src/test/codegen/swap-small-types.rs index f34a1d669bda9..46406ee5182a7 100644 --- a/src/test/codegen/swap-small-types.rs +++ b/src/test/codegen/swap-small-types.rs @@ -9,6 +9,7 @@ // except according to those terms. // compile-flags: -O +// only-x86_64 #![crate_type = "lib"] From c645ecd0a6d2d0996f0a9ae771ad580300a96786 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 22 Jul 2018 13:14:06 +0100 Subject: [PATCH 25/25] Added new lines to .gitignore. --- .gitignore | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2f65ee3e777a3..9ffaa82e1c8b5 100644 --- a/.gitignore +++ b/.gitignore @@ -86,15 +86,18 @@ __pycache__/ target/ /test/ /tmp/ +tags +tags.* TAGS -TAGS.emacs -TAGS.vi +TAGS.* \#* \#*\# config.mk config.stamp keywords.md lexer.ml +mir_dump +Session.vim src/etc/dl tmp.*.rs version.md