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 12 pull requests #30457

Merged
merged 21 commits into from
Dec 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2a1efca
Fix typo
jwworth Dec 15, 2015
d91b256
change macro ambiguity example from ty to ident
durka Dec 16, 2015
6309b0f
move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*
nrc Dec 13, 2015
a478811
Move a bunch of stuff from Session to syntax::errors
nrc Dec 14, 2015
7a03349
Add the files I fogot about earlier
nrc Dec 15, 2015
e237151
A little more refactoring inside emitter.rs
nrc Dec 15, 2015
ff0c74f
test errors
nrc Dec 15, 2015
ccb2186
Trivial cleanup
mmcco Dec 17, 2015
09d4a43
libsyntax: Merge OwnedSlice into ptr::P
petrochenkov Dec 16, 2015
0d298f9
Deprecate name `OwnedSlice` and don't use it
petrochenkov Dec 16, 2015
6c87b19
Abstract away differences between Vec and ptr::P in HIR
petrochenkov Dec 17, 2015
2a23e4a
Clarified shadowing example
Xmasreturns Dec 17, 2015
88ffb26
Fix emitting asm and object file output at the same time
dotdash Dec 18, 2015
cb319fc
Rollup merge of #30286 - oli-obk:const_error_span, r=nikomatsakis
Manishearth Dec 18, 2015
c290296
Rollup merge of #30384 - nrc:diagnostics, r=@nikomatsakis
Manishearth Dec 18, 2015
7eb7bc2
Rollup merge of #30398 - jwworth:pull-request-1450205451, r=sanxiyn
Manishearth Dec 18, 2015
158a1bd
Rollup merge of #30406 - durka:patch-13, r=sanxiyn
Manishearth Dec 18, 2015
9e953df
Rollup merge of #30420 - petrochenkov:owned2, r=nrc
Manishearth Dec 18, 2015
e916676
Rollup merge of #30431 - mmcco:cleanup, r=alexcrichton
Manishearth Dec 18, 2015
4f8b32c
Rollup merge of #30447 - Xmasreturns:Docu, r=steveklabnik
Manishearth Dec 18, 2015
a8e4246
Rollup merge of #30452 - dotdash:24876_take_2, r=alexcrichton
Manishearth Dec 18, 2015
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
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
48 changes: 21 additions & 27 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 Expand Up @@ -1182,46 +1182,40 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
},
hir::ExprTupField(ref base, index) => {
let base_hint = ty_hint.erase_hint();
if let Ok(c) = eval_const_expr_partial(tcx, base, base_hint, fn_args) {
if let Tuple(tup_id) = c {
if let hir::ExprTup(ref fields) = tcx.map.expect_expr(tup_id).node {
if index.node < fields.len() {
return eval_const_expr_partial(tcx, &fields[index.node], base_hint, fn_args)
} else {
signal!(e, TupleIndexOutOfBounds);
}
let c = try!(eval_const_expr_partial(tcx, base, base_hint, fn_args));
if let Tuple(tup_id) = c {
if let hir::ExprTup(ref fields) = tcx.map.expect_expr(tup_id).node {
if index.node < fields.len() {
return eval_const_expr_partial(tcx, &fields[index.node], base_hint, fn_args)
} else {
unreachable!()
signal!(e, TupleIndexOutOfBounds);
}
} else {
signal!(base, ExpectedConstTuple);
unreachable!()
}
} else {
signal!(base, NonConstPath)
signal!(base, ExpectedConstTuple);
}
}
hir::ExprField(ref base, field_name) => {
let base_hint = ty_hint.erase_hint();
// Get the base expression if it is a struct and it is constant
if let Ok(c) = eval_const_expr_partial(tcx, base, base_hint, fn_args) {
if let Struct(struct_id) = c {
if let hir::ExprStruct(_, ref fields, _) = tcx.map.expect_expr(struct_id).node {
// Check that the given field exists and evaluate it
// if the idents are compared run-pass/issue-19244 fails
if let Some(f) = fields.iter().find(|f| f.name.node
== field_name.node) {
return eval_const_expr_partial(tcx, &*f.expr, base_hint, fn_args)
} else {
signal!(e, MissingStructField);
}
let c = try!(eval_const_expr_partial(tcx, base, base_hint, fn_args));
if let Struct(struct_id) = c {
if let hir::ExprStruct(_, ref fields, _) = tcx.map.expect_expr(struct_id).node {
// Check that the given field exists and evaluate it
// if the idents are compared run-pass/issue-19244 fails
if let Some(f) = fields.iter().find(|f| f.name.node
== field_name.node) {
return eval_const_expr_partial(tcx, &*f.expr, base_hint, fn_args)
} else {
unreachable!()
signal!(e, MissingStructField);
}
} else {
signal!(base, ExpectedConstStruct);
unreachable!()
}
} else {
signal!(base, NonConstPath);
signal!(base, ExpectedConstStruct);
}
}
_ => signal!(e, MiscCatchAll)
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