Skip to content

Rollup of 9 pull requests #47644

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

Merged
merged 24 commits into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
aec1623
Suggest casting on numeric type error
estebank Jan 7, 2018
af91d99
Use `into` for casting when possible
estebank Jan 7, 2018
509ea8e
Only suggest casting numeric types using `into()`
estebank Jan 7, 2018
09efaaf
Use `s::u::p::expr_precedence` and fix message
estebank Jan 10, 2018
afe8d13
Use single source of truth for expr precedence
estebank Jan 10, 2018
090a968
Only link res_init() on GNU/*nix
etaoins Jan 10, 2018
71c0873
Move `ExprPrecedence` to `libsyntax/util/parser.rs`
estebank Jan 15, 2018
f66e711
Add E0659 for ambiguous names
GuillaumeGomez Jan 16, 2018
81e6840
Small improvements to the documentation of VecDeque.
Jan 19, 2018
06913a5
Automaticaly calculate beta prerelease numbers
alexcrichton Jan 12, 2018
4d08d05
fix doctests for BTreeSet to use BTreeSet (not BTreeMap)
astraw Jan 20, 2018
1756f68
Fix broken links to other slice functions in chunks/chunks_mut/exact_…
sdroege Jan 21, 2018
e9d0141
Fix ICE with `use self;`
pietroalbini Jan 21, 2018
ea814b8
Revert change to docs in panic section of VecDeque::split_off
Jan 21, 2018
9a56286
Fix mailmap duplicates, Carol and Brian.
Jan 21, 2018
6bb1b0d
Rollup merge of #47247 - estebank:suggest-cast, r=petrochenkov
GuillaumeGomez Jan 21, 2018
ab54a9c
Rollup merge of #47334 - etaoins:only-call-res-init-on-gnu-unix, r=al…
GuillaumeGomez Jan 21, 2018
a1c3449
Rollup merge of #47512 - GuillaumeGomez:e0659, r=petrochenkov
GuillaumeGomez Jan 21, 2018
35221d8
Rollup merge of #47582 - alexcrichton:auto-beta, r=kennytm
GuillaumeGomez Jan 21, 2018
c354bb8
Rollup merge of #47595 - PieterPenninckx:master, r=shepmaster
GuillaumeGomez Jan 21, 2018
50e3836
Rollup merge of #47625 - astraw:btreeset-doctest-fix, r=kennytm
GuillaumeGomez Jan 21, 2018
6e6ab1e
Rollup merge of #47632 - sdroege:exact-chunks-docs-broken-links, r=ke…
GuillaumeGomez Jan 21, 2018
05f77ac
Rollup merge of #47633 - pietroalbini:fix-ice-use-self, r=nagisa
GuillaumeGomez Jan 21, 2018
dcbf0bf
Rollup merge of #47637 - russmack:fix-mailmap-dupes, r=steveklabnik
GuillaumeGomez Jan 21, 2018
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
5 changes: 3 additions & 2 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ Boris Egorov <[email protected]> <[email protected]>
Brandon Sanderson <[email protected]> Brandon Sanderson <[email protected]>
Brett Cannon <[email protected]> Brett Cannon <[email protected]>
Brian Anderson <[email protected]> <[email protected]>
Brian Anderson <[email protected]> <[email protected]>
Brian Dawn <[email protected]>
Brian Leibig <[email protected]> Brian Leibig <[email protected]>
Carl-Anton Ingmarsson <[email protected]> <[email protected]>
Carol (Nichols || Goulding) <[email protected]>
Carol (Nichols || Goulding) <cnichols@thinkthroughmath.com>
Carol (Nichols || Goulding) <[email protected]> <[email protected]>
Carol (Nichols || Goulding) <[email protected]> Carol Nichols <carol.nichols@gmail.com>
Carol Willing <[email protected]>
Chris C Cerami <[email protected]> Chris C Cerami <[email protected]>
Chris Pressey <[email protected]>
Expand Down
5 changes: 0 additions & 5 deletions src/bootstrap/channel.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading