Skip to content

Commit 92d39fe

Browse files
committed
syntax: Remove #[allow(vecs_implicitly_copyable)]
1 parent 2951527 commit 92d39fe

25 files changed

+239
-236
lines changed

src/libsyntax/ast_map.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ pub fn path_to_str_with_sep(p: &[path_elt], sep: ~str, itr: @ident_interner)
6060
str::connect(strs, sep)
6161
}
6262

63-
pub fn path_ident_to_str(p: path, i: ident, itr: @ident_interner) -> ~str {
64-
if vec::is_empty(p) {
63+
pub fn path_ident_to_str(p: &path, i: ident, itr: @ident_interner) -> ~str {
64+
if vec::is_empty(*p) {
6565
//FIXME /* FIXME (#2543) */ copy *i
6666
copy *itr.get(i)
6767
} else {
68-
fmt!("%s::%s", path_to_str(p, itr), *itr.get(i))
68+
fmt!("%s::%s", path_to_str(*p, itr), *itr.get(i))
6969
}
7070
}
7171

@@ -338,7 +338,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
338338
fmt!("unknown node (id=%d)", id)
339339
}
340340
Some(&node_item(item, path)) => {
341-
let path_str = path_ident_to_str(*path, item.ident, itr);
341+
let path_str = path_ident_to_str(path, item.ident, itr);
342342
let item_str = match item.node {
343343
item_const(*) => ~"const",
344344
item_fn(*) => ~"fn",
@@ -355,7 +355,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
355355
}
356356
Some(&node_foreign_item(item, abi, _, path)) => {
357357
fmt!("foreign item %s with abi %? (id=%?)",
358-
path_ident_to_str(*path, item.ident, itr), abi, id)
358+
path_ident_to_str(path, item.ident, itr), abi, id)
359359
}
360360
Some(&node_method(m, _, path)) => {
361361
fmt!("method %s in %s (id=%?)",

src/libsyntax/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn diagnosticcolor(lvl: level) -> u8 {
184184
}
185185
}
186186

187-
fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
187+
fn print_diagnostic(topic: &str, lvl: level, msg: &str) {
188188
let use_color = term::color_supported() &&
189189
io::stderr().get_type() == io::Screen;
190190
if !topic.is_empty() {

src/libsyntax/ext/asm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
119119
cons = str::connect(clobs, ",");
120120
}
121121
Options => {
122-
let option = *p.parse_str();
122+
let option = p.parse_str();
123123

124-
if option == ~"volatile" {
124+
if "volatile" == *option {
125125
volatile = true;
126-
} else if option == ~"alignstack" {
126+
} else if "alignstack" == *option {
127127
alignstack = true;
128-
} else if option == ~"intel" {
128+
} else if "intel" == *option {
129129
dialect = ast::asm_intel;
130130
}
131131

src/libsyntax/ext/auto_encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ fn mk_struct_deser_impl(
836836
cx: @ext_ctxt,
837837
span: span,
838838
ident: ast::ident,
839-
fields: ~[@ast::struct_field],
839+
fields: &[@ast::struct_field],
840840
generics: &ast::Generics
841841
) -> @ast::item {
842842
let fields = do mk_struct_fields(fields).mapi |idx, field| {
@@ -1120,7 +1120,7 @@ fn mk_enum_deser_body(
11201120
ext_cx: @ext_ctxt,
11211121
span: span,
11221122
name: ast::ident,
1123-
variants: ~[ast::variant]
1123+
variants: &[ast::variant]
11241124
) -> @ast::expr {
11251125
let expr_arm_names = build::mk_base_vec_e(
11261126
ext_cx,

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ pub fn mk_unreachable(cx: @ext_ctxt, span: span) -> @ast::expr {
509509
],
510510
~[
511511
mk_base_str(cx, span, ~"internal error: entered unreachable code"),
512-
mk_base_str(cx, span, loc.file.name),
512+
mk_base_str(cx, span, copy loc.file.name),
513513
mk_uint(cx, span, loc.line),
514514
]
515515
)

src/libsyntax/ext/deriving/clone.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ fn cs_clone(cx: @ext_ctxt, span: span,
6060
build::mk_method_call(cx, span, field, clone_ident, ~[]);
6161

6262
match *substr.fields {
63-
Struct(af) => {
63+
Struct(ref af) => {
6464
ctor_ident = ~[ substr.type_ident ];
6565
all_fields = af;
6666
}
67-
EnumMatching(_, variant, af) => {
67+
EnumMatching(_, variant, ref af) => {
6868
ctor_ident = ~[ variant.node.name ];
6969
all_fields = af;
7070
},
7171
EnumNonMatching(*) => cx.span_bug(span, "Non-matching enum variants in `deriving(Clone)`"),
7272
StaticEnum(*) | StaticStruct(*) => cx.span_bug(span, "Static method in `deriving(Clone)`")
7373
}
7474

75-
match all_fields {
75+
match *all_fields {
7676
[(None, _, _), .. _] => {
7777
// enum-like
7878
let subcalls = all_fields.map(|&(_, self_f, _)| subcall(self_f));

src/libsyntax/ext/deriving/cmp/ord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ fn cs_ord(less: bool, equal: bool,
6565
let false_blk_expr = build::mk_block(cx, span,
6666
~[], ~[],
6767
Some(build::mk_bool(cx, span, false)));
68-
let true_blk = build::mk_simple_block(cx, span,
69-
build::mk_bool(cx, span, true));
7068
let base = build::mk_bool(cx, span, equal);
7169
7270
cs_fold(
@@ -108,6 +106,8 @@ fn cs_ord(less: bool, equal: bool,
108106

109107
let cmp = build::mk_method_call(cx, span,
110108
self_f, binop, other_fs.to_owned());
109+
let true_blk = build::mk_simple_block(cx, span,
110+
build::mk_bool(cx, span, true));
111111
let if_ = expr_if(cmp, true_blk, Some(elseif));
112112

113113
build::mk_expr(cx, span, if_)

src/libsyntax/ext/deriving/cmp/totalord.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ pub fn ordering_const(cx: @ext_ctxt, span: span, cnst: Ordering) -> @expr {
5555

5656
pub fn cs_cmp(cx: @ext_ctxt, span: span,
5757
substr: &Substructure) -> @expr {
58-
let lexical_ord = ~[cx.ident_of("core"),
59-
cx.ident_of("cmp"),
60-
cx.ident_of("lexical_ordering")];
6158

6259
cs_same_method_fold(
6360
// foldr (possibly) nests the matches in lexical_ordering better
6461
false,
6562
|cx, span, old, new| {
66-
build::mk_call_global(cx, span, lexical_ord, ~[old, new])
63+
build::mk_call_global(cx, span,
64+
~[cx.ident_of("core"),
65+
cx.ident_of("cmp"),
66+
cx.ident_of("lexical_ordering")],
67+
~[old, new])
6768
},
6869
ordering_const(cx, span, Equal),
6970
|cx, span, list, _| {

src/libsyntax/ext/deriving/generic.rs

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,14 @@ pub enum SubstructureFields<'self> {
259259
fields: `(field ident, self, [others])`, where the field ident is
260260
only non-`None` in the case of a struct variant.
261261
*/
262-
EnumMatching(uint, ast::variant, ~[(Option<ident>, @expr, ~[@expr])]),
262+
EnumMatching(uint, &'self ast::variant, ~[(Option<ident>, @expr, ~[@expr])]),
263263

264264
/**
265265
non-matching variants of the enum, [(variant index, ast::variant,
266266
[field ident, fields])] (i.e. all fields for self are in the
267267
first tuple, for other1 are in the second tuple, etc.)
268268
*/
269-
EnumNonMatching(~[(uint, ast::variant, ~[(Option<ident>, @expr)])]),
269+
EnumNonMatching(&'self [(uint, ast::variant, ~[(Option<ident>, @expr)])]),
270270

271271
/// A static method where Self is a struct
272272
StaticStruct(&'self ast::struct_def, Either<uint, ~[ident]>),
@@ -290,7 +290,7 @@ representing each variant: (variant index, ast::variant instance,
290290
*/
291291
pub type EnumNonMatchFunc<'self> =
292292
&'self fn(@ext_ctxt, span,
293-
~[(uint, ast::variant,
293+
&[(uint, ast::variant,
294294
~[(Option<ident>, @expr)])],
295295
&[@expr]) -> @expr;
296296

@@ -416,8 +416,9 @@ impl<'self> MethodDef<'self> {
416416
let mut nonstatic = false;
417417

418418
match self.self_ty {
419-
Some(self_ptr) => {
420-
let (self_expr, self_ty) = ty::get_explicit_self(cx, span, self_ptr);
419+
Some(ref self_ptr) => {
420+
let (self_expr, self_ty) = ty::get_explicit_self(cx, span,
421+
self_ptr);
421422

422423
ast_self_ty = self_ty;
423424
self_args.push(self_expr);
@@ -616,9 +617,10 @@ impl<'self> MethodDef<'self> {
616617
self_args: &[@expr],
617618
nonself_args: &[@expr])
618619
-> @expr {
620+
let mut matches = ~[];
619621
self.build_enum_match(cx, span, enum_def, type_ident,
620622
self_args, nonself_args,
621-
None, ~[], 0)
623+
None, &mut matches, 0)
622624
}
623625

624626

@@ -650,58 +652,57 @@ impl<'self> MethodDef<'self> {
650652
self_args: &[@expr],
651653
nonself_args: &[@expr],
652654
matching: Option<uint>,
653-
matches_so_far: ~[(uint, ast::variant,
654-
~[(Option<ident>, @expr)])],
655+
matches_so_far: &mut ~[(uint, ast::variant,
656+
~[(Option<ident>, @expr)])],
655657
match_count: uint) -> @expr {
656658
if match_count == self_args.len() {
657659
// we've matched against all arguments, so make the final
658660
// expression at the bottom of the match tree
659-
match matches_so_far {
660-
[] => cx.span_bug(span, ~"no self match on an enum in generic `deriving`"),
661-
_ => {
662-
// we currently have a vec of vecs, where each
663-
// subvec is the fields of one of the arguments,
664-
// but if the variants all match, we want this as
665-
// vec of tuples, where each tuple represents a
666-
// field.
667-
668-
let substructure;
669-
670-
// most arms don't have matching variants, so do a
671-
// quick check to see if they match (even though
672-
// this means iterating twice) instead of being
673-
// optimistic and doing a pile of allocations etc.
674-
match matching {
675-
Some(variant_index) => {
676-
// `ref` inside let matches is buggy. Causes havoc wih rusc.
677-
// let (variant_index, ref self_vec) = matches_so_far[0];
678-
let (variant, self_vec) = match matches_so_far[0] {
679-
(_, v, ref s) => (v, s)
680-
};
681-
682-
let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]);
683-
684-
for matches_so_far.tail().each |&(_, _, other_fields)| {
685-
for other_fields.eachi |i, &(_, other_field)| {
686-
enum_matching_fields[i].push(other_field);
687-
}
688-
}
689-
let field_tuples =
690-
do vec::map_zip(*self_vec,
691-
enum_matching_fields) |&(id, self_f), &other| {
692-
(id, self_f, other)
693-
};
694-
substructure = EnumMatching(variant_index, variant, field_tuples);
695-
}
696-
None => {
697-
substructure = EnumNonMatching(matches_so_far);
661+
if matches_so_far.len() == 0 {
662+
cx.span_bug(span, ~"no self match on an enum in generic \
663+
`deriving`");
664+
}
665+
// we currently have a vec of vecs, where each
666+
// subvec is the fields of one of the arguments,
667+
// but if the variants all match, we want this as
668+
// vec of tuples, where each tuple represents a
669+
// field.
670+
671+
let substructure;
672+
673+
// most arms don't have matching variants, so do a
674+
// quick check to see if they match (even though
675+
// this means iterating twice) instead of being
676+
// optimistic and doing a pile of allocations etc.
677+
match matching {
678+
Some(variant_index) => {
679+
// `ref` inside let matches is buggy. Causes havoc wih rusc.
680+
// let (variant_index, ref self_vec) = matches_so_far[0];
681+
let (variant, self_vec) = match matches_so_far[0] {
682+
(_, ref v, ref s) => (v, s)
683+
};
684+
685+
let mut enum_matching_fields = vec::from_elem(self_vec.len(), ~[]);
686+
687+
for matches_so_far.tail().each |&(_, _, other_fields)| {
688+
for other_fields.eachi |i, &(_, other_field)| {
689+
enum_matching_fields[i].push(other_field);
698690
}
699691
}
700-
self.call_substructure_method(cx, span, type_ident,
701-
self_args, nonself_args,
702-
&substructure)
692+
let field_tuples =
693+
do vec::map_zip(*self_vec,
694+
enum_matching_fields) |&(id, self_f), &other| {
695+
(id, self_f, other)
696+
};
697+
substructure = EnumMatching(variant_index, variant, field_tuples);
698+
}
699+
None => {
700+
substructure = EnumNonMatching(*matches_so_far);
703701
}
704702
}
703+
self.call_substructure_method(cx, span, type_ident,
704+
self_args, nonself_args,
705+
&substructure)
705706

706707
} else { // there are still matches to create
707708
let current_match_str = if match_count == 0 {
@@ -712,9 +713,6 @@ impl<'self> MethodDef<'self> {
712713

713714
let mut arms = ~[];
714715

715-
// this is used as a stack
716-
let mut matches_so_far = matches_so_far;
717-
718716
// the code for nonmatching variants only matters when
719717
// we've seen at least one other variant already
720718
if self.const_nonmatching && match_count > 0 {
@@ -732,7 +730,7 @@ impl<'self> MethodDef<'self> {
732730
current_match_str,
733731
ast::m_imm);
734732

735-
matches_so_far.push((index, *variant, idents));
733+
matches_so_far.push((index, /*bad*/ copy *variant, idents));
736734
let arm_expr = self.build_enum_match(cx, span,
737735
enum_def,
738736
type_ident,
@@ -744,9 +742,10 @@ impl<'self> MethodDef<'self> {
744742
arms.push(build::mk_arm(cx, span, ~[ pattern ], arm_expr));
745743

746744
if enum_def.variants.len() > 1 {
745+
let e = &EnumNonMatching(&[]);
747746
let wild_expr = self.call_substructure_method(cx, span, type_ident,
748747
self_args, nonself_args,
749-
&EnumNonMatching(~[]));
748+
e);
750749
let wild_arm = build::mk_arm(cx, span,
751750
~[ build::mk_pat_wild(cx, span) ],
752751
wild_expr);
@@ -760,7 +759,7 @@ impl<'self> MethodDef<'self> {
760759
current_match_str,
761760
ast::m_imm);
762761

763-
matches_so_far.push((index, *variant, idents));
762+
matches_so_far.push((index, /*bad*/ copy *variant, idents));
764763
let new_matching =
765764
match matching {
766765
_ if match_count == 0 => Some(index),
@@ -850,7 +849,7 @@ pub fn cs_fold(use_foldl: bool,
850849
cx: @ext_ctxt, span: span,
851850
substructure: &Substructure) -> @expr {
852851
match *substructure.fields {
853-
EnumMatching(_, _, all_fields) | Struct(all_fields) => {
852+
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
854853
if use_foldl {
855854
do all_fields.foldl(base) |&old, &(_, self_f, other_fs)| {
856855
f(cx, span, old, self_f, other_fs)
@@ -861,8 +860,9 @@ pub fn cs_fold(use_foldl: bool,
861860
}
862861
}
863862
},
864-
EnumNonMatching(all_enums) => enum_nonmatch_f(cx, span,
865-
all_enums, substructure.nonself_args),
863+
EnumNonMatching(ref all_enums) => enum_nonmatch_f(cx, span,
864+
*all_enums,
865+
substructure.nonself_args),
866866
StaticEnum(*) | StaticStruct(*) => {
867867
cx.span_bug(span, "Static function in `deriving`")
868868
}
@@ -885,7 +885,7 @@ pub fn cs_same_method(f: &fn(@ext_ctxt, span, ~[@expr]) -> @expr,
885885
cx: @ext_ctxt, span: span,
886886
substructure: &Substructure) -> @expr {
887887
match *substructure.fields {
888-
EnumMatching(_, _, all_fields) | Struct(all_fields) => {
888+
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
889889
// call self_n.method(other_1_n, other_2_n, ...)
890890
let called = do all_fields.map |&(_, self_field, other_fields)| {
891891
build::mk_method_call(cx, span,
@@ -896,8 +896,9 @@ pub fn cs_same_method(f: &fn(@ext_ctxt, span, ~[@expr]) -> @expr,
896896

897897
f(cx, span, called)
898898
},
899-
EnumNonMatching(all_enums) => enum_nonmatch_f(cx, span,
900-
all_enums, substructure.nonself_args),
899+
EnumNonMatching(ref all_enums) => enum_nonmatch_f(cx, span,
900+
*all_enums,
901+
substructure.nonself_args),
901902
StaticEnum(*) | StaticStruct(*) => {
902903
cx.span_bug(span, "Static function in `deriving`")
903904
}

0 commit comments

Comments
 (0)