Skip to content

Commit

Permalink
Auto merge of #30457 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
- Successful merges: #30272, #30286, #30365, #30381, #30384, #30398, #30406, #30408, #30420, #30431, #30447, #30452
- Failed merges:
  • Loading branch information
bors committed Dec 18, 2015
2 parents de62f9d + a8e4246 commit 3391630
Show file tree
Hide file tree
Showing 75 changed files with 1,371 additions and 1,197 deletions.
6 changes: 3 additions & 3 deletions src/doc/book/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ These rules provide some flexibility for Rust’s syntax to evolve without
breaking existing macros.

The macro system does not deal with parse ambiguity at all. For example, the
grammar `$($t:ty)* $e:expr` will always fail to parse, because the parser would
be forced to choose between parsing `$t` and parsing `$e`. Changing the
grammar `$($i:ident)* $e:expr` will always fail to parse, because the parser would
be forced to choose between parsing `$i` and parsing `$e`. Changing the
invocation syntax to put a distinctive token in front can solve the problem. In
this case, you can write `$(T $t:ty)* E $e:exp`.
this case, you can write `$(I $i:ident)* E $e:expr`.

[item]: ../reference.html#items

Expand Down
10 changes: 6 additions & 4 deletions src/doc/book/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ There’s one pitfall with patterns: like anything that introduces a new binding
they introduce shadowing. For example:

```rust
let x = 'x';
let x = 1;
let c = 'c';

match c {
Expand All @@ -41,12 +41,14 @@ This prints:

```text
x: c c: c
x: x
x: 1
```

In other words, `x =>` matches the pattern and introduces a new binding named
`x` that’s in scope for the match arm. Because we already have a binding named
`x`, this new `x` shadows it.
`x`. This new binding is in scope for the match arm and takes on the value of
`c`. Notice that the value of `x` outside the scope of the match has no bearing
on the value of `x` within it. Because we already have a binding named `x`, this
new `x` shadows it.

# Multiple patterns

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use rustc_front::hir;
use rustc_front::util;
use rustc_front::intravisit as hir_visit;
use syntax::visit as ast_visit;
use syntax::diagnostic;
use syntax::errors;

/// Information about the registered lints.
///
Expand Down Expand Up @@ -167,7 +167,7 @@ impl LintStore {
match (sess, from_plugin) {
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
(None, _) => early_error(diagnostic::Auto, &msg[..]),
(None, _) => early_error(errors::ColorConfig::Auto, &msg[..]),
(Some(sess), false) => sess.bug(&msg[..]),

// A duplicate name from a plugin is a user error.
Expand All @@ -191,7 +191,7 @@ impl LintStore {
match (sess, from_plugin) {
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
(None, _) => early_error(diagnostic::Auto, &msg[..]),
(None, _) => early_error(errors::ColorConfig::Auto, &msg[..]),
(Some(sess), false) => sess.bug(&msg[..]),

// A duplicate name from a plugin is a user error.
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
ty::TyEnum(adt, _) | ty::TyStruct(adt, _) => {
let v = adt.variant_of_ctor(ctor);
if let VariantKind::Struct = v.kind() {
let field_pats: Vec<_> = v.fields.iter()
let field_pats: hir::HirVec<_> = v.fields.iter()
.zip(pats)
.filter(|&(_, ref pat)| pat.node != hir::PatWild)
.map(|(field, pat)| Spanned {
Expand All @@ -540,14 +540,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
ty::TyArray(_, n) => match ctor {
&Single => {
assert_eq!(pats_len, n);
hir::PatVec(pats.collect(), None, vec!())
hir::PatVec(pats.collect(), None, hir::HirVec::new())
},
_ => unreachable!()
},
ty::TySlice(_) => match ctor {
&Slice(n) => {
assert_eq!(pats_len, n);
hir::PatVec(pats.collect(), None, vec!())
hir::PatVec(pats.collect(), None, hir::HirVec::new())
},
_ => unreachable!()
},
Expand All @@ -562,7 +562,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,

ty::TyArray(_, len) => {
assert_eq!(pats_len, len);
hir::PatVec(pats.collect(), None, vec![])
hir::PatVec(pats.collect(), None, hir::HirVec::new())
}

_ => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,14 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat>

hir::ExprVec(ref exprs) => {
let pats = exprs.iter().map(|expr| const_expr_to_pat(tcx, &**expr, span)).collect();
hir::PatVec(pats, None, vec![])
hir::PatVec(pats, None, hir::HirVec::new())
}

hir::ExprPath(_, ref path) => {
let opt_def = tcx.def_map.borrow().get(&expr.id).map(|d| d.full_def());
match opt_def {
Some(def::DefStruct(..)) =>
hir::PatStruct(path.clone(), vec![], false),
hir::PatStruct(path.clone(), hir::HirVec::new(), false),
Some(def::DefVariant(..)) =>
hir::PatEnum(path.clone(), None),
_ => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
self.delegate.consume(consume_id, consume_span, cmt, mode);
}

fn consume_exprs(&mut self, exprs: &Vec<P<hir::Expr>>) {
fn consume_exprs(&mut self, exprs: &[P<hir::Expr>]) {
for expr in exprs {
self.consume_expr(&**expr);
}
Expand Down Expand Up @@ -651,7 +651,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {

fn walk_struct_expr(&mut self,
_expr: &hir::Expr,
fields: &Vec<hir::Field>,
fields: &[hir::Field],
opt_with: &Option<P<hir::Expr>>) {
// Consume the expressions supplying values for each field.
for field in fields {
Expand Down Expand Up @@ -697,7 +697,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
self.walk_expr(with_expr);

fn contains_field_named(field: ty::FieldDef,
fields: &Vec<hir::Field>)
fields: &[hir::Field])
-> bool
{
fields.iter().any(
Expand Down
23 changes: 11 additions & 12 deletions src/librustc/middle/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ use std::cell::{Cell, RefCell};
use std::char::from_u32;
use std::fmt;
use syntax::ast;
use syntax::owned_slice::OwnedSlice;
use syntax::codemap::{self, Pos, Span};
use syntax::parse::token;
use syntax::ptr::P;
Expand Down Expand Up @@ -1154,10 +1153,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
}

fn rebuild_ty_params(&self,
ty_params: OwnedSlice<hir::TyParam>,
ty_params: P<[hir::TyParam]>,
lifetime: hir::Lifetime,
region_names: &HashSet<ast::Name>)
-> OwnedSlice<hir::TyParam> {
-> P<[hir::TyParam]> {
ty_params.map(|ty_param| {
let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(),
lifetime,
Expand All @@ -1173,10 +1172,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
}

fn rebuild_ty_param_bounds(&self,
ty_param_bounds: OwnedSlice<hir::TyParamBound>,
ty_param_bounds: hir::TyParamBounds,
lifetime: hir::Lifetime,
region_names: &HashSet<ast::Name>)
-> OwnedSlice<hir::TyParamBound> {
-> hir::TyParamBounds {
ty_param_bounds.map(|tpb| {
match tpb {
&hir::RegionTyParamBound(lt) => {
Expand Down Expand Up @@ -1249,13 +1248,13 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
add: &Vec<hir::Lifetime>,
keep: &HashSet<ast::Name>,
remove: &HashSet<ast::Name>,
ty_params: OwnedSlice<hir::TyParam>,
ty_params: P<[hir::TyParam]>,
where_clause: hir::WhereClause)
-> hir::Generics {
let mut lifetimes = Vec::new();
for lt in add {
lifetimes.push(hir::LifetimeDef { lifetime: *lt,
bounds: Vec::new() });
bounds: hir::HirVec::new() });
}
for lt in &generics.lifetimes {
if keep.contains(&lt.lifetime.name) ||
Expand All @@ -1264,7 +1263,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
}
}
hir::Generics {
lifetimes: lifetimes,
lifetimes: lifetimes.into(),
ty_params: ty_params,
where_clause: where_clause,
}
Expand All @@ -1275,7 +1274,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
lifetime: hir::Lifetime,
anon_nums: &HashSet<u32>,
region_names: &HashSet<ast::Name>)
-> Vec<hir::Arg> {
-> hir::HirVec<hir::Arg> {
let mut new_inputs = Vec::new();
for arg in inputs {
let new_ty = self.rebuild_arg_ty_or_output(&*arg.ty, lifetime,
Expand All @@ -1287,7 +1286,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
};
new_inputs.push(possibly_new_arg);
}
new_inputs
new_inputs.into()
}

fn rebuild_output(&self, ty: &hir::FunctionRetTy,
Expand Down Expand Up @@ -1514,7 +1513,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
}
});
hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
lifetimes: new_lts,
lifetimes: new_lts.into(),
types: new_types,
bindings: new_bindings,
})
Expand All @@ -1530,7 +1529,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
hir::Path {
span: path.span,
global: path.global,
segments: new_segs
segments: new_segs.into()
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ struct LifetimeContext<'a> {
enum ScopeChain<'a> {
/// EarlyScope(i, ['a, 'b, ...], s) extends s with early-bound
/// lifetimes, assigning indexes 'a => i, 'b => i+1, ... etc.
EarlyScope(subst::ParamSpace, &'a Vec<hir::LifetimeDef>, Scope<'a>),
EarlyScope(subst::ParamSpace, &'a [hir::LifetimeDef], Scope<'a>),
/// LateScope(['a, 'b, ...], s) extends s with late-bound
/// lifetimes introduced by the declaration binder_id.
LateScope(&'a Vec<hir::LifetimeDef>, Scope<'a>),
LateScope(&'a [hir::LifetimeDef], Scope<'a>),

/// lifetimes introduced by a fn are scoped to the call-site for that fn.
FnScope { fn_id: ast::NodeId, body_id: ast::NodeId, s: Scope<'a> },
Expand Down Expand Up @@ -206,7 +206,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
// a trait ref, which introduces a binding scope.
match self.def_map.get(&ty.id).map(|d| (d.base_def, d.depth)) {
Some((def::DefTrait(..), 0)) => {
self.with(LateScope(&Vec::new(), self.scope), |_, this| {
self.with(LateScope(&[], self.scope), |_, this| {
this.visit_path(path, ty.id);
});
}
Expand Down Expand Up @@ -661,7 +661,7 @@ impl<'a> LifetimeContext<'a> {
lifetime_ref.name);
}

fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<hir::LifetimeDef>) {
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &[hir::LifetimeDef]) {
for i in 0..lifetimes.len() {
let lifetime_i = &lifetimes[i];

Expand Down Expand Up @@ -753,7 +753,7 @@ impl<'a> LifetimeContext<'a> {
}
}

fn search_lifetimes<'a>(lifetimes: &'a Vec<hir::LifetimeDef>,
fn search_lifetimes<'a>(lifetimes: &'a [hir::LifetimeDef],
lifetime_ref: &hir::Lifetime)
-> Option<(u32, &'a hir::Lifetime)> {
for (i, lifetime_decl) in lifetimes.iter().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct Annotator<'a, 'tcx: 'a> {
impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
// Determine the stability for a node based on its attributes and inherited
// stability. The stability is recorded in the index and used as the parent.
fn annotate<F>(&mut self, id: NodeId, attrs: &Vec<Attribute>,
fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
item_sp: Span, kind: AnnotationKind, visit_children: F)
where F: FnOnce(&mut Annotator)
{
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use middle::ty::fold::{TypeFoldable, TypeFolder};

use std::rc::Rc;
use syntax::abi;
use syntax::owned_slice::OwnedSlice;
use syntax::ptr::P;

use rustc_front::hir;

Expand Down Expand Up @@ -555,8 +555,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
}
}

impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for OwnedSlice<T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> OwnedSlice<T> {
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> P<[T]> {
self.iter().map(|t| t.fold_with(folder)).collect()
}
}
Expand Down
Loading

0 comments on commit 3391630

Please sign in to comment.