Skip to content

Commit 21bbcfb

Browse files
committed
---
yaml --- r: 8106 b: refs/heads/snap-stage3 c: a08e589 h: refs/heads/master v: v3
1 parent 5777582 commit 21bbcfb

File tree

11 files changed

+189
-169
lines changed

11 files changed

+189
-169
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 8673c4f195be8377f8e0d83929f9a16bb99092a0
4+
refs/heads/snap-stage3: a08e589390993d27bf8504c1c8c54586bbfa3d37
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/comp/front/test.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,9 @@ fn mk_test_wrapper(cx: test_ctxt,
377377
}
378378

379379
fn mk_main(cx: test_ctxt) -> @ast::item {
380-
381-
let args_mt: ast::mt = {ty: @nospan(ast::ty_str), mut: ast::imm};
380+
let str_pt = @nospan({global: false, idents: ["str"], types: []});
381+
let str_ty = @nospan(ast::ty_path(str_pt, cx.sess.next_node_id()));
382+
let args_mt: ast::mt = {ty: str_ty, mut: ast::imm};
382383
let args_ty: ast::ty = nospan(ast::ty_vec(args_mt));
383384

384385
let args_arg: ast::arg =

branches/snap-stage3/src/comp/middle/debuginfo.rs

Lines changed: 69 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ fn create_block(cx: @block_ctxt) -> @metadata<block_md> {
230230
let cx = cx;
231231
while option::is_none(cx.block_span) {
232232
alt cx.parent {
233-
parent_none { fail "BAD"; /*break;*/ }
234233
parent_some(b) { cx = b; }
234+
parent_none { fail; }
235235
}
236236
}
237237
let sp = option::get(cx.block_span);
@@ -275,7 +275,7 @@ fn size_and_align_of<T>() -> (int, int) {
275275
(sys::size_of::<T>() as int, sys::align_of::<T>() as int)
276276
}
277277

278-
fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
278+
fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
279279
-> @metadata<tydesc_md> {
280280
let cache = get_cache(cx);
281281
let tg = BasicTypeDescriptorTag;
@@ -285,7 +285,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
285285
option::none {}
286286
}
287287

288-
let (name, (size, align), encoding) = alt ty.node {
288+
let (name, (size, align), encoding) = alt ty {
289289
ast::ty_bool {("bool", size_and_align_of::<bool>(), DW_ATE_boolean)}
290290
ast::ty_int(m) { alt m {
291291
ast::ty_char {("char", size_and_align_of::<char>(), DW_ATE_unsigned)}
@@ -307,11 +307,10 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
307307
ast::ty_f32 {("f32", size_and_align_of::<f32>(), DW_ATE_float)}
308308
ast::ty_f64 {("f64", size_and_align_of::<f64>(), DW_ATE_float)}
309309
}}
310-
_ { cx.tcx.sess.span_bug(ty.span,
311-
"create_basic_type: unhandled type"); }
310+
_ { fail; }
312311
};
313312

314-
let fname = filename_from_span(cx, ty.span);
313+
let fname = filename_from_span(cx, span);
315314
let file_node = create_file(cx, fname);
316315
let cu_node = create_compile_unit(cx, fname);
317316
let lldata = [lltag(tg),
@@ -415,7 +414,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field],
415414
for field in fields {
416415
let field_t = ty::get_field(ccx_tcx(cx), t, field.node.ident).mt.ty;
417416
let ty_md = create_ty(cx, field_t, field.node.mt.ty);
418-
let (size, align) = member_size_and_align(field.node.mt.ty);
417+
let (size, align) = member_size_and_align(cx.tcx, field.node.mt.ty);
419418
add_member(scx, field.node.ident,
420419
line_from_span(cx.sess.codemap, field.span) as int,
421420
size as int, align as int, ty_md.node);
@@ -439,8 +438,8 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
439438
//let cu_node = create_compile_unit_metadata(cx, fname);
440439
let tcx = ccx_tcx(cx);
441440
let uint_t = ty::mk_uint(tcx);
442-
let uint_ty = @{node: ast::ty_uint(ast::ty_u), span: span};
443-
let refcount_type = create_basic_type(cx, uint_t, uint_ty);
441+
let refcount_type = create_basic_type(cx, uint_t,
442+
ast::ty_uint(ast::ty_u), span);
444443
let scx = create_structure(file_node, ty_to_str(ccx_tcx(cx), outer), 0);
445444
add_member(scx, "refcnt", 0, sys::size_of::<uint>() as int,
446445
sys::align_of::<uint>() as int, refcount_type.node);
@@ -492,14 +491,14 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
492491
let elem_ty_md = create_ty(cx, elem_t, elem_ty);
493492
let tcx = ccx_tcx(cx);
494493
let scx = create_structure(file_node, ty_to_str(tcx, vec_t), 0);
495-
let uint_ty = @{node: ast::ty_uint(ast::ty_u), span: vec_ty_span};
496-
let size_t_type = create_basic_type(cx, ty::mk_uint(tcx), uint_ty);
494+
let size_t_type = create_basic_type(cx, ty::mk_uint(tcx),
495+
ast::ty_uint(ast::ty_u), vec_ty_span);
497496
add_member(scx, "fill", 0, sys::size_of::<ctypes::size_t>() as int,
498497
sys::align_of::<ctypes::size_t>() as int, size_t_type.node);
499498
add_member(scx, "alloc", 0, sys::size_of::<ctypes::size_t>() as int,
500499
sys::align_of::<ctypes::size_t>() as int, size_t_type.node);
501500
let subrange = llmdnode([lltag(SubrangeTag), lli64(0), lli64(0)]);
502-
let (arr_size, arr_align) = member_size_and_align(elem_ty);
501+
let (arr_size, arr_align) = member_size_and_align(tcx, elem_ty);
503502
let data_ptr = create_composite_type(ArrayTypeTag, "", file_node.node, 0,
504503
arr_size, arr_align, 0,
505504
option::some(elem_ty_md.node),
@@ -510,36 +509,46 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
510509
ret @{node: llnode, data: {hash: ty::type_id(vec_t)}};
511510
}
512511

513-
fn member_size_and_align(ty: @ast::ty) -> (int, int) {
512+
fn member_size_and_align(tcx: ty::ctxt, ty: @ast::ty) -> (int, int) {
514513
alt ty.node {
515-
ast::ty_bool { size_and_align_of::<bool>() }
516-
ast::ty_int(m) { alt m {
517-
ast::ty_char { size_and_align_of::<char>() }
518-
ast::ty_i { size_and_align_of::<int>() }
519-
ast::ty_i8 { size_and_align_of::<i8>() }
520-
ast::ty_i16 { size_and_align_of::<i16>() }
521-
ast::ty_i32 { size_and_align_of::<i32>() }
522-
ast::ty_i64 { size_and_align_of::<i64>() }
523-
}}
524-
ast::ty_uint(m) { alt m {
525-
ast::ty_u { size_and_align_of::<uint>() }
526-
ast::ty_u8 { size_and_align_of::<i8>() }
527-
ast::ty_u16 { size_and_align_of::<u16>() }
528-
ast::ty_u32 { size_and_align_of::<u32>() }
529-
ast::ty_u64 { size_and_align_of::<u64>() }
530-
}}
531-
ast::ty_float(m) { alt m {
532-
ast::ty_f { size_and_align_of::<float>() }
533-
ast::ty_f32 { size_and_align_of::<f32>() }
534-
ast::ty_f64 { size_and_align_of::<f64>() }
535-
}}
514+
ast::ty_path(_, id) {
515+
alt tcx.def_map.get(id) {
516+
ast::def_prim_ty(nty) {
517+
alt nty {
518+
ast::ty_bool { size_and_align_of::<bool>() }
519+
ast::ty_int(m) { alt m {
520+
ast::ty_char { size_and_align_of::<char>() }
521+
ast::ty_i { size_and_align_of::<int>() }
522+
ast::ty_i8 { size_and_align_of::<i8>() }
523+
ast::ty_i16 { size_and_align_of::<i16>() }
524+
ast::ty_i32 { size_and_align_of::<i32>() }
525+
ast::ty_i64 { size_and_align_of::<i64>() }
526+
}}
527+
ast::ty_uint(m) { alt m {
528+
ast::ty_u { size_and_align_of::<uint>() }
529+
ast::ty_u8 { size_and_align_of::<i8>() }
530+
ast::ty_u16 { size_and_align_of::<u16>() }
531+
ast::ty_u32 { size_and_align_of::<u32>() }
532+
ast::ty_u64 { size_and_align_of::<u64>() }
533+
}}
534+
ast::ty_float(m) { alt m {
535+
ast::ty_f { size_and_align_of::<float>() }
536+
ast::ty_f32 { size_and_align_of::<f32>() }
537+
ast::ty_f64 { size_and_align_of::<f64>() }
538+
}}
539+
_ { fail; }
540+
}
541+
}
542+
_ { fail; }
543+
}
544+
}
536545
ast::ty_box(_) | ast::ty_uniq(_) {
537546
size_and_align_of::<ctypes::uintptr_t>()
538547
}
539548
ast::ty_rec(fields) {
540549
let total_size = 0;
541550
for field in fields {
542-
let (size, _) = member_size_and_align(field.node.mt.ty);
551+
let (size, _) = member_size_and_align(tcx, field.node.mt.ty);
543552
total_size += size;
544553
}
545554
(total_size, 64) //XXX different align for other arches?
@@ -551,7 +560,7 @@ fn member_size_and_align(ty: @ast::ty) -> (int, int) {
551560
}
552561
}
553562

554-
fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
563+
fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
555564
-> @metadata<tydesc_md> {
556565
/*let cache = get_cache(cx);
557566
alt cached_metadata::<@metadata<tydesc_md>>(
@@ -560,6 +569,19 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
560569
option::none {}
561570
}*/
562571

572+
/* FIXME I am disabling this code as part of the patch that moves
573+
* recognition of named builtin types into resolve. I tried to fix
574+
* it, but it seems to already be broken -- it's only called when
575+
* --xg is given, and compiling with --xg fails on trivial programs.
576+
*
577+
* Generating an ast::ty from a ty::t seems like it should not be
578+
* needed. It is only done to track spans, but you will not get the
579+
* right spans anyway -- types tend to refer to stuff defined
580+
* elsewhere, not be self-contained.
581+
*/
582+
583+
fail;
584+
/*
563585
fn t_to_ty(cx: @crate_ctxt, t: ty::t, span: span) -> @ast::ty {
564586
let ty = alt ty::get(t).struct {
565587
ty::ty_nil { ast::ty_nil }
@@ -628,8 +650,18 @@ fn create_ty(cx: @crate_ctxt, t: ty::t, ty: @ast::ty)
628650
ret create_pointer_type(cx, t, ty.span, v);
629651
}
630652
631-
_ { ret create_basic_type(cx, t, ty); }
653+
ast::ty_path(_, id) {
654+
alt ccx_tcx(cx).def_map.get(id) {
655+
ast::def_prim_ty(pty) {
656+
ret create_basic_type(cx, t, pty, ty.span);
657+
}
658+
_ {}
659+
}
660+
}
661+
662+
_ {}
632663
};
664+
*/
633665
}
634666

635667
fn filename_from_span(cx: @crate_ctxt, sp: codemap::span) -> str {

branches/snap-stage3/src/comp/middle/lint.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,22 @@ fn check_ctypes(tcx: ty::ctxt, crate: @ast::crate) {
9999
let tys = vec::map(decl.inputs) {|a| a.ty };
100100
for ty in (tys + [decl.output]) {
101101
alt ty.node {
102-
ast::ty_int(ast::ty_i) {
103-
tcx.sess.span_warn(
104-
ty.span,
105-
"found rust type `int` in native module, while \
106-
ctypes::c_int or ctypes::long should be used");
107-
}
108-
ast::ty_uint(ast::ty_u) {
109-
tcx.sess.span_warn(
110-
ty.span,
111-
"found rust type `uint` in native module, while \
112-
ctypes::c_uint or ctypes::ulong should be used");
102+
ast::ty_path(_, id) {
103+
alt tcx.def_map.get(id) {
104+
ast::def_prim_ty(ast::ty_int(ast::ty_i)) {
105+
tcx.sess.span_warn(
106+
ty.span,
107+
"found rust type `int` in native module, while \
108+
ctypes::c_int or ctypes::long should be used");
109+
}
110+
ast::def_prim_ty(ast::ty_uint(ast::ty_u)) {
111+
tcx.sess.span_warn(
112+
ty.span,
113+
"found rust type `uint` in native module, while \
114+
ctypes::c_uint or ctypes::ulong should be used");
115+
}
116+
_ { }
117+
}
113118
}
114119
_ { }
115120
}

0 commit comments

Comments
 (0)