<del> #!/usr/bin/env bash # Copyright 2016 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 <LICENSE-APACHE or # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your # option. This file may not be copied, modified, or distributed # except according to those terms. set -ex ARCH=$1 BINUTILS=2.25.1 GCC=6.4.0 hide_output() { set +x on_err=" echo ERROR: An error was encountered with the build. cat /tmp/build.log exit 1 " trap "$on_err" ERR bash -c "while true; do sleep 30; echo $(date) - building ...; done" & PING_LOOP_PID=$! $@ &> /tmp/build.log trap - ERR kill $PING_LOOP_PID set -x } mkdir binutils cd binutils # First up, build binutils curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 | tar xjf - mkdir binutils-build cd binutils-build hide_output ../binutils-$BINUTILS/configure  --target=$ARCH-unknown-freebsd10 hide_output make -j10 hide_output make install cd ../.. rm -rf binutils # Next, download the FreeBSD libc and relevant header files mkdir freebsd case "$ARCH" in x86_64) URL=ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/10.2-RELEASE/base.txz ;; i686) URL=ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/10.2-RELEASE/base.txz ;; esac curl $URL | tar xJf - -C freebsd ./usr/include ./usr/lib ./lib dst=/usr/local/$ARCH-unknown-freebsd10 cp -r freebsd/usr/include $dst/ cp freebsd/usr/lib/crt1.o $dst/lib cp freebsd/usr/lib/Scrt1.o $dst/lib cp freebsd/usr/lib/crti.o $dst/lib cp freebsd/usr/lib/crtn.o $dst/lib cp freebsd/usr/lib/libc.a $dst/lib cp freebsd/usr/lib/libutil.a $dst/lib cp freebsd/usr/lib/libutil_p.a $dst/lib cp freebsd/usr/lib/libm.a $dst/lib cp freebsd/usr/lib/librt.so.1 $dst/lib cp freebsd/usr/lib/libexecinfo.so.1 $dst/lib cp freebsd/lib/libc.so.7 $dst/lib cp freebsd/lib/libm.so.5 $dst/lib cp freebsd/lib/libutil.so.9 $dst/lib cp freebsd/lib/libthr.so.3 $dst/lib/libpthread.so ln -s libc.so.7 $dst/lib/libc.so ln -s libm.so.5 $dst/lib/libm.so ln -s librt.so.1 $dst/lib/librt.so ln -s libutil.so.9 $dst/lib/libutil.so ln -s libexecinfo.so.1 $dst/lib/libexecinfo.so rm -rf freebsd # Finally, download and build gcc to target FreeBSD mkdir gcc cd gcc curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.gz | tar xzf - cd gcc-$GCC ./contrib/download_prerequisites mkdir ../gcc-build cd ../gcc-build hide_output ../gcc-$GCC/configure                 --enable-languages=c,c++                        --target=$ARCH-unknown-freebsd10                --disable-multilib                              --disable-nls                                   --disable-libgomp                               --disable-libquadmath                           --disable-libssp                                --disable-libvtv                                --disable-libcilkrts                            --disable-libada                                --disable-libsanitizer                          --disable-libquadmath-support                   --disable-lto hide_output make -j10 hide_output make install cd ../.. rm -rf gcc </del>


<ins> #!/bin/bash # Copyright 2016-2017 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 <LICENSE-APACHE or # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your # option. This file may not be copied, modified, or distributed # except according to those terms. set -eux arch=$1 binutils_version=2.25.1 freebsd_version=10.3 triple=$arch-unknown-freebsd10 sysroot=/usr/local/$triple hide_output() { set +x local on_err=" echo ERROR: An error was encountered with the build. cat /tmp/build.log exit 1 " trap "$on_err" ERR bash -c "while true; do sleep 30; echo $(date) - building ...; done" & local ping_loop_pid=$! $@ &> /tmp/build.log trap - ERR kill $ping_loop_pid set -x } # First up, build binutils mkdir binutils cd binutils curl https://ftp.gnu.org/gnu/binutils/binutils-${binutils_version}.tar.bz2 | tar xjf - mkdir binutils-build cd binutils-build hide_output ../binutils-${binutils_version}/configure  --target="$triple" --with-sysroot="$sysroot" hide_output make -j"$(getconf _NPROCESSORS_ONLN)" hide_output make install cd ../.. rm -rf binutils # Next, download the FreeBSD libraries and header files mkdir -p "$sysroot" case $arch in (x86_64) freebsd_arch=amd64 ;; (i686) freebsd_arch=i386 ;; esac files_to_extract=( "./usr/include" "./usr/lib/*crt*.o" ) # Try to unpack only the libraries the build needs, to save space. for lib in c cxxrt gcc_s m thr util; do files_to_extract=("${files_to_extract[@]}" "./lib/lib${lib}.*" "./usr/lib/lib${lib}.*") done for lib in c++ c_nonshared compiler_rt execinfo gcc pthread rt ssp_nonshared; do files_to_extract=("${files_to_extract[@]}" "./usr/lib/lib${lib}.*") done URL=https://download.freebsd.org/ftp/releases/${freebsd_arch}/${freebsd_version}-RELEASE/base.txz curl "$URL" | tar xJf - -C "$sysroot" --wildcards "${files_to_extract[@]}" # Fix up absolute symlinks from the system image.  This can be removed # for FreeBSD 11.  (If there's an easy way to make them relative # symlinks instead, feel free to change this.) set +x find "$sysroot" -type l | while read symlink_path; do symlink_target=$(readlink "$symlink_path") case $symlink_target in (/*) echo "Fixing symlink ${symlink_path} -> ${sysroot}${symlink_target}" >&2 ln -nfs "${sysroot}${symlink_target}" "${symlink_path}" ;; esac done set -x # Clang can do cross-builds out of the box, if we give it the right # flags.  (The local binutils seem to work, but they set the ELF # header "OS/ABI" (EI_OSABI) field to SysV rather than FreeBSD, so # there might be other problems.) # # The --target option is last because the cross-build of LLVM uses # --target without an OS version ("-freebsd" vs. "-freebsd10").  This # makes Clang default to libstdc++ (which no longer exists), and also # controls other features, like GNU-style symbol table hashing and # anything predicated on the version number in the __FreeBSD__ # preprocessor macro. for tool in clang clang++; do tool_path=/usr/local/bin/${triple}-${tool} cat > "$tool_path" <<EOF #!/bin/sh exec $tool --sysroot=$sysroot --prefix=${sysroot}/bin "$@" --target=$triple EOF chmod +x "$tool_path" done </ins>


let stdcppname = if target.contains("openbsd") { // llvm-config on OpenBSD doesn't mention stdlib=libc++ "c++" <ins> } else if target.contains("freebsd") { "c++" </ins> } else if target.contains("netbsd") && llvm_static_stdcpp.is_some() { // NetBSD uses a separate library when relocation is required "stdc++_pic"


<ins> // Copyright 2017 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(unused)] #![feature(nll)] #[derive(Clone, Copy, Default)] struct S { a: u8, b: u8, } #[derive(Clone, Copy, Default)] struct Z { c: u8, d: u8, } union U { s: S, z: Z, } fn main() { unsafe { let mut u = U { s: Default::default() }; let mref = &mut u.s.a; *mref = 22; let nref = &u.z.c; //~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502] println!("{} {}", mref, nref) //~^ ERROR cannot borrow `u.s.a` as mutable because it is also borrowed as immutable [E0502] } } </ins>


<ins> error[E0502]: cannot borrow `u.z.c` as immutable because it is also borrowed as mutable --> $DIR/issue-45157.rs:37:20 | 34 |         let mref = &mut u.s.a; |                    ---------- mutable borrow occurs here ... 37 |         let nref = &u.z.c; |                    ^^^^^^ immutable borrow occurs here error[E0502]: cannot borrow `u.s.a` as mutable because it is also borrowed as immutable --> $DIR/issue-45157.rs:39:27 | 37 |         let nref = &u.z.c; |                    ------ immutable borrow occurs here 38 |         //~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502] 39 |         println!("{} {}", mref, nref) |                           ^^^^ mutable borrow occurs here error: aborting due to 2 previous errors </ins>


[[package]] name = "bitflags" <del> version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitflags" </del> version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]] name = "pulldown-cmark" <del> version = "0.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pulldown-cmark" </del> version = "0.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [


"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "html-diff 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", <del> "pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", </del> <ins> "pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", </ins> ] [[package]]


"checksum backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99f2ce94e22b8e664d95c57fff45b98a966c2252b60691d0b7aeeccd88d70983" "checksum backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "c63ea141ef8fdb10409d0f5daf30ac51f84ef43bff66f16627773d2a292cd189" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" <del> "checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" </del> "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989" "checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32"


"checksum precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf1fc3616b3ef726a847f2cd2388c646ef6a1f1ba4835c2629004da48184150" "checksum procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c93cdc1fb30af9ddf3debc4afbdb0f35126cbd99daa229dd76cdd5349b41d989" "checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" <del> "checksum pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ab1e588ef8efd702c7ed9d2bd774db5e6f4d878bb5a1a9f371828fbdff6973" </del> "checksum pulldown-cmark 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "378e941dbd392c101f2cb88097fa4d7167bc421d4b88de3ff7dbee503bc3233b" "checksum pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a656fdb8b6848f896df5e478a0eb9083681663e37dcb77dd16981ff65329fe8b" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"


[dependencies] env_logger = { version = "0.4", default-features = false } log = "0.3" <del> pulldown-cmark = { version = "0.0.14", default-features = false } </del> <ins> pulldown-cmark = { version = "0.1.0", default-features = false } </ins> html-diff = "0.0.4" [build-dependencies]


match self.inner.next() { Some(Event::FootnoteReference(ref reference)) => { let entry = self.get_entry(&reference);  let reference = format!("{0}   let reference = format!("{0}  ", (*entry).1); return Some(Event::Html(reference.into()));


v.sort_by(|a, b| a.1.cmp(&b.1)); let mut ret = String::from("

"); for (mut content, id) in v {  write!(ret, "
", id).unwrap();   write!(ret, "
", id).unwrap();  let mut is_paragraph = false; if let Some(&Event::End(Tag::Paragraph)) = content.last() { content.pop();


} html::push_html(&mut ret, content.into_iter()); write!(ret,  " ↩",   " ↩",  id).unwrap(); if is_paragraph { ret.push_str("
");


} // See note at the top of this module to understand why these are used: <ins> // // These casts are safe as OsStr is internally a wrapper around [u8] on all // platforms. // // Note that currently this relies on the special knowledge that libstd has; // these types are single-element structs but are not marked repr(transparent) // or repr(C) which would make these casts allowable outside std. </ins> fn os_str_as_u8_slice(s: &OsStr) -> &[u8] { unsafe { &*(s as *const OsStr as *const [u8]) } }


<del> // Copyright 2012 The Rust Project Developers. See the COPYRIGHT </del> <ins> // Copyright 2013 The Rust Project Developers. See the COPYRIGHT </ins> // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //


// except according to those terms. extern mod std; <del> use std::oldmap; use std::treemap::TreeMap; use core::hashmap::linear::*; use core::io::WriterUtil; struct Results { sequential_ints: float, random_ints: float, delete_ints: float, sequential_strings: float, random_strings: float, delete_strings: float } fn timed(result: &mut float, op: &fn()) { let start = std::time::precise_time_s(); op(); let end = std::time::precise_time_s(); *result = (end - start); </del> <ins> use core::io; use std::time; use std::treemap::TreeMap; use core::hashmap::linear::{LinearMap, LinearSet}; use core::trie::TrieMap; fn timed(label: &str, f: &fn()) { let start = time::precise_time_s(); f(); let end = time::precise_time_s(); io::println(fmt!("  %s: %f", label, end - start)); </ins> } <del> fn old_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { { let map = oldmap::HashMap(); do timed(&mut results.sequential_ints) { for uint::range(0, num_keys) |i| { map.insert(i, i+1); } </del> <ins> fn ascending<M: Map<uint, uint>>(map: &mut M, n_keys: uint) { io::println(" Ascending integers:"); </ins> <del> for uint::range(0, num_keys) |i| { fail_unless!(map.get(&i) == i+1); } </del> <ins> do timed("insert") { for uint::range(0, n_keys) |i| { map.insert(i, i + 1); </ins> } } <del> { let map = oldmap::HashMap(); do timed(&mut results.random_ints) { for uint::range(0, num_keys) |i| { map.insert(rng.next() as uint, i); } </del> <ins> do timed("search") { for uint::range(0, n_keys) |i| { fail_unless!(map.find(&i).unwrap() == &(i + 1)); </ins> } } <del> { let map = oldmap::HashMap(); for uint::range(0, num_keys) |i| { map.insert(i, i);; } do timed(&mut results.delete_ints) { for uint::range(0, num_keys) |i| { fail_unless!(map.remove(&i)); } </del> <ins> do timed("remove") { for uint::range(0, n_keys) |i| { fail_unless!(map.remove(&i)); </ins> } } } <del> fn old_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { { let map = oldmap::HashMap(); do timed(&mut results.sequential_strings) { for uint::range(0, num_keys) |i| { let s = uint::to_str(i); map.insert(s, i); } </del> <ins> fn descending<M: Map<uint, uint>>(map: &mut M, n_keys: uint) { io::println(" Descending integers:"); </ins> <del> for uint::range(0, num_keys) |i| { let s = uint::to_str(i); fail_unless!(map.get(&s) == i); } </del> <ins> do timed("insert") { for uint::range(0, n_keys) |i| { map.insert(i, i + 1); </ins> } } <del> { let map = oldmap::HashMap(); do timed(&mut results.random_strings) { for uint::range(0, num_keys) |i| { let s = uint::to_str(rng.next() as uint); map.insert(s, i); } </del> <ins> do timed("search") { for uint::range(0, n_keys) |i| { fail_unless!(map.find(&i).unwrap() == &(i + 1)); </ins> } } <del> { let map = oldmap::HashMap(); for uint::range(0, num_keys) |i| { map.insert(uint::to_str(i), i); } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { fail_unless!(map.remove(&uint::to_str(i))); } </del> <ins> do timed("remove") { for uint::range(0, n_keys) |i| { fail_unless!(map.remove(&i)); </ins> } } } <del> fn linear_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { { let mut map = LinearMap::new(); do timed(&mut results.sequential_ints) { for uint::range(0, num_keys) |i| { map.insert(i, i+1); } </del> <ins> fn vector<M: Map<uint, uint>>(map: &mut M, n_keys: uint, dist: &[uint]) { </ins> <del> for uint::range(0, num_keys) |i| { fail_unless!(map.find(&i).unwrap() == &(i+1)); } </del> <ins> do timed("insert") { for uint::range(0, n_keys) |i| { map.insert(dist[i], i + 1); </ins> } } <del> { let mut map = LinearMap::new(); do timed(&mut results.random_ints) { for uint::range(0, num_keys) |i| { map.insert(rng.next() as uint, i); } </del> <ins> do timed("search") { for uint::range(0, n_keys) |i| { fail_unless!(map.find(&dist[i]).unwrap() == &(i + 1)); </ins> } } <del> { let mut map = LinearMap::new(); for uint::range(0, num_keys) |i| { map.insert(i, i);; } do timed(&mut results.delete_ints) { for uint::range(0, num_keys) |i| { fail_unless!(map.remove(&i)); } </del> <ins> do timed("remove") { for uint::range(0, n_keys) |i| { fail_unless!(map.remove(&dist[i])); </ins> } } } <del> fn linear_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { { let mut map = LinearMap::new(); do timed(&mut results.sequential_strings) { for uint::range(0, num_keys) |i| { let s = uint::to_str(i); map.insert(s, i); } for uint::range(0, num_keys) |i| { let s = uint::to_str(i); fail_unless!(map.find(&s).unwrap() == &i); } </del> <ins> fn main() { let args = os::args(); let n_keys = { if args.len() == 2 { uint::from_str(args[1]).get() } else { 1000000 </ins> } <del> } </del> <ins> }; </ins> <del> { let mut map = LinearMap::new(); do timed(&mut results.random_strings) { for uint::range(0, num_keys) |i| { let s = uint::to_str(rng.next() as uint); map.insert(s, i); } } } </del> <ins> let mut rand = vec::with_capacity(n_keys); </ins> { <del> let mut map = LinearMap::new(); for uint::range(0, num_keys) |i| { map.insert(uint::to_str(i), i); } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { fail_unless!(map.remove(&uint::to_str(i))); </del> <ins> let rng = core::rand::seeded_rng([1, 1, 1, 1, 1, 1, 1]); let mut set = LinearSet::new(); while set.len() != n_keys { let next = rng.next() as uint; if set.insert(next) { rand.push(next); </ins> } } } <del> } fn tree_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { { let mut map = TreeMap::new(); do timed(&mut results.sequential_ints) { for uint::range(0, num_keys) |i| { map.insert(i, i+1); } </del> <ins> io::println(fmt!("%? keys", n_keys)); </ins> <del> for uint::range(0, num_keys) |i| { fail_unless!(map.find(&i).unwrap() == &(i+1)); } } } </del> <ins> io::println("nTreeMap:"); </ins> { <del> let mut map = TreeMap::new(); do timed(&mut results.random_ints) { for uint::range(0, num_keys) |i| { map.insert(rng.next() as uint, i); } } </del> <ins> let mut map = TreeMap::new::<uint, uint>(); ascending(&mut map, n_keys); </ins> } { <del> let mut map = TreeMap::new(); for uint::range(0, num_keys) |i| { map.insert(i, i);; } do timed(&mut results.delete_ints) { for uint::range(0, num_keys) |i| { fail_unless!(map.remove(&i)); } } </del> <ins> let mut map = TreeMap::new::<uint, uint>(); descending(&mut map, n_keys); </ins> } <del> } fn tree_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { </del> { <del> let mut map = TreeMap::new(); do timed(&mut results.sequential_strings) { for uint::range(0, num_keys) |i| { let s = uint::to_str(i); map.insert(s, i); } for uint::range(0, num_keys) |i| { let s = uint::to_str(i); fail_unless!(map.find(&s).unwrap() == &i); } } </del> <ins> io::println(" Random integers:"); let mut map = TreeMap::new::<uint, uint>(); vector(&mut map, n_keys, rand); </ins> } <ins> io::println("nLinearMap:"); </ins> { <del> let mut map = TreeMap::new(); do timed(&mut results.random_strings) { for uint::range(0, num_keys) |i| { let s = uint::to_str(rng.next() as uint); map.insert(s, i); } } </del> <ins> let mut map = LinearMap::new::<uint, uint>(); ascending(&mut map, n_keys); </ins> } { <del> let mut map = TreeMap::new(); for uint::range(0, num_keys) |i| { map.insert(uint::to_str(i), i); } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { fail_unless!(map.remove(&uint::to_str(i))); } } </del> <ins> let mut map = LinearMap::new::<uint, uint>(); descending(&mut map, n_keys); </ins> } <del> } fn write_header(header: &str) { io::stdout().write_str(header); io::stdout().write_str("n"); } fn write_row(label: &str, value: float) { io::stdout().write_str(fmt!("%30s %f sn", label, value)); } fn write_results(label: &str, results: &Results) { write_header(label); write_row("sequential_ints", results.sequential_ints); write_row("random_ints", results.random_ints); write_row("delete_ints", results.delete_ints); write_row("sequential_strings", results.sequential_strings); write_row("random_strings", results.random_strings); write_row("delete_strings", results.delete_strings); } fn empty_results() -> Results { Results { sequential_ints: 0f, random_ints: 0f, delete_ints: 0f, sequential_strings: 0f, random_strings: 0f, delete_strings: 0f, </del> <ins> { io::println(" Random integers:"); let mut map = LinearMap::new::<uint, uint>(); vector(&mut map, n_keys, rand); </ins> } <del> } fn main() { let args = os::args(); let num_keys = { if args.len() == 2 { uint::from_str(args[1]).get() } else { 100 // woefully inadequate for any real measurement } }; let seed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; </del> <ins> io::println("nTrieMap:"); </ins> { <del> let rng = rand::seeded_rng(seed); let mut results = empty_results(); old_int_benchmarks(rng, num_keys, &mut results); old_str_benchmarks(rng, num_keys, &mut results); write_results("std::oldmap::HashMap", &results); </del> <ins> let mut map = TrieMap::new::<uint>(); ascending(&mut map, n_keys); </ins> } { <del> let rng = rand::seeded_rng(seed); let mut results = empty_results(); linear_int_benchmarks(rng, num_keys, &mut results); linear_str_benchmarks(rng, num_keys, &mut results); write_results("core::hashmap::linear::LinearMap", &results); </del> <ins> let mut map = TrieMap::new::<uint>(); descending(&mut map, n_keys); </ins> } { <del> let rng = rand::seeded_rng(seed); let mut results = empty_results(); tree_int_benchmarks(rng, num_keys, &mut results); tree_str_benchmarks(rng, num_keys, &mut results); write_results("std::treemap::TreeMap", &results); </del> <ins> io::println(" Random integers:"); let mut map = TrieMap::new::<uint>(); vector(&mut map, n_keys, rand); </ins> } }


/// Simple usage: /// /// ``` <del> /// #![feature(box_leak)] /// </del> /// fn main() { ///     let x = Box::new(41); ///     let static_ref: &'static mut usize = Box::leak(x);


/// Unsized data: /// /// ``` <del> /// #![feature(box_leak)] /// </del> /// fn main() { ///     let x = vec![1, 2, 3].into_boxed_slice(); ///     let static_ref = Box::leak(x);


///     assert_eq!(*static_ref, [4, 2, 3]); /// } /// ``` <del> #[unstable(feature = "box_leak", reason = "needs an FCP to stabilize", issue = "46179")] </del> <ins> #[stable(feature = "box_leak", since = "1.26.0")] </ins> #[inline] pub fn leak<'a>(b: Box<T>) -> &'a mut T where


return; } <ins> let (_, line_hi, col_hi) = match ctx.byte_pos_to_line_and_col(span.hi) { Some(pos) => pos, None => { Hash::hash(&TAG_INVALID_SPAN, hasher); span.ctxt.hash_stable(ctx, hasher); return; } }; </ins> Hash::hash(&TAG_VALID_SPAN, hasher); // We truncate the stable ID hash and line and column numbers. The chances // of causing a collision this way should be minimal. Hash::hash(&(file_lo.name_hash as u64), hasher); <del> let col = (col_lo.0 as u64) & 0xFF; let line = ((line_lo as u64) & 0xFF_FF_FF) << 8; let len = ((span.hi - span.lo).0 as u64) << 32; let line_col_len = col | line | len; Hash::hash(&line_col_len, hasher); </del> <ins> // Hash both the length and the end location (line/column) of a span. If we // hash only the length, for example, then two otherwise equal spans with // different end locations will have the same hash. This can cause a problem // during incremental compilation wherein a previous result for a query that // depends on the end location of a span will be incorrectly reused when the // end location of the span it depends on has changed (see issue #74890). A // similar analysis applies if some query depends specifically on the length // of the span, but we only hash the end location. So hash both. let col_lo_trunc = (col_lo.0 as u64) & 0xFF; let line_lo_trunc = ((line_lo as u64) & 0xFF_FF_FF) << 8; let col_hi_trunc = (col_hi.0 as u64) & 0xFF << 32; let line_hi_trunc = ((line_hi as u64) & 0xFF_FF_FF) << 40; let col_line = col_lo_trunc | line_lo_trunc | col_hi_trunc | line_hi_trunc; let len = (span.hi - span.lo).0; Hash::hash(&col_line, hasher); Hash::hash(&len, hasher); </ins> span.ctxt.hash_stable(ctx, hasher); } }


<ins> include ../../run-make-fulldeps/tools.mk # FIXME https://github.com/rust-lang/rust/issues/78911 # ignore-32bit wrong/no cross compiler and sometimes we pass wrong gcc args (-m64) # Tests that we don't ICE during incremental compilation after modifying a # function span such that its previous end line exceeds the number of lines # in the new file, but its start line/column and length remain the same. SRC=$(TMPDIR)/src INCR=$(TMPDIR)/incr all: mkdir $(SRC) mkdir $(INCR) cp a.rs $(SRC)/main.rs $(RUSTC) -C incremental=$(INCR) $(SRC)/main.rs cp b.rs $(SRC)/main.rs $(RUSTC) -C incremental=$(INCR) $(SRC)/main.rs </ins>


<ins> fn main() { // foo must be used. foo(); } // For this test to operate correctly, foo's body must start on exactly the same // line and column and have the exact same length in bytes in a.rs and b.rs. In // a.rs, the body must end on a line number which does not exist in b.rs. // Basically, avoid modifying this file, including adding or removing whitespace! fn foo() { assert_eq!(1, 1); } </ins>


<ins> fn main() { // foo must be used. foo(); } // For this test to operate correctly, foo's body must start on exactly the same // line and column and have the exact same length in bytes in a.rs and b.rs. In // a.rs, the body must end on a line number which does not exist in b.rs. // Basically, avoid modifying this file, including adding or removing whitespace! fn foo() { assert_eq!(1, 1);//// } </ins>


include ../../run-make-fulldeps/tools.mk <ins> # FIXME https://github.com/rust-lang/rust/issues/78911 </ins> # ignore-32bit wrong/no cross compiler and sometimes we pass wrong gcc args (-m64) all: foo


let (span, e) = self.interpolated_or_expr_span(e)?; (lo.to(span), ExprKind::Box(e)) } <del> _ => return self.parse_dot_or_call_expr(Some(attrs)) </del> <ins> token::Ident(..) if self.token.is_ident_named("not") => { // `not` is just an ordinary identifier in Rust-the-language, // but as `rustc`-the-compiler, we can issue clever diagnostics // for confused users who really want to say `!` let token_cannot_continue_expr = |t: &token::Token| match *t { // These tokens can start an expression after `!`, but // can't continue an expression after an ident token::Ident(ident, is_raw) => token::ident_can_begin_expr(ident, is_raw), token::Literal(..) | token::Pound => true, token::Interpolated(ref nt) => match nt.0 { token::NtIdent(..) | token::NtExpr(..) | token::NtBlock(..) | token::NtPath(..) => true, _ => false, }, _ => false }; let cannot_continue_expr = self.look_ahead(1, token_cannot_continue_expr); if cannot_continue_expr { self.bump(); // Emit the error ... let mut err = self.diagnostic() .struct_span_err(self.span, &format!("unexpected {} after identifier", self.this_token_descr())); // span the `not` plus trailing whitespace to avoid // trailing whitespace after the `!` in our suggestion let to_replace = self.sess.codemap() .span_until_non_whitespace(lo.to(self.span)); err.span_suggestion_short(to_replace, "use `!` to perform logical negation", "!".to_owned()); err.emit(); // —and recover! (just as if we were in the block // for the `token::Not` arm) let e = self.parse_prefix_expr(None); let (span, e) = self.interpolated_or_expr_span(e)?; (lo.to(span), self.mk_unary(UnOp::Not, e)) } else { return self.parse_dot_or_call_expr(Some(attrs)); } } _ => { return self.parse_dot_or_call_expr(Some(attrs)); } </ins> }; return Ok(self.mk_expr(lo.to(hi), ex, attrs)); }


// Which is valid in other languages, but not Rust. match self.parse_stmt_without_recovery(false) { Ok(Some(stmt)) => { <ins> if self.look_ahead(1, |t| t == &token::OpenDelim(token::Brace)) { // if the next token is an open brace (e.g., `if a b {`), the place- // inside-a-block suggestion would be more likely wrong than right return Err(e); } </ins> let mut stmt_span = stmt.span; // expand the span to include the semicolon, if it exists if self.eat(&token::Semi) {


} } <del> fn ident_can_begin_expr(ident: ast::Ident, is_raw: bool) -> bool { </del> <ins> pub(crate) fn ident_can_begin_expr(ident: ast::Ident, is_raw: bool) -> bool { </ins> let ident_token: Token = Ident(ident, is_raw); !ident_token.is_reserved_ident() ||


self.lifetime().is_some() } <ins> /// Returns `true` if the token is a identifier whose name is the given /// string slice. pub fn is_ident_named(&self, name: &str) -> bool { match self.ident() { Some((ident, _)) => ident.name.as_str() == name, None => false } } </ins> /// Returns `true` if the token is a documentation comment. pub fn is_doc_comment(&self) -> bool { match *self {


<ins> // 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn gratitude() { let for_you = false; if not for_you { //~^ ERROR unexpected `for_you` after identifier println!("I couldn't"); } } fn qualification() { let the_worst = true; while not the_worst { //~^ ERROR unexpected `the_worst` after identifier println!("still pretty bad"); } } fn should_we() { let not = true; if not  // lack of braces is [sic] println!("Then when?"); //~^ ERROR expected `{`, found `; //~| ERROR unexpected `println` after identifier } fn sleepy() { let resource = not 2; //~^ ERROR unexpected `2` after identifier } fn main() { let be_smothered_out_before = true; let young_souls = not be_smothered_out_before; //~^ ERROR unexpected `be_smothered_out_before` after identifier } </ins>


<ins> error: unexpected `for_you` after identifier --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:13:12 | LL |     if not for_you { |        ----^^^^^^^ |        | |        help: use `!` to perform logical negation error: unexpected `the_worst` after identifier --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:21:15 | LL |     while not the_worst { |           ----^^^^^^^^^ |           | |           help: use `!` to perform logical negation error: unexpected `println` after identifier --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:30:9 | LL |     if not  // lack of braces is [sic] |        ----- help: use `!` to perform logical negation LL |         println!("Then when?"); |         ^^^^^^^ error: expected `{`, found `;` --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:30:31 | LL |     if not  // lack of braces is [sic] |     -- this `if` statement has a condition, but no block LL |         println!("Then when?"); |                               ^ error: unexpected `2` after identifier --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:36:24 | LL |     let resource = not 2; |                    ----^ |                    | |                    help: use `!` to perform logical negation error: unexpected `be_smothered_out_before` after identifier --> $DIR/issue-46836-identifier-not-instead-of-negation.rs:42:27 | LL |     let young_souls = not be_smothered_out_before; |                       ----^^^^^^^^^^^^^^^^^^^^^^^ |                       | |                       help: use `!` to perform logical negation error: aborting due to 6 previous errors </ins>


has_elf_tls: version >= (10, 7), abi_return_struct_as_int: true, emit_debug_gdb_scripts: false, <ins> // This environment variable is pretty magical but is intended for // producing deterministic builds. This was first discovered to be used // by the `ar` tool as a way to control whether or not mtime entries in // the archive headers were set to zero or not. It appears that // eventually the linker got updated to do the same thing and now reads // this environment variable too in recent versions. // // For some more info see the commentary on #47086 link_env: vec![("ZERO_AR_DATE".to_string(), "1".to_string())], </ins> ..Default::default() } }


# ignore-musl # ignore-windows <del> # ignore-macos (rust-lang/rust#66568) </del> # Objects are reproducible but their path is not. all:


rm -rf $(TMPDIR) && mkdir $(TMPDIR) $(RUSTC) reproducible-build-aux.rs $(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(shell $(RUSTC) --print sysroot) --remap-path-prefix=$(shell $(RUSTC) --print sysroot)=/sysroot <del> cp -r $(shell $(RUSTC) --print sysroot) $(TMPDIR)/sysroot </del> <ins> cp -R $(shell $(RUSTC) --print sysroot) $(TMPDIR)/sysroot </ins> cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib $(RUSTC) reproducible-build.rs --crate-type rlib --sysroot $(TMPDIR)/sysroot --remap-path-prefix=$(TMPDIR)/sysroot=/sysroot cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1


// A tuple index may not have a suffix self.expect_no_suffix(sp, "tuple index", suf); <del> let dot_span = self.prev_span; hi = self.span; </del> <ins> let idx_span = self.span; </ins> self.bump(); let invalid_msg = "invalid tuple or struct index";


n.to_string()); err.emit(); } <del> let id = respan(dot_span.to(hi), n); let field = self.mk_tup_field(e, id); e = self.mk_expr(lo.to(hi), field, ThinVec::new()); </del> <ins> let field = self.mk_tup_field(e, respan(idx_span, n)); e = self.mk_expr(lo.to(idx_span), field, ThinVec::new()); </ins> } None => { let prev_span = self.prev_span;


<ins> // Copyright 2017 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // ignore-pretty pretty-printing is unhygienic #![feature(decl_macro)] #![allow(unused)] mod foo { pub macro m($s:tt, $i:tt) { $s.$i } } mod bar { struct S(i32); fn f() { let s = S(0); ::foo::m!(s, 0); } } fn main() {} </ins>


use rustc::mir::{BasicBlock, Location, Mir}; use rustc::mir::Local; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; <ins> use rustc::traits; use rustc::infer::InferOk; </ins> use rustc::util::common::ErrorReported; <ins> use borrow_check::nll::type_check::AtLocation; </ins> use rustc_data_structures::fx::FxHashSet; use syntax::codemap::DUMMY_SP; use util::liveness::LivenessResults;


location ); <del> let tcx = self.cx.infcx.tcx; let mut types = vec![(dropped_ty, 0)]; let mut known = FxHashSet(); while let Some((ty, depth)) = types.pop() { let span = DUMMY_SP; // FIXME let result = match tcx.dtorck_constraint_for_ty(span, dropped_ty, depth, ty) { Ok(result) => result, Err(ErrorReported) => { continue; } }; let ty::DtorckConstraint { outlives, dtorck_types, } = result; // All things in the `outlives` array may be touched by // the destructor and must be live at this point. for outlive in outlives { let cause = Cause::DropVar(dropped_local, location); self.push_type_live_constraint(outlive, location, cause); } </del> <ins> // If we end visiting the same type twice (usually due to a cycle involving // associated types), we need to ensure that its region types match up with the type // we added to the 'known' map the first time around. For this reason, we need // our infcx to hold onto its calculated region constraints after each call // to dtorck_constraint_for_ty. Otherwise, normalizing the corresponding associated // type will end up instantiating the type with a new set of inference variables // Since this new type will never be in 'known', we end up looping forever. // // For this reason, we avoid calling TypeChecker.normalize, instead doing all normalization // ourselves in one large 'fully_perform_op' callback. let (type_constraints, kind_constraints) = self.cx.fully_perform_op(location.at_self(), |cx| { let tcx = cx.infcx.tcx; let mut selcx = traits::SelectionContext::new(cx.infcx); let cause = cx.misc(cx.last_span); let mut types = vec![(dropped_ty, 0)]; let mut final_obligations = Vec::new(); let mut type_constraints = Vec::new(); let mut kind_constraints = Vec::new(); </ins> <del> // However, there may also be some types that // `dtorck_constraint_for_ty` could not resolve (e.g., // associated types and parameters). We need to normalize // associated types here and possibly recursively process. for ty in dtorck_types { let ty = self.cx.normalize(&ty, location); let ty = self.cx.infcx.resolve_type_and_region_vars_if_possible(&ty); match ty.sty { ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => { let cause = Cause::DropVar(dropped_local, location); self.push_type_live_constraint(ty, location, cause); </del> <ins> let mut known = FxHashSet(); while let Some((ty, depth)) = types.pop() { let span = DUMMY_SP; // FIXME let result = match tcx.dtorck_constraint_for_ty(span, dropped_ty, depth, ty) { Ok(result) => result, Err(ErrorReported) => { continue; </ins> } <ins> }; let ty::DtorckConstraint { outlives, dtorck_types, } = result; // All things in the `outlives` array may be touched by // the destructor and must be live at this point. for outlive in outlives { let cause = Cause::DropVar(dropped_local, location); kind_constraints.push((outlive, location, cause)); } </ins> <del> _ => if known.insert(ty) { types.push((ty, depth + 1)); }, </del> <ins> // However, there may also be some types that // `dtorck_constraint_for_ty` could not resolve (e.g., // associated types and parameters). We need to normalize // associated types here and possibly recursively process. for ty in dtorck_types { let traits::Normalized { value: ty, obligations } = traits::normalize(&mut selcx, cx.param_env, cause.clone(), &ty); final_obligations.extend(obligations); let ty = cx.infcx.resolve_type_and_region_vars_if_possible(&ty); match ty.sty { ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => { let cause = Cause::DropVar(dropped_local, location); type_constraints.push((ty, location, cause)); } _ => if known.insert(ty) { types.push((ty, depth + 1)); }, } </ins> } } <ins> Ok(InferOk { value: (type_constraints, kind_constraints), obligations: final_obligations }) }).unwrap(); for (ty, location, cause) in type_constraints { self.push_type_live_constraint(ty, location, cause); } for (kind, location, cause) in kind_constraints { self.push_type_live_constraint(kind, location, cause); </ins> } } }


<ins> // 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(nll)] pub struct DescriptorSet<'a> { pub slots: Vec<AttachInfo<'a, Resources>> } pub trait ResourcesTrait<'r>: Sized { type DescriptorSet: 'r; } pub struct Resources; impl<'a> ResourcesTrait<'a> for Resources { type DescriptorSet = DescriptorSet<'a>; } pub enum AttachInfo<'a, R: ResourcesTrait<'a>> { NextDescriptorSet(Box<R::DescriptorSet>) } fn main() { let _x = DescriptorSet {slots: Vec::new()}; } </ins>


// Put the lint store levels and passes back in the session. cx.lint_sess.restore(&sess.lint_store); <del> // Emit all buffered lints from early on in the session now that we've // calculated the lint levels for all AST nodes. for (_id, lints) in cx.buffered.map { for early_lint in lints { span_bug!(early_lint.span, "failed to process buffered lint here"); </del> <ins> // All of the buffered lints should have been emitted at this point. // If not, that means that we somehow buffered a lint for a node id // that was not lint-checked (perhaps it doesn't exist?). This is a bug. // // Rustdoc runs everybody-loops before the early lints and removes // function bodies, so it's totally possible for linted // node ids to not exist (e.g. macros defined within functions for the // unused_macro lint) anymore. So we only run this check // when we're not in rustdoc mode. (see issue #47639) if !sess.opts.actually_rustdoc { for (_id, lints) in cx.buffered.map { for early_lint in lints { span_bug!(early_lint.span, "failed to process buffered lint here"); } </ins> } } }


<ins> // 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // This should not ICE pub fn test() { macro_rules! foo { () => () } } </ins>


let task = get_task_id(); // Expect the weak task service to be alive assert service.try_send(RegisterWeakTask(task, shutdown_chan)); <del> unsafe { rust_inc_kernel_live_count(); } </del> <ins> unsafe { rust_dec_kernel_live_count(); } </ins> do fn&() { let shutdown_port = swap_unwrap(&mut *shutdown_port); f(shutdown_port) }.finally || { <del> unsafe { rust_dec_kernel_live_count(); } </del> <ins> unsafe { rust_inc_kernel_live_count(); } </ins> // Service my have already exited service.send(UnregisterWeakTask(task)); }


let port = swap_unwrap(&mut *port); // The weak task service is itself a weak task debug!("weakening the weak service task"); <del> unsafe { rust_inc_kernel_live_count(); } </del> <ins> unsafe { rust_dec_kernel_live_count(); } </ins> run_weak_task_service(port); }.finally { debug!("unweakening the weak service task"); <del> unsafe { rust_dec_kernel_live_count(); } </del> <ins> unsafe { rust_inc_kernel_live_count(); } </ins> } }


<ins> // Copyright 2012 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that multibyte characters don't crash the compiler fn main() { io::println("마이너스 사인이 없으면"); } </ins>


/// #[stable(feature = "rust1", since = "1.0.0")] pub trait BufRead: Read { <del> /// Fills the internal buffer of this object, returning the buffer contents. </del> <ins> /// Returns the contents of the internal buffer, filling it with more data /// from the inner reader if it is empty. </ins> /// /// This function is a lower-level call. It needs to be paired with the /// [`consume`] method to function properly. When calling this


(accepted, type_alias_enum_variants, "1.37.0", Some(49683)), /// Allows macros to appear in the type position. (accepted, type_macros, "1.13.0", Some(27245)), <ins> /// Allows using type privacy lints (`private_interfaces`, `private_bounds`, `unnameable_types`). (accepted, type_privacy_lints, "CURRENT_RUSTC_VERSION", Some(48054)), </ins> /// Allows `const _: TYPE = VALUE`. (accepted, underscore_const_names, "1.37.0", Some(54912)), /// Allows `use path as _;` and `extern crate c as _;`.


/// Allows creation of instances of a struct by moving fields that have /// not changed from prior instances of the same struct (RFC #2528) (unstable, type_changing_struct_update, "1.58.0", Some(86555)), <del> /// Allows using type privacy lints (`private_interfaces`, `private_bounds`, `unnameable_types`). (unstable, type_privacy_lints, "1.72.0", Some(48054)), </del> /// Enables rustc to generate code that instructs libstd to NOT ignore SIGPIPE. (unstable, unix_sigpipe, "1.65.0", Some(97889)), /// Allows unnamed fields of struct and union type


} declare_lint! { <del> /// The `unreachable_pub` lint triggers for `pub` items not reachable from /// the crate root. </del> <ins> /// The `unreachable_pub` lint triggers for `pub` items not reachable from other crates - that /// means neither directly accessible, nor reexported, nor leaked through things like return /// types. </ins> /// /// ### Example ///


/// ### Example /// /// ```rust,compile_fail <del> /// # #![feature(type_privacy_lints)] </del> /// # #![allow(unused)] /// #![deny(unnameable_types)] /// mod m {


/// /// It is often expected that if you can obtain an object of type `T`, then /// you can name the type `T` as well, this lint attempts to enforce this rule. <ins> /// The recommended action is to either reexport the type properly to make it nameable, /// or document that users are not supposed to be able to name it for one reason or another. /// /// Besides types, this lint applies to traits because traits can also leak through signatures, /// and you may obtain objects of their `dyn Trait` or `impl Trait` types. </ins> pub UNNAMEABLE_TYPES, Allow, "effective visibility of a type is larger than the area in which it can be named", <del> @feature_gate = sym::type_privacy_lints; </del> } declare_lint! {


<del> //@ check-pass #![warn(unnameable_types)] //~ WARN unknown lint fn main() {} </del>


<del> warning: unknown lint: `unnameable_types` --> $DIR/feature-gate-type_privacy_lints.rs:3:1 | LL | #![warn(unnameable_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the `unnameable_types` lint is unstable = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: `#[warn(unknown_lints)]` on by default warning: 1 warning emitted </del>


<del> #![feature(type_privacy_lints)] </del> #![deny(unnameable_types)] mod m {


error: struct `PubStruct` is reachable but cannot be named <del> --> $DIR/unnameable_types.rs:5:5 </del> <ins> --> $DIR/unnameable_types.rs:4:5 </ins> | LL |     pub struct PubStruct(pub i32); |     ^^^^^^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` | note: the lint level is defined here <del> --> $DIR/unnameable_types.rs:2:9 </del> <ins> --> $DIR/unnameable_types.rs:1:9 </ins> | LL | #![deny(unnameable_types)] |         ^^^^^^^^^^^^^^^^ error: enum `PubE` is reachable but cannot be named <del> --> $DIR/unnameable_types.rs:7:5 </del> <ins> --> $DIR/unnameable_types.rs:6:5 </ins> | LL |     pub enum PubE { |     ^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` error: trait `PubTr` is reachable but cannot be named <del> --> $DIR/unnameable_types.rs:11:5 </del> <ins> --> $DIR/unnameable_types.rs:10:5 </ins> | LL |     pub trait PubTr { |     ^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`


``` ", $Feature, "let x: ", stringify!($SelfT), " = 2; // or any other integer type <del> assert_eq!(x.pow(4), 16);", </del> <ins> assert_eq!(x.pow(5), 32);", </ins> $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")]


Basic usage: ``` <del> ", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(4), 16);", $EndFeature, " </del> <ins> ", $Feature, "assert_eq!(2", stringify!($SelfT), ".pow(5), 32);", $EndFeature, " </ins> ```"), #[stable(feature = "rust1", since = "1.0.0")] #[inline]


- checkout: self fetchDepth: 2 <ins> # Spawn a background process to collect CPU usage statistics which we'll upload # at the end of the build. See the comments in the script here for more # information. - bash: python src/ci/cpu-usage-over-time.py &> cpu-usage.csv & displayName: "Collect CPU-usage statistics in the background" </ins> - bash: printenv | sort displayName: Show environment variables


AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) condition: and(succeeded(), or(eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1'))) displayName: Upload artifacts <ins> # Upload CPU usage statistics that we've been gathering this whole time. Always # execute this step in case we want to inspect failed builds, but don't let # errors here ever fail the build since this is just informational. - bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$SYSTEM_JOBNAME.csv env: AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) condition: contains(variables, 'AWS_SECRET_ACCESS_KEY') continueOnError: true displayName: Upload CPU usage statistics </ins>


<ins> #!/usr/bin/env python # ignore-tidy-linelength # This is a small script that we use on CI to collect CPU usage statistics of # our builders. By seeing graphs of CPU usage over time we hope to correlate # that with possible improvements to Rust's own build system, ideally diagnosing # that either builders are always fully using their CPU resources or they're # idle for long stretches of time. # # This script is relatively simple, but it's platform specific. Each platform # (OSX/Windows/Linux) has a different way of calculating the current state of # CPU at a point in time. We then compare two captured states to determine the # percentage of time spent in one state versus another. The state capturing is # all platform-specific but the loop at the bottom is the cross platform part # that executes everywhere. # # # Viewing statistics # # All builders will upload their CPU statistics as CSV files to our S3 buckets. # These URLS look like: # #   https://$bucket.s3.amazonaws.com/rustc-builds/$commit/cpu-$builder.csv # # for example # #   https://rust-lang-ci2.s3.amazonaws.com/rustc-builds/68baada19cd5340f05f0db15a3e16d6671609bcc/cpu-x86_64-apple.csv # # Each CSV file has two columns. The first is the timestamp of the measurement # and the second column is the % of idle cpu time in that time slice. Ideally # the second column is always zero. # # Once you've downloaded a file there's various ways to plot it and visualize # it. For command line usage you can use a script like so: # #      set timefmt '%Y-%m-%dT%H:%M:%S' #      set xdata time #      set ylabel "Idle CPU %" #      set xlabel "Time" #      set datafile sep ',' #      set term png #      set output "printme.png" #      set grid #      builder = "i686-apple" #      plot "cpu-".builder.".csv" using 1:2 with lines title builder # # Executed as `gnuplot < ./foo.plot` it will generate a graph called # `printme.png` which you can then open up. If you know how to improve this # script or the viewing process that would be much appreciated :) (or even if # you know how to automate it!) import datetime import sys import time if sys.platform == 'linux2': class State: def __init__(self): with open('/proc/stat', 'r') as file: data = file.readline().split() if data[0] != 'cpu': raise Exception('did not start with "cpu"') self.user = int(data[1]) self.nice = int(data[2]) self.system = int(data[3]) self.idle = int(data[4]) self.iowait = int(data[5]) self.irq = int(data[6]) self.softirq = int(data[7]) self.steal = int(data[8]) self.guest = int(data[9]) self.guest_nice = int(data[10]) def idle_since(self, prev): user = self.user - prev.user nice = self.nice - prev.nice system = self.system - prev.system idle = self.idle - prev.idle iowait = self.iowait - prev.iowait irq = self.irq - prev.irq softirq = self.softirq - prev.softirq steal = self.steal - prev.steal guest = self.guest - prev.guest guest_nice = self.guest_nice - prev.guest_nice total = user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice return float(idle) / float(total) * 100 elif sys.platform == 'win32': from ctypes.wintypes import DWORD from ctypes import Structure, windll, WinError, GetLastError, byref class FILETIME(Structure): _fields_ = [ ("dwLowDateTime", DWORD), ("dwHighDateTime", DWORD), ] class State: def __init__(self): idle, kernel, user = FILETIME(), FILETIME(), FILETIME() success = windll.kernel32.GetSystemTimes( byref(idle), byref(kernel), byref(user), ) assert success, WinError(GetLastError())[1] self.idle = (idle.dwHighDateTime << 32) | idle.dwLowDateTime self.kernel = (kernel.dwHighDateTime << 32) | kernel.dwLowDateTime self.user = (user.dwHighDateTime << 32) | user.dwLowDateTime def idle_since(self, prev): idle = self.idle - prev.idle user = self.user - prev.user kernel = self.kernel - prev.kernel return float(idle) / float(user + kernel) * 100 elif sys.platform == 'darwin': from ctypes import * libc = cdll.LoadLibrary('/usr/lib/libc.dylib') PROESSOR_CPU_LOAD_INFO = c_int(2) CPU_STATE_USER = 0 CPU_STATE_SYSTEM = 1 CPU_STATE_IDLE = 2 CPU_STATE_NICE = 3 c_int_p = POINTER(c_int) class State: def __init__(self): num_cpus_u = c_uint(0) cpu_info = c_int_p() cpu_info_cnt = c_int(0) err = libc.host_processor_info( libc.mach_host_self(), PROESSOR_CPU_LOAD_INFO, byref(num_cpus_u), byref(cpu_info), byref(cpu_info_cnt), ) assert err == 0 self.user = 0 self.system = 0 self.idle = 0 self.nice = 0 cur = 0 while cur < cpu_info_cnt.value: self.user += cpu_info[cur + CPU_STATE_USER] self.system += cpu_info[cur + CPU_STATE_SYSTEM] self.idle += cpu_info[cur + CPU_STATE_IDLE] self.nice += cpu_info[cur + CPU_STATE_NICE] cur += num_cpus_u.value def idle_since(self, prev): user = self.user - prev.user system = self.system - prev.system idle = self.idle - prev.idle nice = self.nice - prev.nice return float(idle) / float(user + system + idle + nice) * 100.0 else: print('unknown platform', sys.platform) sys.exit(1) cur_state = State(); print("Time,Idle") while True: time.sleep(1); next_state = State(); now = datetime.datetime.utcnow().isoformat() idle = next_state.idle_since(cur_state) print("%s,%s" % (now, idle)) sys.stdout.flush() cur_state = next_state </ins>


// linking executables as pie. Different versions of gcc seem to use // different quotes in the error message so don't check for them. if sess.target.target.options.linker_is_gnu && <ins> sess.linker_flavor() != LinkerFlavor::Ld && </ins> (out.contains("unrecognized command line option") || out.contains("unknown argument")) && out.contains("-no-pie") &&


} else { // recent versions of gcc can be configured to generate position // independent executables by default. We have to pass -no-pie to <del> // explicitly turn that off. if sess.target.target.options.linker_is_gnu { </del> <ins> // explicitly turn that off. Not applicable to ld. if sess.target.target.options.linker_is_gnu && sess.linker_flavor() != LinkerFlavor::Ld { </ins> cmd.no_position_independent_executable(); } }


#[unstable(feature = "proc_macro", issue = "38356")] impl iter::FromIterator<TokenTree> for TokenStream { fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self { <ins> trees.into_iter().map(TokenStream::from).collect() } } #[unstable(feature = "proc_macro", issue = "38356")] impl iter::FromIterator<TokenStream> for TokenStream { fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self { </ins> let mut builder = tokenstream::TokenStreamBuilder::new(); <del> for tree in trees { builder.push(tree.to_internal()); </del> <ins> for stream in streams { builder.push(stream.0); </ins> } TokenStream(builder.build()) }


assigned_map: FxHashMap<Place<'tcx>, FxHashSet<BorrowIndex>>, /// Locations which activate borrows. <del> /// NOTE: A given location may activate more than one borrow in the future /// when more general two-phase borrow support is introduced, but for now we /// only need to store one borrow index activation_map: FxHashMap<Location, BorrowIndex>, </del> <ins> activation_map: FxHashMap<Location, FxHashSet<BorrowIndex>>, </ins> /// Every borrow has a region; this maps each such regions back to /// its borrow-indexes.


idx_vec: IndexVec<BorrowIndex, BorrowData<'tcx>>, location_map: FxHashMap<Location, BorrowIndex>, assigned_map: FxHashMap<Place<'tcx>, FxHashSet<BorrowIndex>>, <del> activation_map: FxHashMap<Location, BorrowIndex>, </del> <ins> activation_map: FxHashMap<Location, FxHashSet<BorrowIndex>>, </ins> region_map: FxHashMap<Region<'tcx>, FxHashSet<BorrowIndex>>, local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>, region_span_map: FxHashMap<RegionKind, Span>,


let idx = self.idx_vec.push(borrow); self.location_map.insert(location, idx); <del> // This assert is a good sanity check until more general 2-phase borrow // support is introduced. See NOTE on the activation_map field for more assert!(!self.activation_map.contains_key(&activate_location), "More than one activation introduced at the same location."); self.activation_map.insert(activate_location, idx); </del> <ins> insert(&mut self.activation_map, &activate_location, idx); </ins> insert(&mut self.assigned_map, assigned_place, idx); insert(&mut self.region_map, &region, idx); if let Some(local) = root_local(borrowed_place) {


location: Location) { // Handle activations match self.activation_map.get(&location) { <del> Some(&activated) => { debug!("activating borrow {:?}", activated); sets.gen(&ReserveOrActivateIndex::active(activated)) </del> <ins> Some(activations) => { for activated in activations { debug!("activating borrow {:?}", activated); sets.gen(&ReserveOrActivateIndex::active(*activated)) } </ins> } None => {} }


<ins> // 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(nll)] struct Foo { } impl Foo { fn method(&mut self, foo: &mut Foo) { } } fn main() { let mut foo = Foo { }; foo.method(&mut foo); //~^     cannot borrow `foo` as mutable more than once at a time //~^^    cannot borrow `foo` as mutable more than once at a time } </ins>


<ins> error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-multi-mut.rs:23:16 | LL |     foo.method(&mut foo); |     -----------^^^^^^^^- |     |          | |     |          second mutable borrow occurs here |     first mutable borrow occurs here |     borrow later used here error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-multi-mut.rs:23:5 | LL |     foo.method(&mut foo); |     ^^^^^^^^^^^--------^ |     |          | |     |          first mutable borrow occurs here |     second mutable borrow occurs here |     borrow later used here error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0499`. </ins>


<ins> // 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // revisions: lxl nll //[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows //[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll // run-pass use std::io::Result; struct Foo {} pub trait FakeRead { fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>; } impl FakeRead for Foo { fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> { Ok(4) } } fn main() { let mut a = Foo {}; let mut v = Vec::new(); a.read_to_end(&mut v); } </ins>


} } <ins> #[stable(feature = "os_str_str_ref_eq", since = "1.28.0")] impl<'a> PartialEq<&'a str> for OsString { fn eq(&self, other: &&'a str) -> bool { **self == **other } } #[stable(feature = "os_str_str_ref_eq", since = "1.28.0")] impl<'a> PartialEq<OsString> for &'a str { fn eq(&self, other: &OsString) -> bool { **other == **self } } </ins> #[stable(feature = "rust1", since = "1.0.0")] impl Eq for OsString {}


<ins> // 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::ffi::OsString; fn main() { let os_str = OsString::from("Hello Rust!"); assert_eq!(os_str, "Hello Rust!"); assert_eq!("Hello Rust!", os_str); } </ins>


impl Sealed for ops::RangeInclusive<usize> {} #[stable(feature = "slice_get_slice", since = "1.28.0")] impl Sealed for ops::RangeToInclusive<usize> {} <ins> #[stable(feature = "slice_index_with_ops_bound_pair", since = "1.53.0")] impl Sealed for (ops::Bound<usize>, ops::Bound<usize>) {} </ins> } /// A helper trait used for indexing operations.


ops::Range { start, end } } <ins> /// Convert pair of `ops::Bound`s into `ops::Range` without performing any bounds checking and (in debug) overflow checking fn into_range_unchecked( len: usize, (start, end): (ops::Bound<usize>, ops::Bound<usize>), ) -> ops::Range<usize> { use ops::Bound; let start = match start { Bound::Included(i) => i, Bound::Excluded(i) => i + 1, Bound::Unbounded => 0, }; let end = match end { Bound::Included(i) => i + 1, Bound::Excluded(i) => i, Bound::Unbounded => len, }; start..end } /// Convert pair of `ops::Bound`s into `ops::Range`. /// Returns `None` on overflowing indices. fn into_range( len: usize, (start, end): (ops::Bound<usize>, ops::Bound<usize>), ) -> Option<ops::Range<usize>> { use ops::Bound; let start = match start { Bound::Included(start) => start, Bound::Excluded(start) => start.checked_add(1)?, Bound::Unbounded => 0, }; let end = match end { Bound::Included(end) => end.checked_add(1)?, Bound::Excluded(end) => end, Bound::Unbounded => len, }; // Don't bother with checking `start < end` and `end <= len` // since these checks are handled by `Range` impls Some(start..end) } /// Convert pair of `ops::Bound`s into `ops::Range`. /// Panics on overflowing indices. fn into_slice_range( len: usize, (start, end): (ops::Bound<usize>, ops::Bound<usize>), ) -> ops::Range<usize> { use ops::Bound; let start = match start { Bound::Included(start) => start, Bound::Excluded(start) => { start.checked_add(1).unwrap_or_else(|| slice_start_index_overflow_fail()) } Bound::Unbounded => 0, }; let end = match end { Bound::Included(end) => { end.checked_add(1).unwrap_or_else(|| slice_end_index_overflow_fail()) } Bound::Excluded(end) => end, Bound::Unbounded => len, }; // Don't bother with checking `start < end` and `end <= len` // since these checks are handled by `Range` impls start..end } #[stable(feature = "slice_index_with_ops_bound_pair", since = "1.53.0")] unsafe impl<T> SliceIndex<[T]> for (ops::Bound<usize>, ops::Bound<usize>) { type Output = [T]; #[inline] fn get(self, slice: &[T]) -> Option<&Self::Output> { into_range(slice.len(), self)?.get(slice) } #[inline] fn get_mut(self, slice: &mut [T]) -> Option<&mut Self::Output> { into_range(slice.len(), self)?.get_mut(slice) } #[inline] unsafe fn get_unchecked(self, slice: *const [T]) -> *const Self::Output { // SAFETY: the caller has to uphold the safety contract for `get_unchecked`. unsafe { into_range_unchecked(slice.len(), self).get_unchecked(slice) } } #[inline] unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut Self::Output { // SAFETY: the caller has to uphold the safety contract for `get_unchecked_mut`. unsafe { into_range_unchecked(slice.len(), self).get_unchecked_mut(slice) } } #[inline] fn index(self, slice: &[T]) -> &Self::Output { into_slice_range(slice.len(), self).index(slice) } #[inline] fn index_mut(self, slice: &mut [T]) -> &mut Self::Output { into_slice_range(slice.len(), self).index_mut(slice) } } </ins>


} )*) => {$( mod $case_name { <ins> #[allow(unused_imports)] use core::ops::Bound; </ins> #[test] fn pass() { let mut v = $data;


bad: data[7..=6]; message: "out of range"; } <ins> in mod boundpair_len { data: [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(6), Bound::Unbounded)] == []; good: data[(Bound::Unbounded, Bound::Included(5))] == [0, 1, 2, 3, 4, 5]; good: data[(Bound::Unbounded, Bound::Excluded(6))] == [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(0), Bound::Included(5))] == [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(0), Bound::Excluded(6))] == [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(2), Bound::Excluded(4))] == [2, 3]; good: data[(Bound::Excluded(1), Bound::Included(4))] == [2, 3, 4]; good: data[(Bound::Excluded(5), Bound::Excluded(6))] == []; good: data[(Bound::Included(6), Bound::Excluded(6))] == []; good: data[(Bound::Excluded(5), Bound::Included(5))] == []; good: data[(Bound::Included(6), Bound::Included(5))] == []; bad: data[(Bound::Unbounded, Bound::Included(6))]; message: "out of range"; } </ins> } panic_cases! {


bad: data[4..=2]; message: "but ends at"; } <ins> in mod boundpair_neg_width { data: [0, 1, 2, 3, 4, 5]; good: data[(Bound::Included(4), Bound::Excluded(4))] == []; bad: data[(Bound::Included(4), Bound::Excluded(3))]; message: "but ends at"; } </ins> } panic_cases! {


bad: data[..= usize::MAX]; message: "maximum usize"; } <ins> in mod boundpair_overflow_end { data: [0; 1]; bad: data[(Bound::Unbounded, Bound::Included(usize::MAX))]; message: "maximum usize"; } in mod boundpair_overflow_start { data: [0; 1]; bad: data[(Bound::Excluded(usize::MAX), Bound::Unbounded)]; message: "maximum usize"; } </ins> } // panic_cases! }


//! which do not. use rustc_data_structures::bitvec::BitVector; <ins> use rustc_data_structures::control_flow_graph::dominators::Dominators; </ins> use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::mir::{self, Location, TerminatorKind}; use rustc::mir::visit::{Visitor, PlaceContext};


use type_of::LayoutLlvmExt; use super::FunctionCx; <del> pub fn memory_locals<'a, 'tcx>(fx: &FunctionCx<'a, 'tcx>) -> BitVector { </del> <ins> pub fn non_ssa_locals<'a, 'tcx>(fx: &FunctionCx<'a, 'tcx>) -> BitVector { </ins> let mir = fx.mir; let mut analyzer = LocalAnalyzer::new(fx);


// (e.g. structs) into an alloca unconditionally, just so // that we don't have to deal with having two pathways // (gep vs extractvalue etc). <del> analyzer.mark_as_memory(mir::Local::new(index)); </del> <ins> analyzer.not_ssa(mir::Local::new(index)); </ins> } } <del> analyzer.memory_locals </del> <ins> analyzer.non_ssa_locals </ins> } struct LocalAnalyzer<'mir, 'a: 'mir, 'tcx: 'a> { fx: &'mir FunctionCx<'a, 'tcx>, <del> memory_locals: BitVector, seen_assigned: BitVector </del> <ins> dominators: Dominators<mir::BasicBlock>, non_ssa_locals: BitVector, // The location of the first visited direct assignment to each // local, or an invalid location (out of bounds `block` index). first_assignment: IndexVec<mir::Local, Location> </ins> } impl<'mir, 'a, 'tcx> LocalAnalyzer<'mir, 'a, 'tcx> { fn new(fx: &'mir FunctionCx<'a, 'tcx>) -> LocalAnalyzer<'mir, 'a, 'tcx> { <ins> let invalid_location = mir::BasicBlock::new(fx.mir.basic_blocks().len()).start_location(); </ins> let mut analyzer = LocalAnalyzer { fx, <del> memory_locals: BitVector::new(fx.mir.local_decls.len()), seen_assigned: BitVector::new(fx.mir.local_decls.len()) </del> <ins> dominators: fx.mir.dominators(), non_ssa_locals: BitVector::new(fx.mir.local_decls.len()), first_assignment: IndexVec::from_elem(invalid_location, &fx.mir.local_decls) </ins> }; // Arguments get assigned to by means of the function being called <del> for idx in 0..fx.mir.arg_count { analyzer.seen_assigned.insert(idx + 1); </del> <ins> for arg in fx.mir.args_iter() { analyzer.first_assignment[arg] = mir::START_BLOCK.start_location(); </ins> } analyzer } <del> fn mark_as_memory(&mut self, local: mir::Local) { debug!("marking {:?} as memory", local); self.memory_locals.insert(local.index()); </del> <ins> fn first_assignment(&self, local: mir::Local) -> Option<Location> { let location = self.first_assignment[local]; if location.block.index() < self.fx.mir.basic_blocks().len() { Some(location) } else { None } </ins> } <del> fn mark_assigned(&mut self, local: mir::Local) { if !self.seen_assigned.insert(local.index()) { self.mark_as_memory(local); </del> <ins> fn not_ssa(&mut self, local: mir::Local) { debug!("marking {:?} as non-SSA", local); self.non_ssa_locals.insert(local.index()); } fn assign(&mut self, local: mir::Local, location: Location) { if self.first_assignment(local).is_some() { self.not_ssa(local); } else { self.first_assignment[local] = location; </ins> } } }


debug!("visit_assign(block={:?}, place={:?}, rvalue={:?})", block, place, rvalue); if let mir::Place::Local(index) = *place { <del> self.mark_assigned(index); </del> <ins> self.assign(index, location); </ins> if !self.fx.rvalue_creates_operand(rvalue) { <del> self.mark_as_memory(index); </del> <ins> self.not_ssa(index); </ins> } } else { self.visit_place(place, PlaceContext::Store, location);


if layout.is_llvm_immediate() || layout.is_llvm_scalar_pair() { // Recurse with the same context, instead of `Projection`, // potentially stopping at non-operand projections, <del> // which would trigger `mark_as_memory` on locals. </del> <ins> // which would trigger `not_ssa` on locals. </ins> self.visit_place(&proj.base, context, location); return; }


} fn visit_local(&mut self, <del> &index: &mir::Local, </del> <ins> &local: &mir::Local, </ins> context: PlaceContext<'tcx>, <del> _: Location) { </del> <ins> location: Location) { </ins> match context { PlaceContext::Call => { <del> self.mark_assigned(index); </del> <ins> self.assign(local, location); </ins> } PlaceContext::StorageLive | PlaceContext::StorageDead | <del> PlaceContext::Validate | </del> <ins> PlaceContext::Validate => {} </ins> PlaceContext::Copy | <del> PlaceContext::Move => {} </del> <ins> PlaceContext::Move => { // Reads from uninitialized variables (e.g. in dead code, after // optimizations) require locals to be in (uninitialized) memory. // NB: there can be uninitialized reads of a local visited after // an assignment to that local, if they happen on disjoint paths. let ssa_read = match self.first_assignment(local) { Some(assignment_location) => { assignment_location.dominates(location, &self.dominators) } None => false }; if !ssa_read { self.not_ssa(local); } } </ins> PlaceContext::Inspect | PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Borrow { .. } | PlaceContext::Projection(..) => { <del> self.mark_as_memory(index); </del> <ins> self.not_ssa(local); </ins> } PlaceContext::Drop => { <del> let ty = mir::Place::Local(index).ty(self.fx.mir, self.fx.cx.tcx); </del> <ins> let ty = mir::Place::Local(local).ty(self.fx.mir, self.fx.cx.tcx); </ins> let ty = self.fx.monomorphize(&ty.to_ty(self.fx.cx.tcx)); // Only need the place if we're actually dropping it. if self.fx.cx.type_needs_drop(ty) { <del> self.mark_as_memory(index); </del> <ins> self.not_ssa(local); </ins> } } }


}, }; <del> let memory_locals = analyze::memory_locals(&fx); </del> <ins> let memory_locals = analyze::non_ssa_locals(&fx); </ins> // Allocate variable and temp allocas fx.locals = {


} #[test] <del> fn connect_timeout_unroutable() { // this IP is unroutable, so connections should always time out, // provided the network is reachable to begin with. let addr = "10.255.255.1:80".parse().unwrap(); let e = TcpStream::connect_timeout(&addr, Duration::from_millis(250)).unwrap_err(); assert!(e.kind() == io::ErrorKind::TimedOut || e.kind() == io::ErrorKind::Other, "bad error: {} {:?}", e, e.kind()); } #[test] </del> fn connect_timeout_unbound() { // bind and drop a socket to track down a "probably unassigned" port let socket = TcpListener::bind("127.0.0.1:0").unwrap();


touch "$TOOLSTATE_FILE" <ins> # Try to test all the tools and store the build/test success in the TOOLSTATE_FILE </ins> set +e python2.7 "$X_PY" test --no-fail-fast  src/doc/book


cat "$TOOLSTATE_FILE" echo <ins> # This function checks that if a tool's submodule changed, the tool's state must improve </ins> verify_status() { echo "Verifying status of $1..." if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]$2$"; then


fi } <ins> # deduplicates the submodule check and the assertion that on beta some tools MUST be passing check_dispatch() { if [ "$1" = submodule_changed ]; then # ignore $2 (branch id) verify_status $3 $4 elif [ "$2" = beta ]; then echo "Requiring test passing for $3..." if grep -q '"'"$3"'":"(test|build)-fail"' "$TOOLSTATE_FILE"; then exit 4 fi fi } # list all tools here status_check() { check_dispatch $1 beta book src/doc/book check_dispatch $1 beta nomicon src/doc/nomicon check_dispatch $1 beta reference src/doc/reference check_dispatch $1 beta rust-by-example src/doc/rust-by-example check_dispatch $1 beta rls src/tool/rls check_dispatch $1 beta rustfmt src/tool/rustfmt # these tools are not required for beta to successfully branch check_dispatch $1 nightly clippy-driver src/tool/clippy check_dispatch $1 nightly miri src/tool/miri } </ins> # If this PR is intended to update one of these tools, do not let the build pass # when they do not test-pass. <del> verify_status book src/doc/book verify_status nomicon src/doc/nomicon verify_status reference src/doc/reference verify_status rust-by-example src/doc/rust-by-example verify_status rls src/tool/rls verify_status rustfmt src/tool/rustfmt verify_status clippy-driver src/tool/clippy verify_status miri src/tool/miri </del> <ins> status_check "submodule_changed" </ins> if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then . "$(dirname $0)/repo.sh"


exit 0 fi <del> if grep -q fail "$TOOLSTATE_FILE"; then exit 4 fi </del> <ins> # abort compilation if an important tool doesn't build # (this code is reachable if not on the nightly channel) status_check "beta_required" </ins>


// FIXME: Temporary fix for https://github.com/rust-lang/cargo/issues/3005 // Force cargo to output binaries with disambiguating hashes in the name <del> cargo.env("__CARGO_DEFAULT_LIB_METADATA", &self.config.channel); </del> <ins> let metadata = if compiler.stage == 0 { // Treat stage0 like special channel, whether it's a normal prior- // release rustc or a local rebuild with the same version, so we // never mix these libraries by accident. "bootstrap" } else { &self.config.channel }; cargo.env("__CARGO_DEFAULT_LIB_METADATA", &metadata); </ins> let stage; if compiler.stage == 0 && self.local_rebuild {


<del> Subproject commit 8b7f7e667268921c278af94ae30a61e87a22b22b </del> <ins> Subproject commit 329923edec41d0ddbea7f30ab12fca0436d459ae </ins>


<ins> #![feature(const_raw_ptr_to_usize_cast)] fn main() { [(); &(static |x| {}) as *const _ as usize]; //~^ ERROR: closures cannot be static //~| ERROR: type annotations needed [(); &(static || {}) as *const _ as usize]; //~^ ERROR: closures cannot be static //~| ERROR: evaluation of constant value failed } </ins>


<ins> error[E0697]: closures cannot be static --> $DIR/issue-52432.rs:4:12 | LL |     [(); &(static |x| {}) as *const _ as usize]; |            ^^^^^^^^^^ error[E0697]: closures cannot be static --> $DIR/issue-52432.rs:7:12 | LL |     [(); &(static || {}) as *const _ as usize]; |            ^^^^^^^^^ error[E0282]: type annotations needed --> $DIR/issue-52432.rs:4:20 | LL |     [(); &(static |x| {}) as *const _ as usize]; |                    ^ consider giving this closure parameter a type error[E0080]: evaluation of constant value failed --> $DIR/issue-52432.rs:7:10 | LL |     [(); &(static || {}) as *const _ as usize]; |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants error: aborting due to 4 previous errors Some errors have detailed explanations: E0080, E0282, E0697. For more information about an error, try `rustc --explain E0080`. </ins>


<ins> // check-pass #![allow(dead_code)] trait Structure<E>: Sized where E: Encoding { type RefTarget: ?Sized; type FfiPtr; unsafe fn borrow_from_ffi_ptr<'a>(ptr: Self::FfiPtr) -> Option<&'a Self::RefTarget>; } enum Slice {} impl<E> Structure<E> for Slice where E: Encoding { type RefTarget = [E::Unit]; type FfiPtr = (*const E::FfiUnit, usize); unsafe fn borrow_from_ffi_ptr<'a>(_ptr: Self::FfiPtr) -> Option<&'a Self::RefTarget> { panic!() } } trait Encoding { type Unit: Unit; type FfiUnit; } trait Unit {} enum Utf16 {} impl Encoding for Utf16 { type Unit = Utf16Unit; type FfiUnit = u16; } struct Utf16Unit(pub u16); impl Unit for Utf16Unit {} type SUtf16Str = SeStr<Slice, Utf16>; struct SeStr<S, E> where S: Structure<E>, E: Encoding { _data: S::RefTarget, } impl<S, E> SeStr<S, E> where S: Structure<E>, E: Encoding { pub unsafe fn from_ptr<'a>(_ptr: S::FfiPtr) -> Option<&'a Self> { panic!() } } fn main() { const TEXT_U16: &'static [u16] = &[]; let _ = unsafe { SUtf16Str::from_ptr((TEXT_U16.as_ptr(), TEXT_U16.len())).unwrap() }; } </ins>


<ins> // check-pass #![allow(dead_code)] trait Structure<E>: Sized where E: Encoding { type RefTarget: ?Sized; type FfiPtr; unsafe fn borrow_from_ffi_ptr<'a>(ptr: Self::FfiPtr) -> Option<&'a Self::RefTarget>; } enum Slice {} impl<E> Structure<E> for Slice where E: Encoding { type RefTarget = [E::Unit]; type FfiPtr = (*const E::FfiUnit, usize); unsafe fn borrow_from_ffi_ptr<'a>(_ptr: Self::FfiPtr) -> Option<&'a Self::RefTarget> { panic!() } } trait Encoding { type Unit: Unit; type FfiUnit; } trait Unit {} enum Utf16 {} impl Encoding for Utf16 { type Unit = Utf16Unit; type FfiUnit = u16; } struct Utf16Unit(pub u16); impl Unit for Utf16Unit {} struct SUtf16Str { _data: <Slice as Structure<Utf16>>::RefTarget, } impl SUtf16Str { pub unsafe fn from_ptr<'a>(ptr: <Slice as Structure<Utf16>>::FfiPtr) -> Option<&'a Self> { std::mem::transmute::<Option<&[<Utf16 as Encoding>::Unit]>, _>( <Slice as Structure<Utf16>>::borrow_from_ffi_ptr(ptr)) } } fn main() { const TEXT_U16: &'static [u16] = &[]; let _ = unsafe { SUtf16Str::from_ptr((TEXT_U16.as_ptr(), TEXT_U16.len())).unwrap() }; } </ins>


<ins> #![feature(type_alias_impl_trait)] type Closure = impl FnOnce(); //~ ERROR: type mismatch resolving fn c() -> Closure { || -> Closure { || () } } fn main() {} </ins>


<ins> error[E0271]: type mismatch resolving `<[closure@$DIR/issue-63279.rs:6:5: 6:28] as std::ops::FnOnce<()>>::Output == ()` --> $DIR/issue-63279.rs:3:1 | LL | type Closure = impl FnOnce(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found () | = note: expected type `Closure` found type `()` = note: the return type of a function must have a statically known size error: aborting due to previous error For more information about this error, try `rustc --explain E0271`. </ins>


<ins> #![feature(fn_traits, unboxed_closures)] fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {} struct Compose<F,G>(F,G); impl<T,F,G> FnOnce<(T,)> for Compose<F,G> where F: FnOnce<(T,)>, G: FnOnce<(F::Output,)> { type Output = G::Output; extern "rust-call" fn call_once(self, (x,): (T,)) -> G::Output { (self.1)((self.0)(x)) } } struct Str<'a>(&'a str); fn mk_str<'a>(s: &'a str) -> Str<'a> { Str(s) } fn main() { let _: for<'a> fn(&'a str) -> Str<'a> = mk_str; // expected concrete lifetime, found bound lifetime parameter 'a let _: for<'a> fn(&'a str) -> Str<'a> = Str; //~^ ERROR: mismatched types test(|_: &str| {}); test(mk_str); // expected concrete lifetime, found bound lifetime parameter 'x test(Str); //~ ERROR: type mismatch in function arguments test(Compose(|_: &str| {}, |_| {})); test(Compose(mk_str, |_| {})); // internal compiler error: cannot relate bound region: //   ReLateBound(DebruijnIndex { depth: 2 }, //     BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65))) //<= ReSkolemized(0, //     BrNamed(DefId { krate: 0, node: DefIndex(6) => test::'x }, 'x(65))) test(Compose(Str, |_| {})); } </ins>


<ins> error[E0308]: mismatched types --> $DIR/issue-30904.rs:20:45 | LL |     let _: for<'a> fn(&'a str) -> Str<'a> = Str; |                                             ^^^ expected concrete lifetime, found bound lifetime parameter 'a | = note: expected type `for<'a> fn(&'a str) -> Str<'a>` found type `fn(&str) -> Str<'_> {Str::<'_>}` error[E0631]: type mismatch in function arguments --> $DIR/issue-30904.rs:26:10 | LL | fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {} |    ----    -------------------------- required by this bound in `test` ... LL | struct Str<'a>(&'a str); | ------------------------ found signature of `fn(&str) -> _` ... LL |     test(Str); |          ^^^ expected signature of `for<'x> fn(&'x str) -> _` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>


use cmp; use io::{self, Initializer, SeekFrom, Error, ErrorKind}; <del> /// A `Cursor` wraps another type and provides it with a </del> <ins> /// A `Cursor` wraps an in-memory buffer and provides it with a </ins> /// [`Seek`] implementation. /// <del> /// `Cursor`s are typically used with in-memory buffers to allow them to /// implement [`Read`] and/or [`Write`], allowing these buffers to be used /// anywhere you might use a reader or writer that does actual I/O. </del> <ins> /// `Cursor`s are used with in-memory buffers, anything implementing /// `AsRef<[u8]>`, to allow them to implement [`Read`] and/or [`Write`], /// allowing these buffers to be used anywhere you might use a reader or writer /// that does actual I/O. </ins> /// /// The standard library implements some I/O traits on various types which /// are commonly used as a buffer, like `Cursor<`[`Vec`]`<u8>>` and


} impl<T> Cursor<T> { <del> /// Creates a new cursor wrapping the provided underlying I/O object. </del> <ins> /// Creates a new cursor wrapping the provided underlying in-memory buffer. </ins> /// <del> /// Cursor initial position is `0` even if underlying object (e. /// g. `Vec`) is not empty. So writing to cursor starts with /// overwriting `Vec` content, not with appending to it. </del> <ins> /// Cursor initial position is `0` even if underlying buffer (e.g. `Vec`) /// is not empty. So writing to cursor starts with overwriting `Vec` /// content, not with appending to it. </ins> /// /// # Examples ///


err.span_label(arm_span, msg); } } <del> hir::MatchSource::TryDesugar => { // Issue #51632 if let Ok(try_snippet) = self.tcx.sess.source_map().span_to_snippet(arm_span) { err.span_suggestion_with_applicability( arm_span, "try wrapping with a success variant", format!("Ok({})", try_snippet), Applicability::MachineApplicable, ); } } </del> <ins> hir::MatchSource::TryDesugar => {} </ins> _ => { let msg = "match arm with an incompatible type"; if self.tcx.sess.source_map().is_multiline(arm_span) {


<del> // 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // run-rustfix #![allow(dead_code)] fn missing_discourses() -> Result<isize, ()> { Ok(1) } fn forbidden_narratives() -> Result<isize, ()> { Ok(missing_discourses()?) //~^ ERROR try expression alternatives have incompatible types //~| HELP try wrapping with a success variant } fn main() {} </del>


// option. This file may not be copied, modified, or distributed // except according to those terms. <del> // run-rustfix </del> #![allow(dead_code)] fn missing_discourses() -> Result<isize, ()> {


fn forbidden_narratives() -> Result<isize, ()> { missing_discourses()? //~^ ERROR try expression alternatives have incompatible types <del> //~| HELP try wrapping with a success variant </del> } fn main() {}


error[E0308]: try expression alternatives have incompatible types <del> --> $DIR/issue-51632-try-desugar-incompatible-types.rs:20:5 </del> <ins> --> $DIR/issue-51632-try-desugar-incompatible-types.rs:18:5 </ins> | LL |     missing_discourses()? <del> |     ^^^^^^^^^^^^^^^^^^^^^ |     | |     expected enum `std::result::Result`, found isize |     help: try wrapping with a success variant: `Ok(missing_discourses()?)` </del> <ins> |     ^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found isize </ins> | = note: expected type `std::result::Result<isize, ()>` found type `isize`


)); } <del> let needs_parens = match expr.kind { // parenthesize if needed (Issue #46756) hir::ExprKind::Cast(_, _) | hir::ExprKind::Binary(_, _, _) => true, // parenthesize borrows of range literals (Issue #54505) _ if is_range_literal(expr) => true, _ => false, }; </del> if let Some((sugg, msg)) = self.can_use_as_ref(expr) { return Some(( sugg,


} } <del> let sugg = mutability.ref_prefix_str(); let (sugg, verbose) = if needs_parens { ( vec![ (sp.shrink_to_lo(), format!("{prefix}{sugg}(")), (sp.shrink_to_hi(), ")".to_string()), ], false, ) } else { (vec![(sp.shrink_to_lo(), format!("{prefix}{sugg}"))], true) </del> <ins> let make_sugg = |expr: &Expr<'_>, span: Span, sugg: &str| { let needs_parens = match expr.kind { // parenthesize if needed (Issue #46756) hir::ExprKind::Cast(_, _) | hir::ExprKind::Binary(_, _, _) => true, // parenthesize borrows of range literals (Issue #54505) _ if is_range_literal(expr) => true, _ => false, }; if needs_parens { ( vec![ (span.shrink_to_lo(), format!("{prefix}{sugg}(")), (span.shrink_to_hi(), ")".to_string()), ], false, ) } else { (vec![(span.shrink_to_lo(), format!("{prefix}{sugg}"))], true) } </ins> }; <ins> // Suggest dereferencing the lhs for expressions such as `&T == T` if let Some(hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Binary(_, lhs, ..), .. })) = self.tcx.hir().find_parent(expr.hir_id) && let &ty::Ref(..) = self.check_expr(lhs).kind() { let (sugg, verbose) = make_sugg(lhs, lhs.span, "*"); return Some(( sugg, "consider dereferencing the borrow".to_string(), Applicability::MachineApplicable, verbose, false, )); } let sugg = mutability.ref_prefix_str(); let (sugg, verbose) = make_sugg(expr, sp, sugg); </ins> return Some(( sugg, format!("consider {}borrowing here", mutability.mutably_str()),


<ins> // Issue #52544 // run-rustfix fn main() { let i: &i64 = &1; if *i < 0 {} //~^ ERROR mismatched types [E0308] } </ins>


<ins> // Issue #52544 // run-rustfix fn main() { let i: &i64 = &1; if i < 0 {} //~^ ERROR mismatched types [E0308] } </ins>


<ins> error[E0308]: mismatched types --> $DIR/binary-op-suggest-deref.rs:6:12 | LL |     if i < 0 {} |            ^ expected `&i64`, found integer | help: consider dereferencing the borrow | LL |     if *i < 0 {} |        + error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>


<del> Subproject commit 52a6a4d7087d14a35d44a11c39c77fa79d71378d </del> <ins> Subproject commit d549d85b1735dc5066b2973f8549557a813bb9c8 </ins>


<del> Subproject commit 03684905101f0b7e49dfe530e54dc1aeac6ef0fb </del> <ins> Subproject commit e19f07f5a6e5546ab4f6ea951e3c6b8627edeaa7 </ins>


# If this file is modified, then llvm will be (optionally) cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. <del> 2018-07-12 </del>  No newline at end of file <ins> 2018-08-02 </ins>


<del> Subproject commit 8214ccf861d538671b0a1436dbf4538dc4a64d09 </del> <ins> Subproject commit f76ea3ca16ed22dde8ef929db74a4b4df6f2f899 </ins>


len); } <del> /// Returns a pair of slices which contain the contents of the buffer not used by the VecDeque. #[inline] unsafe fn unused_as_mut_slices<'a>(&'a mut self) -> (&'a mut [T], &'a mut [T]) { let head = self.head; let tail = self.tail; let buf = self.buffer_as_mut_slice(); if head != tail { // In buf, head..tail contains the VecDeque and tail..head is unused. // So calling `ring_slices` with tail and head swapped returns unused slices. RingSlices::ring_slices(buf, tail, head) } else { // Swapping doesn't help when head == tail. let (before, after) = buf.split_at_mut(head); (after, before) } } </del> /// Copies a potentially wrapping block of memory len long from src to dest. /// (abs(dst - src) + len) must be no larger than cap() (There must be at /// most one continuous overlapping region between src and dest).


#[inline] #[stable(feature = "append", since = "1.4.0")] pub fn append(&mut self, other: &mut Self) { <del> // Copies all values from `src_slice` to the start of `dst_slice`. unsafe fn copy_whole_slice<T>(src_slice: &[T], dst_slice: &mut [T]) { let len = src_slice.len(); ptr::copy_nonoverlapping(src_slice.as_ptr(), dst_slice[..len].as_mut_ptr(), len); } let src_total = other.len(); // Guarantees there is space in `self` for `other`. self.reserve(src_total); self.head = { let original_head = self.head; // The goal is to copy all values from `other` into `self`. To avoid any // mismatch, all valid values in `other` are retrieved... let (src_high, src_low) = other.as_slices(); // and unoccupied parts of self are retrieved. let (dst_high, dst_low) = unsafe { self.unused_as_mut_slices() }; // Then all that is needed is to copy all values from // src (src_high and src_low) to dst (dst_high and dst_low). // // other [o o o . . . . . o o o o] //       [5 6 7]         [1 2 3 4] //       src_low         src_high // // self  [. . . . . . o o o o . .] //       [3 4 5 6 7 .]       [1 2] //       dst_low             dst_high // // Values are not copied one by one but as slices in `copy_whole_slice`. // What slices are used depends on various properties of src and dst. // There are 6 cases in total: //     1. `src` is contiguous and fits in dst_high //     2. `src` is contiguous and does not fit in dst_high //     3. `src` is discontiguous and fits in dst_high //     4. `src` is discontiguous and does not fit in dst_high //        + src_high is smaller than dst_high //     5. `src` is discontiguous and does not fit in dst_high //        + dst_high is smaller than src_high //     6. `src` is discontiguous and does not fit in dst_high //        + dst_high is the same size as src_high let src_contiguous = src_low.is_empty(); let dst_high_fits_src = dst_high.len() >= src_total; match (src_contiguous, dst_high_fits_src) { (true, true) => { // 1. // other [. . . o o o . . . . . .] //       []    [1 1 1] // // self  [. o o o o o . . . . . .] //       [.]         [1 1 1 . . .] unsafe { copy_whole_slice(src_high, dst_high); } original_head + src_total } (true, false) => { // 2. // other [. . . o o o o o . . . .] //       []    [1 1 2 2 2] // // self  [. . . . . . . o o o . .] //       [2 2 2 . . . .]     [1 1] let (src_1, src_2) = src_high.split_at(dst_high.len()); unsafe { copy_whole_slice(src_1, dst_high); copy_whole_slice(src_2, dst_low); } src_total - dst_high.len() } (false, true) => { // 3. // other [o o . . . . . . . o o o] //       [2 2]             [1 1 1] // // self  [. o o . . . . . . . . .] //       [.]   [1 1 1 2 2 . . . .] let (dst_1, dst_2) = dst_high.split_at_mut(src_high.len()); unsafe { copy_whole_slice(src_high, dst_1); copy_whole_slice(src_low, dst_2); } original_head + src_total } (false, false) => { if src_high.len() < dst_high.len() { // 4. // other [o o o . . . . . . o o o] //       [2 3 3]           [1 1 1] // // self  [. . . . . . o o . . . .] //       [3 3 . . . .]   [1 1 1 2] let (dst_1, dst_2) = dst_high.split_at_mut(src_high.len()); let (src_2, src_3) = src_low.split_at(dst_2.len()); unsafe { copy_whole_slice(src_high, dst_1); copy_whole_slice(src_2, dst_2); copy_whole_slice(src_3, dst_low); } src_3.len() } else if src_high.len() > dst_high.len() { // 5. // other [o o o . . . . . o o o o] //       [3 3 3]         [1 1 2 2] // // self  [. . . . . . o o o o . .] //       [2 2 3 3 3 .]       [1 1] let (src_1, src_2) = src_high.split_at(dst_high.len()); let (dst_2, dst_3) = dst_low.split_at_mut(src_2.len()); unsafe { copy_whole_slice(src_1, dst_high); copy_whole_slice(src_2, dst_2); copy_whole_slice(src_low, dst_3); } dst_2.len() + src_low.len() } else { // 6. // other [o o . . . . . . . o o o] //       [2 2]             [1 1 1] // // self  [. . . . . . . o o . . .] //       [2 2 . . . . .]   [1 1 1] unsafe { copy_whole_slice(src_high, dst_high); copy_whole_slice(src_low, dst_low); } src_low.len() } } } }; // Some values now exist in both `other` and `self` but are made inaccessible in `other`. other.tail = other.head; </del> <ins> // naive impl self.extend(other.drain(..)); </ins> } /// Retains only the elements specified by the predicate.


#[stable(feature = "collection_debug", since = "1.17.0")] impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <ins> let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail); </ins> f.debug_tuple("Iter") <del> .field(&self.ring) .field(&self.tail) .field(&self.head) .finish() </del> <ins> .field(&front) .field(&back) .finish() </ins> } }


#[stable(feature = "collection_debug", since = "1.17.0")] impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <ins> let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail); </ins> f.debug_tuple("IterMut") <del> .field(&self.ring) .field(&self.tail) .field(&self.head) .finish() </del> <ins> .field(&front) .field(&back) .finish() </ins> } }


} } <ins> #[test] fn issue_53529() { use boxed::Box; let mut dst = VecDeque::new(); dst.push_front(Box::new(1)); dst.push_front(Box::new(2)); assert_eq!(*dst.pop_back().unwrap(), 1); let mut src = VecDeque::new(); src.push_front(Box::new(2)); dst.append(&mut src); for a in dst { assert_eq!(*a, 2); } } </ins> }


<ins> // ignore-tidy-linelength #![feature(type_alias_impl_trait)] use std::fmt::Debug; pub trait Foo { type Item: Debug; fn foo<T: Debug>(_: T) -> Self::Item; } #[derive(Debug)] pub struct S<T>(std::marker::PhantomData<T>); pub struct S2; impl Foo for S2 { type Item = impl Debug; fn foo<T: Debug>(_: T) -> Self::Item { //~^ Error type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias S::<T>(Default::default()) } } fn main() { S2::foo(123); } </ins>


<ins> error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/issue-53598.rs:20:42 | LL |       fn foo<T: Debug>(_: T) -> Self::Item { |  __________________________________________^ LL | | LL | |         S::<T>(Default::default()) LL | |     } | |_____^ error: aborting due to previous error </ins>


<ins> // ignore-tidy-linelength #![feature(arbitrary_self_types)] #![feature(type_alias_impl_trait)] use std::ops::Deref; trait Foo { type Bar: Foo; fn foo(self: impl Deref<Target = Self>) -> Self::Bar; } impl<C> Foo for C { type Bar = impl Foo; fn foo(self: impl Deref<Target = Self>) -> Self::Bar { //~^ Error type parameter `impl Deref<Target = Self>` is part of concrete type but not used in parameter list for the `impl Trait` type alias self } } fn main() {} </ins>


<ins> error: type parameter `impl Deref<Target = Self>` is part of concrete type but not used in parameter list for the `impl Trait` type alias --> $DIR/issue-57700.rs:16:58 | LL |       fn foo(self: impl Deref<Target = Self>) -> Self::Bar { |  __________________________________________________________^ LL | | LL | |         self LL | |     } | |_____^ error: aborting due to previous error </ins>


<ins> //compile-pass #![feature(nll)] fn main() { let _: &'static usize = &(loop {}, 1).1; } </ins>


<ins> // 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 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // New test for #53818: modifying static memory at compile-time is not allowed. // The test should never succeed. #![feature(const_raw_ptr_deref)] #![feature(const_let)] use std::cell::UnsafeCell; struct Foo(UnsafeCell<u32>); unsafe impl Send for Foo {} unsafe impl Sync for Foo {} static FOO: Foo = Foo(UnsafeCell::new(42)); static BAR: () = unsafe { *FOO.0.get() = 5; //~^ ERROR calls in statics are limited to constant functions, tuple structs and tuple variants // This error is caused by a separate bug that the feature gate error is reported // even though the feature gate "const_let" is active. //~| statements in statics are unstable (see issue #48821) }; fn main() { println!("{}", unsafe { *FOO.0.get() }); } </ins>


<ins> error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants --> $DIR/mod-static-with-const-fn.rs:27:6 | LL |     *FOO.0.get() = 5; |      ^^^^^^^^^^^ error[E0658]: statements in statics are unstable (see issue #48821) --> $DIR/mod-static-with-const-fn.rs:27:5 | LL |     *FOO.0.get() = 5; |     ^^^^^^^^^^^^^^^^ | = help: add #![feature(const_let)] to the crate attributes to enable error: aborting due to 2 previous errors Some errors occurred: E0015, E0658. For more information about an error, try `rustc --explain E0015`. </ins>