diff --git a/src/librustc/front/map/mod.rs b/src/librustc/front/map/mod.rs index 008229aca0bcf..f398c465ffe6e 100644 --- a/src/librustc/front/map/mod.rs +++ b/src/librustc/front/map/mod.rs @@ -20,7 +20,7 @@ use middle::cstore::InlinedItem; use middle::cstore::InlinedItem as II; use middle::def_id::DefId; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast::{self, Name, NodeId, DUMMY_NODE_ID}; use syntax::codemap::{Span, Spanned}; use syntax::parse::token; @@ -512,7 +512,7 @@ impl<'ast> Map<'ast> { } } - pub fn get_foreign_abi(&self, id: NodeId) -> abi::Abi { + pub fn get_foreign_abi(&self, id: NodeId) -> Abi { let parent = self.get_parent(id); let abi = match self.find_entry(parent) { Some(EntryItem(_, i)) => { @@ -522,7 +522,7 @@ impl<'ast> Map<'ast> { } } /// Wrong but OK, because the only inlined foreign items are intrinsics. - Some(RootInlinedParent(_)) => Some(abi::RustIntrinsic), + Some(RootInlinedParent(_)) => Some(Abi::RustIntrinsic), _ => None }; match abi { diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 9afc1e366eed5..a763677db0661 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -17,7 +17,7 @@ use middle::ty::{self, Ty, TypeFoldable}; use std::fmt; -use syntax::abi::RustIntrinsic; +use syntax::abi::Abi::RustIntrinsic; use syntax::ast; use syntax::codemap::Span; use rustc_front::intravisit::{self, Visitor, FnKind}; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 6dd447e3b6860..d34c3b742179c 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -25,7 +25,7 @@ use session::config; use util::nodemap::NodeSet; use std::collections::HashSet; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast; use syntax::attr; use rustc_front::hir; @@ -236,7 +236,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // participate in linkage after this product is produced) if let ast_map::NodeItem(item) = *node { if let hir::ItemFn(_, _, _, abi, _, _) = item.node { - if abi != abi::Rust { + if abi != Abi::Rust { self.reachable_symbols.insert(search_item); } } diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 61418734b674b..29355e0684d96 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -46,7 +46,7 @@ use middle::ty::relate::TypeRelation; use std::cell::RefCell; use std::fmt; use std::rc::Rc; -use syntax::abi; +use syntax::abi::Abi; use rustc_front::hir; use util::common::ErrorReported; use util::nodemap::FnvHashMap; @@ -1288,7 +1288,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // provide an impl, but only for suitable `fn` pointers ty::TyBareFn(_, &ty::BareFnTy { unsafety: hir::Unsafety::Normal, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: _, output: ty::FnConverging(_), diff --git a/src/librustc/middle/ty/context.rs b/src/librustc/middle/ty/context.rs index 071cc0cbe3d63..6307ec8bbd04f 100644 --- a/src/librustc/middle/ty/context.rs +++ b/src/librustc/middle/ty/context.rs @@ -44,7 +44,7 @@ use std::borrow::Borrow; use std::cell::{Cell, RefCell, Ref}; use std::hash::{Hash, Hasher}; use std::rc::Rc; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast::{self, Name, NodeId}; use syntax::attr; use syntax::parse::token::special_idents; @@ -943,7 +943,7 @@ impl<'tcx> ctxt<'tcx> { let input_args = input_tys.iter().cloned().collect(); self.mk_fn(Some(def_id), self.mk_bare_fn(BareFnTy { unsafety: hir::Unsafety::Normal, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: input_args, output: ty::FnConverging(output), diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 77e39bba54afc..a0939dc53dfcf 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -20,7 +20,7 @@ use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; use middle::ty::{self, Ty, TypeFoldable}; use std::fmt; -use syntax::{abi}; +use syntax::abi::Abi; use syntax::parse::token; use syntax::ast::CRATE_NODE_ID; use rustc_front::hir; @@ -814,7 +814,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> { try!(write!(f, "unsafe ")); } - if bare_fn.abi != abi::Rust { + if bare_fn.abi != Abi::Rust { try!(write!(f, "extern {} ", bare_fn.abi)); } diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index c61ae547a2254..0757465ba1088 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -48,7 +48,7 @@ use serialize::json::Json; use std::default::Default; use std::io::prelude::*; -use syntax::abi; +use syntax::abi::Abi; mod android_base; mod apple_base; @@ -262,13 +262,13 @@ impl Default for TargetOptions { impl Target { /// Given a function ABI, turn "System" into the correct ABI for this target. - pub fn adjust_abi(&self, abi: abi::Abi) -> abi::Abi { + pub fn adjust_abi(&self, abi: Abi) -> Abi { match abi { - abi::System => { + Abi::System => { if self.options.is_like_windows && self.arch == "x86" { - abi::Stdcall + Abi::Stdcall } else { - abi::C + Abi::C } }, abi => abi diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 3736e045bd19a..3220295d9b88a 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -32,7 +32,8 @@ use rustc_metadata::cstore::CStore; use rustc::front::map as hir_map; use rustc::session::{self, config}; use std::rc::Rc; -use syntax::{abi, ast}; +use syntax::ast; +use syntax::abi::Abi; use syntax::codemap::{MultiSpan, CodeMap, DUMMY_SP}; use syntax::errors; use syntax::errors::emitter::Emitter; @@ -263,7 +264,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { self.infcx.tcx.mk_fn(None, self.infcx.tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Normal, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: input_args, output: ty::FnConverging(output_ty), diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index dd39d3b63c4f9..091352bb8f8b7 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -10,7 +10,7 @@ pub use self::AnnNode::*; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast; use syntax::codemap::{self, CodeMap, BytePos, Spanned}; use syntax::errors; @@ -290,7 +290,7 @@ pub fn fun_to_string(decl: &hir::FnDecl, try!(s.print_fn(decl, unsafety, constness, - abi::Rust, + Abi::Rust, Some(name), generics, opt_explicit_self, @@ -569,7 +569,7 @@ impl<'a> State<'a> { try!(self.print_fn(decl, hir::Unsafety::Normal, hir::Constness::NotConst, - abi::Rust, + Abi::Rust, Some(item.name), generics, None, @@ -1916,7 +1916,7 @@ impl<'a> State<'a> { decl: &hir::FnDecl, unsafety: hir::Unsafety, constness: hir::Constness, - abi: abi::Abi, + abi: Abi, name: Option, generics: &hir::Generics, opt_explicit_self: Option<&hir::ExplicitSelf_>, @@ -2250,7 +2250,7 @@ impl<'a> State<'a> { } pub fn print_ty_fn(&mut self, - abi: abi::Abi, + abi: Abi, unsafety: hir::Unsafety, decl: &hir::FnDecl, name: Option, @@ -2331,10 +2331,10 @@ impl<'a> State<'a> { } pub fn print_opt_abi_and_extern_if_nondefault(&mut self, - opt_abi: Option) + opt_abi: Option) -> io::Result<()> { match opt_abi { - Some(abi::Rust) => Ok(()), + Some(Abi::Rust) => Ok(()), Some(abi) => { try!(self.word_nbsp("extern")); self.word_nbsp(&abi.to_string()) @@ -2343,7 +2343,7 @@ impl<'a> State<'a> { } } - pub fn print_extern_opt_abi(&mut self, opt_abi: Option) -> io::Result<()> { + pub fn print_extern_opt_abi(&mut self, opt_abi: Option) -> io::Result<()> { match opt_abi { Some(abi) => { try!(self.word_nbsp("extern")); @@ -2356,7 +2356,7 @@ impl<'a> State<'a> { pub fn print_fn_header_info(&mut self, unsafety: hir::Unsafety, constness: hir::Constness, - abi: abi::Abi, + abi: Abi, vis: hir::Visibility) -> io::Result<()> { try!(word(&mut self.s, &visibility_qualified(vis, ""))); @@ -2367,7 +2367,7 @@ impl<'a> State<'a> { hir::Constness::Const => try!(self.word_nbsp("const")), } - if abi != abi::Rust { + if abi != Abi::Rust { try!(self.word_nbsp("extern")); try!(self.word_nbsp(&abi.to_string())); } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 9e3ca70e5e42d..09cdab33c8445 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1039,7 +1039,7 @@ impl LintPass for MutableTransmutes { impl LateLintPass for MutableTransmutes { fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) { - use syntax::abi::RustIntrinsic; + use syntax::abi::Abi::RustIntrinsic; let msg = "mutating transmuted &mut T from &T may cause undefined behavior,\ consider instead using an UnsafeCell"; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 2688d549d4fac..fae40d7224b48 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -23,7 +23,8 @@ use lint::{LintPass, LateLintPass}; use std::cmp; use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64}; -use syntax::{abi, ast}; +use syntax::ast; +use syntax::abi::Abi; use syntax::attr::{self, AttrMetaMethods}; use syntax::codemap::{self, Span}; @@ -558,10 +559,10 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { ty::TyBareFn(None, bare_fn) => { match bare_fn.abi { - abi::Rust | - abi::RustIntrinsic | - abi::PlatformIntrinsic | - abi::RustCall => { + Abi::Rust | + Abi::RustIntrinsic | + Abi::PlatformIntrinsic | + Abi::RustCall => { return FfiUnsafe( "found function pointer with Rust calling \ convention in foreign module; consider using an \ @@ -677,7 +678,7 @@ impl LateLintPass for ImproperCTypes { } if let hir::ItemForeignMod(ref nmod) = it.node { - if nmod.abi != abi::RustIntrinsic && nmod.abi != abi::PlatformIntrinsic { + if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic { for ni in &nmod.items { match ni.node { hir::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &**decl), diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 7b094a5900a05..d5aa091886eb1 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -31,7 +31,7 @@ use std::rc::Rc; use std::fs; use syntax::ast; -use syntax::abi; +use syntax::abi::Abi; use syntax::codemap::{self, Span, mk_sp, Pos}; use syntax::parse; use syntax::attr; @@ -784,7 +784,7 @@ impl<'a, 'b> LocalCrateReader<'a, 'b> { } fn process_foreign_mod(&mut self, i: &hir::Item, fm: &hir::ForeignMod) { - if fm.abi == abi::Rust || fm.abi == abi::RustIntrinsic || fm.abi == abi::PlatformIntrinsic { + if fm.abi == Abi::Rust || fm.abi == Abi::RustIntrinsic || fm.abi == Abi::PlatformIntrinsic { return; } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 2cdce7ae784c9..f73d6f0de2c8d 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -51,7 +51,7 @@ use syntax::attr; use syntax::parse::token::{IdentInterner, special_idents}; use syntax::parse::token; use syntax::ast; -use syntax::abi; +use syntax::abi::Abi; use syntax::codemap::{self, Span, BytePos, NO_EXPANSION}; use syntax::print::pprust; use syntax::ptr::P; @@ -1701,7 +1701,7 @@ pub fn is_extern_fn(cdata: Cmd, id: DefIndex, tcx: &ty::ctxt) -> bool { if let Fn = item_family(item_doc) { let ty::TypeScheme { generics, ty } = get_type(cdata, id, tcx); generics.types.is_empty() && match ty.sty { - ty::TyBareFn(_, fn_ty) => fn_ty.abi != abi::Rust, + ty::TyBareFn(_, fn_ty) => fn_ty.abi != Abi::Rust, _ => false, } } else { diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 8df72016078e6..f43a3d44aa6d2 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -40,7 +40,7 @@ use std::io::prelude::*; use std::io::{Cursor, SeekFrom}; use std::rc::Rc; use std::u32; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast::{self, NodeId, Name, CRATE_NODE_ID, CrateNum}; use syntax::codemap::BytePos; use syntax::attr; @@ -1381,7 +1381,7 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, nitem: &hir::ForeignItem, index: &mut CrateIndex<'tcx>, path: PathElems, - abi: abi::Abi) { + abi: Abi) { let def_id = ecx.tcx.map.local_def_id(nitem.id); index.record(def_id, rbml_w); @@ -1393,7 +1393,7 @@ fn encode_info_for_foreign_item<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, encode_family(rbml_w, FN_FAMILY); encode_bounds_and_type_for_item(rbml_w, ecx, index, nitem.id); encode_name(rbml_w, nitem.name); - if abi == abi::RustIntrinsic || abi == abi::PlatformIntrinsic { + if abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic { encode_inlined_item(ecx, rbml_w, InlinedItemRef::Foreign(nitem)); } encode_attributes(rbml_w, &*nitem.attrs); diff --git a/src/librustc_trans/trans/attributes.rs b/src/librustc_trans/trans/attributes.rs index 28dfa4e07e668..be0c62f511fb8 100644 --- a/src/librustc_trans/trans/attributes.rs +++ b/src/librustc_trans/trans/attributes.rs @@ -14,7 +14,7 @@ use llvm::{self, ValueRef, AttrHelper}; use middle::ty; use middle::infer; use session::config::NoDebugInfo; -use syntax::abi; +use syntax::abi::Abi; pub use syntax::attr::InlineAttr; use syntax::ast; use rustc_front::hir; @@ -136,7 +136,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx let infcx = infer::normalizing_infer_ctxt(ccx.tcx(), &ccx.tcx().tables); function_type = infcx.closure_type(closure_did, substs); let self_type = base::self_type_for_closure(ccx, closure_did, fn_type); - (&function_type.sig, abi::RustCall, Some(self_type)) + (&function_type.sig, Abi::RustCall, Some(self_type)) } _ => ccx.sess().bug("expected closure or function.") }; @@ -151,7 +151,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx // unpack the input ty's let input_tys = match fn_type.sty { ty::TyClosure(..) => { - assert!(abi == abi::RustCall); + assert!(abi == Abi::RustCall); match fn_sig.inputs[0].sty { ty::TyTuple(ref inputs) => { @@ -162,7 +162,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx _ => ccx.sess().bug("expected tuple'd inputs") } }, - ty::TyBareFn(..) if abi == abi::RustCall => { + ty::TyBareFn(..) if abi == Abi::RustCall => { let mut inputs = vec![fn_sig.inputs[0]]; match fn_sig.inputs[1].sty { diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 2fc585c7c795e..9c5173b6278e3 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -100,7 +100,7 @@ use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; use std::str; use std::{i8, i16, i32, i64}; -use syntax::abi::{Rust, RustCall, RustIntrinsic, PlatformIntrinsic, Abi}; +use syntax::abi::Abi; use syntax::codemap::{Span, DUMMY_SP}; use syntax::parse::token::InternedString; use syntax::attr::AttrMetaMethods; @@ -911,10 +911,10 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, match t.sty { ty::TyBareFn(_, ref fn_ty) => { match ccx.sess().target.target.adjust_abi(fn_ty.abi) { - Rust | RustCall => { + Abi::Rust | Abi::RustCall => { get_extern_rust_fn(ccx, t, &name[..], did) } - RustIntrinsic | PlatformIntrinsic => { + Abi::RustIntrinsic | Abi::PlatformIntrinsic => { ccx.sess().bug("unexpected intrinsic in trans_external_path") } _ => { @@ -2030,7 +2030,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>, bcx.fcx.ccx.tn().val_to_string(bcx.fcx.llfn)); let has_tupled_arg = match closure_env { - closure::ClosureEnv::NotClosure => abi == RustCall, + closure::ClosureEnv::NotClosure => abi == Abi::RustCall, _ => false, }; @@ -2502,7 +2502,7 @@ pub fn trans_item(ccx: &CrateContext, item: &hir::Item) { for (ref ccx, is_origin) in ccx.maybe_iter(!from_external && trans_everywhere) { let llfn = get_item_val(ccx, item.id); let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty()); - if abi != Rust { + if abi != Abi::Rust { foreign::trans_rust_fn_with_foreign_abi(ccx, &**decl, &**body, @@ -2606,12 +2606,12 @@ fn register_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, node_type: Ty<'tcx>) -> ValueRef { if let ty::TyBareFn(_, ref f) = node_type.sty { - if f.abi != Rust && f.abi != RustCall { + if f.abi != Abi::Rust && f.abi != Abi::RustCall { ccx.sess().span_bug(sp, &format!("only the `{}` or `{}` calling conventions are valid \ for this function; `{}` was specified", - Rust.name(), - RustCall.name(), + Abi::Rust.name(), + Abi::RustCall.name(), f.abi.name())); } } else { @@ -2789,7 +2789,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { hir::ItemFn(_, _, _, abi, _, _) => { let sym = sym(); - let llfn = if abi == Rust { + let llfn = if abi == Abi::Rust { register_fn(ccx, i.span, sym, i.id, ty) } else { foreign::register_rust_fn_with_foreign_abi(ccx, i.span, sym, i.id) @@ -2912,7 +2912,7 @@ fn register_method(ccx: &CrateContext, let sym = exported_name(ccx, id, mty, &attrs); if let ty::TyBareFn(_, ref f) = mty.sty { - let llfn = if f.abi == Rust || f.abi == RustCall { + let llfn = if f.abi == Abi::Rust || f.abi == Abi::RustCall { register_fn(ccx, span, sym, id, mty) } else { foreign::register_rust_fn_with_foreign_abi(ccx, span, sym, id) diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index 2651b3576feb2..29821384ae936 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -55,7 +55,7 @@ use middle::ty::{self, Ty, TypeFoldable}; use middle::ty::MethodCall; use rustc_front::hir; -use syntax::abi as synabi; +use syntax::abi::Abi; use syntax::ast; use syntax::errors; use syntax::ptr::P; @@ -157,8 +157,8 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &hir::Expr) } } Def::Fn(did) if match expr_ty.sty { - ty::TyBareFn(_, ref f) => f.abi == synabi::RustIntrinsic || - f.abi == synabi::PlatformIntrinsic, + ty::TyBareFn(_, ref f) => f.abi == Abi::RustIntrinsic || + f.abi == Abi::PlatformIntrinsic, _ => false } => { let substs = common::node_id_substs(bcx.ccx(), @@ -294,7 +294,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>( match bare_fn_ty.sty { ty::TyBareFn(opt_def_id, &ty::BareFnTy { unsafety: hir::Unsafety::Normal, - abi: synabi::Rust, + abi: Abi::Rust, ref sig }) => { (opt_def_id, sig) } @@ -310,7 +310,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>( let tuple_fn_ty = tcx.mk_fn(opt_def_id, tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Normal, - abi: synabi::RustCall, + abi: Abi::RustCall, sig: ty::Binder(ty::FnSig { inputs: vec![bare_fn_ty_maybe_ref, tuple_input_ty], @@ -622,7 +622,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, (d.llfn, Some(d.llself)) } Intrinsic(node, substs) => { - assert!(abi == synabi::RustIntrinsic || abi == synabi::PlatformIntrinsic); + assert!(abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic); assert!(dest.is_some()); let call_info = match debug_loc { @@ -652,9 +652,9 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, // Intrinsics should not become actual functions. // We trans them in place in `trans_intrinsic_call` - assert!(abi != synabi::RustIntrinsic && abi != synabi::PlatformIntrinsic); + assert!(abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic); - let is_rust_fn = abi == synabi::Rust || abi == synabi::RustCall; + let is_rust_fn = abi == Abi::Rust || abi == Abi::RustCall; // Generate a location to store the result. If the user does // not care about the result, just make a stack slot. @@ -936,7 +936,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>, llargs: &mut Vec, arg_cleanup_scope: cleanup::ScopeId, ignore_self: bool, - abi: synabi::Abi) + abi: Abi) -> Block<'blk, 'tcx> { debug!("trans_args(abi={})", abi); @@ -953,7 +953,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>, // to cast her view of the arguments to the caller's view. match args { ArgExprs(arg_exprs) => { - if abi == synabi::RustCall { + if abi == Abi::RustCall { // This is only used for direct calls to the `call`, // `call_mut` or `call_once` functions. return trans_args_under_call_abi(cx, diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs index 5bdfc099f0880..9a44837bc5d2f 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -30,7 +30,7 @@ use trans::Disr; use middle::ty; use session::config::FullDebugInfo; -use syntax::abi::RustCall; +use syntax::abi::Abi::RustCall; use syntax::ast; use syntax::attr::{ThinAttributes, ThinAttributesExt}; diff --git a/src/librustc_trans/trans/collector.rs b/src/librustc_trans/trans/collector.rs index 6ec7378859848..57fc338c878c6 100644 --- a/src/librustc_trans/trans/collector.rs +++ b/src/librustc_trans/trans/collector.rs @@ -1294,7 +1294,7 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, output.push_str("unsafe "); } - if abi != ::syntax::abi::Rust { + if abi != ::syntax::abi::Abi::Rust { output.push_str("extern \""); output.push_str(abi.name()); output.push_str("\" "); diff --git a/src/librustc_trans/trans/debuginfo/mod.rs b/src/librustc_trans/trans/debuginfo/mod.rs index f0b48ddd5c388..702721157be51 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/trans/debuginfo/mod.rs @@ -48,7 +48,8 @@ use std::ptr; use std::rc::Rc; use syntax::codemap::{Span, Pos}; -use syntax::{abi, ast, codemap}; +use syntax::{ast, codemap}; +use syntax::abi::Abi; use syntax::attr::IntType; use syntax::parse::token::{self, special_idents}; @@ -455,7 +456,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty::FnDiverging => diverging_type_metadata(cx) }); - let inputs = &if abi == abi::RustCall { + let inputs = &if abi == Abi::RustCall { type_of::untuple_arguments(cx, &sig.inputs) } else { sig.inputs diff --git a/src/librustc_trans/trans/debuginfo/type_names.rs b/src/librustc_trans/trans/debuginfo/type_names.rs index 9f20131f9aad1..f243b1e3bfaa4 100644 --- a/src/librustc_trans/trans/debuginfo/type_names.rs +++ b/src/librustc_trans/trans/debuginfo/type_names.rs @@ -106,7 +106,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, output.push_str("unsafe "); } - if abi != ::syntax::abi::Rust { + if abi != ::syntax::abi::Abi::Rust { output.push_str("extern \""); output.push_str(abi.name()); output.push_str("\" "); diff --git a/src/librustc_trans/trans/declare.rs b/src/librustc_trans/trans/declare.rs index b9e74beaf55ae..75b60be02f778 100644 --- a/src/librustc_trans/trans/declare.rs +++ b/src/librustc_trans/trans/declare.rs @@ -22,7 +22,7 @@ use llvm::{self, ValueRef}; use middle::ty; use middle::infer; -use syntax::abi; +use syntax::abi::Abi; use trans::attributes; use trans::base; use trans::context::CrateContext; @@ -116,7 +116,7 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str, let llenvironment_type = type_of::type_of_explicit_arg(ccx, self_type); debug!("declare_rust_fn function_type={:?} self_type={:?}", function_type, self_type); - (&function_type.sig, abi::RustCall, Some(llenvironment_type)) + (&function_type.sig, Abi::RustCall, Some(llenvironment_type)) } _ => ccx.sess().bug("expected closure or fn") }; diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index 3689f30e38f23..5a909888bd86d 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -34,9 +34,7 @@ use middle::subst::Substs; use std::cmp; use std::iter::once; use libc::c_uint; -use syntax::abi::{Cdecl, Aapcs, C, Win64, Abi}; -use syntax::abi::{PlatformIntrinsic, RustIntrinsic, Rust, RustCall, Stdcall}; -use syntax::abi::{Fastcall, Vectorcall, System}; +use syntax::abi::Abi; use syntax::attr; use syntax::codemap::Span; use syntax::parse::token::{InternedString, special_idents}; @@ -80,6 +78,7 @@ struct LlvmSignature { pub fn llvm_calling_convention(ccx: &CrateContext, abi: Abi) -> CallConv { + use syntax::abi::Abi::*; match ccx.sess().target.target.adjust_abi(abi) { RustIntrinsic => { // Intrinsics are emitted at the call site @@ -488,7 +487,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &hir::ForeignMod) { if let hir::ForeignItemFn(ref decl, _) = foreign_item.node { match foreign_mod.abi { - Rust | RustIntrinsic | PlatformIntrinsic => {} + Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic => {} abi => { let ty = ccx.tcx().node_id_to_type(foreign_item.id); match ty.sty { @@ -626,7 +625,9 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // normal Rust function. This will be the type of the wrappee fn. match t.sty { ty::TyBareFn(_, ref f) => { - assert!(f.abi != Rust && f.abi != RustIntrinsic && f.abi != PlatformIntrinsic); + assert!(f.abi != Abi::Rust); + assert!(f.abi != Abi::RustIntrinsic); + assert!(f.abi != Abi::PlatformIntrinsic); } _ => { ccx.sess().bug(&format!("build_rust_fn: extern fn {} has ty {:?}, \ diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index c6fb119ff0ba4..3e5cd7389c4fa 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -40,7 +40,7 @@ use trans::Disr; use middle::subst::Substs; use rustc::dep_graph::DepNode; use rustc_front::hir; -use syntax::abi::{self, RustIntrinsic}; +use syntax::abi::Abi; use syntax::ast; use syntax::ptr::P; use syntax::parse::token; @@ -365,7 +365,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, &mut llargs, cleanup::CustomScope(cleanup_scope), false, - RustIntrinsic); + Abi::RustIntrinsic); fcx.scopes.borrow_mut().last_mut().unwrap().drop_non_lifetime_clean(); @@ -1261,7 +1261,7 @@ fn get_rust_try_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>, let i8p = tcx.mk_mut_ptr(tcx.types.i8); let fn_ty = tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Unsafe, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: vec![i8p], output: ty::FnOutput::FnConverging(tcx.mk_nil()), @@ -1272,7 +1272,7 @@ fn get_rust_try_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>, let output = ty::FnOutput::FnConverging(tcx.types.i32); let try_fn_ty = tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Unsafe, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: vec![fn_ty, i8p, i8p], output: output, @@ -1350,7 +1350,7 @@ fn generate_filter_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>, // just do the same. let filter_fn_ty = tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Unsafe, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: vec![], output: output, @@ -1370,7 +1370,7 @@ fn generate_filter_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>, // those along. let filter_fn_ty = tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Unsafe, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: vec![i8p, i8p], output: output, diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index 62e69cbb85e6f..cda62c238476e 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -29,7 +29,7 @@ use rustc::front::map as hir_map; use rustc_front::hir; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast; use syntax::attr; use syntax::errors; @@ -96,7 +96,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, if let hir_map::NodeForeignItem(_) = map_node { let abi = ccx.tcx().map.get_foreign_abi(fn_node_id); - if abi != abi::RustIntrinsic && abi != abi::PlatformIntrinsic { + if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic { // Foreign externs don't have to be monomorphized. return (get_item_val(ccx, fn_node_id), mono_ty, true); } @@ -139,8 +139,8 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // This shouldn't need to option dance. let mut hash_id = Some(hash_id); - let mut mk_lldecl = |abi: abi::Abi| { - let lldecl = if abi != abi::Rust { + let mut mk_lldecl = |abi: Abi| { + let lldecl = if abi != Abi::Rust { foreign::decl_rust_fn_with_foreign_abi(ccx, mono_ty, &s) } else { // FIXME(nagisa): perhaps needs a more fine grained selection? See @@ -181,7 +181,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let d = mk_lldecl(abi); let needs_body = setup_lldecl(d, &i.attrs); if needs_body { - if abi != abi::Rust { + if abi != Abi::Rust { foreign::trans_rust_fn_with_foreign_abi( ccx, &**decl, &**body, &[], d, psubsts, fn_node_id, Some(&hash[..])); @@ -206,7 +206,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, hir_map::NodeVariant(v) => { let variant = inlined_variant_def(ccx, fn_node_id); assert_eq!(v.node.name, variant.name); - let d = mk_lldecl(abi::Rust); + let d = mk_lldecl(Abi::Rust); attributes::inline(d, attributes::InlineAttr::Hint); trans_enum_variant(ccx, fn_node_id, Disr::from(variant.disr_val), psubsts, d); d @@ -214,7 +214,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, hir_map::NodeImplItem(impl_item) => { match impl_item.node { hir::ImplItemKind::Method(ref sig, ref body) => { - let d = mk_lldecl(abi::Rust); + let d = mk_lldecl(Abi::Rust); let needs_body = setup_lldecl(d, &impl_item.attrs); if needs_body { trans_fn(ccx, @@ -236,7 +236,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, hir_map::NodeTraitItem(trait_item) => { match trait_item.node { hir::MethodTraitItem(ref sig, Some(ref body)) => { - let d = mk_lldecl(abi::Rust); + let d = mk_lldecl(Abi::Rust); let needs_body = setup_lldecl(d, &trait_item.attrs); if needs_body { trans_fn(ccx, @@ -256,7 +256,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } } hir_map::NodeStructCtor(struct_def) => { - let d = mk_lldecl(abi::Rust); + let d = mk_lldecl(Abi::Rust); attributes::inline(d, attributes::InlineAttr::Hint); if struct_def.is_struct() { panic!("ast-mapped struct didn't have a ctor id") diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index 8696bdd60e291..d94000736855c 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -21,7 +21,7 @@ use middle::ty::{self, Ty, TypeFoldable}; use trans::type_::Type; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast; // LLVM doesn't like objects that are too big. Issue #17913 @@ -91,7 +91,7 @@ pub fn untuple_arguments<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, llenvironment_type: Option, sig: &ty::FnSig<'tcx>, - abi: abi::Abi) + abi: Abi) -> Type { debug!("type_of_rust_fn(sig={:?},abi={:?})", @@ -104,7 +104,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, // First, munge the inputs, if this has the `rust-call` ABI. let inputs_temp; - let inputs = if abi == abi::RustCall { + let inputs = if abi == Abi::RustCall { inputs_temp = untuple_arguments(cx, &sig.inputs); &inputs_temp } else { @@ -156,7 +156,7 @@ pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fty: Ty<'tcx>) ty::TyBareFn(_, ref f) => { // FIXME(#19925) once fn item types are // zero-sized, we'll need to do something here - if f.abi == abi::Rust || f.abi == abi::RustCall { + if f.abi == Abi::Rust || f.abi == Abi::RustCall { let sig = cx.tcx().erase_late_bound_regions(&f.sig); let sig = infer::normalize_associated_type(cx.tcx(), &sig); type_of_rust_fn(cx, None, &sig, f.abi) diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 3b7cb2bd4b466..7fd35cf159ff9 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -16,7 +16,7 @@ use astconv; use middle::subst; use middle::ty::{self, ToPolyTraitRef, Ty}; use std::cmp; -use syntax::abi; +use syntax::abi::Abi; use rustc_front::hir; pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, @@ -54,7 +54,7 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, let mut fn_ty = astconv::ty_of_closure(fcx, hir::Unsafety::Normal, decl, - abi::RustCall, + Abi::RustCall, expected_sig); // Create type variables (for now) to represent the transformed diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 61d468c59ce83..248a2341c2bda 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -20,7 +20,7 @@ use middle::ty::fold::TypeFolder; use {CrateCtxt, require_same_types}; use std::collections::{HashMap}; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast; use syntax::attr::AttrMetaMethods; use syntax::codemap::Span; @@ -30,7 +30,7 @@ use rustc_front::hir; fn equate_intrinsic_type<'a, 'tcx>(tcx: &ty::ctxt<'tcx>, it: &hir::ForeignItem, n_tps: usize, - abi: abi::Abi, + abi: Abi, inputs: Vec>, output: ty::FnOutput<'tcx>) { let fty = tcx.mk_fn(None, tcx.mk_bare_fn(ty::BareFnTy { @@ -285,7 +285,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) { let mut_u8 = tcx.mk_mut_ptr(tcx.types.u8); let fn_ty = ty::BareFnTy { unsafety: hir::Unsafety::Normal, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(FnSig { inputs: vec![mut_u8], output: ty::FnOutput::FnConverging(tcx.mk_nil()), @@ -308,7 +308,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) { tcx, it, n_tps, - abi::RustIntrinsic, + Abi::RustIntrinsic, inputs, output ) @@ -398,7 +398,7 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt, tcx, it, n_tps, - abi::PlatformIntrinsic, + Abi::PlatformIntrinsic, inputs, ty::FnConverging(output) ) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9a0d6bc16411a..e27bec922945f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -115,7 +115,7 @@ use util::nodemap::{DefIdMap, FnvHashMap, NodeMap}; use std::cell::{Cell, Ref, RefCell}; use std::collections::{HashSet}; use std::mem::replace; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast; use syntax::attr; use syntax::attr::AttrMetaMethods; @@ -691,11 +691,11 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { check_bounds_are_used(ccx, &generics.ty_params, pty_ty); } hir::ItemForeignMod(ref m) => { - if m.abi == abi::RustIntrinsic { + if m.abi == Abi::RustIntrinsic { for item in &m.items { intrinsic::check_intrinsic_type(ccx, item); } - } else if m.abi == abi::PlatformIntrinsic { + } else if m.abi == Abi::PlatformIntrinsic { for item in &m.items { intrinsic::check_platform_intrinsic_type(ccx, item); } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 083eeff9f90c1..0c8ad5abe6f8e 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -111,7 +111,8 @@ use util::common::time; use rustc_front::hir; use syntax::codemap::Span; -use syntax::{ast, abi}; +use syntax::ast; +use syntax::abi::Abi; use std::cell::RefCell; @@ -175,9 +176,9 @@ fn lookup_full_def(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) -> Def { fn require_c_abi_if_variadic(tcx: &ty::ctxt, decl: &hir::FnDecl, - abi: abi::Abi, + abi: Abi, span: Span) { - if decl.variadic && abi != abi::C { + if decl.variadic && abi != Abi::C { span_err!(tcx.sess, span, E0045, "variadic function must have C calling convention"); } @@ -238,7 +239,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt, let main_def_id = tcx.map.local_def_id(main_id); let se_ty = tcx.mk_fn(Some(main_def_id), tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Normal, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: Vec::new(), output: ty::FnConverging(tcx.mk_nil()), @@ -285,7 +286,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt, let se_ty = tcx.mk_fn(Some(ccx.tcx.map.local_def_id(start_id)), tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Normal, - abi: abi::Rust, + abi: Abi::Rust, sig: ty::Binder(ty::FnSig { inputs: vec!( tcx.types.isize, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 03e2a7139b278..00b87ad69a8db 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -25,7 +25,7 @@ pub use self::SelfTy::*; pub use self::FunctionRetTy::*; use syntax; -use syntax::abi; +use syntax::abi::Abi; use syntax::ast; use syntax::attr; use syntax::attr::{AttributeMethods, AttrMetaMethods}; @@ -985,7 +985,7 @@ pub struct Method { pub unsafety: hir::Unsafety, pub constness: hir::Constness, pub decl: FnDecl, - pub abi: abi::Abi + pub abi: Abi, } impl Clean for hir::MethodSig { @@ -1020,7 +1020,7 @@ pub struct TyMethod { pub decl: FnDecl, pub generics: Generics, pub self_: SelfTy, - pub abi: abi::Abi + pub abi: Abi, } impl Clean for hir::MethodSig { @@ -1074,7 +1074,7 @@ pub struct Function { pub generics: Generics, pub unsafety: hir::Unsafety, pub constness: hir::Constness, - pub abi: abi::Abi, + pub abi: Abi, } impl Clean for doctree::Function { @@ -2478,7 +2478,7 @@ impl Clean for hir::ForeignItem { decl: decl.clean(cx), generics: generics.clean(cx), unsafety: hir::Unsafety::Unsafe, - abi: abi::Rust, + abi: Abi::Rust, constness: hir::Constness::NotConst, }) } diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 0df143c45ae7d..c959e2108f5a7 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -8,27 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub use self::Os::*; -pub use self::Abi::*; -pub use self::Architecture::*; -pub use self::AbiArchitecture::*; - use std::fmt; #[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[allow(non_camel_case_types)] pub enum Os { - OsWindows, - OsMacos, - OsLinux, - OsAndroid, - OsFreebsd, - OsiOS, - OsDragonfly, - OsBitrig, - OsNetbsd, - OsOpenbsd, - OsNaCl, - OsSolaris, + Windows, + Macos, + Linux, + Android, + Freebsd, + iOS, + Dragonfly, + Bitrig, + Netbsd, + Openbsd, + NaCl, + Solaris, } #[derive(PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Clone, Copy, Debug)] @@ -74,9 +70,9 @@ pub struct AbiData { #[derive(Copy, Clone)] pub enum AbiArchitecture { /// Not a real ABI (e.g., intrinsic) - RustArch, + Rust, /// An ABI that specifies cross-platform defaults (e.g., "C") - AllArch, + All, /// Multiple architectures (bitset) Archs(u32) } @@ -84,23 +80,23 @@ pub enum AbiArchitecture { #[allow(non_upper_case_globals)] const AbiDatas: &'static [AbiData] = &[ // Platform-specific ABIs - AbiData {abi: Cdecl, name: "cdecl" }, - AbiData {abi: Stdcall, name: "stdcall" }, - AbiData {abi: Fastcall, name: "fastcall" }, - AbiData {abi: Vectorcall, name: "vectorcall"}, - AbiData {abi: Aapcs, name: "aapcs" }, - AbiData {abi: Win64, name: "win64" }, + AbiData {abi: Abi::Cdecl, name: "cdecl" }, + AbiData {abi: Abi::Stdcall, name: "stdcall" }, + AbiData {abi: Abi::Fastcall, name: "fastcall" }, + AbiData {abi: Abi::Vectorcall, name: "vectorcall"}, + AbiData {abi: Abi::Aapcs, name: "aapcs" }, + AbiData {abi: Abi::Win64, name: "win64" }, // Cross-platform ABIs // // NB: Do not adjust this ordering without // adjusting the indices below. - AbiData {abi: Rust, name: "Rust" }, - AbiData {abi: C, name: "C" }, - AbiData {abi: System, name: "system" }, - AbiData {abi: RustIntrinsic, name: "rust-intrinsic" }, - AbiData {abi: RustCall, name: "rust-call" }, - AbiData {abi: PlatformIntrinsic, name: "platform-intrinsic" } + AbiData {abi: Abi::Rust, name: "Rust" }, + AbiData {abi: Abi::C, name: "C" }, + AbiData {abi: Abi::System, name: "system" }, + AbiData {abi: Abi::RustIntrinsic, name: "rust-intrinsic" }, + AbiData {abi: Abi::RustCall, name: "rust-call" }, + AbiData {abi: Abi::PlatformIntrinsic, name: "platform-intrinsic" } ]; /// Returns the ABI with the given name (if any). @@ -137,18 +133,18 @@ impl fmt::Display for Abi { impl fmt::Display for Os { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - OsLinux => "linux".fmt(f), - OsWindows => "windows".fmt(f), - OsMacos => "macos".fmt(f), - OsiOS => "ios".fmt(f), - OsAndroid => "android".fmt(f), - OsFreebsd => "freebsd".fmt(f), - OsDragonfly => "dragonfly".fmt(f), - OsBitrig => "bitrig".fmt(f), - OsNetbsd => "netbsd".fmt(f), - OsOpenbsd => "openbsd".fmt(f), - OsNaCl => "nacl".fmt(f), - OsSolaris => "solaris".fmt(f), + Os::Linux => "linux".fmt(f), + Os::Windows => "windows".fmt(f), + Os::Macos => "macos".fmt(f), + Os::iOS => "ios".fmt(f), + Os::Android => "android".fmt(f), + Os::Freebsd => "freebsd".fmt(f), + Os::Dragonfly => "dragonfly".fmt(f), + Os::Bitrig => "bitrig".fmt(f), + Os::Netbsd => "netbsd".fmt(f), + Os::Openbsd => "openbsd".fmt(f), + Os::NaCl => "nacl".fmt(f), + Os::Solaris => "solaris".fmt(f), } } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index a74c2340cecb8..29548d25e7770 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use abi; +use abi::Abi; use ast::{Ident, Generics, Expr}; use ast; use attr; @@ -972,7 +972,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ast::ItemFn(self.fn_decl(inputs, output), ast::Unsafety::Normal, ast::Constness::NotConst, - abi::Rust, + Abi::Rust, generics, body)) } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 32372ccc13b47..c762c73fb99ce 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -684,7 +684,7 @@ mod tests { use std::rc::Rc; use codemap::{Span, BytePos, Pos, Spanned, NO_EXPANSION}; use ast::{self, TokenTree}; - use abi; + use abi::Abi; use attr::{first_attr_value_str_by_name, AttrMetaMethods}; use parse; use parse::parser::Parser; @@ -955,7 +955,7 @@ mod tests { }), ast::Unsafety::Normal, ast::Constness::NotConst, - abi::Rust, + Abi::Rust, ast::Generics{ // no idea on either of these: lifetimes: Vec::new(), ty_params: P::empty(), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bff5071b8ec10..372b7ab3de76a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -10,7 +10,7 @@ pub use self::PathParsingMode::*; -use abi; +use abi::{self, Abi}; use ast::BareFnTy; use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::{Public, Unsafety}; @@ -1118,9 +1118,9 @@ impl<'a> Parser<'a> { let unsafety = try!(self.parse_unsafety()); let abi = if self.eat_keyword(keywords::Extern) { - try!(self.parse_opt_abi()).unwrap_or(abi::C) + try!(self.parse_opt_abi()).unwrap_or(Abi::C) } else { - abi::Rust + Abi::Rust }; try!(self.expect_keyword(keywords::Fn)); @@ -4638,12 +4638,12 @@ impl<'a> Parser<'a> { let is_const_fn = self.eat_keyword(keywords::Const); let unsafety = try!(self.parse_unsafety()); let (constness, unsafety, abi) = if is_const_fn { - (Constness::Const, unsafety, abi::Rust) + (Constness::Const, unsafety, Abi::Rust) } else { let abi = if self.eat_keyword(keywords::Extern) { - try!(self.parse_opt_abi()).unwrap_or(abi::C) + try!(self.parse_opt_abi()).unwrap_or(Abi::C) } else { - abi::Rust + Abi::Rust }; (Constness::NotConst, unsafety, abi) }; @@ -5341,7 +5341,7 @@ impl<'a> Parser<'a> { -> PResult<'a, P> { try!(self.expect(&token::OpenDelim(token::Brace))); - let abi = opt_abi.unwrap_or(abi::C); + let abi = opt_abi.unwrap_or(Abi::C); attrs.extend(try!(self.parse_inner_attributes())); @@ -5513,7 +5513,7 @@ impl<'a> Parser<'a> { if self.eat_keyword(keywords::Fn) { // EXTERN FUNCTION ITEM - let abi = opt_abi.unwrap_or(abi::C); + let abi = opt_abi.unwrap_or(Abi::C); let (ident, item_, extra_attrs) = try!(self.parse_item_fn(Unsafety::Normal, Constness::NotConst, abi)); let last_span = self.last_span; @@ -5556,7 +5556,7 @@ impl<'a> Parser<'a> { }; self.bump(); let (ident, item_, extra_attrs) = - try!(self.parse_item_fn(unsafety, Constness::Const, abi::Rust)); + try!(self.parse_item_fn(unsafety, Constness::Const, Abi::Rust)); let last_span = self.last_span; let item = self.mk_item(lo, last_span.hi, @@ -5621,7 +5621,7 @@ impl<'a> Parser<'a> { // FUNCTION ITEM self.bump(); let (ident, item_, extra_attrs) = - try!(self.parse_item_fn(Unsafety::Normal, Constness::NotConst, abi::Rust)); + try!(self.parse_item_fn(Unsafety::Normal, Constness::NotConst, Abi::Rust)); let last_span = self.last_span; let item = self.mk_item(lo, last_span.hi, @@ -5636,9 +5636,9 @@ impl<'a> Parser<'a> { // UNSAFE FUNCTION ITEM self.bump(); let abi = if self.eat_keyword(keywords::Extern) { - try!(self.parse_opt_abi()).unwrap_or(abi::C) + try!(self.parse_opt_abi()).unwrap_or(Abi::C) } else { - abi::Rust + Abi::Rust }; try!(self.expect_keyword(keywords::Fn)); let (ident, item_, extra_attrs) = diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 759b16c5738f3..df222f0e97486 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -10,7 +10,7 @@ pub use self::AnnNode::*; -use abi; +use abi::{self, Abi}; use ast::{self, TokenTree}; use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::Attribute; @@ -387,7 +387,7 @@ pub fn fun_to_string(decl: &ast::FnDecl, -> String { to_string(|s| { try!(s.head("")); - try!(s.print_fn(decl, unsafety, constness, abi::Rust, Some(name), + try!(s.print_fn(decl, unsafety, constness, Abi::Rust, Some(name), generics, opt_explicit_self, ast::Inherited)); try!(s.end()); // Close the head box s.end() // Close the outer box @@ -1058,7 +1058,7 @@ impl<'a> State<'a> { try!(self.head("")); try!(self.print_fn(decl, ast::Unsafety::Normal, ast::Constness::NotConst, - abi::Rust, Some(item.ident), + Abi::Rust, Some(item.ident), generics, None, item.vis)); try!(self.end()); // end head-ibox try!(word(&mut self.s, ";")); @@ -3086,10 +3086,10 @@ impl<'a> State<'a> { } pub fn print_opt_abi_and_extern_if_nondefault(&mut self, - opt_abi: Option) + opt_abi: Option) -> io::Result<()> { match opt_abi { - Some(abi::Rust) => Ok(()), + Some(Abi::Rust) => Ok(()), Some(abi) => { try!(self.word_nbsp("extern")); self.word_nbsp(&abi.to_string()) @@ -3099,7 +3099,7 @@ impl<'a> State<'a> { } pub fn print_extern_opt_abi(&mut self, - opt_abi: Option) -> io::Result<()> { + opt_abi: Option) -> io::Result<()> { match opt_abi { Some(abi) => { try!(self.word_nbsp("extern")); @@ -3112,7 +3112,7 @@ impl<'a> State<'a> { pub fn print_fn_header_info(&mut self, unsafety: ast::Unsafety, constness: ast::Constness, - abi: abi::Abi, + abi: Abi, vis: ast::Visibility) -> io::Result<()> { try!(word(&mut self.s, &visibility_qualified(vis, ""))); @@ -3123,7 +3123,7 @@ impl<'a> State<'a> { try!(self.print_unsafety(unsafety)); - if abi != abi::Rust { + if abi != Abi::Rust { try!(self.word_nbsp("extern")); try!(self.word_nbsp(&abi.to_string())); } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 9a6d1f8fdab4d..aaff1df3f24f2 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -499,7 +499,7 @@ fn mk_main(cx: &mut TestCtxt) -> P { let main = ast::ItemFn(ecx.fn_decl(vec![], main_ret_ty), ast::Unsafety::Normal, ast::Constness::NotConst, - ::abi::Rust, ast::Generics::default(), main_body); + ::abi::Abi::Rust, ast::Generics::default(), main_body); let main = P(ast::Item { ident: token::str_to_ident("main"), attrs: vec![main_attr], diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 3af701739b431..64108c1e0a128 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -193,7 +193,6 @@ use std::collections::HashSet; use std::vec; use syntax::abi::Abi; -use syntax::abi; use syntax::ast; use syntax::ast::{EnumDef, Expr, Ident, Generics, VariantData}; use syntax::ast_util; @@ -682,7 +681,7 @@ impl<'a> TraitDef<'a> { self, type_ident, generics, - abi::Rust, + Abi::Rust, explicit_self, tys, body) @@ -731,7 +730,7 @@ impl<'a> TraitDef<'a> { self, type_ident, generics, - abi::Rust, + Abi::Rust, explicit_self, tys, body)