]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/const_eval.rs
use slicing sugar
[rust.git] / src / librustc / middle / const_eval.rs
index e726993bd48402cfa27c835dec2e81a408091cac..04d4b41b21aa4a273407b8390854ed8009cf71c0 100644 (file)
@@ -48,7 +48,7 @@
 //     target uses". This _includes_ integer-constants, plus the following
 //     constructors:
 //
-//        fixed-size vectors and strings: .index(&FullRange) and ""/_
+//        fixed-size vectors and strings: [] and ""/_
 //        vector and string slices: &[] and &""
 //        tuples: (,)
 //        enums: foo(...)
@@ -117,7 +117,7 @@ fn variant_expr<'a>(variants: &'a [P<ast::Variant>], id: ast::NodeId)
             None => None,
             Some(ast_map::NodeItem(it)) => match it.node {
                 ast::ItemEnum(ast::EnumDef { ref variants }, _) => {
-                    variant_expr(variants.index(&FullRange), variant_def.node)
+                    variant_expr(&variants[], variant_def.node)
                 }
                 _ => None
             },
@@ -138,7 +138,7 @@ fn variant_expr<'a>(variants: &'a [P<ast::Variant>], id: ast::NodeId)
                     // NOTE this doesn't do the right thing, it compares inlined
                     // NodeId's to the original variant_def's NodeId, but they
                     // come from different crates, so they will likely never match.
-                    variant_expr(variants.index(&FullRange), variant_def.node).map(|e| e.id)
+                    variant_expr(&variants[], variant_def.node).map(|e| e.id)
                 }
                 _ => None
             },
@@ -364,7 +364,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<ast::Pat> {
 pub fn eval_const_expr(tcx: &ty::ctxt, e: &Expr) -> const_val {
     match eval_const_expr_partial(tcx, e) {
         Ok(r) => r,
-        Err(s) => tcx.sess.span_fatal(e.span, s.index(&FullRange))
+        Err(s) => tcx.sess.span_fatal(e.span, &s[])
     }
 }