Skip to content

Commit

Permalink
Auto merge of rust-lang#47644 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Jan 21, 2018
2 parents 97520cc + dcbf0bf commit ff2a7c8
Show file tree
Hide file tree
Showing 31 changed files with 1,935 additions and 188 deletions.
5 changes: 3 additions & 2 deletions .mailmap
Expand Up @@ -41,11 +41,12 @@ Boris Egorov <jightuse@gmail.com> <egorov@linux.com>
Brandon Sanderson <singingboyo@gmail.com> Brandon Sanderson <singingboyo@hotmail.com>
Brett Cannon <brett@python.org> Brett Cannon <brettcannon@users.noreply.github.com>
Brian Anderson <banderson@mozilla.com> <andersrb@gmail.com>
Brian Anderson <banderson@mozilla.com> <banderson@mozilla.org>
Brian Dawn <brian.t.dawn@gmail.com>
Brian Leibig <brian@brianleibig.com> Brian Leibig <brian.leibig@gmail.com>
Carl-Anton Ingmarsson <mail@carlanton.se> <ca.ingmarsson@gmail.com>
Carol (Nichols || Goulding) <carol.nichols@gmail.com>
Carol (Nichols || Goulding) <cnichols@thinkthroughmath.com>
Carol (Nichols || Goulding) <carol.nichols@gmail.com> <cnichols@thinkthroughmath.com>
Carol (Nichols || Goulding) <carol.nichols@gmail.com> Carol Nichols <carol.nichols@gmail.com>
Carol Willing <carolcode@willingconsulting.com>
Chris C Cerami <chrisccerami@users.noreply.github.com> Chris C Cerami <chrisccerami@gmail.com>
Chris Pressey <cpressey@gmail.com>
Expand Down
5 changes: 0 additions & 5 deletions src/bootstrap/channel.rs
Expand Up @@ -26,11 +26,6 @@ use config::Config;
// The version number
pub const CFG_RELEASE_NUM: &str = "1.25.0";

// An optional number to put after the label, e.g. '.2' -> '-beta.2'
// Be sure to make this starts with a dot to conform to semver pre-release
// versions (section 9)
pub const CFG_PRERELEASE_VERSION: &str = ".1";

pub struct GitInfo {
inner: Option<Info>,
}
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/dist.rs
Expand Up @@ -1652,7 +1652,6 @@ fn add_env(build: &Build, cmd: &mut Command, target: Interned<String>) {
cmd.env("CFG_RELEASE_INFO", build.rust_version())
.env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM)
.env("CFG_RELEASE", build.rust_release())
.env("CFG_PRERELEASE_VERSION", channel::CFG_PRERELEASE_VERSION)
.env("CFG_VER_MAJOR", parts.next().unwrap())
.env("CFG_VER_MINOR", parts.next().unwrap())
.env("CFG_VER_PATCH", parts.next().unwrap())
Expand Down
53 changes: 51 additions & 2 deletions src/bootstrap/lib.rs
Expand Up @@ -134,7 +134,7 @@ extern crate toml;
#[cfg(unix)]
extern crate libc;

use std::cell::RefCell;
use std::cell::{RefCell, Cell};
use std::collections::{HashSet, HashMap};
use std::env;
use std::fs::{self, File};
Expand Down Expand Up @@ -250,6 +250,7 @@ pub struct Build {
is_sudo: bool,
ci_env: CiEnv,
delayed_failures: RefCell<Vec<String>>,
prerelease_version: Cell<Option<u32>>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -335,6 +336,7 @@ impl Build {
is_sudo,
ci_env: CiEnv::current(),
delayed_failures: RefCell::new(Vec::new()),
prerelease_version: Cell::new(None),
}
}

Expand Down Expand Up @@ -774,12 +776,59 @@ impl Build {
fn release(&self, num: &str) -> String {
match &self.config.channel[..] {
"stable" => num.to_string(),
"beta" => format!("{}-beta{}", num, channel::CFG_PRERELEASE_VERSION),
"beta" => format!("{}-beta.{}", num, self.beta_prerelease_version()),
"nightly" => format!("{}-nightly", num),
_ => format!("{}-dev", num),
}
}

fn beta_prerelease_version(&self) -> u32 {
if let Some(s) = self.prerelease_version.get() {
return s
}

let beta = output(
Command::new("git")
.arg("ls-remote")
.arg("origin")
.arg("beta")
.current_dir(&self.src)
);
let beta = beta.trim().split_whitespace().next().unwrap();
let master = output(
Command::new("git")
.arg("ls-remote")
.arg("origin")
.arg("master")
.current_dir(&self.src)
);
let master = master.trim().split_whitespace().next().unwrap();

// Figure out where the current beta branch started.
let base = output(
Command::new("git")
.arg("merge-base")
.arg(beta)
.arg(master)
.current_dir(&self.src),
);
let base = base.trim();

// Next figure out how many merge commits happened since we branched off
// beta. That's our beta number!
let count = output(
Command::new("git")
.arg("rev-list")
.arg("--count")
.arg("--merges")
.arg(format!("{}...HEAD", base))
.current_dir(&self.src),
);
let n = count.trim().parse().unwrap();
self.prerelease_version.set(Some(n));
n
}

/// Returns the value of `release` above for Rust itself.
fn rust_release(&self) -> String {
self.release(channel::CFG_RELEASE_NUM)
Expand Down
6 changes: 6 additions & 0 deletions src/ci/init_repo.sh
Expand Up @@ -36,6 +36,12 @@ fi
rm -rf "$CACHE_DIR"
mkdir "$CACHE_DIR"

# On the beta channel we'll be automatically calculating the prerelease version
# via the git history, so unshallow our shallow clone from CI.
if grep -q RUST_RELEASE_CHANNEL=beta src/ci/run.sh; then
git fetch origin --unshallow beta master
fi

travis_fold start update_cache
travis_time_start

Expand Down
24 changes: 12 additions & 12 deletions src/liballoc/btree/set.rs
Expand Up @@ -658,26 +658,26 @@ impl<T: Ord> BTreeSet<T> {
/// Basic usage:
///
/// ```
/// use std::collections::BTreeMap;
/// use std::collections::BTreeSet;
///
/// let mut a = BTreeMap::new();
/// a.insert(1, "a");
/// a.insert(2, "b");
/// a.insert(3, "c");
/// a.insert(17, "d");
/// a.insert(41, "e");
/// let mut a = BTreeSet::new();
/// a.insert(1);
/// a.insert(2);
/// a.insert(3);
/// a.insert(17);
/// a.insert(41);
///
/// let b = a.split_off(&3);
///
/// assert_eq!(a.len(), 2);
/// assert_eq!(b.len(), 3);
///
/// assert_eq!(a[&1], "a");
/// assert_eq!(a[&2], "b");
/// assert!(a.contains(&1));
/// assert!(a.contains(&2));
///
/// assert_eq!(b[&3], "c");
/// assert_eq!(b[&17], "d");
/// assert_eq!(b[&41], "e");
/// assert!(b.contains(&3));
/// assert!(b.contains(&17));
/// assert!(b.contains(&41));
/// ```
#[stable(feature = "btree_split_off", since = "1.11.0")]
pub fn split_off<Q: ?Sized + Ord>(&mut self, key: &Q) -> Self where T: Borrow<Q> {
Expand Down
8 changes: 8 additions & 0 deletions src/liballoc/slice.rs
Expand Up @@ -630,6 +630,8 @@ impl<T> [T] {
/// assert_eq!(iter.next().unwrap(), &['m']);
/// assert!(iter.next().is_none());
/// ```
///
/// [`exact_chunks`]: #method.exact_chunks
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn chunks(&self, chunk_size: usize) -> Chunks<T> {
Expand Down Expand Up @@ -660,6 +662,8 @@ impl<T> [T] {
/// assert_eq!(iter.next().unwrap(), &['r', 'e']);
/// assert!(iter.next().is_none());
/// ```
///
/// [`chunks`]: #method.chunks
#[unstable(feature = "exact_chunks", issue = "47115")]
#[inline]
pub fn exact_chunks(&self, chunk_size: usize) -> ExactChunks<T> {
Expand Down Expand Up @@ -692,6 +696,8 @@ impl<T> [T] {
/// }
/// assert_eq!(v, &[1, 1, 2, 2, 3]);
/// ```
///
/// [`exact_chunks_mut`]: #method.exact_chunks_mut
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<T> {
Expand Down Expand Up @@ -728,6 +734,8 @@ impl<T> [T] {
/// }
/// assert_eq!(v, &[1, 1, 2, 2, 0]);
/// ```
///
/// [`chunks_mut`]: #method.chunks_mut
#[unstable(feature = "exact_chunks", issue = "47115")]
#[inline]
pub fn exact_chunks_mut(&mut self, chunk_size: usize) -> ExactChunksMut<T> {
Expand Down
15 changes: 8 additions & 7 deletions src/liballoc/vec_deque.rs
Expand Up @@ -906,7 +906,7 @@ impl<T> VecDeque<T> {
}
}

/// Clears the buffer, removing all values.
/// Clears the `VecDeque`, removing all values.
///
/// # Examples
///
Expand Down Expand Up @@ -1624,18 +1624,18 @@ impl<T> VecDeque<T> {
return elem;
}

/// Splits the collection into two at the given index.
/// Splits the `VecDeque` into two at the given index.
///
/// Returns a newly allocated `Self`. `self` contains elements `[0, at)`,
/// and the returned `Self` contains elements `[at, len)`.
/// Returns a newly allocated `VecDeque`. `self` contains elements `[0, at)`,
/// and the returned `VecDeque` contains elements `[at, len)`.
///
/// Note that the capacity of `self` does not change.
///
/// Element at index 0 is the front of the queue.
///
/// # Panics
///
/// Panics if `at > len`
/// Panics if `at > len`.
///
/// # Examples
///
Expand Down Expand Up @@ -1815,7 +1815,8 @@ impl<T> VecDeque<T> {

impl<T: Clone> VecDeque<T> {
/// Modifies the `VecDeque` in-place so that `len()` is equal to new_len,
/// either by removing excess elements or by appending clones of `value` to the back.
/// either by removing excess elements from the back or by appending clones of `value`
/// to the back.
///
/// # Examples
///
Expand Down Expand Up @@ -2390,7 +2391,7 @@ impl<T> IntoIterator for VecDeque<T> {
type Item = T;
type IntoIter = IntoIter<T>;

/// Consumes the list into a front-to-back iterator yielding elements by
/// Consumes the `VecDeque` into a front-to-back iterator yielding elements by
/// value.
fn into_iter(self) -> IntoIter<T> {
IntoIter { inner: self }
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/hir/lowering.rs
Expand Up @@ -2046,7 +2046,8 @@ impl<'a> LoweringContext<'a> {
};

// Correctly resolve `self` imports
if path.segments.last().unwrap().identifier.name == keywords::SelfValue.name() {
if path.segments.len() > 1 &&
path.segments.last().unwrap().identifier.name == keywords::SelfValue.name() {
let _ = path.segments.pop();
if ident.name == keywords::SelfValue.name() {
*name = path.segments.last().unwrap().identifier.name;
Expand Down
64 changes: 63 additions & 1 deletion src/librustc/hir/mod.rs
Expand Up @@ -34,13 +34,14 @@ use util::nodemap::{NodeMap, FxHashSet};
use syntax_pos::{Span, DUMMY_SP};
use syntax::codemap::{self, Spanned};
use syntax::abi::Abi;
use syntax::ast::{Ident, Name, NodeId, DUMMY_NODE_ID, AsmDialect};
use syntax::ast::{self, Ident, Name, NodeId, DUMMY_NODE_ID, AsmDialect};
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem};
use syntax::ext::hygiene::SyntaxContext;
use syntax::ptr::P;
use syntax::symbol::{Symbol, keywords};
use syntax::tokenstream::TokenStream;
use syntax::util::ThinVec;
use syntax::util::parser::ExprPrecedence;
use ty::AdtKind;

use rustc_data_structures::indexed_vec;
Expand Down Expand Up @@ -958,6 +959,31 @@ impl BinOp_ {
}
}

impl Into<ast::BinOpKind> for BinOp_ {
fn into(self) -> ast::BinOpKind {
match self {
BiAdd => ast::BinOpKind::Add,
BiSub => ast::BinOpKind::Sub,
BiMul => ast::BinOpKind::Mul,
BiDiv => ast::BinOpKind::Div,
BiRem => ast::BinOpKind::Rem,
BiAnd => ast::BinOpKind::And,
BiOr => ast::BinOpKind::Or,
BiBitXor => ast::BinOpKind::BitXor,
BiBitAnd => ast::BinOpKind::BitAnd,
BiBitOr => ast::BinOpKind::BitOr,
BiShl => ast::BinOpKind::Shl,
BiShr => ast::BinOpKind::Shr,
BiEq => ast::BinOpKind::Eq,
BiLt => ast::BinOpKind::Lt,
BiLe => ast::BinOpKind::Le,
BiNe => ast::BinOpKind::Ne,
BiGe => ast::BinOpKind::Ge,
BiGt => ast::BinOpKind::Gt,
}
}
}

pub type BinOp = Spanned<BinOp_>;

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
Expand Down Expand Up @@ -1166,6 +1192,42 @@ pub struct Expr {
pub hir_id: HirId,
}

impl Expr {
pub fn precedence(&self) -> ExprPrecedence {
match self.node {
ExprBox(_) => ExprPrecedence::Box,
ExprArray(_) => ExprPrecedence::Array,
ExprCall(..) => ExprPrecedence::Call,
ExprMethodCall(..) => ExprPrecedence::MethodCall,
ExprTup(_) => ExprPrecedence::Tup,
ExprBinary(op, ..) => ExprPrecedence::Binary(op.node.into()),
ExprUnary(..) => ExprPrecedence::Unary,
ExprLit(_) => ExprPrecedence::Lit,
ExprType(..) | ExprCast(..) => ExprPrecedence::Cast,
ExprIf(..) => ExprPrecedence::If,
ExprWhile(..) => ExprPrecedence::While,
ExprLoop(..) => ExprPrecedence::Loop,
ExprMatch(..) => ExprPrecedence::Match,
ExprClosure(..) => ExprPrecedence::Closure,
ExprBlock(..) => ExprPrecedence::Block,
ExprAssign(..) => ExprPrecedence::Assign,
ExprAssignOp(..) => ExprPrecedence::AssignOp,
ExprField(..) => ExprPrecedence::Field,
ExprTupField(..) => ExprPrecedence::TupField,
ExprIndex(..) => ExprPrecedence::Index,
ExprPath(..) => ExprPrecedence::Path,
ExprAddrOf(..) => ExprPrecedence::AddrOf,
ExprBreak(..) => ExprPrecedence::Break,
ExprAgain(..) => ExprPrecedence::Continue,
ExprRet(..) => ExprPrecedence::Ret,
ExprInlineAsm(..) => ExprPrecedence::InlineAsm,
ExprStruct(..) => ExprPrecedence::Struct,
ExprRepeat(..) => ExprPrecedence::Repeat,
ExprYield(..) => ExprPrecedence::Yield,
}
}
}

impl fmt::Debug for Expr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "expr({}: {})", self.id,
Expand Down

0 comments on commit ff2a7c8

Please sign in to comment.