use rustc::middle::const_qualif::ConstQualif;
use rustc::lint::builtin::CONST_ERR;
-use rustc_front::hir;
+use rustc_front::hir::{self, PatKind};
use syntax::ast;
use syntax::codemap::Span;
use syntax::feature_gate::UnstableFeatures;
let ty = self.tcx.node_id_to_type(e.id);
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
let cause = traits::ObligationCause::new(e.span, e.id, traits::SharedStatic);
- let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
- fulfill_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
- match fulfill_cx.select_all_or_error(&infcx) {
+ let mut fulfillment_cx = traits::FulfillmentContext::new();
+ fulfillment_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
+ match fulfillment_cx.select_all_or_error(&infcx) {
Ok(()) => { },
Err(ref errors) => {
traits::report_fulfillment_errors(&infcx, errors);
assert_eq!(self.mode, Mode::Var);
match i.node {
hir::ItemStatic(_, hir::MutImmutable, ref expr) => {
- self.check_static_type(&**expr);
- self.global_expr(Mode::Static, &**expr);
+ self.check_static_type(&expr);
+ self.global_expr(Mode::Static, &expr);
}
hir::ItemStatic(_, hir::MutMutable, ref expr) => {
- self.check_static_mut_type(&**expr);
- self.global_expr(Mode::StaticMut, &**expr);
+ self.check_static_mut_type(&expr);
+ self.global_expr(Mode::StaticMut, &expr);
}
hir::ItemConst(_, ref expr) => {
- self.global_expr(Mode::Const, &**expr);
+ self.global_expr(Mode::Const, &expr);
}
hir::ItemEnum(ref enum_definition, _) => {
for var in &enum_definition.variants {
if let Some(ref ex) = var.node.disr_expr {
- self.global_expr(Mode::Const, &**ex);
+ self.global_expr(Mode::Const, &ex);
}
}
}
match t.node {
hir::ConstTraitItem(_, ref default) => {
if let Some(ref expr) = *default {
- self.global_expr(Mode::Const, &*expr);
+ self.global_expr(Mode::Const, &expr);
} else {
intravisit::walk_trait_item(self, t);
}
fn visit_impl_item(&mut self, i: &'v hir::ImplItem) {
match i.node {
hir::ImplItemKind::Const(_, ref expr) => {
- self.global_expr(Mode::Const, &*expr);
+ self.global_expr(Mode::Const, &expr);
}
_ => self.with_mode(Mode::Var, |v| intravisit::walk_impl_item(v, i)),
}
fn visit_pat(&mut self, p: &hir::Pat) {
match p.node {
- hir::PatLit(ref lit) => {
- self.global_expr(Mode::Const, &**lit);
+ PatKind::Lit(ref lit) => {
+ self.global_expr(Mode::Const, &lit);
}
- hir::PatRange(ref start, ref end) => {
- self.global_expr(Mode::Const, &**start);
- self.global_expr(Mode::Const, &**end);
+ PatKind::Range(ref start, ref end) => {
+ self.global_expr(Mode::Const, &start);
+ self.global_expr(Mode::Const, &end);
match const_eval::compare_lit_exprs(self.tcx, start, end) {
Some(Ordering::Less) |
match ex.node {
hir::ExprCall(ref callee, ref args) => {
for arg in args {
- self.visit_expr(&**arg)
+ self.visit_expr(&arg)
}
let inner = self.qualif;
- self.visit_expr(&**callee);
+ self.visit_expr(&callee);
// The callee's size doesn't count in the call.
let added = self.qualif - inner;
self.qualif = inner | (added - ConstQualif::NON_ZERO_SIZED);
}
hir::ExprRepeat(ref element, _) => {
- self.visit_expr(&**element);
+ self.visit_expr(&element);
// The count is checked elsewhere (typeck).
let count = match node_ty.sty {
ty::TyArray(_, n) => n,
loop {
callee = match callee.node {
hir::ExprBlock(ref block) => match block.expr {
- Some(ref tail) => &**tail,
+ Some(ref tail) => &tail,
None => break
},
_ => break
hir::ExprAgain(_) |
hir::ExprRet(_) |
- // Miscellaneous expressions that could be implemented.
- hir::ExprRange(..) |
-
// Expressions with side-effects.
hir::ExprAssign(..) |
hir::ExprAssignOp(..) |
match v.tcx.tables.borrow().adjustments.get(&e.id) {
None |
Some(&ty::adjustment::AdjustReifyFnPointer) |
- Some(&ty::adjustment::AdjustUnsafeFnPointer) => {}
+ Some(&ty::adjustment::AdjustUnsafeFnPointer) |
+ Some(&ty::adjustment::AdjustMutToConstPointer) => {}
Some(&ty::adjustment::AdjustDerefRef(
ty::adjustment::AutoDerefRef { autoderefs, .. }