diff --git a/mk/crates.mk b/mk/crates.mk index b7bb7c1083dd8..cf8a85e11fdfd 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -49,16 +49,17 @@ # automatically generated for all stage/host/target combinations. ################################################################################ -TARGET_CRATES := libc std flate arena term \ - serialize getopts collections test rand \ - log graphviz core rbml alloc \ +TARGET_CRATES := libc std term \ + getopts collections test rand \ + core alloc \ rustc_unicode rustc_bitflags \ alloc_system alloc_jemalloc RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \ rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \ rustc_data_structures rustc_front rustc_platform_intrinsics \ rustc_plugin rustc_metadata rustc_passes -HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros +HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros \ + flate arena graphviz rbml log serialize TOOLS := compiletest rustdoc rustc rustbook error_index_generator DEPS_core := @@ -84,8 +85,8 @@ DEPS_log := std DEPS_num := std DEPS_rbml := std log serialize DEPS_serialize := std log -DEPS_term := std log -DEPS_test := std getopts serialize rbml term native:rust_test_helpers +DEPS_term := std +DEPS_test := std getopts term native:rust_test_helpers DEPS_syntax := std term serialize log arena libc rustc_bitflags DEPS_syntax_ext := syntax fmt_macros diff --git a/src/bootstrap/build/sanity.rs b/src/bootstrap/build/sanity.rs index 40f4c7076092d..6ac581a7c6949 100644 --- a/src/bootstrap/build/sanity.rs +++ b/src/bootstrap/build/sanity.rs @@ -79,7 +79,7 @@ pub fn check(build: &mut Build) { } // Make sure musl-root is valid if specified - if target.contains("musl") { + if target.contains("musl") && target.contains("x86_64") { match build.config.musl_root { Some(ref root) => { if fs::metadata(root.join("lib/libc.a")).is_err() { diff --git a/src/doc/book/vectors.md b/src/doc/book/vectors.md index f5a543d75b1b4..ceb6b3c003e52 100644 --- a/src/doc/book/vectors.md +++ b/src/doc/book/vectors.md @@ -115,6 +115,36 @@ for i in v { } ``` +Note: You cannot use the vector again once you have iterated by taking ownership of the vector. +You can iterate the vector multiple times by taking a reference to the vector whilst iterating. +For example, the following code does not compile. + +```rust,ignore +let mut v = vec![1, 2, 3, 4, 5]; + +for i in v { + println!("Take ownership of the vector and its element {}", i); +} + +for i in v { + println!("Take ownership of the vector and its element {}", i); +} +``` + +Whereas the following works perfectly, + +```rust +let mut v = vec![1, 2, 3, 4, 5]; + +for i in &v { + println!("This is a reference to {}", i); +} + +for i in &v { + println!("This is a reference to {}", i); +} +``` + Vectors have many more useful methods, which you can read about in [their API documentation][vec]. diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index a555b8592912e..2d898b50e0c3a 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1095,8 +1095,6 @@ fn eq_slice(a: &str, b: &str) -> bool { /// faster than comparing each byte in a loop. #[inline] unsafe fn cmp_slice(a: &str, b: &str, len: usize) -> i32 { - // NOTE: In theory n should be libc::size_t and not usize, but libc is not available here - #[allow(improper_ctypes)] extern { fn memcmp(s1: *const i8, s2: *const i8, n: usize) -> i32; } memcmp(a.as_ptr() as *const i8, b.as_ptr() as *const i8, len) } diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index fe059076926ee..884f4490d9f4b 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -92,11 +92,6 @@ #![deny(missing_docs)] #![feature(staged_api)] #![feature(str_char)] -#![cfg_attr(test, feature(rustc_private))] - -#[cfg(test)] -#[macro_use] -extern crate log; use self::Name::*; use self::HasArg::*; @@ -1544,8 +1539,6 @@ Options: let generated_usage = usage("Usage: fruits", &optgroups); - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", generated_usage); assert_eq!(generated_usage, expected); } @@ -1573,8 +1566,6 @@ Options: let usage = usage("Usage: fruits", &optgroups); - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", usage); assert!(usage == expected) } @@ -1601,8 +1592,6 @@ Options: let usage = usage("Usage: fruits", &optgroups); - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", usage); assert!(usage == expected) } @@ -1617,8 +1606,6 @@ Options: let expected = "Usage: fruits -b VAL [-a VAL] [-k] [-p [VAL]] [-l VAL]..".to_string(); let generated_usage = short_usage("fruits", &optgroups); - debug!("expected: <<{}>>", expected); - debug!("generated: <<{}>>", generated_usage); assert_eq!(generated_usage, expected); } diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 79c73a83ee7e0..20da15834966e 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -161,13 +161,17 @@ pub fn addr_of(ccx: &CrateContext, gv } -fn const_deref_ptr(cx: &CrateContext, v: ValueRef) -> ValueRef { +/// Deref a constant pointer +fn load_const(cx: &CrateContext, v: ValueRef, t: Ty) -> ValueRef { let v = match cx.const_unsized().borrow().get(&v) { Some(&v) => v, None => v }; - unsafe { - llvm::LLVMGetInitializer(v) + let d = unsafe { llvm::LLVMGetInitializer(v) }; + if t.is_bool() { + unsafe { llvm::LLVMConstTrunc(d, Type::i1(cx).to_ref()) } + } else { + d } } @@ -178,7 +182,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, match ty.builtin_deref(true, ty::NoPreference) { Some(mt) => { if type_is_sized(cx.tcx(), mt.ty) { - (const_deref_ptr(cx, v), mt.ty) + (load_const(cx, v, mt.ty), mt.ty) } else { // Derefing a fat pointer does not change the representation, // just the type to the unsized contents. @@ -588,7 +592,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let is_float = ty.is_fp(); let signed = ty.is_signed(); - let (te2, _) = try!(const_expr(cx, &e2, param_substs, fn_args, trueconst)); + let (te2, ty2) = try!(const_expr(cx, &e2, param_substs, fn_args, trueconst)); + debug!("const_expr_unadjusted: te2={}, ty={:?}", + cx.tn().val_to_string(te2), + ty2); try!(check_binary_expr_validity(cx, e, ty, te1, te2, trueconst)); @@ -671,13 +678,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, }; let (arr, len) = match bt.sty { ty::TyArray(_, u) => (bv, C_uint(cx, u)), - ty::TySlice(_) | ty::TyStr => { + ty::TySlice(..) | ty::TyStr => { let e1 = const_get_elt(cx, bv, &[0]); - (const_deref_ptr(cx, e1), const_get_elt(cx, bv, &[1])) + (load_const(cx, e1, bt), const_get_elt(cx, bv, &[1])) }, ty::TyRef(_, mt) => match mt.ty.sty { ty::TyArray(_, u) => { - (const_deref_ptr(cx, bv), C_uint(cx, u)) + (load_const(cx, bv, mt.ty), C_uint(cx, u)) }, _ => cx.sess().span_bug(base.span, &format!("index-expr base must be a vector \ @@ -891,7 +898,8 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, expr::trans_def_fn_unadjusted(cx, e, def, param_substs).val } Def::Const(def_id) | Def::AssociatedConst(def_id) => { - const_deref_ptr(cx, try!(get_const_val(cx, def_id, e, param_substs))) + load_const(cx, try!(get_const_val(cx, def_id, e, param_substs)), + ety) } Def::Variant(enum_did, variant_did) => { let vinfo = cx.tcx().lookup_adt_def(enum_did).variant_with_id(variant_did); diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 1cadc4e476ac4..c07871a4029ca 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -616,15 +616,19 @@ a.test-arrow { } .sidebar .location { - float: left; + float: right; margin: 0px; - padding: 5px; - width: 60%; + padding: 3px 10px 1px 10px; + min-height: 39px; background: inherit; text-align: left; font-size: 24px; } + .sidebar .location:empty { + padding: 0; + } + .sidebar img { width: 35px; margin-top: 5px; diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 587d1d422587b..358d63ae4f987 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -179,7 +179,7 @@ pub trait AsciiExt { /// /// assert_eq!(upper, "A"); /// ``` - #[unstable(feature = "ascii", issue = "27809")] + #[stable(feature = "into_ascii", since = "1.8.0")] fn into_ascii_uppercase(self) -> Self::Owned where Self: Sized { self.to_ascii_uppercase() } @@ -202,7 +202,7 @@ pub trait AsciiExt { /// /// assert_eq!(lower, "a"); /// ``` - #[unstable(feature = "ascii", issue = "27809")] + #[stable(feature = "into_ascii", since = "1.8.0")] fn into_ascii_lowercase(self) -> Self::Owned where Self: Sized { self.to_ascii_lowercase() } @@ -210,7 +210,7 @@ pub trait AsciiExt { /// Implement `into_ascii_lowercase` and `into_ascii_uppercase` without memory allocation, /// defer other methods to `str`. -#[unstable(feature = "ascii", issue = "27809")] +#[stable(feature = "into_ascii", since = "1.8.0")] impl AsciiExt for String { type Owned = Self; @@ -242,7 +242,7 @@ impl AsciiExt for String { /// Implement `into_ascii_lowercase` and `into_ascii_uppercase` without memory allocation, /// defer other methods to `[u8]`. -#[unstable(feature = "ascii", issue = "27809")] +#[stable(feature = "into_ascii", since = "1.8.0")] impl AsciiExt for Vec { type Owned = Self; diff --git a/src/libstd/build.rs b/src/libstd/build.rs index a1144a964fd37..c60ec4d3655b0 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -28,7 +28,7 @@ fn main() { } if target.contains("unknown-linux") { - if target.contains("musl") { + if target.contains("musl") && target.contains("x86_64") { println!("cargo:rustc-link-lib=static=unwind"); } else { println!("cargo:rustc-link-lib=dl"); diff --git a/src/libtest/Cargo.toml b/src/libtest/Cargo.toml index 96a84496b9c9c..ecbd5a9c0f509 100644 --- a/src/libtest/Cargo.toml +++ b/src/libtest/Cargo.toml @@ -11,4 +11,3 @@ crate-type = ["dylib", "rlib"] [dependencies] getopts = { path = "../libgetopts" } term = { path = "../libterm" } -serialize = { path = "../libserialize" } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 7536ab9c5afc6..11d2a3e65c8be 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -42,8 +42,6 @@ #![feature(staged_api)] extern crate getopts; -extern crate serialize; -extern crate serialize as rustc_serialize; extern crate term; extern crate libc; @@ -56,7 +54,6 @@ use self::NamePadding::*; use self::OutputLocation::*; use stats::Stats; -use serialize::Encodable; use std::boxed::FnBox; use term::Terminal; @@ -215,7 +212,7 @@ pub struct TestDescAndFn { pub testfn: TestFn, } -#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug, Copy)] +#[derive(Clone, PartialEq, Debug, Copy)] pub struct Metric { value: f64, noise: f64, diff --git a/src/test/compile-fail/derive-no-std-not-supported.rs b/src/test/compile-fail-fulldeps/derive-no-std-not-supported.rs similarity index 100% rename from src/test/compile-fail/derive-no-std-not-supported.rs rename to src/test/compile-fail-fulldeps/derive-no-std-not-supported.rs diff --git a/src/test/compile-fail/dropck_tarena_cycle_checked.rs b/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs similarity index 100% rename from src/test/compile-fail/dropck_tarena_cycle_checked.rs rename to src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs diff --git a/src/test/compile-fail/dropck_tarena_unsound_drop.rs b/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs similarity index 100% rename from src/test/compile-fail/dropck_tarena_unsound_drop.rs rename to src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs diff --git a/src/test/run-pass/conditional-debug-macro-off.rs b/src/test/run-pass-fulldeps/conditional-debug-macro-off.rs similarity index 100% rename from src/test/run-pass/conditional-debug-macro-off.rs rename to src/test/run-pass-fulldeps/conditional-debug-macro-off.rs diff --git a/src/test/run-pass/deprecated-derive.rs b/src/test/run-pass-fulldeps/deprecated-derive.rs similarity index 100% rename from src/test/run-pass/deprecated-derive.rs rename to src/test/run-pass-fulldeps/deprecated-derive.rs diff --git a/src/test/run-pass/derive-no-std.rs b/src/test/run-pass-fulldeps/derive-no-std.rs similarity index 100% rename from src/test/run-pass/derive-no-std.rs rename to src/test/run-pass-fulldeps/derive-no-std.rs diff --git a/src/test/run-pass/deriving-encodable-decodable-box.rs b/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs similarity index 100% rename from src/test/run-pass/deriving-encodable-decodable-box.rs rename to src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs diff --git a/src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs b/src/test/run-pass-fulldeps/deriving-encodable-decodable-cell-refcell.rs similarity index 100% rename from src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs rename to src/test/run-pass-fulldeps/deriving-encodable-decodable-cell-refcell.rs diff --git a/src/test/run-pass/deriving-global.rs b/src/test/run-pass-fulldeps/deriving-global.rs similarity index 100% rename from src/test/run-pass/deriving-global.rs rename to src/test/run-pass-fulldeps/deriving-global.rs diff --git a/src/test/run-pass/dropck_tarena_sound_drop.rs b/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs similarity index 100% rename from src/test/run-pass/dropck_tarena_sound_drop.rs rename to src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs diff --git a/src/test/run-pass/empty-struct-braces-derive.rs b/src/test/run-pass-fulldeps/empty-struct-braces-derive.rs similarity index 100% rename from src/test/run-pass/empty-struct-braces-derive.rs rename to src/test/run-pass-fulldeps/empty-struct-braces-derive.rs diff --git a/src/test/run-pass/extern-mod-syntax.rs b/src/test/run-pass-fulldeps/extern-mod-syntax.rs similarity index 100% rename from src/test/run-pass/extern-mod-syntax.rs rename to src/test/run-pass-fulldeps/extern-mod-syntax.rs diff --git a/src/test/run-pass/issue-11881.rs b/src/test/run-pass-fulldeps/issue-11881.rs similarity index 100% rename from src/test/run-pass/issue-11881.rs rename to src/test/run-pass-fulldeps/issue-11881.rs diff --git a/src/test/run-pass/issue-14021.rs b/src/test/run-pass-fulldeps/issue-14021.rs similarity index 100% rename from src/test/run-pass/issue-14021.rs rename to src/test/run-pass-fulldeps/issue-14021.rs diff --git a/src/test/run-pass/issue-15924.rs b/src/test/run-pass-fulldeps/issue-15924.rs similarity index 100% rename from src/test/run-pass/issue-15924.rs rename to src/test/run-pass-fulldeps/issue-15924.rs diff --git a/src/test/run-pass/issue-24972.rs b/src/test/run-pass-fulldeps/issue-24972.rs similarity index 100% rename from src/test/run-pass/issue-24972.rs rename to src/test/run-pass-fulldeps/issue-24972.rs diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass-fulldeps/issue-2804.rs similarity index 100% rename from src/test/run-pass/issue-2804.rs rename to src/test/run-pass-fulldeps/issue-2804.rs diff --git a/src/test/run-pass/issue-4016.rs b/src/test/run-pass-fulldeps/issue-4016.rs similarity index 100% rename from src/test/run-pass/issue-4016.rs rename to src/test/run-pass-fulldeps/issue-4016.rs diff --git a/src/test/run-pass/issue-4036.rs b/src/test/run-pass-fulldeps/issue-4036.rs similarity index 100% rename from src/test/run-pass/issue-4036.rs rename to src/test/run-pass-fulldeps/issue-4036.rs diff --git a/src/test/run-pass/logging-enabled-debug.rs b/src/test/run-pass-fulldeps/logging-enabled-debug.rs similarity index 100% rename from src/test/run-pass/logging-enabled-debug.rs rename to src/test/run-pass-fulldeps/logging-enabled-debug.rs diff --git a/src/test/run-pass/logging-enabled.rs b/src/test/run-pass-fulldeps/logging-enabled.rs similarity index 100% rename from src/test/run-pass/logging-enabled.rs rename to src/test/run-pass-fulldeps/logging-enabled.rs diff --git a/src/test/run-pass/logging-right-crate.rs b/src/test/run-pass-fulldeps/logging-right-crate.rs similarity index 100% rename from src/test/run-pass/logging-right-crate.rs rename to src/test/run-pass-fulldeps/logging-right-crate.rs diff --git a/src/test/run-pass/logging-separate-lines.rs b/src/test/run-pass-fulldeps/logging-separate-lines.rs similarity index 100% rename from src/test/run-pass/logging-separate-lines.rs rename to src/test/run-pass-fulldeps/logging-separate-lines.rs diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass-fulldeps/placement-new-arena.rs similarity index 100% rename from src/test/run-pass/placement-new-arena.rs rename to src/test/run-pass-fulldeps/placement-new-arena.rs diff --git a/src/test/run-pass/regions-mock-tcx.rs b/src/test/run-pass-fulldeps/regions-mock-tcx.rs similarity index 100% rename from src/test/run-pass/regions-mock-tcx.rs rename to src/test/run-pass-fulldeps/regions-mock-tcx.rs diff --git a/src/test/run-pass/rust-log-filter.rs b/src/test/run-pass-fulldeps/rust-log-filter.rs similarity index 100% rename from src/test/run-pass/rust-log-filter.rs rename to src/test/run-pass-fulldeps/rust-log-filter.rs diff --git a/src/test/run-pass/issue-30891.rs b/src/test/run-pass/issue-30891.rs new file mode 100644 index 0000000000000..622e5fa544ec9 --- /dev/null +++ b/src/test/run-pass/issue-30891.rs @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const ERROR_CONST: bool = true; + +fn get() -> bool { + false || ERROR_CONST +} + +pub fn main() { + assert_eq!(get(), true); +} diff --git a/src/test/rustdoc/issue-27362.rs b/src/test/rustdoc/issue-27362.rs index 179778fd1283f..b28fb7ec47a8c 100644 --- a/src/test/rustdoc/issue-27362.rs +++ b/src/test/rustdoc/issue-27362.rs @@ -10,6 +10,7 @@ // aux-build:issue-27362.rs // ignore-cross-compile +// ignore-test This test fails on beta/stable #32019 extern crate issue_27362; pub use issue_27362 as quux;