Skip to content

Commit 2d47437

Browse files
nikomatsakisbrson
authored andcommitted
---
yaml --- r: 5786 b: refs/heads/master c: 212707c h: refs/heads/master v: v3
1 parent 5c40756 commit 2d47437

File tree

10 files changed

+31
-17
lines changed

10 files changed

+31
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 24b201fa48558832f13c41f1307d824ee26915eb
2+
refs/heads/master: 212707ce8440205d5f49b0a274caf629bf118de0

trunk/src/comp/metadata/decoder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: ast::def_id) ->
178178
'u' { ast::def_fn(did, ast::unsafe_fn) }
179179
'f' { ast::def_fn(did, ast::impure_fn) }
180180
'p' { ast::def_fn(did, ast::pure_fn) }
181-
'F' { ast::def_native_fn(did) }
181+
'U' { ast::def_native_fn(did, ast::unsafe_fn) }
182+
'F' { ast::def_native_fn(did, ast::impure_fn) }
183+
'P' { ast::def_native_fn(did, ast::pure_fn) }
182184
'y' { ast::def_ty(did) }
183185
'T' { ast::def_native_ty(did) }
184186
't' { ast::def_ty(did) }

trunk/src/comp/metadata/encoder.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,15 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
350350
encode_type(ecx, ebml_w,
351351
ty::mk_native(ecx.ccx.tcx, local_def(nitem.id)));
352352
}
353-
native_item_fn(_, _, tps) {
353+
native_item_fn(_, fn_decl, tps) {
354+
let letter =
355+
alt fn_decl.purity {
356+
unsafe_fn. { 'U' }
357+
pure_fn. { 'P' } // this is currently impossible, but hey.
358+
impure_fn. { 'F' }
359+
} as u8;
354360
encode_def_id(ebml_w, local_def(nitem.id));
355-
encode_family(ebml_w, 'F' as u8);
361+
encode_family(ebml_w, letter);
356362
encode_type_param_kinds(ebml_w, tps);
357363
encode_type(ecx, ebml_w, node_id_to_monotype(ecx.ccx.tcx, nitem.id));
358364
encode_symbol(ecx, ebml_w, nitem.id);

trunk/src/comp/middle/resolve.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,9 +1059,11 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
10591059
ret some(ast::def_native_ty(local_def(native_item.id)));
10601060
}
10611061
}
1062-
ast::native_item_fn(_, _, _) {
1062+
ast::native_item_fn(_, decl, _) {
10631063
if ns == ns_value {
1064-
ret some(ast::def_native_fn(local_def(native_item.id)));
1064+
ret some(ast::def_native_fn(
1065+
local_def(native_item.id),
1066+
decl.purity));
10651067
}
10661068
}
10671069
}
@@ -1163,7 +1165,7 @@ fn ns_for_def(d: def) -> namespace {
11631165
ast::def_binding(_) { ns_type }
11641166
ast::def_use(_) { ns_module }
11651167
ast::def_native_ty(_) { ns_type }
1166-
ast::def_native_fn(_) { ns_value }
1168+
ast::def_native_fn(_, _) { ns_value }
11671169
};
11681170
}
11691171

trunk/src/comp/middle/trans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3096,7 +3096,7 @@ fn trans_var(cx: @block_ctxt, sp: span, def: ast::def, id: ast::node_id)
30963096
-> lval_maybe_callee {
30973097
let ccx = bcx_ccx(cx);
30983098
alt def {
3099-
ast::def_fn(did, _) | ast::def_native_fn(did) {
3099+
ast::def_fn(did, _) | ast::def_native_fn(did, _) {
31003100
let tyt = ty::lookup_item_type(ccx.tcx, did);
31013101
ret lval_static_fn(cx, tyt, did, id);
31023102
}

trunk/src/comp/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2602,7 +2602,7 @@ fn def_has_ty_params(def: ast::def) -> bool {
26022602
ast::def_binding(_) { ret false; }
26032603
ast::def_use(_) { ret false; }
26042604
ast::def_native_ty(_) { ret false; }
2605-
ast::def_native_fn(_) { ret true; }
2605+
ast::def_native_fn(_, _) { ret true; }
26062606
}
26072607
}
26082608

trunk/src/comp/middle/typeck.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn ty_param_kinds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
103103
ret {kinds: no_kinds, ty: typ};
104104
}
105105
ast::def_fn(id, _) { ret ty::lookup_item_type(fcx.ccx.tcx, id); }
106-
ast::def_native_fn(id) { ret ty::lookup_item_type(fcx.ccx.tcx, id); }
106+
ast::def_native_fn(id, _) { ret ty::lookup_item_type(fcx.ccx.tcx, id); }
107107
ast::def_const(id) { ret ty::lookup_item_type(fcx.ccx.tcx, id); }
108108
ast::def_variant(_, vid) { ret ty::lookup_item_type(fcx.ccx.tcx, vid); }
109109
ast::def_binding(id) {
@@ -1560,7 +1560,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
15601560
"safe function calls function marked unsafe");
15611561
}
15621562
}
1563-
some(ast::def_native_fn(_)) {
1563+
some(ast::def_native_fn(_, ast::unsafe_fn.)) {
15641564
if sess.get_opts().check_unsafe {
15651565
ccx.tcx.sess.span_fatal(
15661566
sp,
@@ -1893,6 +1893,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
18931893
}
18941894
ast::expr_path(pth) {
18951895
let defn = lookup_def(fcx, pth.span, id);
1896+
18961897
let tpt = ty_param_kinds_and_ty_for_def(fcx, expr.span, defn);
18971898
if ty::def_has_ty_params(defn) {
18981899
let path_tpot = instantiate_path(fcx, pth, tpt, expr.span);

trunk/src/comp/syntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tag def {
4141
def_binding(def_id);
4242
def_use(def_id);
4343
def_native_ty(def_id);
44-
def_native_fn(def_id);
44+
def_native_fn(def_id, purity);
4545
def_upvar(def_id, @def, /* writable */bool);
4646
}
4747

trunk/src/comp/syntax/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn def_id_of_def(d: def) -> def_id {
3737
def_binding(id) { ret id; }
3838
def_use(id) { ret id; }
3939
def_native_ty(id) { ret id; }
40-
def_native_fn(id) { ret id; }
40+
def_native_fn(id, _) { ret id; }
4141
def_upvar(id, _, _) { ret id; }
4242
}
4343
}

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,11 +1972,11 @@ fn parse_item_native_type(p: parser, attrs: [ast::attribute]) ->
19721972
span: ast_util::mk_sp(t.lo, hi)};
19731973
}
19741974

1975-
fn parse_item_native_fn(p: parser, attrs: [ast::attribute]) ->
1976-
@ast::native_item {
1975+
fn parse_item_native_fn(p: parser, attrs: [ast::attribute],
1976+
purity: ast::purity) -> @ast::native_item {
19771977
let lo = p.get_last_lo_pos();
19781978
let t = parse_fn_header(p);
1979-
let decl = parse_fn_decl(p, ast::impure_fn, ast::il_normal);
1979+
let decl = parse_fn_decl(p, purity, ast::il_normal);
19801980
let link_name = none;
19811981
if p.peek() == token::EQ { p.bump(); link_name = some(parse_str(p)); }
19821982
let hi = p.get_hi_pos();
@@ -1993,7 +1993,10 @@ fn parse_native_item(p: parser, attrs: [ast::attribute]) ->
19931993
if eat_word(p, "type") {
19941994
ret parse_item_native_type(p, attrs);
19951995
} else if eat_word(p, "fn") {
1996-
ret parse_item_native_fn(p, attrs);
1996+
ret parse_item_native_fn(p, attrs, ast::impure_fn);
1997+
} else if eat_word(p, "unsafe") {
1998+
expect_word(p, "fn");
1999+
ret parse_item_native_fn(p, attrs, ast::unsafe_fn);
19972000
} else { unexpected(p, p.peek()); }
19982001
}
19992002

0 commit comments

Comments
 (0)