Skip to content

Commit 3391630

Browse files
committed
Auto merge of #30457 - Manishearth:rollup, r=Manishearth
- Successful merges: #30272, #30286, #30365, #30381, #30384, #30398, #30406, #30408, #30420, #30431, #30447, #30452 - Failed merges:
2 parents de62f9d + a8e4246 commit 3391630

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1371
-1197
lines changed

src/doc/book/macros.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,10 @@ These rules provide some flexibility for Rust’s syntax to evolve without
485485
breaking existing macros.
486486

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

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

src/doc/book/patterns.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ There’s one pitfall with patterns: like anything that introduces a new binding
2727
they introduce shadowing. For example:
2828

2929
```rust
30-
let x = 'x';
30+
let x = 1;
3131
let c = 'c';
3232

3333
match c {
@@ -41,12 +41,14 @@ This prints:
4141

4242
```text
4343
x: c c: c
44-
x: x
44+
x: 1
4545
```
4646

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

5153
# Multiple patterns
5254

src/librustc/lint/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use rustc_front::hir;
4747
use rustc_front::util;
4848
use rustc_front::intravisit as hir_visit;
4949
use syntax::visit as ast_visit;
50-
use syntax::diagnostic;
50+
use syntax::errors;
5151

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

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

197197
// A duplicate name from a plugin is a user error.

src/librustc/middle/check_match.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
517517
ty::TyEnum(adt, _) | ty::TyStruct(adt, _) => {
518518
let v = adt.variant_of_ctor(ctor);
519519
if let VariantKind::Struct = v.kind() {
520-
let field_pats: Vec<_> = v.fields.iter()
520+
let field_pats: hir::HirVec<_> = v.fields.iter()
521521
.zip(pats)
522522
.filter(|&(_, ref pat)| pat.node != hir::PatWild)
523523
.map(|(field, pat)| Spanned {
@@ -540,14 +540,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
540540
ty::TyArray(_, n) => match ctor {
541541
&Single => {
542542
assert_eq!(pats_len, n);
543-
hir::PatVec(pats.collect(), None, vec!())
543+
hir::PatVec(pats.collect(), None, hir::HirVec::new())
544544
},
545545
_ => unreachable!()
546546
},
547547
ty::TySlice(_) => match ctor {
548548
&Slice(n) => {
549549
assert_eq!(pats_len, n);
550-
hir::PatVec(pats.collect(), None, vec!())
550+
hir::PatVec(pats.collect(), None, hir::HirVec::new())
551551
},
552552
_ => unreachable!()
553553
},
@@ -562,7 +562,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
562562

563563
ty::TyArray(_, len) => {
564564
assert_eq!(pats_len, len);
565-
hir::PatVec(pats.collect(), None, vec![])
565+
hir::PatVec(pats.collect(), None, hir::HirVec::new())
566566
}
567567

568568
_ => {

src/librustc/middle/const_eval.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,14 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat>
357357

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

363363
hir::ExprPath(_, ref path) => {
364364
let opt_def = tcx.def_map.borrow().get(&expr.id).map(|d| d.full_def());
365365
match opt_def {
366366
Some(def::DefStruct(..)) =>
367-
hir::PatStruct(path.clone(), vec![], false),
367+
hir::PatStruct(path.clone(), hir::HirVec::new(), false),
368368
Some(def::DefVariant(..)) =>
369369
hir::PatEnum(path.clone(), None),
370370
_ => {

src/librustc/middle/expr_use_visitor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
324324
self.delegate.consume(consume_id, consume_span, cmt, mode);
325325
}
326326

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

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

699699
fn contains_field_named(field: ty::FieldDef,
700-
fields: &Vec<hir::Field>)
700+
fields: &[hir::Field])
701701
-> bool
702702
{
703703
fields.iter().any(

src/librustc/middle/infer/error_reporting.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ use std::cell::{Cell, RefCell};
9090
use std::char::from_u32;
9191
use std::fmt;
9292
use syntax::ast;
93-
use syntax::owned_slice::OwnedSlice;
9493
use syntax::codemap::{self, Pos, Span};
9594
use syntax::parse::token;
9695
use syntax::ptr::P;
@@ -1154,10 +1153,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11541153
}
11551154

11561155
fn rebuild_ty_params(&self,
1157-
ty_params: OwnedSlice<hir::TyParam>,
1156+
ty_params: P<[hir::TyParam]>,
11581157
lifetime: hir::Lifetime,
11591158
region_names: &HashSet<ast::Name>)
1160-
-> OwnedSlice<hir::TyParam> {
1159+
-> P<[hir::TyParam]> {
11611160
ty_params.map(|ty_param| {
11621161
let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(),
11631162
lifetime,
@@ -1173,10 +1172,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11731172
}
11741173

11751174
fn rebuild_ty_param_bounds(&self,
1176-
ty_param_bounds: OwnedSlice<hir::TyParamBound>,
1175+
ty_param_bounds: hir::TyParamBounds,
11771176
lifetime: hir::Lifetime,
11781177
region_names: &HashSet<ast::Name>)
1179-
-> OwnedSlice<hir::TyParamBound> {
1178+
-> hir::TyParamBounds {
11801179
ty_param_bounds.map(|tpb| {
11811180
match tpb {
11821181
&hir::RegionTyParamBound(lt) => {
@@ -1249,13 +1248,13 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12491248
add: &Vec<hir::Lifetime>,
12501249
keep: &HashSet<ast::Name>,
12511250
remove: &HashSet<ast::Name>,
1252-
ty_params: OwnedSlice<hir::TyParam>,
1251+
ty_params: P<[hir::TyParam]>,
12531252
where_clause: hir::WhereClause)
12541253
-> hir::Generics {
12551254
let mut lifetimes = Vec::new();
12561255
for lt in add {
12571256
lifetimes.push(hir::LifetimeDef { lifetime: *lt,
1258-
bounds: Vec::new() });
1257+
bounds: hir::HirVec::new() });
12591258
}
12601259
for lt in &generics.lifetimes {
12611260
if keep.contains(&lt.lifetime.name) ||
@@ -1264,7 +1263,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12641263
}
12651264
}
12661265
hir::Generics {
1267-
lifetimes: lifetimes,
1266+
lifetimes: lifetimes.into(),
12681267
ty_params: ty_params,
12691268
where_clause: where_clause,
12701269
}
@@ -1275,7 +1274,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12751274
lifetime: hir::Lifetime,
12761275
anon_nums: &HashSet<u32>,
12771276
region_names: &HashSet<ast::Name>)
1278-
-> Vec<hir::Arg> {
1277+
-> hir::HirVec<hir::Arg> {
12791278
let mut new_inputs = Vec::new();
12801279
for arg in inputs {
12811280
let new_ty = self.rebuild_arg_ty_or_output(&*arg.ty, lifetime,
@@ -1287,7 +1286,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12871286
};
12881287
new_inputs.push(possibly_new_arg);
12891288
}
1290-
new_inputs
1289+
new_inputs.into()
12911290
}
12921291

12931292
fn rebuild_output(&self, ty: &hir::FunctionRetTy,
@@ -1514,7 +1513,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
15141513
}
15151514
});
15161515
hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
1517-
lifetimes: new_lts,
1516+
lifetimes: new_lts.into(),
15181517
types: new_types,
15191518
bindings: new_bindings,
15201519
})
@@ -1530,7 +1529,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
15301529
hir::Path {
15311530
span: path.span,
15321531
global: path.global,
1533-
segments: new_segs
1532+
segments: new_segs.into()
15341533
}
15351534
}
15361535
}

src/librustc/middle/resolve_lifetime.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ struct LifetimeContext<'a> {
7979
enum ScopeChain<'a> {
8080
/// EarlyScope(i, ['a, 'b, ...], s) extends s with early-bound
8181
/// lifetimes, assigning indexes 'a => i, 'b => i+1, ... etc.
82-
EarlyScope(subst::ParamSpace, &'a Vec<hir::LifetimeDef>, Scope<'a>),
82+
EarlyScope(subst::ParamSpace, &'a [hir::LifetimeDef], Scope<'a>),
8383
/// LateScope(['a, 'b, ...], s) extends s with late-bound
8484
/// lifetimes introduced by the declaration binder_id.
85-
LateScope(&'a Vec<hir::LifetimeDef>, Scope<'a>),
85+
LateScope(&'a [hir::LifetimeDef], Scope<'a>),
8686

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

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

@@ -753,7 +753,7 @@ impl<'a> LifetimeContext<'a> {
753753
}
754754
}
755755

756-
fn search_lifetimes<'a>(lifetimes: &'a Vec<hir::LifetimeDef>,
756+
fn search_lifetimes<'a>(lifetimes: &'a [hir::LifetimeDef],
757757
lifetime_ref: &hir::Lifetime)
758758
-> Option<(u32, &'a hir::Lifetime)> {
759759
for (i, lifetime_decl) in lifetimes.iter().enumerate() {

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct Annotator<'a, 'tcx: 'a> {
8282
impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
8383
// Determine the stability for a node based on its attributes and inherited
8484
// stability. The stability is recorded in the index and used as the parent.
85-
fn annotate<F>(&mut self, id: NodeId, attrs: &Vec<Attribute>,
85+
fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
8686
item_sp: Span, kind: AnnotationKind, visit_children: F)
8787
where F: FnOnce(&mut Annotator)
8888
{

src/librustc/middle/ty/structural_impls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use middle::ty::fold::{TypeFoldable, TypeFolder};
1616

1717
use std::rc::Rc;
1818
use syntax::abi;
19-
use syntax::owned_slice::OwnedSlice;
19+
use syntax::ptr::P;
2020

2121
use rustc_front::hir;
2222

@@ -555,8 +555,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
555555
}
556556
}
557557

558-
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for OwnedSlice<T> {
559-
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> OwnedSlice<T> {
558+
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> {
559+
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> P<[T]> {
560560
self.iter().map(|t| t.fold_with(folder)).collect()
561561
}
562562
}

0 commit comments

Comments
 (0)