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 14 pull requests #58866

Merged
merged 34 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1fd2f16
Have all methods of Filter and FilterMap use internal iteration
timvermeulen Feb 25, 2019
8884771
Add relevant benchmarks
timvermeulen Feb 27, 2019
ec2e4ba
Improve existing benchmarks to prevent extreme optimizations
timvermeulen Feb 27, 2019
88bd624
Add trailing newline
timvermeulen Feb 27, 2019
4e7d4c7
ManuallyDrop != MaybeUninit
RalfJung Feb 27, 2019
b70a953
Replace `s` with `self` in docs for str methods taking self.
tspiteri Feb 20, 2019
f92c204
improve readability
RalfJung Feb 27, 2019
a998b1f
allow specifying attributes for tool lints
euclio Feb 27, 2019
fbdece4
Ensure `record_layout_for_printing()` is inlined.
nnethercote Feb 28, 2019
0c1a38c
Update src/libcore/mem.rs
Centril Feb 28, 2019
96be181
Fixed a syntax error in the pin docs
Feb 28, 2019
3391f6c
tidy: deny(rust_2018_idioms)
Centril Mar 1, 2019
805145f
Revert "Auto merge of #58597 - pietroalbini:appveyor-gce, r=alexcrich…
pietroalbini Mar 1, 2019
260b091
tools/rustbook: deny(rust_2018_idioms)
Centril Mar 1, 2019
c259489
tools/remote-test-{client,server}: deny(rust_2018_idioms)
Centril Mar 1, 2019
670a4d6
Fix typo in Vec#resize_with documentation
jens1o Mar 1, 2019
c3aab14
Forbid duplicating Cargo as a dependency
mati865 Mar 1, 2019
a7d17bf
Update toolchain to build NetBSD release
alexcrichton Mar 1, 2019
2e82d11
Rollup merge of #58730 - timvermeulen:internal_iteration, r=scottmcm
kennytm Mar 2, 2019
df2b6bc
Rollup merge of #58780 - RalfJung:manually-drop, r=nagisa
kennytm Mar 2, 2019
f67736a
Rollup merge of #58782 - tspiteri:str-escape-self, r=kennytm
kennytm Mar 2, 2019
4aebce5
Rollup merge of #58785 - euclio:tool-lint-attrs, r=estebank
kennytm Mar 2, 2019
8bdd948
Rollup merge of #58802 - nnethercote:inline-record_layout, r=oli-obk
kennytm Mar 2, 2019
c4f693c
Rollup merge of #58821 - alex:patch-1, r=Centril
kennytm Mar 2, 2019
2c1a7c1
Rollup merge of #58830 - Centril:rust_2018_idioms-tidy, r=oli-obk
kennytm Mar 2, 2019
1180df2
Rollup merge of #58832 - pietroalbini:appveyor-hyperv, r=kennytm
kennytm Mar 2, 2019
53fc9c6
Rollup merge of #58833 - Centril:rust_2018_idioms-rustbook, r=oli-obk
kennytm Mar 2, 2019
0404c83
Rollup merge of #58835 - Centril:rust_2018_idioms-remote-test, r=oli-obk
kennytm Mar 2, 2019
2e51007
Rollup merge of #58838 - jens1o:patch-1, r=Centril
kennytm Mar 2, 2019
133f973
Rollup merge of #58852 - alexcrichton:update-netbsd, r=Mark-Simulacrum
kennytm Mar 2, 2019
c835a0a
Rollup merge of #58842 - mati865:53005, r=alexcrichton
kennytm Mar 2, 2019
04d0a8c
Fix C-variadic function printing
dlrobertson Mar 2, 2019
379cd29
Nit
alexreg Mar 2, 2019
946e670
Rollup merge of #58865 - dlrobertson:fix-varargs, r=alexreg
kennytm Mar 3, 2019
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
5 changes: 0 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ environment:
# server goes down presumably. See #43333 for more info
CARGO_HTTP_CHECK_REVOKE: false

# Execute the builds on GCE instead of Hyper-V. Those builders have a 3-4
# minute startup overhead, but AppVeyor support recommended this as a
# possible solution for #58160 (spurious 259 exit codes)
appveyor_build_worker_cloud: gce

matrix:
# 32/64 bit MSVC tests
- MSYS_BITS: 64
Expand Down
20 changes: 2 additions & 18 deletions src/ci/docker/dist-x86_64-netbsd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,8 @@ FROM ubuntu:16.04
COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh

# Ubuntu 16.04 (this container) ships with make 4, but something in the
# toolchains we build below chokes on that, so go back to make 3
COPY scripts/make3.sh /scripts/
RUN sh /scripts/make3.sh

COPY scripts/crosstool-ng.sh /scripts/
RUN sh /scripts/crosstool-ng.sh

COPY scripts/rustbuild-setup.sh /scripts/
RUN sh /scripts/rustbuild-setup.sh
USER rustbuild
WORKDIR /tmp

COPY dist-x86_64-netbsd/build-netbsd-toolchain.sh /tmp/
RUN ./build-netbsd-toolchain.sh

USER root
RUN /tmp/build-netbsd-toolchain.sh

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand All @@ -33,6 +18,5 @@ ENV \

ENV HOSTS=x86_64-unknown-netbsd

ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs \
--set llvm.allow-old-toolchain
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
12 changes: 6 additions & 6 deletions src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot
URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror

# Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz
curl $URL/2017-03-17-netbsd-src.tgz | tar xzf -
curl $URL/2017-03-17-netbsd-gnusrc.tgz | tar xzf -
curl $URL/2017-03-17-netbsd-sharesrc.tgz | tar xzf -
curl $URL/2017-03-17-netbsd-syssrc.tgz | tar xzf -
curl $URL/2018-03-01-netbsd-src.tgz | tar xzf -
curl $URL/2018-03-01-netbsd-gnusrc.tgz | tar xzf -
curl $URL/2018-03-01-netbsd-sharesrc.tgz | tar xzf -
curl $URL/2018-03-01-netbsd-syssrc.tgz | tar xzf -

# Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/amd64/binary/sets/*.tgz
curl $URL/2017-03-17-netbsd-base.tgz | \
curl $URL/2018-03-01-netbsd-base.tgz | \
tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
curl $URL/2017-03-17-netbsd-comp.tgz | \
curl $URL/2018-03-01-netbsd-comp.tgz | \
tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib

cd usr/src
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ impl<T> Vec<T> {
/// This method uses a closure to create new values on every push. If
/// you'd rather [`Clone`] a given value, use [`resize`]. If you want
/// to use the [`Default`] trait to generate values, you can pass
/// [`Default::default()`] as the second argument..
/// [`Default::default()`] as the second argument.
///
/// # Examples
///
Expand Down
32 changes: 30 additions & 2 deletions src/libcore/benches/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ bench_sums! {
bench_sums! {
bench_filter_sum,
bench_filter_ref_sum,
(0i64..1000000).filter(|x| x % 2 == 0)
(0i64..1000000).filter(|x| x % 3 == 0)
}

bench_sums! {
bench_filter_chain_sum,
bench_filter_chain_ref_sum,
(0i64..1000000).chain(0..1000000).filter(|x| x % 2 == 0)
(0i64..1000000).chain(0..1000000).filter(|x| x % 3 == 0)
}

bench_sums! {
Expand Down Expand Up @@ -306,3 +306,31 @@ fn bench_skip_then_zip(b: &mut Bencher) {
assert_eq!(s, 2009900);
});
}

#[bench]
fn bench_filter_count(b: &mut Bencher) {
b.iter(|| {
(0i64..1000000).map(black_box).filter(|x| x % 3 == 0).count()
})
}

#[bench]
fn bench_filter_ref_count(b: &mut Bencher) {
b.iter(|| {
(0i64..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count()
})
}

#[bench]
fn bench_filter_chain_count(b: &mut Bencher) {
b.iter(|| {
(0i64..1000000).chain(0..1000000).map(black_box).filter(|x| x % 3 == 0).count()
})
}

#[bench]
fn bench_filter_chain_ref_count(b: &mut Bencher) {
b.iter(|| {
(0i64..1000000).chain(0..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count()
})
}
37 changes: 7 additions & 30 deletions src/libcore/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,7 @@ impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool

#[inline]
fn next(&mut self) -> Option<I::Item> {
for x in &mut self.iter {
if (self.predicate)(&x) {
return Some(x);
}
}
None
self.try_for_each(Err).err()
}

#[inline]
Expand All @@ -707,12 +702,9 @@ impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool
// Using the branchless version will also simplify the LLVM byte code, thus
// leaving more budget for LLVM optimizations.
#[inline]
fn count(mut self) -> usize {
let mut count = 0;
for x in &mut self.iter {
count += (self.predicate)(&x) as usize;
}
count
fn count(self) -> usize {
let mut predicate = self.predicate;
self.iter.map(|x| predicate(&x) as usize).sum()
}

#[inline]
Expand Down Expand Up @@ -746,12 +738,7 @@ impl<I: DoubleEndedIterator, P> DoubleEndedIterator for Filter<I, P>
{
#[inline]
fn next_back(&mut self) -> Option<I::Item> {
for x in self.iter.by_ref().rev() {
if (self.predicate)(&x) {
return Some(x);
}
}
None
self.try_rfold((), |_, x| Err(x)).err()
}

#[inline]
Expand Down Expand Up @@ -820,12 +807,7 @@ impl<B, I: Iterator, F> Iterator for FilterMap<I, F>

#[inline]
fn next(&mut self) -> Option<B> {
for x in self.iter.by_ref() {
if let Some(y) = (self.f)(x) {
return Some(y);
}
}
None
self.try_for_each(Err).err()
}

#[inline]
Expand Down Expand Up @@ -863,12 +845,7 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for FilterMap<I, F>
{
#[inline]
fn next_back(&mut self) -> Option<B> {
for x in self.iter.by_ref().rev() {
if let Some(y) = (self.f)(x) {
return Some(y);
}
}
None
self.try_rfold((), |_, x| Err(x)).err()
}

#[inline]
Expand Down
8 changes: 8 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,10 +900,16 @@ pub fn discriminant<T>(v: &T) -> Discriminant<T> {
}
}

// FIXME: Reference `MaybeUninit` from these docs, once that is stable.
/// A wrapper to inhibit compiler from automatically calling `T`’s destructor.
///
/// This wrapper is 0-cost.
///
/// `ManuallyDrop<T>` is subject to the same layout optimizations as `T`.
/// As a consequence, it has *no effect* on the assumptions that the compiler makes
/// about all values being initialized at their type. In particular, initializing
/// a `ManuallyDrop<&mut T>` with [`mem::zeroed`] is undefined behavior.
///
/// # Examples
///
/// This wrapper helps with explicitly documenting the drop order dependencies between fields of
Expand Down Expand Up @@ -935,6 +941,8 @@ pub fn discriminant<T>(v: &T) -> Discriminant<T> {
/// }
/// }
/// ```
///
/// [`mem::zeroed`]: fn.zeroed.html
#[stable(feature = "manually_drop", since = "1.20.0")]
#[lang = "manually_drop"]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
//! had a method `fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T>`.
//! Then we could do the following:
//! ```compile_fail
//! fn exploit_ref_cell<T>(rc: Pin<&mut RefCell<T>) {
//! fn exploit_ref_cell<T>(rc: Pin<&mut RefCell<T>>) {
//! { let p = rc.as_mut().get_pin_mut(); } // Here we get pinned access to the `T`.
//! let rc_shr: &RefCell<T> = rc.into_ref().get_ref();
//! let b = rc_shr.borrow_mut();
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3965,7 +3965,7 @@ impl str {
me.make_ascii_lowercase()
}

/// Return an iterator that escapes each char in `s` with [`char::escape_debug`].
/// Return an iterator that escapes each char in `self` with [`char::escape_debug`].
///
/// Note: only extended grapheme codepoints that begin the string will be
/// escaped.
Expand Down Expand Up @@ -4013,7 +4013,7 @@ impl str {
}
}

/// Return an iterator that escapes each char in `s` with [`char::escape_default`].
/// Return an iterator that escapes each char in `self` with [`char::escape_default`].
///
/// [`char::escape_default`]: ../std/primitive.char.html#method.escape_default
///
Expand Down Expand Up @@ -4051,7 +4051,7 @@ impl str {
EscapeDefault { inner: self.chars().flat_map(CharEscapeDefault) }
}

/// Return an iterator that escapes each char in `s` with [`char::escape_unicode`].
/// Return an iterator that escapes each char in `self` with [`char::escape_unicode`].
///
/// [`char::escape_unicode`]: ../std/primitive.char.html#method.escape_unicode
///
Expand Down
20 changes: 14 additions & 6 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,22 @@ macro_rules! declare_lint {

#[macro_export]
macro_rules! declare_tool_lint {
($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr) => (
declare_tool_lint!{$vis $tool::$NAME, $Level, $desc, false}
(
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr
) => (
declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false}
);
($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr,
report_in_external_macro: $rep: expr) => (
declare_tool_lint!{$vis $tool::$NAME, $Level, $desc, $rep}
(
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
report_in_external_macro: $rep:expr
) => (
declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep}
);
($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr, $external: expr) => (
(
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
$external:expr
) => (
$(#[$attr])*
$vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint {
name: &concat!(stringify!($tool), "::", stringify!($NAME)),
default_level: $crate::lint::$Level,
Expand Down
22 changes: 12 additions & 10 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,25 +1176,27 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {

/// This is invoked by the `layout_raw` query to record the final
/// layout of each type.
#[inline]
#[inline(always)]
fn record_layout_for_printing(&self, layout: TyLayout<'tcx>) {
// If we are running with `-Zprint-type-sizes`, record layouts for
// dumping later. Ignore layouts that are done with non-empty
// environments or non-monomorphic layouts, as the user only wants
// to see the stuff resulting from the final codegen session.
// If we are running with `-Zprint-type-sizes`, maybe record layouts
// for dumping later.
if self.tcx.sess.opts.debugging_opts.print_type_sizes {
self.record_layout_for_printing_outlined(layout)
}
}

fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
// Ignore layouts that are done with non-empty environments or
// non-monomorphic layouts, as the user only wants to see the stuff
// resulting from the final codegen session.
if
!self.tcx.sess.opts.debugging_opts.print_type_sizes ||
layout.ty.has_param_types() ||
layout.ty.has_self_ty() ||
!self.param_env.caller_bounds.is_empty()
{
return;
}

self.record_layout_for_printing_outlined(layout)
}

fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
// (delay format until we actually need it)
let record = |kind, packed, opt_discr_size, variants| {
let type_desc = format!("{:?}", layout.ty);
Expand Down
3 changes: 0 additions & 3 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2814,9 +2814,6 @@ impl<'a> State<'a> {
-> io::Result<()> {
self.popen()?;
self.commasep(Inconsistent, &decl.inputs, |s, arg| s.print_arg(arg, false))?;
if decl.c_variadic {
self.s.word(", ...")?;
}
self.pclose()?;

self.print_fn_output(decl)
Expand Down
15 changes: 15 additions & 0 deletions src/test/pretty/fn-variadic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Check that `fn foo(x: i32, ...)` does not print as `fn foo(x: i32, ..., ...)`.
// See issue #58853.

// pp-exact
#![feature(c_variadic)]

extern "C" {
pub fn foo(x: i32, ...);
}

pub unsafe extern "C" fn bar(_: i32, mut ap: ...) -> usize {
ap.arg::<usize>()
}

fn main() { }
6 changes: 5 additions & 1 deletion src/test/ui-fulldeps/auxiliary/lint_tool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
use rustc_plugin::Registry;
use syntax::ast;
declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
declare_tool_lint!(pub clippy::TEST_GROUP, Warn, "Warn about other stuff");
declare_tool_lint!(
/// Some docs
pub clippy::TEST_GROUP,
Warn, "Warn about other stuff"
);

struct Pass;

Expand Down
4 changes: 3 additions & 1 deletion src/tools/remote-test-client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![deny(rust_2018_idioms)]

/// This is a small client program intended to pair with `remote-test-server` in
/// this repository. This client connects to the server over TCP and is used to
/// push artifacts and run tests on the server instead of locally.
Expand All @@ -15,7 +17,7 @@ use std::process::{Command, Stdio};
use std::thread;
use std::time::Duration;

const REMOTE_ADDR_ENV: &'static str = "TEST_DEVICE_ADDR";
const REMOTE_ADDR_ENV: &str = "TEST_DEVICE_ADDR";

macro_rules! t {
($e:expr) => (match $e {
Expand Down
4 changes: 3 additions & 1 deletion src/tools/remote-test-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![deny(rust_2018_idioms)]

/// This is a small server which is intended to run inside of an emulator or
/// on a remote test device. This server pairs with the `remote-test-client`
/// program in this repository. The `remote-test-client` connects to this
Expand Down Expand Up @@ -120,7 +122,7 @@ struct RemoveOnDrop<'a> {
inner: &'a Path,
}

impl<'a> Drop for RemoveOnDrop<'a> {
impl Drop for RemoveOnDrop<'_> {
fn drop(&mut self) {
t!(fs::remove_dir_all(self.inner));
}
Expand Down
Loading