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 10 pull requests #40040

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b2ac1c9
Additional docs for Vec, String, and slice trait impls
mbrubeck Feb 16, 2017
047a215
Set rustdoc --test files' path relative to the current directory
GuillaumeGomez Feb 15, 2017
6091330
Follow rename of mx_handle_wait Magenta syscalls
raphlinus Feb 17, 2017
5205e2f
Normalize labeled and unlabeled breaks
cramertj Feb 15, 2017
0c4c6fd
Rebuild mingw startup objects only when necessary
petrochenkov Feb 18, 2017
4d65622
Properly implement labeled breaks in while conditions
cramertj Feb 16, 2017
56e519d
Add tests for control flow in while condition
cramertj Feb 17, 2017
a611bbc
Rename hir::Label to hir::Destination
cramertj Feb 18, 2017
ec648a1
Fix indentation of error message
sgrif Feb 18, 2017
e606a43
Fix rustdoc test with new file path
GuillaumeGomez Feb 19, 2017
25b1488
Simplify adaptive hashmap
arthurprs Feb 20, 2017
58a9dd3
Add missing urls and examples into Barrier structs
GuillaumeGomez Feb 21, 2017
163698c
Switch Fuchsia to readdir (instead of readdir_r)
raphlinus Feb 21, 2017
689dc26
Clarify thread::Builder::stack_size
matklad Feb 22, 2017
81b9b3c
Update name_bytes, scoop up latest libc
raphlinus Feb 22, 2017
b3ee249
Merge branch 'master' of https://github.com/rust-lang/rust into readdir
raphlinus Feb 22, 2017
958fbc5
Make path separator replacement for subfiles as well
GuillaumeGomez Feb 22, 2017
795f929
Rollup merge of #39859 - GuillaumeGomez:rustdoc-test-relative-path, r…
GuillaumeGomez Feb 22, 2017
3952bb0
Rollup merge of #39864 - cramertj:normalize-breaks, r=nikomatsakis
GuillaumeGomez Feb 22, 2017
8f07320
Rollup merge of #39886 - mbrubeck:doc-edit, r=steveklabnik
GuillaumeGomez Feb 22, 2017
a55c74a
Rollup merge of #39892 - petrochenkov:rt, r=alexcrichton
GuillaumeGomez Feb 22, 2017
fd05cc3
Rollup merge of #39914 - raphlinus:mx_handle_wait, r=alexcrichton
GuillaumeGomez Feb 22, 2017
195579f
Rollup merge of #39940 - sgrif:sg-indentation, r=alexcrichton
GuillaumeGomez Feb 22, 2017
b013fb0
Rollup merge of #39988 - arthurprs:hm-adapt2, r=alexcrichton
GuillaumeGomez Feb 22, 2017
92f1cac
Rollup merge of #40010 - GuillaumeGomez:barrier-docs, r=frewsxcv
GuillaumeGomez Feb 22, 2017
7e544c2
Rollup merge of #40024 - raphlinus:readdir, r=alexcrichton
GuillaumeGomez Feb 22, 2017
708da3e
Rollup merge of #40030 - matklad:stack-docs, r=alexcrichton
GuillaumeGomez Feb 22, 2017
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
34 changes: 21 additions & 13 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::fs::{self, File};
use std::path::{Path, PathBuf};
use std::process::Command;

use build_helper::{output, mtime};
use build_helper::{output, mtime, up_to_date};
use filetime::FileTime;

use util::{exe, libdir, is_dylib, copy};
Expand Down Expand Up @@ -132,21 +132,29 @@ pub fn build_startup_objects(build: &Build, for_compiler: &Compiler, target: &st

let compiler = Compiler::new(0, &build.config.build);
let compiler_path = build.compiler_path(&compiler);
let into = build.sysroot_libdir(for_compiler, target);
t!(fs::create_dir_all(&into));

for file in t!(fs::read_dir(build.src.join("src/rtstartup"))) {
let file = t!(file);
let mut cmd = Command::new(&compiler_path);
build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
.arg("--target").arg(target)
.arg("--emit=obj")
.arg("--out-dir").arg(&into)
.arg(file.path()));
let src_dir = &build.src.join("src/rtstartup");
let dst_dir = &build.native_dir(target).join("rtstartup");
let sysroot_dir = &build.sysroot_libdir(for_compiler, target);
t!(fs::create_dir_all(dst_dir));
t!(fs::create_dir_all(sysroot_dir));

for file in &["rsbegin", "rsend"] {
let src_file = &src_dir.join(file.to_string() + ".rs");
let dst_file = &dst_dir.join(file.to_string() + ".o");
if !up_to_date(src_file, dst_file) {
let mut cmd = Command::new(&compiler_path);
build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
.arg("--target").arg(target)
.arg("--emit=obj")
.arg("--out-dir").arg(dst_dir)
.arg(src_file));
}

copy(dst_file, &sysroot_dir.join(file.to_string() + ".o"));
}

for obj in ["crt2.o", "dllcrt2.o"].iter() {
copy(&compiler_file(build.cc(target), obj), &into.join(obj));
copy(&compiler_file(build.cc(target), obj), &sysroot_dir.join(obj));
}
}

Expand Down
42 changes: 42 additions & 0 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,43 @@ impl hash::Hash for String {
}
}

/// Implements the `+` operator for concatenating two strings.
///
/// This consumes the `String` on the left-hand side and re-uses its buffer (growing it if
/// necessary). This is done to avoid allocating a new `String` and copying the entire contents on
/// every operation, which would lead to `O(n^2)` running time when building an `n`-byte string by
/// repeated concatenation.
///
/// The string on the right-hand side is only borrowed; its contents are copied into the returned
/// `String`.
///
/// # Examples
///
/// Concatenating two `String`s takes the first by value and borrows the second:
///
/// ```
/// let a = String::from("hello");
/// let b = String::from(" world");
/// let c = a + &b;
/// // `a` is moved and can no longer be used here.
/// ```
///
/// If you want to keep using the first `String`, you can clone it and append to the clone instead:
///
/// ```
/// let a = String::from("hello");
/// let b = String::from(" world");
/// let c = a.clone() + &b;
/// // `a` is still valid here.
/// ```
///
/// Concatenating `&str` slices can be done by converting the first to a `String`:
///
/// ```
/// let a = "hello";
/// let b = " world";
/// let c = a.to_string() + b;
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> Add<&'a str> for String {
type Output = String;
Expand All @@ -1640,6 +1677,11 @@ impl<'a> Add<&'a str> for String {
}
}

/// Implements the `+=` operator for appending to a `String`.
///
/// This has the same behavior as the [`push_str()`] method.
///
/// [`push_str()`]: struct.String.html#method.push_str
#[stable(feature = "stringaddassign", since = "1.12.0")]
impl<'a> AddAssign<&'a str> for String {
#[inline]
Expand Down
2 changes: 2 additions & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,7 @@ array_impls! {
30 31 32
}

/// Implements comparison of vectors, lexicographically.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PartialOrd> PartialOrd for Vec<T> {
#[inline]
Expand All @@ -1787,6 +1788,7 @@ impl<T: PartialOrd> PartialOrd for Vec<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Eq> Eq for Vec<T> {}

/// Implements ordering of vectors, lexicographically.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Ord for Vec<T> {
#[inline]
Expand Down
2 changes: 2 additions & 0 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2202,13 +2202,15 @@ impl<A, B> PartialEq<[B]> for [A] where A: PartialEq<B> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Eq> Eq for [T] {}

/// Implements comparison of vectors lexicographically.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Ord for [T] {
fn cmp(&self, other: &[T]) -> Ordering {
SliceOrd::compare(self, other)
}
}

/// Implements comparison of vectors lexicographically.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PartialOrd> PartialOrd for [T] {
fn partial_cmp(&self, other: &[T]) -> Option<Ordering> {
Expand Down
14 changes: 14 additions & 0 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,13 @@ mod traits {
use ops;
use str::eq_slice;

/// Implements ordering of strings.
///
/// Strings are ordered lexicographically by their byte values. This orders Unicode code
/// points based on their positions in the code charts. This is not necessarily the same as
/// "alphabetical" order, which varies by language and locale. Sorting strings according to
/// culturally-accepted standards requires locale-specific data that is outside the scope of
/// the `str` type.
#[stable(feature = "rust1", since = "1.0.0")]
impl Ord for str {
#[inline]
Expand All @@ -1387,6 +1394,13 @@ mod traits {
#[stable(feature = "rust1", since = "1.0.0")]
impl Eq for str {}

/// Implements comparison operations on strings.
///
/// Strings are compared lexicographically by their byte values. This compares Unicode code
/// points based on their positions in the code charts. This is not necessarily the same as
/// "alphabetical" order, which varies by language and locale. Comparing strings according to
/// culturally-accepted standards requires locale-specific data that is outside the scope of
/// the `str` type.
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialOrd for str {
#[inline]
Expand Down
36 changes: 23 additions & 13 deletions src/librustc/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,24 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
// Note that `break` and `continue` statements
// may cause additional edges.

// Is the condition considered part of the loop?
let loopback = self.add_dummy_node(&[pred]); // 1
let cond_exit = self.expr(&cond, loopback); // 2
let expr_exit = self.add_ast_node(expr.id, &[cond_exit]); // 3

// Create expr_exit without pred (cond_exit)
let expr_exit = self.add_ast_node(expr.id, &[]); // 3

// The LoopScope needs to be on the loop_scopes stack while evaluating the
// condition and the body of the loop (both can break out of the loop)
self.loop_scopes.push(LoopScope {
loop_id: expr.id,
continue_index: loopback,
break_index: expr_exit
});

let cond_exit = self.expr(&cond, loopback); // 2

// Add pred (cond_exit) to expr_exit
self.add_contained_edge(cond_exit, expr_exit);

let body_exit = self.block(&body, cond_exit); // 4
self.add_contained_edge(body_exit, loopback); // 5
self.loop_scopes.pop();
Expand Down Expand Up @@ -294,17 +303,17 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
self.add_unreachable_node()
}

hir::ExprBreak(label, ref opt_expr) => {
hir::ExprBreak(destination, ref opt_expr) => {
let v = self.opt_expr(opt_expr, pred);
let loop_scope = self.find_scope(expr, label);
let loop_scope = self.find_scope(expr, destination);
let b = self.add_ast_node(expr.id, &[v]);
self.add_exiting_edge(expr, b,
loop_scope, loop_scope.break_index);
self.add_unreachable_node()
}

hir::ExprAgain(label) => {
let loop_scope = self.find_scope(expr, label);
hir::ExprAgain(destination) => {
let loop_scope = self.find_scope(expr, destination);
let a = self.add_ast_node(expr.id, &[pred]);
self.add_exiting_edge(expr, a,
loop_scope, loop_scope.continue_index);
Expand Down Expand Up @@ -579,17 +588,18 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {

fn find_scope(&self,
expr: &hir::Expr,
label: Option<hir::Label>) -> LoopScope {
match label {
None => *self.loop_scopes.last().unwrap(),
Some(label) => {
destination: hir::Destination) -> LoopScope {

match destination.loop_id.into() {
Ok(loop_id) => {
for l in &self.loop_scopes {
if l.loop_id == label.loop_id {
if l.loop_id == loop_id {
return *l;
}
}
span_bug!(expr.span, "no loop scope for id {}", label.loop_id);
span_bug!(expr.span, "no loop scope for id {}", loop_id);
}
Err(err) => span_bug!(expr.span, "loop scope error: {}", err)
}
}
}
24 changes: 14 additions & 10 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,18 +1006,22 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
ExprPath(ref qpath) => {
visitor.visit_qpath(qpath, expression.id, expression.span);
}
ExprBreak(None, ref opt_expr) => {
ExprBreak(label, ref opt_expr) => {
label.ident.map(|ident| {
if let Ok(loop_id) = label.loop_id.into() {
visitor.visit_def_mention(Def::Label(loop_id));
}
visitor.visit_name(ident.span, ident.node.name);
});
walk_list!(visitor, visit_expr, opt_expr);
}
ExprBreak(Some(label), ref opt_expr) => {
visitor.visit_def_mention(Def::Label(label.loop_id));
visitor.visit_name(label.span, label.name);
walk_list!(visitor, visit_expr, opt_expr);
}
ExprAgain(None) => {}
ExprAgain(Some(label)) => {
visitor.visit_def_mention(Def::Label(label.loop_id));
visitor.visit_name(label.span, label.name);
ExprAgain(label) => {
label.ident.map(|ident| {
if let Ok(loop_id) = label.loop_id.into() {
visitor.visit_def_mention(Def::Label(loop_id));
}
visitor.visit_name(ident.span, ident.node.name);
});
}
ExprRet(ref optional_expression) => {
walk_list!(visitor, visit_expr, optional_expression);
Expand Down
Loading