diff options
43 files changed, 185 insertions, 113 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock index 09baaeadaee..8594e4ff130 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -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" diff --git a/src/ci/docker/dist-various-2/Dockerfile b/src/ci/docker/dist-various-2/Dockerfile index e8d6c12de44..7adb32efa1d 100644 --- a/src/ci/docker/dist-various-2/Dockerfile +++ b/src/ci/docker/dist-various-2/Dockerfile @@ -34,12 +34,12 @@ 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++ \ @@ -47,8 +47,8 @@ ENV \ 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 diff --git a/src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh b/src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh index ef8f0c37f8c..ec19f7c4f45 100755 --- a/src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh +++ b/src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh @@ -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 diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs index 91bc778ad4c..618aff963f2 100644 --- a/src/liballoc/tests/lib.rs +++ b/src/liballoc/tests/lib.rs @@ -24,6 +24,7 @@ #![feature(try_reserve)] #![feature(unboxed_closures)] #![feature(exact_chunks)] +#![feature(repeat_generic_slice)] extern crate alloc_system; extern crate core; diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs index 3b7eec38609..df5e18a9a18 100644 --- a/src/liballoc/tests/slice.rs +++ b/src/liballoc/tests/slice.rs @@ -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] + ); +} diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index be82ab44cd1..fe5914c72e1 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -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 /// diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 3b030fc098f..7e2c5d03d6b 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -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> { diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index 656f325b4dd..a17c160c4d0 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -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 { diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 04b725957b6..05361b65641 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -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, diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index 07286f1250c..b8991a0366a 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -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 diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 5c1009fb31f..14cfaa81533 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -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); diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4490b2f3fa9..9fbf4e7c6a0 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -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], @@ -3169,10 +3167,6 @@ mod tests { 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()); diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 77a1129f66d..7b8bbbf4a10 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -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 diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 8300f98fb1c..5f8a2208bb0 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -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, diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 83128ba75d5..aa4f63675d7 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -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, diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index e51caf89ee6..b217e6a8564 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -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 { diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index f2b17584adc..13f0c90e885 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -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); diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 91392ab013d..1592722a0b2 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -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; diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs index a362556717b..2ec85e1c27f 100644 --- a/src/librustc_driver/profile/mod.rs +++ b/src/librustc_driver/profile/mod.rs @@ -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 diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs index 4aaf5eb47f6..ecd2f4d916d 100644 --- a/src/librustc_driver/profile/trace.rs +++ b/src/librustc_driver/profile/trace.rs @@ -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); diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 6bcf0d9eff6..f54626d6a20 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -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) diff --git a/src/librustc_metadata/dynamic_lib.rs b/src/librustc_metadata/dynamic_lib.rs index d7da0d00012..182a071277e 100644 --- a/src/librustc_metadata/dynamic_lib.rs +++ b/src/librustc_metadata/dynamic_lib.rs @@ -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) } } diff --git a/src/librustc_mir/borrow_check/nll/facts.rs b/src/librustc_mir/borrow_check/nll/facts.rs index 2523711f936..8eb052f88e1 100644 --- a/src/librustc_mir/borrow_check/nll/facts.rs +++ b/src/librustc_mir/borrow_check/nll/facts.rs @@ -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 diff --git a/src/librustc_mir/interpret/terminator/drop.rs b/src/librustc_mir/interpret/terminator/drop.rs index c0fafa7f83e..d750c1f47a6 100644 --- a/src/librustc_mir/interpret/terminator/drop.rs +++ b/src/librustc_mir/interpret/terminator/drop.rs @@ -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, ) diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 5019c74742a..7a8c35e7b96 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -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>) { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index f27ca444672..c6bad9e1980 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -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 { diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 0ad652b4710..29b6f958cc1 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -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 { diff --git a/src/librustc_target/spec/aarch64_unknown_fuchsia.rs b/src/librustc_target/spec/aarch64_fuchsia.rs index 4da6724ef62..28baf6f66e7 100644 --- a/src/librustc_target/spec/aarch64_unknown_fuchsia.rs +++ b/src/librustc_target/spec/aarch64_fuchsia.rs @@ -15,7 +15,7 @@ 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(), @@ -23,7 +23,7 @@ pub fn target() -> TargetResult { 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(), diff --git a/src/librustc_target/spec/fuchsia_base.rs b/src/librustc_target/spec/fuchsia_base.rs index 19a66b693f2..b593b835326 100644 --- a/src/librustc_target/spec/fuchsia_base.rs +++ b/src/librustc_target/spec/fuchsia_base.rs @@ -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, diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 9ac6e9835f0..c5d21cdc46a 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -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), diff --git a/src/librustc_target/spec/x86_64_unknown_fuchsia.rs b/src/librustc_target/spec/x86_64_fuchsia.rs index a510ec8eb34..e8fa179887c 100644 --- a/src/librustc_target/spec/x86_64_unknown_fuchsia.rs +++ b/src/librustc_target/spec/x86_64_fuchsia.rs @@ -18,7 +18,7 @@ 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(), @@ -26,7 +26,7 @@ pub fn target() -> TargetResult { 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, }) diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 220dd122b26..55aa38d942e 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -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, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index f137f4acf44..81fef9bf83e 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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>"); diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index f7052e4834a..ae804ad409e 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -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. /// diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 64309dd9b8b..56760546c50 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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 { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index de68780ef2c..0e9b0718b21 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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() { diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 61af70af47d..734f76e4999 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -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) { diff --git a/src/liballoc/repeat-generic-slice.rs b/src/test/ui/bad-crate-name.rs index 5c14ee4fd83..70e1806a20b 100644 --- a/src/liballoc/repeat-generic-slice.rs +++ b/src/test/ui/bad-crate-name.rs @@ -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() {} diff --git a/src/test/ui/bad-crate-name.stderr b/src/test/ui/bad-crate-name.stderr new file mode 100644 index 00000000000..8348badeeeb --- /dev/null +++ b/src/test/ui/bad-crate-name.stderr @@ -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`. diff --git a/src/test/ui/issue-13033.stderr b/src/test/ui/issue-13033.stderr index 2db3cb80a81..f06d7360d85 100644 --- a/src/test/ui/issue-13033.stderr +++ b/src/test/ui/issue-13033.stderr @@ -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 diff --git a/src/test/ui/mismatched_types/E0053.stderr b/src/test/ui/mismatched_types/E0053.stderr index 1b16694bf2c..f707a600f29 100644 --- a/src/test/ui/mismatched_types/E0053.stderr +++ b/src/test/ui/mismatched_types/E0053.stderr @@ -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 diff --git a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr index 28b16641e4d..631af21cac5 100644 --- a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr +++ b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr @@ -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 diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index bb20678d4a1..83b2895e1d6 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -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,6 +101,7 @@ 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", @@ -108,7 +109,6 @@ static TARGETS: &'static [&'static str] = &[ "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", |
