syntax: Remove #[allow(vecs_implicitly_copyable)]

This commit is contained in:
Alex Crichton 2013-05-12 00:25:31 -04:00
parent 2951527528
commit 92d39fe4d5
25 changed files with 235 additions and 232 deletions

View file

@ -60,11 +60,11 @@ fn cs_clone(cx: @ext_ctxt, span: span,
build::mk_method_call(cx, span, field, clone_ident, ~[]);
match *substr.fields {
Struct(af) => {
Struct(ref af) => {
ctor_ident = ~[ substr.type_ident ];
all_fields = af;
}
EnumMatching(_, variant, af) => {
EnumMatching(_, variant, ref af) => {
ctor_ident = ~[ variant.node.name ];
all_fields = af;
},
@ -72,7 +72,7 @@ fn cs_clone(cx: @ext_ctxt, span: span,
StaticEnum(*) | StaticStruct(*) => cx.span_bug(span, "Static method in `deriving(Clone)`")
}
match all_fields {
match *all_fields {
[(None, _, _), .. _] => {
// enum-like
let subcalls = all_fields.map(|&(_, self_f, _)| subcall(self_f));

View file

@ -65,8 +65,6 @@ fn cs_ord(less: bool, equal: bool,
let false_blk_expr = build::mk_block(cx, span,
~[], ~[],
Some(build::mk_bool(cx, span, false)));
let true_blk = build::mk_simple_block(cx, span,
build::mk_bool(cx, span, true));
let base = build::mk_bool(cx, span, equal);
cs_fold(
@ -108,6 +106,8 @@ fn cs_ord(less: bool, equal: bool,
let cmp = build::mk_method_call(cx, span,
self_f, binop, other_fs.to_owned());
let true_blk = build::mk_simple_block(cx, span,
build::mk_bool(cx, span, true));
let if_ = expr_if(cmp, true_blk, Some(elseif));
build::mk_expr(cx, span, if_)

View file

@ -55,15 +55,16 @@ pub fn ordering_const(cx: @ext_ctxt, span: span, cnst: Ordering) -> @expr {
pub fn cs_cmp(cx: @ext_ctxt, span: span,
substr: &Substructure) -> @expr {
let lexical_ord = ~[cx.ident_of("core"),
cx.ident_of("cmp"),
cx.ident_of("lexical_ordering")];
cs_same_method_fold(
// foldr (possibly) nests the matches in lexical_ordering better
false,
|cx, span, old, new| {
build::mk_call_global(cx, span, lexical_ord, ~[old, new])
build::mk_call_global(cx, span,
~[cx.ident_of("core"),
cx.ident_of("cmp"),
cx.ident_of("lexical_ordering")],
~[old, new])
},
ordering_const(cx, span, Equal),
|cx, span, list, _| {

View file

@ -259,14 +259,14 @@ pub enum SubstructureFields<'self> {
fields: `(field ident, self, [others])`, where the field ident is
only non-`None` in the case of a struct variant.
*/
EnumMatching(uint, ast::variant, ~[(Option<ident>, @expr, ~[@expr])]),
EnumMatching(uint, &'self ast::variant, ~[(Option<ident>, @expr, ~[@expr])]),
/**
non-matching variants of the enum, [(variant index, ast::variant,
[field ident, fields])] (i.e. all fields for self are in the
first tuple, for other1 are in the second tuple, etc.)
*/
EnumNonMatching(~[(uint, ast::variant, ~[(Option<ident>, @expr)])]),
EnumNonMatching(&'self [(uint, ast::variant, ~[(Option<ident>, @expr)])]),
/// A static method where Self is a struct
StaticStruct(&'self ast::struct_def, Either<uint, ~[ident]>),
@ -290,7 +290,7 @@ representing each variant: (variant index, ast::variant instance,
*/
pub type EnumNonMatchFunc<'self> =
&'self fn(@ext_ctxt, span,
~[(uint, ast::variant,
&[(uint, ast::variant,
~[(Option<ident>, @expr)])],
&[@expr]) -> @expr;
@ -416,8 +416,9 @@ impl<'self> MethodDef<'self> {
let mut nonstatic = false;
match self.self_ty {
Some(self_ptr) => {
let (self_expr, self_ty) = ty::get_explicit_self(cx, span, self_ptr);
Some(ref self_ptr) => {
let (self_expr, self_ty) = ty::get_explicit_self(cx, span,
self_ptr);
ast_self_ty = self_ty;
self_args.push(self_expr);
@ -616,9 +617,10 @@ impl<'self> MethodDef<'self> {
self_args: &[@expr],
nonself_args: &[@expr])
-> @expr {
let mut matches = ~[];
self.build_enum_match(cx, span, enum_def, type_ident,
self_args, nonself_args,
None, ~[], 0)
None, &mut matches, 0)
}
@ -650,58 +652,57 @@ impl<'self> MethodDef<'self> {
self_args: &[@expr],
nonself_args: &[@expr],
matching: Option<uint>,
matches_so_far: ~[(uint, ast::variant,
~[(Option<ident>, @expr)])],
matches_so_far: &mut ~[(uint, ast::variant,
~[(Option<ident>, @expr)])],
match_count: uint) -> @expr {
if match_count == self_args.len() {
// we've matched against all arguments, so make the final
// expression at the bottom of the match tree
match matches_so_far {
[] => cx.span_bug(span, ~"no self match on an enum in generic `deriving`"),
_ => {
// we currently have a vec of vecs, where each
// subvec is the fields of one of the arguments,
// but if the variants all match, we want this as
// vec of tuples, where each tuple represents a
// field.
if matches_so_far.len() == 0 {
cx.span_bug(span, ~"no self match on an enum in generic \
`deriving`");
}
// we currently have a vec of vecs, where each
// subvec is the fields of one of the arguments,
// but if the variants all match, we want this as
// vec of tuples, where each tuple represents a
// field.
let substructure;
let substructure;
// most arms don't have matching variants, so do a
// quick check to see if they match (even though
// this means iterating twice) instead of being
// optimistic and doing a pile of allocations etc.
match matching {
Some(variant_index) => {
// `ref` inside let matches is buggy. Causes havoc wih rusc.
// let (variant_index, ref self_vec) = matches_so_far[0];
let (variant, self_vec) = match matches_so_far[0] {
(_, v, ref s) => (v, s)
};
// most arms don't have matching variants, so do a
// quick check to see if they match (even though
// this means iterating twice) instead of being
// optimistic and doing a pile of allocations etc.
match matching {
Some(variant_index) => {
// `ref` inside let matches is buggy. Causes havoc wih rusc.
// let (variant_index, ref self_vec) = matches_so_far[0];
let (variant, self_vec) = match matches_so_far[0] {
(_, ref v, ref s) => (v, s)
};
let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]);
let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]);
for matches_so_far.tail().each |&(_, _, other_fields)| {
for other_fields.eachi |i, &(_, other_field)| {
enum_matching_fields[i].push(other_field);
}
}
let field_tuples =
do vec::map_zip(*self_vec,
enum_matching_fields) |&(id, self_f), &other| {
(id, self_f, other)
};
substructure = EnumMatching(variant_index, variant, field_tuples);
}
None => {
substructure = EnumNonMatching(matches_so_far);
for matches_so_far.tail().each |&(_, _, other_fields)| {
for other_fields.eachi |i, &(_, other_field)| {
enum_matching_fields[i].push(other_field);
}
}
self.call_substructure_method(cx, span, type_ident,
self_args, nonself_args,
&substructure)
let field_tuples =
do vec::map_zip(*self_vec,
enum_matching_fields) |&(id, self_f), &other| {
(id, self_f, other)
};
substructure = EnumMatching(variant_index, variant, field_tuples);
}
None => {
substructure = EnumNonMatching(*matches_so_far);
}
}
self.call_substructure_method(cx, span, type_ident,
self_args, nonself_args,
&substructure)
} else { // there are still matches to create
let current_match_str = if match_count == 0 {
@ -712,9 +713,6 @@ impl<'self> MethodDef<'self> {
let mut arms = ~[];
// this is used as a stack
let mut matches_so_far = matches_so_far;
// the code for nonmatching variants only matters when
// we've seen at least one other variant already
if self.const_nonmatching && match_count > 0 {
@ -732,7 +730,7 @@ impl<'self> MethodDef<'self> {
current_match_str,
ast::m_imm);
matches_so_far.push((index, *variant, idents));
matches_so_far.push((index, /*bad*/ copy *variant, idents));
let arm_expr = self.build_enum_match(cx, span,
enum_def,
type_ident,
@ -744,9 +742,10 @@ impl<'self> MethodDef<'self> {
arms.push(build::mk_arm(cx, span, ~[ pattern ], arm_expr));
if enum_def.variants.len() > 1 {
let e = &EnumNonMatching(&[]);
let wild_expr = self.call_substructure_method(cx, span, type_ident,
self_args, nonself_args,
&EnumNonMatching(~[]));
e);
let wild_arm = build::mk_arm(cx, span,
~[ build::mk_pat_wild(cx, span) ],
wild_expr);
@ -760,7 +759,7 @@ impl<'self> MethodDef<'self> {
current_match_str,
ast::m_imm);
matches_so_far.push((index, *variant, idents));
matches_so_far.push((index, /*bad*/ copy *variant, idents));
let new_matching =
match matching {
_ if match_count == 0 => Some(index),
@ -850,7 +849,7 @@ pub fn cs_fold(use_foldl: bool,
cx: @ext_ctxt, span: span,
substructure: &Substructure) -> @expr {
match *substructure.fields {
EnumMatching(_, _, all_fields) | Struct(all_fields) => {
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
if use_foldl {
do all_fields.foldl(base) |&old, &(_, self_f, other_fs)| {
f(cx, span, old, self_f, other_fs)
@ -861,8 +860,9 @@ pub fn cs_fold(use_foldl: bool,
}
}
},
EnumNonMatching(all_enums) => enum_nonmatch_f(cx, span,
all_enums, substructure.nonself_args),
EnumNonMatching(ref all_enums) => enum_nonmatch_f(cx, span,
*all_enums,
substructure.nonself_args),
StaticEnum(*) | StaticStruct(*) => {
cx.span_bug(span, "Static function in `deriving`")
}
@ -885,7 +885,7 @@ pub fn cs_same_method(f: &fn(@ext_ctxt, span, ~[@expr]) -> @expr,
cx: @ext_ctxt, span: span,
substructure: &Substructure) -> @expr {
match *substructure.fields {
EnumMatching(_, _, all_fields) | Struct(all_fields) => {
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
// call self_n.method(other_1_n, other_2_n, ...)
let called = do all_fields.map |&(_, self_field, other_fields)| {
build::mk_method_call(cx, span,
@ -896,8 +896,9 @@ pub fn cs_same_method(f: &fn(@ext_ctxt, span, ~[@expr]) -> @expr,
f(cx, span, called)
},
EnumNonMatching(all_enums) => enum_nonmatch_f(cx, span,
all_enums, substructure.nonself_args),
EnumNonMatching(ref all_enums) => enum_nonmatch_f(cx, span,
*all_enums,
substructure.nonself_args),
StaticEnum(*) | StaticStruct(*) => {
cx.span_bug(span, "Static function in `deriving`")
}

View file

@ -59,7 +59,7 @@ pub fn expand_meta_deriving(cx: @ext_ctxt,
use ast::{meta_list, meta_name_value, meta_word};
match mitem.node {
meta_name_value(_, l) => {
meta_name_value(_, ref l) => {
cx.span_err(l.span, ~"unexpected value in `deriving`");
in_items
}
@ -67,7 +67,7 @@ pub fn expand_meta_deriving(cx: @ext_ctxt,
cx.span_warn(mitem.span, ~"empty trait list in `deriving`");
in_items
}
meta_list(_, titems) => {
meta_list(_, ref titems) => {
do titems.foldr(in_items) |&titem, in_items| {
match titem.node {
meta_name_value(tname, _) |
@ -92,9 +92,9 @@ pub fn expand_meta_deriving(cx: @ext_ctxt,
~"ToStr" => expand!(to_str::expand_deriving_to_str),
tname => {
ref tname => {
cx.span_err(titem.span, fmt!("unknown \
`deriving` trait: `%s`", tname));
`deriving` trait: `%s`", *tname));
in_items
}
}

View file

@ -63,7 +63,7 @@ pub impl Path {
fn to_path(&self, cx: @ext_ctxt, span: span,
self_ty: ident, self_generics: &Generics) -> @ast::Path {
let idents = self.path.map(|s| cx.ident_of(*s) );
let lt = mk_lifetime(cx, span, self.lifetime);
let lt = mk_lifetime(cx, span, &self.lifetime);
let tys = self.params.map(|t| t.to_ty(cx, span, self_ty, self_generics));
if self.global {
@ -106,9 +106,9 @@ pub fn nil_ty() -> Ty {
Tuple(~[])
}
fn mk_lifetime(cx: @ext_ctxt, span: span, lt: Option<~str>) -> Option<@ast::Lifetime> {
match lt {
Some(s) => Some(@build::mk_lifetime(cx, span, cx.ident_of(s))),
fn mk_lifetime(cx: @ext_ctxt, span: span, lt: &Option<~str>) -> Option<@ast::Lifetime> {
match *lt {
Some(ref s) => Some(@build::mk_lifetime(cx, span, cx.ident_of(*s))),
None => None
}
}
@ -123,10 +123,10 @@ pub impl Ty {
Owned => {
build::mk_ty_uniq(cx, span, raw_ty)
}
Managed(copy mutbl) => {
Managed(mutbl) => {
build::mk_ty_box(cx, span, raw_ty, mutbl)
}
Borrowed(copy lt, copy mutbl) => {
Borrowed(ref lt, mutbl) => {
let lt = mk_lifetime(cx, span, lt);
build::mk_ty_rptr(cx, span, raw_ty, lt, mutbl)
}
@ -216,20 +216,20 @@ pub impl LifetimeBounds {
}
pub fn get_explicit_self(cx: @ext_ctxt, span: span, self_ptr: Option<PtrTy>)
pub fn get_explicit_self(cx: @ext_ctxt, span: span, self_ptr: &Option<PtrTy>)
-> (@expr, ast::self_ty) {
let self_path = build::make_self(cx, span);
match self_ptr {
match *self_ptr {
None => {
(self_path, respan(span, ast::sty_value))
}
Some(ptr) => {
Some(ref ptr) => {
let self_ty = respan(
span,
match ptr {
match *ptr {
Owned => ast::sty_uniq(ast::m_imm),
Managed(mutbl) => ast::sty_box(mutbl),
Borrowed(lt, mutbl) => {
Borrowed(ref lt, mutbl) => {
let lt = lt.map(|s| @build::mk_lifetime(cx, span,
cx.ident_of(*s)));
ast::sty_region(lt, mutbl)