]> git.lizzy.rs Git - rust.git/commitdiff
Use ast attributes every where (remove HIR attributes).
authorNick Cameron <ncameron@mozilla.com>
Mon, 14 Sep 2015 09:58:20 +0000 (21:58 +1200)
committerNick Cameron <ncameron@mozilla.com>
Tue, 15 Sep 2015 22:57:06 +0000 (10:57 +1200)
This could be a [breaking-change] if your lint or syntax extension (is that even possible?) uses HIR attributes or literals.

83 files changed:
src/librustc/front/map/mod.rs
src/librustc/lint/context.rs
src/librustc/lint/mod.rs
src/librustc/metadata/creader.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/cstore.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/macro_import.rs
src/librustc/metadata/tyencode.rs
src/librustc/middle/check_match.rs
src/librustc/middle/const_eval.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/dead.rs
src/librustc/middle/entry.rs
src/librustc/middle/infer/combine.rs
src/librustc/middle/infer/unify_key.rs
src/librustc/middle/lang_items.rs
src/librustc/middle/reachable.rs
src/librustc/middle/stability.rs
src/librustc/middle/traits/error_reporting.rs
src/librustc/middle/ty/cast.rs
src/librustc/middle/ty/contents.rs
src/librustc/middle/ty/context.rs
src/librustc/middle/ty/error.rs
src/librustc/middle/ty/fast_reject.rs
src/librustc/middle/ty/mod.rs
src/librustc/middle/ty/sty.rs
src/librustc/middle/ty/util.rs
src/librustc/middle/weak_lang_items.rs
src/librustc/plugin/build.rs
src/librustc/session/config.rs
src/librustc/util/ppaux.rs
src/librustc_back/svh.rs
src/librustc_borrowck/borrowck/fragments.rs
src/librustc_driver/pretty.rs
src/librustc_front/attr.rs
src/librustc_front/fold.rs
src/librustc_front/hir.rs
src/librustc_front/lib.rs
src/librustc_front/lowering.rs
src/librustc_front/print/pp.rs [deleted file]
src/librustc_front/print/pprust.rs
src/librustc_front/util.rs
src/librustc_front/visit.rs
src/librustc_lint/builtin.rs
src/librustc_mir/dump.rs
src/librustc_mir/tcx/expr.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/lib.rs
src/librustc_trans/back/link.rs
src/librustc_trans/trans/_match.rs
src/librustc_trans/trans/adt.rs
src/librustc_trans/trans/attributes.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/debuginfo/gdb.rs
src/librustc_trans/trans/debuginfo/metadata.rs
src/librustc_trans/trans/debuginfo/mod.rs
src/librustc_trans/trans/debuginfo/type_names.rs
src/librustc_trans/trans/debuginfo/utils.rs
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/foreign.rs
src/librustc_trans/trans/meth.rs
src/librustc_trans/trans/monomorphize.rs
src/librustc_trans/trans/tvec.rs
src/librustc_trans/trans/type_.rs
src/librustc_trans/trans/type_of.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/cast.rs
src/librustc_typeck/check/intrinsic.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/coherence/orphan.rs
src/librustc_typeck/collect.rs
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/doctree.rs
src/librustdoc/html/render.rs
src/librustdoc/test.rs
src/librustdoc/visit_ast.rs
src/libsyntax/print/pprust.rs
src/test/auxiliary/lint_for_crate.rs

index 764f54ce0f0c1599be263eeae8fa54d33411b116..03a52e3cfe46968a45ffafaf733ceb71c9260b35 100644 (file)
@@ -17,7 +17,7 @@
 use middle::def_id::DefId;
 
 use syntax::abi;
-use syntax::ast::{Name, NodeId, Ident, CRATE_NODE_ID, DUMMY_NODE_ID};
+use syntax::ast::{self, Name, NodeId, Ident, CRATE_NODE_ID, DUMMY_NODE_ID};
 use syntax::codemap::{Span, Spanned};
 use syntax::parse::token;
 
@@ -538,7 +538,7 @@ fn with_path_next<T, F>(&self, id: NodeId, next: LinkedPath, f: F) -> T where
 
     /// Given a node ID, get a list of of attributes associated with the AST
     /// corresponding to the Node ID
-    pub fn attrs(&self, id: NodeId) -> &'ast [Attribute] {
+    pub fn attrs(&self, id: NodeId) -> &'ast [ast::Attribute] {
         let attrs = match self.find(id) {
             Some(NodeItem(i)) => Some(&i.attrs[..]),
             Some(NodeForeignItem(fi)) => Some(&fi.attrs[..]),
index 67be93cc2bdc6425ea6b62e704702a17b09db8d8..afc33c0a12c7d10514f3e706b03688b51552e6e1 100644 (file)
 use std::cmp;
 use std::mem;
 use syntax::ast_util::IdVisitingOperation;
-use rustc_front::attr::{self, AttrMetaMethods};
-use rustc_front::util;
+use syntax::attr::{self, AttrMetaMethods};
 use syntax::codemap::Span;
 use syntax::parse::token::InternedString;
 use syntax::ast;
 use rustc_front::hir;
 use rustc_front::visit::{self, Visitor, FnKind};
+use rustc_front::util;
 use syntax::visit::Visitor as SyntaxVisitor;
 use syntax::diagnostic;
 
@@ -286,7 +286,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
 /// Parse the lint attributes into a vector, with `Err`s for malformed lint
 /// attributes. Writing this as an iterator is an enormous mess.
 // See also the hir version just below.
-pub fn gather_attrs(attrs: &[hir::Attribute])
+pub fn gather_attrs(attrs: &[ast::Attribute])
                     -> Vec<Result<(InternedString, Level, Span), Span>> {
     let mut out = vec!();
     for attr in attrs {
@@ -299,39 +299,7 @@ pub fn gather_attrs(attrs: &[hir::Attribute])
 
         let meta = &attr.node.value;
         let metas = match meta.node {
-            hir::MetaList(_, ref metas) => metas,
-            _ => {
-                out.push(Err(meta.span));
-                continue;
-            }
-        };
-
-        for meta in metas {
-            out.push(match meta.node {
-                hir::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
-                _ => Err(meta.span),
-            });
-        }
-    }
-    out
-}
-// Copy-pasted from the above function :-(
-pub fn gather_attrs_from_hir(attrs: &[::rustc_front::hir::Attribute])
-                             -> Vec<Result<(InternedString, Level, Span), Span>> {
-    use ::rustc_front::attr::AttrMetaMethods;
-
-    let mut out = vec!();
-    for attr in attrs {
-        let level = match Level::from_str(&attr.name()) {
-            None => continue,
-            Some(lvl) => lvl,
-        };
-
-        ::rustc_front::attr::mark_used(attr);
-
-        let meta = &attr.node.value;
-        let metas = match meta.node {
-            ::rustc_front::hir::MetaList(_, ref metas) => metas,
+            ast::MetaList(_, ref metas) => metas,
             _ => {
                 out.push(Err(meta.span));
                 continue;
@@ -340,9 +308,7 @@ pub fn gather_attrs_from_hir(attrs: &[::rustc_front::hir::Attribute])
 
         for meta in metas {
             out.push(match meta.node {
-                ::rustc_front::hir::MetaWord(ref lint_name) => {
-                    Ok((lint_name.clone(), level, meta.span))
-                }
+                ast::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
                 _ => Err(meta.span),
             });
         }
@@ -454,7 +420,7 @@ pub fn span_lint(&self, lint: &'static Lint, span: Span, msg: &str) {
     /// current lint context, call the provided function, then reset the
     /// lints in effect to their previous state.
     fn with_lint_attrs<F>(&mut self,
-                          attrs: &[hir::Attribute],
+                          attrs: &[ast::Attribute],
                           f: F) where
         F: FnOnce(&mut Context),
     {
@@ -675,7 +641,7 @@ fn visit_path(&mut self, p: &hir::Path, id: ast::NodeId) {
         visit::walk_path(self, p);
     }
 
-    fn visit_attribute(&mut self, attr: &hir::Attribute) {
+    fn visit_attribute(&mut self, attr: &ast::Attribute) {
         run_lints!(self, check_attribute, attr);
     }
 }
index 2b3a6c6e287f9e0912b84a0304b284e19c76434a..11a1852ed2509c2f0a3f75efbab9d9b8c6154bc0 100644 (file)
@@ -39,7 +39,7 @@
 use rustc_front::hir;
 
 pub use lint::context::{Context, LintStore, raw_emit_lint, check_crate, gather_attrs,
-                        gather_attrs_from_hir, GatherNodeLevels};
+                        GatherNodeLevels};
 
 /// Specification of a single lint.
 #[derive(Copy, Clone, Debug)]
@@ -158,14 +158,14 @@ fn check_lifetime_def(&mut self, _: &Context, _: &hir::LifetimeDef) { }
     fn check_explicit_self(&mut self, _: &Context, _: &hir::ExplicitSelf) { }
     fn check_mac(&mut self, _: &Context, _: &ast::Mac) { }
     fn check_path(&mut self, _: &Context, _: &hir::Path, _: ast::NodeId) { }
-    fn check_attribute(&mut self, _: &Context, _: &hir::Attribute) { }
+    fn check_attribute(&mut self, _: &Context, _: &ast::Attribute) { }
 
     /// Called when entering a syntax node that can have lint attributes such
     /// as `#[allow(...)]`. Called with *all* the attributes of that node.
-    fn enter_lint_attrs(&mut self, _: &Context, _: &[hir::Attribute]) { }
+    fn enter_lint_attrs(&mut self, _: &Context, _: &[ast::Attribute]) { }
 
     /// Counterpart to `enter_lint_attrs`.
-    fn exit_lint_attrs(&mut self, _: &Context, _: &[hir::Attribute]) { }
+    fn exit_lint_attrs(&mut self, _: &Context, _: &[ast::Attribute]) { }
 }
 
 /// A lint pass boxed up as a trait object.
index 5ac84578369d2fc2736475c7506a2fb4797a441b..90b7b1c960b5b65d8ef7175fb4e89ab7dcac4f6d 100644 (file)
 use syntax::codemap::{self, Span, mk_sp, Pos};
 use syntax::parse;
 use syntax::attr;
+use syntax::attr::AttrMetaMethods;
 use syntax::parse::token::InternedString;
 use syntax::util::small_vector::SmallVector;
 use rustc_front::visit;
 use rustc_front::hir;
-use rustc_front::attr as attr_front;
-use rustc_front::attr::AttrMetaMethods;
-use rustc_front::lowering::unlower_attribute;
 use log;
 
 pub struct LocalCrateReader<'a, 'b:'a> {
@@ -79,10 +77,9 @@ fn dump_crates(cstore: &CStore) {
 fn should_link(i: &ast::Item) -> bool {
     !attr::contains_name(&i.attrs, "no_link")
 }
-
 // Dup for the hir
 fn should_link_hir(i: &hir::Item) -> bool {
-    !attr_front::contains_name(&i.attrs, "no_link")
+    !attr::contains_name(&i.attrs, "no_link")
 }
 
 struct CrateInfo {
@@ -329,7 +326,7 @@ fn is_staged_api(&self, data: &[u8]) -> bool {
         let attrs = decoder::get_crate_attributes(data);
         for attr in &attrs {
             if &attr.name()[..] == "staged_api" {
-                match attr.node.value.node { hir::MetaWord(_) => return true, _ => (/*pass*/) }
+                match attr.node.value.node { ast::MetaWord(_) => return true, _ => (/*pass*/) }
             }
         }
 
@@ -483,7 +480,7 @@ pub fn read_exported_macros(&mut self, item: &ast::Item) -> Vec<ast::MacroDef> {
                 p.abort_if_errors();
                 macros.push(ast::MacroDef {
                     ident: name.ident(),
-                    attrs: attrs.iter().map(|a| unlower_attribute(a)).collect(),
+                    attrs: attrs,
                     id: ast::DUMMY_NODE_ID,
                     span: span,
                     imported_from: Some(item.ident),
index e1cb9bd0e77cf60db4317ad998cae8d564355d64..88d73b3feb3908e1bf877175b9476a101770f076 100644 (file)
@@ -21,7 +21,7 @@
 
 use std::rc::Rc;
 use syntax::ast;
-use rustc_front::attr;
+use syntax::attr;
 use rustc_front::hir;
 
 #[derive(Copy, Clone)]
@@ -186,7 +186,7 @@ pub fn get_methods_if_impl(cstore: &cstore::CStore,
 
 pub fn get_item_attrs(cstore: &cstore::CStore,
                       def_id: DefId)
-                      -> Vec<hir::Attribute> {
+                      -> Vec<ast::Attribute> {
     let cdata = cstore.get_crate_data(def_id.krate);
     decoder::get_item_attrs(&*cdata, def_id.node)
 }
@@ -197,7 +197,7 @@ pub fn get_struct_field_names(cstore: &cstore::CStore, def: DefId) -> Vec<ast::N
 }
 
 pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: DefId) -> FnvHashMap<ast::NodeId,
-        Vec<hir::Attribute>> {
+        Vec<ast::Attribute>> {
     let cdata = cstore.get_crate_data(def.krate);
     decoder::get_struct_field_attrs(&*cdata)
 }
index 42f52b2d20b1b949151ad64c66778983b7a7efb1..5f60fa8ff40e3122577adf66ff406cd745e389a3 100644 (file)
@@ -27,7 +27,7 @@
 use std::path::PathBuf;
 use flate::Bytes;
 use syntax::ast;
-use rustc_front::attr;
+use syntax::attr;
 use syntax::codemap;
 use syntax::parse::token;
 use syntax::parse::token::IdentInterner;
index e2cf50cf30ad0b4a768c510eb25bf12a150f62c6..050e04bff8307113be98644b1c17fdc0486c9e68 100644 (file)
@@ -16,7 +16,6 @@
 use self::Family::*;
 
 use front::map as ast_map;
-use rustc_front::print::pprust;
 use rustc_front::hir;
 
 use back::svh::Svh;
 use rbml::reader;
 use rbml;
 use serialize::Decodable;
-use rustc_front::attr;
+use syntax::attr;
 use syntax::parse::token::{IdentInterner, special_idents};
 use syntax::parse::token;
 use syntax::ast;
 use syntax::abi;
 use syntax::codemap;
+use syntax::print::pprust;
 use syntax::ptr::P;
 
 
@@ -1041,7 +1041,7 @@ pub fn get_tuple_struct_definition_if_ctor(cdata: Cmd,
 
 pub fn get_item_attrs(cdata: Cmd,
                       orig_node_id: ast::NodeId)
-                      -> Vec<hir::Attribute> {
+                      -> Vec<ast::Attribute> {
     // The attributes for a tuple struct are attached to the definition, not the ctor;
     // we assume that someone passing in a tuple struct ctor is actually wanting to
     // look at the definition
@@ -1051,7 +1051,7 @@ pub fn get_item_attrs(cdata: Cmd,
     get_attributes(item)
 }
 
-pub fn get_struct_field_attrs(cdata: Cmd) -> FnvHashMap<ast::NodeId, Vec<hir::Attribute>> {
+pub fn get_struct_field_attrs(cdata: Cmd) -> FnvHashMap<ast::NodeId, Vec<ast::Attribute>> {
     let data = rbml::Doc::new(cdata.data());
     let fields = reader::get_doc(data, tag_struct_fields);
     reader::tagged_docs(fields, tag_struct_field).map(|field| {
@@ -1079,7 +1079,7 @@ pub fn get_struct_field_names(intr: &IdentInterner, cdata: Cmd, id: ast::NodeId)
     })).collect()
 }
 
-fn get_meta_items(md: rbml::Doc) -> Vec<P<hir::MetaItem>> {
+fn get_meta_items(md: rbml::Doc) -> Vec<P<ast::MetaItem>> {
     reader::tagged_docs(md, tag_meta_item_word).map(|meta_item_doc| {
         let nd = reader::get_doc(meta_item_doc, tag_meta_item_name);
         let n = token::intern_and_get_ident(nd.as_str_slice());
@@ -1100,7 +1100,7 @@ fn get_meta_items(md: rbml::Doc) -> Vec<P<hir::MetaItem>> {
     })).collect()
 }
 
-fn get_attributes(md: rbml::Doc) -> Vec<hir::Attribute> {
+fn get_attributes(md: rbml::Doc) -> Vec<ast::Attribute> {
     match reader::maybe_get_doc(md, tag_attributes) {
         Some(attrs_d) => {
             reader::tagged_docs(attrs_d, tag_attribute).map(|attr_doc| {
@@ -1113,9 +1113,9 @@ fn get_attributes(md: rbml::Doc) -> Vec<hir::Attribute> {
                 assert_eq!(meta_items.len(), 1);
                 let meta_item = meta_items.into_iter().nth(0).unwrap();
                 codemap::Spanned {
-                    node: hir::Attribute_ {
+                    node: ast::Attribute_ {
                         id: attr::mk_attr_id(),
-                        style: hir::AttrOuter,
+                        style: ast::AttrOuter,
                         value: meta_item,
                         is_sugared_doc: is_sugared_doc,
                     },
@@ -1139,7 +1139,7 @@ fn list_crate_attributes(md: rbml::Doc, hash: &Svh,
     write!(out, "\n\n")
 }
 
-pub fn get_crate_attributes(data: &[u8]) -> Vec<hir::Attribute> {
+pub fn get_crate_attributes(data: &[u8]) -> Vec<ast::Attribute> {
     get_attributes(rbml::Doc::new(data))
 }
 
@@ -1337,7 +1337,7 @@ pub fn get_plugin_registrar_fn(data: &[u8]) -> Option<ast::NodeId> {
 }
 
 pub fn each_exported_macro<F>(data: &[u8], intr: &IdentInterner, mut f: F) where
-    F: FnMut(ast::Name, Vec<hir::Attribute>, String) -> bool,
+    F: FnMut(ast::Name, Vec<ast::Attribute>, String) -> bool,
 {
     let macros = reader::get_doc(rbml::Doc::new(data), tag_macro_defs);
     for macro_doc in reader::tagged_docs(macros, tag_macro_def) {
index ff24541692eccfd6ceaa80fdf368d628c6f30eac..83dc2f04e4682e948d5921309827a4db2985cf05 100644 (file)
 use std::io::{Cursor, SeekFrom};
 use std::rc::Rc;
 use syntax::abi;
-use syntax::ast::{NodeId, Name, CRATE_NODE_ID, CrateNum};
+use syntax::ast::{self, NodeId, Name, CRATE_NODE_ID, CrateNum};
+use syntax::attr;
+use syntax::attr::AttrMetaMethods;
 use syntax::diagnostic::SpanHandler;
 use syntax::parse::token::special_idents;
 use syntax;
 use rbml::writer::Encoder;
 
-use rustc_front::hir as ast;
+use rustc_front::hir;
 use rustc_front::visit::Visitor;
 use rustc_front::visit;
-use rustc_front::attr;
-use rustc_front::attr::AttrMetaMethods;
 use front::map::{LinkedPath, PathElem, PathElems};
 use front::map as ast_map;
 
@@ -272,7 +272,7 @@ fn encode_struct_fields(rbml_w: &mut Encoder,
 fn encode_enum_variant_info(ecx: &EncodeContext,
                             rbml_w: &mut Encoder,
                             id: NodeId,
-                            vis: ast::Visibility,
+                            vis: hir::Visibility,
                             index: &mut Vec<IndexEntry>) {
     debug!("encode_enum_variant_info(id={})", id);
 
@@ -445,12 +445,12 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
 /// top-level items that are sub-items of the given item. Specifically:
 ///
 /// * For newtype structs, iterates through the node ID of the constructor.
-fn each_auxiliary_node_id<F>(item: &ast::Item, callback: F) -> bool where
+fn each_auxiliary_node_id<F>(item: &hir::Item, callback: F) -> bool where
     F: FnOnce(NodeId) -> bool,
 {
     let mut continue_ = true;
     match item.node {
-        ast::ItemStruct(ref struct_def, _) => {
+        hir::ItemStruct(ref struct_def, _) => {
             // If this is a newtype struct, return the constructor.
             match struct_def.ctor_id {
                 Some(ctor_id) if !struct_def.fields.is_empty() &&
@@ -496,12 +496,12 @@ fn encode_reexports(ecx: &EncodeContext,
 
 fn encode_info_for_mod(ecx: &EncodeContext,
                        rbml_w: &mut Encoder,
-                       md: &ast::Mod,
+                       md: &hir::Mod,
                        attrs: &[ast::Attribute],
                        id: NodeId,
                        path: PathElems,
                        name: Name,
-                       vis: ast::Visibility) {
+                       vis: hir::Visibility) {
     rbml_w.start_tag(tag_items_data_item);
     encode_def_id(rbml_w, DefId::local(id));
     encode_family(rbml_w, 'm');
@@ -519,7 +519,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
             true
         });
 
-        if let ast::ItemImpl(..) = item.node {
+        if let hir::ItemImpl(..) = item.node {
             let (ident, did) = (item.ident, item.id);
             debug!("(encoding info for module) ... encoding impl {} ({}/{})",
                    ident,
@@ -536,7 +536,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
     encode_stability(rbml_w, stab);
 
     // Encode the reexports of this module, if this module is public.
-    if vis == ast::Public {
+    if vis == hir::Public {
         debug!("(encoding info for module) encoding reexports for {}", id);
         encode_reexports(ecx, rbml_w, id, path);
     }
@@ -546,26 +546,26 @@ fn encode_info_for_mod(ecx: &EncodeContext,
 }
 
 fn encode_struct_field_family(rbml_w: &mut Encoder,
-                              visibility: ast::Visibility) {
+                              visibility: hir::Visibility) {
     encode_family(rbml_w, match visibility {
-        ast::Public => 'g',
-        ast::Inherited => 'N'
+        hir::Public => 'g',
+        hir::Inherited => 'N'
     });
 }
 
-fn encode_visibility(rbml_w: &mut Encoder, visibility: ast::Visibility) {
+fn encode_visibility(rbml_w: &mut Encoder, visibility: hir::Visibility) {
     let ch = match visibility {
-        ast::Public => 'y',
-        ast::Inherited => 'i',
+        hir::Public => 'y',
+        hir::Inherited => 'i',
     };
     rbml_w.wr_tagged_u8(tag_items_data_item_visibility, ch as u8);
 }
 
-fn encode_constness(rbml_w: &mut Encoder, constness: ast::Constness) {
+fn encode_constness(rbml_w: &mut Encoder, constness: hir::Constness) {
     rbml_w.start_tag(tag_items_data_item_constness);
     let ch = match constness {
-        ast::Constness::Const => 'c',
-        ast::Constness::NotConst => 'n',
+        hir::Constness::Const => 'c',
+        hir::Constness::NotConst => 'n',
     };
     rbml_w.wr_str(&ch.to_string());
     rbml_w.end_tag();
@@ -593,10 +593,10 @@ fn encode_explicit_self(rbml_w: &mut Encoder,
         }
     }
 
-    fn encode_mutability(m: ast::Mutability) -> u8 {
+    fn encode_mutability(m: hir::Mutability) -> u8 {
         match m {
-            ast::MutImmutable => 'i' as u8,
-            ast::MutMutable => 'm' as u8,
+            hir::MutImmutable => 'i' as u8,
+            hir::MutMutable => 'm' as u8,
         }
     }
 }
@@ -784,7 +784,7 @@ fn encode_info_for_associated_const(ecx: &EncodeContext,
                                     associated_const: &ty::AssociatedConst,
                                     impl_path: PathElems,
                                     parent_id: NodeId,
-                                    impl_item_opt: Option<&ast::ImplItem>) {
+                                    impl_item_opt: Option<&hir::ImplItem>) {
     debug!("encode_info_for_associated_const({:?},{:?})",
            associated_const.def_id,
            associated_const.name);
@@ -822,7 +822,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
                                     impl_path: PathElems,
                                     is_default_impl: bool,
                                     parent_id: NodeId,
-                                    impl_item_opt: Option<&ast::ImplItem>) {
+                                    impl_item_opt: Option<&hir::ImplItem>) {
 
     debug!("encode_info_for_method: {:?} {:?}", m.def_id,
            m.name);
@@ -841,13 +841,13 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
     let elem = ast_map::PathName(m.name);
     encode_path(rbml_w, impl_path.chain(Some(elem)));
     if let Some(impl_item) = impl_item_opt {
-        if let ast::MethodImplItem(ref sig, _) = impl_item.node {
+        if let hir::MethodImplItem(ref sig, _) = impl_item.node {
             encode_attributes(rbml_w, &impl_item.attrs);
             let scheme = ecx.tcx.lookup_item_type(m.def_id);
             let any_types = !scheme.generics.types.is_empty();
             let needs_inline = any_types || is_default_impl ||
                                attr::requests_inline(&impl_item.attrs);
-            if needs_inline || sig.constness == ast::Constness::Const {
+            if needs_inline || sig.constness == hir::Constness::Const {
                 encode_inlined_item(ecx, rbml_w, InlinedItemRef::ImplItem(DefId::local(parent_id),
                                                                impl_item));
             }
@@ -867,7 +867,7 @@ fn encode_info_for_associated_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
                                              associated_type: &ty::AssociatedType<'tcx>,
                                              impl_path: PathElems,
                                              parent_id: NodeId,
-                                             impl_item_opt: Option<&ast::ImplItem>) {
+                                             impl_item_opt: Option<&hir::ImplItem>) {
     debug!("encode_info_for_associated_type({:?},{:?})",
            associated_type.def_id,
            associated_type.name);
@@ -903,11 +903,11 @@ fn encode_info_for_associated_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
 }
 
 fn encode_method_argument_names(rbml_w: &mut Encoder,
-                                decl: &ast::FnDecl) {
+                                decl: &hir::FnDecl) {
     rbml_w.start_tag(tag_method_argument_names);
     for arg in &decl.inputs {
         let tag = tag_method_argument_name;
-        if let ast::PatIdent(_, ref path1, _) = arg.pat.node {
+        if let hir::PatIdent(_, ref path1, _) = arg.pat.node {
             let name = path1.node.name.as_str();
             rbml_w.wr_tagged_bytes(tag, name.as_bytes());
         } else {
@@ -982,13 +982,13 @@ fn encode_stability(rbml_w: &mut Encoder, stab_opt: Option<&attr::Stability>) {
 
 fn encode_info_for_item(ecx: &EncodeContext,
                         rbml_w: &mut Encoder,
-                        item: &ast::Item,
+                        item: &hir::Item,
                         index: &mut Vec<IndexEntry>,
                         path: PathElems,
-                        vis: ast::Visibility) {
+                        vis: hir::Visibility) {
     let tcx = ecx.tcx;
 
-    fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
+    fn add_to_index(item: &hir::Item, rbml_w: &mut Encoder,
                     index: &mut Vec<IndexEntry>) {
         index.push(IndexEntry {
             node: item.id,
@@ -1003,11 +1003,11 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
     let stab = stability::lookup(tcx, DefId::local(item.id));
 
     match item.node {
-      ast::ItemStatic(_, m, _) => {
+      hir::ItemStatic(_, m, _) => {
         add_to_index(item, rbml_w, index);
         rbml_w.start_tag(tag_items_data_item);
         encode_def_id(rbml_w, def_id);
-        if m == ast::MutMutable {
+        if m == hir::MutMutable {
             encode_family(rbml_w, 'b');
         } else {
             encode_family(rbml_w, 'c');
@@ -1021,7 +1021,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
         encode_attributes(rbml_w, &item.attrs);
         rbml_w.end_tag();
       }
-      ast::ItemConst(_, _) => {
+      hir::ItemConst(_, _) => {
         add_to_index(item, rbml_w, index);
         rbml_w.start_tag(tag_items_data_item);
         encode_def_id(rbml_w, def_id);
@@ -1035,7 +1035,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
         encode_stability(rbml_w, stab);
         rbml_w.end_tag();
       }
-      ast::ItemFn(ref decl, _, constness, _, ref generics, _) => {
+      hir::ItemFn(ref decl, _, constness, _, ref generics, _) => {
         add_to_index(item, rbml_w, index);
         rbml_w.start_tag(tag_items_data_item);
         encode_def_id(rbml_w, def_id);
@@ -1046,7 +1046,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
         encode_path(rbml_w, path);
         encode_attributes(rbml_w, &item.attrs);
         let needs_inline = tps_len > 0 || attr::requests_inline(&item.attrs);
-        if needs_inline || constness == ast::Constness::Const {
+        if needs_inline || constness == hir::Constness::Const {
             encode_inlined_item(ecx, rbml_w, InlinedItemRef::Item(item));
         }
         if tps_len == 0 {
@@ -1058,7 +1058,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
         encode_method_argument_names(rbml_w, &**decl);
         rbml_w.end_tag();
       }
-      ast::ItemMod(ref m) => {
+      hir::ItemMod(ref m) => {
         add_to_index(item, rbml_w, index);
         encode_info_for_mod(ecx,
                             rbml_w,
@@ -1069,7 +1069,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
                             item.ident.name,
                             item.vis);
       }
-      ast::ItemForeignMod(ref fm) => {
+      hir::ItemForeignMod(ref fm) => {
         add_to_index(item, rbml_w, index);
         rbml_w.start_tag(tag_items_data_item);
         encode_def_id(rbml_w, def_id);
@@ -1086,7 +1086,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
         encode_stability(rbml_w, stab);
         rbml_w.end_tag();
       }
-      ast::ItemTy(..) => {
+      hir::ItemTy(..) => {
         add_to_index(item, rbml_w, index);
         rbml_w.start_tag(tag_items_data_item);
         encode_def_id(rbml_w, def_id);
@@ -1098,7 +1098,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
         encode_stability(rbml_w, stab);
         rbml_w.end_tag();
       }
-      ast::ItemEnum(ref enum_definition, _) => {
+      hir::ItemEnum(ref enum_definition, _) => {
         add_to_index(item, rbml_w, index);
 
         rbml_w.start_tag(tag_items_data_item);
@@ -1128,7 +1128,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
                                  vis,
                                  index);
       }
-      ast::ItemStruct(ref struct_def, _) => {
+      hir::ItemStruct(ref struct_def, _) => {
         let def = ecx.tcx.lookup_adt_def(def_id);
         let variant = def.struct_variant();
 
@@ -1174,7 +1174,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
             None => {}
         }
       }
-      ast::ItemDefaultImpl(unsafety, _) => {
+      hir::ItemDefaultImpl(unsafety, _) => {
           add_to_index(item, rbml_w, index);
           rbml_w.start_tag(tag_items_data_item);
           encode_def_id(rbml_w, def_id);
@@ -1186,7 +1186,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
           encode_trait_ref(rbml_w, ecx, trait_ref, tag_item_trait_ref);
           rbml_w.end_tag();
       }
-      ast::ItemImpl(unsafety, polarity, _, _, ref ty, ref ast_items) => {
+      hir::ItemImpl(unsafety, polarity, _, _, ref ty, ref ast_items) => {
         // We need to encode information about the default methods we
         // have inherited, so we drive this based on the impl structure.
         let impl_items = tcx.impl_items.borrow();
@@ -1212,7 +1212,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
         }
 
         match ty.node {
-            ast::TyPath(None, ref path) if path.segments.len() == 1 => {
+            hir::TyPath(None, ref path) if path.segments.len() == 1 => {
                 let name = path.segments.last().unwrap().identifier.name;
                 encode_impl_type_basename(rbml_w, name);
             }
@@ -1289,7 +1289,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
             }
         }
       }
-      ast::ItemTrait(_, _, _, ref ms) => {
+      hir::ItemTrait(_, _, _, ref ms) => {
         add_to_index(item, rbml_w, index);
         rbml_w.start_tag(tag_items_data_item);
         encode_def_id(rbml_w, def_id);
@@ -1429,11 +1429,11 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
             let trait_item = &*ms[i];
             encode_attributes(rbml_w, &trait_item.attrs);
             match trait_item.node {
-                ast::ConstTraitItem(_, _) => {
+                hir::ConstTraitItem(_, _) => {
                     encode_inlined_item(ecx, rbml_w,
                                         InlinedItemRef::TraitItem(def_id, trait_item));
                 }
-                ast::MethodTraitItem(ref sig, ref body) => {
+                hir::MethodTraitItem(ref sig, ref body) => {
                     // If this is a static method, we've already
                     // encoded this.
                     if is_nonstatic_method {
@@ -1453,13 +1453,13 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
                     encode_method_argument_names(rbml_w, &sig.decl);
                 }
 
-                ast::TypeTraitItem(..) => {}
+                hir::TypeTraitItem(..) => {}
             }
 
             rbml_w.end_tag();
         }
       }
-      ast::ItemExternCrate(_) | ast::ItemUse(_) => {
+      hir::ItemExternCrate(_) | hir::ItemUse(_) => {
         // these are encoded separately
       }
     }
@@ -1467,7 +1467,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &mut Encoder,
 
 fn encode_info_for_foreign_item(ecx: &EncodeContext,
                                 rbml_w: &mut Encoder,
-                                nitem: &ast::ForeignItem,
+                                nitem: &hir::ForeignItem,
                                 index: &mut Vec<IndexEntry>,
                                 path: PathElems,
                                 abi: abi::Abi) {
@@ -1480,7 +1480,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
     encode_def_id(rbml_w, DefId::local(nitem.id));
     encode_visibility(rbml_w, nitem.vis);
     match nitem.node {
-      ast::ForeignItemFn(ref fndecl, _) => {
+      hir::ForeignItemFn(ref fndecl, _) => {
         encode_family(rbml_w, FN_FAMILY);
         encode_bounds_and_type_for_item(rbml_w, ecx, nitem.id);
         encode_name(rbml_w, nitem.ident.name);
@@ -1493,7 +1493,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
         encode_symbol(ecx, rbml_w, nitem.id);
         encode_method_argument_names(rbml_w, &*fndecl);
       }
-      ast::ForeignItemStatic(_, mutbl) => {
+      hir::ForeignItemStatic(_, mutbl) => {
         if mutbl {
             encode_family(rbml_w, 'b');
         } else {
@@ -1511,9 +1511,9 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
     rbml_w.end_tag();
 }
 
-fn my_visit_expr(_e: &ast::Expr) { }
+fn my_visit_expr(_e: &hir::Expr) { }
 
-fn my_visit_item(i: &ast::Item,
+fn my_visit_item(i: &hir::Item,
                  rbml_w: &mut Encoder,
                  ecx: &EncodeContext,
                  index: &mut Vec<IndexEntry>) {
@@ -1522,7 +1522,7 @@ fn my_visit_item(i: &ast::Item,
     });
 }
 
-fn my_visit_foreign_item(ni: &ast::ForeignItem,
+fn my_visit_foreign_item(ni: &hir::ForeignItem,
                          rbml_w: &mut Encoder,
                          ecx: &EncodeContext,
                          index: &mut Vec<IndexEntry>) {
@@ -1545,18 +1545,18 @@ struct EncodeVisitor<'a, 'b:'a, 'c:'a, 'tcx:'c> {
 }
 
 impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for EncodeVisitor<'a, 'b, 'c, 'tcx> {
-    fn visit_expr(&mut self, ex: &ast::Expr) {
+    fn visit_expr(&mut self, ex: &hir::Expr) {
         visit::walk_expr(self, ex);
         my_visit_expr(ex);
     }
-    fn visit_item(&mut self, i: &ast::Item) {
+    fn visit_item(&mut self, i: &hir::Item) {
         visit::walk_item(self, i);
         my_visit_item(i,
                       self.rbml_w_for_visit_item,
                       self.ecx,
                       self.index);
     }
-    fn visit_foreign_item(&mut self, ni: &ast::ForeignItem) {
+    fn visit_foreign_item(&mut self, ni: &hir::ForeignItem) {
         visit::walk_foreign_item(self, ni);
         my_visit_foreign_item(ni,
                               self.rbml_w_for_visit_item,
@@ -1567,7 +1567,7 @@ fn visit_foreign_item(&mut self, ni: &ast::ForeignItem) {
 
 fn encode_info_for_items(ecx: &EncodeContext,
                          rbml_w: &mut Encoder,
-                         krate: &ast::Crate)
+                         krate: &hir::Crate)
                          -> Vec<IndexEntry> {
     let mut index = Vec::new();
     rbml_w.start_tag(tag_items_data);
@@ -1582,7 +1582,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
                         CRATE_NODE_ID,
                         [].iter().cloned().chain(LinkedPath::empty()),
                         syntax::parse::token::special_idents::invalid.name,
-                        ast::Public);
+                        hir::Public);
 
     visit::walk_crate(&mut EncodeVisitor {
         index: &mut index,
@@ -1644,10 +1644,10 @@ fn encode_attributes(rbml_w: &mut Encoder, attrs: &[ast::Attribute]) {
     rbml_w.end_tag();
 }
 
-fn encode_unsafety(rbml_w: &mut Encoder, unsafety: ast::Unsafety) {
+fn encode_unsafety(rbml_w: &mut Encoder, unsafety: hir::Unsafety) {
     let byte: u8 = match unsafety {
-        ast::Unsafety::Normal => 0,
-        ast::Unsafety::Unsafe => 1,
+        hir::Unsafety::Normal => 0,
+        hir::Unsafety::Unsafe => 1,
     };
     rbml_w.wr_tagged_u8(tag_unsafety, byte);
 }
@@ -1670,10 +1670,10 @@ fn encode_associated_type_names(rbml_w: &mut Encoder, names: &[Name]) {
     rbml_w.end_tag();
 }
 
-fn encode_polarity(rbml_w: &mut Encoder, polarity: ast::ImplPolarity) {
+fn encode_polarity(rbml_w: &mut Encoder, polarity: hir::ImplPolarity) {
     let byte: u8 = match polarity {
-        ast::ImplPolarity::Positive => 0,
-        ast::ImplPolarity::Negative => 1,
+        hir::ImplPolarity::Positive => 0,
+        hir::ImplPolarity::Negative => 1,
     };
     rbml_w.wr_tagged_u8(tag_polarity, byte);
 }
@@ -1782,7 +1782,7 @@ fn encode_codemap(ecx: &EncodeContext, rbml_w: &mut Encoder) {
 
 /// Serialize the text of the exported macros
 fn encode_macro_defs(rbml_w: &mut Encoder,
-                     krate: &ast::Crate) {
+                     krate: &hir::Crate) {
     rbml_w.start_tag(tag_macro_defs);
     for def in &krate.exported_macros {
         rbml_w.start_tag(tag_macro_def);
@@ -1798,13 +1798,13 @@ fn encode_macro_defs(rbml_w: &mut Encoder,
     rbml_w.end_tag();
 }
 
-fn encode_struct_field_attrs(rbml_w: &mut Encoder, krate: &ast::Crate) {
+fn encode_struct_field_attrs(rbml_w: &mut Encoder, krate: &hir::Crate) {
     struct StructFieldVisitor<'a, 'b:'a> {
         rbml_w: &'a mut Encoder<'b>,
     }
 
     impl<'a, 'b, 'v> Visitor<'v> for StructFieldVisitor<'a, 'b> {
-        fn visit_struct_field(&mut self, field: &ast::StructField) {
+        fn visit_struct_field(&mut self, field: &hir::StructField) {
             self.rbml_w.start_tag(tag_struct_field);
             self.rbml_w.wr_tagged_u32(tag_struct_field_id, field.node.id);
             encode_attributes(self.rbml_w, &field.node.attrs);
@@ -1827,8 +1827,8 @@ struct ImplVisitor<'a, 'b:'a, 'c:'a, 'tcx:'b> {
 }
 
 impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for ImplVisitor<'a, 'b, 'c, 'tcx> {
-    fn visit_item(&mut self, item: &ast::Item) {
-        if let ast::ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
+    fn visit_item(&mut self, item: &hir::Item) {
+        if let hir::ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
             let def_id = self.ecx.tcx.def_map.borrow().get(&trait_ref.ref_id).unwrap().def_id();
 
             // Load eagerly if this is an implementation of the Drop trait
@@ -1856,7 +1856,7 @@ fn visit_item(&mut self, item: &ast::Item) {
 ///
 /// * Implementations of traits not defined in this crate.
 fn encode_impls<'a>(ecx: &'a EncodeContext,
-                    krate: &ast::Crate,
+                    krate: &hir::Crate,
                     rbml_w: &'a mut Encoder) {
     rbml_w.start_tag(tag_impls);
 
@@ -1872,7 +1872,7 @@ fn encode_impls<'a>(ecx: &'a EncodeContext,
 }
 
 fn encode_misc_info(ecx: &EncodeContext,
-                    krate: &ast::Crate,
+                    krate: &hir::Crate,
                     rbml_w: &mut Encoder) {
     rbml_w.start_tag(tag_misc_info);
     rbml_w.start_tag(tag_misc_info_crate_items);
@@ -1956,7 +1956,7 @@ fn encode_dylib_dependency_formats(rbml_w: &mut Encoder, ecx: &EncodeContext) {
 #[allow(non_upper_case_globals)]
 pub const metadata_encoding_version : &'static [u8] = &[b'r', b'u', b's', b't', 0, 0, 0, 2 ];
 
-pub fn encode_metadata(parms: EncodeParams, krate: &ast::Crate) -> Vec<u8> {
+pub fn encode_metadata(parms: EncodeParams, krate: &hir::Crate) -> Vec<u8> {
     let mut wr = Cursor::new(Vec::new());
     encode_metadata_inner(&mut wr, parms, krate);
 
@@ -1995,7 +1995,7 @@ pub fn encode_metadata(parms: EncodeParams, krate: &ast::Crate) -> Vec<u8> {
 
 fn encode_metadata_inner(wr: &mut Cursor<Vec<u8>>,
                          parms: EncodeParams,
-                         krate: &ast::Crate) {
+                         krate: &hir::Crate) {
     struct Stats {
         attr_bytes: u64,
         dep_bytes: u64,
index 527f5919e2ddcd48fbe6058759e6979c0bf427a2..c4a133fa944841148d5fc88e07f50691d49bd1fb 100644 (file)
@@ -21,7 +21,6 @@
 use syntax::visit;
 use syntax::visit::Visitor;
 use syntax::attr::AttrMetaMethods;
-use rustc_front::attr::AttrMetaMethods as FrontAttrMetaMethods;
 
 struct MacroLoader<'a> {
     sess: &'a Session,
index d7554c4cf750186b1aa619f037d1252f58ad328c..3176f5c9cc42f31bd544e7ce54e7bd3073fc7de9 100644 (file)
@@ -27,6 +27,7 @@
 use rustc_front::hir;
 
 use syntax::abi::Abi;
+use syntax::ast;
 use syntax::diagnostic::SpanHandler;
 
 use rbml::writer::Encoder;
@@ -65,26 +66,26 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
         ty::TyChar => mywrite!(w, "c"),
         ty::TyInt(t) => {
             match t {
-                hir::TyIs => mywrite!(w, "is"),
-                hir::TyI8 => mywrite!(w, "MB"),
-                hir::TyI16 => mywrite!(w, "MW"),
-                hir::TyI32 => mywrite!(w, "ML"),
-                hir::TyI64 => mywrite!(w, "MD")
+                ast::TyIs => mywrite!(w, "is"),
+                ast::TyI8 => mywrite!(w, "MB"),
+                ast::TyI16 => mywrite!(w, "MW"),
+                ast::TyI32 => mywrite!(w, "ML"),
+                ast::TyI64 => mywrite!(w, "MD")
             }
         }
         ty::TyUint(t) => {
             match t {
-                hir::TyUs => mywrite!(w, "us"),
-                hir::TyU8 => mywrite!(w, "Mb"),
-                hir::TyU16 => mywrite!(w, "Mw"),
-                hir::TyU32 => mywrite!(w, "Ml"),
-                hir::TyU64 => mywrite!(w, "Md")
+                ast::TyUs => mywrite!(w, "us"),
+                ast::TyU8 => mywrite!(w, "Mb"),
+                ast::TyU16 => mywrite!(w, "Mw"),
+                ast::TyU32 => mywrite!(w, "Ml"),
+                ast::TyU64 => mywrite!(w, "Md")
             }
         }
         ty::TyFloat(t) => {
             match t {
-                hir::TyF32 => mywrite!(w, "Mf"),
-                hir::TyF64 => mywrite!(w, "MF"),
+                ast::TyF32 => mywrite!(w, "Mf"),
+                ast::TyF64 => mywrite!(w, "MF"),
             }
         }
         ty::TyEnum(def, substs) => {
index 8d592c9262958e26d4058c44416cdce7732b2906..2e6207b0df51e4e2c6c60a08bcf4993a030fb3c8 100644 (file)
@@ -404,7 +404,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
 
 fn const_val_to_expr(value: &ConstVal) -> P<hir::Expr> {
     let node = match value {
-        &ConstVal::Bool(b) => hir::LitBool(b),
+        &ConstVal::Bool(b) => ast::LitBool(b),
         _ => unreachable!()
     };
     P(hir::Expr {
index e1cf6ace8432eaa2af09b87f7546806517a69a89..11be35a24f5f74af8636fd44157456ea36acb94f 100644 (file)
@@ -466,35 +466,35 @@ pub enum IntTy { I8, I16, I32, I64 }
 pub enum UintTy { U8, U16, U32, U64 }
 
 impl IntTy {
-    pub fn from(tcx: &ty::ctxt, t: hir::IntTy) -> IntTy {
-        let t = if let hir::TyIs = t {
+    pub fn from(tcx: &ty::ctxt, t: ast::IntTy) -> IntTy {
+        let t = if let ast::TyIs = t {
             tcx.sess.target.int_type
         } else {
             t
         };
         match t {
-            hir::TyIs => unreachable!(),
-            hir::TyI8  => IntTy::I8,
-            hir::TyI16 => IntTy::I16,
-            hir::TyI32 => IntTy::I32,
-            hir::TyI64 => IntTy::I64,
+            ast::TyIs => unreachable!(),
+            ast::TyI8  => IntTy::I8,
+            ast::TyI16 => IntTy::I16,
+            ast::TyI32 => IntTy::I32,
+            ast::TyI64 => IntTy::I64,
         }
     }
 }
 
 impl UintTy {
-    pub fn from(tcx: &ty::ctxt, t: hir::UintTy) -> UintTy {
-        let t = if let hir::TyUs = t {
+    pub fn from(tcx: &ty::ctxt, t: ast::UintTy) -> UintTy {
+        let t = if let ast::TyUs = t {
             tcx.sess.target.uint_type
         } else {
             t
         };
         match t {
-            hir::TyUs => unreachable!(),
-            hir::TyU8  => UintTy::U8,
-            hir::TyU16 => UintTy::U16,
-            hir::TyU32 => UintTy::U32,
-            hir::TyU64 => UintTy::U64,
+            ast::TyUs => unreachable!(),
+            ast::TyU8  => UintTy::U8,
+            ast::TyU16 => UintTy::U16,
+            ast::TyU32 => UintTy::U32,
+            ast::TyU64 => UintTy::U64,
         }
     }
 }
@@ -1141,60 +1141,60 @@ macro_rules! convert_val {
 
     // Issue #23890: If isize/usize, then dispatch to appropriate target representation type
     match (&ty.sty, tcx.sess.target.int_type, tcx.sess.target.uint_type) {
-        (&ty::TyInt(hir::TyIs), hir::TyI32, _) => return convert_val!(i32, Int, i64),
-        (&ty::TyInt(hir::TyIs), hir::TyI64, _) => return convert_val!(i64, Int, i64),
-        (&ty::TyInt(hir::TyIs), _, _) => panic!("unexpected target.int_type"),
+        (&ty::TyInt(ast::TyIs), ast::TyI32, _) => return convert_val!(i32, Int, i64),
+        (&ty::TyInt(ast::TyIs), ast::TyI64, _) => return convert_val!(i64, Int, i64),
+        (&ty::TyInt(ast::TyIs), _, _) => panic!("unexpected target.int_type"),
 
-        (&ty::TyUint(hir::TyUs), _, hir::TyU32) => return convert_val!(u32, Uint, u64),
-        (&ty::TyUint(hir::TyUs), _, hir::TyU64) => return convert_val!(u64, Uint, u64),
-        (&ty::TyUint(hir::TyUs), _, _) => panic!("unexpected target.uint_type"),
+        (&ty::TyUint(ast::TyUs), _, ast::TyU32) => return convert_val!(u32, Uint, u64),
+        (&ty::TyUint(ast::TyUs), _, ast::TyU64) => return convert_val!(u64, Uint, u64),
+        (&ty::TyUint(ast::TyUs), _, _) => panic!("unexpected target.uint_type"),
 
         _ => {}
     }
 
     match ty.sty {
-        ty::TyInt(hir::TyIs) => unreachable!(),
-        ty::TyUint(hir::TyUs) => unreachable!(),
+        ty::TyInt(ast::TyIs) => unreachable!(),
+        ty::TyUint(ast::TyUs) => unreachable!(),
 
-        ty::TyInt(hir::TyI8) => convert_val!(i8, Int, i64),
-        ty::TyInt(hir::TyI16) => convert_val!(i16, Int, i64),
-        ty::TyInt(hir::TyI32) => convert_val!(i32, Int, i64),
-        ty::TyInt(hir::TyI64) => convert_val!(i64, Int, i64),
+        ty::TyInt(ast::TyI8) => convert_val!(i8, Int, i64),
+        ty::TyInt(ast::TyI16) => convert_val!(i16, Int, i64),
+        ty::TyInt(ast::TyI32) => convert_val!(i32, Int, i64),
+        ty::TyInt(ast::TyI64) => convert_val!(i64, Int, i64),
 
-        ty::TyUint(hir::TyU8) => convert_val!(u8, Uint, u64),
-        ty::TyUint(hir::TyU16) => convert_val!(u16, Uint, u64),
-        ty::TyUint(hir::TyU32) => convert_val!(u32, Uint, u64),
-        ty::TyUint(hir::TyU64) => convert_val!(u64, Uint, u64),
+        ty::TyUint(ast::TyU8) => convert_val!(u8, Uint, u64),
+        ty::TyUint(ast::TyU16) => convert_val!(u16, Uint, u64),
+        ty::TyUint(ast::TyU32) => convert_val!(u32, Uint, u64),
+        ty::TyUint(ast::TyU64) => convert_val!(u64, Uint, u64),
 
-        ty::TyFloat(hir::TyF32) => convert_val!(f32, Float, f64),
-        ty::TyFloat(hir::TyF64) => convert_val!(f64, Float, f64),
+        ty::TyFloat(ast::TyF32) => convert_val!(f32, Float, f64),
+        ty::TyFloat(ast::TyF64) => convert_val!(f64, Float, f64),
         _ => Err(ErrKind::CannotCast),
     }
 }
 
-fn lit_to_const(lit: &hir::Lit, ty_hint: Option<Ty>) -> ConstVal {
+fn lit_to_const(lit: &ast::Lit, ty_hint: Option<Ty>) -> ConstVal {
     match lit.node {
-        hir::LitStr(ref s, _) => Str((*s).clone()),
-        hir::LitByteStr(ref data) => {
+        ast::LitStr(ref s, _) => Str((*s).clone()),
+        ast::LitByteStr(ref data) => {
             ByteStr(data.clone())
         }
-        hir::LitByte(n) => Uint(n as u64),
-        hir::LitChar(n) => Uint(n as u64),
-        hir::LitInt(n, hir::SignedIntLit(_, hir::Plus)) => Int(n as i64),
-        hir::LitInt(n, hir::UnsuffixedIntLit(hir::Plus)) => {
+        ast::LitByte(n) => Uint(n as u64),
+        ast::LitChar(n) => Uint(n as u64),
+        ast::LitInt(n, ast::SignedIntLit(_, ast::Plus)) => Int(n as i64),
+        ast::LitInt(n, ast::UnsuffixedIntLit(ast::Plus)) => {
             match ty_hint.map(|ty| &ty.sty) {
                 Some(&ty::TyUint(_)) => Uint(n),
                 _ => Int(n as i64)
             }
         }
-        hir::LitInt(n, hir::SignedIntLit(_, hir::Minus)) |
-        hir::LitInt(n, hir::UnsuffixedIntLit(hir::Minus)) => Int(-(n as i64)),
-        hir::LitInt(n, hir::UnsignedIntLit(_)) => Uint(n),
-        hir::LitFloat(ref n, _) |
-        hir::LitFloatUnsuffixed(ref n) => {
+        ast::LitInt(n, ast::SignedIntLit(_, ast::Minus)) |
+        ast::LitInt(n, ast::UnsuffixedIntLit(ast::Minus)) => Int(-(n as i64)),
+        ast::LitInt(n, ast::UnsignedIntLit(_)) => Uint(n),
+        ast::LitFloat(ref n, _) |
+        ast::LitFloatUnsuffixed(ref n) => {
             Float(n.parse::<f64>().unwrap() as f64)
         }
-        hir::LitBool(b) => Bool(b)
+        ast::LitBool(b) => Bool(b)
     }
 }
 
index 14ba241f62b0f1bfabdb6dd0a94a68eaef0fa1c0..132efc1ff88269eb3e5875faea0ced62478b9722 100644 (file)
@@ -24,6 +24,7 @@
 use syntax::ast;
 use syntax::ast_util::IdRange;
 use syntax::print::pp;
+use syntax::print::pprust::PrintState;
 use util::nodemap::NodeMap;
 use rustc_front::hir;
 use rustc_front::visit;
index ed9ca48b39ca2b209cce82a105e0130fae0a3060..182bc067a7fc177134cc19973522dac3c61acf47 100644 (file)
@@ -15,7 +15,6 @@
 use front::map as ast_map;
 use rustc_front::hir;
 use rustc_front::visit::{self, Visitor};
-use rustc_front::attr::{self, AttrMetaMethods};
 
 use middle::{def, pat_util, privacy, ty};
 use middle::def_id::{DefId};
@@ -24,6 +23,7 @@
 
 use std::collections::HashSet;
 use syntax::{ast, codemap};
+use syntax::attr::{self, AttrMetaMethods};
 
 // Any local node that may call something in its body block should be
 // explored. For example, if it's a live NodeItem that is a
@@ -285,13 +285,13 @@ fn visit_item(&mut self, _: &hir::Item) {
     }
 }
 
-fn has_allow_dead_code_or_lang_attr(attrs: &[hir::Attribute]) -> bool {
+fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
     if attr::contains_name(attrs, "lang") {
         return true;
     }
 
     let dead_code = lint::builtin::DEAD_CODE.name_lower();
-    for attr in lint::gather_attrs_from_hir(attrs) {
+    for attr in lint::gather_attrs(attrs) {
         match attr {
             Ok((ref name, lint::Allow, _))
                 if &name[..] == dead_code => return true,
index e32a9b280f3d517af2a38a6815d39e7c030903da..841859ffec42c6dc7ffeb7481bfafaea014f2020 100644 (file)
 use front::map as ast_map;
 use session::{config, Session};
 use syntax::ast::NodeId;
-use rustc_front::hir::{Item, ItemFn};
-use rustc_front::attr;
+use syntax::attr;
 use syntax::codemap::Span;
 use syntax::entry::EntryPointType;
+use rustc_front::hir::{Item, ItemFn};
 use rustc_front::visit;
 use rustc_front::visit::Visitor;
 
index 2447a8cee7bbb9d56bf9c0e1d2f8969a350e04f1..03554a59655b162c4ef18e7819333a0e2cd7d7bf 100644 (file)
@@ -48,8 +48,8 @@
 use middle::ty::fold::{TypeFolder, TypeFoldable};
 use middle::ty::relate::{Relate, RelateResult, TypeRelation};
 
+use syntax::ast;
 use syntax::codemap::Span;
-use rustc_front::hir;
 
 #[derive(Clone)]
 pub struct CombineFields<'a, 'tcx: 'a> {
@@ -138,7 +138,7 @@ fn unify_integral_variable<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
 fn unify_float_variable<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
                                  vid_is_expected: bool,
                                  vid: ty::FloatVid,
-                                 val: hir::FloatTy)
+                                 val: ast::FloatTy)
                                  -> RelateResult<'tcx, Ty<'tcx>>
 {
     try!(infcx
@@ -388,7 +388,7 @@ fn int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::Int
 }
 
 fn float_unification_error<'tcx>(a_is_expected: bool,
-                                 v: (hir::FloatTy, hir::FloatTy))
+                                 v: (ast::FloatTy, ast::FloatTy))
                                  -> TypeError<'tcx>
 {
     let (a, b) = v;
index 6bb46ac787073d6cc19858efabfd87c081b83846..41aa191ac24d210f23a3e36dd7cf84293ad6fe5c 100644 (file)
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use syntax::ast;
 use middle::ty::{self, IntVarValue, Ty};
 use rustc_data_structures::unify::UnifyKey;
-use rustc_front::hir as ast;
 
 pub trait ToType<'tcx> {
     fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx>;
index a34571e4acac77097210f33670bdd6fc427b4a8d..f0aa824c589d3050df829542601e43e94a10b38e 100644 (file)
@@ -28,7 +28,8 @@
 use middle::weak_lang_items;
 use util::nodemap::FnvHashMap;
 
-use rustc_front::attr::AttrMetaMethods;
+use syntax::ast;
+use syntax::attr::AttrMetaMethods;
 use syntax::codemap::{DUMMY_SP, Span};
 use syntax::parse::token::InternedString;
 use rustc_front::visit::Visitor;
@@ -216,7 +217,7 @@ pub fn collect(&mut self, krate: &hir::Crate) {
     }
 }
 
-pub fn extract(attrs: &[hir::Attribute]) -> Option<InternedString> {
+pub fn extract(attrs: &[ast::Attribute]) -> Option<InternedString> {
     for attribute in attrs {
         match attribute.value_str() {
             Some(ref value) if attribute.check_name("lang") => {
index 215368754c999b9e3bf2d7edaac5a24ecf233343..3fb3d575f93c6e3cabec67b688853965a58bcc56 100644 (file)
@@ -26,8 +26,8 @@
 use std::collections::HashSet;
 use syntax::abi;
 use syntax::ast;
+use syntax::attr;
 use rustc_front::hir;
-use rustc_front::attr;
 use rustc_front::visit::Visitor;
 use rustc_front::visit;
 
index 9c4697404201eac242c08128b6f458ce7aff2142..e29d432707104cfeceb01b97b36d12088418e43c 100644 (file)
 use syntax::parse::token::InternedString;
 use syntax::codemap::{Span, DUMMY_SP};
 use syntax::ast;
-use syntax::ast::NodeId;
+use syntax::ast::{NodeId, Attribute};
 use syntax::feature_gate::{GateIssue, emit_feature_err};
+use syntax::attr::{self, Stability, AttrMetaMethods};
 use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};
 
 use rustc_front::hir;
-use rustc_front::hir::{FnDecl, Attribute, Block, Crate, Item, Generics, StructField, Variant};
-use rustc_front::attr::{self, Stability, AttrMetaMethods};
+use rustc_front::hir::{FnDecl, Block, Crate, Item, Generics, StructField, Variant};
 use rustc_front::visit::{self, FnKind, Visitor};
 
 use std::mem::replace;
@@ -237,7 +237,7 @@ pub fn new(krate: &Crate) -> Index {
         for attr in &krate.attrs {
             if &attr.name()[..] == "staged_api" {
                 match attr.node.value.node {
-                    hir::MetaWord(_) => {
+                    ast::MetaWord(_) => {
                         attr::mark_used(attr);
                         is_staged_api = true;
                     }
index 2ed53f16afd28e9215426ad161a385b402747590..5248cb7f30e97fed681dd1285ab9e6226529e882 100644 (file)
@@ -31,7 +31,7 @@
 use std::collections::HashMap;
 use std::fmt;
 use syntax::codemap::Span;
-use rustc_front::attr::{AttributeMethods, AttrMetaMethods};
+use syntax::attr::{AttributeMethods, AttrMetaMethods};
 
 pub fn report_fulfillment_errors<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
                                            errors: &Vec<FulfillmentError<'tcx>>) {
index 8cb4f941a2264eb8fc84a2e98c2022f6a6c76f97..8233b6b2b2b6e7a61f4a16e3f5ce45442b6814c2 100644 (file)
@@ -13,7 +13,7 @@
 
 use middle::ty::{self, Ty};
 
-use rustc_front::hir as ast;
+use syntax::ast;
 
 /// Types that are represented as ints.
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
index bcce9e8ea54761d2f73b37728a349a2372698174..afe88f70d945055a4ed325a317c18bc919489345 100644 (file)
@@ -16,7 +16,7 @@
 use std::fmt;
 use std::ops;
 
-use rustc_front::hir;
+use syntax::ast;
 
 /// Type contents is how the type checker reasons about kinds.
 /// They track what kinds of things are found within a type.  You can
@@ -182,7 +182,7 @@ fn tc_ty<'tcx>(cx: &ty::ctxt<'tcx>,
 
             let result = match ty.sty {
                 // usize and isize are ffi-unsafe
-                ty::TyUint(hir::TyUs) | ty::TyInt(hir::TyIs) => {
+                ty::TyUint(ast::TyUs) | ty::TyInt(ast::TyIs) => {
                     TC::None
                 }
 
index e3b6da56680da303b5657aec0a52ecfe4cd93a81..31e4765aaaa601862d9de2a30ecf0180ffe22639 100644 (file)
 use std::hash::{Hash, Hasher};
 use std::rc::Rc;
 use syntax::abi;
-use syntax::ast::{Name, NodeId};
+use syntax::ast::{self, Name, NodeId};
+use syntax::attr;
 use syntax::parse::token::special_idents;
 
 use rustc_front::hir;
-use rustc_front::attr;
 
 /// Internal storage
 pub struct CtxtArenas<'tcx> {
@@ -146,18 +146,18 @@ fn new(arena: &'tcx TypedArena<TyS<'tcx>>,
             bool: mk(TyBool),
             char: mk(TyChar),
             err: mk(TyError),
-            isize: mk(TyInt(hir::TyIs)),
-            i8: mk(TyInt(hir::TyI8)),
-            i16: mk(TyInt(hir::TyI16)),
-            i32: mk(TyInt(hir::TyI32)),
-            i64: mk(TyInt(hir::TyI64)),
-            usize: mk(TyUint(hir::TyUs)),
-            u8: mk(TyUint(hir::TyU8)),
-            u16: mk(TyUint(hir::TyU16)),
-            u32: mk(TyUint(hir::TyU32)),
-            u64: mk(TyUint(hir::TyU64)),
-            f32: mk(TyFloat(hir::TyF32)),
-            f64: mk(TyFloat(hir::TyF64)),
+            isize: mk(TyInt(ast::TyIs)),
+            i8: mk(TyInt(ast::TyI8)),
+            i16: mk(TyInt(ast::TyI16)),
+            i32: mk(TyInt(ast::TyI32)),
+            i64: mk(TyInt(ast::TyI64)),
+            usize: mk(TyUint(ast::TyUs)),
+            u8: mk(TyUint(ast::TyU8)),
+            u16: mk(TyUint(ast::TyU16)),
+            u32: mk(TyUint(ast::TyU32)),
+            u64: mk(TyUint(ast::TyU64)),
+            f32: mk(TyFloat(ast::TyF32)),
+            f64: mk(TyFloat(ast::TyF64)),
         }
     }
 }
@@ -771,30 +771,30 @@ pub fn mk_ty(&self, st: TypeVariants<'tcx>) -> Ty<'tcx> {
         ctxt::intern_ty(&self.arenas.type_, &self.interner, st)
     }
 
-    pub fn mk_mach_int(&self, tm: hir::IntTy) -> Ty<'tcx> {
+    pub fn mk_mach_int(&self, tm: ast::IntTy) -> Ty<'tcx> {
         match tm {
-            hir::TyIs   => self.types.isize,
-            hir::TyI8   => self.types.i8,
-            hir::TyI16  => self.types.i16,
-            hir::TyI32  => self.types.i32,
-            hir::TyI64  => self.types.i64,
+            ast::TyIs   => self.types.isize,
+            ast::TyI8   => self.types.i8,
+            ast::TyI16  => self.types.i16,
+            ast::TyI32  => self.types.i32,
+            ast::TyI64  => self.types.i64,
         }
     }
 
-    pub fn mk_mach_uint(&self, tm: hir::UintTy) -> Ty<'tcx> {
+    pub fn mk_mach_uint(&self, tm: ast::UintTy) -> Ty<'tcx> {
         match tm {
-            hir::TyUs   => self.types.usize,
-            hir::TyU8   => self.types.u8,
-            hir::TyU16  => self.types.u16,
-            hir::TyU32  => self.types.u32,
-            hir::TyU64  => self.types.u64,
+            ast::TyUs   => self.types.usize,
+            ast::TyU8   => self.types.u8,
+            ast::TyU16  => self.types.u16,
+            ast::TyU32  => self.types.u32,
+            ast::TyU64  => self.types.u64,
         }
     }
 
-    pub fn mk_mach_float(&self, tm: hir::FloatTy) -> Ty<'tcx> {
+    pub fn mk_mach_float(&self, tm: ast::FloatTy) -> Ty<'tcx> {
         match tm {
-            hir::TyF32  => self.types.f32,
-            hir::TyF64  => self.types.f64,
+            ast::TyF32  => self.types.f32,
+            ast::TyF64  => self.types.f64,
         }
     }
 
index 72c4366c5bcd5a8f189a1fef6080eed41527de69..ba7be3e2c994845dcf0d7692b47a94156b4cea21 100644 (file)
@@ -15,7 +15,7 @@
 
 use std::fmt;
 use syntax::abi;
-use syntax::ast::Name;
+use syntax::ast::{self, Name};
 use syntax::codemap::Span;
 
 use rustc_front::hir;
@@ -49,7 +49,7 @@ pub enum TypeError<'tcx> {
     Sorts(ExpectedFound<Ty<'tcx>>),
     IntegerAsChar,
     IntMismatch(ExpectedFound<ty::IntVarValue>),
-    FloatMismatch(ExpectedFound<hir::FloatTy>),
+    FloatMismatch(ExpectedFound<ast::FloatTy>),
     Traits(ExpectedFound<DefId>),
     BuiltinBoundsMismatch(ExpectedFound<ty::BuiltinBounds>),
     VariadicMismatch(ExpectedFound<bool>),
index 2b81be19182e2d525e568e97d678c402481f448b..77608f4012845d687c7054bc0fc4562202d83f8f 100644 (file)
@@ -10,7 +10,7 @@
 
 use middle::def_id::DefId;
 use middle::ty::{self, Ty};
-use rustc_front::hir;
+use syntax::ast;
 
 use self::SimplifiedType::*;
 
@@ -19,9 +19,9 @@
 pub enum SimplifiedType {
     BoolSimplifiedType,
     CharSimplifiedType,
-    IntSimplifiedType(hir::IntTy),
-    UintSimplifiedType(hir::UintTy),
-    FloatSimplifiedType(hir::FloatTy),
+    IntSimplifiedType(ast::IntTy),
+    UintSimplifiedType(ast::UintTy),
+    FloatSimplifiedType(ast::FloatTy),
     EnumSimplifiedType(DefId),
     StrSimplifiedType,
     VecSimplifiedType,
index a8adb3886442442093073996d76d26d4adf32c96..fdf23c455ba2ffa032c38e117d4334d77d7caec4 100644 (file)
 use std::vec::IntoIter;
 use std::collections::{HashMap, HashSet};
 use syntax::ast::{self, CrateNum, Name, NodeId};
+use syntax::attr::{self, AttrMetaMethods};
 use syntax::codemap::Span;
 use syntax::parse::token::{InternedString, special_idents};
 
 use rustc_front::hir;
 use rustc_front::hir::{ItemImpl, ItemTrait};
 use rustc_front::hir::{MutImmutable, MutMutable, Visibility};
-use rustc_front::attr::{self, AttrMetaMethods};
 
 pub use self::sty::{Binder, DebruijnIndex};
 pub use self::sty::{BuiltinBound, BuiltinBounds, ExistentialBounds};
@@ -563,8 +563,8 @@ pub struct ClosureUpvar<'tcx> {
 
 #[derive(Clone, Copy, PartialEq)]
 pub enum IntVarValue {
-    IntType(hir::IntTy),
-    UintType(hir::UintTy),
+    IntType(ast::IntTy),
+    UintType(ast::UintTy),
 }
 
 /// Default region to use for the bound of objects that are
@@ -2337,7 +2337,7 @@ pub fn lookup_super_predicates(&self, did: DefId) -> GenericPredicates<'tcx> {
     }
 
     /// Get the attributes of a definition.
-    pub fn get_attrs(&self, did: DefId) -> Cow<'tcx, [hir::Attribute]> {
+    pub fn get_attrs(&self, did: DefId) -> Cow<'tcx, [ast::Attribute]> {
         if did.is_local() {
             Cow::Borrowed(self.map.attrs(did.node))
         } else {
index 3969738a22e86b94278bb4042612ff9065ddd506..2d578fd0ea54301d20594fddb6d96e145a85058f 100644 (file)
@@ -23,7 +23,7 @@
 use std::ops;
 use std::mem;
 use syntax::abi;
-use syntax::ast::{Name, NodeId};
+use syntax::ast::{self, Name, NodeId};
 use syntax::parse::token::special_idents;
 
 use rustc_front::hir;
@@ -79,13 +79,13 @@ pub enum TypeVariants<'tcx> {
     TyChar,
 
     /// A primitive signed integer type. For example, `i32`.
-    TyInt(hir::IntTy),
+    TyInt(ast::IntTy),
 
     /// A primitive unsigned integer type. For example, `u32`.
-    TyUint(hir::UintTy),
+    TyUint(ast::UintTy),
 
     /// A primitive floating-point type. For example, `f64`.
-    TyFloat(hir::FloatTy),
+    TyFloat(ast::FloatTy),
 
     /// An enumerated type, defined with `enum`.
     ///
@@ -93,7 +93,7 @@ pub enum TypeVariants<'tcx> {
     /// That is, even after substitution it is possible that there are type
     /// variables. This happens when the `TyEnum` corresponds to an enum
     /// definition and not a concrete use of it. To get the correct `TyEnum`
-    /// from the tcx, use the `NodeId` from the `hir::Ty` and look it up in
+    /// from the tcx, use the `NodeId` from the `ast::Ty` and look it up in
     /// the `ast_ty_to_ty_cache`. This is probably true for `TyStruct` as
     /// well.
     TyEnum(AdtDef<'tcx>, &'tcx Substs<'tcx>),
@@ -944,7 +944,7 @@ pub fn is_simd(&self) -> bool {
     pub fn sequence_element_type(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
         match self.sty {
             TyArray(ty, _) | TySlice(ty) => ty,
-            TyStr => cx.mk_mach_uint(hir::TyU8),
+            TyStr => cx.mk_mach_uint(ast::TyU8),
             _ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
                                       self)),
         }
@@ -1035,7 +1035,7 @@ pub fn is_fresh(&self) -> bool {
 
     pub fn is_uint(&self) -> bool {
         match self.sty {
-            TyInfer(IntVar(_)) | TyUint(hir::TyUs) => true,
+            TyInfer(IntVar(_)) | TyUint(ast::TyUs) => true,
             _ => false
         }
     }
@@ -1081,7 +1081,7 @@ pub fn is_signed(&self) -> bool {
 
     pub fn is_machine(&self) -> bool {
         match self.sty {
-            TyInt(hir::TyIs) | TyUint(hir::TyUs) => false,
+            TyInt(ast::TyIs) | TyUint(ast::TyUs) => false,
             TyInt(..) | TyUint(..) | TyFloat(..) => true,
             _ => false
         }
index 883146185357610d07635437095106548b24a59f..3a90f3e0136e50d008b65b441e09deeede4b18e8 100644 (file)
 
 use std::cmp;
 use std::hash::{Hash, SipHasher, Hasher};
-use syntax::ast::Name;
+use syntax::ast::{self, Name};
+use syntax::attr::{self, AttrMetaMethods, SignedInt, UnsignedInt};
 use syntax::codemap::Span;
 
 use rustc_front::hir;
-use rustc_front::attr::{self, AttrMetaMethods, SignedInt, UnsignedInt};
 
 pub trait IntTypeExt {
     fn to_ty<'tcx>(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx>;
@@ -44,48 +44,48 @@ pub trait IntTypeExt {
 impl IntTypeExt for attr::IntType {
     fn to_ty<'tcx>(&self, cx: &ty::ctxt<'tcx>) -> Ty<'tcx> {
         match *self {
-            SignedInt(hir::TyI8)      => cx.types.i8,
-            SignedInt(hir::TyI16)     => cx.types.i16,
-            SignedInt(hir::TyI32)     => cx.types.i32,
-            SignedInt(hir::TyI64)     => cx.types.i64,
-            SignedInt(hir::TyIs)   => cx.types.isize,
-            UnsignedInt(hir::TyU8)    => cx.types.u8,
-            UnsignedInt(hir::TyU16)   => cx.types.u16,
-            UnsignedInt(hir::TyU32)   => cx.types.u32,
-            UnsignedInt(hir::TyU64)   => cx.types.u64,
-            UnsignedInt(hir::TyUs) => cx.types.usize,
+            SignedInt(ast::TyI8)      => cx.types.i8,
+            SignedInt(ast::TyI16)     => cx.types.i16,
+            SignedInt(ast::TyI32)     => cx.types.i32,
+            SignedInt(ast::TyI64)     => cx.types.i64,
+            SignedInt(ast::TyIs)   => cx.types.isize,
+            UnsignedInt(ast::TyU8)    => cx.types.u8,
+            UnsignedInt(ast::TyU16)   => cx.types.u16,
+            UnsignedInt(ast::TyU32)   => cx.types.u32,
+            UnsignedInt(ast::TyU64)   => cx.types.u64,
+            UnsignedInt(ast::TyUs) => cx.types.usize,
         }
     }
 
     fn i64_to_disr(&self, val: i64) -> Option<Disr> {
         match *self {
-            SignedInt(hir::TyI8)    => val.to_i8()  .map(|v| v as Disr),
-            SignedInt(hir::TyI16)   => val.to_i16() .map(|v| v as Disr),
-            SignedInt(hir::TyI32)   => val.to_i32() .map(|v| v as Disr),
-            SignedInt(hir::TyI64)   => val.to_i64() .map(|v| v as Disr),
-            UnsignedInt(hir::TyU8)  => val.to_u8()  .map(|v| v as Disr),
-            UnsignedInt(hir::TyU16) => val.to_u16() .map(|v| v as Disr),
-            UnsignedInt(hir::TyU32) => val.to_u32() .map(|v| v as Disr),
-            UnsignedInt(hir::TyU64) => val.to_u64() .map(|v| v as Disr),
-
-            UnsignedInt(hir::TyUs) |
-            SignedInt(hir::TyIs) => unreachable!(),
+            SignedInt(ast::TyI8)    => val.to_i8()  .map(|v| v as Disr),
+            SignedInt(ast::TyI16)   => val.to_i16() .map(|v| v as Disr),
+            SignedInt(ast::TyI32)   => val.to_i32() .map(|v| v as Disr),
+            SignedInt(ast::TyI64)   => val.to_i64() .map(|v| v as Disr),
+            UnsignedInt(ast::TyU8)  => val.to_u8()  .map(|v| v as Disr),
+            UnsignedInt(ast::TyU16) => val.to_u16() .map(|v| v as Disr),
+            UnsignedInt(ast::TyU32) => val.to_u32() .map(|v| v as Disr),
+            UnsignedInt(ast::TyU64) => val.to_u64() .map(|v| v as Disr),
+
+            UnsignedInt(ast::TyUs) |
+            SignedInt(ast::TyIs) => unreachable!(),
         }
     }
 
     fn u64_to_disr(&self, val: u64) -> Option<Disr> {
         match *self {
-            SignedInt(hir::TyI8)    => val.to_i8()  .map(|v| v as Disr),
-            SignedInt(hir::TyI16)   => val.to_i16() .map(|v| v as Disr),
-            SignedInt(hir::TyI32)   => val.to_i32() .map(|v| v as Disr),
-            SignedInt(hir::TyI64)   => val.to_i64() .map(|v| v as Disr),
-            UnsignedInt(hir::TyU8)  => val.to_u8()  .map(|v| v as Disr),
-            UnsignedInt(hir::TyU16) => val.to_u16() .map(|v| v as Disr),
-            UnsignedInt(hir::TyU32) => val.to_u32() .map(|v| v as Disr),
-            UnsignedInt(hir::TyU64) => val.to_u64() .map(|v| v as Disr),
-
-            UnsignedInt(hir::TyUs) |
-            SignedInt(hir::TyIs) => unreachable!(),
+            SignedInt(ast::TyI8)    => val.to_i8()  .map(|v| v as Disr),
+            SignedInt(ast::TyI16)   => val.to_i16() .map(|v| v as Disr),
+            SignedInt(ast::TyI32)   => val.to_i32() .map(|v| v as Disr),
+            SignedInt(ast::TyI64)   => val.to_i64() .map(|v| v as Disr),
+            UnsignedInt(ast::TyU8)  => val.to_u8()  .map(|v| v as Disr),
+            UnsignedInt(ast::TyU16) => val.to_u16() .map(|v| v as Disr),
+            UnsignedInt(ast::TyU32) => val.to_u32() .map(|v| v as Disr),
+            UnsignedInt(ast::TyU64) => val.to_u64() .map(|v| v as Disr),
+
+            UnsignedInt(ast::TyUs) |
+            SignedInt(ast::TyIs) => unreachable!(),
         }
     }
 
@@ -97,18 +97,18 @@ macro_rules! add1 {
             // SignedInt repr means we *want* to reinterpret the bits
             // treating the highest bit of Disr as a sign-bit, so
             // cast to i64 before range-checking.
-            SignedInt(hir::TyI8)    => add1!((val as i64).to_i8()),
-            SignedInt(hir::TyI16)   => add1!((val as i64).to_i16()),
-            SignedInt(hir::TyI32)   => add1!((val as i64).to_i32()),
-            SignedInt(hir::TyI64)   => add1!(Some(val as i64)),
-
-            UnsignedInt(hir::TyU8)  => add1!(val.to_u8()),
-            UnsignedInt(hir::TyU16) => add1!(val.to_u16()),
-            UnsignedInt(hir::TyU32) => add1!(val.to_u32()),
-            UnsignedInt(hir::TyU64) => add1!(Some(val)),
-
-            UnsignedInt(hir::TyUs) |
-            SignedInt(hir::TyIs) => unreachable!(),
+            SignedInt(ast::TyI8)    => add1!((val as i64).to_i8()),
+            SignedInt(ast::TyI16)   => add1!((val as i64).to_i16()),
+            SignedInt(ast::TyI32)   => add1!((val as i64).to_i32()),
+            SignedInt(ast::TyI64)   => add1!(Some(val as i64)),
+
+            UnsignedInt(ast::TyU8)  => add1!(val.to_u8()),
+            UnsignedInt(ast::TyU16) => add1!(val.to_u16()),
+            UnsignedInt(ast::TyU32) => add1!(val.to_u32()),
+            UnsignedInt(ast::TyU64) => add1!(Some(val)),
+
+            UnsignedInt(ast::TyUs) |
+            SignedInt(ast::TyIs) => unreachable!(),
         }
     }
 
@@ -117,17 +117,17 @@ macro_rules! add1 {
     // full range from `i64::MIN` through `u64::MAX`.
     fn disr_string(&self, val: Disr) -> String {
         match *self {
-            SignedInt(hir::TyI8)    => format!("{}", val as i8 ),
-            SignedInt(hir::TyI16)   => format!("{}", val as i16),
-            SignedInt(hir::TyI32)   => format!("{}", val as i32),
-            SignedInt(hir::TyI64)   => format!("{}", val as i64),
-            UnsignedInt(hir::TyU8)  => format!("{}", val as u8 ),
-            UnsignedInt(hir::TyU16) => format!("{}", val as u16),
-            UnsignedInt(hir::TyU32) => format!("{}", val as u32),
-            UnsignedInt(hir::TyU64) => format!("{}", val as u64),
-
-            UnsignedInt(hir::TyUs) |
-            SignedInt(hir::TyIs) => unreachable!(),
+            SignedInt(ast::TyI8)    => format!("{}", val as i8 ),
+            SignedInt(ast::TyI16)   => format!("{}", val as i16),
+            SignedInt(ast::TyI32)   => format!("{}", val as i32),
+            SignedInt(ast::TyI64)   => format!("{}", val as i64),
+            UnsignedInt(ast::TyU8)  => format!("{}", val as u8 ),
+            UnsignedInt(ast::TyU16) => format!("{}", val as u16),
+            UnsignedInt(ast::TyU32) => format!("{}", val as u32),
+            UnsignedInt(ast::TyU64) => format!("{}", val as u64),
+
+            UnsignedInt(ast::TyUs) |
+            SignedInt(ast::TyIs) => unreachable!(),
         }
     }
 
@@ -137,17 +137,17 @@ macro_rules! add1 {
         }
         let val = val.unwrap_or(ty::INITIAL_DISCRIMINANT_VALUE);
         match *self {
-            SignedInt(hir::TyI8)    => add1!(val as i8 ),
-            SignedInt(hir::TyI16)   => add1!(val as i16),
-            SignedInt(hir::TyI32)   => add1!(val as i32),
-            SignedInt(hir::TyI64)   => add1!(val as i64),
-            UnsignedInt(hir::TyU8)  => add1!(val as u8 ),
-            UnsignedInt(hir::TyU16) => add1!(val as u16),
-            UnsignedInt(hir::TyU32) => add1!(val as u32),
-            UnsignedInt(hir::TyU64) => add1!(val as u64),
-
-            UnsignedInt(hir::TyUs) |
-            SignedInt(hir::TyIs) => unreachable!(),
+            SignedInt(ast::TyI8)    => add1!(val as i8 ),
+            SignedInt(ast::TyI16)   => add1!(val as i16),
+            SignedInt(ast::TyI32)   => add1!(val as i32),
+            SignedInt(ast::TyI64)   => add1!(val as i64),
+            UnsignedInt(ast::TyU8)  => add1!(val as u8 ),
+            UnsignedInt(ast::TyU16) => add1!(val as u16),
+            UnsignedInt(ast::TyU32) => add1!(val as u32),
+            UnsignedInt(ast::TyU64) => add1!(val as u64),
+
+            UnsignedInt(ast::TyUs) |
+            SignedInt(ast::TyIs) => unreachable!(),
         }
     }
 }
@@ -279,14 +279,14 @@ pub fn enum_repr_type(&self, opt_hint: Option<&attr::ReprAttr>)
             //
             // NB. Historically `fn enum_variants` generate i64 here, while
             // rustc_typeck::check would generate isize.
-            _ => SignedInt(hir::TyIs),
+            _ => SignedInt(ast::TyIs),
         };
 
         let repr_type_ty = repr_type.to_ty(self);
         let repr_type = match repr_type {
-            SignedInt(hir::TyIs) =>
+            SignedInt(ast::TyIs) =>
                 SignedInt(self.sess.target.int_type),
-            UnsignedInt(hir::TyUs) =>
+            UnsignedInt(ast::TyUs) =>
                 UnsignedInt(self.sess.target.uint_type),
             other => other
         };
index 43b7943fd2096f88bf999fa5d5583574a01269b6..96c8e5c7d5218cddbf35bc9536604b3b3d60cff4 100644 (file)
@@ -15,6 +15,7 @@
 use metadata::csearch;
 use middle::lang_items;
 
+use syntax::ast;
 use syntax::codemap::Span;
 use syntax::parse::token::InternedString;
 use rustc_front::visit::Visitor;
@@ -54,7 +55,7 @@ pub fn check_crate(krate: &hir::Crate,
     verify(sess, items);
 }
 
-pub fn link_name(attrs: &[hir::Attribute]) -> Option<InternedString> {
+pub fn link_name(attrs: &[ast::Attribute]) -> Option<InternedString> {
     lang_items::extract(attrs).and_then(|name| {
         $(if &name[..] == stringify!($name) {
             Some(InternedString::new(stringify!($sym)))
index 55fd63b7534721a4943d16c6572c24e314ae85f5..ea85b264261cd2d7027e3b7d2753be4700940674 100644 (file)
 //! Used by `rustc` when compiling a plugin crate.
 
 use syntax::ast;
+use syntax::attr;
 use syntax::codemap::Span;
 use syntax::diagnostic;
 use rustc_front::visit;
 use rustc_front::visit::Visitor;
 use rustc_front::hir;
-use rustc_front::attr;
 
 struct RegistrarFinder {
     registrars: Vec<(ast::NodeId, Span)> ,
index b56283e756723c965fd8c7ccfef15d7bc1755096..ad0eb4d53fe26b837d98e167d912ecb576375515 100644 (file)
 use lint;
 use metadata::cstore;
 
-use syntax::ast;
-use rustc_front::hir::{IntTy, UintTy};
+use syntax::ast::{self, IntTy, UintTy};
 use syntax::attr;
 use syntax::attr::AttrMetaMethods;
-use rustc_front::hir;
 use syntax::diagnostic::{ColorConfig, Auto, Always, Never, SpanHandler};
 use syntax::parse;
 use syntax::parse::token::InternedString;
@@ -669,8 +667,8 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
     };
 
     let (int_type, uint_type) = match &target.target_pointer_width[..] {
-        "32" => (hir::TyI32, hir::TyU32),
-        "64" => (hir::TyI64, hir::TyU64),
+        "32" => (ast::TyI32, ast::TyU32),
+        "64" => (ast::TyI64, ast::TyU64),
         w    => sp.handler().fatal(&format!("target specification was invalid: unrecognized \
                                              target-pointer-width {}", w))
     };
index fee60d46dc0019b7436f4986015124092c2e74d8..68bfa42f6f6cbd4623c1c342cea1705f1f1cf559 100644 (file)
 
 use std::fmt;
 use syntax::abi;
+use syntax::ast;
 use syntax::parse::token;
 use syntax::ast::DUMMY_NODE_ID;
-use rustc_front::hir as ast;
+use rustc_front::hir;
 
 pub fn verbose() -> bool {
     ty::tls::with(|tcx| tcx.sess.verbose())
@@ -334,7 +335,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 impl<'tcx> fmt::Display for ty::TypeAndMut<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}{}",
-               if self.mutbl == ast::MutMutable { "mut " } else { "" },
+               if self.mutbl == hir::MutMutable { "mut " } else { "" },
                self.ty)
     }
 }
@@ -825,8 +826,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             TyBox(typ) => write!(f, "Box<{}>",  typ),
             TyRawPtr(ref tm) => {
                 write!(f, "*{} {}", match tm.mutbl {
-                    ast::MutMutable => "mut",
-                    ast::MutImmutable => "const",
+                    hir::MutMutable => "mut",
+                    hir::MutImmutable => "const",
                 },  tm.ty)
             }
             TyRef(r, ref tm) => {
@@ -853,7 +854,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 write!(f, ")")
             }
             TyBareFn(opt_def_id, ref bare_fn) => {
-                if bare_fn.unsafety == ast::Unsafety::Unsafe {
+                if bare_fn.unsafety == hir::Unsafety::Unsafe {
                     try!(write!(f, "unsafe "));
                 }
 
@@ -966,10 +967,10 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.write_str(match *self {
             ty::StaticExplicitSelfCategory => "static",
             ty::ByValueExplicitSelfCategory => "self",
-            ty::ByReferenceExplicitSelfCategory(_, ast::MutMutable) => {
+            ty::ByReferenceExplicitSelfCategory(_, hir::MutMutable) => {
                 "&mut self"
             }
-            ty::ByReferenceExplicitSelfCategory(_, ast::MutImmutable) => "&self",
+            ty::ByReferenceExplicitSelfCategory(_, hir::MutImmutable) => "&self",
             ty::ByBoxExplicitSelfCategory => "Box<self>",
         })
     }
index 5f6bf939fb2a8ec0103e0ec13b202d091ff12f5a..36fc814234d7f61da6590a72249426ffd033c141 100644 (file)
@@ -232,7 +232,7 @@ pub enum SawExprComponent<'a> {
         SawExprTup,
         SawExprBinary(hir::BinOp_),
         SawExprUnary(hir::UnOp),
-        SawExprLit(hir::Lit_),
+        SawExprLit(ast::Lit_),
         SawExprCast,
         SawExprIf,
         SawExprWhile,
index 86b6314b57cc114da522b3995b6dcdf629321aeb..cecbeacadecce738b6f2d4a02b13550ed28b028f 100644 (file)
@@ -28,7 +28,7 @@
 use std::rc::Rc;
 use syntax::ast;
 use syntax::codemap::Span;
-use rustc_front::attr::AttrMetaMethods;
+use syntax::attr::AttrMetaMethods;
 
 #[derive(PartialEq, Eq, PartialOrd, Ord)]
 enum Fragment {
index 53beb6d312d896233abb2edcb1dc97ae7e4eba83..dc36a4ab93c6aefb4ea637b6e3a64f566494e64a 100644 (file)
@@ -32,6 +32,7 @@
 use syntax::codemap;
 use syntax::fold::{self, Folder};
 use syntax::print::{pp, pprust};
+use syntax::print::pprust::PrintState;
 use syntax::ptr::P;
 use syntax::util::small_vector::SmallVector;
 
index 8609fd9b9d965b939b50ce06e109a92435ed021a..7041f29cffff8d9d9b5ddbf7873435bfcf352878 100644 (file)
@@ -15,8 +15,6 @@
 pub use self::IntType::*;
 
 use hir;
-use hir::{AttrId, Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList};
-use lowering::{lower_attr_style, unlower_attribute};
 use syntax::codemap::{Span, Spanned, spanned, dummy_spanned};
 use syntax::codemap::BytePos;
 use syntax::diagnostic::SpanHandler;
index ba20b46090afc9aa9e357d15a517cfdd13fafb87..0ff972f830f011f9aaa911f775a538d311471fca 100644 (file)
@@ -12,7 +12,8 @@
 //! and returns a piece of the same type.
 
 use hir::*;
-use syntax::ast::{Ident, NodeId, DUMMY_NODE_ID};
+use syntax::ast::{Ident, NodeId, DUMMY_NODE_ID, Attribute, Attribute_, MetaItem};
+use syntax::ast::{MetaWord, MetaList, MetaNameValue};
 use hir;
 use syntax::codemap::{respan, Span, Spanned};
 use syntax::owned_slice::OwnedSlice;
index f8f17617310b7b4ef2beef790a21fa224cb66a33..f329aa49daabc63e599a20e22096ec07c9f03966 100644 (file)
@@ -11,7 +11,6 @@
 // The Rust HIR.
 
 pub use self::AsmDialect::*;
-pub use self::AttrStyle::*;
 pub use self::BindingMode::*;
 pub use self::BinOp_::*;
 pub use self::BlockCheckMode::*;
 pub use self::Decl_::*;
 pub use self::ExplicitSelf_::*;
 pub use self::Expr_::*;
-pub use self::FloatTy::*;
 pub use self::FunctionRetTy::*;
 pub use self::ForeignItem_::*;
 pub use self::ImplItem_::*;
-pub use self::IntTy::*;
 pub use self::Item_::*;
-pub use self::Lit_::*;
-pub use self::LitIntType::*;
-pub use self::MetaItem_::*;
 pub use self::Mutability::*;
 pub use self::Pat_::*;
 pub use self::PathListItem_::*;
 pub use self::PatWildKind::*;
 pub use self::PrimTy::*;
-pub use self::Sign::*;
 pub use self::Stmt_::*;
-pub use self::StrStyle::*;
 pub use self::StructFieldKind::*;
 pub use self::TraitItem_::*;
 pub use self::Ty_::*;
 pub use self::TyParamBound::*;
-pub use self::UintTy::*;
 pub use self::UnOp::*;
 pub use self::UnsafeSource::*;
 pub use self::VariantKind::*;
@@ -51,6 +42,7 @@
 use syntax::codemap::{self, Span, Spanned, DUMMY_SP, ExpnId};
 use syntax::abi::Abi;
 use syntax::ast::{Name, Ident, NodeId, DUMMY_NODE_ID, TokenTree};
+use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, CrateConfig};
 use syntax::owned_slice::OwnedSlice;
 use syntax::parse::token::InternedString;
 use syntax::ptr::P;
@@ -59,7 +51,6 @@
 use util;
 
 use std::fmt;
-use std::rc::Rc;
 use serialize::{Encodable, Encoder, Decoder};
 
 
@@ -333,10 +324,6 @@ pub struct WhereEqPredicate {
     pub ty: P<Ty>,
 }
 
-/// The set of MetaItems that define the compilation environment of the crate,
-/// used to drive conditional compilation
-pub type CrateConfig = Vec<P<MetaItem>> ;
-
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 pub struct Crate {
     pub module: Mod,
@@ -362,40 +349,6 @@ pub struct MacroDef {
     pub body: Vec<TokenTree>,
 }
 
-pub type MetaItem = Spanned<MetaItem_>;
-
-#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
-pub enum MetaItem_ {
-    MetaWord(InternedString),
-    MetaList(InternedString, Vec<P<MetaItem>>),
-    MetaNameValue(InternedString, Lit),
-}
-
-// can't be derived because the MetaList requires an unordered comparison
-impl PartialEq for MetaItem_ {
-    fn eq(&self, other: &MetaItem_) -> bool {
-        match *self {
-            MetaWord(ref ns) => match *other {
-                MetaWord(ref no) => (*ns) == (*no),
-                _ => false
-            },
-            MetaNameValue(ref ns, ref vs) => match *other {
-                MetaNameValue(ref no, ref vo) => {
-                    (*ns) == (*no) && vs.node == vo.node
-                }
-                _ => false
-            },
-            MetaList(ref ns, ref miss) => match *other {
-                MetaList(ref no, ref miso) => {
-                    ns == no &&
-                        miss.iter().all(|mi| miso.iter().any(|x| x.node == mi.node))
-                }
-                _ => false
-            }
-        }
-    }
-}
-
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 pub struct Block {
     /// Statements in a block
@@ -787,72 +740,6 @@ pub enum CaptureClause {
     CaptureByRef,
 }
 
-
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
-pub enum StrStyle {
-    /// A regular string, like `"foo"`
-    CookedStr,
-    /// A raw string, like `r##"foo"##`
-    ///
-    /// The uint is the number of `#` symbols used
-    RawStr(usize)
-}
-
-/// A literal
-pub type Lit = Spanned<Lit_>;
-
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
-pub enum Sign {
-    Minus,
-    Plus
-}
-
-impl Sign {
-    pub fn new<T: IntSign>(n: T) -> Sign {
-        n.sign()
-    }
-}
-
-pub trait IntSign {
-    fn sign(&self) -> Sign;
-}
-macro_rules! doit {
-    ($($t:ident)*) => ($(impl IntSign for $t {
-        #[allow(unused_comparisons)]
-        fn sign(&self) -> Sign {
-            if *self < 0 {Minus} else {Plus}
-        }
-    })*)
-}
-doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
-
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
-pub enum LitIntType {
-    SignedIntLit(IntTy, Sign),
-    UnsignedIntLit(UintTy),
-    UnsuffixedIntLit(Sign)
-}
-
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
-pub enum Lit_ {
-    /// A string literal (`"foo"`)
-    LitStr(InternedString, StrStyle),
-    /// A byte string (`b"foo"`)
-    LitByteStr(Rc<Vec<u8>>),
-    /// A byte char (`b'f'`)
-    LitByte(u8),
-    /// A character literal (`'a'`)
-    LitChar(char),
-    /// An integer literal (`1u8`)
-    LitInt(u64, LitIntType),
-    /// A float literal (`1f64` or `1E10f64`)
-    LitFloat(InternedString, FloatTy),
-    /// A float literal without a suffix (`1.0 or 1.0E10`)
-    LitFloatUnsuffixed(InternedString),
-    /// A boolean literal
-    LitBool(bool),
-}
-
 // NB: If you change this, you'll probably want to change the corresponding
 // type structure in middle/ty.rs as well.
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
@@ -917,99 +804,6 @@ pub enum ImplItem_ {
     TypeImplItem(P<Ty>),
 }
 
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
-pub enum IntTy {
-    TyIs,
-    TyI8,
-    TyI16,
-    TyI32,
-    TyI64,
-}
-
-impl fmt::Debug for IntTy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        fmt::Display::fmt(self, f)
-    }
-}
-
-impl fmt::Display for IntTy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", util::int_ty_to_string(*self, None))
-    }
-}
-
-impl IntTy {
-    pub fn bit_width(&self) -> Option<usize> {
-        Some(match *self {
-            TyIs => return None,
-            TyI8 => 8,
-            TyI16 => 16,
-            TyI32 => 32,
-            TyI64 => 64,
-        })
-    }
-}
-
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
-pub enum UintTy {
-    TyUs,
-    TyU8,
-    TyU16,
-    TyU32,
-    TyU64,
-}
-
-impl UintTy {
-    pub fn bit_width(&self) -> Option<usize> {
-        Some(match *self {
-            TyUs => return None,
-            TyU8 => 8,
-            TyU16 => 16,
-            TyU32 => 32,
-            TyU64 => 64,
-        })
-    }
-}
-
-impl fmt::Debug for UintTy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        fmt::Display::fmt(self, f)
-    }
-}
-
-impl fmt::Display for UintTy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", util::uint_ty_to_string(*self, None))
-    }
-}
-
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
-pub enum FloatTy {
-    TyF32,
-    TyF64,
-}
-
-impl fmt::Debug for FloatTy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        fmt::Display::fmt(self, f)
-    }
-}
-
-impl fmt::Display for FloatTy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", util::float_ty_to_string(*self))
-    }
-}
-
-impl FloatTy {
-    pub fn bit_width(&self) -> usize {
-        match *self {
-            TyF32 => 32,
-            TyF64 => 64,
-        }
-    }
-}
-
 // Bind a type to an associated type: `A=Foo`.
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 pub struct TypeBinding {
@@ -1316,30 +1110,6 @@ pub enum ViewPath_ {
     ViewPathList(Path, Vec<PathListItem>)
 }
 
-/// Meta-data associated with an item
-pub type Attribute = Spanned<Attribute_>;
-
-/// Distinguishes between Attributes that decorate items and Attributes that
-/// are contained as statements within items. These two cases need to be
-/// distinguished for pretty-printing.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
-pub enum AttrStyle {
-    AttrOuter,
-    AttrInner,
-}
-
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
-pub struct AttrId(pub usize);
-
-/// Doc-comments are promoted to attributes that have is_sugared_doc = true
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
-pub struct Attribute_ {
-    pub id: AttrId,
-    pub style: AttrStyle,
-    pub value: P<MetaItem>,
-    pub is_sugared_doc: bool,
-}
-
 /// TraitRef's appear in impls.
 ///
 /// resolve maps each TraitRef's ref_id to its defining trait; that's all
index fae4f15725534333e423ee3b17606ef92a8fb381..4c6d8505c81f02fdaa1e19bf2e5e91edfb09021a 100644 (file)
@@ -36,7 +36,6 @@
 #![feature(staged_api)]
 #![feature(str_char)]
 #![feature(filling_drop)]
-#![feature(str_escape)]
 #![cfg_attr(test, feature(test))]
 
 extern crate serialize;
@@ -50,7 +49,6 @@
 pub mod lowering;
 pub mod fold;
 pub mod visit;
-pub mod attr;
 pub mod util;
 
 pub mod print {
index aa7545d52d11e1eb6805a14d397e87c239b1c1c9..38f9ec2c8e6bc71c97057170e7f5a8e296e5660c 100644 (file)
 use syntax::owned_slice::OwnedSlice;
 
 
-pub fn lower_meta_items(meta_items: &Vec<P<MetaItem>>) -> Vec<P<hir::MetaItem>> {
-    meta_items.iter().map(|x| lower_meta_item(x)).collect()
-}
-
 pub fn lower_view_path(view_path: &ViewPath) -> P<hir::ViewPath> {
     P(Spanned {
         node: match view_path.node {
@@ -54,13 +50,9 @@ pub fn lower_view_path(view_path: &ViewPath) -> P<hir::ViewPath> {
     })
 }
 
-pub fn lower_attrs(attrs: &Vec<Attribute>) -> Vec<hir::Attribute> {
-    attrs.iter().map(|x| lower_attribute(x)).collect()
-}
-
 pub fn lower_arm(arm: &Arm) -> hir::Arm {
     hir::Arm {
-        attrs: lower_attrs(&arm.attrs),
+        attrs: arm.attrs.clone(),
         pats: arm.pats.iter().map(|x| lower_pat(x)).collect(),
         guard: arm.guard.as_ref().map(|ref x| lower_expr(x)),
         body: lower_expr(&arm.body),
@@ -144,7 +136,7 @@ pub fn lower_variant(v: &Variant) -> P<hir::Variant> {
         node: hir::Variant_ {
             id: v.node.id,
             name: v.node.name,
-            attrs: lower_attrs(&v.node.attrs),
+            attrs: v.node.attrs.clone(),
             kind: match v.node.kind {
                 TupleVariantKind(ref variant_args) => {
                     hir::TupleVariantKind(variant_args.iter().map(|ref x|
@@ -212,31 +204,6 @@ pub fn lower_local(l: &Local) -> P<hir::Local> {
         })
 }
 
-pub fn lower_attribute(at: &Attribute) -> hir::Attribute {
-    Spanned {
-        node: hir::Attribute_ {
-            id: hir::AttrId(at.node.id.0),
-            style: lower_attr_style(at.node.style),
-            value: lower_meta_item(&at.node.value),
-            is_sugared_doc: at.node.is_sugared_doc,
-        },
-        span: at.span,
-    }
-}
-
-// FIXME we should probably just unify hir and ast Attributes.
-pub fn unlower_attribute(at: &hir::Attribute) -> Attribute {
-    Spanned {
-        node: Attribute_ {
-            id: AttrId(at.node.id.0),
-            style: unlower_attr_style(at.node.style),
-            value: unlower_meta_item(&at.node.value),
-            is_sugared_doc: at.node.is_sugared_doc,
-        },
-        span: at.span,
-    }
-}
-
 pub fn lower_explicit_self_underscore(es: &ExplicitSelf_) -> hir::ExplicitSelf_ {
     match *es {
         SelfStatic => hir::SelfStatic,
@@ -261,33 +228,6 @@ pub fn lower_explicit_self(s: &ExplicitSelf) -> hir::ExplicitSelf {
     Spanned { node: lower_explicit_self_underscore(&s.node), span: s.span }
 }
 
-
-pub fn lower_meta_item(mi: &MetaItem) -> P<hir::MetaItem> {
-    P(Spanned {
-        node: match mi.node {
-            MetaWord(ref id) => hir::MetaWord(id.clone()),
-            MetaList(ref id, ref mis) => {
-                hir::MetaList(id.clone(), mis.iter().map(|mi| lower_meta_item(mi)).collect())
-            }
-            MetaNameValue(ref id, ref s) => hir::MetaNameValue(id.clone(), lower_lit(s))
-        },
-        span: mi.span,
-    })
-}
-
-pub fn unlower_meta_item(mi: &hir::MetaItem) -> P<MetaItem> {
-    P(Spanned {
-        node: match mi.node {
-            hir::MetaWord(ref id) => MetaWord(id.clone()),
-            hir::MetaList(ref id, ref mis) => {
-                MetaList(id.clone(), mis.iter().map(|mi| unlower_meta_item(mi)).collect())
-            }
-            hir::MetaNameValue(ref id, ref s) => MetaNameValue(id.clone(), unlower_lit(s))
-        },
-        span: mi.span,
-    })
-}
-
 pub fn lower_arg(arg: &Arg) -> hir::Arg {
     hir::Arg { id: arg.id, pat: lower_pat(&arg.pat), ty: lower_ty(&arg.ty) }
 }
@@ -424,7 +364,7 @@ pub fn lower_struct_field(f: &StructField) -> hir::StructField {
             id: f.node.id,
             kind: lower_struct_field_kind(&f.node.kind),
             ty: lower_ty(&f.node.ty),
-            attrs: lower_attrs(&f.node.attrs),
+            attrs: f.node.attrs.clone(),
         },
         span: f.span,
     }
@@ -528,7 +468,7 @@ pub fn lower_trait_item(i: &TraitItem) -> P<hir::TraitItem> {
     P(hir::TraitItem {
             id: i.id,
             ident: i.ident,
-            attrs: lower_attrs(&i.attrs),
+            attrs: i.attrs.clone(),
             node: match i.node {
             ConstTraitItem(ref ty, ref default) => {
                 hir::ConstTraitItem(lower_ty(ty),
@@ -551,7 +491,7 @@ pub fn lower_impl_item(i: &ImplItem) -> P<hir::ImplItem> {
     P(hir::ImplItem {
             id: i.id,
             ident: i.ident,
-            attrs: lower_attrs(&i.attrs),
+            attrs: i.attrs.clone(),
             vis: lower_visibility(i.vis),
             node: match i.node  {
             ConstImplItem(ref ty, ref expr) => {
@@ -573,12 +513,10 @@ pub fn lower_mod(m: &Mod) -> hir::Mod {
 }
 
 pub fn lower_crate(c: &Crate) -> hir::Crate {
-    let config = lower_meta_items(&c.config);
-
     hir::Crate {
         module: lower_mod(&c.module),
-        attrs: lower_attrs(&c.attrs),
-        config: config,
+        attrs: c.attrs.clone(),
+        config: c.config.clone(),
         span: c.span,
         exported_macros: c.exported_macros.iter().map(|m| lower_macro_def(m)).collect(),
     }
@@ -587,7 +525,7 @@ pub fn lower_crate(c: &Crate) -> hir::Crate {
 pub fn lower_macro_def(m: &MacroDef) -> hir::MacroDef {
     hir::MacroDef {
         ident: m.ident,
-        attrs: m.attrs.iter().map(|a| lower_attribute(a)).collect(),
+        attrs: m.attrs.clone(),
         id: m.id,
         span: m.span,
         imported_from: m.imported_from,
@@ -610,7 +548,7 @@ pub fn lower_item_simple(i: &Item) -> hir::Item {
     hir::Item {
         id: i.id,
         ident: i.ident,
-        attrs: lower_attrs(&i.attrs),
+        attrs: i.attrs.clone(),
         node: node,
         vis: lower_visibility(i.vis),
         span: i.span,
@@ -621,7 +559,7 @@ pub fn lower_foreign_item(i: &ForeignItem) -> P<hir::ForeignItem> {
     P(hir::ForeignItem {
             id: i.id,
             ident: i.ident,
-            attrs: lower_attrs(&i.attrs),
+            attrs: i.attrs.clone(),
             node: match i.node {
             ForeignItemFn(ref fdec, ref generics) => {
                 hir::ForeignItemFn(lower_fn_decl(fdec), lower_generics(generics))
@@ -660,37 +598,6 @@ pub fn lower_constness(c: Constness) -> hir::Constness {
     }
 }
 
-pub fn lower_lit(l: &Lit) -> hir::Lit {
-    Spanned {
-        node: match l.node {
-            LitStr(ref i, s) => hir::LitStr(i.clone(), lower_string_style(s)),
-            LitByteStr(ref b) => hir::LitByteStr(b.clone()),
-            LitByte(u) => hir::LitByte(u),
-            LitChar(c) => hir::LitChar(c),
-            LitInt(u, ref t) => hir::LitInt(u, lower_lit_int_type(t)),
-            LitFloat(ref i, t) => hir::LitFloat(i.clone(), lower_float_ty(t)),
-            LitFloatUnsuffixed(ref i) => hir::LitFloatUnsuffixed(i.clone()),
-            LitBool(b) => hir::LitBool(b),
-        },
-        span: l.span,
-    }
-}
-
-pub fn unlower_lit(l: &hir::Lit) -> Lit {
-    Spanned {
-        node: match l.node {
-            hir::LitStr(ref i, s) => LitStr(i.clone(), unlower_string_style(s)),
-            hir::LitByteStr(ref b) => LitByteStr(b.clone()),
-            hir::LitByte(u) => LitByte(u),
-            hir::LitChar(c) => LitChar(c),
-            hir::LitInt(u, ref t) => LitInt(u, unlower_lit_int_type(t)),
-            hir::LitFloat(ref i, t) => LitFloat(i.clone(), unlower_float_ty(t)),
-            hir::LitFloatUnsuffixed(ref i) => LitFloatUnsuffixed(i.clone()),
-            hir::LitBool(b) => LitBool(b),
-        },
-        span: l.span,
-    }
-}
 pub fn lower_unop(u: UnOp) -> hir::UnOp {
     match u {
         UnUniq => hir::UnUniq,
@@ -810,7 +717,7 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
                 ExprUnary(op, ref ohs) => {
                     hir::ExprUnary(lower_unop(op), lower_expr(ohs))
                 }
-                ExprLit(ref l) => hir::ExprLit(P(lower_lit(l))),
+                ExprLit(ref l) => hir::ExprLit(P((**l).clone())),
                 ExprCast(ref expr, ref ty) => {
                     hir::ExprCast(lower_expr(expr), lower_ty(ty))
                 }
@@ -891,7 +798,7 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
                         (c.clone(), lower_expr(out), *is_rw)
                     }).collect(),
                     asm: asm.clone(),
-                    asm_str_style: lower_string_style(asm_str_style),
+                    asm_str_style: asm_str_style,
                     clobbers: clobbers.clone(),
                     volatile: volatile,
                     alignstack: alignstack,
@@ -937,20 +844,6 @@ pub fn lower_stmt(s: &Stmt) -> P<hir::Stmt> {
     }
 }
 
-pub fn lower_string_style(s: StrStyle) -> hir::StrStyle {
-    match s {
-        CookedStr => hir::CookedStr,
-        RawStr(u) => hir::RawStr(u),
-    }
-}
-
-pub fn unlower_string_style(s: hir::StrStyle) -> StrStyle {
-    match s {
-        hir::CookedStr => CookedStr,
-        hir::RawStr(u) => RawStr(u),
-    }
-}
-
 pub fn lower_match_source(m: &MatchSource) -> hir::MatchSource {
     match *m {
         MatchSource::Normal => hir::MatchSource::Normal,
@@ -1027,107 +920,9 @@ pub fn lower_impl_polarity(i: ImplPolarity) -> hir::ImplPolarity {
     }
 }
 
-pub fn lower_float_ty(f: FloatTy) -> hir::FloatTy {
-    match f {
-        TyF32 => hir::TyF32,
-        TyF64 => hir::TyF64,
-    }
-}
-
-pub fn unlower_float_ty(f: hir::FloatTy) -> FloatTy {
-    match f {
-        hir::TyF32 => TyF32,
-        hir::TyF64 => TyF64,
-    }
-}
-
-pub fn lower_lit_int_type(i: &LitIntType) -> hir::LitIntType {
-    match *i {
-        SignedIntLit(i, s) => hir::SignedIntLit(lower_int_ty(i), lower_sign(s)),
-        UnsignedIntLit(u) => hir::UnsignedIntLit(lower_uint_ty(u)),
-        UnsuffixedIntLit(s) => hir::UnsuffixedIntLit(lower_sign(s)),
-    }
-}
-
-pub fn unlower_lit_int_type(i: &hir::LitIntType) -> LitIntType {
-    match *i {
-        hir::SignedIntLit(i, s) => SignedIntLit(unlower_int_ty(i), unlower_sign(s)),
-        hir::UnsignedIntLit(u) => UnsignedIntLit(unlower_uint_ty(u)),
-        hir::UnsuffixedIntLit(s) => UnsuffixedIntLit(unlower_sign(s)),
-    }
-}
-
-pub fn lower_int_ty(i: IntTy) -> hir::IntTy {
-    match i {
-        TyIs => hir::TyIs,
-        TyI8 => hir::TyI8,
-        TyI16 => hir::TyI16,
-        TyI32 => hir::TyI32,
-        TyI64 => hir::TyI64,
-    }
-}
-
-pub fn unlower_int_ty(i: hir::IntTy) -> IntTy {
-    match i {
-        hir::TyIs => TyIs,
-        hir::TyI8 => TyI8,
-        hir::TyI16 => TyI16,
-        hir::TyI32 => TyI32,
-        hir::TyI64 => TyI64,
-    }
-}
-
-pub fn lower_uint_ty(u: UintTy) -> hir::UintTy {
-    match u {
-        TyUs => hir::TyUs,
-        TyU8 => hir::TyU8,
-        TyU16 => hir::TyU16,
-        TyU32 => hir::TyU32,
-        TyU64 => hir::TyU64,
-    }
-}
-
-pub fn unlower_uint_ty(u: hir::UintTy) -> UintTy {
-    match u {
-        hir::TyUs => TyUs,
-        hir::TyU8 => TyU8,
-        hir::TyU16 => TyU16,
-        hir::TyU32 => TyU32,
-        hir::TyU64 => TyU64,
-    }
-}
-
-pub fn lower_sign(f: Sign) -> hir::Sign {
-    match f {
-        Minus => hir::Minus,
-        Plus => hir::Plus,
-    }
-}
-
-pub fn unlower_sign(f: hir::Sign) -> Sign {
-    match f {
-        hir::Minus => Minus,
-        hir::Plus => Plus,
-    }
-}
-
 pub fn lower_trait_bound_modifier(f: TraitBoundModifier) -> hir::TraitBoundModifier {
     match f {
         TraitBoundModifier::None => hir::TraitBoundModifier::None,
         TraitBoundModifier::Maybe => hir::TraitBoundModifier::Maybe,
     }
 }
-
-pub fn lower_attr_style(f: AttrStyle) -> hir::AttrStyle {
-    match f {
-        AttrOuter => hir::AttrOuter,
-        AttrInner => hir::AttrInner,
-    }
-}
-
-pub fn unlower_attr_style(f: hir::AttrStyle) -> AttrStyle {
-    match f {
-        hir::AttrOuter => AttrOuter,
-        hir::AttrInner => AttrInner,
-    }
-}
diff --git a/src/librustc_front/print/pp.rs b/src/librustc_front/print/pp.rs
deleted file mode 100644 (file)
index 7c5a464..0000000
+++ /dev/null
@@ -1,686 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! This pretty-printer is a direct reimplementation of Philip Karlton's
-//! Mesa pretty-printer, as described in appendix A of
-//!
-//!     STAN-CS-79-770: "Pretty Printing", by Derek C. Oppen.
-//!     Stanford Department of Computer Science, 1979.
-//!
-//! The algorithm's aim is to break a stream into as few lines as possible
-//! while respecting the indentation-consistency requirements of the enclosing
-//! block, and avoiding breaking at silly places on block boundaries, for
-//! example, between "x" and ")" in "x)".
-//!
-//! I am implementing this algorithm because it comes with 20 pages of
-//! documentation explaining its theory, and because it addresses the set of
-//! concerns I've seen other pretty-printers fall down on. Weirdly. Even though
-//! it's 32 years old. What can I say?
-//!
-//! Despite some redundancies and quirks in the way it's implemented in that
-//! paper, I've opted to keep the implementation here as similar as I can,
-//! changing only what was blatantly wrong, a typo, or sufficiently
-//! non-idiomatic rust that it really stuck out.
-//!
-//! In particular you'll see a certain amount of churn related to INTEGER vs.
-//! CARDINAL in the Mesa implementation. Mesa apparently interconverts the two
-//! somewhat readily? In any case, I've used usize for indices-in-buffers and
-//! ints for character-sizes-and-indentation-offsets. This respects the need
-//! for ints to "go negative" while carrying a pending-calculation balance, and
-//! helps differentiate all the numbers flying around internally (slightly).
-//!
-//! I also inverted the indentation arithmetic used in the print stack, since
-//! the Mesa implementation (somewhat randomly) stores the offset on the print
-//! stack in terms of margin-col rather than col itself. I store col.
-//!
-//! I also implemented a small change in the String token, in that I store an
-//! explicit length for the string. For most tokens this is just the length of
-//! the accompanying string. But it's necessary to permit it to differ, for
-//! encoding things that are supposed to "go on their own line" -- certain
-//! classes of comment and blank-line -- where relying on adjacent
-//! hardbreak-like Break tokens with long blankness indication doesn't actually
-//! work. To see why, consider when there is a "thing that should be on its own
-//! line" between two long blocks, say functions. If you put a hardbreak after
-//! each function (or before each) and the breaking algorithm decides to break
-//! there anyways (because the functions themselves are long) you wind up with
-//! extra blank lines. If you don't put hardbreaks you can wind up with the
-//! "thing which should be on its own line" not getting its own line in the
-//! rare case of "really small functions" or such. This re-occurs with comments
-//! and explicit blank lines. So in those cases we use a string with a payload
-//! we want isolated to a line and an explicit length that's huge, surrounded
-//! by two zero-length breaks. The algorithm will try its best to fit it on a
-//! line (which it can't) and so naturally place the content on its own line to
-//! avoid combining it with other lines and making matters even worse.
-
-use std::io;
-use std::string;
-
-#[derive(Clone, Copy, PartialEq)]
-pub enum Breaks {
-    Consistent,
-    Inconsistent,
-}
-
-#[derive(Clone, Copy)]
-pub struct BreakToken {
-    offset: isize,
-    blank_space: isize
-}
-
-#[derive(Clone, Copy)]
-pub struct BeginToken {
-    offset: isize,
-    breaks: Breaks
-}
-
-#[derive(Clone)]
-pub enum Token {
-    String(String, isize),
-    Break(BreakToken),
-    Begin(BeginToken),
-    End,
-    Eof,
-}
-
-impl Token {
-    pub fn is_eof(&self) -> bool {
-        match *self {
-            Token::Eof => true,
-            _ => false,
-        }
-    }
-
-    pub fn is_hardbreak_tok(&self) -> bool {
-        match *self {
-            Token::Break(BreakToken {
-                offset: 0,
-                blank_space: bs
-            }) if bs == SIZE_INFINITY =>
-                true,
-            _ =>
-                false
-        }
-    }
-}
-
-pub fn tok_str(token: &Token) -> String {
-    match *token {
-        Token::String(ref s, len) => format!("STR({},{})", s, len),
-        Token::Break(_) => "BREAK".to_string(),
-        Token::Begin(_) => "BEGIN".to_string(),
-        Token::End => "END".to_string(),
-        Token::Eof => "EOF".to_string()
-    }
-}
-
-pub fn buf_str(toks: &[Token],
-               szs: &[isize],
-               left: usize,
-               right: usize,
-               lim: usize)
-               -> String {
-    let n = toks.len();
-    assert_eq!(n, szs.len());
-    let mut i = left;
-    let mut l = lim;
-    let mut s = string::String::from("[");
-    while i != right && l != 0 {
-        l -= 1;
-        if i != left {
-            s.push_str(", ");
-        }
-        s.push_str(&format!("{}={}",
-                           szs[i],
-                           tok_str(&toks[i])));
-        i += 1;
-        i %= n;
-    }
-    s.push(']');
-    s
-}
-
-#[derive(Copy, Clone)]
-pub enum PrintStackBreak {
-    Fits,
-    Broken(Breaks),
-}
-
-#[derive(Copy, Clone)]
-pub struct PrintStackElem {
-    offset: isize,
-    pbreak: PrintStackBreak
-}
-
-const SIZE_INFINITY: isize = 0xffff;
-
-pub fn mk_printer<'a>(out: Box<io::Write+'a>, linewidth: usize) -> Printer<'a> {
-    // Yes 3, it makes the ring buffers big enough to never
-    // fall behind.
-    let n: usize = 3 * linewidth;
-    debug!("mk_printer {}", linewidth);
-    let token = vec![Token::Eof; n];
-    let size = vec![0_isize; n];
-    let scan_stack = vec![0_usize; n];
-    Printer {
-        out: out,
-        buf_len: n,
-        margin: linewidth as isize,
-        space: linewidth as isize,
-        left: 0,
-        right: 0,
-        token: token,
-        size: size,
-        left_total: 0,
-        right_total: 0,
-        scan_stack: scan_stack,
-        scan_stack_empty: true,
-        top: 0,
-        bottom: 0,
-        print_stack: Vec::new(),
-        pending_indentation: 0
-    }
-}
-
-
-/// In case you do not have the paper, here is an explanation of what's going
-/// on.
-///
-/// There is a stream of input tokens flowing through this printer.
-///
-/// The printer buffers up to 3N tokens inside itself, where N is linewidth.
-/// Yes, linewidth is chars and tokens are multi-char, but in the worst
-/// case every token worth buffering is 1 char long, so it's ok.
-///
-/// Tokens are String, Break, and Begin/End to delimit blocks.
-///
-/// Begin tokens can carry an offset, saying "how far to indent when you break
-/// inside here", as well as a flag indicating "consistent" or "inconsistent"
-/// breaking. Consistent breaking means that after the first break, no attempt
-/// will be made to flow subsequent breaks together onto lines. Inconsistent
-/// is the opposite. Inconsistent breaking example would be, say:
-///
-///  foo(hello, there, good, friends)
-///
-/// breaking inconsistently to become
-///
-///  foo(hello, there
-///      good, friends);
-///
-/// whereas a consistent breaking would yield:
-///
-///  foo(hello,
-///      there
-///      good,
-///      friends);
-///
-/// That is, in the consistent-break blocks we value vertical alignment
-/// more than the ability to cram stuff onto a line. But in all cases if it
-/// can make a block a one-liner, it'll do so.
-///
-/// Carrying on with high-level logic:
-///
-/// The buffered tokens go through a ring-buffer, 'tokens'. The 'left' and
-/// 'right' indices denote the active portion of the ring buffer as well as
-/// describing hypothetical points-in-the-infinite-stream at most 3N tokens
-/// apart (i.e. "not wrapped to ring-buffer boundaries"). The paper will switch
-/// between using 'left' and 'right' terms to denote the wrapped-to-ring-buffer
-/// and point-in-infinite-stream senses freely.
-///
-/// There is a parallel ring buffer, 'size', that holds the calculated size of
-/// each token. Why calculated? Because for Begin/End pairs, the "size"
-/// includes everything between the pair. That is, the "size" of Begin is
-/// actually the sum of the sizes of everything between Begin and the paired
-/// End that follows. Since that is arbitrarily far in the future, 'size' is
-/// being rewritten regularly while the printer runs; in fact most of the
-/// machinery is here to work out 'size' entries on the fly (and give up when
-/// they're so obviously over-long that "infinity" is a good enough
-/// approximation for purposes of line breaking).
-///
-/// The "input side" of the printer is managed as an abstract process called
-/// SCAN, which uses 'scan_stack', 'scan_stack_empty', 'top' and 'bottom', to
-/// manage calculating 'size'. SCAN is, in other words, the process of
-/// calculating 'size' entries.
-///
-/// The "output side" of the printer is managed by an abstract process called
-/// PRINT, which uses 'print_stack', 'margin' and 'space' to figure out what to
-/// do with each token/size pair it consumes as it goes. It's trying to consume
-/// the entire buffered window, but can't output anything until the size is >=
-/// 0 (sizes are set to negative while they're pending calculation).
-///
-/// So SCAN takes input and buffers tokens and pending calculations, while
-/// PRINT gobbles up completed calculations and tokens from the buffer. The
-/// theory is that the two can never get more than 3N tokens apart, because
-/// once there's "obviously" too much data to fit on a line, in a size
-/// calculation, SCAN will write "infinity" to the size and let PRINT consume
-/// it.
-///
-/// In this implementation (following the paper, again) the SCAN process is
-/// the method called 'pretty_print', and the 'PRINT' process is the method
-/// called 'print'.
-pub struct Printer<'a> {
-    pub out: Box<io::Write+'a>,
-    buf_len: usize,
-    /// Width of lines we're constrained to
-    margin: isize,
-    /// Number of spaces left on line
-    space: isize,
-    /// Index of left side of input stream
-    left: usize,
-    /// Index of right side of input stream
-    right: usize,
-    /// Ring-buffer stream goes through
-    token: Vec<Token> ,
-    /// Ring-buffer of calculated sizes
-    size: Vec<isize> ,
-    /// Running size of stream "...left"
-    left_total: isize,
-    /// Running size of stream "...right"
-    right_total: isize,
-    /// Pseudo-stack, really a ring too. Holds the
-    /// primary-ring-buffers index of the Begin that started the
-    /// current block, possibly with the most recent Break after that
-    /// Begin (if there is any) on top of it. Stuff is flushed off the
-    /// bottom as it becomes irrelevant due to the primary ring-buffer
-    /// advancing.
-    scan_stack: Vec<usize> ,
-    /// Top==bottom disambiguator
-    scan_stack_empty: bool,
-    /// Index of top of scan_stack
-    top: usize,
-    /// Index of bottom of scan_stack
-    bottom: usize,
-    /// Stack of blocks-in-progress being flushed by print
-    print_stack: Vec<PrintStackElem> ,
-    /// Buffered indentation to avoid writing trailing whitespace
-    pending_indentation: isize,
-}
-
-impl<'a> Printer<'a> {
-    pub fn last_token(&mut self) -> Token {
-        self.token[self.right].clone()
-    }
-    // be very careful with this!
-    pub fn replace_last_token(&mut self, t: Token) {
-        self.token[self.right] = t;
-    }
-    pub fn pretty_print(&mut self, token: Token) -> io::Result<()> {
-        debug!("pp Vec<{},{}>", self.left, self.right);
-        match token {
-          Token::Eof => {
-            if !self.scan_stack_empty {
-                self.check_stack(0);
-                try!(self.advance_left());
-            }
-            self.indent(0);
-            Ok(())
-          }
-          Token::Begin(b) => {
-            if self.scan_stack_empty {
-                self.left_total = 1;
-                self.right_total = 1;
-                self.left = 0;
-                self.right = 0;
-            } else { self.advance_right(); }
-            debug!("pp Begin({})/buffer Vec<{},{}>",
-                   b.offset, self.left, self.right);
-            self.token[self.right] = token;
-            self.size[self.right] = -self.right_total;
-            let right = self.right;
-            self.scan_push(right);
-            Ok(())
-          }
-          Token::End => {
-            if self.scan_stack_empty {
-                debug!("pp End/print Vec<{},{}>", self.left, self.right);
-                self.print(token, 0)
-            } else {
-                debug!("pp End/buffer Vec<{},{}>", self.left, self.right);
-                self.advance_right();
-                self.token[self.right] = token;
-                self.size[self.right] = -1;
-                let right = self.right;
-                self.scan_push(right);
-                Ok(())
-            }
-          }
-          Token::Break(b) => {
-            if self.scan_stack_empty {
-                self.left_total = 1;
-                self.right_total = 1;
-                self.left = 0;
-                self.right = 0;
-            } else { self.advance_right(); }
-            debug!("pp Break({})/buffer Vec<{},{}>",
-                   b.offset, self.left, self.right);
-            self.check_stack(0);
-            let right = self.right;
-            self.scan_push(right);
-            self.token[self.right] = token;
-            self.size[self.right] = -self.right_total;
-            self.right_total += b.blank_space;
-            Ok(())
-          }
-          Token::String(s, len) => {
-            if self.scan_stack_empty {
-                debug!("pp String('{}')/print Vec<{},{}>",
-                       s, self.left, self.right);
-                self.print(Token::String(s, len), len)
-            } else {
-                debug!("pp String('{}')/buffer Vec<{},{}>",
-                       s, self.left, self.right);
-                self.advance_right();
-                self.token[self.right] = Token::String(s, len);
-                self.size[self.right] = len;
-                self.right_total += len;
-                self.check_stream()
-            }
-          }
-        }
-    }
-    pub fn check_stream(&mut self) -> io::Result<()> {
-        debug!("check_stream Vec<{}, {}> with left_total={}, right_total={}",
-               self.left, self.right, self.left_total, self.right_total);
-        if self.right_total - self.left_total > self.space {
-            debug!("scan window is {}, longer than space on line ({})",
-                   self.right_total - self.left_total, self.space);
-            if !self.scan_stack_empty {
-                if self.left == self.scan_stack[self.bottom] {
-                    debug!("setting {} to infinity and popping", self.left);
-                    let scanned = self.scan_pop_bottom();
-                    self.size[scanned] = SIZE_INFINITY;
-                }
-            }
-            try!(self.advance_left());
-            if self.left != self.right {
-                try!(self.check_stream());
-            }
-        }
-        Ok(())
-    }
-    pub fn scan_push(&mut self, x: usize) {
-        debug!("scan_push {}", x);
-        if self.scan_stack_empty {
-            self.scan_stack_empty = false;
-        } else {
-            self.top += 1;
-            self.top %= self.buf_len;
-            assert!((self.top != self.bottom));
-        }
-        self.scan_stack[self.top] = x;
-    }
-    pub fn scan_pop(&mut self) -> usize {
-        assert!((!self.scan_stack_empty));
-        let x = self.scan_stack[self.top];
-        if self.top == self.bottom {
-            self.scan_stack_empty = true;
-        } else {
-            self.top += self.buf_len - 1; self.top %= self.buf_len;
-        }
-        return x;
-    }
-    pub fn scan_top(&mut self) -> usize {
-        assert!((!self.scan_stack_empty));
-        return self.scan_stack[self.top];
-    }
-    pub fn scan_pop_bottom(&mut self) -> usize {
-        assert!((!self.scan_stack_empty));
-        let x = self.scan_stack[self.bottom];
-        if self.top == self.bottom {
-            self.scan_stack_empty = true;
-        } else {
-            self.bottom += 1; self.bottom %= self.buf_len;
-        }
-        return x;
-    }
-    pub fn advance_right(&mut self) {
-        self.right += 1;
-        self.right %= self.buf_len;
-        assert!((self.right != self.left));
-    }
-    pub fn advance_left(&mut self) -> io::Result<()> {
-        debug!("advance_left Vec<{},{}>, sizeof({})={}", self.left, self.right,
-               self.left, self.size[self.left]);
-
-        let mut left_size = self.size[self.left];
-
-        while left_size >= 0 {
-            let left = self.token[self.left].clone();
-
-            let len = match left {
-                Token::Break(b) => b.blank_space,
-                Token::String(_, len) => {
-                    assert_eq!(len, left_size);
-                    len
-                }
-                _ => 0
-            };
-
-            try!(self.print(left, left_size));
-
-            self.left_total += len;
-
-            if self.left == self.right {
-                break;
-            }
-
-            self.left += 1;
-            self.left %= self.buf_len;
-
-            left_size = self.size[self.left];
-        }
-
-        Ok(())
-    }
-    pub fn check_stack(&mut self, k: isize) {
-        if !self.scan_stack_empty {
-            let x = self.scan_top();
-            match self.token[x] {
-                Token::Begin(_) => {
-                    if k > 0 {
-                        let popped = self.scan_pop();
-                        self.size[popped] = self.size[x] + self.right_total;
-                        self.check_stack(k - 1);
-                    }
-                }
-                Token::End => {
-                    // paper says + not =, but that makes no sense.
-                    let popped = self.scan_pop();
-                    self.size[popped] = 1;
-                    self.check_stack(k + 1);
-                }
-                _ => {
-                    let popped = self.scan_pop();
-                    self.size[popped] = self.size[x] + self.right_total;
-                    if k > 0 {
-                        self.check_stack(k);
-                    }
-                }
-            }
-        }
-    }
-    pub fn print_newline(&mut self, amount: isize) -> io::Result<()> {
-        debug!("NEWLINE {}", amount);
-        let ret = write!(self.out, "\n");
-        self.pending_indentation = 0;
-        self.indent(amount);
-        return ret;
-    }
-    pub fn indent(&mut self, amount: isize) {
-        debug!("INDENT {}", amount);
-        self.pending_indentation += amount;
-    }
-    pub fn get_top(&mut self) -> PrintStackElem {
-        let print_stack = &mut self.print_stack;
-        let n = print_stack.len();
-        if n != 0 {
-            (*print_stack)[n - 1]
-        } else {
-            PrintStackElem {
-                offset: 0,
-                pbreak: PrintStackBreak::Broken(Breaks::Inconsistent)
-            }
-        }
-    }
-    pub fn print_str(&mut self, s: &str) -> io::Result<()> {
-        while self.pending_indentation > 0 {
-            try!(write!(self.out, " "));
-            self.pending_indentation -= 1;
-        }
-        write!(self.out, "{}", s)
-    }
-    pub fn print(&mut self, token: Token, l: isize) -> io::Result<()> {
-        debug!("print {} {} (remaining line space={})", tok_str(&token), l,
-               self.space);
-        debug!("{}", buf_str(&self.token,
-                             &self.size,
-                             self.left,
-                             self.right,
-                             6));
-        match token {
-          Token::Begin(b) => {
-            if l > self.space {
-                let col = self.margin - self.space + b.offset;
-                debug!("print Begin -> push broken block at col {}", col);
-                self.print_stack.push(PrintStackElem {
-                    offset: col,
-                    pbreak: PrintStackBreak::Broken(b.breaks)
-                });
-            } else {
-                debug!("print Begin -> push fitting block");
-                self.print_stack.push(PrintStackElem {
-                    offset: 0,
-                    pbreak: PrintStackBreak::Fits
-                });
-            }
-            Ok(())
-          }
-          Token::End => {
-            debug!("print End -> pop End");
-            let print_stack = &mut self.print_stack;
-            assert!((!print_stack.is_empty()));
-            print_stack.pop().unwrap();
-            Ok(())
-          }
-          Token::Break(b) => {
-            let top = self.get_top();
-            match top.pbreak {
-              PrintStackBreak::Fits => {
-                debug!("print Break({}) in fitting block", b.blank_space);
-                self.space -= b.blank_space;
-                self.indent(b.blank_space);
-                Ok(())
-              }
-              PrintStackBreak::Broken(Breaks::Consistent) => {
-                debug!("print Break({}+{}) in consistent block",
-                       top.offset, b.offset);
-                let ret = self.print_newline(top.offset + b.offset);
-                self.space = self.margin - (top.offset + b.offset);
-                ret
-              }
-              PrintStackBreak::Broken(Breaks::Inconsistent) => {
-                if l > self.space {
-                    debug!("print Break({}+{}) w/ newline in inconsistent",
-                           top.offset, b.offset);
-                    let ret = self.print_newline(top.offset + b.offset);
-                    self.space = self.margin - (top.offset + b.offset);
-                    ret
-                } else {
-                    debug!("print Break({}) w/o newline in inconsistent",
-                           b.blank_space);
-                    self.indent(b.blank_space);
-                    self.space -= b.blank_space;
-                    Ok(())
-                }
-              }
-            }
-          }
-          Token::String(s, len) => {
-            debug!("print String({})", s);
-            assert_eq!(l, len);
-            // assert!(l <= space);
-            self.space -= len;
-            self.print_str(&s[..])
-          }
-          Token::Eof => {
-            // Eof should never get here.
-            panic!();
-          }
-        }
-    }
-}
-
-// Convenience functions to talk to the printer.
-//
-// "raw box"
-pub fn rbox(p: &mut Printer, indent: usize, b: Breaks) -> io::Result<()> {
-    p.pretty_print(Token::Begin(BeginToken {
-        offset: indent as isize,
-        breaks: b
-    }))
-}
-
-pub fn ibox(p: &mut Printer, indent: usize) -> io::Result<()> {
-    rbox(p, indent, Breaks::Inconsistent)
-}
-
-pub fn cbox(p: &mut Printer, indent: usize) -> io::Result<()> {
-    rbox(p, indent, Breaks::Consistent)
-}
-
-pub fn break_offset(p: &mut Printer, n: usize, off: isize) -> io::Result<()> {
-    p.pretty_print(Token::Break(BreakToken {
-        offset: off,
-        blank_space: n as isize
-    }))
-}
-
-pub fn end(p: &mut Printer) -> io::Result<()> {
-    p.pretty_print(Token::End)
-}
-
-pub fn eof(p: &mut Printer) -> io::Result<()> {
-    p.pretty_print(Token::Eof)
-}
-
-pub fn word(p: &mut Printer, wrd: &str) -> io::Result<()> {
-    p.pretty_print(Token::String(/* bad */ wrd.to_string(), wrd.len() as isize))
-}
-
-pub fn huge_word(p: &mut Printer, wrd: &str) -> io::Result<()> {
-    p.pretty_print(Token::String(/* bad */ wrd.to_string(), SIZE_INFINITY))
-}
-
-pub fn zero_word(p: &mut Printer, wrd: &str) -> io::Result<()> {
-    p.pretty_print(Token::String(/* bad */ wrd.to_string(), 0))
-}
-
-pub fn spaces(p: &mut Printer, n: usize) -> io::Result<()> {
-    break_offset(p, n, 0)
-}
-
-pub fn zerobreak(p: &mut Printer) -> io::Result<()> {
-    spaces(p, 0)
-}
-
-pub fn space(p: &mut Printer) -> io::Result<()> {
-    spaces(p, 1)
-}
-
-pub fn hardbreak(p: &mut Printer) -> io::Result<()> {
-    spaces(p, SIZE_INFINITY as usize)
-}
-
-pub fn hardbreak_tok_offset(off: isize) -> Token {
-    Token::Break(BreakToken {offset: off, blank_space: SIZE_INFINITY})
-}
-
-pub fn hardbreak_tok() -> Token {
-    hardbreak_tok_offset(0)
-}
index a1382b467fb876fc1545d531b5e0dc71a95497eb..d8d85135dd8f5732458ff9704f5df089d7790494 100644 (file)
 use syntax::parse::token::{self, BinOpToken};
 use syntax::parse::lexer::comments;
 use syntax::parse;
-use syntax::print::pp::{self, break_offset, word, space, zerobreak, hardbreak};
+use syntax::print::pp::{self, break_offset, word, space, hardbreak};
 use syntax::print::pp::{Breaks, eof};
 use syntax::print::pp::Breaks::{Consistent, Inconsistent};
+use syntax::print::pprust::{self as ast_pp, PrintState};
 use syntax::ptr::P;
 
 use hir;
 use hir::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
-use attr::{AttrMetaMethods, AttributeMethods};
 
-use std::ascii;
 use std::io::{self, Write, Read};
-use std::iter;
 
 pub enum AnnNode<'a> {
     NodeIdent(&'a ast::Ident),
@@ -51,22 +49,39 @@ fn post(&self, _state: &mut State, _node: AnnNode) -> io::Result<()> { Ok(()) }
 
 impl PpAnn for NoAnn {}
 
-#[derive(Copy, Clone)]
-pub struct CurrentCommentAndLiteral {
-    cur_cmnt: usize,
-    cur_lit: usize,
-}
 
 pub struct State<'a> {
     pub s: pp::Printer<'a>,
     cm: Option<&'a CodeMap>,
-    comments: Option<Vec<comments::Comment> >,
-    literals: Option<Vec<comments::Literal> >,
-    cur_cmnt_and_lit: CurrentCommentAndLiteral,
+    comments: Option<Vec<comments::Comment>>,
+    literals: Option<Vec<comments::Literal>>,
+    cur_cmnt_and_lit: ast_pp::CurrentCommentAndLiteral,
     boxes: Vec<pp::Breaks>,
     ann: &'a (PpAnn+'a),
 }
 
+impl<'a> PrintState<'a> for State<'a> {
+    fn writer(&mut self) -> &mut pp::Printer<'a> {
+        &mut self.s
+    }
+
+    fn boxes(&mut self) -> &mut Vec<pp::Breaks> {
+        &mut self.boxes
+    }
+
+    fn comments(&mut self) -> &mut Option<Vec<comments::Comment>> {
+        &mut self.comments
+    }
+
+    fn cur_cmnt_and_lit(&mut self) -> &mut ast_pp::CurrentCommentAndLiteral {
+        &mut self.cur_cmnt_and_lit
+    }
+
+    fn literals(&self) -> &Option<Vec<comments::Literal>> {
+        &self.literals
+    }
+}
+
 pub fn rust_printer<'a>(writer: Box<Write+'a>) -> State<'a> {
     static NO_ANN: NoAnn = NoAnn;
     rust_printer_annotated(writer, &NO_ANN)
@@ -79,7 +94,7 @@ pub fn rust_printer_annotated<'a>(writer: Box<Write+'a>,
         cm: None,
         comments: None,
         literals: None,
-        cur_cmnt_and_lit: CurrentCommentAndLiteral {
+        cur_cmnt_and_lit: ast_pp::CurrentCommentAndLiteral {
             cur_cmnt: 0,
             cur_lit: 0
         },
@@ -154,9 +169,9 @@ pub fn new(cm: &'a CodeMap,
         State {
             s: pp::mk_printer(out, default_columns),
             cm: Some(cm),
-            comments: comments,
-            literals: literals,
-            cur_cmnt_and_lit: CurrentCommentAndLiteral {
+            comments: comments.clone(),
+            literals: literals.clone(),
+            cur_cmnt_and_lit: ast_pp::CurrentCommentAndLiteral {
                 cur_cmnt: 0,
                 cur_lit: 0
             },
@@ -221,10 +236,6 @@ pub fn stmt_to_string(stmt: &hir::Stmt) -> String {
     to_string(|s| s.print_stmt(stmt))
 }
 
-pub fn attr_to_string(attr: &hir::Attribute) -> String {
-    to_string(|s| s.print_attribute(attr))
-}
-
 pub fn item_to_string(i: &hir::Item) -> String {
     to_string(|s| s.print_item(i))
 }
@@ -283,18 +294,6 @@ pub fn block_to_string(blk: &hir::Block) -> String {
     })
 }
 
-pub fn meta_item_to_string(mi: &hir::MetaItem) -> String {
-    to_string(|s| s.print_meta_item(mi))
-}
-
-pub fn attribute_to_string(attr: &hir::Attribute) -> String {
-    to_string(|s| s.print_attribute(attr))
-}
-
-pub fn lit_to_string(l: &hir::Lit) -> String {
-    to_string(|s| s.print_literal(l))
-}
-
 pub fn explicit_self_to_string(explicit_self: &hir::ExplicitSelf_) -> String {
     to_string(|s| s.print_explicit_self(explicit_self, hir::MutImmutable).map(|_| {}))
 }
@@ -324,27 +323,11 @@ fn needs_parentheses(expr: &hir::Expr) -> bool {
 }
 
 impl<'a> State<'a> {
-    pub fn ibox(&mut self, u: usize) -> io::Result<()> {
-        self.boxes.push(pp::Breaks::Inconsistent);
-        pp::ibox(&mut self.s, u)
-    }
-
-    pub fn end(&mut self) -> io::Result<()> {
-        self.boxes.pop().unwrap();
-        pp::end(&mut self.s)
-    }
-
     pub fn cbox(&mut self, u: usize) -> io::Result<()> {
         self.boxes.push(pp::Breaks::Consistent);
         pp::cbox(&mut self.s, u)
     }
 
-    // "raw box"
-    pub fn rbox(&mut self, u: usize, b: pp::Breaks) -> io::Result<()> {
-        self.boxes.push(b);
-        pp::rbox(&mut self.s, u, b)
-    }
-
     pub fn nbsp(&mut self) -> io::Result<()> { word(&mut self.s, " ") }
 
     pub fn word_nbsp(&mut self, w: &str) -> io::Result<()> {
@@ -352,15 +335,6 @@ pub fn word_nbsp(&mut self, w: &str) -> io::Result<()> {
         self.nbsp()
     }
 
-    pub fn word_space(&mut self, w: &str) -> io::Result<()> {
-        try!(word(&mut self.s, w));
-        space(&mut self.s)
-    }
-
-    pub fn popen(&mut self) -> io::Result<()> { word(&mut self.s, "(") }
-
-    pub fn pclose(&mut self) -> io::Result<()> { word(&mut self.s, ")") }
-
     pub fn head(&mut self, w: &str) -> io::Result<()> {
         // outer-box is consistent
         try!(self.cbox(indent_unit));
@@ -396,38 +370,12 @@ pub fn bclose(&mut self, span: codemap::Span) -> io::Result<()> {
         self.bclose_(span, indent_unit)
     }
 
-    pub fn is_begin(&mut self) -> bool {
-        match self.s.last_token() {
-            pp::Token::Begin(_) => true,
-            _ => false,
-        }
-    }
-
-    pub fn is_end(&mut self) -> bool {
-        match self.s.last_token() {
-            pp::Token::End => true,
-            _ => false,
-        }
-    }
-
-    // is this the beginning of a line?
-    pub fn is_bol(&mut self) -> bool {
-        self.s.last_token().is_eof() || self.s.last_token().is_hardbreak_tok()
-    }
-
     pub fn in_cbox(&self) -> bool {
         match self.boxes.last() {
             Some(&last_box) => last_box == pp::Breaks::Consistent,
             None => false
         }
     }
-
-    pub fn hardbreak_if_not_bol(&mut self) -> io::Result<()> {
-        if !self.is_bol() {
-            try!(hardbreak(&mut self.s))
-        }
-        Ok(())
-    }
     pub fn space_if_not_bol(&mut self) -> io::Result<()> {
         if !self.is_bol() { try!(space(&mut self.s)); }
         Ok(())
@@ -457,18 +405,6 @@ pub fn synth_comment(&mut self, text: String) -> io::Result<()> {
         word(&mut self.s, "*/")
     }
 
-    pub fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], mut op: F) -> io::Result<()> where
-        F: FnMut(&mut State, &T) -> io::Result<()>,
-    {
-        try!(self.rbox(0, b));
-        let mut first = true;
-        for elt in elts {
-            if first { first = false; } else { try!(self.word_space(",")); }
-            try!(op(self, elt));
-        }
-        self.end()
-    }
-
 
     pub fn commasep_cmnt<T, F, G>(&mut self,
                                   b: Breaks,
@@ -501,7 +437,7 @@ pub fn commasep_exprs(&mut self, b: Breaks,
     }
 
     pub fn print_mod(&mut self, _mod: &hir::Mod,
-                     attrs: &[hir::Attribute]) -> io::Result<()> {
+                     attrs: &[ast::Attribute]) -> io::Result<()> {
         try!(self.print_inner_attributes(attrs));
         for item in &_mod.items {
             try!(self.print_item(&**item));
@@ -510,7 +446,7 @@ pub fn print_mod(&mut self, _mod: &hir::Mod,
     }
 
     pub fn print_foreign_mod(&mut self, nmod: &hir::ForeignMod,
-                             attrs: &[hir::Attribute]) -> io::Result<()> {
+                             attrs: &[ast::Attribute]) -> io::Result<()> {
         try!(self.print_inner_attributes(attrs));
         for item in &nmod.items {
             try!(self.print_foreign_item(&**item));
@@ -694,7 +630,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                 if let Some(p) = *optional_path {
                     let val = p.as_str();
                     if val.contains("-") {
-                        try!(self.print_string(&val, hir::CookedStr));
+                        try!(self.print_string(&val, ast::CookedStr));
                     } else {
                         try!(self.print_name(p));
                     }
@@ -1105,58 +1041,6 @@ pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
         self.ann.post(self, NodeSubItem(ii.id))
     }
 
-    pub fn print_outer_attributes(&mut self,
-                                  attrs: &[hir::Attribute]) -> io::Result<()> {
-        let mut count = 0;
-        for attr in attrs {
-            match attr.node.style {
-                hir::AttrOuter => {
-                    try!(self.print_attribute(attr));
-                    count += 1;
-                }
-                _ => {/* fallthrough */ }
-            }
-        }
-        if count > 0 {
-            try!(self.hardbreak_if_not_bol());
-        }
-        Ok(())
-    }
-
-    pub fn print_inner_attributes(&mut self,
-                                  attrs: &[hir::Attribute]) -> io::Result<()> {
-        let mut count = 0;
-        for attr in attrs {
-            match attr.node.style {
-                hir::AttrInner => {
-                    try!(self.print_attribute(attr));
-                    count += 1;
-                }
-                _ => {/* fallthrough */ }
-            }
-        }
-        if count > 0 {
-            try!(self.hardbreak_if_not_bol());
-        }
-        Ok(())
-    }
-
-    pub fn print_attribute(&mut self, attr: &hir::Attribute) -> io::Result<()> {
-        try!(self.hardbreak_if_not_bol());
-        try!(self.maybe_print_comment(attr.span.lo));
-        if attr.node.is_sugared_doc {
-            word(&mut self.s, &attr.value_str().unwrap())
-        } else {
-            match attr.node.style {
-                hir::AttrInner => try!(word(&mut self.s, "#![")),
-                hir::AttrOuter => try!(word(&mut self.s, "#[")),
-            }
-            try!(self.print_meta_item(&*attr.meta()));
-            word(&mut self.s, "]")
-        }
-    }
-
-
     pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> {
         try!(self.maybe_print_comment(st.span.lo));
         match st.node {
@@ -1194,14 +1078,14 @@ pub fn print_block_unclosed_indent(&mut self, blk: &hir::Block,
 
     pub fn print_block_with_attrs(&mut self,
                                   blk: &hir::Block,
-                                  attrs: &[hir::Attribute]) -> io::Result<()> {
+                                  attrs: &[ast::Attribute]) -> io::Result<()> {
         self.print_block_maybe_unclosed(blk, indent_unit, attrs, true)
     }
 
     pub fn print_block_maybe_unclosed(&mut self,
                                       blk: &hir::Block,
                                       indented: usize,
-                                      attrs: &[hir::Attribute],
+                                      attrs: &[ast::Attribute],
                                       close_box: bool) -> io::Result<()> {
         match blk.rules {
             hir::UnsafeBlock(..) | hir::PushUnsafeBlock(..) => try!(self.word_space("unsafe")),
@@ -1620,9 +1504,9 @@ pub fn print_expr(&mut self, expr: &hir::Expr) -> io::Result<()> {
                     match co.slice_shift_char() {
                         Some(('=', operand)) if is_rw => {
                             try!(s.print_string(&format!("+{}", operand),
-                                                hir::CookedStr))
+                                                ast::CookedStr))
                         }
-                        _ => try!(s.print_string(&co, hir::CookedStr))
+                        _ => try!(s.print_string(&co, ast::CookedStr))
                     }
                     try!(s.popen());
                     try!(s.print_expr(&**o));
@@ -1634,7 +1518,7 @@ pub fn print_expr(&mut self, expr: &hir::Expr) -> io::Result<()> {
 
                 try!(self.commasep(Inconsistent, &a.inputs,
                                    |s, &(ref co, ref o)| {
-                    try!(s.print_string(&co, hir::CookedStr));
+                    try!(s.print_string(&co, ast::CookedStr));
                     try!(s.popen());
                     try!(s.print_expr(&**o));
                     try!(s.pclose());
@@ -1645,7 +1529,7 @@ pub fn print_expr(&mut self, expr: &hir::Expr) -> io::Result<()> {
 
                 try!(self.commasep(Inconsistent, &a.clobbers,
                                    |s, co| {
-                    try!(s.print_string(&co, hir::CookedStr));
+                    try!(s.print_string(&co, ast::CookedStr));
                     Ok(())
                 }));
 
@@ -1665,7 +1549,7 @@ pub fn print_expr(&mut self, expr: &hir::Expr) -> io::Result<()> {
                     try!(self.word_space(":"));
                     try!(self.commasep(Inconsistent, &*options,
                                        |s, &co| {
-                        try!(s.print_string(co, hir::CookedStr));
+                        try!(s.print_string(co, ast::CookedStr));
                         Ok(())
                     }));
                 }
@@ -2294,29 +2178,6 @@ pub fn print_where_clause(&mut self, where_clause: &hir::WhereClause)
         Ok(())
     }
 
-    pub fn print_meta_item(&mut self, item: &hir::MetaItem) -> io::Result<()> {
-        try!(self.ibox(indent_unit));
-        match item.node {
-            hir::MetaWord(ref name) => {
-                try!(word(&mut self.s, &name));
-            }
-            hir::MetaNameValue(ref name, ref value) => {
-                try!(self.word_space(&name[..]));
-                try!(self.word_space("="));
-                try!(self.print_literal(value));
-            }
-            hir::MetaList(ref name, ref items) => {
-                try!(word(&mut self.s, &name));
-                try!(self.popen());
-                try!(self.commasep(Consistent,
-                                   &items[..],
-                                   |s, i| s.print_meta_item(&**i)));
-                try!(self.pclose());
-            }
-        }
-        self.end()
-    }
-
     pub fn print_view_path(&mut self, vp: &hir::ViewPath) -> io::Result<()> {
         match vp.node {
             hir::ViewPathSimple(ident, ref path) => {
@@ -2494,181 +2355,6 @@ pub fn print_remaining_comments(&mut self) -> io::Result<()> {
         Ok(())
     }
 
-    pub fn print_literal(&mut self, lit: &hir::Lit) -> io::Result<()> {
-        try!(self.maybe_print_comment(lit.span.lo));
-        match self.next_lit(lit.span.lo) {
-            Some(ref ltrl) => {
-                return word(&mut self.s, &(*ltrl).lit);
-            }
-            _ => ()
-        }
-        match lit.node {
-            hir::LitStr(ref st, style) => self.print_string(&st, style),
-            hir::LitByte(byte) => {
-                let mut res = String::from("b'");
-                res.extend(ascii::escape_default(byte).map(|c| c as char));
-                res.push('\'');
-                word(&mut self.s, &res[..])
-            }
-            hir::LitChar(ch) => {
-                let mut res = String::from("'");
-                res.extend(ch.escape_default());
-                res.push('\'');
-                word(&mut self.s, &res[..])
-            }
-            hir::LitInt(i, t) => {
-                match t {
-                    hir::SignedIntLit(st, hir::Plus) => {
-                        word(&mut self.s,
-                             &::util::int_ty_to_string(st, Some(i as i64)))
-                    }
-                    hir::SignedIntLit(st, hir::Minus) => {
-                        let istr = ::util::int_ty_to_string(st, Some(-(i as i64)));
-                        word(&mut self.s,
-                             &format!("-{}", istr))
-                    }
-                    hir::UnsignedIntLit(ut) => {
-                        word(&mut self.s, &::util::uint_ty_to_string(ut, Some(i)))
-                    }
-                    hir::UnsuffixedIntLit(hir::Plus) => {
-                        word(&mut self.s, &format!("{}", i))
-                    }
-                    hir::UnsuffixedIntLit(hir::Minus) => {
-                        word(&mut self.s, &format!("-{}", i))
-                    }
-                }
-            }
-            hir::LitFloat(ref f, t) => {
-                word(&mut self.s,
-                     &format!(
-                         "{}{}",
-                         &f,
-                         &::util::float_ty_to_string(t)))
-            }
-            hir::LitFloatUnsuffixed(ref f) => word(&mut self.s, &f[..]),
-            hir::LitBool(val) => {
-                if val { word(&mut self.s, "true") } else { word(&mut self.s, "false") }
-            }
-            hir::LitByteStr(ref v) => {
-                let mut escaped: String = String::new();
-                for &ch in v.iter() {
-                    escaped.extend(ascii::escape_default(ch)
-                                         .map(|c| c as char));
-                }
-                word(&mut self.s, &format!("b\"{}\"", escaped))
-            }
-        }
-    }
-
-    pub fn next_lit(&mut self, pos: BytePos) -> Option<comments::Literal> {
-        match self.literals {
-            Some(ref lits) => {
-                while self.cur_cmnt_and_lit.cur_lit < lits.len() {
-                    let ltrl = (*lits)[self.cur_cmnt_and_lit.cur_lit].clone();
-                    if ltrl.pos > pos { return None; }
-                    self.cur_cmnt_and_lit.cur_lit += 1;
-                    if ltrl.pos == pos { return Some(ltrl); }
-                }
-                None
-            }
-            _ => None
-        }
-    }
-
-    pub fn maybe_print_comment(&mut self, pos: BytePos) -> io::Result<()> {
-        loop {
-            match self.next_comment() {
-                Some(ref cmnt) => {
-                    if (*cmnt).pos < pos {
-                        try!(self.print_comment(cmnt));
-                        self.cur_cmnt_and_lit.cur_cmnt += 1;
-                    } else { break; }
-                }
-                _ => break
-            }
-        }
-        Ok(())
-    }
-
-    pub fn print_comment(&mut self,
-                         cmnt: &comments::Comment) -> io::Result<()> {
-        match cmnt.style {
-            comments::Mixed => {
-                assert_eq!(cmnt.lines.len(), 1);
-                try!(zerobreak(&mut self.s));
-                try!(word(&mut self.s, &cmnt.lines[0]));
-                zerobreak(&mut self.s)
-            }
-            comments::Isolated => {
-                try!(self.hardbreak_if_not_bol());
-                for line in &cmnt.lines {
-                    // Don't print empty lines because they will end up as trailing
-                    // whitespace
-                    if !line.is_empty() {
-                        try!(word(&mut self.s, &line[..]));
-                    }
-                    try!(hardbreak(&mut self.s));
-                }
-                Ok(())
-            }
-            comments::Trailing => {
-                try!(word(&mut self.s, " "));
-                if cmnt.lines.len() == 1 {
-                    try!(word(&mut self.s, &cmnt.lines[0]));
-                    hardbreak(&mut self.s)
-                } else {
-                    try!(self.ibox(0));
-                    for line in &cmnt.lines {
-                        if !line.is_empty() {
-                            try!(word(&mut self.s, &line[..]));
-                        }
-                        try!(hardbreak(&mut self.s));
-                    }
-                    self.end()
-                }
-            }
-            comments::BlankLine => {
-                // We need to do at least one, possibly two hardbreaks.
-                let is_semi = match self.s.last_token() {
-                    pp::Token::String(s, _) => ";" == s,
-                    _ => false
-                };
-                if is_semi || self.is_begin() || self.is_end() {
-                    try!(hardbreak(&mut self.s));
-                }
-                hardbreak(&mut self.s)
-            }
-        }
-    }
-
-    pub fn print_string(&mut self, st: &str,
-                        style: hir::StrStyle) -> io::Result<()> {
-        let st = match style {
-            hir::CookedStr => {
-                (format!("\"{}\"", st.escape_default()))
-            }
-            hir::RawStr(n) => {
-                (format!("r{delim}\"{string}\"{delim}",
-                         delim=repeat("#", n),
-                         string=st))
-            }
-        };
-        word(&mut self.s, &st[..])
-    }
-
-    pub fn next_comment(&mut self) -> Option<comments::Comment> {
-        match self.comments {
-            Some(ref cmnts) => {
-                if self.cur_cmnt_and_lit.cur_cmnt < cmnts.len() {
-                    Some(cmnts[self.cur_cmnt_and_lit.cur_cmnt].clone())
-                } else {
-                    None
-                }
-            }
-            _ => None
-        }
-    }
-
     pub fn print_opt_abi_and_extern_if_nondefault(&mut self,
                                                   opt_abi: Option<abi::Abi>)
         -> io::Result<()> {
@@ -2722,8 +2408,6 @@ pub fn print_unsafety(&mut self, s: hir::Unsafety) -> io::Result<()> {
     }
 }
 
-fn repeat(s: &str, n: usize) -> String { iter::repeat(s).take(n).collect() }
-
 // Dup'ed from parse::classify, but adapted for the HIR.
 /// Does this expression require a semicolon to be treated
 /// as a statement? The negation of this: 'can this expression
index 247ea2ea23b8cb63fec155efb728549e515d53e0..0a47da77a8fce2520565b4f1d5efc1a239778034 100644 (file)
@@ -338,64 +338,10 @@ pub fn compute_id_range_for_fn_body(fk: FnKind,
     id_visitor.operation.result
 }
 
-/// Returns true if this literal is a string and false otherwise.
-pub fn lit_is_str(lit: &Lit) -> bool {
-    match lit.node {
-        LitStr(..) => true,
-        _ => false,
-    }
-}
-
 pub fn is_path(e: P<Expr>) -> bool {
     match e.node { ExprPath(..) => true, _ => false }
 }
 
-/// Get a string representation of a signed int type, with its value.
-/// We want to avoid "45int" and "-3int" in favor of "45" and "-3"
-pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String {
-    let s = match t {
-        TyIs => "isize",
-        TyI8 => "i8",
-        TyI16 => "i16",
-        TyI32 => "i32",
-        TyI64 => "i64"
-    };
-
-    match val {
-        // cast to a u64 so we can correctly print INT64_MIN. All integral types
-        // are parsed as u64, so we wouldn't want to print an extra negative
-        // sign.
-        Some(n) => format!("{}{}", n as u64, s),
-        None => s.to_string()
-    }
-}
-
-
-/// Get a string representation of an unsigned int type, with its value.
-/// We want to avoid "42u" in favor of "42us". "42uint" is right out.
-pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {
-    let s = match t {
-        TyUs => "usize",
-        TyU8 => "u8",
-        TyU16 => "u16",
-        TyU32 => "u32",
-        TyU64 => "u64"
-    };
-
-    match val {
-        Some(n) => format!("{}{}", n, s),
-        None => s.to_string()
-    }
-}
-
-pub fn float_ty_to_string(t: FloatTy) -> String {
-    match t {
-        TyF32 => "f32".to_string(),
-        TyF64 => "f64".to_string(),
-    }
-}
-
-
 pub fn empty_generics() -> Generics {
     Generics {
         lifetimes: Vec::new(),
index f20e5345f20668145159109abba3f6b29b93f9e3..4a3e74fd3fef72a93da1ee8e1b20c7968746d22f 100644 (file)
@@ -24,7 +24,7 @@
 //! those that are created by the expansion of a macro.
 
 use syntax::abi::Abi;
-use syntax::ast::{Ident, NodeId, CRATE_NODE_ID, Name};
+use syntax::ast::{Ident, NodeId, CRATE_NODE_ID, Name, Attribute};
 use hir::*;
 use hir;
 use syntax::codemap::Span;
index 4084f13e818f226fe0b8d965f62f1340b7edefae..816b84f3d46b1171df0ecad002b0747241b6d6ac 100644 (file)
 use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
 
 use syntax::{abi, ast};
-use syntax::attr as syntax_attr;
+use syntax::attr::{self, AttrMetaMethods};
 use syntax::codemap::{self, Span};
 use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
-use rustc_front::hir::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
+use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
 use syntax::ptr::P;
 
 use rustc_front::hir;
-
-use rustc_front::attr::{self, AttrMetaMethods};
 use rustc_front::visit::{self, FnKind, Visitor};
-use rustc_front::lowering::unlower_attribute;
-
 use rustc_front::util::is_shift_binop;
 
 // hardwired lints from librustc
@@ -80,7 +76,7 @@ fn get_lints(&self) -> LintArray {
     fn check_expr(&mut self, cx: &Context, e: &hir::Expr) {
         if let hir::ExprWhile(ref cond, _, _) = e.node {
             if let hir::ExprLit(ref lit) = cond.node {
-                if let hir::LitBool(true) = lit.node {
+                if let ast::LitBool(true) = lit.node {
                     cx.span_lint(WHILE_TRUE, e.span,
                                  "denote infinite loops with loop { ... }");
                 }
@@ -132,10 +128,10 @@ fn check_expr(&mut self, cx: &Context, e: &hir::Expr) {
                 match expr.node  {
                     hir::ExprLit(ref lit) => {
                         match lit.node {
-                            hir::LitInt(_, hir::UnsignedIntLit(_)) => {
+                            ast::LitInt(_, ast::UnsignedIntLit(_)) => {
                                 check_unsigned_negation_feature(cx, e.span);
                             },
-                            hir::LitInt(_, hir::UnsuffixedIntLit(_)) => {
+                            ast::LitInt(_, ast::UnsuffixedIntLit(_)) => {
                                 if let ty::TyUint(_) = cx.tcx.node_id_to_type(e.id).sty {
                                     check_unsigned_negation_feature(cx, e.span);
                                 }
@@ -176,7 +172,7 @@ fn check_expr(&mut self, cx: &Context, e: &hir::Expr) {
 
                     if let Some(bits) = opt_ty_bits {
                         let exceeding = if let hir::ExprLit(ref lit) = r.node {
-                            if let hir::LitInt(shift, _) = lit.node { shift >= bits }
+                            if let ast::LitInt(shift, _) = lit.node { shift >= bits }
                             else { false }
                         } else {
                             match eval_const_expr_partial(cx.tcx, &r, ExprTypeChecked) {
@@ -196,9 +192,9 @@ fn check_expr(&mut self, cx: &Context, e: &hir::Expr) {
                 match cx.tcx.node_id_to_type(e.id).sty {
                     ty::TyInt(t) => {
                         match lit.node {
-                            hir::LitInt(v, hir::SignedIntLit(_, hir::Plus)) |
-                            hir::LitInt(v, hir::UnsuffixedIntLit(hir::Plus)) => {
-                                let int_type = if let hir::TyIs = t {
+                            ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
+                            ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => {
+                                let int_type = if let ast::TyIs = t {
                                     cx.sess().target.int_type
                                 } else {
                                     t
@@ -219,15 +215,15 @@ fn check_expr(&mut self, cx: &Context, e: &hir::Expr) {
                         };
                     },
                     ty::TyUint(t) => {
-                        let uint_type = if let hir::TyUs = t {
+                        let uint_type = if let ast::TyUs = t {
                             cx.sess().target.uint_type
                         } else {
                             t
                         };
                         let (min, max) = uint_ty_range(uint_type);
                         let lit_val: u64 = match lit.node {
-                            hir::LitByte(_v) => return,  // _v is u8, within range by definition
-                            hir::LitInt(v, _) => v,
+                            ast::LitByte(_v) => return,  // _v is u8, within range by definition
+                            ast::LitInt(v, _) => v,
                             _ => panic!()
                         };
                         if lit_val < min || lit_val > max {
@@ -238,8 +234,8 @@ fn check_expr(&mut self, cx: &Context, e: &hir::Expr) {
                     ty::TyFloat(t) => {
                         let (min, max) = float_ty_range(t);
                         let lit_val: f64 = match lit.node {
-                            hir::LitFloat(ref v, _) |
-                            hir::LitFloatUnsuffixed(ref v) => {
+                            ast::LitFloat(ref v, _) |
+                            ast::LitFloatUnsuffixed(ref v) => {
                                 match v.parse() {
                                     Ok(f) => f,
                                     Err(_) => return
@@ -282,50 +278,50 @@ fn rev_binop(binop: hir::BinOp) -> hir::BinOp {
 
         // for isize & usize, be conservative with the warnings, so that the
         // warnings are consistent between 32- and 64-bit platforms
-        fn int_ty_range(int_ty: hir::IntTy) -> (i64, i64) {
+        fn int_ty_range(int_ty: ast::IntTy) -> (i64, i64) {
             match int_ty {
-                hir::TyIs => (i64::MIN,        i64::MAX),
-                hir::TyI8 =>    (i8::MIN  as i64, i8::MAX  as i64),
-                hir::TyI16 =>   (i16::MIN as i64, i16::MAX as i64),
-                hir::TyI32 =>   (i32::MIN as i64, i32::MAX as i64),
-                hir::TyI64 =>   (i64::MIN,        i64::MAX)
+                ast::TyIs => (i64::MIN,        i64::MAX),
+                ast::TyI8 =>    (i8::MIN  as i64, i8::MAX  as i64),
+                ast::TyI16 =>   (i16::MIN as i64, i16::MAX as i64),
+                ast::TyI32 =>   (i32::MIN as i64, i32::MAX as i64),
+                ast::TyI64 =>   (i64::MIN,        i64::MAX)
             }
         }
 
-        fn uint_ty_range(uint_ty: hir::UintTy) -> (u64, u64) {
+        fn uint_ty_range(uint_ty: ast::UintTy) -> (u64, u64) {
             match uint_ty {
-                hir::TyUs => (u64::MIN,         u64::MAX),
-                hir::TyU8 =>    (u8::MIN   as u64, u8::MAX   as u64),
-                hir::TyU16 =>   (u16::MIN  as u64, u16::MAX  as u64),
-                hir::TyU32 =>   (u32::MIN  as u64, u32::MAX  as u64),
-                hir::TyU64 =>   (u64::MIN,         u64::MAX)
+                ast::TyUs => (u64::MIN,         u64::MAX),
+                ast::TyU8 =>    (u8::MIN   as u64, u8::MAX   as u64),
+                ast::TyU16 =>   (u16::MIN  as u64, u16::MAX  as u64),
+                ast::TyU32 =>   (u32::MIN  as u64, u32::MAX  as u64),
+                ast::TyU64 =>   (u64::MIN,         u64::MAX)
             }
         }
 
-        fn float_ty_range(float_ty: hir::FloatTy) -> (f64, f64) {
+        fn float_ty_range(float_ty: ast::FloatTy) -> (f64, f64) {
             match float_ty {
-                hir::TyF32 => (f32::MIN as f64, f32::MAX as f64),
-                hir::TyF64 => (f64::MIN,        f64::MAX)
+                ast::TyF32 => (f32::MIN as f64, f32::MAX as f64),
+                ast::TyF64 => (f64::MIN,        f64::MAX)
             }
         }
 
-        fn int_ty_bits(int_ty: hir::IntTy, target_int_ty: hir::IntTy) -> u64 {
+        fn int_ty_bits(int_ty: ast::IntTy, target_int_ty: ast::IntTy) -> u64 {
             match int_ty {
-                hir::TyIs => int_ty_bits(target_int_ty, target_int_ty),
-                hir::TyI8 =>    i8::BITS  as u64,
-                hir::TyI16 =>   i16::BITS as u64,
-                hir::TyI32 =>   i32::BITS as u64,
-                hir::TyI64 =>   i64::BITS as u64
+                ast::TyIs => int_ty_bits(target_int_ty, target_int_ty),
+                ast::TyI8 =>    i8::BITS  as u64,
+                ast::TyI16 =>   i16::BITS as u64,
+                ast::TyI32 =>   i32::BITS as u64,
+                ast::TyI64 =>   i64::BITS as u64
             }
         }
 
-        fn uint_ty_bits(uint_ty: hir::UintTy, target_uint_ty: hir::UintTy) -> u64 {
+        fn uint_ty_bits(uint_ty: ast::UintTy, target_uint_ty: ast::UintTy) -> u64 {
             match uint_ty {
-                hir::TyUs => uint_ty_bits(target_uint_ty, target_uint_ty),
-                hir::TyU8 =>    u8::BITS  as u64,
-                hir::TyU16 =>   u16::BITS as u64,
-                hir::TyU32 =>   u32::BITS as u64,
-                hir::TyU64 =>   u64::BITS as u64
+                ast::TyUs => uint_ty_bits(target_uint_ty, target_uint_ty),
+                ast::TyU8 =>    u8::BITS  as u64,
+                ast::TyU16 =>   u16::BITS as u64,
+                ast::TyU32 =>   u32::BITS as u64,
+                ast::TyU64 =>   u64::BITS as u64
             }
         }
 
@@ -348,10 +344,10 @@ fn check_limits(tcx: &ty::ctxt, binop: hir::BinOp,
                     let (min, max) = int_ty_range(int_ty);
                     let lit_val: i64 = match lit.node {
                         hir::ExprLit(ref li) => match li.node {
-                            hir::LitInt(v, hir::SignedIntLit(_, hir::Plus)) |
-                            hir::LitInt(v, hir::UnsuffixedIntLit(hir::Plus)) => v as i64,
-                            hir::LitInt(v, hir::SignedIntLit(_, hir::Minus)) |
-                            hir::LitInt(v, hir::UnsuffixedIntLit(hir::Minus)) => -(v as i64),
+                            ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
+                            ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => v as i64,
+                            ast::LitInt(v, ast::SignedIntLit(_, ast::Minus)) |
+                            ast::LitInt(v, ast::UnsuffixedIntLit(ast::Minus)) => -(v as i64),
                             _ => return true
                         },
                         _ => panic!()
@@ -362,7 +358,7 @@ fn check_limits(tcx: &ty::ctxt, binop: hir::BinOp,
                     let (min, max): (u64, u64) = uint_ty_range(uint_ty);
                     let lit_val: u64 = match lit.node {
                         hir::ExprLit(ref li) => match li.node {
-                            hir::LitInt(v, _) => v,
+                            ast::LitInt(v, _) => v,
                             _ => return true
                         },
                         _ => panic!()
@@ -557,11 +553,11 @@ fn check_type_for_ffi(&self,
                 FfiSafe
             }
 
-            ty::TyInt(hir::TyIs) => {
+            ty::TyInt(ast::TyIs) => {
                 FfiUnsafe("found Rust type `isize` in foreign module, while \
                           `libc::c_int` or `libc::c_long` should be used")
             }
-            ty::TyUint(hir::TyUs) => {
+            ty::TyUint(ast::TyUs) => {
                 FfiUnsafe("found Rust type `usize` in foreign module, while \
                           `libc::c_uint` or `libc::c_ulong` should be used")
             }
@@ -892,7 +888,7 @@ fn get_lints(&self) -> LintArray {
         lint_array!(UNUSED_ATTRIBUTES)
     }
 
-    fn check_attribute(&mut self, cx: &Context, attr: &hir::Attribute) {
+    fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) {
         // Note that check_name() marks the attribute as used if it matches.
         for &(ref name, ty, _) in KNOWN_ATTRIBUTES {
             match ty {
@@ -910,7 +906,7 @@ fn check_attribute(&mut self, cx: &Context, attr: &hir::Attribute) {
             }
         }
 
-        if !syntax_attr::is_used(&unlower_attribute(attr)) {
+        if !attr::is_used(attr) {
             cx.span_lint(UNUSED_ATTRIBUTES, attr.span, "unused attribute");
             // Is it a builtin attribute that must be used at the crate level?
             let known_crate = KNOWN_ATTRIBUTES.iter().find(|&&(name, ty, _)| {
@@ -927,9 +923,9 @@ fn check_attribute(&mut self, cx: &Context, attr: &hir::Attribute) {
                                                     }).is_some();
             if  known_crate || plugin_crate {
                 let msg = match attr.node.style {
-                    hir::AttrOuter => "crate-level attribute should be an inner \
+                    ast::AttrOuter => "crate-level attribute should be an inner \
                                        attribute: add an exclamation mark: #![foo]",
-                    hir::AttrInner => "crate-level attribute should be in the \
+                    ast::AttrInner => "crate-level attribute should be in the \
                                        root module",
                 };
                 cx.span_lint(UNUSED_ATTRIBUTES, attr.span, msg);
@@ -1019,7 +1015,7 @@ fn check_stmt(&mut self, cx: &Context, s: &hir::Stmt) {
             cx.span_lint(UNUSED_RESULTS, s.span, "unused result");
         }
 
-        fn check_must_use(cx: &Context, attrs: &[hir::Attribute], sp: Span) -> bool {
+        fn check_must_use(cx: &Context, attrs: &[ast::Attribute], sp: Span) -> bool {
             for attr in attrs {
                 if attr.check_name("must_use") {
                     let mut msg = "unused result which must be used".to_string();
@@ -1780,7 +1776,7 @@ fn doc_hidden(&self) -> bool {
     fn check_missing_docs_attrs(&self,
                                cx: &Context,
                                id: Option<ast::NodeId>,
-                               attrs: &[hir::Attribute],
+                               attrs: &[ast::Attribute],
                                sp: Span,
                                desc: &'static str) {
         // If we're building a test harness, then warning about
@@ -1805,7 +1801,7 @@ fn check_missing_docs_attrs(&self,
 
         let has_doc = attrs.iter().any(|a| {
             match a.node.value.node {
-                hir::MetaNameValue(ref name, _) if *name == "doc" => true,
+                ast::MetaNameValue(ref name, _) if *name == "doc" => true,
                 _ => false
             }
         });
@@ -1821,7 +1817,7 @@ fn get_lints(&self) -> LintArray {
         lint_array!(MISSING_DOCS)
     }
 
-    fn enter_lint_attrs(&mut self, _: &Context, attrs: &[hir::Attribute]) {
+    fn enter_lint_attrs(&mut self, _: &Context, attrs: &[ast::Attribute]) {
         let doc_hidden = self.doc_hidden() || attrs.iter().any(|attr| {
             attr.check_name("doc") && match attr.meta_item_list() {
                 None => false,
@@ -1831,7 +1827,7 @@ fn enter_lint_attrs(&mut self, _: &Context, attrs: &[hir::Attribute]) {
         self.doc_hidden_stack.push(doc_hidden);
     }
 
-    fn exit_lint_attrs(&mut self, _: &Context, _: &[hir::Attribute]) {
+    fn exit_lint_attrs(&mut self, _: &Context, _: &[ast::Attribute]) {
         self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
     }
 
@@ -2573,7 +2569,7 @@ impl LintPass for UnstableFeatures {
     fn get_lints(&self) -> LintArray {
         lint_array!(UNSTABLE_FEATURES)
     }
-    fn check_attribute(&mut self, ctx: &Context, attr: &hir::Attribute) {
+    fn check_attribute(&mut self, ctx: &Context, attr: &ast::Attribute) {
         if attr::contains_name(&[attr.node.value.clone()], "feature") {
             if let Some(items) = attr.node.value.meta_item_list() {
                 for item in items {
index 8e608de024e84657101888a0bd91a918d9485d45..9b3514028afada6888c60eaa9540aa64bec8aa59 100644 (file)
@@ -32,9 +32,9 @@
 use self::rustc::middle::ty::{self, Ty};
 use self::rustc::util::common::ErrorReported;
 use self::rustc_front::hir;
-use self::rustc_front::attr::{AttrMetaMethods};
 use self::rustc_front::visit;
 use self::syntax::ast;
+use self::syntax::attr::AttrMetaMethods;
 use self::syntax::codemap::Span;
 
 pub fn dump_crate(tcx: &ty::ctxt) {
@@ -50,7 +50,7 @@ struct OuterDump<'a,'tcx:'a> {
 }
 
 impl<'a, 'tcx> OuterDump<'a, 'tcx> {
-    fn visit_mir<OP>(&self, attributes: &'tcx [hir::Attribute], mut walk_op: OP)
+    fn visit_mir<OP>(&self, attributes: &'tcx [ast::Attribute], mut walk_op: OP)
         where OP: FnMut(&mut InnerDump<'a,'tcx>)
     {
         let mut built_mir = false;
@@ -94,7 +94,7 @@ fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
 
 struct InnerDump<'a,'tcx:'a> {
     tcx: &'a ty::ctxt<'tcx>,
-    attr: Option<&'a hir::Attribute>,
+    attr: Option<&'a ast::Attribute>,
 }
 
 impl<'a, 'tcx> visit::Visitor<'tcx> for InnerDump<'a,'tcx> {
index f15470e7851d41b133e5470748154e94506888ab..350253c5b533af0230f8ab4f6a549443eca51c5f 100644 (file)
@@ -23,6 +23,7 @@
 use tcx::rustc::middle::ty::{self, Ty};
 use tcx::rustc_front::hir;
 use tcx::rustc_front::util as hir_util;
+use tcx::syntax::ast;
 use tcx::syntax::codemap::Span;
 use tcx::syntax::parse::token;
 use tcx::syntax::ptr::P;
@@ -462,56 +463,56 @@ fn to_borrow_kind(m: hir::Mutability) -> BorrowKind {
 fn convert_literal<'a,'tcx:'a>(cx: &mut Cx<'a,'tcx>,
                                expr_span: Span,
                                expr_ty: Ty<'tcx>,
-                               literal: &hir::Lit)
+                               literal: &ast::Lit)
                                -> Literal<Cx<'a,'tcx>>
 {
     use repr::IntegralBits::*;
     match (&literal.node, &expr_ty.sty) {
-        (&hir::LitStr(ref text, _), _) =>
+        (&ast::LitStr(ref text, _), _) =>
             Literal::String { value: text.clone() },
-        (&hir::LitByteStr(ref bytes), _) =>
+        (&ast::LitByteStr(ref bytes), _) =>
             Literal::Bytes { value: bytes.clone() },
-        (&hir::LitByte(c), _) =>
+        (&ast::LitByte(c), _) =>
             Literal::Uint { bits: B8, value: c as u64 },
-        (&hir::LitChar(c), _) =>
+        (&ast::LitChar(c), _) =>
             Literal::Char { c: c },
-        (&hir::LitInt(v, _), &ty::TyUint(hir::TyU8)) =>
+        (&ast::LitInt(v, _), &ty::TyUint(ast::TyU8)) =>
             Literal::Uint { bits: B8, value: v },
-        (&hir::LitInt(v, _), &ty::TyUint(hir::TyU16)) =>
+        (&ast::LitInt(v, _), &ty::TyUint(ast::TyU16)) =>
             Literal::Uint { bits: B16, value: v },
-        (&hir::LitInt(v, _), &ty::TyUint(hir::TyU32)) =>
+        (&ast::LitInt(v, _), &ty::TyUint(ast::TyU32)) =>
             Literal::Uint { bits: B32, value: v },
-        (&hir::LitInt(v, _), &ty::TyUint(hir::TyU64)) =>
+        (&ast::LitInt(v, _), &ty::TyUint(ast::TyU64)) =>
             Literal::Uint { bits: B64, value: v },
-        (&hir::LitInt(v, _), &ty::TyUint(hir::TyUs)) =>
+        (&ast::LitInt(v, _), &ty::TyUint(ast::TyUs)) =>
             Literal::Uint { bits: BSize, value: v },
-        (&hir::LitInt(v, hir::SignedIntLit(_, hir::Sign::Minus)), &ty::TyInt(hir::TyI8)) =>
+        (&ast::LitInt(v, ast::SignedIntLit(_, ast::Sign::Minus)), &ty::TyInt(ast::TyI8)) =>
             Literal::Int { bits: B8, value: -(v as i64) },
-        (&hir::LitInt(v, hir::SignedIntLit(_, hir::Sign::Minus)), &ty::TyInt(hir::TyI16)) =>
+        (&ast::LitInt(v, ast::SignedIntLit(_, ast::Sign::Minus)), &ty::TyInt(ast::TyI16)) =>
             Literal::Int { bits: B16, value: -(v as i64) },
-        (&hir::LitInt(v, hir::SignedIntLit(_, hir::Sign::Minus)), &ty::TyInt(hir::TyI32)) =>
+        (&ast::LitInt(v, ast::SignedIntLit(_, ast::Sign::Minus)), &ty::TyInt(ast::TyI32)) =>
             Literal::Int { bits: B32, value: -(v as i64) },
-        (&hir::LitInt(v, hir::SignedIntLit(_, hir::Sign::Minus)), &ty::TyInt(hir::TyI64)) =>
+        (&ast::LitInt(v, ast::SignedIntLit(_, ast::Sign::Minus)), &ty::TyInt(ast::TyI64)) =>
             Literal::Int { bits: B64, value: -(v as i64) },
-        (&hir::LitInt(v, hir::SignedIntLit(_, hir::Sign::Minus)), &ty::TyInt(hir::TyIs)) =>
+        (&ast::LitInt(v, ast::SignedIntLit(_, ast::Sign::Minus)), &ty::TyInt(ast::TyIs)) =>
             Literal::Int { bits: BSize, value: -(v as i64) },
-        (&hir::LitInt(v, _), &ty::TyInt(hir::TyI8)) =>
+        (&ast::LitInt(v, _), &ty::TyInt(ast::TyI8)) =>
             Literal::Int { bits: B8, value: v as i64 },
-        (&hir::LitInt(v, _), &ty::TyInt(hir::TyI16)) =>
+        (&ast::LitInt(v, _), &ty::TyInt(ast::TyI16)) =>
             Literal::Int { bits: B16, value: v as i64 },
-        (&hir::LitInt(v, _), &ty::TyInt(hir::TyI32)) =>
+        (&ast::LitInt(v, _), &ty::TyInt(ast::TyI32)) =>
             Literal::Int { bits: B32, value: v as i64 },
-        (&hir::LitInt(v, _), &ty::TyInt(hir::TyI64)) =>
+        (&ast::LitInt(v, _), &ty::TyInt(ast::TyI64)) =>
             Literal::Int { bits: B64, value: v as i64 },
-        (&hir::LitInt(v, _), &ty::TyInt(hir::TyIs)) =>
+        (&ast::LitInt(v, _), &ty::TyInt(ast::TyIs)) =>
             Literal::Int { bits: BSize, value: v as i64 },
-        (&hir::LitFloat(ref v, _), &ty::TyFloat(hir::TyF32)) |
-        (&hir::LitFloatUnsuffixed(ref v), &ty::TyFloat(hir::TyF32)) =>
+        (&ast::LitFloat(ref v, _), &ty::TyFloat(ast::TyF32)) |
+        (&ast::LitFloatUnsuffixed(ref v), &ty::TyFloat(ast::TyF32)) =>
             Literal::Float { bits: FloatBits::F32, value: v.parse::<f64>().unwrap() },
-        (&hir::LitFloat(ref v, _), &ty::TyFloat(hir::TyF64)) |
-        (&hir::LitFloatUnsuffixed(ref v), &ty::TyFloat(hir::TyF64)) =>
+        (&ast::LitFloat(ref v, _), &ty::TyFloat(ast::TyF64)) |
+        (&ast::LitFloatUnsuffixed(ref v), &ty::TyFloat(ast::TyF64)) =>
             Literal::Float { bits: FloatBits::F64, value: v.parse::<f64>().unwrap() },
-        (&hir::LitBool(v), _) =>
+        (&ast::LitBool(v), _) =>
             Literal::Bool { value: v },
         (ref l, ref t) =>
             cx.tcx.sess.span_bug(
index 6e72e51d9fefa3370180a4b1fc63184227ec872a..1a2498420faa27beea11d0e6a96651ecd37d6243 100644 (file)
@@ -37,6 +37,7 @@
 use rustc::middle::def_id::DefId;
 
 use syntax::ast::{Name, NodeId};
+use syntax::attr::AttrMetaMethods;
 use syntax::parse::token::special_idents;
 use syntax::codemap::{Span, DUMMY_SP};
 
@@ -53,7 +54,6 @@
 use rustc_front::hir::UnnamedField;
 use rustc_front::hir::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple};
 use rustc_front::hir::Visibility;
-use rustc_front::attr::AttrMetaMethods;
 use rustc_front::visit::{self, Visitor};
 
 use std::mem::replace;
index 79aa4e535220ee1925c5848e55f153fc6456f0f1..8e34118957ebd8bfa5e6c8f5ceaf4c6318165f33 100644 (file)
@@ -65,7 +65,8 @@
 use rustc::util::lev_distance::lev_distance;
 
 use syntax::ast;
-use syntax::ast::{Ident, Name, NodeId, CrateNum};
+use syntax::ast::{Ident, Name, NodeId, CrateNum, TyIs, TyI8, TyI16, TyI32, TyI64};
+use syntax::ast::{TyUs, TyU8, TyU16, TyU32, TyU64, TyF64, TyF32};
 use syntax::attr::AttrMetaMethods;
 use syntax::ext::mtwt;
 use syntax::parse::token::{self, special_names, special_idents};
 use rustc_front::hir::{Local, MethodImplItem};
 use rustc_front::hir::{Pat, PatEnum, PatIdent, PatLit, PatQPath};
 use rustc_front::hir::{PatRange, PatStruct, Path, PrimTy};
-use rustc_front::hir::{TraitRef, Ty, TyBool, TyChar, TyF32};
-use rustc_front::hir::{TyF64, TyFloat, TyIs, TyI8, TyI16, TyI32, TyI64, TyInt};
-use rustc_front::hir::{TyPath, TyPtr};
-use rustc_front::hir::{TyRptr, TyStr, TyUs, TyU8, TyU16, TyU32, TyU64, TyUint};
+use rustc_front::hir::{TraitRef, Ty, TyBool, TyChar, TyFloat, TyInt};
+use rustc_front::hir::{TyRptr, TyStr, TyUint, TyPath, TyPtr};
 use rustc_front::hir::TypeImplItem;
 use rustc_front::util::walk_pat;
 
index d5486e84fc43123fc8bdbe99f94931f1e581af71..83e33ede6f23fa1240c227c2921d85cfbe547c19 100644 (file)
@@ -46,7 +46,6 @@
 use syntax::codemap::Span;
 use syntax::parse::token;
 use syntax::attr::AttrMetaMethods;
-use rustc_front::attr::AttrMetaMethods as FrontAttrMetaMethods;
 
 use rustc_front::hir;
 
index c6866004df949254f515bac2b5d81b2154c9e845..aaa10aacd036ba2f4a2f37d2863d97f327dade30 100644 (file)
@@ -905,7 +905,7 @@ fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                 compare_str(cx, lhs_data, lhs_len, rhs_data, rhs_len, rhs_t, debug_loc)
             }
             ty::TyArray(ty, _) | ty::TySlice(ty) => match ty.sty {
-                ty::TyUint(hir::TyU8) => {
+                ty::TyUint(ast::TyU8) => {
                     // NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
                     // which calls memcmp().
                     let pat_len = val_ty(rhs).element_type().array_length();
index 9b630037fe8264df5f0616d478f8c30a8175091c..de09e33ec142786b0f6442281c8b5a0e00ac65ea 100644 (file)
@@ -51,9 +51,8 @@
 use middle::ty::{self, Ty};
 use middle::ty::Disr;
 use syntax::ast;
-use rustc_front::attr;
-use rustc_front::attr::IntType;
-use rustc_front::hir;
+use syntax::attr;
+use syntax::attr::IntType;
 use trans::_match;
 use trans::build::*;
 use trans::cleanup;
@@ -387,11 +386,11 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             let ity = if use_align {
                 // Use the overall alignment
                 match align {
-                    1 => attr::UnsignedInt(hir::TyU8),
-                    2 => attr::UnsignedInt(hir::TyU16),
-                    4 => attr::UnsignedInt(hir::TyU32),
+                    1 => attr::UnsignedInt(ast::TyU8),
+                    2 => attr::UnsignedInt(ast::TyU16),
+                    4 => attr::UnsignedInt(ast::TyU32),
                     8 if machine::llalign_of_min(cx, Type::i64(cx)) == 8 =>
-                        attr::UnsignedInt(hir::TyU64),
+                        attr::UnsignedInt(ast::TyU64),
                     _ => min_ity // use min_ity as a fallback
                 }
             } else {
@@ -583,12 +582,12 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
     // Lists of sizes to try.  u64 is always allowed as a fallback.
     #[allow(non_upper_case_globals)]
     const choose_shortest: &'static [IntType] = &[
-        attr::UnsignedInt(hir::TyU8), attr::SignedInt(hir::TyI8),
-        attr::UnsignedInt(hir::TyU16), attr::SignedInt(hir::TyI16),
-        attr::UnsignedInt(hir::TyU32), attr::SignedInt(hir::TyI32)];
+        attr::UnsignedInt(ast::TyU8), attr::SignedInt(ast::TyI8),
+        attr::UnsignedInt(ast::TyU16), attr::SignedInt(ast::TyI16),
+        attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
     #[allow(non_upper_case_globals)]
     const at_least_32: &'static [IntType] = &[
-        attr::UnsignedInt(hir::TyU32), attr::SignedInt(hir::TyI32)];
+        attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
 
     let attempts;
     match hint {
@@ -622,7 +621,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
             return ity;
         }
     }
-    return attr::UnsignedInt(hir::TyU64);
+    return attr::UnsignedInt(ast::TyU64);
 }
 
 pub fn ll_inttype(cx: &CrateContext, ity: IntType) -> Type {
index c77cb49144818b4e94c3d3b3f896b503e0eb30ff..af4c2205e659b8067b981c67ff040b01b5921622 100644 (file)
@@ -15,8 +15,9 @@
 use middle::infer;
 use session::config::NoDebugInfo;
 use syntax::abi;
+pub use syntax::attr::InlineAttr;
+use syntax::ast;
 use rustc_front::hir;
-pub use rustc_front::attr::InlineAttr;
 use trans::base;
 use trans::common;
 use trans::context::CrateContext;
@@ -90,8 +91,8 @@ pub fn set_optimize_for_size(val: ValueRef, optimize: bool) {
 
 /// Composite function which sets LLVM attributes for function depending on its AST (#[attribute])
 /// attributes.
-pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[hir::Attribute], llfn: ValueRef) {
-    use rustc_front::attr::*;
+pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[ast::Attribute], llfn: ValueRef) {
+    use syntax::attr::*;
     inline(llfn, find_inline_attr(Some(ccx.sess().diagnostic()), attrs));
 
     // FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
index 1359252e0351af2e486941e0fac440a75e53fa07..89bd247b893a856e0cd877c4c32c09cb28aba93e 100644 (file)
@@ -95,9 +95,9 @@
 use syntax::abi::{Rust, RustCall, RustIntrinsic, PlatformIntrinsic, Abi};
 use syntax::codemap::Span;
 use syntax::parse::token::InternedString;
+use syntax::attr::AttrMetaMethods;
+use syntax::attr;
 use rustc_front;
-use rustc_front::attr::AttrMetaMethods;
-use rustc_front::attr;
 use rustc_front::visit::Visitor;
 use rustc_front::visit;
 use rustc_front::hir;
@@ -581,12 +581,12 @@ pub fn llty_and_min_for_signed_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
         ty::TyInt(t) => {
             let llty = Type::int_from_ty(cx.ccx(), t);
             let min = match t {
-                hir::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
-                hir::TyIs => i64::MIN as u64,
-                hir::TyI8 => i8::MIN as u64,
-                hir::TyI16 => i16::MIN as u64,
-                hir::TyI32 => i32::MIN as u64,
-                hir::TyI64 => i64::MIN as u64,
+                ast::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
+                ast::TyIs => i64::MIN as u64,
+                ast::TyI8 => i8::MIN as u64,
+                ast::TyI16 => i16::MIN as u64,
+                ast::TyI32 => i32::MIN as u64,
+                ast::TyI64 => i64::MIN as u64,
             };
             (llty, min)
         }
@@ -1563,7 +1563,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                    llfndecl: ValueRef,
                                    param_substs: &'tcx Substs<'tcx>,
                                    fn_ast_id: ast::NodeId,
-                                   _attributes: &[hir::Attribute],
+                                   _attributes: &[ast::Attribute],
                                    output_type: ty::FnOutput<'tcx>,
                                    abi: Abi,
                                    closure_env: closure::ClosureEnv<'b>) {
@@ -1682,7 +1682,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                           llfndecl: ValueRef,
                           param_substs: &'tcx Substs<'tcx>,
                           id: ast::NodeId,
-                          attrs: &[hir::Attribute]) {
+                          attrs: &[ast::Attribute]) {
     let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string());
     debug!("trans_fn(param_substs={:?})", param_substs);
     let _icx = push_ctxt("trans_fn");
@@ -2294,7 +2294,7 @@ fn create_entry_fn(ccx: &CrateContext,
 }
 
 fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, id: ast::NodeId,
-                           ty: Ty<'tcx>, attrs: &[hir::Attribute]) -> String {
+                           ty: Ty<'tcx>, attrs: &[ast::Attribute]) -> String {
     match ccx.external_srcs().borrow().get(&id) {
         Some(&did) => {
             let sym = csearch::get_symbol(&ccx.sess().cstore, did);
@@ -2492,7 +2492,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
 }
 
 fn register_method(ccx: &CrateContext, id: ast::NodeId,
-                   attrs: &[hir::Attribute], span: Span) -> ValueRef {
+                   attrs: &[ast::Attribute], span: Span) -> ValueRef {
     let mty = ccx.tcx().node_id_to_type(id);
 
     let sym = exported_name(ccx, id, mty, &attrs);
index a2d74635b5e1ce6f2a54ae350fde781565392256..0f06e3cbfa4224787a2baa842a57700314338c4d 100644 (file)
 use util::nodemap::NodeMap;
 
 use rustc_front::hir;
-use rustc_front::attr;
 
 use std::ffi::{CStr, CString};
 use libc::c_uint;
 use syntax::ast;
+use syntax::attr;
 use syntax::parse::token;
 use syntax::ptr::P;
 
 pub type FnArgMap<'a> = Option<&'a NodeMap<ValueRef>>;
 
-pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &hir::Lit)
+pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
     -> ValueRef {
     let _icx = push_ctxt("trans_lit");
     debug!("const_lit: {:?}", lit);
     match lit.node {
-        hir::LitByte(b) => C_integral(Type::uint_from_ty(cx, hir::TyU8), b as u64, false),
-        hir::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
-        hir::LitInt(i, hir::SignedIntLit(t, _)) => {
+        ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::TyU8), b as u64, false),
+        ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
+        ast::LitInt(i, ast::SignedIntLit(t, _)) => {
             C_integral(Type::int_from_ty(cx, t), i, true)
         }
-        hir::LitInt(u, hir::UnsignedIntLit(t)) => {
+        ast::LitInt(u, ast::UnsignedIntLit(t)) => {
             C_integral(Type::uint_from_ty(cx, t), u, false)
         }
-        hir::LitInt(i, hir::UnsuffixedIntLit(_)) => {
+        ast::LitInt(i, ast::UnsuffixedIntLit(_)) => {
             let lit_int_ty = cx.tcx().node_id_to_type(e.id);
             match lit_int_ty.sty {
                 ty::TyInt(t) => {
@@ -79,10 +79,10 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &hir::Lit)
                                 lit_int_ty))
             }
         }
-        hir::LitFloat(ref fs, t) => {
+        ast::LitFloat(ref fs, t) => {
             C_floating(&fs, Type::float_from_ty(cx, t))
         }
-        hir::LitFloatUnsuffixed(ref fs) => {
+        ast::LitFloatUnsuffixed(ref fs) => {
             let lit_float_ty = cx.tcx().node_id_to_type(e.id);
             match lit_float_ty.sty {
                 ty::TyFloat(t) => {
@@ -94,9 +94,9 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &hir::Lit)
                 }
             }
         }
-        hir::LitBool(b) => C_bool(cx, b),
-        hir::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()),
-        hir::LitByteStr(ref data) => {
+        ast::LitBool(b) => C_bool(cx, b),
+        ast::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()),
+        ast::LitByteStr(ref data) => {
             addr_of(cx, C_bytes(cx, &data[..]), "byte_str")
         }
     }
@@ -898,7 +898,7 @@ pub fn trans_static(ccx: &CrateContext,
                     m: hir::Mutability,
                     expr: &hir::Expr,
                     id: ast::NodeId,
-                    attrs: &Vec<hir::Attribute>)
+                    attrs: &Vec<ast::Attribute>)
                     -> ValueRef {
     unsafe {
         let _icx = push_ctxt("trans_static");
index 3d330fc1c7116df59496d6633f14fd266b919102..f7b0f37c9ff78bbbb337417310adede676f60942 100644 (file)
@@ -20,7 +20,7 @@
 
 use std::ffi::CString;
 use std::ptr;
-use rustc_front::attr;
+use syntax::attr;
 
 
 /// Inserts a side-effect free instruction sequence that makes sure that the
index a68eab953c3fa5a8d96af154bcffbbf98d7cb310..33d79662d39daae0385c79d24c80a1e427c9f13e 100644 (file)
@@ -27,7 +27,6 @@
 use middle::pat_util;
 use middle::subst::{self, Substs};
 use rustc::front::map as hir_map;
-use rustc_front;
 use rustc_front::hir;
 use trans::{type_of, adt, machine, monomorphize};
 use trans::common::{self, CrateContext, FunctionContext, Block};
@@ -43,6 +42,7 @@
 use std::path::Path;
 use std::ptr;
 use std::rc::Rc;
+use syntax;
 use syntax::util::interner::Interner;
 use syntax::codemap::Span;
 use syntax::{ast, codemap};
@@ -934,22 +934,22 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::TyBool => ("bool".to_string(), DW_ATE_boolean),
         ty::TyChar => ("char".to_string(), DW_ATE_unsigned_char),
         ty::TyInt(int_ty) => match int_ty {
-            hir::TyIs => ("isize".to_string(), DW_ATE_signed),
-            hir::TyI8 => ("i8".to_string(), DW_ATE_signed),
-            hir::TyI16 => ("i16".to_string(), DW_ATE_signed),
-            hir::TyI32 => ("i32".to_string(), DW_ATE_signed),
-            hir::TyI64 => ("i64".to_string(), DW_ATE_signed)
+            ast::TyIs => ("isize".to_string(), DW_ATE_signed),
+            ast::TyI8 => ("i8".to_string(), DW_ATE_signed),
+            ast::TyI16 => ("i16".to_string(), DW_ATE_signed),
+            ast::TyI32 => ("i32".to_string(), DW_ATE_signed),
+            ast::TyI64 => ("i64".to_string(), DW_ATE_signed)
         },
         ty::TyUint(uint_ty) => match uint_ty {
-            hir::TyUs => ("usize".to_string(), DW_ATE_unsigned),
-            hir::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
-            hir::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
-            hir::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
-            hir::TyU64 => ("u64".to_string(), DW_ATE_unsigned)
+            ast::TyUs => ("usize".to_string(), DW_ATE_unsigned),
+            ast::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
+            ast::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
+            ast::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
+            ast::TyU64 => ("u64".to_string(), DW_ATE_unsigned)
         },
         ty::TyFloat(float_ty) => match float_ty {
-            hir::TyF32 => ("f32".to_string(), DW_ATE_float),
-            hir::TyF64 => ("f64".to_string(), DW_ATE_float),
+            ast::TyF32 => ("f32".to_string(), DW_ATE_float),
+            ast::TyF64 => ("f64".to_string(), DW_ATE_float),
         },
         _ => cx.sess().bug("debuginfo::basic_type_metadata - t is invalid type")
     };
@@ -1608,7 +1608,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         })
         .collect();
 
-    let discriminant_type_metadata = |inttype: rustc_front::attr::IntType| {
+    let discriminant_type_metadata = |inttype: syntax::attr::IntType| {
         let disr_type_key = (enum_def_id, inttype);
         let cached_discriminant_type_metadata = debug_context(cx).created_enum_disr_types
                                                                  .borrow()
index dbb1355c9e6123d4c0e68f4624689fadb3d486bf..10b9ee2ac7502cf375a98a193fc2664703dcf92d 100644 (file)
@@ -31,7 +31,6 @@
 use middle::subst::{self, Substs};
 use rustc_front;
 use rustc_front::hir;
-use rustc_front::attr::IntType;
 
 use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block};
 use trans;
@@ -49,6 +48,7 @@
 
 use syntax::codemap::{Span, Pos};
 use syntax::{abi, ast, codemap};
+use syntax::attr::IntType;
 use syntax::parse::token::{self, special_idents};
 
 pub mod gdb;
index 425364407b51b6bc8b123b1abde42174e1e409e6..7400ec3cbcd4aceb19b7aeeda25f2ce99bdfe1b8 100644 (file)
@@ -18,7 +18,7 @@
 use middle::ty::{self, Ty};
 
 use rustc_front::hir;
-
+use syntax::ast;
 
 // Compute the name of the type as it should be stored in debuginfo. Does not do
 // any caching, i.e. calling the function twice with the same type will also do
@@ -43,18 +43,18 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::TyBool              => output.push_str("bool"),
         ty::TyChar              => output.push_str("char"),
         ty::TyStr               => output.push_str("str"),
-        ty::TyInt(hir::TyIs)    => output.push_str("isize"),
-        ty::TyInt(hir::TyI8)    => output.push_str("i8"),
-        ty::TyInt(hir::TyI16)   => output.push_str("i16"),
-        ty::TyInt(hir::TyI32)   => output.push_str("i32"),
-        ty::TyInt(hir::TyI64)   => output.push_str("i64"),
-        ty::TyUint(hir::TyUs)   => output.push_str("usize"),
-        ty::TyUint(hir::TyU8)   => output.push_str("u8"),
-        ty::TyUint(hir::TyU16)  => output.push_str("u16"),
-        ty::TyUint(hir::TyU32)  => output.push_str("u32"),
-        ty::TyUint(hir::TyU64)  => output.push_str("u64"),
-        ty::TyFloat(hir::TyF32) => output.push_str("f32"),
-        ty::TyFloat(hir::TyF64) => output.push_str("f64"),
+        ty::TyInt(ast::TyIs)    => output.push_str("isize"),
+        ty::TyInt(ast::TyI8)    => output.push_str("i8"),
+        ty::TyInt(ast::TyI16)   => output.push_str("i16"),
+        ty::TyInt(ast::TyI32)   => output.push_str("i32"),
+        ty::TyInt(ast::TyI64)   => output.push_str("i64"),
+        ty::TyUint(ast::TyUs)   => output.push_str("usize"),
+        ty::TyUint(ast::TyU8)   => output.push_str("u8"),
+        ty::TyUint(ast::TyU16)  => output.push_str("u16"),
+        ty::TyUint(ast::TyU32)  => output.push_str("u32"),
+        ty::TyUint(ast::TyU64)  => output.push_str("u64"),
+        ty::TyFloat(ast::TyF32) => output.push_str("f32"),
+        ty::TyFloat(ast::TyF64) => output.push_str("f64"),
         ty::TyStruct(def, substs) |
         ty::TyEnum(def, substs) => {
             push_item_name(cx, def.did, qualified, output);
index c019a0a950cba5bfd9b0ef2cf3ab6686bf875912..09d014a33823eeb80efc7d4e721625373eac636d 100644 (file)
@@ -21,8 +21,6 @@
 use trans::common::{CrateContext, FunctionContext};
 use trans::type_::Type;
 
-use rustc_front::hir;
-
 use syntax::codemap::Span;
 use syntax::{ast, codemap};
 
@@ -46,11 +44,11 @@ pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
     };
 }
 
-pub fn contains_nodebug_attribute(attributes: &[hir::Attribute]) -> bool {
+pub fn contains_nodebug_attribute(attributes: &[ast::Attribute]) -> bool {
     attributes.iter().any(|attr| {
-        let meta_item: &hir::MetaItem = &*attr.node.value;
+        let meta_item: &ast::MetaItem = &*attr.node.value;
         match meta_item.node {
-            hir::MetaWord(ref value) => &value[..] == "no_debug",
+            ast::MetaWord(ref value) => &value[..] == "no_debug",
             _ => false
         }
     })
index 7d8996867c016ff4138ec8425502ad2d6f49aeab..55c833b7686d83dae869d7ead16c93412b6d50d1 100644 (file)
@@ -83,7 +83,7 @@
 use rustc_front;
 use rustc_front::hir;
 
-use syntax::{ast, codemap};
+use syntax::{ast, ast_util, codemap};
 use syntax::parse::token::InternedString;
 use syntax::ptr::P;
 use syntax::parse::token;
@@ -1140,7 +1140,7 @@ fn make_field(field_name: &str, expr: P<hir::Expr>) -> hir::Field {
         }
         hir::ExprLit(ref lit) => {
             match lit.node {
-                hir::LitStr(ref s, _) => {
+                ast::LitStr(ref s, _) => {
                     tvec::trans_lit_str(bcx, expr, (*s).clone(), dest)
                 }
                 _ => {
@@ -1549,7 +1549,7 @@ pub fn trans_adt<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 
 fn trans_immediate_lit<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                    expr: &hir::Expr,
-                                   lit: &hir::Lit)
+                                   lit: &ast::Lit)
                                    -> DatumBlock<'blk, 'tcx, Expr> {
     // must not be a string constant, that is a RvalueDpsExpr
     let _icx = push_ctxt("trans_immediate_lit");
@@ -2381,8 +2381,8 @@ fn to_intrinsic<'blk, 'tcx>(&self, bcx: Block<'blk, 'tcx>, lhs_ty: Ty) -> ValueR
         bcx.ccx().get_intrinsic(&name)
     }
     fn to_intrinsic_name(&self, tcx: &ty::ctxt, ty: Ty) -> &'static str {
-        use rustc_front::hir::IntTy::*;
-        use rustc_front::hir::UintTy::*;
+        use syntax::ast::IntTy::*;
+        use syntax::ast::UintTy::*;
         use middle::ty::{TyInt, TyUint};
 
         let new_sty = match ty.sty {
@@ -2714,7 +2714,7 @@ fn expr_kind(tcx: &ty::ctxt, expr: &hir::Expr) -> ExprKind {
             ExprKind::RvalueDps
         }
 
-        hir::ExprLit(ref lit) if rustc_front::util::lit_is_str(&**lit) => {
+        hir::ExprLit(ref lit) if ast_util::lit_is_str(&**lit) => {
             ExprKind::RvalueDps
         }
 
index cbb092aa4eb33b3ada7e399e4a1e2b3faaf451d9..38b4cc630f8c76c4e2faf8343a54f73dfe1961d7 100644 (file)
 use libc::c_uint;
 use syntax::abi::{Cdecl, Aapcs, C, Win64, Abi};
 use syntax::abi::{PlatformIntrinsic, RustIntrinsic, Rust, RustCall, Stdcall, Fastcall, System};
+use syntax::attr;
 use syntax::codemap::Span;
 use syntax::parse::token::{InternedString, special_idents};
 use syntax::ast;
 
 use rustc_front::print::pprust;
-use rustc_front::attr;
 use rustc_front::hir;
 
 ///////////////////////////////////////////////////////////////////////////
@@ -188,7 +188,7 @@ pub fn get_extern_fn(ccx: &CrateContext,
 pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                           abi: Abi, fty: Ty<'tcx>,
                                           name: &str,
-                                          attrs: &[hir::Attribute])-> ValueRef {
+                                          attrs: &[ast::Attribute])-> ValueRef {
     debug!("register_foreign_item_fn(abi={:?}, \
             ty={:?}, \
             name={})",
@@ -577,7 +577,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
 pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                                 decl: &hir::FnDecl,
                                                 body: &hir::Block,
-                                                attrs: &[hir::Attribute],
+                                                attrs: &[ast::Attribute],
                                                 llwrapfn: ValueRef,
                                                 param_substs: &'tcx Substs<'tcx>,
                                                 id: ast::NodeId,
@@ -600,7 +600,7 @@ fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                decl: &hir::FnDecl,
                                body: &hir::Block,
                                param_substs: &'tcx Substs<'tcx>,
-                               attrs: &[hir::Attribute],
+                               attrs: &[ast::Attribute],
                                id: ast::NodeId,
                                hash: Option<&str>)
                                -> ValueRef
index 4b36734c67fdfaf094bf9444716772d5539a4ac2..d6f59bf5ca8511ff92d4b505cb82db8c835a5f13 100644 (file)
 use middle::ty::MethodCall;
 
 use syntax::ast;
+use syntax::attr;
 use syntax::codemap::DUMMY_SP;
 use syntax::ptr::P;
 
-use rustc_front::attr;
 use rustc_front::visit;
 use rustc_front::hir;
 
@@ -773,7 +773,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 fn opaque_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, method_ty: &ty::BareFnTy<'tcx>)
                           -> &'tcx ty::BareFnTy<'tcx> {
     let mut inputs = method_ty.sig.0.inputs.clone();
-    inputs[0] = tcx.mk_mut_ptr(tcx.mk_mach_int(hir::TyI8));
+    inputs[0] = tcx.mk_mut_ptr(tcx.mk_mach_int(ast::TyI8));
 
     tcx.mk_bare_fn(ty::BareFnTy {
         unsafety: method_ty.unsafety,
index 20c3f356b1122b50676b6e6832f05c901fc01b11..73784919c139125f456846bd1248278c04edc894 100644 (file)
 use rustc::front::map as hir_map;
 
 use rustc_front::hir;
-use rustc_front::attr;
 
 use syntax::abi;
 use syntax::ast;
+use syntax::attr;
 use std::hash::{Hasher, Hash, SipHasher};
 
 pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
@@ -146,7 +146,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         ccx.monomorphized().borrow_mut().insert(hash_id.take().unwrap(), lldecl);
         lldecl
     };
-    let setup_lldecl = |lldecl, attrs: &[hir::Attribute]| {
+    let setup_lldecl = |lldecl, attrs: &[ast::Attribute]| {
         base::update_linkage(ccx, lldecl, None, base::OriginalTranslation);
         attributes::from_fn_attrs(ccx, attrs, lldecl);
 
index 8deaa045c84d5d50e0da5feb0bd451e027b633c4..c7e1af5853d11a48ca3b34eef95bb3cb75d3b3a6 100644 (file)
@@ -30,6 +30,7 @@
 
 use rustc_front::hir;
 
+use syntax::ast;
 use syntax::parse::token::InternedString;
 
 #[derive(Copy, Clone)]
@@ -91,7 +92,7 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     // Handle the "..." case (returns a slice since strings are always unsized):
     if let hir::ExprLit(ref lit) = content_expr.node {
-        if let hir::LitStr(ref s, _) = lit.node {
+        if let ast::LitStr(ref s, _) = lit.node {
             let scratch = rvalue_scratch_datum(bcx, vec_ty, "");
             bcx = trans_lit_str(bcx,
                                 content_expr,
@@ -172,7 +173,7 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     match content_expr.node {
         hir::ExprLit(ref lit) => {
             match lit.node {
-                hir::LitStr(ref s, _) => {
+                ast::LitStr(ref s, _) => {
                     match dest {
                         Ignore => return bcx,
                         SaveIn(lldest) => {
@@ -268,7 +269,7 @@ fn elements_required(bcx: Block, content_expr: &hir::Expr) -> usize {
     match content_expr.node {
         hir::ExprLit(ref lit) => {
             match lit.node {
-                hir::LitStr(ref s, _) => s.len(),
+                ast::LitStr(ref s, _) => s.len(),
                 _ => {
                     bcx.tcx().sess.span_bug(content_expr.span,
                                             "unexpected evec content")
index e0df6ec35c2f9febb252d249d9763b6a46126e62..c635d1ba233fd99fd8b5757647ebf8d61033d142 100644 (file)
@@ -17,7 +17,7 @@
 use trans::context::CrateContext;
 use util::nodemap::FnvHashMap;
 
-use rustc_front::hir;
+use syntax::ast;
 
 use std::ffi::CString;
 use std::mem;
@@ -125,30 +125,30 @@ pub fn int(ccx: &CrateContext) -> Type {
         }
     }
 
-    pub fn int_from_ty(ccx: &CrateContext, t: hir::IntTy) -> Type {
+    pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
         match t {
-            hir::TyIs => ccx.int_type(),
-            hir::TyI8 => Type::i8(ccx),
-            hir::TyI16 => Type::i16(ccx),
-            hir::TyI32 => Type::i32(ccx),
-            hir::TyI64 => Type::i64(ccx)
+            ast::TyIs => ccx.int_type(),
+            ast::TyI8 => Type::i8(ccx),
+            ast::TyI16 => Type::i16(ccx),
+            ast::TyI32 => Type::i32(ccx),
+            ast::TyI64 => Type::i64(ccx)
         }
     }
 
-    pub fn uint_from_ty(ccx: &CrateContext, t: hir::UintTy) -> Type {
+    pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
         match t {
-            hir::TyUs => ccx.int_type(),
-            hir::TyU8 => Type::i8(ccx),
-            hir::TyU16 => Type::i16(ccx),
-            hir::TyU32 => Type::i32(ccx),
-            hir::TyU64 => Type::i64(ccx)
+            ast::TyUs => ccx.int_type(),
+            ast::TyU8 => Type::i8(ccx),
+            ast::TyU16 => Type::i16(ccx),
+            ast::TyU32 => Type::i32(ccx),
+            ast::TyU64 => Type::i64(ccx)
         }
     }
 
-    pub fn float_from_ty(ccx: &CrateContext, t: hir::FloatTy) -> Type {
+    pub fn float_from_ty(ccx: &CrateContext, t: ast::FloatTy) -> Type {
         match t {
-            hir::TyF32 => Type::f32(ccx),
-            hir::TyF64 => Type::f64(ccx),
+            ast::TyF32 => Type::f32(ccx),
+            ast::TyF64 => Type::f64(ccx),
         }
     }
 
index 43e1ad8115beda7f619098fc6966fafb2fd23818..b7a232822fe172323c46b1e26dcf125a960444e6 100644 (file)
@@ -21,7 +21,7 @@
 use trans::type_::Type;
 
 use syntax::abi;
-use rustc_front::hir;
+use syntax::ast;
 
 // LLVM doesn't like objects that are too big. Issue #17913
 fn ensure_array_fits_in_address_space<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
@@ -379,7 +379,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
                   let unsized_part = cx.tcx().struct_tail(ty);
                   let info_ty = match unsized_part.sty {
                       ty::TyStr | ty::TyArray(..) | ty::TySlice(_) => {
-                          Type::uint_from_ty(cx, hir::TyUs)
+                          Type::uint_from_ty(cx, ast::TyUs)
                       }
                       ty::TyTrait(_) => Type::vtable_ptr(cx),
                       _ => panic!("Unexpected type returned from \
index 2ce06786db281e86df0ec4d721861387010d2eb6..08cda74e3170dd3cf3e802ff106cb775e16a275e 100644 (file)
@@ -56,7 +56,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
             // They can denote both statically and dynamically sized byte arrays
             let mut pat_ty = expr_ty;
             if let hir::ExprLit(ref lt) = lt.node {
-                if let hir::LitByteStr(_) = lt.node {
+                if let ast::LitByteStr(_) = lt.node {
                     let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
                     if let ty::TyRef(_, mt) = expected_ty.sty {
                         if let ty::TySlice(_) = mt.ty.sty {
index 98c8c0a319946ce04ded756353d81b43f05ded8b..13e5e46ed27002fe4109908a6976a6a5a7af164d 100644 (file)
@@ -49,7 +49,8 @@
 use middle::ty::cast::{CastKind, CastTy};
 use syntax::codemap::Span;
 use rustc_front::hir;
-use rustc_front::hir::UintTy::TyU8;
+use syntax::ast;
+use syntax::ast::UintTy::TyU8;
 
 
 /// Reifies a cast check to be checked once we have full type information for
@@ -245,7 +246,7 @@ fn do_check<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<CastKind, CastError> {
             (_, Int(Bool)) => Err(CastError::CastToBool),
 
             // * -> Char
-            (Int(U(hir::TyU8)), Int(Char)) => Ok(CastKind::U8CharCast), // u8-char-cast
+            (Int(U(ast::TyU8)), Int(Char)) => Ok(CastKind::U8CharCast), // u8-char-cast
             (_, Int(Char)) => Err(CastError::CastToChar),
 
             // prim -> float,ptr
index e7c7b5831d0fc97c20bf9c1fd3f681c7d25e80eb..d87940bfa1eb27a3d36d9bd7a183093a7c4c9eca 100644 (file)
@@ -22,6 +22,7 @@
 
 use std::collections::{HashMap};
 use syntax::abi;
+use syntax::ast;
 use syntax::attr::AttrMetaMethods;
 use syntax::codemap::Span;
 use syntax::parse::token;
@@ -470,22 +471,22 @@ fn match_intrinsic_type_to_type<'tcx, 'a>(
         },
         // (The width we pass to LLVM doesn't concern the type checker.)
         Integer(signed, bits, _llvm_width) => match (signed, bits, &t.sty) {
-            (true,  8,  &ty::TyInt(hir::IntTy::TyI8)) |
-            (false, 8,  &ty::TyUint(hir::UintTy::TyU8)) |
-            (true,  16, &ty::TyInt(hir::IntTy::TyI16)) |
-            (false, 16, &ty::TyUint(hir::UintTy::TyU16)) |
-            (true,  32, &ty::TyInt(hir::IntTy::TyI32)) |
-            (false, 32, &ty::TyUint(hir::UintTy::TyU32)) |
-            (true,  64, &ty::TyInt(hir::IntTy::TyI64)) |
-            (false, 64, &ty::TyUint(hir::UintTy::TyU64)) => {},
+            (true,  8,  &ty::TyInt(ast::IntTy::TyI8)) |
+            (false, 8,  &ty::TyUint(ast::UintTy::TyU8)) |
+            (true,  16, &ty::TyInt(ast::IntTy::TyI16)) |
+            (false, 16, &ty::TyUint(ast::UintTy::TyU16)) |
+            (true,  32, &ty::TyInt(ast::IntTy::TyI32)) |
+            (false, 32, &ty::TyUint(ast::UintTy::TyU32)) |
+            (true,  64, &ty::TyInt(ast::IntTy::TyI64)) |
+            (false, 64, &ty::TyUint(ast::UintTy::TyU64)) => {},
             _ => simple_error(&format!("`{}`", t),
                               &format!("`{}{n}`",
                                        if signed {"i"} else {"u"},
                                        n = bits)),
         },
         Float(bits) => match (bits, &t.sty) {
-            (32, &ty::TyFloat(hir::FloatTy::TyF32)) |
-            (64, &ty::TyFloat(hir::FloatTy::TyF64)) => {},
+            (32, &ty::TyFloat(ast::FloatTy::TyF32)) |
+            (64, &ty::TyFloat(ast::FloatTy::TyF64)) => {},
             _ => simple_error(&format!("`{}`", t),
                               &format!("`f{n}`", n = bits)),
         },
index f65602d9aaccb0d9e9d1a348fd709cf79f9e32a3..c63b081c73c4872cb7afafb0eb0a6635f926083a 100644 (file)
@@ -319,51 +319,51 @@ fn assemble_probe(&mut self, self_ty: Ty<'tcx>) {
                 let lang_def_id = self.tcx().lang_items.mut_ptr_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyInt(hir::TyI8) => {
+            ty::TyInt(ast::TyI8) => {
                 let lang_def_id = self.tcx().lang_items.i8_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyInt(hir::TyI16) => {
+            ty::TyInt(ast::TyI16) => {
                 let lang_def_id = self.tcx().lang_items.i16_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyInt(hir::TyI32) => {
+            ty::TyInt(ast::TyI32) => {
                 let lang_def_id = self.tcx().lang_items.i32_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyInt(hir::TyI64) => {
+            ty::TyInt(ast::TyI64) => {
                 let lang_def_id = self.tcx().lang_items.i64_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyInt(hir::TyIs) => {
+            ty::TyInt(ast::TyIs) => {
                 let lang_def_id = self.tcx().lang_items.isize_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyUint(hir::TyU8) => {
+            ty::TyUint(ast::TyU8) => {
                 let lang_def_id = self.tcx().lang_items.u8_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyUint(hir::TyU16) => {
+            ty::TyUint(ast::TyU16) => {
                 let lang_def_id = self.tcx().lang_items.u16_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyUint(hir::TyU32) => {
+            ty::TyUint(ast::TyU32) => {
                 let lang_def_id = self.tcx().lang_items.u32_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyUint(hir::TyU64) => {
+            ty::TyUint(ast::TyU64) => {
                 let lang_def_id = self.tcx().lang_items.u64_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyUint(hir::TyUs) => {
+            ty::TyUint(ast::TyUs) => {
                 let lang_def_id = self.tcx().lang_items.usize_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyFloat(hir::TyF32) => {
+            ty::TyFloat(ast::TyF32) => {
                 let lang_def_id = self.tcx().lang_items.f32_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyFloat(hir::TyF64) => {
+            ty::TyFloat(ast::TyF64) => {
                 let lang_def_id = self.tcx().lang_items.f64_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
index 9dd7cfea43f6901869aada381e36fa79a1d28087..51eee67df96ec767a8fadb16810978dab0db4eb6 100644 (file)
 use std::slice;
 use syntax::abi;
 use syntax::ast;
+use syntax::attr;
+use syntax::attr::AttrMetaMethods;
 use syntax::codemap::{self, Span};
 use syntax::owned_slice::OwnedSlice;
 use syntax::parse::token::{self, InternedString};
 use rustc_front::visit::{self, Visitor};
 use rustc_front::hir;
 use rustc_front::hir::Visibility;
-use rustc_front::attr;
-use rustc_front::attr::AttrMetaMethods;
 use rustc_front::hir::{Item, ItemImpl};
 use rustc_front::print::pprust;
 
@@ -2309,7 +2309,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
 
     // First, try built-in indexing.
     match (adjusted_ty.builtin_index(), &index_ty.sty) {
-        (Some(ty), &ty::TyUint(hir::TyUs)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => {
+        (Some(ty), &ty::TyUint(ast::TyUs)) | (Some(ty), &ty::TyInfer(ty::IntVar(_))) => {
             debug!("try_index_step: success, using built-in indexing");
             // If we had `[T; N]`, we should've caught it before unsizing to `[T]`.
             assert!(!unsize);
@@ -2573,21 +2573,21 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
             let arg_ty = structurally_resolved_type(fcx, arg.span,
                                                     fcx.expr_ty(&**arg));
             match arg_ty.sty {
-                ty::TyFloat(hir::TyF32) => {
+                ty::TyFloat(ast::TyF32) => {
                     fcx.type_error_message(arg.span,
                                            |t| {
                         format!("can't pass an {} to variadic \
                                  function, cast to c_double", t)
                     }, arg_ty, None);
                 }
-                ty::TyInt(hir::TyI8) | ty::TyInt(hir::TyI16) | ty::TyBool => {
+                ty::TyInt(ast::TyI8) | ty::TyInt(ast::TyI16) | ty::TyBool => {
                     fcx.type_error_message(arg.span, |t| {
                         format!("can't pass {} to variadic \
                                  function, cast to c_int",
                                        t)
                     }, arg_ty, None);
                 }
-                ty::TyUint(hir::TyU8) | ty::TyUint(hir::TyU16) => {
+                ty::TyUint(ast::TyU8) | ty::TyUint(ast::TyU16) => {
                     fcx.type_error_message(arg.span, |t| {
                         format!("can't pass {} to variadic \
                                  function, cast to c_uint",
@@ -2616,23 +2616,23 @@ fn write_call<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
 
 // AST fragment checking
 fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
-                       lit: &hir::Lit,
+                       lit: &ast::Lit,
                        expected: Expectation<'tcx>)
                        -> Ty<'tcx>
 {
     let tcx = fcx.ccx.tcx;
 
     match lit.node {
-        hir::LitStr(..) => tcx.mk_static_str(),
-        hir::LitByteStr(ref v) => {
+        ast::LitStr(..) => tcx.mk_static_str(),
+        ast::LitByteStr(ref v) => {
             tcx.mk_imm_ref(tcx.mk_region(ty::ReStatic),
                             tcx.mk_array(tcx.types.u8, v.len()))
         }
-        hir::LitByte(_) => tcx.types.u8,
-        hir::LitChar(_) => tcx.types.char,
-        hir::LitInt(_, hir::SignedIntLit(t, _)) => tcx.mk_mach_int(t),
-        hir::LitInt(_, hir::UnsignedIntLit(t)) => tcx.mk_mach_uint(t),
-        hir::LitInt(_, hir::UnsuffixedIntLit(_)) => {
+        ast::LitByte(_) => tcx.types.u8,
+        ast::LitChar(_) => tcx.types.char,
+        ast::LitInt(_, ast::SignedIntLit(t, _)) => tcx.mk_mach_int(t),
+        ast::LitInt(_, ast::UnsignedIntLit(t)) => tcx.mk_mach_uint(t),
+        ast::LitInt(_, ast::UnsuffixedIntLit(_)) => {
             let opt_ty = expected.to_option(fcx).and_then(|ty| {
                 match ty.sty {
                     ty::TyInt(_) | ty::TyUint(_) => Some(ty),
@@ -2645,8 +2645,8 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
             opt_ty.unwrap_or_else(
                 || tcx.mk_int_var(fcx.infcx().next_int_var_id()))
         }
-        hir::LitFloat(_, t) => tcx.mk_mach_float(t),
-        hir::LitFloatUnsuffixed(_) => {
+        ast::LitFloat(_, t) => tcx.mk_mach_float(t),
+        ast::LitFloatUnsuffixed(_) => {
             let opt_ty = expected.to_option(fcx).and_then(|ty| {
                 match ty.sty {
                     ty::TyFloat(_) => Some(ty),
@@ -2656,7 +2656,7 @@ fn check_lit<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
             opt_ty.unwrap_or_else(
                 || tcx.mk_float_var(fcx.infcx().next_float_var_id()))
         }
-        hir::LitBool(_) => tcx.types.bool
+        ast::LitBool(_) => tcx.types.bool
     }
 }
 
@@ -4219,22 +4219,22 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
     fn disr_in_range(ccx: &CrateCtxt,
                      ty: attr::IntType,
                      disr: ty::Disr) -> bool {
-        fn uint_in_range(ccx: &CrateCtxt, ty: hir::UintTy, disr: ty::Disr) -> bool {
+        fn uint_in_range(ccx: &CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool {
             match ty {
-                hir::TyU8 => disr as u8 as Disr == disr,
-                hir::TyU16 => disr as u16 as Disr == disr,
-                hir::TyU32 => disr as u32 as Disr == disr,
-                hir::TyU64 => disr as u64 as Disr == disr,
-                hir::TyUs => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
+                ast::TyU8 => disr as u8 as Disr == disr,
+                ast::TyU16 => disr as u16 as Disr == disr,
+                ast::TyU32 => disr as u32 as Disr == disr,
+                ast::TyU64 => disr as u64 as Disr == disr,
+                ast::TyUs => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
             }
         }
-        fn int_in_range(ccx: &CrateCtxt, ty: hir::IntTy, disr: ty::Disr) -> bool {
+        fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
             match ty {
-                hir::TyI8 => disr as i8 as Disr == disr,
-                hir::TyI16 => disr as i16 as Disr == disr,
-                hir::TyI32 => disr as i32 as Disr == disr,
-                hir::TyI64 => disr as i64 as Disr == disr,
-                hir::TyIs => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
+                ast::TyI8 => disr as i8 as Disr == disr,
+                ast::TyI16 => disr as i16 as Disr == disr,
+                ast::TyI32 => disr as i32 as Disr == disr,
+                ast::TyI64 => disr as i64 as Disr == disr,
+                ast::TyIs => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
             }
         }
         match ty {
index 022f1e3646a12f6e599ff1754e9b1985e99436e7..43ae33ac596a0450bafafa7e0137e684a3e6c739 100644 (file)
@@ -14,6 +14,7 @@
 use middle::def_id::{DefId, LOCAL_CRATE};
 use middle::traits;
 use middle::ty;
+use syntax::ast;
 use syntax::codemap::Span;
 use rustc_front::visit;
 use rustc_front::hir;
@@ -119,84 +120,84 @@ fn check_item(&self, item: &hir::Item) {
                                                   "*mut T",
                                                   item.span);
                     }
-                    ty::TyInt(hir::TyI8) => {
+                    ty::TyInt(ast::TyI8) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.i8_impl(),
                                                   "i8",
                                                   "i8",
                                                   item.span);
                     }
-                    ty::TyInt(hir::TyI16) => {
+                    ty::TyInt(ast::TyI16) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.i16_impl(),
                                                   "i16",
                                                   "i16",
                                                   item.span);
                     }
-                    ty::TyInt(hir::TyI32) => {
+                    ty::TyInt(ast::TyI32) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.i32_impl(),
                                                   "i32",
                                                   "i32",
                                                   item.span);
                     }
-                    ty::TyInt(hir::TyI64) => {
+                    ty::TyInt(ast::TyI64) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.i64_impl(),
                                                   "i64",
                                                   "i64",
                                                   item.span);
                     }
-                    ty::TyInt(hir::TyIs) => {
+                    ty::TyInt(ast::TyIs) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.isize_impl(),
                                                   "isize",
                                                   "isize",
                                                   item.span);
                     }
-                    ty::TyUint(hir::TyU8) => {
+                    ty::TyUint(ast::TyU8) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.u8_impl(),
                                                   "u8",
                                                   "u8",
                                                   item.span);
                     }
-                    ty::TyUint(hir::TyU16) => {
+                    ty::TyUint(ast::TyU16) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.u16_impl(),
                                                   "u16",
                                                   "u16",
                                                   item.span);
                     }
-                    ty::TyUint(hir::TyU32) => {
+                    ty::TyUint(ast::TyU32) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.u32_impl(),
                                                   "u32",
                                                   "u32",
                                                   item.span);
                     }
-                    ty::TyUint(hir::TyU64) => {
+                    ty::TyUint(ast::TyU64) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.u64_impl(),
                                                   "u64",
                                                   "u64",
                                                   item.span);
                     }
-                    ty::TyUint(hir::TyUs) => {
+                    ty::TyUint(ast::TyUs) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.usize_impl(),
                                                   "usize",
                                                   "usize",
                                                   item.span);
                     }
-                    ty::TyFloat(hir::TyF32) => {
+                    ty::TyFloat(ast::TyF32) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.f32_impl(),
                                                   "f32",
                                                   "f32",
                                                   item.span);
                     }
-                    ty::TyFloat(hir::TyF64) => {
+                    ty::TyFloat(ast::TyF64) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.f64_impl(),
                                                   "f64",
index f7520ed54b77e3f153d8782fb9c1c29ccf29a190..f00e5465e47742a78bd8d37876b514aec5cb728e 100644 (file)
 
 use syntax::abi;
 use syntax::ast;
+use syntax::attr;
 use syntax::codemap::Span;
 use syntax::parse::token::special_idents;
 use syntax::ptr::P;
 use rustc_front::hir;
 use rustc_front::visit;
-use rustc_front::attr;
 use rustc_front::print::pprust;
 
 ///////////////////////////////////////////////////////////////////////////
index c9af86f06db9325ee1ca4d7c96929767b7ca51ba..930bc831028f03df0a4ecef999916b2d289bbe81 100644 (file)
@@ -13,7 +13,7 @@
 use std::collections::HashSet;
 
 use syntax::ast;
-use rustc_front::attr::AttrMetaMethods;
+use syntax::attr::AttrMetaMethods;
 use rustc_front::hir;
 
 use rustc::metadata::csearch;
index 7ef359787e87e1b6438e9737f85af75785e0d069..8737957c0656144bb5d47aa97f711d3f79644ecc 100644 (file)
@@ -27,6 +27,8 @@
 use syntax;
 use syntax::abi;
 use syntax::ast;
+use syntax::attr;
+use syntax::attr::{AttributeMethods, AttrMetaMethods};
 use syntax::codemap;
 use syntax::codemap::{DUMMY_SP, Pos, Spanned};
 use syntax::parse::token::{self, InternedString, special_idents};
@@ -43,9 +45,6 @@
 use rustc::middle::stability;
 
 use rustc_front::hir;
-use rustc_front::attr;
-use rustc_front::attr::{AttributeMethods, AttrMetaMethods};
-use rustc_front::lowering::unlower_attribute;
 
 use std::collections::HashMap;
 use std::path::PathBuf;
@@ -143,8 +142,7 @@ fn clean(&self, cx: &DocContext) -> Crate {
 
         // Figure out the name of this crate
         let input = &cx.input;
-        let attrs: Vec<_> = self.attrs.iter().map(|a| unlower_attribute(a)).collect();
-        let name = link::find_crate_name(None, &attrs, input);
+        let name = link::find_crate_name(None, &self.attrs, input);
 
         // Clean the crate, translating the entire libsyntax AST to one that is
         // understood by rustdoc.
@@ -437,21 +435,21 @@ pub enum Attribute {
     NameValue(String, String)
 }
 
-impl Clean<Attribute> for hir::MetaItem {
+impl Clean<Attribute> for ast::MetaItem {
     fn clean(&self, cx: &DocContext) -> Attribute {
         match self.node {
-            hir::MetaWord(ref s) => Word(s.to_string()),
-            hir::MetaList(ref s, ref l) => {
+            ast::MetaWord(ref s) => Word(s.to_string()),
+            ast::MetaList(ref s, ref l) => {
                 List(s.to_string(), l.clean(cx))
             }
-            hir::MetaNameValue(ref s, ref v) => {
+            ast::MetaNameValue(ref s, ref v) => {
                 NameValue(s.to_string(), lit_to_string(v))
             }
         }
     }
 }
 
-impl Clean<Attribute> for hir::Attribute {
+impl Clean<Attribute> for ast::Attribute {
     fn clean(&self, cx: &DocContext) -> Attribute {
         self.with_desugared_doc(|a| a.node.value.clean(cx))
     }
@@ -475,13 +473,13 @@ fn value_str(&self) -> Option<InternedString> {
             _ => None,
         }
     }
-    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<hir::MetaItem>]> { None }
+    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<ast::MetaItem>]> { None }
     fn span(&self) -> codemap::Span { unimplemented!() }
 }
 impl<'a> attr::AttrMetaMethods for &'a Attribute {
     fn name(&self) -> InternedString { (**self).name() }
     fn value_str(&self) -> Option<InternedString> { (**self).value_str() }
-    fn meta_item_list(&self) -> Option<&[P<hir::MetaItem>]> { None }
+    fn meta_item_list(&self) -> Option<&[P<ast::MetaItem>]> { None }
     fn span(&self) -> codemap::Span { unimplemented!() }
 }
 
@@ -1626,18 +1624,18 @@ fn clean(&self, cx: &DocContext) -> Type {
         match self.sty {
             ty::TyBool => Primitive(Bool),
             ty::TyChar => Primitive(Char),
-            ty::TyInt(hir::TyIs) => Primitive(Isize),
-            ty::TyInt(hir::TyI8) => Primitive(I8),
-            ty::TyInt(hir::TyI16) => Primitive(I16),
-            ty::TyInt(hir::TyI32) => Primitive(I32),
-            ty::TyInt(hir::TyI64) => Primitive(I64),
-            ty::TyUint(hir::TyUs) => Primitive(Usize),
-            ty::TyUint(hir::TyU8) => Primitive(U8),
-            ty::TyUint(hir::TyU16) => Primitive(U16),
-            ty::TyUint(hir::TyU32) => Primitive(U32),
-            ty::TyUint(hir::TyU64) => Primitive(U64),
-            ty::TyFloat(hir::TyF32) => Primitive(F32),
-            ty::TyFloat(hir::TyF64) => Primitive(F64),
+            ty::TyInt(ast::TyIs) => Primitive(Isize),
+            ty::TyInt(ast::TyI8) => Primitive(I8),
+            ty::TyInt(ast::TyI16) => Primitive(I16),
+            ty::TyInt(ast::TyI32) => Primitive(I32),
+            ty::TyInt(ast::TyI64) => Primitive(I64),
+            ty::TyUint(ast::TyUs) => Primitive(Usize),
+            ty::TyUint(ast::TyU8) => Primitive(U8),
+            ty::TyUint(ast::TyU16) => Primitive(U16),
+            ty::TyUint(ast::TyU32) => Primitive(U32),
+            ty::TyUint(ast::TyU64) => Primitive(U64),
+            ty::TyFloat(ast::TyF32) => Primitive(F32),
+            ty::TyFloat(ast::TyF64) => Primitive(F64),
             ty::TyStr => Primitive(Str),
             ty::TyBox(t) => {
                 let box_did = cx.tcx_opt().and_then(|tcx| {
@@ -2515,11 +2513,11 @@ fn to_src(&self, cx: &DocContext) -> String {
     }
 }
 
-fn lit_to_string(lit: &hir::Lit) -> String {
+fn lit_to_string(lit: &ast::Lit) -> String {
     match lit.node {
-        hir::LitStr(ref st, _) => st.to_string(),
-        hir::LitByteStr(ref data) => format!("{:?}", data),
-        hir::LitByte(b) => {
+        ast::LitStr(ref st, _) => st.to_string(),
+        ast::LitByteStr(ref data) => format!("{:?}", data),
+        ast::LitByte(b) => {
             let mut res = String::from("b'");
             for c in (b as char).escape_default() {
                 res.push(c);
@@ -2527,11 +2525,11 @@ fn lit_to_string(lit: &hir::Lit) -> String {
             res.push('\'');
             res
         },
-        hir::LitChar(c) => format!("'{}'", c),
-        hir::LitInt(i, _t) => i.to_string(),
-        hir::LitFloat(ref f, _t) => f.to_string(),
-        hir::LitFloatUnsuffixed(ref f) => f.to_string(),
-        hir::LitBool(b) => b.to_string(),
+        ast::LitChar(c) => format!("'{}'", c),
+        ast::LitInt(i, _t) => i.to_string(),
+        ast::LitFloat(ref f, _t) => f.to_string(),
+        ast::LitFloatUnsuffixed(ref f) => f.to_string(),
+        ast::LitBool(b) => b.to_string(),
     }
 }
 
@@ -2594,18 +2592,18 @@ fn resolve_type(cx: &DocContext,
             hir::TyStr => return Primitive(Str),
             hir::TyBool => return Primitive(Bool),
             hir::TyChar => return Primitive(Char),
-            hir::TyInt(hir::TyIs) => return Primitive(Isize),
-            hir::TyInt(hir::TyI8) => return Primitive(I8),
-            hir::TyInt(hir::TyI16) => return Primitive(I16),
-            hir::TyInt(hir::TyI32) => return Primitive(I32),
-            hir::TyInt(hir::TyI64) => return Primitive(I64),
-            hir::TyUint(hir::TyUs) => return Primitive(Usize),
-            hir::TyUint(hir::TyU8) => return Primitive(U8),
-            hir::TyUint(hir::TyU16) => return Primitive(U16),
-            hir::TyUint(hir::TyU32) => return Primitive(U32),
-            hir::TyUint(hir::TyU64) => return Primitive(U64),
-            hir::TyFloat(hir::TyF32) => return Primitive(F32),
-            hir::TyFloat(hir::TyF64) => return Primitive(F64),
+            hir::TyInt(ast::TyIs) => return Primitive(Isize),
+            hir::TyInt(ast::TyI8) => return Primitive(I8),
+            hir::TyInt(ast::TyI16) => return Primitive(I16),
+            hir::TyInt(ast::TyI32) => return Primitive(I32),
+            hir::TyInt(ast::TyI64) => return Primitive(I64),
+            hir::TyUint(ast::TyUs) => return Primitive(Usize),
+            hir::TyUint(ast::TyU8) => return Primitive(U8),
+            hir::TyUint(ast::TyU16) => return Primitive(U16),
+            hir::TyUint(ast::TyU32) => return Primitive(U32),
+            hir::TyUint(ast::TyU64) => return Primitive(U64),
+            hir::TyFloat(ast::TyF32) => return Primitive(F32),
+            hir::TyFloat(ast::TyF64) => return Primitive(F64),
         },
         def::DefSelfTy(..) if path.segments.len() == 1 => {
             return Generic(special_idents::type_self.name.to_string());
index 5140cca03ea340eb1ffc0c0301330f7682f57dff..1a027a3d146360b04054b620cc5a0ab01e0acaf8 100644 (file)
 use syntax::abi;
 use syntax::ast;
 use syntax::ast::{Ident, NodeId};
+use syntax::attr;
 use syntax::ptr::P;
 use rustc_front::hir;
-use rustc_front::attr;
 
 pub struct Module {
     pub name: Option<Ident>,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub where_outer: Span,
     pub where_inner: Span,
     pub extern_crates: Vec<ExternCrate>,
@@ -100,7 +100,7 @@ pub struct Struct {
     pub struct_type: StructType,
     pub name: Ident,
     pub generics: hir::Generics,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub fields: Vec<hir::StructField>,
     pub whence: Span,
 }
@@ -110,7 +110,7 @@ pub struct Enum {
     pub stab: Option<attr::Stability>,
     pub variants: Vec<Variant>,
     pub generics: hir::Generics,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub id: NodeId,
     pub whence: Span,
     pub name: Ident,
@@ -118,7 +118,7 @@ pub struct Enum {
 
 pub struct Variant {
     pub name: Ident,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub kind: hir::VariantKind,
     pub id: ast::NodeId,
     pub vis: hir::Visibility,
@@ -128,7 +128,7 @@ pub struct Variant {
 
 pub struct Function {
     pub decl: hir::FnDecl,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub id: NodeId,
     pub name: Ident,
     pub vis: hir::Visibility,
@@ -145,7 +145,7 @@ pub struct Typedef {
     pub gen: hir::Generics,
     pub name: Ident,
     pub id: ast::NodeId,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub whence: Span,
     pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
@@ -157,7 +157,7 @@ pub struct Static {
     pub mutability: hir::Mutability,
     pub expr: P<hir::Expr>,
     pub name: Ident,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub id: ast::NodeId,
@@ -168,7 +168,7 @@ pub struct Constant {
     pub type_: P<hir::Ty>,
     pub expr: P<hir::Expr>,
     pub name: Ident,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub id: ast::NodeId,
@@ -181,7 +181,7 @@ pub struct Trait {
     pub items: Vec<P<hir::TraitItem>>, //should be TraitItem
     pub generics: hir::Generics,
     pub bounds: Vec<hir::TyParamBound>,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub id: ast::NodeId,
     pub whence: Span,
     pub vis: hir::Visibility,
@@ -195,7 +195,7 @@ pub struct Impl {
     pub trait_: Option<hir::TraitRef>,
     pub for_: P<hir::Ty>,
     pub items: Vec<P<hir::ImplItem>>,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub whence: Span,
     pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
@@ -206,14 +206,14 @@ pub struct DefaultImpl {
     pub unsafety: hir::Unsafety,
     pub trait_: hir::TraitRef,
     pub id: ast::NodeId,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub whence: Span,
 }
 
 pub struct Macro {
     pub name: Ident,
     pub id: ast::NodeId,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub whence: Span,
     pub stab: Option<attr::Stability>,
     pub imported_from: Option<Ident>,
@@ -223,14 +223,14 @@ pub struct ExternCrate {
     pub name: Ident,
     pub path: Option<String>,
     pub vis: hir::Visibility,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub whence: Span,
 }
 
 pub struct Import {
     pub id: NodeId,
     pub vis: hir::Visibility,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub node: hir::ViewPath_,
     pub whence: Span,
 }
index 86b268001a6aeb357e682abac729a6492b7ab370..b34f1a01a2b0eaf04827ae9645b2ba25c168e6ab 100644 (file)
 use externalfiles::ExternalHtml;
 
 use serialize::json::{self, ToJson};
-use syntax::{abi, ast};
+use syntax::{abi, ast, attr};
 use rustc::middle::def_id::{DefId, LOCAL_CRATE};
 use rustc::util::nodemap::NodeSet;
-use rustc_front::{hir, attr};
+use rustc_front::hir;
 
 use clean::{self, SelfTy};
 use doctree;
index 95215cf2d5caf76985e1ff49cf1f9a9f53f2ffba..2f47353fee7b299dca31520fb1afffdbdde54ca3 100644 (file)
@@ -124,8 +124,8 @@ pub fn run(input: &str,
 
 // Look for #![doc(test(no_crate_inject))], used by crates in the std facade
 fn scrape_test_config(krate: &::rustc_front::hir::Crate) -> TestOptions {
-    use rustc_front::attr::AttrMetaMethods;
-    use rustc_front::print::pprust;
+    use syntax::attr::AttrMetaMethods;
+    use syntax::print::pprust;
 
     let mut opts = TestOptions {
         no_crate_inject: false,
index 978b572ac9372e539ca496cdb7808b7228721e8f..e3fb13d13906d3b8a06d42a47e425bd850b13e05 100644 (file)
 
 use syntax::abi;
 use syntax::ast;
+use syntax::attr;
+use syntax::attr::AttrMetaMethods;
 use syntax::codemap::Span;
 
 use rustc::front::map as hir_map;
 use rustc::middle::def_id::DefId;
 use rustc::middle::stability;
 
-use rustc_front::attr;
-use rustc_front::attr::AttrMetaMethods;
 use rustc_front::hir;
 
 use core;
@@ -39,7 +39,7 @@
 
 pub struct RustdocVisitor<'a, 'tcx: 'a> {
     pub module: Module,
-    pub attrs: Vec<hir::Attribute>,
+    pub attrs: Vec<ast::Attribute>,
     pub cx: &'a core::DocContext<'a, 'tcx>,
     pub analysis: Option<&'a core::CrateAnalysis>,
     view_item_stack: HashSet<ast::NodeId>,
@@ -146,7 +146,7 @@ pub fn visit_fn(&mut self, item: &hir::Item,
         }
     }
 
-    pub fn visit_mod_contents(&mut self, span: Span, attrs: Vec<hir::Attribute> ,
+    pub fn visit_mod_contents(&mut self, span: Span, attrs: Vec<ast::Attribute> ,
                               vis: hir::Visibility, id: ast::NodeId,
                               m: &hir::Mod,
                               name: Option<ast::Ident>) -> Module {
index 555fdc1ff864759a62e01f9790d08a2d79227d7d..b00ff85051c9a5b4407dbf3ca47702647a00f33c 100644 (file)
@@ -54,8 +54,8 @@ impl PpAnn for NoAnn {}
 
 #[derive(Copy, Clone)]
 pub struct CurrentCommentAndLiteral {
-    cur_cmnt: usize,
-    cur_lit: usize,
+    pub cur_cmnt: usize,
+    pub cur_lit: usize,
 }
 
 pub struct State<'a> {
@@ -450,43 +450,369 @@ fn needs_parentheses(expr: &ast::Expr) -> bool {
     }
 }
 
-impl<'a> State<'a> {
-    pub fn ibox(&mut self, u: usize) -> io::Result<()> {
-        self.boxes.push(pp::Breaks::Inconsistent);
-        pp::ibox(&mut self.s, u)
+pub trait PrintState<'a> {
+    fn writer(&mut self) -> &mut pp::Printer<'a>;
+    fn boxes(&mut self) -> &mut Vec<pp::Breaks>;
+    fn comments(&mut self) -> &mut Option<Vec<comments::Comment>>;
+    fn cur_cmnt_and_lit(&mut self) -> &mut CurrentCommentAndLiteral;
+    fn literals(&self) -> &Option<Vec<comments::Literal>>;
+
+    fn word_space(&mut self, w: &str) -> io::Result<()> {
+        try!(word(self.writer(), w));
+        space(self.writer())
     }
 
-    pub fn end(&mut self) -> io::Result<()> {
-        self.boxes.pop().unwrap();
-        pp::end(&mut self.s)
+    fn popen(&mut self) -> io::Result<()> { word(self.writer(), "(") }
+
+    fn pclose(&mut self) -> io::Result<()> { word(self.writer(), ")") }
+
+    fn is_begin(&mut self) -> bool {
+        match self.writer().last_token() {
+            pp::Token::Begin(_) => true,
+            _ => false,
+        }
     }
 
-    pub fn cbox(&mut self, u: usize) -> io::Result<()> {
-        self.boxes.push(pp::Breaks::Consistent);
-        pp::cbox(&mut self.s, u)
+    fn is_end(&mut self) -> bool {
+        match self.writer().last_token() {
+            pp::Token::End => true,
+            _ => false,
+        }
+    }
+
+    // is this the beginning of a line?
+    fn is_bol(&mut self) -> bool {
+        self.writer().last_token().is_eof() || self.writer().last_token().is_hardbreak_tok()
+    }
+
+    fn hardbreak_if_not_bol(&mut self) -> io::Result<()> {
+        if !self.is_bol() {
+            try!(hardbreak(self.writer()))
+        }
+        Ok(())
     }
 
     // "raw box"
-    pub fn rbox(&mut self, u: usize, b: pp::Breaks) -> io::Result<()> {
-        self.boxes.push(b);
-        pp::rbox(&mut self.s, u, b)
+    fn rbox(&mut self, u: usize, b: pp::Breaks) -> io::Result<()> {
+        self.boxes().push(b);
+        pp::rbox(self.writer(), u, b)
     }
 
-    pub fn nbsp(&mut self) -> io::Result<()> { word(&mut self.s, " ") }
+    fn ibox(&mut self, u: usize) -> io::Result<()> {
+        self.boxes().push(pp::Breaks::Inconsistent);
+        pp::ibox(self.writer(), u)
+    }
 
-    pub fn word_nbsp(&mut self, w: &str) -> io::Result<()> {
-        try!(word(&mut self.s, w));
-        self.nbsp()
+    fn end(&mut self) -> io::Result<()> {
+        self.boxes().pop().unwrap();
+        pp::end(self.writer())
     }
 
-    pub fn word_space(&mut self, w: &str) -> io::Result<()> {
-        try!(word(&mut self.s, w));
-        space(&mut self.s)
+    fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], mut op: F) -> io::Result<()>
+        where F: FnMut(&mut Self, &T) -> io::Result<()>,
+    {
+        try!(self.rbox(0, b));
+        let mut first = true;
+        for elt in elts {
+            if first { first = false; } else { try!(self.word_space(",")); }
+            try!(op(self, elt));
+        }
+        self.end()
+    }
+
+
+    fn next_lit(&mut self, pos: BytePos) -> Option<comments::Literal> {
+        let mut cur_lit = self.cur_cmnt_and_lit().cur_lit;
+
+        let mut result = None;
+
+        if let &Some(ref lits) = self.literals()
+        {
+            while cur_lit < lits.len() {
+                let ltrl = (*lits)[cur_lit].clone();
+                if ltrl.pos > pos { break; }
+                cur_lit += 1;
+                if ltrl.pos == pos {
+                    result = Some(ltrl);
+                    break;
+                }
+            }
+        }
+
+        self.cur_cmnt_and_lit().cur_lit = cur_lit;
+        result
+    }
+
+    fn maybe_print_comment(&mut self, pos: BytePos) -> io::Result<()> {
+        loop {
+            match self.next_comment() {
+                Some(ref cmnt) => {
+                    if (*cmnt).pos < pos {
+                        try!(self.print_comment(cmnt));
+                        self.cur_cmnt_and_lit().cur_cmnt += 1;
+                    } else { break; }
+                }
+                _ => break
+            }
+        }
+        Ok(())
+    }
+
+    fn print_comment(&mut self,
+                     cmnt: &comments::Comment) -> io::Result<()> {
+        match cmnt.style {
+            comments::Mixed => {
+                assert_eq!(cmnt.lines.len(), 1);
+                try!(zerobreak(self.writer()));
+                try!(word(self.writer(), &cmnt.lines[0]));
+                zerobreak(self.writer())
+            }
+            comments::Isolated => {
+                try!(self.hardbreak_if_not_bol());
+                for line in &cmnt.lines {
+                    // Don't print empty lines because they will end up as trailing
+                    // whitespace
+                    if !line.is_empty() {
+                        try!(word(self.writer(), &line[..]));
+                    }
+                    try!(hardbreak(self.writer()));
+                }
+                Ok(())
+            }
+            comments::Trailing => {
+                try!(word(self.writer(), " "));
+                if cmnt.lines.len() == 1 {
+                    try!(word(self.writer(), &cmnt.lines[0]));
+                    hardbreak(self.writer())
+                } else {
+                    try!(self.ibox(0));
+                    for line in &cmnt.lines {
+                        if !line.is_empty() {
+                            try!(word(self.writer(), &line[..]));
+                        }
+                        try!(hardbreak(self.writer()));
+                    }
+                    self.end()
+                }
+            }
+            comments::BlankLine => {
+                // We need to do at least one, possibly two hardbreaks.
+                let is_semi = match self.writer().last_token() {
+                    pp::Token::String(s, _) => ";" == s,
+                    _ => false
+                };
+                if is_semi || self.is_begin() || self.is_end() {
+                    try!(hardbreak(self.writer()));
+                }
+                hardbreak(self.writer())
+            }
+        }
+    }
+
+    fn next_comment(&mut self) -> Option<comments::Comment> {
+        let cur_cmnt = self.cur_cmnt_and_lit().cur_cmnt;
+        match *self.comments() {
+            Some(ref cmnts) => {
+                if cur_cmnt < cmnts.len() {
+                    Some(cmnts[cur_cmnt].clone())
+                } else {
+                    None
+                }
+            }
+            _ => None
+        }
+    }
+
+    fn print_literal(&mut self, lit: &ast::Lit) -> io::Result<()> {
+        try!(self.maybe_print_comment(lit.span.lo));
+        match self.next_lit(lit.span.lo) {
+            Some(ref ltrl) => {
+                return word(self.writer(), &(*ltrl).lit);
+            }
+            _ => ()
+        }
+        match lit.node {
+            ast::LitStr(ref st, style) => self.print_string(&st, style),
+            ast::LitByte(byte) => {
+                let mut res = String::from("b'");
+                res.extend(ascii::escape_default(byte).map(|c| c as char));
+                res.push('\'');
+                word(self.writer(), &res[..])
+            }
+            ast::LitChar(ch) => {
+                let mut res = String::from("'");
+                res.extend(ch.escape_default());
+                res.push('\'');
+                word(self.writer(), &res[..])
+            }
+            ast::LitInt(i, t) => {
+                match t {
+                    ast::SignedIntLit(st, ast::Plus) => {
+                        word(self.writer(),
+                             &ast_util::int_ty_to_string(st, Some(i as i64)))
+                    }
+                    ast::SignedIntLit(st, ast::Minus) => {
+                        let istr = ast_util::int_ty_to_string(st, Some(-(i as i64)));
+                        word(self.writer(),
+                             &format!("-{}", istr))
+                    }
+                    ast::UnsignedIntLit(ut) => {
+                        word(self.writer(), &ast_util::uint_ty_to_string(ut, Some(i)))
+                    }
+                    ast::UnsuffixedIntLit(ast::Plus) => {
+                        word(self.writer(), &format!("{}", i))
+                    }
+                    ast::UnsuffixedIntLit(ast::Minus) => {
+                        word(self.writer(), &format!("-{}", i))
+                    }
+                }
+            }
+            ast::LitFloat(ref f, t) => {
+                word(self.writer(),
+                     &format!(
+                         "{}{}",
+                         &f,
+                         &ast_util::float_ty_to_string(t)))
+            }
+            ast::LitFloatUnsuffixed(ref f) => word(self.writer(), &f[..]),
+            ast::LitBool(val) => {
+                if val { word(self.writer(), "true") } else { word(self.writer(), "false") }
+            }
+            ast::LitByteStr(ref v) => {
+                let mut escaped: String = String::new();
+                for &ch in v.iter() {
+                    escaped.extend(ascii::escape_default(ch)
+                                         .map(|c| c as char));
+                }
+                word(self.writer(), &format!("b\"{}\"", escaped))
+            }
+        }
+    }
+
+    fn print_string(&mut self, st: &str,
+                    style: ast::StrStyle) -> io::Result<()> {
+        let st = match style {
+            ast::CookedStr => {
+                (format!("\"{}\"", st.escape_default()))
+            }
+            ast::RawStr(n) => {
+                (format!("r{delim}\"{string}\"{delim}",
+                         delim=repeat("#", n),
+                         string=st))
+            }
+        };
+        word(self.writer(), &st[..])
+    }
+
+    fn print_inner_attributes(&mut self,
+                                  attrs: &[ast::Attribute]) -> io::Result<()> {
+        let mut count = 0;
+        for attr in attrs {
+            match attr.node.style {
+                ast::AttrInner => {
+                    try!(self.print_attribute(attr));
+                    count += 1;
+                }
+                _ => {/* fallthrough */ }
+            }
+        }
+        if count > 0 {
+            try!(self.hardbreak_if_not_bol());
+        }
+        Ok(())
+    }
+
+    fn print_outer_attributes(&mut self,
+                              attrs: &[ast::Attribute]) -> io::Result<()> {
+        let mut count = 0;
+        for attr in attrs {
+            match attr.node.style {
+                ast::AttrOuter => {
+                    try!(self.print_attribute(attr));
+                    count += 1;
+                }
+                _ => {/* fallthrough */ }
+            }
+        }
+        if count > 0 {
+            try!(self.hardbreak_if_not_bol());
+        }
+        Ok(())
+    }
+
+    fn print_attribute(&mut self, attr: &ast::Attribute) -> io::Result<()> {
+        try!(self.hardbreak_if_not_bol());
+        try!(self.maybe_print_comment(attr.span.lo));
+        if attr.node.is_sugared_doc {
+            word(self.writer(), &attr.value_str().unwrap())
+        } else {
+            match attr.node.style {
+                ast::AttrInner => try!(word(self.writer(), "#![")),
+                ast::AttrOuter => try!(word(self.writer(), "#[")),
+            }
+            try!(self.print_meta_item(&*attr.meta()));
+            word(self.writer(), "]")
+        }
+    }
+
+    fn print_meta_item(&mut self, item: &ast::MetaItem) -> io::Result<()> {
+        try!(self.ibox(indent_unit));
+        match item.node {
+            ast::MetaWord(ref name) => {
+                try!(word(self.writer(), &name));
+            }
+            ast::MetaNameValue(ref name, ref value) => {
+                try!(self.word_space(&name[..]));
+                try!(self.word_space("="));
+                try!(self.print_literal(value));
+            }
+            ast::MetaList(ref name, ref items) => {
+                try!(word(self.writer(), &name));
+                try!(self.popen());
+                try!(self.commasep(Consistent,
+                                   &items[..],
+                                   |s, i| s.print_meta_item(&**i)));
+                try!(self.pclose());
+            }
+        }
+        self.end()
+    }
+}
+
+impl<'a> PrintState<'a> for State<'a> {
+    fn writer(&mut self) -> &mut pp::Printer<'a> {
+        &mut self.s
+    }
+
+    fn boxes(&mut self) -> &mut Vec<pp::Breaks> {
+        &mut self.boxes
+    }
+
+    fn comments(&mut self) -> &mut Option<Vec<comments::Comment>> {
+        &mut self.comments
+    }
+
+    fn cur_cmnt_and_lit(&mut self) -> &mut CurrentCommentAndLiteral {
+        &mut self.cur_cmnt_and_lit
     }
 
-    pub fn popen(&mut self) -> io::Result<()> { word(&mut self.s, "(") }
+    fn literals(&self) -> &Option<Vec<comments::Literal>> {
+        &self.literals
+    }
+}
 
-    pub fn pclose(&mut self) -> io::Result<()> { word(&mut self.s, ")") }
+impl<'a> State<'a> {
+    pub fn cbox(&mut self, u: usize) -> io::Result<()> {
+        self.boxes.push(pp::Breaks::Consistent);
+        pp::cbox(&mut self.s, u)
+    }
+
+    pub fn nbsp(&mut self) -> io::Result<()> { word(&mut self.s, " ") }
+
+    pub fn word_nbsp(&mut self, w: &str) -> io::Result<()> {
+        try!(word(&mut self.s, w));
+        self.nbsp()
+    }
 
     pub fn head(&mut self, w: &str) -> io::Result<()> {
         // outer-box is consistent
@@ -523,25 +849,6 @@ pub fn bclose(&mut self, span: codemap::Span) -> io::Result<()> {
         self.bclose_(span, indent_unit)
     }
 
-    pub fn is_begin(&mut self) -> bool {
-        match self.s.last_token() {
-            pp::Token::Begin(_) => true,
-            _ => false,
-        }
-    }
-
-    pub fn is_end(&mut self) -> bool {
-        match self.s.last_token() {
-            pp::Token::End => true,
-            _ => false,
-        }
-    }
-
-    // is this the beginning of a line?
-    pub fn is_bol(&mut self) -> bool {
-        self.s.last_token().is_eof() || self.s.last_token().is_hardbreak_tok()
-    }
-
     pub fn in_cbox(&self) -> bool {
         match self.boxes.last() {
             Some(&last_box) => last_box == pp::Breaks::Consistent,
@@ -549,12 +856,6 @@ pub fn in_cbox(&self) -> bool {
         }
     }
 
-    pub fn hardbreak_if_not_bol(&mut self) -> io::Result<()> {
-        if !self.is_bol() {
-            try!(hardbreak(&mut self.s))
-        }
-        Ok(())
-    }
     pub fn space_if_not_bol(&mut self) -> io::Result<()> {
         if !self.is_bol() { try!(space(&mut self.s)); }
         Ok(())
@@ -584,17 +885,6 @@ pub fn synth_comment(&mut self, text: String) -> io::Result<()> {
         word(&mut self.s, "*/")
     }
 
-    pub fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], mut op: F) -> io::Result<()> where
-        F: FnMut(&mut State, &T) -> io::Result<()>,
-    {
-        try!(self.rbox(0, b));
-        let mut first = true;
-        for elt in elts {
-            if first { first = false; } else { try!(self.word_space(",")); }
-            try!(op(self, elt));
-        }
-        self.end()
-    }
 
 
     pub fn commasep_cmnt<T, F, G>(&mut self,
@@ -1326,58 +1616,6 @@ pub fn print_impl_item(&mut self, ii: &ast::ImplItem) -> io::Result<()> {
         self.ann.post(self, NodeSubItem(ii.id))
     }
 
-    pub fn print_outer_attributes(&mut self,
-                                  attrs: &[ast::Attribute]) -> io::Result<()> {
-        let mut count = 0;
-        for attr in attrs {
-            match attr.node.style {
-                ast::AttrOuter => {
-                    try!(self.print_attribute(attr));
-                    count += 1;
-                }
-                _ => {/* fallthrough */ }
-            }
-        }
-        if count > 0 {
-            try!(self.hardbreak_if_not_bol());
-        }
-        Ok(())
-    }
-
-    pub fn print_inner_attributes(&mut self,
-                                  attrs: &[ast::Attribute]) -> io::Result<()> {
-        let mut count = 0;
-        for attr in attrs {
-            match attr.node.style {
-                ast::AttrInner => {
-                    try!(self.print_attribute(attr));
-                    count += 1;
-                }
-                _ => {/* fallthrough */ }
-            }
-        }
-        if count > 0 {
-            try!(self.hardbreak_if_not_bol());
-        }
-        Ok(())
-    }
-
-    pub fn print_attribute(&mut self, attr: &ast::Attribute) -> io::Result<()> {
-        try!(self.hardbreak_if_not_bol());
-        try!(self.maybe_print_comment(attr.span.lo));
-        if attr.node.is_sugared_doc {
-            word(&mut self.s, &attr.value_str().unwrap())
-        } else {
-            match attr.node.style {
-                ast::AttrInner => try!(word(&mut self.s, "#![")),
-                ast::AttrOuter => try!(word(&mut self.s, "#[")),
-            }
-            try!(self.print_meta_item(&*attr.meta()));
-            word(&mut self.s, "]")
-        }
-    }
-
-
     pub fn print_stmt(&mut self, st: &ast::Stmt) -> io::Result<()> {
         try!(self.maybe_print_comment(st.span.lo));
         match st.node {
@@ -2620,29 +2858,6 @@ pub fn print_where_clause(&mut self, where_clause: &ast::WhereClause)
         Ok(())
     }
 
-    pub fn print_meta_item(&mut self, item: &ast::MetaItem) -> io::Result<()> {
-        try!(self.ibox(indent_unit));
-        match item.node {
-            ast::MetaWord(ref name) => {
-                try!(word(&mut self.s, &name));
-            }
-            ast::MetaNameValue(ref name, ref value) => {
-                try!(self.word_space(&name[..]));
-                try!(self.word_space("="));
-                try!(self.print_literal(value));
-            }
-            ast::MetaList(ref name, ref items) => {
-                try!(word(&mut self.s, &name));
-                try!(self.popen());
-                try!(self.commasep(Consistent,
-                                   &items[..],
-                                   |s, i| s.print_meta_item(&**i)));
-                try!(self.pclose());
-            }
-        }
-        self.end()
-    }
-
     pub fn print_view_path(&mut self, vp: &ast::ViewPath) -> io::Result<()> {
         match vp.node {
             ast::ViewPathSimple(ident, ref path) => {
@@ -2832,181 +3047,6 @@ pub fn print_remaining_comments(&mut self) -> io::Result<()> {
         Ok(())
     }
 
-    pub fn print_literal(&mut self, lit: &ast::Lit) -> io::Result<()> {
-        try!(self.maybe_print_comment(lit.span.lo));
-        match self.next_lit(lit.span.lo) {
-            Some(ref ltrl) => {
-                return word(&mut self.s, &(*ltrl).lit);
-            }
-            _ => ()
-        }
-        match lit.node {
-            ast::LitStr(ref st, style) => self.print_string(&st, style),
-            ast::LitByte(byte) => {
-                let mut res = String::from("b'");
-                res.extend(ascii::escape_default(byte).map(|c| c as char));
-                res.push('\'');
-                word(&mut self.s, &res[..])
-            }
-            ast::LitChar(ch) => {
-                let mut res = String::from("'");
-                res.extend(ch.escape_default());
-                res.push('\'');
-                word(&mut self.s, &res[..])
-            }
-            ast::LitInt(i, t) => {
-                match t {
-                    ast::SignedIntLit(st, ast::Plus) => {
-                        word(&mut self.s,
-                             &ast_util::int_ty_to_string(st, Some(i as i64)))
-                    }
-                    ast::SignedIntLit(st, ast::Minus) => {
-                        let istr = ast_util::int_ty_to_string(st, Some(-(i as i64)));
-                        word(&mut self.s,
-                             &format!("-{}", istr))
-                    }
-                    ast::UnsignedIntLit(ut) => {
-                        word(&mut self.s, &ast_util::uint_ty_to_string(ut, Some(i)))
-                    }
-                    ast::UnsuffixedIntLit(ast::Plus) => {
-                        word(&mut self.s, &format!("{}", i))
-                    }
-                    ast::UnsuffixedIntLit(ast::Minus) => {
-                        word(&mut self.s, &format!("-{}", i))
-                    }
-                }
-            }
-            ast::LitFloat(ref f, t) => {
-                word(&mut self.s,
-                     &format!(
-                         "{}{}",
-                         &f,
-                         &ast_util::float_ty_to_string(t)))
-            }
-            ast::LitFloatUnsuffixed(ref f) => word(&mut self.s, &f[..]),
-            ast::LitBool(val) => {
-                if val { word(&mut self.s, "true") } else { word(&mut self.s, "false") }
-            }
-            ast::LitByteStr(ref v) => {
-                let mut escaped: String = String::new();
-                for &ch in v.iter() {
-                    escaped.extend(ascii::escape_default(ch)
-                                         .map(|c| c as char));
-                }
-                word(&mut self.s, &format!("b\"{}\"", escaped))
-            }
-        }
-    }
-
-    pub fn next_lit(&mut self, pos: BytePos) -> Option<comments::Literal> {
-        match self.literals {
-            Some(ref lits) => {
-                while self.cur_cmnt_and_lit.cur_lit < lits.len() {
-                    let ltrl = (*lits)[self.cur_cmnt_and_lit.cur_lit].clone();
-                    if ltrl.pos > pos { return None; }
-                    self.cur_cmnt_and_lit.cur_lit += 1;
-                    if ltrl.pos == pos { return Some(ltrl); }
-                }
-                None
-            }
-            _ => None
-        }
-    }
-
-    pub fn maybe_print_comment(&mut self, pos: BytePos) -> io::Result<()> {
-        loop {
-            match self.next_comment() {
-                Some(ref cmnt) => {
-                    if (*cmnt).pos < pos {
-                        try!(self.print_comment(cmnt));
-                        self.cur_cmnt_and_lit.cur_cmnt += 1;
-                    } else { break; }
-                }
-                _ => break
-            }
-        }
-        Ok(())
-    }
-
-    pub fn print_comment(&mut self,
-                         cmnt: &comments::Comment) -> io::Result<()> {
-        match cmnt.style {
-            comments::Mixed => {
-                assert_eq!(cmnt.lines.len(), 1);
-                try!(zerobreak(&mut self.s));
-                try!(word(&mut self.s, &cmnt.lines[0]));
-                zerobreak(&mut self.s)
-            }
-            comments::Isolated => {
-                try!(self.hardbreak_if_not_bol());
-                for line in &cmnt.lines {
-                    // Don't print empty lines because they will end up as trailing
-                    // whitespace
-                    if !line.is_empty() {
-                        try!(word(&mut self.s, &line[..]));
-                    }
-                    try!(hardbreak(&mut self.s));
-                }
-                Ok(())
-            }
-            comments::Trailing => {
-                try!(word(&mut self.s, " "));
-                if cmnt.lines.len() == 1 {
-                    try!(word(&mut self.s, &cmnt.lines[0]));
-                    hardbreak(&mut self.s)
-                } else {
-                    try!(self.ibox(0));
-                    for line in &cmnt.lines {
-                        if !line.is_empty() {
-                            try!(word(&mut self.s, &line[..]));
-                        }
-                        try!(hardbreak(&mut self.s));
-                    }
-                    self.end()
-                }
-            }
-            comments::BlankLine => {
-                // We need to do at least one, possibly two hardbreaks.
-                let is_semi = match self.s.last_token() {
-                    pp::Token::String(s, _) => ";" == s,
-                    _ => false
-                };
-                if is_semi || self.is_begin() || self.is_end() {
-                    try!(hardbreak(&mut self.s));
-                }
-                hardbreak(&mut self.s)
-            }
-        }
-    }
-
-    pub fn print_string(&mut self, st: &str,
-                        style: ast::StrStyle) -> io::Result<()> {
-        let st = match style {
-            ast::CookedStr => {
-                (format!("\"{}\"", st.escape_default()))
-            }
-            ast::RawStr(n) => {
-                (format!("r{delim}\"{string}\"{delim}",
-                         delim=repeat("#", n),
-                         string=st))
-            }
-        };
-        word(&mut self.s, &st[..])
-    }
-
-    pub fn next_comment(&mut self) -> Option<comments::Comment> {
-        match self.comments {
-            Some(ref cmnts) => {
-                if self.cur_cmnt_and_lit.cur_cmnt < cmnts.len() {
-                    Some(cmnts[self.cur_cmnt_and_lit.cur_cmnt].clone())
-                } else {
-                    None
-                }
-            }
-            _ => None
-        }
-    }
-
     pub fn print_opt_abi_and_extern_if_nondefault(&mut self,
                                                   opt_abi: Option<abi::Abi>)
         -> io::Result<()> {
index 708fcafcb53112d00a02d67f09538f15fd876c64..4c9c7f443c29005226a682edabce0094e3111017 100644 (file)
 
 #[macro_use] extern crate rustc;
 extern crate rustc_front;
+extern crate syntax;
 
 use rustc::lint::{Context, LintPass, LintPassObject, LintArray};
 use rustc::plugin::Registry;
-use rustc_front::{hir, attr};
+use rustc_front::hir;
+use syntax::attr;
 
 declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]");