Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #32038

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9bf73d2
Explained the difference between ownership iteration and reference it…
srinivasreddy Mar 2, 2016
a3c9afa
addressed review comments - grammar corrections, space additions
srinivasreddy Mar 2, 2016
2dc723d
made print message similar across two loops
srinivasreddy Mar 2, 2016
d3ae29d
Ignore a rustdoc test that does not work on beta
brson Mar 3, 2016
48fd993
std: Stabilize `into_*` ASCII methods
alexcrichton Mar 3, 2016
311ff03
Responsive layout correction.
Mar 3, 2016
d2df551
added ignore
srinivasreddy Mar 3, 2016
4da9e9f
mk: Distribute fewer TARGET_CRATES
alexcrichton Mar 2, 2016
ddd2e99
[rustbuild] fix cross compilation of std for mips(el)-linux-musl
Mar 3, 2016
cf29344
truncate i8-s to i1-s when loading constants
arielb1 Mar 3, 2016
633cd84
`usize` is now a proper ctype, so fix cmp_slice
ubsan Mar 4, 2016
75c14e1
Rollup merge of #32002 - srinivasreddy:vector_doc, r=Manishearth
Manishearth Mar 4, 2016
e3a0ae8
Rollup merge of #32009 - alexcrichton:trim-fulldeps, r=brson
Manishearth Mar 4, 2016
d5b66f7
Rollup merge of #32017 - brson:ignoretest, r=nikomatsakis
Manishearth Mar 4, 2016
a8a42c3
Rollup merge of #32020 - alexcrichton:stabilize-into-ascii, r=brson
Manishearth Mar 4, 2016
5d9c6c1
Rollup merge of #32022 - gohyda:master, r=alexcrichton
Manishearth Mar 4, 2016
a022de6
Rollup merge of #32027 - japaric:rustbuild-mips, r=alexcrichton
Manishearth Mar 4, 2016
714301a
Rollup merge of #32032 - arielb1:load-const, r=eddyb
Manishearth Mar 4, 2016
860e1fd
Rollup merge of #32035 - ubsan:master, r=bluss
Manishearth Mar 4, 2016
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
13 changes: 7 additions & 6 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 :=
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/build/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
30 changes: 30 additions & 0 deletions src/doc/book/vectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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].

Expand Down
2 changes: 0 additions & 2 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 0 additions & 13 deletions src/libgetopts/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -1544,8 +1539,6 @@ Options:

let generated_usage = usage("Usage: fruits", &optgroups);

debug!("expected: <<{}>>", expected);
debug!("generated: <<{}>>", generated_usage);
assert_eq!(generated_usage, expected);
}

Expand Down Expand Up @@ -1573,8 +1566,6 @@ Options:

let usage = usage("Usage: fruits", &optgroups);

debug!("expected: <<{}>>", expected);
debug!("generated: <<{}>>", usage);
assert!(usage == expected)
}

Expand All @@ -1601,8 +1592,6 @@ Options:

let usage = usage("Usage: fruits", &optgroups);

debug!("expected: <<{}>>", expected);
debug!("generated: <<{}>>", usage);
assert!(usage == expected)
}

Expand All @@ -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);
}

Expand Down
26 changes: 17 additions & 9 deletions src/librustc_trans/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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.
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -202,15 +202,15 @@ 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()
}
}

/// 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;

Expand Down Expand Up @@ -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<u8> {
type Owned = Self;

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion src/libtest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ crate-type = ["dylib", "rlib"]
[dependencies]
getopts = { path = "../libgetopts" }
term = { path = "../libterm" }
serialize = { path = "../libserialize" }
5 changes: 1 addition & 4 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -56,7 +54,6 @@ use self::NamePadding::*;
use self::OutputLocation::*;

use stats::Stats;
use serialize::Encodable;
use std::boxed::FnBox;
use term::Terminal;

Expand Down Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions src/test/run-pass/issue-30891.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

const ERROR_CONST: bool = true;

fn get() -> bool {
false || ERROR_CONST
}

pub fn main() {
assert_eq!(get(), true);
}
1 change: 1 addition & 0 deletions src/test/rustdoc/issue-27362.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down