diff options
| author | bors <bors@rust-lang.org> | 2013-03-11 10:15:58 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-11 10:15:58 -0700 |
| commit | 2ebb67487c1530822d83d6da6f71fa62cb68f2cd (patch) | |
| tree | 7c5b611ac00f1054d51fd657d7fb7d143291fce2 /src/libsyntax | |
| parent | 51cdca0bf0d3efc554c1815df9306ea10e881a14 (diff) | |
| parent | 08c840205ea477d4f76216abac45be6a4ce9fa4b (diff) | |
| download | rust-2ebb67487c1530822d83d6da6f71fa62cb68f2cd.tar.gz rust-2ebb67487c1530822d83d6da6f71fa62cb68f2cd.zip | |
auto merge of #5291 : pcwalton/rust/drop-lint, r=pcwalton
r? @nikomatsakis
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/ast_map.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/auto_encode.rs | 44 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/pipec.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/proto.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/opt_vec.rs | 20 | ||||
| -rw-r--r-- | src/libsyntax/parse/common.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/obsolete.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 33 |
15 files changed, 75 insertions, 112 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f3e73823f69..27dba9c2b5e 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1086,7 +1086,7 @@ pub enum variant_kind { #[auto_encode] #[auto_decode] #[deriving_eq] -pub struct enum_def_ { +pub struct enum_def { variants: ~[variant], common: Option<@struct_def>, } @@ -1094,11 +1094,6 @@ pub struct enum_def_ { #[auto_encode] #[auto_decode] #[deriving_eq] -pub enum enum_def = enum_def_; - -#[auto_encode] -#[auto_decode] -#[deriving_eq] pub struct variant_ { name: ident, attrs: ~[attribute], diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 3001fe8069c..a7d5c0ce75f 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -423,7 +423,7 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str { } pub fn node_item_query<Result>(items: map, id: node_id, - query: fn(@item) -> Result, + query: &fn(@item) -> Result, +error_msg: ~str) -> Result { match items.find(&id) { Some(node_item(it, _)) => query(it), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 7b0e72e6e95..35b188a248f 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -516,7 +516,7 @@ pub pure fn is_item_impl(item: @ast::item) -> bool { } } -pub fn walk_pat(pat: @pat, it: fn(@pat)) { +pub fn walk_pat(pat: @pat, it: &fn(@pat)) { it(pat); match pat.node { pat_ident(_, _, Some(p)) => walk_pat(p, it), diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 3397ca91c96..0d6ece8ad92 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -35,11 +35,11 @@ pub trait Pos { } /// A byte offset -pub enum BytePos = uint; +pub struct BytePos(uint); /// A character offset. Because of multibyte utf8 characters, a byte offset /// is not equivalent to a character offset. The CodeMap will convert BytePos /// values to CharPos values as necessary. -pub enum CharPos = uint; +pub struct CharPos(uint); // XXX: Lots of boilerplate in these impls, but so far my attempts to fix // have been unsuccessful diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 33e734fbd64..4e177fecec9 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -306,7 +306,7 @@ fn print_macro_backtrace(cm: @codemap::CodeMap, sp: span) { pub fn expect<T:Copy>(diag: span_handler, opt: Option<T>, - msg: fn() -> ~str) -> T { + msg: &fn() -> ~str) -> T { match opt { Some(ref t) => (*t), None => diag.handler().bug(msg()) diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index ecb5be6cc3c..c99d8977643 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -432,7 +432,7 @@ fn mk_impl( ty_param: ast::TyParam, path: @ast::path, generics: &ast::Generics, - f: fn(@ast::Ty) -> @ast::method + f: &fn(@ast::Ty) -> @ast::method ) -> @ast::item { /*! * @@ -1256,51 +1256,51 @@ mod test { fn emit_owned_str(&self, +_v: &str) { self.add_unknown_to_log(); } fn emit_managed_str(&self, +_v: &str) { self.add_unknown_to_log(); } - fn emit_borrowed(&self, f: fn()) { self.add_unknown_to_log(); f() } - fn emit_owned(&self, f: fn()) { self.add_unknown_to_log(); f() } - fn emit_managed(&self, f: fn()) { self.add_unknown_to_log(); f() } + fn emit_borrowed(&self, f: &fn()) { self.add_unknown_to_log(); f() } + fn emit_owned(&self, f: &fn()) { self.add_unknown_to_log(); f() } + fn emit_managed(&self, f: &fn()) { self.add_unknown_to_log(); f() } - fn emit_enum(&self, name: &str, f: fn()) { + fn emit_enum(&self, name: &str, f: &fn()) { self.add_to_log(CallToEmitEnum(name.to_str())); f(); } fn emit_enum_variant(&self, name: &str, +id: uint, - +cnt: uint, f: fn()) { + +cnt: uint, f: &fn()) { self.add_to_log(CallToEmitEnumVariant (name.to_str(),id,cnt)); f(); } - fn emit_enum_variant_arg(&self, +idx: uint, f: fn()) { + fn emit_enum_variant_arg(&self, +idx: uint, f: &fn()) { self.add_to_log(CallToEmitEnumVariantArg (idx)); f(); } - fn emit_borrowed_vec(&self, +_len: uint, f: fn()) { + fn emit_borrowed_vec(&self, +_len: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_owned_vec(&self, +_len: uint, f: fn()) { + fn emit_owned_vec(&self, +_len: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_managed_vec(&self, +_len: uint, f: fn()) { + fn emit_managed_vec(&self, +_len: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_vec_elt(&self, +_idx: uint, f: fn()) { + fn emit_vec_elt(&self, +_idx: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_rec(&self, f: fn()) { + fn emit_rec(&self, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_struct(&self, name: &str, +len: uint, f: fn()) { + fn emit_struct(&self, name: &str, +len: uint, f: &fn()) { self.add_to_log(CallToEmitStruct (name.to_str(),len)); f(); } - fn emit_field(&self, name: &str, +idx: uint, f: fn()) { + fn emit_field(&self, name: &str, +idx: uint, f: &fn()) { self.add_to_log(CallToEmitField (name.to_str(),idx)); f(); } - fn emit_tup(&self, +_len: uint, f: fn()) { + fn emit_tup(&self, +_len: uint, f: &fn()) { self.add_unknown_to_log(); f(); } - fn emit_tup_elt(&self, +_idx: uint, f: fn()) { + fn emit_tup_elt(&self, +_idx: uint, f: &fn()) { self.add_unknown_to_log(); f(); } } @@ -1327,16 +1327,4 @@ mod test { CallToEmitEnumVariantArg (1), CallToEmitUint (44)]); } - - pub enum BPos = uint; - - #[auto_encode] - pub struct HasPos { pos : BPos } - - #[test] fn encode_newtype_test () { - check_equal (to_call_log (HasPos {pos:BPos(48)}), - ~[CallToEmitStruct(~"HasPos",1), - CallToEmitField(~"pos",0), - CallToEmitUint(48)]); - } } diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 001e1b0daf6..fd8b2dbf72f 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -238,9 +238,7 @@ impl to_type_decls for state { cx.item_enum_poly( name, self.span, - ast::enum_def(enum_def_ { - variants: items_msg, - common: None }), + ast::enum_def { variants: items_msg, common: None }, cx.strip_bounds(&self.generics) ) ] diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 329b3f59b1e..dc9abd536d1 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -104,7 +104,7 @@ pub impl state_ { /// Iterate over the states that can be reached in one message /// from this state. - fn reachable(&self, f: fn(state) -> bool) { + fn reachable(&self, f: &fn(state) -> bool) { for self.messages.each |m| { match *m { message(_, _, _, _, Some(next_state { state: ref id, _ })) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 2a5fe788770..427760c920f 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -254,16 +254,14 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ { } item_enum(ref enum_definition, ref generics) => { item_enum( - ast::enum_def( - ast::enum_def_ { - variants: do enum_definition.variants.map |x| { - fld.fold_variant(x) - }, - common: do enum_definition.common.map |x| { - fold_struct_def(*x, fld) - } + ast::enum_def { + variants: do enum_definition.variants.map |x| { + fld.fold_variant(x) + }, + common: do enum_definition.common.map |x| { + fold_struct_def(*x, fld) } - ), + }, fold_generics(generics, fld)) } item_struct(ref struct_def, ref generics) => { @@ -684,10 +682,7 @@ fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ { fold_struct_def(*x, fld) }; kind = enum_variant_kind( - ast::enum_def(ast::enum_def_ { - variants: variants, - common: common - }) + ast::enum_def { variants: variants, common: common } ); } } diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 16db384bb06..ba0c7a71b7c 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -122,7 +122,7 @@ impl<A:Eq> Eq for OptVec<A> { } impl<A> BaseIter<A> for OptVec<A> { - pure fn each(&self, blk: fn(v: &A) -> bool) { + pure fn each(&self, blk: &fn(v: &A) -> bool) { match *self { Empty => {} Vec(ref v) => v.each(blk) @@ -136,31 +136,31 @@ impl<A> BaseIter<A> for OptVec<A> { impl<A> iter::ExtendedIter<A> for OptVec<A> { #[inline(always)] - pure fn eachi(&self, blk: fn(+v: uint, v: &A) -> bool) { + pure fn eachi(&self, blk: &fn(+v: uint, v: &A) -> bool) { iter::eachi(self, blk) } #[inline(always)] - pure fn all(&self, blk: fn(&A) -> bool) -> bool { + pure fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } #[inline(always)] - pure fn any(&self, blk: fn(&A) -> bool) -> bool { + pure fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } #[inline(always)] - pure fn foldl<B>(&self, +b0: B, blk: fn(&B, &A) -> B) -> B { + pure fn foldl<B>(&self, +b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } #[inline(always)] - pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> { + pure fn position(&self, f: &fn(&A) -> bool) -> Option<uint> { iter::position(self, f) } #[inline(always)] - pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] { + pure fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } #[inline(always)] - pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB) + pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -176,13 +176,13 @@ impl<A: Eq> iter::EqIter<A> for OptVec<A> { impl<A: Copy> iter::CopyableIter<A> for OptVec<A> { #[inline(always)] - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } #[inline(always)] pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } #[inline(always)] - pure fn find(&self, f: fn(&A) -> bool) -> Option<A> { + pure fn find(&self, f: &fn(&A) -> bool) -> Option<A> { iter::find(self, f) } } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 7af2204fafd..c7b9a769293 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -248,7 +248,7 @@ pub impl Parser { fn parse_seq_to_before_gt<T: Copy>( &self, sep: Option<token::Token>, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> OptVec<T> { let mut first = true; let mut v = opt_vec::Empty; @@ -269,7 +269,7 @@ pub impl Parser { fn parse_seq_to_gt<T: Copy>( &self, sep: Option<token::Token>, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> OptVec<T> { let v = self.parse_seq_to_before_gt(sep, f); self.expect_gt(); @@ -283,7 +283,7 @@ pub impl Parser { &self, ket: &token::Token, sep: SeqSep, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> ~[T] { let val = self.parse_seq_to_before_end(ket, sep, f); self.bump(); @@ -297,7 +297,7 @@ pub impl Parser { &self, ket: &token::Token, sep: SeqSep, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> ~[T] { let mut first: bool = true; let mut v: ~[T] = ~[]; @@ -323,7 +323,7 @@ pub impl Parser { bra: &token::Token, ket: &token::Token, sep: SeqSep, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> ~[T] { self.expect(bra); let result = self.parse_seq_to_before_end(ket, sep, f); @@ -338,7 +338,7 @@ pub impl Parser { bra: &token::Token, ket: &token::Token, sep: SeqSep, - f: fn(&Parser) -> T + f: &fn(&Parser) -> T ) -> spanned<~[T]> { let lo = self.span.lo; self.expect(bra); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index a1fc7230dd1..fd84f867068 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -173,7 +173,7 @@ pub fn parse_tts_from_source_str( } pub fn parse_from_source_str<T>( - f: fn (Parser) -> T, + f: &fn (Parser) -> T, name: ~str, ss: codemap::FileSubstr, source: @~str, +cfg: ast::crate_cfg, diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 97ff175da07..ef858a2d5eb 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -53,6 +53,8 @@ pub enum ObsoleteSyntax { ObsoleteRecordPattern, ObsoleteAssertion, ObsoletePostFnTySigil, + ObsoleteBareFnType, + ObsoleteNewtypeEnum, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -166,6 +168,14 @@ pub impl Parser { "Rather than `fn@`, `fn~`, or `fn&`, \ write `@fn`, `~fn`, and `&fn` respectively" ), + ObsoleteBareFnType => ( + "bare function type", + "use `&fn` or `extern fn` instead" + ), + ObsoleteNewtypeEnum => ( + "newtype enum", + "instead of `enum Foo = int`, write `struct Foo(int)`" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 38cd09abad4..99c1c2cb1fe 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -77,6 +77,7 @@ use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer}; use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility}; use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern}; use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil}; +use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum}; use parse::prec::{as_prec, token_to_binop}; use parse::token::{can_begin_expr, is_ident, is_ident_or_path}; use parse::token::{is_plain_ident, INTERPOLATED, special_idents}; @@ -647,8 +648,9 @@ pub impl Parser { } else if self.eat_keyword(&~"extern") { self.parse_ty_bare_fn() } else if self.token_is_closure_keyword(© *self.token) { - // self.warn(fmt!("Old-school closure keyword")); - self.parse_ty_closure(ast::BorrowedSigil, None) + let result = self.parse_ty_closure(ast::BorrowedSigil, None); + self.obsolete(*self.last_span, ObsoleteBareFnType); + result } else if *self.token == token::MOD_SEP || is_ident_or_path(&*self.token) { let path = self.parse_path_with_tps(colons_before_params); @@ -1829,7 +1831,7 @@ pub impl Parser { fn parse_sugary_call_expr(&self, keyword: ~str, sugar: CallSugar, - ctor: fn(+v: @expr) -> expr_) -> @expr { + ctor: &fn(+v: @expr) -> expr_) -> @expr { let lo = self.last_span; // Parse the callee `foo` in // for foo || { @@ -2769,7 +2771,7 @@ pub impl Parser { (lifetimes, opt_vec::take_vec(result)) } - fn parse_fn_decl(&self, parse_arg_fn: fn(&Parser) -> arg_or_capture_item) + fn parse_fn_decl(&self, parse_arg_fn: &fn(&Parser) -> arg_or_capture_item) -> fn_decl { let args_or_capture_items: ~[arg_or_capture_item] = @@ -2813,10 +2815,10 @@ pub impl Parser { fn parse_fn_decl_with_self( &self, parse_arg_fn: - fn(&Parser) -> arg_or_capture_item + &fn(&Parser) -> arg_or_capture_item ) -> (self_ty, fn_decl) { fn maybe_parse_self_ty( - cnstr: fn(+v: mutability) -> ast::self_ty_, + cnstr: &fn(+v: mutability) -> ast::self_ty_, p: &Parser ) -> ast::self_ty_ { // We need to make sure it isn't a mode or a type @@ -3765,7 +3767,7 @@ pub impl Parser { enum"); } - enum_def(ast::enum_def_ { variants: variants, common: common_fields }) + ast::enum_def { variants: variants, common: common_fields } } fn parse_item_enum(&self) -> item_info { @@ -3788,12 +3790,12 @@ pub impl Parser { vis: public, }); + self.obsolete(*self.last_span, ObsoleteNewtypeEnum); + return ( id, item_enum( - enum_def( - ast::enum_def_ { variants: ~[variant], common: None } - ), + ast::enum_def { variants: ~[variant], common: None }, generics), None ); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c81c1c8bd0e..49899fdeec4 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -314,8 +314,8 @@ pub fn commasep<IN>(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN)) { } -pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: ~[IN], op: fn(@ps, IN), - get_span: fn(IN) -> codemap::span) { +pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: ~[IN], op: &fn(@ps, IN), + get_span: &fn(IN) -> codemap::span) { box(s, 0u, b); let len = vec::len::<IN>(elts); let mut i = 0u; @@ -612,36 +612,11 @@ pub fn print_item(s: @ps, &&item: @ast::item) { pub fn print_enum_def(s: @ps, enum_definition: ast::enum_def, generics: &ast::Generics, ident: ast::ident, span: codemap::span, visibility: ast::visibility) { - let mut newtype = - vec::len(enum_definition.variants) == 1u && - ident == enum_definition.variants[0].node.name; - if newtype { - match enum_definition.variants[0].node.kind { - ast::tuple_variant_kind(ref args) if args.len() == 1 => {} - _ => newtype = false - } - } - if newtype { - ibox(s, indent_unit); - word_space(s, visibility_qualified(visibility, ~"enum")); - } else { - head(s, visibility_qualified(visibility, ~"enum")); - } - + head(s, visibility_qualified(visibility, ~"enum")); print_ident(s, ident); print_generics(s, generics); space(s.s); - if newtype { - word_space(s, ~"="); - match /*bad*/ copy enum_definition.variants[0].node.kind { - ast::tuple_variant_kind(args) => print_type(s, args[0].ty), - _ => fail!(~"newtype syntax with struct?") - } - word(s.s, ~";"); - end(s); - } else { - print_variants(s, enum_definition.variants, span); - } + print_variants(s, enum_definition.variants, span); } pub fn print_variants(s: @ps, |
