diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/check_match.rs | 7 | ||||
| -rw-r--r-- | src/librustc/middle/mem_categorization.rs | 1 | ||||
| -rw-r--r-- | src/librustc/middle/resolve.rs | 2 | ||||
| -rw-r--r-- | src/librustc/middle/trans/_match.rs | 8 | ||||
| -rw-r--r-- | src/librustc/middle/trans/adt.rs | 24 | ||||
| -rw-r--r-- | src/librustc/middle/trans/datum.rs | 4 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/check/_match.rs | 6 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/check/regionck.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/parse/obsolete.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 19 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 5 |
15 files changed, 31 insertions, 74 deletions
diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 60e08e7dc98..07782c25284 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -319,8 +319,7 @@ pub fn pat_ctor_id(cx: @MatchCheckCtxt, p: @pat) -> Option<ctor> { _ => Some(single) } } - pat_box(_) | pat_uniq(_) | pat_rec(_, _) | pat_tup(_) | - pat_region(*) => { + pat_box(_) | pat_uniq(_) | pat_tup(_) | pat_region(*) => { Some(single) } pat_vec(elems, tail) => { @@ -547,7 +546,6 @@ pub fn specialize(cx: @MatchCheckCtxt, _ => None } } - pat_rec(ref flds, _) => fail!(), pat_struct(_, ref flds, _) => { // Is this a struct or an enum variant? match cx.tcx.def_map.get(&pat_id) { @@ -709,9 +707,6 @@ pub fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool { false } pat_lit(_) | pat_range(_, _) => { true } - pat_rec(fields, _) => { - fields.any(|f| is_refutable(cx, f.pat)) - } pat_struct(_, fields, _) => { fields.any(|f| is_refutable(cx, f.pat)) } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 0fc55e58956..18cf02cf66d 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -942,7 +942,6 @@ pub impl mem_categorization_ctxt { // nullary variant or identifier: ignore } - ast::pat_rec(ref field_pats, _) | ast::pat_struct(_, ref field_pats, _) => { // {f1: p1, ..., fN: pN} for field_pats.each |fp| { diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 5479dac4d95..075d4673636 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -47,7 +47,7 @@ use syntax::ast::{item_const, item_enum, item_fn, item_foreign_mod}; use syntax::ast::{item_impl, item_mac, item_mod, item_trait, item_ty, le}; use syntax::ast::{local, local_crate, lt, method, mode, module_ns, mul}; use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident}; -use syntax::ast::{path, pat_box, pat_lit, pat_range, pat_rec, pat_struct}; +use syntax::ast::{path, pat_box, pat_lit, pat_range, pat_struct}; use syntax::ast::{pat_tup, pat_uniq, pat_wild, prim_ty, private, provided}; use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl}; use syntax::ast::{struct_dtor, struct_field, struct_variant_kind, sty_by_ref}; diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 5bfa314e397..d7254ffa660 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -459,8 +459,7 @@ pub fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r], do enter_match(bcx, dm, m, col, val) |p| { match p.node { - ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) | - ast::pat_struct(*) => Some(~[]), + ast::pat_wild | ast::pat_tup(_) | ast::pat_struct(*) => Some(~[]), ast::pat_ident(_, _, None) if pat_is_binding(dm, p) => Some(~[]), _ => None } @@ -611,7 +610,7 @@ pub fn enter_rec_or_struct(bcx: block, let dummy = @ast::pat {id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { match /*bad*/copy p.node { - ast::pat_rec(fpats, _) | ast::pat_struct(_, fpats, _) => { + ast::pat_struct(_, fpats, _) => { let mut pats = ~[]; for vec::each(fields) |fname| { match fpats.find(|p| p.ident == *fname) { @@ -887,7 +886,6 @@ pub fn collect_record_or_struct_fields(bcx: block, let mut fields: ~[ast::ident] = ~[]; for vec::each(m) |br| { match /*bad*/copy br.pats[col].node { - ast::pat_rec(fs, _) => extend(&mut fields, fs), ast::pat_struct(_, fs, _) => { match ty::get(node_id_type(bcx, br.pats[col].id)).sty { ty::ty_struct(*) => extend(&mut fields, fs), @@ -1766,7 +1764,7 @@ pub fn bind_irrefutable_pat(bcx: block, } } } - ast::pat_rec(fields, _) | ast::pat_struct(_, fields, _) => { + ast::pat_struct(_, fields, _) => { let tcx = bcx.tcx(); let pat_ty = node_id_type(bcx, pat.id); let pat_repr = adt::represent_type(bcx.ccx(), pat_ty); diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 4ad61c190a9..e39de62cd29 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -155,7 +155,7 @@ pub fn represent_type(cx: @CrateContext, t: ty::t) -> @Repr { Unit(cases[0].discr) } else if cases.len() == 1 { // Equivalent to a struct/tuple/newtype. - assert cases[0].discr == 0; + fail_unless!(cases[0].discr == 0); Univariant(mk_struct(cx, cases[0].tys), NonStruct) } else if cases.all(|c| c.tys.len() == 0) { // All bodies empty -> intlike @@ -302,18 +302,18 @@ pub fn trans_case(bcx: block, r: &Repr, discr: int) -> _match::opt_result { pub fn trans_start_init(bcx: block, r: &Repr, val: ValueRef, discr: int) { match *r { Unit(the_discr) => { - assert discr == the_discr; + fail_unless!(discr == the_discr); } CEnum(min, max) => { - assert min <= discr && discr <= max; + fail_unless!(min <= discr && discr <= max); Store(bcx, C_int(bcx.ccx(), discr), GEPi(bcx, val, [0, 0])) } Univariant(_, StructWithDtor) => { - assert discr == 0; + fail_unless!(discr == 0); Store(bcx, C_u8(1), GEPi(bcx, val, [0, 1])) } Univariant(*) => { - assert discr == 0; + fail_unless!(discr == 0); } General(*) => { Store(bcx, C_int(bcx.ccx(), discr), GEPi(bcx, val, [0, 0])) @@ -328,7 +328,7 @@ pub fn trans_start_init(bcx: block, r: &Repr, val: ValueRef, discr: int) { pub fn num_args(r: &Repr, discr: int) -> uint { match *r { Unit(*) | CEnum(*) => 0, - Univariant(ref st, _dt) => { assert discr == 0; st.fields.len() } + Univariant(ref st, _) => { fail_unless!(discr == 0); st.fields.len() } General(ref cases) => cases[discr as uint].fields.len() } } @@ -344,7 +344,7 @@ pub fn trans_field_ptr(bcx: block, r: &Repr, val: ValueRef, discr: int, bcx.ccx().sess.bug(~"element access in C-like enum") } Univariant(ref st, dt) => { - assert discr == 0; + fail_unless!(discr == 0); let val = match dt { NonStruct => val, StructWithDtor | StructWithoutDtor => GEPi(bcx, val, [0, 0]) @@ -411,12 +411,12 @@ pub fn trans_const(ccx: @CrateContext, r: &Repr, discr: int, C_struct(~[]) } CEnum(min, max) => { - assert vals.len() == 0; - assert min <= discr && discr <= max; + fail_unless!(vals.len() == 0); + fail_unless!(min <= discr && discr <= max); C_int(ccx, discr) } Univariant(ref st, dt) => { - assert discr == 0; + fail_unless!(discr == 0); let s = C_struct(build_const_struct(ccx, st, vals)); match dt { NonStruct => s, @@ -452,7 +452,7 @@ pub fn trans_const(ccx: @CrateContext, r: &Repr, discr: int, */ fn build_const_struct(ccx: @CrateContext, st: &Struct, vals: &[ValueRef]) -> ~[ValueRef] { - assert vals.len() == st.fields.len(); + fail_unless!(vals.len() == st.fields.len()); let mut offset = 0; let mut cfields = ~[]; @@ -468,7 +468,7 @@ fn build_const_struct(ccx: @CrateContext, st: &Struct, vals: &[ValueRef]) cfields.push(padding(target_offset - offset)); offset = target_offset; } - assert !is_undef(vals[i]); + fail_unless!(!is_undef(vals[i])); // If that assert fails, could change it to wrap in a struct? // (See `const_struct_field` for why real fields must not be undef.) cfields.push(vals[i]); diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index e6089914564..ac150d44e39 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -679,7 +679,7 @@ pub impl Datum { } let repr = adt::represent_type(ccx, self.ty); - assert adt::is_newtypeish(repr); + fail_unless!(adt::is_newtypeish(repr)); let ty = ty::subst(ccx.tcx, substs, variants[0].args[0]); return match self.mode { ByRef => { @@ -719,7 +719,7 @@ pub impl Datum { } let repr = adt::represent_type(ccx, self.ty); - assert adt::is_newtypeish(repr); + fail_unless!(adt::is_newtypeish(repr)); let ty = fields[0].mt.ty; return match self.mode { ByRef => { diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 119a59a526c..1da4cbe7c91 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -414,12 +414,6 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { ast::pat_enum(path, subpats) => { check_pat_variant(pcx, pat, path, subpats, expected); } - ast::pat_rec(fields, etc) => { - tcx.sess.span_fatal - (pat.span, - fmt!("mismatched types: expected `%s` but found record", - fcx.infcx().ty_to_str(expected))); - } ast::pat_struct(path, fields, etc) => { // Grab the class data that we care about. let structure = structure_of(fcx, pat.span, expected); diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 2b3931a5d6d..204991d50d3 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -874,7 +874,6 @@ pub mod guarantor { } } ast::pat_enum(*) => {} - ast::pat_rec(ref fpats, _) | ast::pat_struct(_, ref fpats, _) => { for fpats.each |fpat| { link_ref_bindings_in_pat(rcx, fpat.pat, guarantor); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 68afa38ba89..0581f5f96b0 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -302,7 +302,6 @@ pub enum pat_ { pat_ident(binding_mode, @path, Option<@pat>), pat_enum(@path, Option<~[@pat]>), /* "none" means a * pattern where * we don't bind the fields to names */ - pat_rec(~[field_pat], bool), pat_struct(@path, ~[field_pat], bool), pat_tup(~[@pat]), pat_box(@pat), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index ba683004aee..686ae3900ff 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -520,7 +520,7 @@ pub fn walk_pat(pat: @pat, it: fn(@pat)) { it(pat); match pat.node { pat_ident(_, _, Some(p)) => walk_pat(p, it), - pat_rec(ref fields, _) | pat_struct(_, ref fields, _) => { + pat_struct(_, ref fields, _) => { for fields.each |f| { walk_pat(f.pat, it) } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 3ada03c08f4..ea18598f75c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -399,15 +399,6 @@ pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ { pats.map(|pats| pats.map(|x| fld.fold_pat(*x))) ) } - pat_rec(ref fields, etc) => { - let fs = do fields.map |f| { - ast::field_pat { - ident: /* FIXME (#2543) */ copy f.ident, - pat: fld.fold_pat(f.pat), - } - }; - pat_rec(fs, etc) - } pat_struct(pth, ref fields, etc) => { let pth_ = fld.fold_path(pth); let fs = do fields.map |f| { diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index dbb44858761..4e1b34bb299 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -50,6 +50,7 @@ pub enum ObsoleteSyntax { ObsoleteMutVector, ObsoleteTraitImplVisibility, ObsoleteRecordType, + ObsoleteRecordPattern, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -150,6 +151,10 @@ pub impl Parser { "structural record type", "use a structure instead" ), + ObsoleteRecordPattern => ( + "structural record pattern", + "use a structure instead" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 498b6f3ca70..2a113c44612 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -40,8 +40,8 @@ use ast::{lit_int_unsuffixed, lit_nil, lit_str, lit_uint, local, m_const}; use ast::{m_imm, m_mutbl, mac_, mac_invoc_tt, matcher, match_nonterminal}; use ast::{match_seq, match_tok, method, mode, module_ns, mt, mul, mutability}; use ast::{named_field, neg, node_id, noreturn, not, pat, pat_box, pat_enum}; -use ast::{pat_ident, pat_lit, pat_range, pat_rec, pat_region, pat_struct}; -use ast::{pat_tup, pat_uniq, pat_wild, path, private}; +use ast::{pat_ident, pat_lit, pat_range, pat_region, pat_struct, pat_tup}; +use ast::{pat_uniq, pat_wild, path, private}; use ast::{re_self, re_anon, re_named, region, rem, required}; use ast::{ret_style, return_val, self_ty, shl, shr, stmt, stmt_decl}; use ast::{stmt_expr, stmt_semi, stmt_mac, struct_def, struct_field}; @@ -75,7 +75,7 @@ use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax}; use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer}; use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility}; -use parse::obsolete::{ObsoleteRecordType}; +use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern}; 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}; @@ -2192,10 +2192,11 @@ pub impl Parser { } token::LBRACE => { self.bump(); - let (fields, etc) = self.parse_pat_fields(refutable); + let (_, _) = self.parse_pat_fields(refutable); hi = self.span.hi; self.bump(); - pat = pat_rec(fields, etc); + self.obsolete(*self.span, ObsoleteRecordPattern); + pat = pat_wild; } token::LPAREN => { self.bump(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8e26f37d7de..c0ce8ec45aa 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1574,25 +1574,6 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) { } } } - ast::pat_rec(fields, etc) => { - word(s.s, ~"{"); - fn print_field(s: @ps, f: ast::field_pat, refutable: bool) { - cbox(s, indent_unit); - print_ident(s, f.ident); - word_space(s, ~":"); - print_pat(s, f.pat, refutable); - end(s); - } - fn get_span(f: ast::field_pat) -> codemap::span { return f.pat.span; } - commasep_cmnt(s, consistent, fields, - |s, f| print_field(s, f, refutable), - get_span); - if etc { - if vec::len(fields) != 0u { word_space(s, ~","); } - word(s.s, ~"_"); - } - word(s.s, ~"}"); - } ast::pat_struct(path, fields, etc) => { print_path(s, path, true); word(s.s, ~"{"); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 2f086534ed5..8b277b22149 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -263,11 +263,6 @@ pub fn visit_pat<E>(p: @pat, e: E, v: vt<E>) { for children.each |child| { (v.visit_pat)(*child, e, v); } } } - pat_rec(ref fields, _) => { - for fields.each |f| { - (v.visit_pat)(f.pat, e, v) - } - }, pat_struct(path, ref fields, _) => { visit_path(path, e, v); for fields.each |f| { |
