Skip to content

Rollup of 11 pull requests #52802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jul 28, 2018
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
20151ca
Suggest on method signature diff between impl and trait
csmoe Jul 25, 2018
d5347ff
Fix ui test
csmoe Jul 26, 2018
acd38f6
Improve a few vectors - calculate capacity or build from iterators
ljedrz Jul 25, 2018
a3bf27b
Suggest underscore when using dashes in crate namet push fork
estebank Jul 26, 2018
89a8162
Impl Send & Sync for JoinHandle
Jul 26, 2018
efa11da
rustc_metadata: test loading atoi instead of cos
cuviper Jul 27, 2018
e950d22
Omit the vendor component in Fuchsia triple
petrhosek Jul 27, 2018
688db1d
Add stability attributes
Jul 27, 2018
3170956
Remove unused option flag
sinkuu Apr 20, 2018
b326e71
Incorporate a stray test
sinkuu Apr 28, 2018
e25c3e2
Fix doc comment for 'ptr::copy_to' method
Jul 27, 2018
a171ed2
revert accidental atty downgrade
RalfJung Jul 27, 2018
1cca420
Use slices where a vector is not necessary
ljedrz Jul 27, 2018
647d295
review comments
estebank Jul 27, 2018
80c798b
Rollup merge of #52702 - csmoe:mut_diff, r=estebank
kennytm Jul 28, 2018
7da2214
Rollup merge of #52703 - ljedrz:vec_improvements, r=nikomatsakis
kennytm Jul 28, 2018
b584c32
Rollup merge of #52740 - estebank:crate-name, r=petrochenkov
kennytm Jul 28, 2018
b326319
Rollup merge of #52759 - stjepang:impl-send-sync-for-joinhandle, r=TimNN
kennytm Jul 28, 2018
42e92d9
Rollup merge of #52760 - cuviper:test_loading_atoi, r=alexcrichton
kennytm Jul 28, 2018
1fad057
Rollup merge of #52763 - petrhosek:fuchsia-triple, r=alexcrichton
kennytm Jul 28, 2018
c9347f7
Rollup merge of #52765 - sinkuu:remove_nonzeroing_move_opt, r=pnkfelix
kennytm Jul 28, 2018
2c088cb
Rollup merge of #52769 - sinkuu:stray_test, r=alexcrichton
kennytm Jul 28, 2018
f22c03f
Rollup merge of #52777 - omni-viral:master, r=TimNN
kennytm Jul 28, 2018
f0efbc0
Rollup merge of #52779 - RalfJung:atty, r=Mark-Simulacrum
kennytm Jul 28, 2018
59f8422
Rollup merge of #52781 - ljedrz:avoid_vec_arguments, r=nikomatsakis
kennytm Jul 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ dependencies = [

[[package]]
name = "atty"
version = "0.2.10"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -187,7 +187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "cargo"
version = "0.30.0"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -303,7 +303,7 @@ version = "2.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -622,7 +622,7 @@ name = "env_logger"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1844,7 +1844,7 @@ name = "rustc-ap-rustc_errors"
version = "182.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-ap-rustc_data_structures 182.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-ap-serialize 182.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-ap-syntax_pos 182.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2097,7 +2097,7 @@ dependencies = [
name = "rustc_errors"
version = "0.0.0"
dependencies = [
"atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_data_structures 0.0.0",
"serialize 0.0.0",
"syntax_pos 0.0.0",
@@ -3056,7 +3056,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
"checksum assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98589b0e465a6c510d95fceebd365bb79bedece7f6e18a480897f2015f85ec51"
"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
"checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
16 changes: 8 additions & 8 deletions src/ci/docker/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
@@ -34,21 +34,21 @@ COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV \
AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \
CC_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang \
CXX_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang++ \
AR_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-ar \
CC_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang \
CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++ \
AR_x86_64_fuchsia=x86_64-fuchsia-ar \
CC_x86_64_fuchsia=x86_64-fuchsia-clang \
CXX_x86_64_fuchsia=x86_64-fuchsia-clang++ \
AR_aarch64_fuchsia=aarch64-fuchsia-ar \
CC_aarch64_fuchsia=aarch64-fuchsia-clang \
CXX_aarch64_fuchsia=aarch64-fuchsia-clang++ \
AR_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-ar \
CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-gcc \
CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \
AR_x86_64_sun_solaris=x86_64-sun-solaris2.10-ar \
CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \
CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++

ENV TARGETS=x86_64-unknown-fuchsia
ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia
ENV TARGETS=x86_64-fuchsia
ENV TARGETS=$TARGETS,aarch64-fuchsia
ENV TARGETS=$TARGETS,sparcv9-sun-solaris
ENV TARGETS=$TARGETS,wasm32-unknown-unknown
ENV TARGETS=$TARGETS,x86_64-sun-solaris
10 changes: 5 additions & 5 deletions src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ build() {
esac

hide_output make -j$(getconf _NPROCESSORS_ONLN) $tgt
dst=/usr/local/${arch}-unknown-fuchsia
dst=/usr/local/${arch}-fuchsia
mkdir -p $dst
cp -a build-${tgt}/sysroot/include $dst/
cp -a build-${tgt}/sysroot/lib $dst/
@@ -55,11 +55,11 @@ rm -rf zircon

for arch in x86_64 aarch64; do
for tool in clang clang++; do
cat >/usr/local/bin/${arch}-unknown-fuchsia-${tool} <<EOF
cat >/usr/local/bin/${arch}-fuchsia-${tool} <<EOF
#!/bin/sh
${tool} --target=${arch}-unknown-fuchsia --sysroot=/usr/local/${arch}-unknown-fuchsia "\$@"
${tool} --target=${arch}-fuchsia --sysroot=/usr/local/${arch}-fuchsia "\$@"
EOF
chmod +x /usr/local/bin/${arch}-unknown-fuchsia-${tool}
chmod +x /usr/local/bin/${arch}-fuchsia-${tool}
done
ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar
ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-fuchsia-ar
done
1 change: 1 addition & 0 deletions src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
#![feature(try_reserve)]
#![feature(unboxed_closures)]
#![feature(exact_chunks)]
#![feature(repeat_generic_slice)]

extern crate alloc_system;
extern crate core;
11 changes: 11 additions & 0 deletions src/liballoc/tests/slice.rs
Original file line number Diff line number Diff line change
@@ -1529,3 +1529,14 @@ fn panic_safe() {
}
}
}

#[test]
fn repeat_generic_slice() {
assert_eq!([1, 2].repeat(2), vec![1, 2, 1, 2]);
assert_eq!([1, 2, 3, 4].repeat(0), vec![]);
assert_eq!([1, 2, 3, 4].repeat(1), vec![1, 2, 3, 4]);
assert_eq!(
[1, 2, 3, 4].repeat(3),
vec![1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
);
}
4 changes: 2 additions & 2 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
@@ -1162,8 +1162,8 @@ impl<T: ?Sized> *const T {
///
/// Care must be taken with the ownership of `self` and `dest`.
/// This method semantically moves the values of `self` into `dest`.
/// However it does not drop the contents of `self`, or prevent the contents
/// of `dest` from being dropped or used.
/// However it does not drop the contents of `dest`, or prevent the contents
/// of `self` from being dropped or used.
///
/// # Examples
///
4 changes: 2 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
@@ -746,7 +746,7 @@ impl<'a> LoweringContext<'a> {
// This is used to track which lifetimes have already been defined, and
// which are new in-band lifetimes that need to have a definition created
// for them.
fn with_in_scope_lifetime_defs<T, F>(&mut self, params: &Vec<GenericParam>, f: F) -> T
fn with_in_scope_lifetime_defs<T, F>(&mut self, params: &[GenericParam], f: F) -> T
where
F: FnOnce(&mut LoweringContext) -> T,
{
@@ -2237,7 +2237,7 @@ impl<'a> LoweringContext<'a> {

fn lower_generic_params(
&mut self,
params: &Vec<GenericParam>,
params: &[GenericParam],
add_bounds: &NodeMap<Vec<GenericBound>>,
mut itctx: ImplTraitContext,
) -> hir::HirVec<hir::GenericParam> {
2 changes: 1 addition & 1 deletion src/librustc/hir/map/hir_id_validator.rs
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
.collect();

// Try to map those to something more useful
let mut missing_items = vec![];
let mut missing_items = Vec::with_capacity(missing.len());

for local_id in missing {
let hir_id = HirId {
2 changes: 1 addition & 1 deletion src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
@@ -396,7 +396,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
pub fn hash_stable_trait_impls<'a, 'gcx, W, R>(
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>,
blanket_impls: &Vec<DefId>,
blanket_impls: &[DefId],
non_blanket_impls: &HashMap<fast_reject::SimplifiedType, Vec<DefId>, R>)
where W: StableHasherResult,
R: std_hash::BuildHasher,
6 changes: 1 addition & 5 deletions src/librustc/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
@@ -505,11 +505,7 @@ where
}

fn recursive_type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
let mut bounds = vec![];

for subty in ty.walk_shallow() {
bounds.push(self.type_bound(subty));
}
let mut bounds = ty.walk_shallow().map(|subty| self.type_bound(subty)).collect::<Vec<_>>();

let mut regions = ty.regions();
regions.retain(|r| !r.is_late_bound()); // ignore late-bound regions
2 changes: 1 addition & 1 deletion src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
@@ -219,7 +219,7 @@ impl LintStore {
}
}

let mut future_incompatible = vec![];
let mut future_incompatible = Vec::with_capacity(lints.len());
for lint in lints {
future_incompatible.push(lint.id);
self.future_incompatible.insert(lint.id, lint);
6 changes: 0 additions & 6 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
@@ -1247,8 +1247,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"for every macro invocation, print its name and arguments"),
debug_macros: bool = (false, parse_bool, [TRACKED],
"emit line numbers debug info inside macros"),
enable_nonzeroing_move_hints: bool = (false, parse_bool, [TRACKED],
"force nonzeroing move optimization on"),
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
"don't clear the hygiene data after analysis"),
keep_ast: bool = (false, parse_bool, [UNTRACKED],
@@ -3168,10 +3166,6 @@ mod tests {
opts.debugging_opts.force_overflow_checks = Some(true);
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

opts = reference.clone();
opts.debugging_opts.enable_nonzeroing_move_hints = true;
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

opts = reference.clone();
opts.debugging_opts.show_span = Some(String::from("abc"));
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
3 changes: 0 additions & 3 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
@@ -624,9 +624,6 @@ impl Session {
pub fn unstable_options(&self) -> bool {
self.opts.debugging_opts.unstable_options
}
pub fn nonzeroing_move_hints(&self) -> bool {
self.opts.debugging_opts.enable_nonzeroing_move_hints
}
pub fn overflow_checks(&self) -> bool {
self.opts
.cg
4 changes: 2 additions & 2 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ use syntax_pos::{DUMMY_SP, Span};

impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
pub fn report_fulfillment_errors(&self,
errors: &Vec<FulfillmentError<'tcx>>,
errors: &[FulfillmentError<'tcx>],
body_id: Option<hir::BodyId>,
fallback_has_occurred: bool) {
#[derive(Debug)]
@@ -1015,7 +1015,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
) -> DiagnosticBuilder<'tcx> {
let kind = if is_closure { "closure" } else { "function" };

let args_str = |arguments: &Vec<ArgKind>, other: &Vec<ArgKind>| {
let args_str = |arguments: &[ArgKind], other: &[ArgKind]| {
let arg_length = arguments.len();
let distinct = match &other[..] {
&[ArgKind::Tuple(..)] => true,
11 changes: 4 additions & 7 deletions src/librustc/traits/object_safety.rs
Original file line number Diff line number Diff line change
@@ -98,13 +98,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn astconv_object_safety_violations(self, trait_def_id: DefId)
-> Vec<ObjectSafetyViolation>
{
let mut violations = vec![];

for def_id in traits::supertrait_def_ids(self, trait_def_id) {
if self.predicates_reference_self(def_id, true) {
violations.push(ObjectSafetyViolation::SupertraitSelf);
}
}
let violations = traits::supertrait_def_ids(self, trait_def_id)
.filter(|&def_id| self.predicates_reference_self(def_id, true))
.map(|_| ObjectSafetyViolation::SupertraitSelf)
.collect();

debug!("astconv_object_safety_violations(trait_def_id={:?}) = {:?}",
trait_def_id,
4 changes: 2 additions & 2 deletions src/librustc_borrowck/borrowck/gather_loans/move_error.rs
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ pub struct GroupedMoveErrors<'tcx> {
move_to_places: Vec<MovePlace<'tcx>>
}

fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &Vec<MoveError<'tcx>>) {
fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveError<'tcx>]) {
let grouped_errors = group_errors_with_same_origin(errors);
for error in &grouped_errors {
let mut err = report_cannot_move_out_of(bccx, error.move_from.clone());
@@ -103,7 +103,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &Vec<Move
}
}

fn group_errors_with_same_origin<'tcx>(errors: &Vec<MoveError<'tcx>>)
fn group_errors_with_same_origin<'tcx>(errors: &[MoveError<'tcx>])
-> Vec<GroupedMoveErrors<'tcx>> {
let mut grouped_errors = Vec::new();
for error in errors {
5 changes: 3 additions & 2 deletions src/librustc_codegen_llvm/back/link.rs
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ use std::env;
use std::fmt;
use std::fs;
use std::io;
use std::iter;
use std::path::{Path, PathBuf};
use std::process::{Output, Stdio};
use std::str;
@@ -885,9 +886,9 @@ fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &
}
let file = tmpdir.join("linker-arguments");
let bytes = if sess.target.target.options.is_like_msvc {
let mut out = vec![];
let mut out = Vec::with_capacity((1 + args.len()) * 2);
// start the stream with a UTF-16 BOM
for c in vec![0xFEFF].into_iter().chain(args.encode_utf16()) {
for c in iter::once(0xFEFF).chain(args.encode_utf16()) {
// encode in little endian
out.push(c as u8);
out.push((c >> 8) as u8);
8 changes: 4 additions & 4 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
@@ -1395,7 +1395,7 @@ fn generated_output_paths(

// Runs `f` on every output file path and returns the first non-None result, or None if `f`
// returns None for every file path.
fn check_output<F, T>(output_paths: &Vec<PathBuf>, f: F) -> Option<T>
fn check_output<F, T>(output_paths: &[PathBuf], f: F) -> Option<T>
where
F: Fn(&PathBuf) -> Option<T>,
{
@@ -1407,7 +1407,7 @@ where
None
}

pub fn output_contains_path(output_paths: &Vec<PathBuf>, input_path: &PathBuf) -> bool {
pub fn output_contains_path(output_paths: &[PathBuf], input_path: &PathBuf) -> bool {
let input_path = input_path.canonicalize().ok();
if input_path.is_none() {
return false;
@@ -1422,7 +1422,7 @@ pub fn output_contains_path(output_paths: &Vec<PathBuf>, input_path: &PathBuf) -
check_output(output_paths, check).is_some()
}

pub fn output_conflicts_with_dir(output_paths: &Vec<PathBuf>) -> Option<PathBuf> {
pub fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> {
let check = |output_path: &PathBuf| {
if output_path.is_dir() {
Some(output_path.clone())
@@ -1433,7 +1433,7 @@ pub fn output_conflicts_with_dir(output_paths: &Vec<PathBuf>) -> Option<PathBuf>
check_output(output_paths, check)
}

fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &Vec<PathBuf>) {
fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[PathBuf]) {
// Write out dependency rules to the dep-info file if requested
if !sess.opts.output_types.contains_key(&OutputType::DepInfo) {
return;
2 changes: 1 addition & 1 deletion src/librustc_driver/profile/mod.rs
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ struct StackFrame {
pub traces: Vec<trace::Rec>,
}

fn total_duration(traces: &Vec<trace::Rec>) -> Duration {
fn total_duration(traces: &[trace::Rec]) -> Duration {
let mut sum : Duration = Duration::new(0,0);
for t in traces.iter() { sum += t.dur_total; }
return sum
8 changes: 4 additions & 4 deletions src/librustc_driver/profile/trace.rs
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ fn html_of_fraction(frac: f64) -> (String, String) {
else { (format!("< 0.1%", ), css) }
}

fn total_duration(traces: &Vec<Rec>) -> Duration {
fn total_duration(traces: &[Rec]) -> Duration {
let mut sum : Duration = Duration::new(0,0);
for t in traces.iter() {
sum += t.dur_total;
@@ -123,7 +123,7 @@ fn duration_div(nom: Duration, den: Duration) -> f64 {
to_nanos(nom) as f64 / to_nanos(den) as f64
}

fn write_traces_rec(file: &mut File, traces: &Vec<Rec>, total: Duration, depth: usize) {
fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usize) {
for t in traces {
let (eff_text, eff_css_classes) = html_of_effect(&t.effect);
let (dur_text, dur_css_classes) = html_of_duration(&t.start, &t.dur_total);
@@ -149,7 +149,7 @@ fn write_traces_rec(file: &mut File, traces: &Vec<Rec>, total: Duration, depth:
}
}

fn compute_counts_rec(counts: &mut HashMap<String,QueryMetric>, traces: &Vec<Rec>) {
fn compute_counts_rec(counts: &mut HashMap<String,QueryMetric>, traces: &[Rec]) {
for t in traces.iter() {
match t.effect {
Effect::TimeBegin(ref msg) => {
@@ -218,7 +218,7 @@ pub fn write_counts(count_file: &mut File, counts: &mut HashMap<String,QueryMetr
}
}

pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &Vec<Rec>) {
pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &[Rec]) {
let capacity = traces.iter().fold(0, |acc, t| acc + 1 + t.extent.len());
let mut counts : HashMap<String, QueryMetric> = HashMap::with_capacity(capacity);
compute_counts_rec(&mut counts, traces);
10 changes: 5 additions & 5 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
@@ -749,7 +749,7 @@ impl EmitterWriter {
max
}

fn get_max_line_num(&mut self, span: &MultiSpan, children: &Vec<SubDiagnostic>) -> usize {
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize {
let mut max = 0;

let primary = self.get_multispan_max_line_num(span);
@@ -954,7 +954,7 @@ impl EmitterWriter {

fn emit_message_default(&mut self,
msp: &MultiSpan,
msg: &Vec<(String, Style)>,
msg: &[(String, Style)],
code: &Option<DiagnosticId>,
level: &Level,
max_line_num_len: usize,
@@ -1317,10 +1317,10 @@ impl EmitterWriter {

fn emit_messages_default(&mut self,
level: &Level,
message: &Vec<(String, Style)>,
message: &[(String, Style)],
code: &Option<DiagnosticId>,
span: &MultiSpan,
children: &Vec<SubDiagnostic>,
children: &[SubDiagnostic],
suggestions: &[CodeSuggestion]) {
let max_line_num_len = if self.ui_testing {
ANONYMIZED_LINE_NUM.len()
@@ -1433,7 +1433,7 @@ fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
num_overlap(a1.start_col, a1.end_col + padding, a2.start_col, a2.end_col, false)
}

fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
fn emit_to_destination(rendered_buffer: &[Vec<StyledString>],
lvl: &Level,
dst: &mut Destination,
short_message: bool)
25 changes: 12 additions & 13 deletions src/librustc_metadata/dynamic_lib.rs
Original file line number Diff line number Diff line change
@@ -90,30 +90,29 @@ mod tests {
use std::mem;

#[test]
fn test_loading_cosine() {
fn test_loading_atoi() {
if cfg!(windows) {
return
}

// The math library does not need to be loaded since it is already
// statically linked in
let libm = match DynamicLibrary::open(None) {
// The C library does not need to be loaded since it is already linked in
let lib = match DynamicLibrary::open(None) {
Err(error) => panic!("Could not load self as module: {}", error),
Ok(libm) => libm
Ok(lib) => lib
};

let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe {
match libm.symbol("cos") {
Err(error) => panic!("Could not load function cos: {}", error),
Ok(cosine) => mem::transmute::<*mut u8, _>(cosine)
let atoi: extern fn(*const libc::c_char) -> libc::c_int = unsafe {
match lib.symbol("atoi") {
Err(error) => panic!("Could not load function atoi: {}", error),
Ok(atoi) => mem::transmute::<*mut u8, _>(atoi)
}
};

let argument = 0.0;
let expected_result = 1.0;
let result = cosine(argument);
let argument = CString::new("1383428980").unwrap();
let expected_result = 0x52757374;
let result = atoi(argument.as_ptr());
if result != expected_result {
panic!("cos({}) != {} but equaled {} instead", argument,
panic!("atoi({:?}) != {} but equaled {} instead", argument,
expected_result, result)
}
}
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/nll/facts.rs
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ struct FactWriter<'w> {
impl<'w> FactWriter<'w> {
fn write_facts_to_path<T>(
&self,
rows: &Vec<T>,
rows: &[T],
file_name: &str,
) -> Result<(), Box<dyn Error>>
where
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/terminator/drop.rs
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
self.eval_fn_call(
instance,
Some((Place::undef(), target)),
&vec![valty],
&[valty],
span,
fn_sig,
)
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/uniform_array_move_out.rs
Original file line number Diff line number Diff line change
@@ -222,7 +222,7 @@ impl RestoreSubsliceArrayMoveOut {
// indices is an integer interval. If all checks pass do the replacent.
// items are Vec<Option<LocalUse, index in source array, source place for init local>>
fn check_and_patch<'tcx>(candidate: Location,
items: &Vec<Option<(&LocalUse, u32, &Place<'tcx>)>>,
items: &[Option<(&LocalUse, u32, &Place<'tcx>)>],
opt_size: Option<u64>,
patch: &mut MirPatch<'tcx>,
dst_place: &Place<'tcx>) {
2 changes: 1 addition & 1 deletion src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ impl<'a> AstValidator<'a> {
}
}

fn check_late_bound_lifetime_defs(&self, params: &Vec<GenericParam>) {
fn check_late_bound_lifetime_defs(&self, params: &[GenericParam]) {
// Check only lifetime parameters are present and that the lifetime
// parameters that are present have no bounds.
let non_lt_param_spans: Vec<_> = params.iter().filter_map(|param| match param.kind {
2 changes: 1 addition & 1 deletion src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
@@ -783,7 +783,7 @@ impl<'a> Resolver<'a> {
}
};
let ident = Ident::new(Symbol::intern(name), span);
self.lookup_typo_candidate(&vec![ident], MacroNS, is_macro, span)
self.lookup_typo_candidate(&[ident], MacroNS, is_macro, span)
});

if let Some(suggestion) = suggestion {
Original file line number Diff line number Diff line change
@@ -15,15 +15,15 @@ pub fn target() -> TargetResult {
base.max_atomic_width = Some(128);

Ok(Target {
llvm_target: "aarch64-unknown-fuchsia".to_string(),
llvm_target: "aarch64-fuchsia".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "fuchsia".to_string(),
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
target_vendor: "".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
2 changes: 1 addition & 1 deletion src/librustc_target/spec/fuchsia_base.rs
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ pub fn opts() -> TargetOptions {
executables: true,
target_family: Some("unix".to_string()),
linker_is_gnu: true,
has_rpath: true,
has_rpath: false,
pre_link_args: args,
position_independent_executables: true,
has_elf_tls: true,
4 changes: 2 additions & 2 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
@@ -332,8 +332,8 @@ supported_targets! {
("x86_64-apple-darwin", x86_64_apple_darwin),
("i686-apple-darwin", i686_apple_darwin),

("aarch64-unknown-fuchsia", aarch64_unknown_fuchsia),
("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia),
("aarch64-fuchsia", aarch64_fuchsia),
("x86_64-fuchsia", x86_64_fuchsia),

("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc),

Original file line number Diff line number Diff line change
@@ -18,15 +18,15 @@ pub fn target() -> TargetResult {
base.stack_probes = true;

Ok(Target {
llvm_target: "x86_64-unknown-fuchsia".to_string(),
llvm_target: "x86_64-fuchsia".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
arch: "x86_64".to_string(),
target_os: "fuchsia".to_string(),
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
target_vendor: "".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})
11 changes: 11 additions & 0 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
@@ -319,6 +319,17 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
E0053,
"method `{}` has an incompatible type for trait",
trait_m.ident);
if let TypeError::Mutability = terr {
if let Some(trait_err_span) = trait_err_span {
if let Ok(trait_err_str) = tcx.sess.codemap().span_to_snippet(trait_err_span) {
diag.span_suggestion(
impl_err_span,
"consider change the type to match the mutability in trait",
format!("{}", trait_err_str),
);
}
}
}

infcx.note_type_err(&mut diag,
&cause,
6 changes: 3 additions & 3 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
@@ -2690,7 +2690,7 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
for it in &implementor.inner_impl().items {
if let clean::TypedefItem(ref tydef, _) = it.inner {
write!(w, "<span class=\"where fmt-newline\"> ")?;
assoc_type(w, it, &vec![], Some(&tydef.type_), AssocItemLink::Anchor(None))?;
assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None))?;
write!(w, ";</span>")?;
}
}
@@ -3040,7 +3040,7 @@ fn assoc_const(w: &mut fmt::Formatter,
}

fn assoc_type<W: fmt::Write>(w: &mut W, it: &clean::Item,
bounds: &Vec<clean::GenericBound>,
bounds: &[clean::GenericBound],
default: Option<&clean::Type>,
link: AssocItemLink) -> fmt::Result {
write!(w, "type <a href='{}' class=\"type\">{}</a>",
@@ -3749,7 +3749,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
for it in &impl_.items {
if let clean::TypedefItem(ref tydef, _) = it.inner {
out.push_str("<span class=\"where fmt-newline\"> ");
assoc_type(&mut out, it, &vec![],
assoc_type(&mut out, it, &[],
Some(&tydef.type_),
AssocItemLink::GotoSource(t_did, &FxHashSet()))?;
out.push_str(";</span>");
5 changes: 5 additions & 0 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
@@ -1276,6 +1276,11 @@ impl<T> JoinInner<T> {
#[stable(feature = "rust1", since = "1.0.0")]
pub struct JoinHandle<T>(JoinInner<T>);

#[stable(feature = "joinhandle_impl_send_sync", since = "1.29.0")]
unsafe impl<T> Send for JoinHandle<T> {}
#[stable(feature = "joinhandle_impl_send_sync", since = "1.29.0")]
unsafe impl<T> Sync for JoinHandle<T> {}

impl<T> JoinHandle<T> {
/// Extracts a handle to the underlying thread.
///
36 changes: 35 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
@@ -6514,6 +6514,39 @@ impl<'a> Parser<'a> {
})
}

fn parse_crate_name_with_dashes(&mut self) -> PResult<'a, ast::Ident> {
let error_msg = "crate name using dashes are not valid in `extern crate` statements";
let suggestion_msg = "if the original crate name uses dashes you need to use underscores \
in the code";
let mut ident = self.parse_ident()?;
let mut idents = vec![];
let mut replacement = vec![];
let mut fixed_crate_name = false;
// Accept `extern crate name-like-this` for better diagnostics
let dash = token::Token::BinOp(token::BinOpToken::Minus);
if self.token == dash { // Do not include `-` as part of the expected tokens list
while self.eat(&dash) {
fixed_crate_name = true;
replacement.push((self.prev_span, "_".to_string()));
idents.push(self.parse_ident()?);
}
}
if fixed_crate_name {
let fixed_name_sp = ident.span.to(idents.last().unwrap().span);
let mut fixed_name = format!("{}", ident.name);
for part in idents {
fixed_name.push_str(&format!("_{}", part.name));
}
ident = Ident::from_str(&fixed_name).with_span_pos(fixed_name_sp);

let mut err = self.struct_span_err(fixed_name_sp, error_msg);
err.span_label(fixed_name_sp, "dash-separated idents are not valid");
err.multipart_suggestion(suggestion_msg, replacement);
err.emit();
}
Ok(ident)
}

/// Parse extern crate links
///
/// # Examples
@@ -6525,7 +6558,8 @@ impl<'a> Parser<'a> {
visibility: Visibility,
attrs: Vec<Attribute>)
-> PResult<'a, P<Item>> {
let orig_name = self.parse_ident()?;
// Accept `extern crate name-like-this` for better diagnostics
let orig_name = self.parse_crate_name_with_dashes()?;
let (item_name, orig_name) = if let Some(rename) = self.parse_rename()? {
(rename, Some(orig_name.name))
} else {
2 changes: 1 addition & 1 deletion src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
@@ -3065,7 +3065,7 @@ impl<'a> State<'a> {
unsafety: ast::Unsafety,
decl: &ast::FnDecl,
name: Option<ast::Ident>,
generic_params: &Vec<ast::GenericParam>)
generic_params: &[ast::GenericParam])
-> io::Result<()> {
self.ibox(INDENT_UNIT)?;
if !generic_params.is_empty() {
9 changes: 4 additions & 5 deletions src/libsyntax_pos/lib.rs
Original file line number Diff line number Diff line change
@@ -632,15 +632,14 @@ impl MultiSpan {
/// `SpanLabel` instances with empty labels.
pub fn span_labels(&self) -> Vec<SpanLabel> {
let is_primary = |span| self.primary_spans.contains(&span);
let mut span_labels = vec![];

for &(span, ref label) in &self.span_labels {
span_labels.push(SpanLabel {
let mut span_labels = self.span_labels.iter().map(|&(span, ref label)|
SpanLabel {
span,
is_primary: is_primary(span),
label: Some(label.clone())
});
}
}
).collect::<Vec<_>>();

for &span in &self.primary_spans {
if !span_labels.iter().any(|sl| sl.span == span) {
Original file line number Diff line number Diff line change
@@ -8,12 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(repeat_generic_slice)]
extern crate krate-name-here;
//~^ ERROR crate name using dashes are not valid in `extern crate` statements
//~| ERROR can't find crate for `krate_name_here`

fn main() {
assert_eq!([1, 2].repeat(2), vec![1, 2, 1, 2]);
assert_eq!([1, 2, 3, 4].repeat(0), vec![]);
assert_eq!([1, 2, 3, 4].repeat(1), vec![1, 2, 3, 4]);
assert_eq!([1, 2, 3, 4].repeat(3),
vec![1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]);
}
fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/bad-crate-name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: crate name using dashes are not valid in `extern crate` statements
--> $DIR/bad-crate-name.rs:11:14
|
LL | extern crate krate-name-here;
| ^^^^^^^^^^^^^^^ dash-separated idents are not valid
help: if the original crate name uses dashes you need to use underscores in the code
|
LL | extern crate krate_name_here;
| ^ ^

error[E0463]: can't find crate for `krate_name_here`
--> $DIR/bad-crate-name.rs:11:1
|
LL | extern crate krate-name-here;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0463`.
4 changes: 4 additions & 0 deletions src/test/ui/issue-13033.stderr
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ LL | fn bar(&mut self, other: &Foo) {}
|
= note: expected type `fn(&mut Baz, &mut dyn Foo)`
found type `fn(&mut Baz, &dyn Foo)`
help: consider change the type to match the mutability in trait
|
LL | fn bar(&mut self, other: &mut Foo) {}
| ^^^^^^^^

error: aborting due to previous error

4 changes: 4 additions & 0 deletions src/test/ui/mismatched_types/E0053.stderr
Original file line number Diff line number Diff line change
@@ -21,6 +21,10 @@ LL | fn bar(&mut self) { }
|
= note: expected type `fn(&Bar)`
found type `fn(&mut Bar)`
help: consider change the type to match the mutability in trait
|
LL | fn bar(&self) { }
| ^^^^^

error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -21,6 +21,10 @@ LL | fn bar(&mut self, bar: &Bar) { } //~ ERROR incompatible type
|
= note: expected type `fn(&mut Bar, &mut Bar)`
found type `fn(&mut Bar, &Bar)`
help: consider change the type to match the mutability in trait
|
LL | fn bar(&mut self, bar: &mut Bar) { } //~ ERROR incompatible type
| ^^^^^^^^

error: aborting due to 2 previous errors

4 changes: 2 additions & 2 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
@@ -46,9 +46,9 @@ static HOSTS: &'static [&'static str] = &[

static TARGETS: &'static [&'static str] = &[
"aarch64-apple-ios",
"aarch64-fuchsia",
"aarch64-linux-android",
"aarch64-unknown-cloudabi",
"aarch64-unknown-fuchsia",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"arm-linux-androideabi",
@@ -101,14 +101,14 @@ static TARGETS: &'static [&'static str] = &[
"wasm32-unknown-unknown",
"x86_64-apple-darwin",
"x86_64-apple-ios",
"x86_64-fuchsia",
"x86_64-linux-android",
"x86_64-pc-windows-gnu",
"x86_64-pc-windows-msvc",
"x86_64-rumprun-netbsd",
"x86_64-sun-solaris",
"x86_64-unknown-cloudabi",
"x86_64-unknown-freebsd",
"x86_64-unknown-fuchsia",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-gnux32",
"x86_64-unknown-linux-musl",