Skip to content

Commit 27cc0a3

Browse files
committed
Promote 'struct' from a restricted keyword to a strict keyword
1 parent 1203da3 commit 27cc0a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+185
-186
lines changed

src/libsyntax/parse/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ fn restricted_keyword_table() -> HashMap<~str, ()> {
415415
~"fail", ~"fn",
416416
~"impl",
417417
~"priv", ~"pub",
418-
~"struct",
419418
~"unsafe"
420419
];
421420
for keys.each |word| {
@@ -438,6 +437,7 @@ fn strict_keyword_table() -> HashMap<~str, ()> {
438437
~"match", ~"mod", ~"move", ~"mut",
439438
~"pure",
440439
~"ref", ~"return",
440+
~"struct",
441441
~"true", ~"trait", ~"type",
442442
~"unchecked", ~"use",
443443
~"while"

src/rustc/metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ fn get_enum_variants(intr: ident_interner, cdata: cmd, id: ast::node_id,
584584
tcx, cdata);
585585
let name = item_name(intr, item);
586586
let mut arg_tys: ~[ty::t] = ~[];
587-
match ty::get(ctor_ty).struct {
587+
match ty::get(ctor_ty).sty {
588588
ty::ty_fn(f) => {
589589
for f.sig.inputs.each |a| { vec::push(arg_tys, a.ty); }
590590
}
@@ -696,7 +696,7 @@ fn get_trait_methods(intr: ident_interner, cdata: cmd, id: ast::node_id,
696696
let bounds = item_ty_param_bounds(mth, tcx, cdata);
697697
let name = item_name(intr, mth);
698698
let ty = doc_type(mth, tcx, cdata);
699-
let fty = match ty::get(ty).struct {
699+
let fty = match ty::get(ty).sty {
700700
ty::ty_fn(f) => f,
701701
_ => {
702702
tcx.diag.handler().bug(

src/rustc/metadata/tyencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
4747
Some(s) => *s,
4848
None => {
4949
let buf = io::mem_buffer();
50-
enc_sty(io::mem_buffer_writer(buf), cx, ty::get(t).struct);
50+
enc_sty(io::mem_buffer_writer(buf), cx, ty::get(t).sty);
5151
cx.tcx.short_names_cache.insert(t, @io::mem_buffer_str(buf));
5252
io::mem_buffer_str(buf)
5353
}
@@ -72,7 +72,7 @@ fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
7272
}
7373
_ => {}
7474
}
75-
enc_sty(w, cx, ty::get(t).struct);
75+
enc_sty(w, cx, ty::get(t).sty);
7676
let end = w.tell();
7777
let len = end - pos;
7878
fn estimate_sz(u: uint) -> uint {

src/rustc/middle/borrowck/check_loans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl check_loan_ctxt {
224224
}
225225

226226
let callee_ty = ty::node_id_to_type(tcx, callee_id);
227-
match ty::get(callee_ty).struct {
227+
match ty::get(callee_ty).sty {
228228
ty::ty_fn(fn_ty) => {
229229
match fn_ty.meta.purity {
230230
ast::pure_fn => return, // case (c) above

src/rustc/middle/check_alt.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
3939
// If the type *is* empty, it's vacuously exhaustive
4040
return;
4141
}
42-
match ty::get(pat_ty).struct {
42+
match ty::get(pat_ty).sty {
4343
ty_enum(did, _) => {
4444
if (*enum_variants(tcx, did)).is_empty() && arms.is_empty() {
4545

@@ -85,7 +85,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
8585
not_useful => return, // This is good, wildcard pattern isn't reachable
8686
useful_ => None,
8787
useful(ty, ctor) => {
88-
match ty::get(ty).struct {
88+
match ty::get(ty).sty {
8989
ty::ty_bool => {
9090
match ctor {
9191
val(const_bool(true)) => Some(~"true"),
@@ -167,7 +167,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
167167
None => {
168168
match missing_ctor(tcx, m, left_ty) {
169169
None => {
170-
match ty::get(left_ty).struct {
170+
match ty::get(left_ty).sty {
171171
ty::ty_bool => {
172172
match is_useful_specialized(tcx, m, v, val(const_bool(true)),
173173
0u, left_ty){
@@ -257,7 +257,7 @@ fn is_wild(tcx: ty::ctxt, p: @pat) -> bool {
257257
}
258258

259259
fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> {
260-
match ty::get(left_ty).struct {
260+
match ty::get(left_ty).sty {
261261
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) | ty::ty_tup(_) |
262262
ty::ty_rec(_) | ty::ty_class(*) => {
263263
for m.each |r| {
@@ -302,7 +302,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> {
302302
}
303303

304304
fn ctor_arity(tcx: ty::ctxt, ctor: ctor, ty: ty::t) -> uint {
305-
match ty::get(ty).struct {
305+
match ty::get(ty).sty {
306306
ty::ty_tup(fs) => fs.len(),
307307
ty::ty_rec(fs) => fs.len(),
308308
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u,
@@ -352,7 +352,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
352352
}
353353
}
354354
pat_rec(flds, _) => {
355-
let ty_flds = match ty::get(left_ty).struct {
355+
let ty_flds = match ty::get(left_ty).sty {
356356
ty::ty_rec(flds) => flds,
357357
_ => fail ~"bad type for pat_rec"
358358
};
@@ -367,7 +367,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
367367
pat_struct(_, flds, _) => {
368368
// Grab the class data that we care about.
369369
let class_fields, class_id;
370-
match ty::get(left_ty).struct {
370+
match ty::get(left_ty).sty {
371371
ty::ty_class(cid, _) => {
372372
class_id = cid;
373373
class_fields = ty::lookup_class_fields(tcx, class_id);

src/rustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
317317
expr_cast(base, _) => {
318318
let ety = ty::expr_ty(tcx, e);
319319
let base = eval_const_expr(tcx, base);
320-
match ty::get(ety).struct {
320+
match ty::get(ety).sty {
321321
ty::ty_float(_) => {
322322
match base {
323323
const_uint(u) => const_float(u as f64),

src/rustc/middle/kind.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
300300
Some(ex) => {
301301
// All noncopyable fields must be overridden
302302
let t = ty::expr_ty(cx.tcx, ex);
303-
let ty_fields = match ty::get(t).struct {
303+
let ty_fields = match ty::get(t).sty {
304304
ty::ty_rec(f) => f,
305305
_ => cx.tcx.sess.span_bug(ex.span, ~"bad expr type in record")
306306
};
@@ -504,7 +504,7 @@ fn check_send(cx: ctx, ty: ty::t, sp: span) -> bool {
504504
// note: also used from middle::typeck::regionck!
505505
fn check_owned(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
506506
if !ty::kind_is_owned(ty::type_kind(tcx, ty)) {
507-
match ty::get(ty).struct {
507+
match ty::get(ty).sty {
508508
ty::ty_param(*) => {
509509
tcx.sess.span_err(sp, ~"value may contain borrowed \
510510
pointers; use `owned` bound");
@@ -551,7 +551,7 @@ fn check_cast_for_escaping_regions(
551551
// Determine what type we are casting to; if it is not an trait, then no
552552
// worries.
553553
let target_ty = ty::expr_ty(cx.tcx, target);
554-
let target_substs = match ty::get(target_ty).struct {
554+
let target_substs = match ty::get(target_ty).sty {
555555
ty::ty_trait(_, substs, _) => {substs}
556556
_ => { return; /* not a cast to a trait */ }
557557
};
@@ -574,7 +574,7 @@ fn check_cast_for_escaping_regions(
574574
let target_params = ty::param_tys_in_type(target_ty);
575575
let source_ty = ty::expr_ty(cx.tcx, source);
576576
do ty::walk_ty(source_ty) |ty| {
577-
match ty::get(ty).struct {
577+
match ty::get(ty).sty {
578578
ty::ty_param(source_param) => {
579579
if target_params.contains(source_param) {
580580
/* case (2) */

src/rustc/middle/lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ fn check_item_heap(cx: ty::ctxt, it: @ast::item) {
498498
let mut n_box = 0;
499499
let mut n_uniq = 0;
500500
ty::fold_ty(cx, ty, |t| {
501-
match ty::get(t).struct {
501+
match ty::get(t).sty {
502502
ty::ty_box(_) => n_box += 1,
503503
ty::ty_uniq(_) => n_uniq += 1,
504504
_ => ()
@@ -658,7 +658,7 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
658658
}
659659

660660
let fn_ty = ty::node_id_to_type(tcx, id);
661-
match ty::get(fn_ty).struct {
661+
match ty::get(fn_ty).sty {
662662
ty::ty_fn(fn_ty) => {
663663
let mut counter = 0;
664664
do vec::iter2(fn_ty.sig.inputs, decl.inputs) |arg_ty, arg_ast| {

src/rustc/middle/mem_categorization.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ enum deref_kind {deref_ptr(ptr_kind), deref_comp(comp_kind)}
290290
// derefable (we model an index as the combination of a deref and then a
291291
// pointer adjustment).
292292
fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
293-
match ty::get(t).struct {
293+
match ty::get(t).sty {
294294
ty::ty_uniq(*) |
295295
ty::ty_evec(_, ty::vstore_uniq) |
296296
ty::ty_estr(ty::vstore_uniq) => {
@@ -424,7 +424,7 @@ impl &mem_categorization_ctxt {
424424
// Any expression can be borrowed (to account for auto-ref on method
425425
// receivers), but @, ~, @vec, and ~vec are handled specially.
426426
let expr_ty = ty::expr_ty(self.tcx, expr);
427-
match ty::get(expr_ty).struct {
427+
match ty::get(expr_ty).sty {
428428
ty::ty_evec(*) | ty::ty_estr(*) => {
429429
self.cat_index(expr, expr)
430430
}
@@ -1013,7 +1013,7 @@ impl &mem_categorization_ctxt {
10131013
cat_comp(_, comp_tuple) => ~"tuple content",
10141014
cat_comp(_, comp_variant(_)) => ~"enum content",
10151015
cat_comp(_, comp_index(t, _)) => {
1016-
match ty::get(t).struct {
1016+
match ty::get(t).sty {
10171017
ty::ty_evec(*) => mut_str + ~" vec content",
10181018
ty::ty_estr(*) => mut_str + ~" str content",
10191019
_ => mut_str + ~" indexed content"
@@ -1034,7 +1034,7 @@ fn field_mutbl(tcx: ty::ctxt,
10341034
base_ty: ty::t,
10351035
f_name: ast::ident) -> Option<ast::mutability> {
10361036
// Need to refactor so that records/class fields can be treated uniformly.
1037-
match ty::get(base_ty).struct {
1037+
match ty::get(base_ty).sty {
10381038
ty::ty_rec(fields) => {
10391039
for fields.each |f| {
10401040
if f.ident == f_name {

src/rustc/middle/privacy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
154154
visit_expr: |expr, method_map: &method_map, visitor| {
155155
match expr.node {
156156
expr_field(base, ident, _) => {
157-
match ty::get(ty::expr_ty(tcx, base)).struct {
157+
match ty::get(ty::expr_ty(tcx, base)).sty {
158158
ty_class(id, _)
159159
if id.crate != local_crate ||
160160
!privileged_items.contains(id.node) => {
@@ -175,7 +175,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
175175
}
176176
}
177177
expr_struct(_, fields, _) => {
178-
match ty::get(ty::expr_ty(tcx, expr)).struct {
178+
match ty::get(ty::expr_ty(tcx, expr)).sty {
179179
ty_class(id, _) => {
180180
if id.crate != local_crate ||
181181
!privileged_items.contains(id.node) {
@@ -202,7 +202,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
202202
visit_pat: |pattern, method_map, visitor| {
203203
match pattern.node {
204204
pat_struct(_, fields, _) => {
205-
match ty::get(ty::pat_ty(tcx, pattern)).struct {
205+
match ty::get(ty::pat_ty(tcx, pattern)).sty {
206206
ty_class(id, _) => {
207207
if id.crate != local_crate ||
208208
!privileged_items.contains(id.node) {

src/rustc/middle/trans/alt.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
293293
{vals: ~[ValueRef], bcx: block} {
294294
let _icx = bcx.insn_ctxt("alt::extract_variant_args");
295295
let ccx = bcx.fcx.ccx;
296-
let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id))
297-
.struct {
296+
let enum_ty_substs = match ty::get(node_id_type(bcx, pat_id)).sty {
298297
ty::ty_enum(id, substs) => { assert id == vdefs.enm; substs.tps }
299298
_ => bcx.sess().bug(~"extract_variant_args: pattern has non-enum type")
300299
};
@@ -436,7 +435,7 @@ fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
436435
return rslt(rs.bcx, rs.val);
437436
}
438437

439-
match ty::get(rhs_t).struct {
438+
match ty::get(rhs_t).sty {
440439
ty::ty_estr(ty::vstore_uniq) => {
441440
let scratch_result = scratch_datum(cx, ty::mk_bool(cx.tcx()),
442441
false);
@@ -559,7 +558,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
559558

560559
if any_tup_pat(m, col) {
561560
let tup_ty = node_id_type(bcx, pat_id);
562-
let n_tup_elts = match ty::get(tup_ty).struct {
561+
let n_tup_elts = match ty::get(tup_ty).sty {
563562
ty::ty_tup(elts) => elts.len(),
564563
_ => ccx.sess.bug(~"non-tuple type in tuple pattern")
565564
};

src/rustc/middle/trans/base.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef,
422422
t: ty::t, op: ast::binop) -> Result {
423423
let f = |a| compare_scalar_values(cx, lhs, rhs, a, op);
424424

425-
match ty::get(t).struct {
425+
match ty::get(t).sty {
426426
ty::ty_nil => rslt(cx, f(nil_type)),
427427
ty::ty_bool | ty::ty_ptr(_) => rslt(cx, f(unsigned_int)),
428428
ty::ty_int(_) => rslt(cx, f(signed_int)),
@@ -528,7 +528,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
528528
let fn_ty = variant.ctor_ty;
529529
let ccx = cx.ccx();
530530
let mut cx = cx;
531-
match ty::get(fn_ty).struct {
531+
match ty::get(fn_ty).sty {
532532
ty::ty_fn(ref fn_ty) => {
533533
let mut j = 0u;
534534
let v_id = variant.id;
@@ -548,7 +548,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
548548
Typestate constraint that shows the unimpl case doesn't happen?
549549
*/
550550
let mut cx = cx;
551-
match ty::get(t).struct {
551+
match ty::get(t).sty {
552552
ty::ty_rec(*) | ty::ty_class(*) => {
553553
do expr::with_field_tys(cx.tcx(), t) |_has_dtor, field_tys| {
554554
for vec::eachi(field_tys) |i, field_ty| {
@@ -655,7 +655,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop,
655655
} else {
656656
~"modulo zero"
657657
};
658-
let is_zero = match ty::get(rhs_t).struct {
658+
let is_zero = match ty::get(rhs_t).sty {
659659
ty::ty_int(t) => {
660660
let zero = C_integral(T_int_ty(cx.ccx(), t), 0u64, False);
661661
ICmp(cx, lib::llvm::IntEQ, rhs, zero)
@@ -681,7 +681,7 @@ fn null_env_ptr(bcx: block) -> ValueRef {
681681
fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t)
682682
-> ValueRef {
683683
let name = csearch::get_symbol(ccx.sess.cstore, did);
684-
match ty::get(t).struct {
684+
match ty::get(t).sty {
685685
ty::ty_fn(_) => {
686686
let llty = type_of_fn_from_ty(ccx, t);
687687
return get_extern_fn(ccx.externs, ccx.llmod, name,
@@ -1956,7 +1956,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
19561956

19571957
let main_takes_argv =
19581958
// invariant!
1959-
match ty::get(main_node_type).struct {
1959+
match ty::get(main_node_type).sty {
19601960
ty::ty_fn(ref fn_ty) => fn_ty.sig.inputs.len() != 0u,
19611961
_ => ccx.sess.span_fatal(sp, ~"main has a non-function type")
19621962
};

src/rustc/middle/trans/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ fn adapt_borrowed_value(bcx: block,
620620
datum.to_str(bcx.ccx()),
621621
bcx.expr_to_str(expr));
622622

623-
match ty::get(datum.ty).struct {
623+
match ty::get(datum.ty).sty {
624624
ty::ty_uniq(_) | ty::ty_box(_) => {
625625
let body_datum = datum.box_body(bcx);
626626
let rptr_datum = body_datum.to_rptr(bcx);

src/rustc/middle/trans/consts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
1010
ast::lit_uint(u, t) => C_integral(T_uint_ty(cx, t), u, False),
1111
ast::lit_int_unsuffixed(i) => {
1212
let lit_int_ty = ty::node_id_to_type(cx.tcx, e.id);
13-
match ty::get(lit_int_ty).struct {
13+
match ty::get(lit_int_ty).sty {
1414
ty::ty_int(t) => {
1515
C_integral(T_int_ty(cx, t), i as u64, True)
1616
}
@@ -76,7 +76,7 @@ fn const_autoderef(cx: @crate_ctxt, ty: ty::t, v: ValueRef)
7676
let mut v1 = v;
7777
loop {
7878
// Only rptrs can be autoderef'ed in a const context.
79-
match ty::get(ty).struct {
79+
match ty::get(ty).sty {
8080
ty::ty_rptr(_, mt) => {
8181
t1 = mt.ty;
8282
v1 = const_deref(cx, v1);
@@ -184,7 +184,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
184184
~"index is not an integer-constant \
185185
expression")
186186
};
187-
let (arr, _len) = match ty::get(bt).struct {
187+
let (arr, _len) = match ty::get(bt).sty {
188188
ty::ty_evec(_, vstore) | ty::ty_estr(vstore) =>
189189
match vstore {
190190
ty::vstore_fixed(u) =>
@@ -236,7 +236,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
236236
// we can get the value (as a number) out of.
237237

238238
let len = llvm::LLVMGetArrayLength(val_ty(arr)) as u64;
239-
let len = match ty::get(bt).struct {
239+
let len = match ty::get(bt).sty {
240240
ty::ty_estr(*) => {assert len > 0; len - 1},
241241
_ => len
242242
};

src/rustc/middle/trans/datum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl Datum {
528528
* This datum must represent an @T or ~T box. Returns a new
529529
* by-ref datum of type T, pointing at the contents. */
530530

531-
let content_ty = match ty::get(self.ty).struct {
531+
let content_ty = match ty::get(self.ty).sty {
532532
ty::ty_box(mt) | ty::ty_uniq(mt) => mt.ty,
533533
_ => {
534534
bcx.tcx().sess.bug(fmt!(
@@ -583,7 +583,7 @@ impl Datum {
583583
}
584584
}
585585

586-
match ty::get(self.ty).struct {
586+
match ty::get(self.ty).sty {
587587
ty::ty_box(_) | ty::ty_uniq(_) => {
588588
return Some(self.box_body(bcx));
589589
}

0 commit comments

Comments
 (0)