about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-06-26 16:18:37 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-06-26 16:18:37 -0700
commit697f1e38d646bb6c7bab054c8c8c5b469c566ef6 (patch)
tree614999c97dd8e6f648f8a3fd41a8de3304baffa9 /src/libsyntax
parent999b567e2af0a454bc862bc2e5b1bc16dae78f44 (diff)
downloadrust-697f1e38d646bb6c7bab054c8c8c5b469c566ef6.tar.gz
rust-697f1e38d646bb6c7bab054c8c8c5b469c566ef6.zip
Change 'native' and 'crust' to 'extern'.
This comes with a terminology change. All linkage-symbols are 'extern'
now, including rust syms in other crates. Some extern ABIs are
merely "foreign". The term "native" is retired, not clear/useful.

What was "crust" is now "extern" applied to a _definition_. This
is a bit of an overloading, but should be unambiguous: it means
that the definition should be made available to some non-rust ABI.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs28
-rw-r--r--src/libsyntax/ast_map.rs16
-rw-r--r--src/libsyntax/ast_util.rs10
-rw-r--r--src/libsyntax/attr.rs12
-rw-r--r--src/libsyntax/ext/expand.rs2
-rw-r--r--src/libsyntax/fold.rs39
-rw-r--r--src/libsyntax/parse/parser.rs42
-rw-r--r--src/libsyntax/parse/token.rs2
-rw-r--r--src/libsyntax/print/pprust.rs19
-rw-r--r--src/libsyntax/visit.rs24
10 files changed, 102 insertions, 92 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 936718dd0a7..3d2d28a9b1d 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -73,7 +73,7 @@ enum def {
     def_fn(def_id, purity),
     def_self(node_id),
     def_mod(def_id),
-    def_native_mod(def_id),
+    def_foreign_mod(def_id),
     def_const(def_id),
     def_arg(node_id, mode),
     def_local(node_id, bool /* is_mutbl */),
@@ -563,7 +563,7 @@ enum purity {
     pure_fn, // declared with "pure fn"
     unsafe_fn, // declared with "unsafe fn"
     impure_fn, // declared with "fn"
-    crust_fn, // declared with "crust fn"
+    extern_fn, // declared with "crust fn"
 }
 
 #[auto_serialize]
@@ -584,16 +584,16 @@ type method = {ident: ident, attrs: [attribute]/~,
 type _mod = {view_items: [@view_item]/~, items: [@item]/~};
 
 #[auto_serialize]
-enum native_abi {
-    native_abi_rust_intrinsic,
-    native_abi_cdecl,
-    native_abi_stdcall,
+enum foreign_abi {
+    foreign_abi_rust_intrinsic,
+    foreign_abi_cdecl,
+    foreign_abi_stdcall,
 }
 
 #[auto_serialize]
-type native_mod =
+type foreign_mod =
     {view_items: [@view_item]/~,
-     items: [@native_item]/~};
+     items: [@foreign_item]/~};
 
 #[auto_serialize]
 type variant_arg = {ty: @ty, id: node_id};
@@ -681,7 +681,7 @@ enum item_ {
     item_const(@ty, @expr),
     item_fn(fn_decl, [ty_param]/~, blk),
     item_mod(_mod),
-    item_native_mod(native_mod),
+    item_foreign_mod(foreign_mod),
     item_ty(@ty, [ty_param]/~, region_param),
     item_enum([variant]/~, [ty_param]/~, region_param),
     item_class([ty_param]/~, /* ty params for class */
@@ -728,16 +728,16 @@ type class_dtor_ = {id: node_id,
                     body: blk};
 
 #[auto_serialize]
-type native_item =
+type foreign_item =
     {ident: ident,
      attrs: [attribute]/~,
-     node: native_item_,
+     node: foreign_item_,
      id: node_id,
      span: span};
 
 #[auto_serialize]
-enum native_item_ {
-    native_item_fn(fn_decl, [ty_param]/~),
+enum foreign_item_ {
+    foreign_item_fn(fn_decl, [ty_param]/~),
 }
 
 // The data we save and restore about an inlined item or method.  This is not
@@ -747,7 +747,7 @@ enum native_item_ {
 enum inlined_item {
     ii_item(@item),
     ii_method(def_id /* impl id */, @method),
-    ii_native(@native_item),
+    ii_foreign(@foreign_item),
     ii_ctor(class_ctor, ident, [ty_param]/~, def_id /* parent id */),
     ii_dtor(class_dtor, ident, [ty_param]/~, def_id /* parent id */)
 }
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs
index 5ba498cb3f7..5c066bef98b 100644
--- a/src/libsyntax/ast_map.rs
+++ b/src/libsyntax/ast_map.rs
@@ -34,7 +34,7 @@ fn path_to_str(p: path) -> str {
 
 enum ast_node {
     node_item(@item, @path),
-    node_native_item(@native_item, native_abi, @path),
+    node_foreign_item(@foreign_item, foreign_abi, @path),
     node_method(@method, def_id /* impl did */, @path /* path to the impl */),
     node_variant(variant, @item, @path),
     node_expr(@expr),
@@ -104,8 +104,8 @@ fn map_decoded_item(diag: span_handler,
     // add it to the table now:
     alt ii {
       ii_item(*) | ii_ctor(*) | ii_dtor(*) { /* fallthrough */ }
-      ii_native(i) {
-        cx.map.insert(i.id, node_native_item(i, native_abi_rust_intrinsic,
+      ii_foreign(i) {
+        cx.map.insert(i.id, node_foreign_item(i, foreign_abi_rust_intrinsic,
                                              @path));
       }
       ii_method(impl_did, m) {
@@ -202,14 +202,14 @@ fn map_item(i: @item, cx: ctx, v: vt) {
                 extend(cx, i.ident)));
         }
       }
-      item_native_mod(nm) {
-        let abi = alt attr::native_abi(i.attrs) {
+      item_foreign_mod(nm) {
+        let abi = alt attr::foreign_abi(i.attrs) {
           either::left(msg) { cx.diag.span_fatal(i.span, msg); }
           either::right(abi) { abi }
         };
         for nm.items.each {|nitem|
             cx.map.insert(nitem.id,
-                          node_native_item(nitem, abi,
+                          node_foreign_item(nitem, abi,
                                            /* FIXME (#2543) */
                                            @copy cx.path));
         }
@@ -228,7 +228,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
       _ { }
     }
     alt i.node {
-      item_mod(_) | item_native_mod(_) {
+      item_mod(_) | item_foreign_mod(_) {
         vec::push(cx.path, path_mod(i.ident));
       }
       _ { vec::push(cx.path, path_name(i.ident)); }
@@ -269,7 +269,7 @@ fn node_id_to_str(map: map, id: node_id) -> str {
       some(node_item(item, path)) {
         #fmt["item %s (id=%?)", path_ident_to_str(*path, item.ident), id]
       }
-      some(node_native_item(item, abi, path)) {
+      some(node_foreign_item(item, abi, path)) {
         #fmt["native item %s with abi %? (id=%?)",
              path_ident_to_str(*path, item.ident), abi, id]
       }
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 3068d61830e..23326343d38 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -51,7 +51,7 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} {
 pure fn def_id_of_def(d: def) -> def_id {
     alt d {
       def_fn(id, _) | def_mod(id) |
-      def_native_mod(id) | def_const(id) |
+      def_foreign_mod(id) | def_const(id) |
       def_variant(_, id) | def_ty(id) | def_ty_param(id, _) |
       def_use(id) | def_class(id) { id }
       def_arg(id, _) | def_local(id, _) | def_self(id) |
@@ -321,7 +321,7 @@ impl inlined_item_methods for inlined_item {
     fn ident() -> ident {
         alt self {
           ii_item(i) { /* FIXME (#2543) */ copy i.ident }
-          ii_native(i) { /* FIXME (#2543) */ copy i.ident }
+          ii_foreign(i) { /* FIXME (#2543) */ copy i.ident }
           ii_method(_, m) { /* FIXME (#2543) */ copy m.ident }
           ii_ctor(_, nm, _, _) { /* FIXME (#2543) */ copy nm }
           ii_dtor(_, nm, _, _) { /* FIXME (#2543) */ copy nm }
@@ -331,7 +331,7 @@ impl inlined_item_methods for inlined_item {
     fn id() -> ast::node_id {
         alt self {
           ii_item(i) { i.id }
-          ii_native(i) { i.id }
+          ii_foreign(i) { i.id }
           ii_method(_, m) { m.id }
           ii_ctor(ctor, _, _, _) { ctor.node.id }
           ii_dtor(dtor, _, _, _) { dtor.node.id }
@@ -341,7 +341,7 @@ impl inlined_item_methods for inlined_item {
     fn accept<E>(e: E, v: visit::vt<E>) {
         alt self {
           ii_item(i) { v.visit_item(i, e, v) }
-          ii_native(i) { v.visit_native_item(i, e, v) }
+          ii_foreign(i) { v.visit_foreign_item(i, e, v) }
           ii_method(_, m) { visit::visit_method_helper(m, e, v) }
           ii_ctor(ctor, nm, tps, parent_id) {
               visit::visit_class_ctor_helper(ctor, nm, tps, parent_id, e, v);
@@ -419,7 +419,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
             }
         },
 
-        visit_native_item: fn@(ni: @native_item) {
+        visit_foreign_item: fn@(ni: @foreign_item) {
             vfn(ni.id)
         },
 
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index af808222f11..01e2df141de 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -39,7 +39,7 @@ export sort_meta_items;
 export remove_meta_items_by_name;
 export find_linkage_attrs;
 export find_linkage_metas;
-export native_abi;
+export foreign_abi;
 export inline_attr;
 export find_inline_attr;
 export require_unique_names;
@@ -322,19 +322,19 @@ fn find_linkage_metas(attrs: [ast::attribute]/~) -> [@ast::meta_item]/~ {
     }
 }
 
-fn native_abi(attrs: [ast::attribute]/~) -> either<str, ast::native_abi> {
+fn foreign_abi(attrs: [ast::attribute]/~) -> either<str, ast::foreign_abi> {
     ret alt attr::first_attr_value_str_by_name(attrs, "abi") {
       option::none {
-        either::right(ast::native_abi_cdecl)
+        either::right(ast::foreign_abi_cdecl)
       }
       option::some(@"rust-intrinsic") {
-        either::right(ast::native_abi_rust_intrinsic)
+        either::right(ast::foreign_abi_rust_intrinsic)
       }
       option::some(@"cdecl") {
-        either::right(ast::native_abi_cdecl)
+        either::right(ast::foreign_abi_cdecl)
       }
       option::some(@"stdcall") {
-        either::right(ast::native_abi_stdcall)
+        either::right(ast::foreign_abi_stdcall)
       }
       option::some(t) {
         either::left("unsupported abi: " + *t)
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index ca5d7f6bab3..e9c6e6e122c 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -129,7 +129,7 @@ fn expand_item(cx: ext_ctxt, &&it: @ast::item, fld: ast_fold,
     -> @ast::item
 {
     let is_mod = alt it.node {
-      ast::item_mod(_) | ast::item_native_mod(_) {true}
+      ast::item_mod(_) | ast::item_foreign_mod(_) {true}
       _ {false}
     };
     if is_mod { cx.mod_push(it.ident); }
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index d1ee7a16a47..0f9397f5c2b 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -21,7 +21,7 @@ iface ast_fold {
     fn fold_crate(crate) -> crate;
     fn fold_crate_directive(&&@crate_directive) -> @crate_directive;
     fn fold_view_item(&&@view_item) -> @view_item;
-    fn fold_native_item(&&@native_item) -> @native_item;
+    fn fold_foreign_item(&&@foreign_item) -> @foreign_item;
     fn fold_item(&&@item) -> @item;
     fn fold_class_item(&&@class_member) -> @class_member;
     fn fold_item_underscore(item_) -> item_;
@@ -36,7 +36,7 @@ iface ast_fold {
     fn fold_constr(&&@constr) -> @constr;
     fn fold_ty_constr(&&@ty_constr) -> @ty_constr;
     fn fold_mod(_mod) -> _mod;
-    fn fold_native_mod(native_mod) -> native_mod;
+    fn fold_foreign_mod(foreign_mod) -> foreign_mod;
     fn fold_variant(variant) -> variant;
     fn fold_ident(&&ident) -> ident;
     fn fold_path(&&@path) -> @path;
@@ -54,7 +54,7 @@ type ast_fold_precursor = @{
     fold_crate_directive: fn@(crate_directive_, span,
                               ast_fold) -> (crate_directive_, span),
     fold_view_item: fn@(view_item_, ast_fold) -> view_item_,
-    fold_native_item: fn@(&&@native_item, ast_fold) -> @native_item,
+    fold_foreign_item: fn@(&&@foreign_item, ast_fold) -> @foreign_item,
     fold_item: fn@(&&@item, ast_fold) -> @item,
     fold_class_item: fn@(&&@class_member, ast_fold) -> @class_member,
     fold_item_underscore: fn@(item_, ast_fold) -> item_,
@@ -70,7 +70,7 @@ type ast_fold_precursor = @{
     fold_ty_constr: fn@(ast::ty_constr_, span, ast_fold)
         -> (ty_constr_, span),
     fold_mod: fn@(_mod, ast_fold) -> _mod,
-    fold_native_mod: fn@(native_mod, ast_fold) -> native_mod,
+    fold_foreign_mod: fn@(foreign_mod, ast_fold) -> foreign_mod,
     fold_variant: fn@(variant_, span, ast_fold) -> (variant_, span),
     fold_ident: fn@(&&ident, ast_fold) -> ident,
     fold_path: fn@(path, ast_fold) -> path,
@@ -105,7 +105,7 @@ fn fold_attribute_(at: attribute, fld: ast_fold) ->
                 value: *fold_meta_item_(@at.node.value, fld)},
          span: fld.new_span(at.span)};
 }
-//used in noop_fold_native_item and noop_fold_fn_decl
+//used in noop_fold_foreign_item and noop_fold_fn_decl
 fn fold_arg_(a: arg, fld: ast_fold) -> arg {
     ret {mode: a.mode,
          ty: fld.fold_ty(a.ty),
@@ -186,7 +186,8 @@ fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {
 }
 
 
-fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
+fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold)
+    -> @foreign_item {
     let fold_arg = {|x|fold_arg_(x, fld)};
     let fold_attribute = {|x|fold_attribute_(x, fld)};
 
@@ -194,8 +195,8 @@ fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
           attrs: vec::map(ni.attrs, fold_attribute),
           node:
               alt ni.node {
-                native_item_fn(fdec, typms) {
-                  native_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
+                foreign_item_fn(fdec, typms) {
+                  foreign_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
                                   output: fld.fold_ty(fdec.output),
                                   purity: fdec.purity,
                                   cf: fdec.cf,
@@ -241,7 +242,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
                       fld.fold_block(body))
           }
           item_mod(m) { item_mod(fld.fold_mod(m)) }
-          item_native_mod(nm) { item_native_mod(fld.fold_native_mod(nm)) }
+          item_foreign_mod(nm) { item_foreign_mod(fld.fold_foreign_mod(nm)) }
           item_ty(t, typms, rp) { item_ty(fld.fold_ty(t),
                                           fold_ty_params(typms, fld),
                                           rp) }
@@ -517,9 +518,9 @@ fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
          items: vec::map(m.items, fld.fold_item)};
 }
 
-fn noop_fold_native_mod(nm: native_mod, fld: ast_fold) -> native_mod {
+fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod {
     ret {view_items: vec::map(nm.view_items, fld.fold_view_item),
-         items: vec::map(nm.items, fld.fold_native_item)}
+         items: vec::map(nm.items, fld.fold_foreign_item)}
 }
 
 fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
@@ -583,7 +584,7 @@ fn default_ast_fold() -> ast_fold_precursor {
     ret @{fold_crate: wrap(noop_fold_crate),
           fold_crate_directive: wrap(noop_fold_crate_directive),
           fold_view_item: noop_fold_view_item,
-          fold_native_item: noop_fold_native_item,
+          fold_foreign_item: noop_fold_foreign_item,
           fold_item: noop_fold_item,
           fold_class_item: noop_fold_class_item,
           fold_item_underscore: noop_fold_item_underscore,
@@ -598,7 +599,7 @@ fn default_ast_fold() -> ast_fold_precursor {
           fold_constr: wrap(noop_fold_constr),
           fold_ty_constr: wrap(noop_fold_ty_constr),
           fold_mod: noop_fold_mod,
-          fold_native_mod: noop_fold_native_mod,
+          fold_foreign_mod: noop_fold_foreign_mod,
           fold_variant: wrap(noop_fold_variant),
           fold_ident: noop_fold_ident,
           fold_path: noop_fold_path,
@@ -628,9 +629,9 @@ impl of ast_fold for ast_fold_precursor {
               vis: x.vis,
               span: self.new_span(x.span)};
     }
-    fn fold_native_item(&&x: @native_item)
-        -> @native_item {
-        ret self.fold_native_item(x, self as ast_fold);
+    fn fold_foreign_item(&&x: @foreign_item)
+        -> @foreign_item {
+        ret self.fold_foreign_item(x, self as ast_fold);
     }
     fn fold_item(&&i: @item) -> @item {
         ret self.fold_item(i, self as ast_fold);
@@ -699,9 +700,9 @@ impl of ast_fold for ast_fold_precursor {
     fn fold_mod(x: _mod) -> _mod {
         ret self.fold_mod(x, self as ast_fold);
     }
-    fn fold_native_mod(x: native_mod) ->
-       native_mod {
-        ret self.fold_native_mod(x, self as ast_fold);
+    fn fold_foreign_mod(x: foreign_mod) ->
+       foreign_mod {
+        ret self.fold_foreign_mod(x, self as ast_fold);
     }
     fn fold_variant(x: variant) ->
        variant {
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index c6b31e52039..378580d3c36 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -147,7 +147,8 @@ class parser {
     fn get_id() -> node_id { next_node_id(self.sess) }
 
     fn parse_ty_fn(purity: ast::purity) -> ty_ {
-        let proto = if self.eat_keyword("native") {
+        let proto = if self.eat_keyword("native") ||
+            self.eat_keyword("extern") {
             self.expect_keyword("fn");
             ast::proto_bare
         } else {
@@ -413,7 +414,8 @@ class parser {
             self.parse_ty_fn(ast::unsafe_fn)
         } else if self.is_keyword("fn") {
             self.parse_ty_fn(ast::impure_fn)
-        } else if self.eat_keyword("native") {
+        } else if self.eat_keyword("native") ||
+            self.eat_keyword("extern") {
             self.expect_keyword("fn");
             ty_fn(proto_bare, self.parse_ty_fn_decl(ast::impure_fn))
         } else if self.token == token::MOD_SEP || is_ident(self.token) {
@@ -2165,8 +2167,8 @@ class parser {
         (id, item_mod(m), some(inner_attrs.inner))
     }
 
-    fn parse_item_native_fn(+attrs: [attribute]/~,
-                            purity: purity) -> @native_item {
+    fn parse_item_foreign_fn(+attrs: [attribute]/~,
+                             purity: purity) -> @foreign_item {
         let lo = self.last_span.lo;
         let t = self.parse_fn_header();
         let (decl, _) = self.parse_fn_decl(purity, {|p| p.parse_arg()});
@@ -2174,7 +2176,7 @@ class parser {
         self.expect(token::SEMI);
         ret @{ident: t.ident,
               attrs: attrs,
-              node: native_item_fn(decl, t.tps),
+              node: foreign_item_fn(decl, t.tps),
               id: self.get_id(),
               span: mk_sp(lo, hi)};
     }
@@ -2191,35 +2193,35 @@ class parser {
         else { self.unexpected(); }
     }
 
-    fn parse_native_item(+attrs: [attribute]/~) ->
-        @native_item {
-        self.parse_item_native_fn(attrs, self.parse_fn_purity())
+    fn parse_foreign_item(+attrs: [attribute]/~) ->
+        @foreign_item {
+        self.parse_item_foreign_fn(attrs, self.parse_fn_purity())
     }
 
-    fn parse_native_mod_items(+first_item_attrs: [attribute]/~) ->
-        native_mod {
+    fn parse_foreign_mod_items(+first_item_attrs: [attribute]/~) ->
+        foreign_mod {
         // Shouldn't be any view items since we've already parsed an item attr
         let {attrs_remaining, view_items} =
             self.parse_view(first_item_attrs, false);
-        let mut items: [@native_item]/~ = []/~;
+        let mut items: [@foreign_item]/~ = []/~;
         let mut initial_attrs = attrs_remaining;
         while self.token != token::RBRACE {
             let attrs = initial_attrs + self.parse_outer_attributes();
             initial_attrs = []/~;
-            vec::push(items, self.parse_native_item(attrs));
+            vec::push(items, self.parse_foreign_item(attrs));
         }
         ret {view_items: view_items,
              items: items};
     }
 
-    fn parse_item_native_mod() -> item_info {
+    fn parse_item_foreign_mod() -> item_info {
         self.expect_keyword("mod");
         let id = self.parse_ident();
         self.expect(token::LBRACE);
         let more_attrs = self.parse_inner_attrs_and_next();
-        let m = self.parse_native_mod_items(more_attrs.next);
+        let m = self.parse_foreign_mod_items(more_attrs.next);
         self.expect(token::RBRACE);
-        (id, item_native_mod(m), some(more_attrs.inner))
+        (id, item_foreign_mod(m), some(more_attrs.inner))
     }
 
     fn parse_type_decl() -> {lo: uint, ident: ident} {
@@ -2355,13 +2357,19 @@ class parser {
             self.bump();
             self.expect_keyword("fn");
             self.parse_item_fn(unsafe_fn)
+        } else if self.eat_keyword("extern") {
+            if self.eat_keyword("fn") {
+                self.parse_item_fn(extern_fn)
+            } else {
+                self.parse_item_foreign_mod()
+            }
         } else if self.eat_keyword("crust") {
             self.expect_keyword("fn");
-            self.parse_item_fn(crust_fn)
+            self.parse_item_fn(extern_fn)
         } else if self.eat_keyword("mod") {
             self.parse_item_mod()
         } else if self.eat_keyword("native") {
-            self.parse_item_native_mod()
+            self.parse_item_foreign_mod()
         } else if self.eat_keyword("type") {
             self.parse_item_type()
         } else if self.eat_keyword("enum") {
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index feffbd4020c..0586a3c2d52 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -288,7 +288,7 @@ fn restricted_keyword_table() -> hashmap<str, ()> {
         "be", "break",
         "check", "claim", "class", "const", "cont", "copy", "crust",
         "do", "drop",
-        "else", "enum", "export",
+        "else", "enum", "export", "extern",
         "fail", "false", "fn", "for",
         "if", "iface", "impl", "import",
         "let", "log", "loop",
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 0d3855b4f93..12715270685 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -297,12 +297,13 @@ fn print_mod(s: ps, _mod: ast::_mod, attrs: [ast::attribute]/~) {
     for _mod.items.each {|item| print_item(s, item); }
 }
 
-fn print_native_mod(s: ps, nmod: ast::native_mod, attrs: [ast::attribute]/~) {
+fn print_foreign_mod(s: ps, nmod: ast::foreign_mod,
+                     attrs: [ast::attribute]/~) {
     print_inner_attributes(s, attrs);
     for nmod.view_items.each {|vitem|
         print_view_item(s, vitem);
     }
-    for nmod.items.each {|item| print_native_item(s, item); }
+    for nmod.items.each {|item| print_foreign_item(s, item); }
 }
 
 fn print_region(s: ps, region: @ast::region) {
@@ -388,12 +389,12 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) {
     end(s);
 }
 
-fn print_native_item(s: ps, item: @ast::native_item) {
+fn print_foreign_item(s: ps, item: @ast::foreign_item) {
     hardbreak_if_not_bol(s);
     maybe_print_comment(s, item.span.lo);
     print_outer_attributes(s, item.attrs);
     alt item.node {
-      ast::native_item_fn(decl, typarams) {
+      ast::foreign_item_fn(decl, typarams) {
         print_fn(s, decl, item.ident, typarams);
         end(s); // end head-ibox
         word(s.s, ";");
@@ -434,12 +435,12 @@ fn print_item(s: ps, &&item: @ast::item) {
         print_mod(s, _mod, item.attrs);
         bclose(s, item.span);
       }
-      ast::item_native_mod(nmod) {
-        head(s, "native");
+      ast::item_foreign_mod(nmod) {
+        head(s, "extern");
         word_nbsp(s, "mod");
         word_nbsp(s, *item.ident);
         bopen(s);
-        print_native_mod(s, nmod, item.attrs);
+        print_foreign_mod(s, nmod, item.attrs);
         bclose(s, item.span);
       }
       ast::item_ty(ty, params, rp) {
@@ -1753,7 +1754,7 @@ fn purity_to_str(p: ast::purity) -> str {
       ast::impure_fn {"impure"}
       ast::unsafe_fn {"unsafe"}
       ast::pure_fn {"pure"}
-      ast::crust_fn {"crust"}
+      ast::extern_fn {"extern"}
     }
 }
 
@@ -1766,7 +1767,7 @@ fn print_purity(s: ps, p: ast::purity) {
 
 fn proto_to_str(p: ast::proto) -> str {
     ret alt p {
-      ast::proto_bare { "native fn" }
+      ast::proto_bare { "extern fn" }
       ast::proto_any { "fn" }
       ast::proto_block { "fn&" }
       ast::proto_uniq { "fn~" }
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 6a07d7f62ca..dad722d2182 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -48,7 +48,7 @@ type visitor<E> =
     // generic over constr and ty_constr
     @{visit_mod: fn@(_mod, span, node_id, E, vt<E>),
       visit_view_item: fn@(@view_item, E, vt<E>),
-      visit_native_item: fn@(@native_item, E, vt<E>),
+      visit_foreign_item: fn@(@foreign_item, E, vt<E>),
       visit_item: fn@(@item, E, vt<E>),
       visit_local: fn@(@local, E, vt<E>),
       visit_block: fn@(ast::blk, E, vt<E>),
@@ -66,7 +66,7 @@ type visitor<E> =
 fn default_visitor<E>() -> visitor<E> {
     ret @{visit_mod: {|a,b,c,d,e|visit_mod::<E>(a, b, c, d, e)},
           visit_view_item: {|a,b,c|visit_view_item::<E>(a, b, c)},
-          visit_native_item: {|a,b,c|visit_native_item::<E>(a, b, c)},
+          visit_foreign_item: {|a,b,c|visit_foreign_item::<E>(a, b, c)},
           visit_item: {|a,b,c|visit_item::<E>(a, b, c)},
           visit_local: {|a,b,c|visit_local::<E>(a, b, c)},
           visit_block: {|a,b,c|visit_block::<E>(a, b, c)},
@@ -121,9 +121,9 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) {
                    i.span, i.id, e, v);
       }
       item_mod(m) { v.visit_mod(m, i.span, i.id, e, v); }
-      item_native_mod(nm) {
+      item_foreign_mod(nm) {
         for nm.view_items.each {|vi| v.visit_view_item(vi, e, v); }
-        for nm.items.each {|ni| v.visit_native_item(ni, e, v); }
+        for nm.items.each {|ni| v.visit_foreign_item(ni, e, v); }
       }
       item_ty(t, tps, rp) {
         v.visit_ty(t, e, v);
@@ -247,9 +247,9 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
     }
 }
 
-fn visit_native_item<E>(ni: @native_item, e: E, v: vt<E>) {
+fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) {
     alt ni.node {
-      native_item_fn(fd, tps) {
+      foreign_item_fn(fd, tps) {
         v.visit_ty_params(tps, e, v);
         visit_fn_decl(fd, e, v);
       }
@@ -444,7 +444,7 @@ type simple_visitor =
     // generic over constr and ty_constr
     @{visit_mod: fn@(_mod, span, node_id),
       visit_view_item: fn@(@view_item),
-      visit_native_item: fn@(@native_item),
+      visit_foreign_item: fn@(@foreign_item),
       visit_item: fn@(@item),
       visit_local: fn@(@local),
       visit_block: fn@(ast::blk),
@@ -464,7 +464,7 @@ fn simple_ignore_ty(_t: @ty) {}
 fn default_simple_visitor() -> simple_visitor {
     ret @{visit_mod: fn@(_m: _mod, _sp: span, _id: node_id) { },
           visit_view_item: fn@(_vi: @view_item) { },
-          visit_native_item: fn@(_ni: @native_item) { },
+          visit_foreign_item: fn@(_ni: @foreign_item) { },
           visit_item: fn@(_i: @item) { },
           visit_local: fn@(_l: @local) { },
           visit_block: fn@(_b: ast::blk) { },
@@ -492,10 +492,10 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
         f(vi);
         visit_view_item(vi, e, v);
     }
-    fn v_native_item(f: fn@(@native_item), ni: @native_item, &&e: (),
+    fn v_foreign_item(f: fn@(@foreign_item), ni: @foreign_item, &&e: (),
                      v: vt<()>) {
         f(ni);
-        visit_native_item(ni, e, v);
+        visit_foreign_item(ni, e, v);
     }
     fn v_item(f: fn@(@item), i: @item, &&e: (), v: vt<()>) {
         f(i);
@@ -565,8 +565,8 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
                 visit_view_item: {|a,b,c|
                     v_view_item(v.visit_view_item, a, b, c)
                 },
-                visit_native_item:
-                    {|a,b,c|v_native_item(v.visit_native_item, a, b, c)},
+                visit_foreign_item:
+                    {|a,b,c|v_foreign_item(v.visit_foreign_item, a, b, c)},
                 visit_item: {|a,b,c|v_item(v.visit_item, a, b, c)},
                 visit_local: {|a,b,c|v_local(v.visit_local, a, b, c)},
                 visit_block: {|a,b,c|v_block(v.visit_block, a, b, c)},