Add an intital HIR and lowering step
This commit is contained in:
parent
cfd76b364c
commit
facdf2ebb1
160 changed files with 13917 additions and 4451 deletions
|
@ -21,6 +21,7 @@ use std::iter::repeat;
|
|||
use rustc::middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use rustc_front::hir;
|
||||
|
||||
use clean;
|
||||
use html::item_type::ItemType;
|
||||
|
@ -30,15 +31,15 @@ use html::render::{cache, CURRENT_LOCATION_KEY};
|
|||
/// Helper to render an optional visibility with a space after it (if the
|
||||
/// visibility is preset)
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct VisSpace(pub Option<ast::Visibility>);
|
||||
pub struct VisSpace(pub Option<hir::Visibility>);
|
||||
/// Similarly to VisSpace, this structure is used to render a function style with a
|
||||
/// space after it.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct UnsafetySpace(pub ast::Unsafety);
|
||||
pub struct UnsafetySpace(pub hir::Unsafety);
|
||||
/// Similarly to VisSpace, this structure is used to render a function constness
|
||||
/// with a space after it.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct ConstnessSpace(pub ast::Constness);
|
||||
pub struct ConstnessSpace(pub hir::Constness);
|
||||
/// Wrapper struct for properly emitting a method declaration.
|
||||
pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
|
||||
/// Similar to VisSpace, but used for mutability
|
||||
|
@ -56,19 +57,19 @@ pub struct CommaSep<'a, T: 'a>(pub &'a [T]);
|
|||
pub struct AbiSpace(pub Abi);
|
||||
|
||||
impl VisSpace {
|
||||
pub fn get(&self) -> Option<ast::Visibility> {
|
||||
pub fn get(&self) -> Option<hir::Visibility> {
|
||||
let VisSpace(v) = *self; v
|
||||
}
|
||||
}
|
||||
|
||||
impl UnsafetySpace {
|
||||
pub fn get(&self) -> ast::Unsafety {
|
||||
pub fn get(&self) -> hir::Unsafety {
|
||||
let UnsafetySpace(v) = *self; v
|
||||
}
|
||||
}
|
||||
|
||||
impl ConstnessSpace {
|
||||
pub fn get(&self) -> ast::Constness {
|
||||
pub fn get(&self) -> hir::Constness {
|
||||
let ConstnessSpace(v) = *self; v
|
||||
}
|
||||
}
|
||||
|
@ -201,8 +202,8 @@ impl fmt::Display for clean::TyParamBound {
|
|||
}
|
||||
clean::TraitBound(ref ty, modifier) => {
|
||||
let modifier_str = match modifier {
|
||||
ast::TraitBoundModifier::None => "",
|
||||
ast::TraitBoundModifier::Maybe => "?",
|
||||
hir::TraitBoundModifier::None => "",
|
||||
hir::TraitBoundModifier::Maybe => "?",
|
||||
};
|
||||
write!(f, "{}{}", modifier_str, *ty)
|
||||
}
|
||||
|
@ -618,8 +619,8 @@ impl<'a> fmt::Display for Method<'a> {
|
|||
impl fmt::Display for VisSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.get() {
|
||||
Some(ast::Public) => write!(f, "pub "),
|
||||
Some(ast::Inherited) | None => Ok(())
|
||||
Some(hir::Public) => write!(f, "pub "),
|
||||
Some(hir::Inherited) | None => Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -627,8 +628,8 @@ impl fmt::Display for VisSpace {
|
|||
impl fmt::Display for UnsafetySpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.get() {
|
||||
ast::Unsafety::Unsafe => write!(f, "unsafe "),
|
||||
ast::Unsafety::Normal => Ok(())
|
||||
hir::Unsafety::Unsafe => write!(f, "unsafe "),
|
||||
hir::Unsafety::Normal => Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -636,8 +637,8 @@ impl fmt::Display for UnsafetySpace {
|
|||
impl fmt::Display for ConstnessSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.get() {
|
||||
ast::Constness::Const => write!(f, "const "),
|
||||
ast::Constness::NotConst => Ok(())
|
||||
hir::Constness::Const => write!(f, "const "),
|
||||
hir::Constness::NotConst => Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,9 +52,10 @@ use std::sync::Arc;
|
|||
use externalfiles::ExternalHtml;
|
||||
|
||||
use serialize::json::{self, ToJson};
|
||||
use syntax::{abi, ast, attr};
|
||||
use syntax::{abi, ast};
|
||||
use rustc::middle::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc::util::nodemap::NodeSet;
|
||||
use rustc_front::{hir, attr};
|
||||
|
||||
use clean::{self, SelfTy};
|
||||
use doctree;
|
||||
|
@ -858,7 +859,7 @@ impl DocFolder for Cache {
|
|||
let orig_privmod = match item.inner {
|
||||
clean::ModuleItem(..) => {
|
||||
let prev = self.privmod;
|
||||
self.privmod = prev || (self.remove_priv && item.visibility != Some(ast::Public));
|
||||
self.privmod = prev || (self.remove_priv && item.visibility != Some(hir::Public));
|
||||
prev
|
||||
}
|
||||
_ => self.privmod,
|
||||
|
@ -1327,10 +1328,10 @@ impl Context {
|
|||
clean::ModuleItem(ref m) => {
|
||||
(m.items.is_empty() &&
|
||||
it.doc_value().is_none() &&
|
||||
it.visibility != Some(ast::Public)) ||
|
||||
(self.passes.contains("strip-private") && it.visibility != Some(ast::Public))
|
||||
it.visibility != Some(hir::Public)) ||
|
||||
(self.passes.contains("strip-private") && it.visibility != Some(hir::Public))
|
||||
}
|
||||
clean::PrimitiveItem(..) => it.visibility != Some(ast::Public),
|
||||
clean::PrimitiveItem(..) => it.visibility != Some(hir::Public),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -1975,8 +1976,8 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item,
|
|||
link: AssocItemLink) -> fmt::Result {
|
||||
fn method(w: &mut fmt::Formatter,
|
||||
it: &clean::Item,
|
||||
unsafety: ast::Unsafety,
|
||||
constness: ast::Constness,
|
||||
unsafety: hir::Unsafety,
|
||||
constness: hir::Constness,
|
||||
abi: abi::Abi,
|
||||
g: &clean::Generics,
|
||||
selfty: &clean::SelfTy,
|
||||
|
@ -2009,7 +2010,7 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item,
|
|||
}
|
||||
match meth.inner {
|
||||
clean::TyMethodItem(ref m) => {
|
||||
method(w, meth, m.unsafety, ast::Constness::NotConst,
|
||||
method(w, meth, m.unsafety, hir::Constness::NotConst,
|
||||
m.abi, &m.generics, &m.self_, &m.decl, link)
|
||||
}
|
||||
clean::MethodItem(ref m) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue