Skip to content

Commit aab9c95

Browse files
committed
Remove old slicing hacks and make new slicing work
1 parent 73ebba0 commit aab9c95

File tree

9 files changed

+137
-403
lines changed

9 files changed

+137
-403
lines changed

src/librustc/middle/expr_use_visitor.rs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -441,28 +441,12 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
441441
}
442442

443443
ast::ExprIndex(ref lhs, ref rhs) => { // lhs[rhs]
444-
match rhs.node {
445-
ast::ExprRange(ref start, ref end) => {
446-
// Hacked slicing syntax (KILLME).
447-
let args = match (start, end) {
448-
(&Some(ref e1), &Some(ref e2)) => vec![&**e1, &**e2],
449-
(&Some(ref e), &None) => vec![&**e],
450-
(&None, &Some(ref e)) => vec![&**e],
451-
(&None, &None) => Vec::new()
452-
};
453-
let overloaded =
454-
self.walk_overloaded_operator(expr, &**lhs, args, PassArgs::ByRef);
455-
assert!(overloaded);
456-
}
457-
_ => {
458-
if !self.walk_overloaded_operator(expr,
459-
&**lhs,
460-
vec![&**rhs],
461-
PassArgs::ByRef) {
462-
self.select_from_expr(&**lhs);
463-
self.consume_expr(&**rhs);
464-
}
465-
}
444+
if !self.walk_overloaded_operator(expr,
445+
&**lhs,
446+
vec![&**rhs],
447+
PassArgs::ByRef) {
448+
self.select_from_expr(&**lhs);
449+
self.consume_expr(&**rhs);
466450
}
467451
}
468452

src/librustc/middle/lang_items.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ lets_do_this! {
266266
ShrTraitLangItem, "shr", shr_trait;
267267
IndexTraitLangItem, "index", index_trait;
268268
IndexMutTraitLangItem, "index_mut", index_mut_trait;
269-
SliceTraitLangItem, "slice", slice_trait;
270-
SliceMutTraitLangItem, "slice_mut", slice_mut_trait;
271269
RangeStructLangItem, "range", range_struct;
272270
RangeFromStructLangItem, "range_from", range_from_struct;
273271
RangeToStructLangItem, "range_to", range_to_struct;

src/librustc/middle/mem_categorization.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -482,28 +482,20 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
482482
Ok(self.cat_tup_field(expr, base_cmt, idx.node, expr_ty))
483483
}
484484

485-
ast::ExprIndex(ref base, ref idx) => {
486-
match idx.node {
487-
ast::ExprRange(..) => {
488-
// Slicing syntax special case (KILLME).
489-
Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty))
485+
ast::ExprIndex(ref base, _) => {
486+
let method_call = ty::MethodCall::expr(expr.id());
487+
match self.typer.node_method_ty(method_call) {
488+
Some(method_ty) => {
489+
// If this is an index implemented by a method call, then it will
490+
// include an implicit deref of the result.
491+
let ret_ty = ty::ty_fn_ret(method_ty).unwrap();
492+
self.cat_deref(expr,
493+
self.cat_rvalue_node(expr.id(),
494+
expr.span(),
495+
ret_ty), 1, true)
490496
}
491-
_ => {
492-
let method_call = ty::MethodCall::expr(expr.id());
493-
match self.typer.node_method_ty(method_call) {
494-
Some(method_ty) => {
495-
// If this is an index implemented by a method call, then it will
496-
// include an implicit deref of the result.
497-
let ret_ty = ty::ty_fn_ret(method_ty).unwrap();
498-
self.cat_deref(expr,
499-
self.cat_rvalue_node(expr.id(),
500-
expr.span(),
501-
ret_ty), 1, true)
502-
}
503-
None => {
504-
self.cat_index(expr, try!(self.cat_expr(&**base)))
505-
}
506-
}
497+
None => {
498+
self.cat_index(expr, self.cat_expr(&**base))
507499
}
508500
}
509501
}

src/librustc/middle/ty.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ pub struct ClosureTy<'tcx> {
10471047
pub abi: abi::Abi,
10481048
}
10491049

1050-
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
1050+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Show)]
10511051
pub enum FnOutput<'tcx> {
10521052
FnConverging(Ty<'tcx>),
10531053
FnDiverging
@@ -1699,8 +1699,7 @@ impl fmt::Show for RegionVid {
16991699

17001700
impl<'tcx> fmt::Show for FnSig<'tcx> {
17011701
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1702-
// grr, without tcx not much we can do.
1703-
write!(f, "(...)")
1702+
write!(f, "({}; variadic: {})->{}", self.inputs, self.variadic, self.output)
17041703
}
17051704
}
17061705

src/librustc_trans/trans/cleanup.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ use trans::common;
2424
use trans::common::{Block, FunctionContext, ExprId, NodeInfo};
2525
use trans::debuginfo;
2626
use trans::glue;
27-
// Temporary due to slicing syntax hacks (KILLME)
28-
//use middle::region;
27+
use middle::region;
2928
use trans::type_::Type;
3029
use middle::ty::{self, Ty};
3130
use std::fmt;
@@ -129,16 +128,15 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
129128
// excluding id's that correspond to closure bodies only). For
130129
// now we just say that if there is already an AST scope on the stack,
131130
// this new AST scope had better be its immediate child.
132-
// Temporarily removed due to slicing syntax hacks (KILLME).
133-
/*let top_scope = self.top_ast_scope();
131+
let top_scope = self.top_ast_scope();
134132
if top_scope.is_some() {
135133
assert_eq!(self.ccx
136134
.tcx()
137135
.region_maps
138136
.opt_encl_scope(region::CodeExtent::from_node_id(debug_loc.id))
139137
.map(|s|s.node_id()),
140138
top_scope);
141-
}*/
139+
}
142140

143141
self.push_scope(CleanupScope::new(AstScopeKind(debug_loc.id),
144142
Some(debug_loc)));

src/librustc_trans/trans/expr.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -573,40 +573,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
573573
trans_rec_tup_field(bcx, &**base, idx.node)
574574
}
575575
ast::ExprIndex(ref base, ref idx) => {
576-
match idx.node {
577-
ast::ExprRange(ref start, ref end) => {
578-
// Special case for slicing syntax (KILLME).
579-
let _icx = push_ctxt("trans_slice");
580-
let ccx = bcx.ccx();
581-
582-
let method_call = MethodCall::expr(expr.id);
583-
let method_ty = ccx.tcx()
584-
.method_map
585-
.borrow()
586-
.get(&method_call)
587-
.map(|method| method.ty);
588-
let base_datum = unpack_datum!(bcx, trans(bcx, &**base));
589-
590-
let mut args = vec![];
591-
start.as_ref().map(|e| args.push((unpack_datum!(bcx, trans(bcx, &**e)), e.id)));
592-
end.as_ref().map(|e| args.push((unpack_datum!(bcx, trans(bcx, &**e)), e.id)));
593-
594-
let result_ty = ty::ty_fn_ret(monomorphize_type(bcx,
595-
method_ty.unwrap())).unwrap();
596-
let scratch = rvalue_scratch_datum(bcx, result_ty, "trans_slice");
597-
598-
unpack_result!(bcx,
599-
trans_overloaded_op(bcx,
600-
expr,
601-
method_call,
602-
base_datum,
603-
args,
604-
Some(SaveIn(scratch.val)),
605-
true));
606-
DatumBlock::new(bcx, scratch.to_expr_datum())
607-
}
608-
_ => trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
609-
}
576+
trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
610577
}
611578
ast::ExprBox(_, ref contents) => {
612579
// Special case for `Box<T>`

0 commit comments

Comments
 (0)