rollup merge of #21368: tomjakubowski/rustdoc-miscellany
Conflicts: src/librustdoc/clean/mod.rs
This commit is contained in:
@@ -45,7 +45,6 @@ use rustc::middle::def;
|
||||
use rustc::middle::subst::{self, ParamSpace, VecPerParamSpace};
|
||||
use rustc::middle::ty;
|
||||
use rustc::middle::stability;
|
||||
use rustc::session::config;
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::u32;
|
||||
@@ -116,7 +115,7 @@ impl<T: Clean<U>, U> Clean<Vec<U>> for syntax::owned_slice::OwnedSlice<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Crate {
|
||||
pub name: String,
|
||||
pub src: FsPath,
|
||||
@@ -127,6 +126,8 @@ pub struct Crate {
|
||||
|
||||
impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
||||
fn clean(&self, cx: &DocContext) -> Crate {
|
||||
use rustc::session::config::Input;
|
||||
|
||||
let mut externs = Vec::new();
|
||||
cx.sess().cstore.iter_crate_data(|n, meta| {
|
||||
externs.push((n, meta.clean(cx)));
|
||||
@@ -134,8 +135,8 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
||||
externs.sort_by(|&(a, _), &(b, _)| a.cmp(&b));
|
||||
|
||||
// Figure out the name of this crate
|
||||
let input = config::Input::File(cx.src.clone());
|
||||
let name = link::find_crate_name(None, self.attrs.as_slice(), &input);
|
||||
let input = &cx.input;
|
||||
let name = link::find_crate_name(None, self.attrs.as_slice(), input);
|
||||
|
||||
// Clean the crate, translating the entire libsyntax AST to one that is
|
||||
// understood by rustdoc.
|
||||
@@ -188,9 +189,14 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
||||
m.items.extend(tmp.into_iter());
|
||||
}
|
||||
|
||||
let src = match cx.input {
|
||||
Input::File(ref path) => path.clone(),
|
||||
Input::Str(_) => FsPath::new("") // FIXME: this is wrong
|
||||
};
|
||||
|
||||
Crate {
|
||||
name: name.to_string(),
|
||||
src: cx.src.clone(),
|
||||
src: src,
|
||||
module: Some(module),
|
||||
externs: externs,
|
||||
primitives: primitives,
|
||||
@@ -198,7 +204,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct ExternalCrate {
|
||||
pub name: String,
|
||||
pub attrs: Vec<Attribute>,
|
||||
@@ -231,7 +237,7 @@ impl Clean<ExternalCrate> for cstore::crate_metadata {
|
||||
/// Anything with a source location and set of attributes and, optionally, a
|
||||
/// name. That is, anything that can be documented. This doesn't correspond
|
||||
/// directly to the AST's concept of an item; it's a strict superset.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Item {
|
||||
/// Stringified span
|
||||
pub source: Span,
|
||||
@@ -307,7 +313,7 @@ impl Item {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub enum ItemEnum {
|
||||
StructItem(Struct),
|
||||
EnumItem(Enum),
|
||||
@@ -336,7 +342,7 @@ pub enum ItemEnum {
|
||||
AssociatedTypeItem(TyParam),
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Module {
|
||||
pub items: Vec<Item>,
|
||||
pub is_crate: bool,
|
||||
@@ -938,7 +944,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics<'tcx>, subst::ParamSpace) {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Method {
|
||||
pub generics: Generics,
|
||||
pub self_: SelfTy,
|
||||
@@ -977,7 +983,7 @@ impl Clean<Item> for ast::Method {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct TyMethod {
|
||||
pub unsafety: ast::Unsafety,
|
||||
pub decl: FnDecl,
|
||||
@@ -1015,7 +1021,7 @@ impl Clean<Item> for ast::TypeMethod {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
|
||||
pub enum SelfTy {
|
||||
SelfStatic,
|
||||
SelfValue,
|
||||
@@ -1036,7 +1042,7 @@ impl Clean<SelfTy> for ast::ExplicitSelf_ {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Function {
|
||||
pub decl: FnDecl,
|
||||
pub generics: Generics,
|
||||
@@ -1155,7 +1161,7 @@ impl Clean<FunctionRetTy> for ast::FunctionRetTy {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Trait {
|
||||
pub unsafety: ast::Unsafety,
|
||||
pub items: Vec<TraitMethod>,
|
||||
@@ -1199,11 +1205,11 @@ impl Clean<PolyTrait> for ast::PolyTraitRef {
|
||||
|
||||
/// An item belonging to a trait, whether a method or associated. Could be named
|
||||
/// TraitItem except that's already taken by an exported enum variant.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub enum TraitMethod {
|
||||
RequiredMethod(Item),
|
||||
ProvidedMethod(Item),
|
||||
TypeTraitItem(Item),
|
||||
TypeTraitItem(Item), // an associated type
|
||||
}
|
||||
|
||||
impl TraitMethod {
|
||||
@@ -1244,7 +1250,7 @@ impl Clean<TraitMethod> for ast::TraitItem {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub enum ImplMethod {
|
||||
MethodImplItem(Item),
|
||||
TypeImplItem(Item),
|
||||
@@ -1380,7 +1386,7 @@ pub enum PrimitiveType {
|
||||
PrimitiveTuple,
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Copy, Show)]
|
||||
pub enum TypeKind {
|
||||
TypeEnum,
|
||||
TypeFunction,
|
||||
@@ -1623,7 +1629,7 @@ impl Clean<Type> for ast::QPath {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub enum StructField {
|
||||
HiddenStructField, // inserted later by strip passes
|
||||
TypedStructField(Type),
|
||||
@@ -1682,7 +1688,7 @@ impl Clean<Option<Visibility>> for ast::Visibility {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Struct {
|
||||
pub struct_type: doctree::StructType,
|
||||
pub generics: Generics,
|
||||
@@ -1712,7 +1718,7 @@ impl Clean<Item> for doctree::Struct {
|
||||
/// This is a more limited form of the standard Struct, different in that
|
||||
/// it lacks the things most items have (name, id, parameterization). Found
|
||||
/// only as a variant in an enum.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct VariantStruct {
|
||||
pub struct_type: doctree::StructType,
|
||||
pub fields: Vec<Item>,
|
||||
@@ -1729,7 +1735,7 @@ impl Clean<VariantStruct> for syntax::ast::StructDef {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Enum {
|
||||
pub variants: Vec<Item>,
|
||||
pub generics: Generics,
|
||||
@@ -1754,7 +1760,7 @@ impl Clean<Item> for doctree::Enum {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Variant {
|
||||
pub kind: VariantKind,
|
||||
}
|
||||
@@ -1822,7 +1828,7 @@ impl<'tcx> Clean<Item> for ty::VariantInfo<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub enum VariantKind {
|
||||
CLikeVariant,
|
||||
TupleVariant(Vec<Type>),
|
||||
@@ -1969,7 +1975,7 @@ impl Clean<String> for ast::Name {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Typedef {
|
||||
pub type_: Type,
|
||||
pub generics: Generics,
|
||||
@@ -2082,7 +2088,7 @@ impl Clean<Mutability> for ast::Mutability {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Show, Clone, RustcEncodable, RustcDecodable, PartialEq, Copy)]
|
||||
#[derive(Show, Clone, RustcEncodable, RustcDecodable, PartialEq, Copy, Show)]
|
||||
pub enum ImplPolarity {
|
||||
Positive,
|
||||
Negative,
|
||||
@@ -2097,7 +2103,7 @@ impl Clean<ImplPolarity> for ast::ImplPolarity {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Impl {
|
||||
pub generics: Generics,
|
||||
pub trait_: Option<Type>,
|
||||
@@ -2137,7 +2143,7 @@ impl Clean<Item> for doctree::Impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct ViewItem {
|
||||
pub inner: ViewItemInner,
|
||||
}
|
||||
@@ -2203,7 +2209,7 @@ impl Clean<Vec<Item>> for ast::ViewItem {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub enum ViewItemInner {
|
||||
ExternCrate(String, Option<String>, ast::NodeId),
|
||||
Import(ViewPath)
|
||||
@@ -2226,7 +2232,7 @@ impl Clean<ViewItemInner> for ast::ViewItem_ {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub enum ViewPath {
|
||||
// use source as str;
|
||||
SimpleImport(String, ImportSource),
|
||||
@@ -2236,7 +2242,7 @@ pub enum ViewPath {
|
||||
ImportList(ImportSource, Vec<ViewListIdent>),
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct ImportSource {
|
||||
pub path: Path,
|
||||
pub did: Option<ast::DefId>,
|
||||
@@ -2257,7 +2263,7 @@ impl Clean<ViewPath> for ast::ViewPath {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct ViewListIdent {
|
||||
pub name: String,
|
||||
pub source: Option<ast::DefId>,
|
||||
@@ -2476,7 +2482,7 @@ fn resolve_def(cx: &DocContext, id: ast::NodeId) -> Option<ast::DefId> {
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Macro {
|
||||
pub source: String,
|
||||
}
|
||||
@@ -2497,7 +2503,7 @@ impl Clean<Item> for doctree::Macro {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Show)]
|
||||
pub struct Stability {
|
||||
pub level: attr::StabilityLevel,
|
||||
pub text: String
|
||||
@@ -2533,14 +2539,14 @@ impl Clean<Item> for ty::AssociatedType {
|
||||
source: DUMMY_SP.clean(cx),
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: Vec::new(),
|
||||
// FIXME(#18048): this is wrong, but cross-crate associated types are broken
|
||||
// anyway, for the time being.
|
||||
inner: AssociatedTypeItem(TyParam {
|
||||
name: self.name.clean(cx),
|
||||
did: ast::DefId {
|
||||
krate: 0,
|
||||
node: ast::DUMMY_NODE_ID
|
||||
},
|
||||
// FIXME(#20727): bounds are missing and need to be filled in from the
|
||||
// predicates on the trait itself
|
||||
bounds: vec![],
|
||||
default: None,
|
||||
}),
|
||||
@@ -2572,6 +2578,16 @@ impl Clean<Item> for ast::Typedef {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Clean<Typedef> for (ty::TypeScheme<'a>, ParamSpace) {
|
||||
fn clean(&self, cx: &DocContext) -> Typedef {
|
||||
let (ref ty_scheme, ps) = *self;
|
||||
Typedef {
|
||||
type_: ty_scheme.ty.clean(cx),
|
||||
generics: (&ty_scheme.generics, ps).clean(cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
|
||||
t: ty::Ty, name: &str,
|
||||
fallback: fn(Box<Type>) -> Type) -> Type {
|
||||
|
||||
Reference in New Issue
Block a user