Transition librustdoc to 2018 edition
This commit is contained in:
parent
082c86175f
commit
1932d7a52d
@ -2,6 +2,7 @@
|
||||
authors = ["The Rust Project Developers"]
|
||||
name = "rustdoc"
|
||||
version = "0.0.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
name = "rustdoc"
|
||||
|
@ -220,7 +220,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_lifetime(&self, region: Region, names_map: &FxHashMap<String, Lifetime>) -> Lifetime {
|
||||
fn get_lifetime(&self, region: Region<'_>, names_map: &FxHashMap<String, Lifetime>) -> Lifetime {
|
||||
self.region_name(region)
|
||||
.map(|name| {
|
||||
names_map.get(&name).unwrap_or_else(|| {
|
||||
@ -231,7 +231,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||
.clone()
|
||||
}
|
||||
|
||||
fn region_name(&self, region: Region) -> Option<String> {
|
||||
fn region_name(&self, region: Region<'_>) -> Option<String> {
|
||||
match region {
|
||||
&ty::ReEarlyBound(r) => Some(r.name.to_string()),
|
||||
_ => None,
|
||||
@ -259,7 +259,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||
// we need to create the Generics.
|
||||
let mut finished: FxHashMap<_, Vec<_>> = Default::default();
|
||||
|
||||
let mut vid_map: FxHashMap<RegionTarget, RegionDeps> = Default::default();
|
||||
let mut vid_map: FxHashMap<RegionTarget<'_>, RegionDeps<'_>> = Default::default();
|
||||
|
||||
// Flattening is done in two parts. First, we insert all of the constraints
|
||||
// into a map. Each RegionTarget (either a RegionVid or a Region) maps
|
||||
@ -842,7 +842,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||
vec.sort_by_cached_key(|x| format!("{:?}", x))
|
||||
}
|
||||
|
||||
fn is_fn_ty(&self, tcx: &TyCtxt, ty: &Type) -> bool {
|
||||
fn is_fn_ty(&self, tcx: &TyCtxt<'_, '_, '_>, ty: &Type) -> bool {
|
||||
match &ty {
|
||||
&&Type::ResolvedPath { ref did, .. } => {
|
||||
*did == tcx.require_lang_item(lang_items::FnTraitLangItem)
|
||||
|
@ -5,7 +5,7 @@ use rustc::ty::subst::Subst;
|
||||
use rustc::infer::InferOk;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
use core::DocAccessLevels;
|
||||
use crate::core::DocAccessLevels;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -14,7 +14,7 @@ use syntax::feature_gate::Features;
|
||||
|
||||
use syntax_pos::Span;
|
||||
|
||||
use html::escape::Escape;
|
||||
use crate::html::escape::Escape;
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum Cfg {
|
||||
@ -261,7 +261,7 @@ impl ops::BitOr for Cfg {
|
||||
struct Html<'a>(&'a Cfg, bool);
|
||||
|
||||
fn write_with_opt_paren<T: fmt::Display>(
|
||||
fmt: &mut fmt::Formatter,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
has_paren: bool,
|
||||
obj: T,
|
||||
) -> fmt::Result {
|
||||
@ -277,7 +277,7 @@ fn write_with_opt_paren<T: fmt::Display>(
|
||||
|
||||
|
||||
impl<'a> fmt::Display for Html<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self.0 {
|
||||
Cfg::Not(ref child) => match **child {
|
||||
Cfg::Any(ref sub_cfgs) => {
|
||||
|
@ -1,8 +1,8 @@
|
||||
use core::DocContext;
|
||||
use crate::core::DocContext;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub fn get_def_from_def_id<F>(cx: &DocContext,
|
||||
pub fn get_def_from_def_id<F>(cx: &DocContext<'_, '_, '_>,
|
||||
def_id: DefId,
|
||||
callback: &F,
|
||||
) -> Vec<Item>
|
||||
@ -38,7 +38,7 @@ where F: Fn(& dyn Fn(DefId) -> Def) -> Vec<Item> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_def_from_node_id<F>(cx: &DocContext,
|
||||
pub fn get_def_from_node_id<F>(cx: &DocContext<'_, '_, '_>,
|
||||
id: ast::NodeId,
|
||||
name: String,
|
||||
callback: &F,
|
||||
|
@ -13,9 +13,9 @@ use rustc_metadata::cstore::LoadedMacro;
|
||||
use rustc::ty;
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
|
||||
use core::{DocContext, DocAccessLevels};
|
||||
use doctree;
|
||||
use clean::{
|
||||
use crate::core::{DocContext, DocAccessLevels};
|
||||
use crate::doctree;
|
||||
use crate::clean::{
|
||||
self,
|
||||
GetDefId,
|
||||
ToSource,
|
||||
@ -35,7 +35,7 @@ use super::Clean;
|
||||
///
|
||||
/// The returned value is `None` if the definition could not be inlined,
|
||||
/// and `Some` of a vector of items if it was successfully expanded.
|
||||
pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHashSet<DefId>)
|
||||
pub fn try_inline(cx: &DocContext<'_, '_, '_>, def: Def, name: ast::Name, visited: &mut FxHashSet<DefId>)
|
||||
-> Option<Vec<clean::Item>> {
|
||||
let did = if let Some(did) = def.opt_def_id() {
|
||||
did
|
||||
@ -124,7 +124,7 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa
|
||||
Some(ret)
|
||||
}
|
||||
|
||||
pub fn try_inline_glob(cx: &DocContext, def: Def, visited: &mut FxHashSet<DefId>)
|
||||
pub fn try_inline_glob(cx: &DocContext<'_, '_, '_>, def: Def, visited: &mut FxHashSet<DefId>)
|
||||
-> Option<Vec<clean::Item>>
|
||||
{
|
||||
if def == Def::Err { return None }
|
||||
@ -141,7 +141,7 @@ pub fn try_inline_glob(cx: &DocContext, def: Def, visited: &mut FxHashSet<DefId>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_attrs(cx: &DocContext, did: DefId) -> clean::Attributes {
|
||||
pub fn load_attrs(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Attributes {
|
||||
cx.tcx.get_attrs(did).clean(cx)
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ pub fn load_attrs(cx: &DocContext, did: DefId) -> clean::Attributes {
|
||||
///
|
||||
/// These names are used later on by HTML rendering to generate things like
|
||||
/// source links back to the original item.
|
||||
pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) {
|
||||
pub fn record_extern_fqn(cx: &DocContext<'_, '_, '_>, did: DefId, kind: clean::TypeKind) {
|
||||
let mut crate_name = cx.tcx.crate_name(did.krate).to_string();
|
||||
if did.is_local() {
|
||||
crate_name = cx.crate_name.clone().unwrap_or(crate_name);
|
||||
@ -177,7 +177,7 @@ pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait {
|
||||
pub fn build_external_trait(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Trait {
|
||||
let auto_trait = cx.tcx.trait_def(did).has_auto_impl;
|
||||
let trait_items = cx.tcx.associated_items(did).map(|item| item.clean(cx)).collect();
|
||||
let predicates = cx.tcx.predicates_of(did);
|
||||
@ -197,7 +197,7 @@ pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
|
||||
fn build_external_function(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Function {
|
||||
let sig = cx.tcx.fn_sig(did);
|
||||
|
||||
let constness = if cx.tcx.is_min_const_fn(did) {
|
||||
@ -219,7 +219,7 @@ fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_enum(cx: &DocContext, did: DefId) -> clean::Enum {
|
||||
fn build_enum(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Enum {
|
||||
let predicates = cx.tcx.predicates_of(did);
|
||||
|
||||
clean::Enum {
|
||||
@ -229,7 +229,7 @@ fn build_enum(cx: &DocContext, did: DefId) -> clean::Enum {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_struct(cx: &DocContext, did: DefId) -> clean::Struct {
|
||||
fn build_struct(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Struct {
|
||||
let predicates = cx.tcx.predicates_of(did);
|
||||
let variant = cx.tcx.adt_def(did).non_enum_variant();
|
||||
|
||||
@ -245,7 +245,7 @@ fn build_struct(cx: &DocContext, did: DefId) -> clean::Struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_union(cx: &DocContext, did: DefId) -> clean::Union {
|
||||
fn build_union(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Union {
|
||||
let predicates = cx.tcx.predicates_of(did);
|
||||
let variant = cx.tcx.adt_def(did).non_enum_variant();
|
||||
|
||||
@ -257,7 +257,7 @@ fn build_union(cx: &DocContext, did: DefId) -> clean::Union {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_type_alias(cx: &DocContext, did: DefId) -> clean::Typedef {
|
||||
fn build_type_alias(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Typedef {
|
||||
let predicates = cx.tcx.predicates_of(did);
|
||||
|
||||
clean::Typedef {
|
||||
@ -266,7 +266,7 @@ fn build_type_alias(cx: &DocContext, did: DefId) -> clean::Typedef {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_impls(cx: &DocContext, did: DefId) -> Vec<clean::Item> {
|
||||
pub fn build_impls(cx: &DocContext<'_, '_, '_>, did: DefId) -> Vec<clean::Item> {
|
||||
let tcx = cx.tcx;
|
||||
let mut impls = Vec::new();
|
||||
|
||||
@ -277,7 +277,7 @@ pub fn build_impls(cx: &DocContext, did: DefId) -> Vec<clean::Item> {
|
||||
impls
|
||||
}
|
||||
|
||||
pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||
pub fn build_impl(cx: &DocContext<'_, '_, '_>, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||
if !cx.renderinfo.borrow_mut().inlined.insert(did) {
|
||||
return
|
||||
}
|
||||
@ -387,7 +387,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||
});
|
||||
}
|
||||
|
||||
fn build_module(cx: &DocContext, did: DefId, visited: &mut FxHashSet<DefId>) -> clean::Module {
|
||||
fn build_module(cx: &DocContext<'_, '_, '_>, did: DefId, visited: &mut FxHashSet<DefId>) -> clean::Module {
|
||||
let mut items = Vec::new();
|
||||
fill_in(cx, did, &mut items, visited);
|
||||
return clean::Module {
|
||||
@ -395,7 +395,7 @@ fn build_module(cx: &DocContext, did: DefId, visited: &mut FxHashSet<DefId>) ->
|
||||
is_crate: false,
|
||||
};
|
||||
|
||||
fn fill_in(cx: &DocContext, did: DefId, items: &mut Vec<clean::Item>,
|
||||
fn fill_in(cx: &DocContext<'_, '_, '_>, did: DefId, items: &mut Vec<clean::Item>,
|
||||
visited: &mut FxHashSet<DefId>) {
|
||||
// If we're re-exporting a re-export it may actually re-export something in
|
||||
// two namespaces, so the target may be listed twice. Make sure we only
|
||||
@ -412,7 +412,7 @@ fn build_module(cx: &DocContext, did: DefId, visited: &mut FxHashSet<DefId>) ->
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_inlined_const(cx: &DocContext, did: DefId) -> String {
|
||||
pub fn print_inlined_const(cx: &DocContext<'_, '_, '_>, did: DefId) -> String {
|
||||
if let Some(node_id) = cx.tcx.hir().as_local_node_id(did) {
|
||||
cx.tcx.hir().node_to_pretty_string(node_id)
|
||||
} else {
|
||||
@ -420,14 +420,14 @@ pub fn print_inlined_const(cx: &DocContext, did: DefId) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_const(cx: &DocContext, did: DefId) -> clean::Constant {
|
||||
fn build_const(cx: &DocContext<'_, '_, '_>, did: DefId) -> clean::Constant {
|
||||
clean::Constant {
|
||||
type_: cx.tcx.type_of(did).clean(cx),
|
||||
expr: print_inlined_const(cx, did)
|
||||
}
|
||||
}
|
||||
|
||||
fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static {
|
||||
fn build_static(cx: &DocContext<'_, '_, '_>, did: DefId, mutable: bool) -> clean::Static {
|
||||
clean::Static {
|
||||
type_: cx.tcx.type_of(did).clean(cx),
|
||||
mutability: if mutable {clean::Mutable} else {clean::Immutable},
|
||||
@ -435,7 +435,7 @@ fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_macro(cx: &DocContext, did: DefId, name: ast::Name) -> clean::ItemEnum {
|
||||
fn build_macro(cx: &DocContext<'_, '_, '_>, did: DefId, name: ast::Name) -> clean::ItemEnum {
|
||||
let imported_from = cx.tcx.original_crate_name(did.krate);
|
||||
match cx.cstore.load_macro_untracked(did, cx.sess()) {
|
||||
LoadedMacro::MacroDef(def) => {
|
||||
@ -537,7 +537,7 @@ fn separate_supertrait_bounds(mut g: clean::Generics)
|
||||
(g, ty_bounds)
|
||||
}
|
||||
|
||||
pub fn record_extern_trait(cx: &DocContext, did: DefId) {
|
||||
pub fn record_extern_trait(cx: &DocContext<'_, '_, '_>, did: DefId) {
|
||||
if did.is_local() {
|
||||
return;
|
||||
}
|
||||
|
@ -48,11 +48,12 @@ use std::u32;
|
||||
|
||||
use parking_lot::ReentrantMutex;
|
||||
|
||||
use core::{self, DocContext};
|
||||
use doctree;
|
||||
use visit_ast;
|
||||
use html::render::{cache, ExternalLocation};
|
||||
use html::item_type::ItemType;
|
||||
use crate::core::{self, DocContext};
|
||||
use crate::doctree;
|
||||
use crate::visit_ast;
|
||||
use crate::html::render::{cache, ExternalLocation};
|
||||
use crate::html::item_type::ItemType;
|
||||
|
||||
|
||||
use self::cfg::Cfg;
|
||||
use self::auto_trait::AutoTraitFinder;
|
||||
@ -70,56 +71,56 @@ thread_local!(pub static MAX_DEF_ID: RefCell<FxHashMap<CrateNum, DefId>> = Defau
|
||||
const FN_OUTPUT_NAME: &'static str = "Output";
|
||||
|
||||
// extract the stability index for a node from tcx, if possible
|
||||
fn get_stability(cx: &DocContext, def_id: DefId) -> Option<Stability> {
|
||||
fn get_stability(cx: &DocContext<'_, '_, '_>, def_id: DefId) -> Option<Stability> {
|
||||
cx.tcx.lookup_stability(def_id).clean(cx)
|
||||
}
|
||||
|
||||
fn get_deprecation(cx: &DocContext, def_id: DefId) -> Option<Deprecation> {
|
||||
fn get_deprecation(cx: &DocContext<'_, '_, '_>, def_id: DefId) -> Option<Deprecation> {
|
||||
cx.tcx.lookup_deprecation(def_id).clean(cx)
|
||||
}
|
||||
|
||||
pub trait Clean<T> {
|
||||
fn clean(&self, cx: &DocContext) -> T;
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> T;
|
||||
}
|
||||
|
||||
impl<T: Clean<U>, U> Clean<Vec<U>> for [T] {
|
||||
fn clean(&self, cx: &DocContext) -> Vec<U> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<U> {
|
||||
self.iter().map(|x| x.clean(cx)).collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clean<U>, U, V: Idx> Clean<IndexVec<V, U>> for IndexVec<V, T> {
|
||||
fn clean(&self, cx: &DocContext) -> IndexVec<V, U> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> IndexVec<V, U> {
|
||||
self.iter().map(|x| x.clean(cx)).collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clean<U>, U> Clean<U> for P<T> {
|
||||
fn clean(&self, cx: &DocContext) -> U {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> U {
|
||||
(**self).clean(cx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clean<U>, U> Clean<U> for Rc<T> {
|
||||
fn clean(&self, cx: &DocContext) -> U {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> U {
|
||||
(**self).clean(cx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clean<U>, U> Clean<Option<U>> for Option<T> {
|
||||
fn clean(&self, cx: &DocContext) -> Option<U> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<U> {
|
||||
self.as_ref().map(|v| v.clean(cx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, U> Clean<U> for ty::Binder<T> where T: Clean<U> {
|
||||
fn clean(&self, cx: &DocContext) -> U {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> U {
|
||||
self.skip_binder().clean(cx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clean<U>, U> Clean<Vec<U>> for P<[T]> {
|
||||
fn clean(&self, cx: &DocContext) -> Vec<U> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<U> {
|
||||
self.iter().map(|x| x.clean(cx)).collect()
|
||||
}
|
||||
}
|
||||
@ -139,8 +140,8 @@ pub struct Crate {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'rcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx, 'rcx> {
|
||||
fn clean(&self, cx: &DocContext) -> Crate {
|
||||
use ::visit_lib::LibEmbargoVisitor;
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Crate {
|
||||
use crate::visit_lib::LibEmbargoVisitor;
|
||||
|
||||
{
|
||||
let mut r = cx.renderinfo.borrow_mut();
|
||||
@ -233,7 +234,7 @@ pub struct ExternalCrate {
|
||||
}
|
||||
|
||||
impl Clean<ExternalCrate> for CrateNum {
|
||||
fn clean(&self, cx: &DocContext) -> ExternalCrate {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> ExternalCrate {
|
||||
let root = DefId { krate: *self, index: CRATE_DEF_INDEX };
|
||||
let krate_span = cx.tcx.def_span(root);
|
||||
let krate_src = cx.sess().source_map().span_to_filename(krate_span);
|
||||
@ -365,7 +366,7 @@ pub struct Item {
|
||||
}
|
||||
|
||||
impl fmt::Debug for Item {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
||||
let fake = MAX_DEF_ID.with(|m| m.borrow().get(&self.def_id.krate)
|
||||
.map(|id| self.def_id >= *id).unwrap_or(false));
|
||||
@ -581,7 +582,7 @@ pub struct Module {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Module {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let name = if self.name.is_some() {
|
||||
self.name.expect("No name provided").clean(cx)
|
||||
} else {
|
||||
@ -949,7 +950,8 @@ impl Attributes {
|
||||
///
|
||||
/// Cache must be populated before call
|
||||
pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> {
|
||||
use html::format::href;
|
||||
use crate::html::format::href;
|
||||
|
||||
self.links.iter().filter_map(|&(ref s, did, ref fragment)| {
|
||||
match did {
|
||||
Some(did) => {
|
||||
@ -1019,7 +1021,7 @@ impl AttributesExt for Attributes {
|
||||
}
|
||||
|
||||
impl Clean<Attributes> for [ast::Attribute] {
|
||||
fn clean(&self, cx: &DocContext) -> Attributes {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Attributes {
|
||||
Attributes::from_ast(cx.sess().diagnostic(), self)
|
||||
}
|
||||
}
|
||||
@ -1031,7 +1033,7 @@ pub enum GenericBound {
|
||||
}
|
||||
|
||||
impl GenericBound {
|
||||
fn maybe_sized(cx: &DocContext) -> GenericBound {
|
||||
fn maybe_sized(cx: &DocContext<'_, '_, '_>) -> GenericBound {
|
||||
let did = cx.tcx.require_lang_item(lang_items::SizedTraitLangItem);
|
||||
let empty = cx.tcx.intern_substs(&[]);
|
||||
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
|
||||
@ -1048,7 +1050,7 @@ impl GenericBound {
|
||||
}, hir::TraitBoundModifier::Maybe)
|
||||
}
|
||||
|
||||
fn is_sized_bound(&self, cx: &DocContext) -> bool {
|
||||
fn is_sized_bound(&self, cx: &DocContext<'_, '_, '_>) -> bool {
|
||||
use rustc::hir::TraitBoundModifier as TBM;
|
||||
if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self {
|
||||
if trait_.def_id() == cx.tcx.lang_items().sized_trait() {
|
||||
@ -1074,7 +1076,7 @@ impl GenericBound {
|
||||
}
|
||||
|
||||
impl Clean<GenericBound> for hir::GenericBound {
|
||||
fn clean(&self, cx: &DocContext) -> GenericBound {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
|
||||
match *self {
|
||||
hir::GenericBound::Outlives(lt) => GenericBound::Outlives(lt.clean(cx)),
|
||||
hir::GenericBound::Trait(ref t, modifier) => {
|
||||
@ -1084,8 +1086,8 @@ impl Clean<GenericBound> for hir::GenericBound {
|
||||
}
|
||||
}
|
||||
|
||||
fn external_generic_args(cx: &DocContext, trait_did: Option<DefId>, has_self: bool,
|
||||
bindings: Vec<TypeBinding>, substs: &Substs) -> GenericArgs {
|
||||
fn external_generic_args(cx: &DocContext<'_, '_, '_>, trait_did: Option<DefId>, has_self: bool,
|
||||
bindings: Vec<TypeBinding>, substs: &Substs<'_>) -> GenericArgs {
|
||||
let lifetimes = substs.regions().filter_map(|v| v.clean(cx)).collect();
|
||||
let types = substs.types().skip(has_self as usize).collect::<Vec<_>>();
|
||||
|
||||
@ -1126,8 +1128,8 @@ fn external_generic_args(cx: &DocContext, trait_did: Option<DefId>, has_self: bo
|
||||
|
||||
// trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar
|
||||
// from Fn<(A, B,), C> to Fn(A, B) -> C
|
||||
fn external_path(cx: &DocContext, name: &str, trait_did: Option<DefId>, has_self: bool,
|
||||
bindings: Vec<TypeBinding>, substs: &Substs) -> Path {
|
||||
fn external_path(cx: &DocContext<'_, '_, '_>, name: &str, trait_did: Option<DefId>, has_self: bool,
|
||||
bindings: Vec<TypeBinding>, substs: &Substs<'_>) -> Path {
|
||||
Path {
|
||||
global: false,
|
||||
def: Def::Err,
|
||||
@ -1139,7 +1141,7 @@ fn external_path(cx: &DocContext, name: &str, trait_did: Option<DefId>, has_self
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Clean<GenericBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>) {
|
||||
fn clean(&self, cx: &DocContext) -> GenericBound {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
|
||||
let (trait_ref, ref bounds) = *self;
|
||||
inline::record_extern_fqn(cx, trait_ref.def_id, TypeKind::Trait);
|
||||
let path = external_path(cx, &cx.tcx.item_name(trait_ref.def_id).as_str(),
|
||||
@ -1183,13 +1185,13 @@ impl<'a, 'tcx> Clean<GenericBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<GenericBound> for ty::TraitRef<'tcx> {
|
||||
fn clean(&self, cx: &DocContext) -> GenericBound {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
|
||||
(self, vec![]).clean(cx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Option<Vec<GenericBound>>> for Substs<'tcx> {
|
||||
fn clean(&self, cx: &DocContext) -> Option<Vec<GenericBound>> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<Vec<GenericBound>> {
|
||||
let mut v = Vec::new();
|
||||
v.extend(self.regions().filter_map(|r| r.clean(cx)).map(GenericBound::Outlives));
|
||||
v.extend(self.types().map(|t| GenericBound::TraitBound(PolyTrait {
|
||||
@ -1216,7 +1218,7 @@ impl Lifetime {
|
||||
}
|
||||
|
||||
impl Clean<Lifetime> for hir::Lifetime {
|
||||
fn clean(&self, cx: &DocContext) -> Lifetime {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Lifetime {
|
||||
if self.id != ast::DUMMY_NODE_ID {
|
||||
let def = cx.tcx.named_region(self.hir_id);
|
||||
match def {
|
||||
@ -1235,7 +1237,7 @@ impl Clean<Lifetime> for hir::Lifetime {
|
||||
}
|
||||
|
||||
impl Clean<Lifetime> for hir::GenericParam {
|
||||
fn clean(&self, _: &DocContext) -> Lifetime {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> Lifetime {
|
||||
match self.kind {
|
||||
hir::GenericParamKind::Lifetime { .. } => {
|
||||
if self.bounds.len() > 0 {
|
||||
@ -1259,7 +1261,7 @@ impl Clean<Lifetime> for hir::GenericParam {
|
||||
}
|
||||
|
||||
impl Clean<Constant> for hir::ConstArg {
|
||||
fn clean(&self, cx: &DocContext) -> Constant {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Constant {
|
||||
Constant {
|
||||
type_: cx.tcx.type_of(cx.tcx.hir().body_owner_def_id(self.value.body)).clean(cx),
|
||||
expr: print_const_expr(cx, self.value.body),
|
||||
@ -1268,13 +1270,13 @@ impl Clean<Constant> for hir::ConstArg {
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Lifetime> for ty::GenericParamDef {
|
||||
fn clean(&self, _cx: &DocContext) -> Lifetime {
|
||||
fn clean(&self, _cx: &DocContext<'_, '_, '_>) -> Lifetime {
|
||||
Lifetime(self.name.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<Option<Lifetime>> for ty::RegionKind {
|
||||
fn clean(&self, cx: &DocContext) -> Option<Lifetime> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<Lifetime> {
|
||||
match *self {
|
||||
ty::ReStatic => Some(Lifetime::statik()),
|
||||
ty::ReLateBound(_, ty::BrNamed(_, name)) => Some(Lifetime(name.to_string())),
|
||||
@ -1303,7 +1305,7 @@ pub enum WherePredicate {
|
||||
}
|
||||
|
||||
impl Clean<WherePredicate> for hir::WherePredicate {
|
||||
fn clean(&self, cx: &DocContext) -> WherePredicate {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> WherePredicate {
|
||||
match *self {
|
||||
hir::WherePredicate::BoundPredicate(ref wbp) => {
|
||||
WherePredicate::BoundPredicate {
|
||||
@ -1330,7 +1332,7 @@ impl Clean<WherePredicate> for hir::WherePredicate {
|
||||
}
|
||||
|
||||
impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
|
||||
fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<WherePredicate> {
|
||||
use rustc::ty::Predicate;
|
||||
|
||||
match *self {
|
||||
@ -1349,7 +1351,7 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Clean<WherePredicate> for ty::TraitPredicate<'a> {
|
||||
fn clean(&self, cx: &DocContext) -> WherePredicate {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> WherePredicate {
|
||||
WherePredicate::BoundPredicate {
|
||||
ty: self.trait_ref.self_ty().clean(cx),
|
||||
bounds: vec![self.trait_ref.clean(cx)]
|
||||
@ -1358,7 +1360,7 @@ impl<'a> Clean<WherePredicate> for ty::TraitPredicate<'a> {
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<WherePredicate> for ty::SubtypePredicate<'tcx> {
|
||||
fn clean(&self, _cx: &DocContext) -> WherePredicate {
|
||||
fn clean(&self, _cx: &DocContext<'_, '_, '_>) -> WherePredicate {
|
||||
panic!("subtype predicates are an internal rustc artifact \
|
||||
and should not be seen by rustdoc")
|
||||
}
|
||||
@ -1367,7 +1369,7 @@ impl<'tcx> Clean<WherePredicate> for ty::SubtypePredicate<'tcx> {
|
||||
impl<'tcx> Clean<Option<WherePredicate>> for
|
||||
ty::OutlivesPredicate<ty::Region<'tcx>,ty::Region<'tcx>> {
|
||||
|
||||
fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<WherePredicate> {
|
||||
let ty::OutlivesPredicate(ref a, ref b) = *self;
|
||||
|
||||
match (a, b) {
|
||||
@ -1385,7 +1387,7 @@ impl<'tcx> Clean<Option<WherePredicate>> for
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Option<WherePredicate>> for ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
|
||||
fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<WherePredicate> {
|
||||
let ty::OutlivesPredicate(ref ty, ref lt) = *self;
|
||||
|
||||
match lt {
|
||||
@ -1401,7 +1403,7 @@ impl<'tcx> Clean<Option<WherePredicate>> for ty::OutlivesPredicate<Ty<'tcx>, ty:
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<WherePredicate> for ty::ProjectionPredicate<'tcx> {
|
||||
fn clean(&self, cx: &DocContext) -> WherePredicate {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> WherePredicate {
|
||||
WherePredicate::EqPredicate {
|
||||
lhs: self.projection_ty.clean(cx),
|
||||
rhs: self.ty.clean(cx)
|
||||
@ -1410,7 +1412,7 @@ impl<'tcx> Clean<WherePredicate> for ty::ProjectionPredicate<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
|
||||
fn clean(&self, cx: &DocContext) -> Type {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
|
||||
let trait_ = match self.trait_ref(cx.tcx).clean(cx) {
|
||||
GenericBound::TraitBound(t, _) => t.trait_,
|
||||
GenericBound::Outlives(_) => panic!("cleaning a trait got a lifetime"),
|
||||
@ -1458,7 +1460,7 @@ impl GenericParamDef {
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<GenericParamDef> for ty::GenericParamDef {
|
||||
fn clean(&self, cx: &DocContext) -> GenericParamDef {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericParamDef {
|
||||
let (name, kind) = match self.kind {
|
||||
ty::GenericParamDefKind::Lifetime => {
|
||||
(self.name.to_string(), GenericParamDefKind::Lifetime)
|
||||
@ -1488,7 +1490,7 @@ impl<'tcx> Clean<GenericParamDef> for ty::GenericParamDef {
|
||||
}
|
||||
|
||||
impl Clean<GenericParamDef> for hir::GenericParam {
|
||||
fn clean(&self, cx: &DocContext) -> GenericParamDef {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericParamDef {
|
||||
let (name, kind) = match self.kind {
|
||||
hir::GenericParamKind::Lifetime { .. } => {
|
||||
let name = if self.bounds.len() > 0 {
|
||||
@ -1538,7 +1540,7 @@ pub struct Generics {
|
||||
}
|
||||
|
||||
impl Clean<Generics> for hir::Generics {
|
||||
fn clean(&self, cx: &DocContext) -> Generics {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Generics {
|
||||
// Synthetic type-parameters are inserted after normal ones.
|
||||
// In order for normal parameters to be able to refer to synthetic ones,
|
||||
// scans them first.
|
||||
@ -1608,7 +1610,7 @@ impl Clean<Generics> for hir::Generics {
|
||||
|
||||
impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
|
||||
&'a Lrc<ty::GenericPredicates<'tcx>>) {
|
||||
fn clean(&self, cx: &DocContext) -> Generics {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Generics {
|
||||
use self::WherePredicate as WP;
|
||||
|
||||
let (gens, preds) = *self;
|
||||
@ -1689,7 +1691,7 @@ pub struct Method {
|
||||
}
|
||||
|
||||
impl<'a> Clean<Method> for (&'a hir::MethodSig, &'a hir::Generics, hir::BodyId) {
|
||||
fn clean(&self, cx: &DocContext) -> Method {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Method {
|
||||
let (generics, decl) = enter_impl_trait(cx, || {
|
||||
(self.1.clean(cx), (&*self.0.decl, self.2).clean(cx))
|
||||
});
|
||||
@ -1716,7 +1718,7 @@ pub struct Function {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Function {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let (generics, decl) = enter_impl_trait(cx, || {
|
||||
(self.generics.clean(cx), (&self.decl, self.body).clean(cx))
|
||||
});
|
||||
@ -1788,7 +1790,7 @@ pub struct Arguments {
|
||||
}
|
||||
|
||||
impl<'a> Clean<Arguments> for (&'a [hir::Ty], &'a [ast::Ident]) {
|
||||
fn clean(&self, cx: &DocContext) -> Arguments {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Arguments {
|
||||
Arguments {
|
||||
values: self.0.iter().enumerate().map(|(i, ty)| {
|
||||
let mut name = self.1.get(i).map(|ident| ident.to_string())
|
||||
@ -1806,7 +1808,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty], &'a [ast::Ident]) {
|
||||
}
|
||||
|
||||
impl<'a> Clean<Arguments> for (&'a [hir::Ty], hir::BodyId) {
|
||||
fn clean(&self, cx: &DocContext) -> Arguments {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Arguments {
|
||||
let body = cx.tcx.hir().body(self.1);
|
||||
|
||||
Arguments {
|
||||
@ -1823,7 +1825,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty], hir::BodyId) {
|
||||
impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl, A)
|
||||
where (&'a [hir::Ty], A): Clean<Arguments>
|
||||
{
|
||||
fn clean(&self, cx: &DocContext) -> FnDecl {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> FnDecl {
|
||||
FnDecl {
|
||||
inputs: (&self.0.inputs[..], self.1).clean(cx),
|
||||
output: self.0.output.clean(cx),
|
||||
@ -1834,7 +1836,7 @@ impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl, A)
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
|
||||
fn clean(&self, cx: &DocContext) -> FnDecl {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> FnDecl {
|
||||
let (did, sig) = *self;
|
||||
let mut names = if cx.tcx.hir().as_local_node_id(did).is_some() {
|
||||
vec![].into_iter()
|
||||
@ -1895,7 +1897,7 @@ pub enum FunctionRetTy {
|
||||
}
|
||||
|
||||
impl Clean<FunctionRetTy> for hir::FunctionRetTy {
|
||||
fn clean(&self, cx: &DocContext) -> FunctionRetTy {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> FunctionRetTy {
|
||||
match *self {
|
||||
hir::Return(ref typ) => Return(typ.clean(cx)),
|
||||
hir::DefaultReturn(..) => DefaultReturn,
|
||||
@ -1924,7 +1926,7 @@ pub struct Trait {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Trait {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let attrs = self.attrs.clean(cx);
|
||||
let is_spotlight = attrs.has_doc_flag("spotlight");
|
||||
Item {
|
||||
@ -1955,7 +1957,7 @@ pub struct TraitAlias {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::TraitAlias {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let attrs = self.attrs.clean(cx);
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
@ -1974,7 +1976,7 @@ impl Clean<Item> for doctree::TraitAlias {
|
||||
}
|
||||
|
||||
impl Clean<bool> for hir::IsAuto {
|
||||
fn clean(&self, _: &DocContext) -> bool {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> bool {
|
||||
match *self {
|
||||
hir::IsAuto::Yes => true,
|
||||
hir::IsAuto::No => false,
|
||||
@ -1983,13 +1985,13 @@ impl Clean<bool> for hir::IsAuto {
|
||||
}
|
||||
|
||||
impl Clean<Type> for hir::TraitRef {
|
||||
fn clean(&self, cx: &DocContext) -> Type {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
|
||||
resolve_type(cx, self.path.clean(cx), self.ref_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<PolyTrait> for hir::PolyTraitRef {
|
||||
fn clean(&self, cx: &DocContext) -> PolyTrait {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> PolyTrait {
|
||||
PolyTrait {
|
||||
trait_: self.trait_ref.clean(cx),
|
||||
generic_params: self.bound_generic_params.clean(cx)
|
||||
@ -1998,7 +2000,7 @@ impl Clean<PolyTrait> for hir::PolyTraitRef {
|
||||
}
|
||||
|
||||
impl Clean<Item> for hir::TraitItem {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let inner = match self.node {
|
||||
hir::TraitItemKind::Const(ref ty, default) => {
|
||||
AssociatedConstItem(ty.clean(cx),
|
||||
@ -2035,7 +2037,7 @@ impl Clean<Item> for hir::TraitItem {
|
||||
}
|
||||
|
||||
impl Clean<Item> for hir::ImplItem {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let inner = match self.node {
|
||||
hir::ImplItemKind::Const(ref ty, expr) => {
|
||||
AssociatedConstItem(ty.clean(cx),
|
||||
@ -2067,7 +2069,7 @@ impl Clean<Item> for hir::ImplItem {
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Item> for ty::AssociatedItem {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let inner = match self.kind {
|
||||
ty::AssociatedKind::Const => {
|
||||
let ty = cx.tcx.type_of(self.def_id);
|
||||
@ -2385,7 +2387,7 @@ impl GetDefId for Type {
|
||||
fn def_id(&self) -> Option<DefId> {
|
||||
match *self {
|
||||
ResolvedPath { did, .. } => Some(did),
|
||||
Primitive(p) => ::html::render::cache().primitive_locations.get(&p).cloned(),
|
||||
Primitive(p) => crate::html::render::cache().primitive_locations.get(&p).cloned(),
|
||||
BorrowedRef { type_: box Generic(..), .. } =>
|
||||
Primitive(PrimitiveType::Reference).def_id(),
|
||||
BorrowedRef { ref type_, .. } => type_.def_id(),
|
||||
@ -2509,7 +2511,7 @@ impl From<ast::FloatTy> for PrimitiveType {
|
||||
}
|
||||
|
||||
impl Clean<Type> for hir::Ty {
|
||||
fn clean(&self, cx: &DocContext) -> Type {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
|
||||
use rustc::hir::*;
|
||||
|
||||
match self.node {
|
||||
@ -2708,7 +2710,7 @@ impl Clean<Type> for hir::Ty {
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||
fn clean(&self, cx: &DocContext) -> Type {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
|
||||
match self.sty {
|
||||
ty::Never => Never,
|
||||
ty::Bool => Primitive(PrimitiveType::Bool),
|
||||
@ -2903,7 +2905,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||
}
|
||||
|
||||
impl Clean<Item> for hir::StructField {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.ident.name).clean(cx),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -2918,7 +2920,7 @@ impl Clean<Item> for hir::StructField {
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Item> for ty::FieldDef {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.ident.name).clean(cx),
|
||||
attrs: cx.tcx.get_attrs(self.did).clean(cx),
|
||||
@ -2941,7 +2943,7 @@ pub enum Visibility {
|
||||
}
|
||||
|
||||
impl Clean<Option<Visibility>> for hir::Visibility {
|
||||
fn clean(&self, cx: &DocContext) -> Option<Visibility> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<Visibility> {
|
||||
Some(match self.node {
|
||||
hir::VisibilityKind::Public => Visibility::Public,
|
||||
hir::VisibilityKind::Inherited => Visibility::Inherited,
|
||||
@ -2956,7 +2958,7 @@ impl Clean<Option<Visibility>> for hir::Visibility {
|
||||
}
|
||||
|
||||
impl Clean<Option<Visibility>> for ty::Visibility {
|
||||
fn clean(&self, _: &DocContext) -> Option<Visibility> {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> Option<Visibility> {
|
||||
Some(if *self == ty::Visibility::Public { Public } else { Inherited })
|
||||
}
|
||||
}
|
||||
@ -2978,7 +2980,7 @@ pub struct Union {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Struct {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -2998,7 +3000,7 @@ impl Clean<Item> for doctree::Struct {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Union {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -3028,7 +3030,7 @@ pub struct VariantStruct {
|
||||
}
|
||||
|
||||
impl Clean<VariantStruct> for ::rustc::hir::VariantData {
|
||||
fn clean(&self, cx: &DocContext) -> VariantStruct {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> VariantStruct {
|
||||
VariantStruct {
|
||||
struct_type: doctree::struct_type_from_def(self),
|
||||
fields: self.fields().iter().map(|x| x.clean(cx)).collect(),
|
||||
@ -3045,7 +3047,7 @@ pub struct Enum {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Enum {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -3069,7 +3071,7 @@ pub struct Variant {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Variant {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -3086,7 +3088,7 @@ impl Clean<Item> for doctree::Variant {
|
||||
}
|
||||
|
||||
impl<'tcx> Clean<Item> for ty::VariantDef {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let kind = match self.ctor_kind {
|
||||
CtorKind::Const => VariantKind::CLike,
|
||||
CtorKind::Fn => {
|
||||
@ -3134,7 +3136,7 @@ pub enum VariantKind {
|
||||
}
|
||||
|
||||
impl Clean<VariantKind> for hir::VariantData {
|
||||
fn clean(&self, cx: &DocContext) -> VariantKind {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> VariantKind {
|
||||
if self.is_struct() {
|
||||
VariantKind::Struct(self.clean(cx))
|
||||
} else if self.is_unit() {
|
||||
@ -3165,7 +3167,7 @@ impl Span {
|
||||
}
|
||||
|
||||
impl Clean<Span> for syntax_pos::Span {
|
||||
fn clean(&self, cx: &DocContext) -> Span {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Span {
|
||||
if self.is_dummy() {
|
||||
return Span::empty();
|
||||
}
|
||||
@ -3198,7 +3200,7 @@ impl Path {
|
||||
}
|
||||
|
||||
impl Clean<Path> for hir::Path {
|
||||
fn clean(&self, cx: &DocContext) -> Path {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Path {
|
||||
Path {
|
||||
global: self.is_global(),
|
||||
def: self.def,
|
||||
@ -3221,7 +3223,7 @@ pub enum GenericArgs {
|
||||
}
|
||||
|
||||
impl Clean<GenericArgs> for hir::GenericArgs {
|
||||
fn clean(&self, cx: &DocContext) -> GenericArgs {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericArgs {
|
||||
if self.parenthesized {
|
||||
let output = self.bindings[0].ty.clean(cx);
|
||||
GenericArgs::Parenthesized {
|
||||
@ -3263,7 +3265,7 @@ pub struct PathSegment {
|
||||
}
|
||||
|
||||
impl Clean<PathSegment> for hir::PathSegment {
|
||||
fn clean(&self, cx: &DocContext) -> PathSegment {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> PathSegment {
|
||||
PathSegment {
|
||||
name: self.ident.name.clean(cx),
|
||||
args: self.with_generic_args(|generic_args| generic_args.clean(cx))
|
||||
@ -3335,21 +3337,21 @@ fn qpath_to_string(p: &hir::QPath) -> String {
|
||||
|
||||
impl Clean<String> for Ident {
|
||||
#[inline]
|
||||
fn clean(&self, cx: &DocContext) -> String {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> String {
|
||||
self.name.clean(cx)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<String> for ast::Name {
|
||||
#[inline]
|
||||
fn clean(&self, _: &DocContext) -> String {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> String {
|
||||
self.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<String> for InternedString {
|
||||
#[inline]
|
||||
fn clean(&self, _: &DocContext) -> String {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> String {
|
||||
self.to_string()
|
||||
}
|
||||
}
|
||||
@ -3361,7 +3363,7 @@ pub struct Typedef {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Typedef {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -3385,7 +3387,7 @@ pub struct Existential {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Existential {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -3411,7 +3413,7 @@ pub struct BareFunctionDecl {
|
||||
}
|
||||
|
||||
impl Clean<BareFunctionDecl> for hir::BareFnTy {
|
||||
fn clean(&self, cx: &DocContext) -> BareFunctionDecl {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> BareFunctionDecl {
|
||||
let (generic_params, decl) = enter_impl_trait(cx, || {
|
||||
(self.generic_params.clean(cx), (&*self.decl, &self.arg_names[..]).clean(cx))
|
||||
});
|
||||
@ -3435,7 +3437,7 @@ pub struct Static {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Static {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
debug!("cleaning static {}: {:?}", self.name.clean(cx), self);
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
@ -3461,7 +3463,7 @@ pub struct Constant {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Constant {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -3485,7 +3487,7 @@ pub enum Mutability {
|
||||
}
|
||||
|
||||
impl Clean<Mutability> for hir::Mutability {
|
||||
fn clean(&self, _: &DocContext) -> Mutability {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> Mutability {
|
||||
match self {
|
||||
&hir::MutMutable => Mutable,
|
||||
&hir::MutImmutable => Immutable,
|
||||
@ -3500,7 +3502,7 @@ pub enum ImplPolarity {
|
||||
}
|
||||
|
||||
impl Clean<ImplPolarity> for hir::ImplPolarity {
|
||||
fn clean(&self, _: &DocContext) -> ImplPolarity {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> ImplPolarity {
|
||||
match self {
|
||||
&hir::ImplPolarity::Positive => ImplPolarity::Positive,
|
||||
&hir::ImplPolarity::Negative => ImplPolarity::Negative,
|
||||
@ -3521,30 +3523,30 @@ pub struct Impl {
|
||||
pub blanket_impl: Option<Type>,
|
||||
}
|
||||
|
||||
pub fn get_auto_traits_with_node_id(cx: &DocContext, id: ast::NodeId, name: String) -> Vec<Item> {
|
||||
pub fn get_auto_traits_with_node_id(cx: &DocContext<'_, '_, '_>, id: ast::NodeId, name: String) -> Vec<Item> {
|
||||
let finder = AutoTraitFinder::new(cx);
|
||||
finder.get_with_node_id(id, name)
|
||||
}
|
||||
|
||||
pub fn get_auto_traits_with_def_id(cx: &DocContext, id: DefId) -> Vec<Item> {
|
||||
pub fn get_auto_traits_with_def_id(cx: &DocContext<'_, '_, '_>, id: DefId) -> Vec<Item> {
|
||||
let finder = AutoTraitFinder::new(cx);
|
||||
|
||||
finder.get_with_def_id(id)
|
||||
}
|
||||
|
||||
pub fn get_blanket_impls_with_node_id(cx: &DocContext, id: ast::NodeId, name: String) -> Vec<Item> {
|
||||
pub fn get_blanket_impls_with_node_id(cx: &DocContext<'_, '_, '_>, id: ast::NodeId, name: String) -> Vec<Item> {
|
||||
let finder = BlanketImplFinder::new(cx);
|
||||
finder.get_with_node_id(id, name)
|
||||
}
|
||||
|
||||
pub fn get_blanket_impls_with_def_id(cx: &DocContext, id: DefId) -> Vec<Item> {
|
||||
pub fn get_blanket_impls_with_def_id(cx: &DocContext<'_, '_, '_>, id: DefId) -> Vec<Item> {
|
||||
let finder = BlanketImplFinder::new(cx);
|
||||
|
||||
finder.get_with_def_id(id)
|
||||
}
|
||||
|
||||
impl Clean<Vec<Item>> for doctree::Impl {
|
||||
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
|
||||
let mut ret = Vec::new();
|
||||
let trait_ = self.trait_.clean(cx);
|
||||
let items = self.items.clean(cx);
|
||||
@ -3586,7 +3588,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_deref_target_impls(cx: &DocContext,
|
||||
fn build_deref_target_impls(cx: &DocContext<'_, '_, '_>,
|
||||
items: &[Item],
|
||||
ret: &mut Vec<Item>) {
|
||||
use self::PrimitiveType::*;
|
||||
@ -3644,7 +3646,7 @@ fn build_deref_target_impls(cx: &DocContext,
|
||||
}
|
||||
|
||||
impl Clean<Vec<Item>> for doctree::ExternCrate {
|
||||
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
|
||||
|
||||
let please_inline = self.vis.node.is_pub() && self.attrs.iter().any(|a| {
|
||||
a.name() == "doc" && match a.meta_item_list() {
|
||||
@ -3680,7 +3682,7 @@ impl Clean<Vec<Item>> for doctree::ExternCrate {
|
||||
}
|
||||
|
||||
impl Clean<Vec<Item>> for doctree::Import {
|
||||
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
|
||||
// We consider inlining the documentation of `pub use` statements, but we
|
||||
// forcefully don't inline if this is not public or if the
|
||||
// #[doc(no_inline)] attribute is present.
|
||||
@ -3754,7 +3756,7 @@ pub struct ImportSource {
|
||||
}
|
||||
|
||||
impl Clean<Vec<Item>> for hir::ForeignMod {
|
||||
fn clean(&self, cx: &DocContext) -> Vec<Item> {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
|
||||
let mut items = self.items.clean(cx);
|
||||
for item in &mut items {
|
||||
if let ForeignFunctionItem(ref mut f) = item.inner {
|
||||
@ -3766,7 +3768,7 @@ impl Clean<Vec<Item>> for hir::ForeignMod {
|
||||
}
|
||||
|
||||
impl Clean<Item> for hir::ForeignItem {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let inner = match self.node {
|
||||
hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => {
|
||||
let (generics, decl) = enter_impl_trait(cx, || {
|
||||
@ -3811,11 +3813,11 @@ impl Clean<Item> for hir::ForeignItem {
|
||||
// Utilities
|
||||
|
||||
pub trait ToSource {
|
||||
fn to_src(&self, cx: &DocContext) -> String;
|
||||
fn to_src(&self, cx: &DocContext<'_, '_, '_>) -> String;
|
||||
}
|
||||
|
||||
impl ToSource for syntax_pos::Span {
|
||||
fn to_src(&self, cx: &DocContext) -> String {
|
||||
fn to_src(&self, cx: &DocContext<'_, '_, '_>) -> String {
|
||||
debug!("converting span {:?} to snippet", self.clean(cx));
|
||||
let sn = match cx.sess().source_map().span_to_snippet(*self) {
|
||||
Ok(x) => x,
|
||||
@ -3862,7 +3864,7 @@ fn name_from_pat(p: &hir::Pat) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn print_const(cx: &DocContext, n: ty::LazyConst) -> String {
|
||||
fn print_const(cx: &DocContext<'_, '_, '_>, n: ty::LazyConst<'_>) -> String {
|
||||
match n {
|
||||
ty::LazyConst::Unevaluated(def_id, _) => {
|
||||
if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) {
|
||||
@ -3884,12 +3886,12 @@ fn print_const(cx: &DocContext, n: ty::LazyConst) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn print_const_expr(cx: &DocContext, body: hir::BodyId) -> String {
|
||||
fn print_const_expr(cx: &DocContext<'_, '_, '_>, body: hir::BodyId) -> String {
|
||||
cx.tcx.hir().hir_to_pretty_string(body.hir_id)
|
||||
}
|
||||
|
||||
/// Given a type Path, resolve it to a Type using the TyCtxt
|
||||
fn resolve_type(cx: &DocContext,
|
||||
fn resolve_type(cx: &DocContext<'_, '_, '_>,
|
||||
path: Path,
|
||||
id: ast::NodeId) -> Type {
|
||||
if id == ast::DUMMY_NODE_ID {
|
||||
@ -3920,7 +3922,7 @@ fn resolve_type(cx: &DocContext,
|
||||
ResolvedPath { path: path, typarams: None, did: did, is_generic: is_generic }
|
||||
}
|
||||
|
||||
pub fn register_def(cx: &DocContext, def: Def) -> DefId {
|
||||
pub fn register_def(cx: &DocContext<'_, '_, '_>, def: Def) -> DefId {
|
||||
debug!("register_def({:?})", def);
|
||||
|
||||
let (did, kind) = match def {
|
||||
@ -3955,7 +3957,7 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId {
|
||||
did
|
||||
}
|
||||
|
||||
fn resolve_use_source(cx: &DocContext, path: Path) -> ImportSource {
|
||||
fn resolve_use_source(cx: &DocContext<'_, '_, '_>, path: Path) -> ImportSource {
|
||||
ImportSource {
|
||||
did: if path.def.opt_def_id().is_none() {
|
||||
None
|
||||
@ -3973,7 +3975,7 @@ pub struct Macro {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::Macro {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
let name = self.name.clean(cx);
|
||||
Item {
|
||||
name: Some(name.clone()),
|
||||
@ -4002,7 +4004,7 @@ pub struct ProcMacro {
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::ProcMacro {
|
||||
fn clean(&self, cx: &DocContext) -> Item {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
|
||||
Item {
|
||||
name: Some(self.name.clean(cx)),
|
||||
attrs: self.attrs.clean(cx),
|
||||
@ -4036,7 +4038,7 @@ pub struct Deprecation {
|
||||
}
|
||||
|
||||
impl Clean<Stability> for attr::Stability {
|
||||
fn clean(&self, _: &DocContext) -> Stability {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> Stability {
|
||||
Stability {
|
||||
level: stability::StabilityLevel::from_attr_level(&self.level),
|
||||
feature: Some(self.feature.to_string()).filter(|f| !f.is_empty()),
|
||||
@ -4063,13 +4065,13 @@ impl Clean<Stability> for attr::Stability {
|
||||
}
|
||||
|
||||
impl<'a> Clean<Stability> for &'a attr::Stability {
|
||||
fn clean(&self, dc: &DocContext) -> Stability {
|
||||
fn clean(&self, dc: &DocContext<'_, '_, '_>) -> Stability {
|
||||
(**self).clean(dc)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<Deprecation> for attr::Deprecation {
|
||||
fn clean(&self, _: &DocContext) -> Deprecation {
|
||||
fn clean(&self, _: &DocContext<'_, '_, '_>) -> Deprecation {
|
||||
Deprecation {
|
||||
since: self.since.map(|s| s.to_string()).filter(|s| !s.is_empty()),
|
||||
note: self.note.map(|n| n.to_string()).filter(|n| !n.is_empty()),
|
||||
@ -4085,7 +4087,7 @@ pub struct TypeBinding {
|
||||
}
|
||||
|
||||
impl Clean<TypeBinding> for hir::TypeBinding {
|
||||
fn clean(&self, cx: &DocContext) -> TypeBinding {
|
||||
fn clean(&self, cx: &DocContext<'_, '_, '_>) -> TypeBinding {
|
||||
TypeBinding {
|
||||
name: self.ident.name.clean(cx),
|
||||
ty: self.ty.clean(cx)
|
||||
@ -4093,7 +4095,7 @@ impl Clean<TypeBinding> for hir::TypeBinding {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<String> {
|
||||
pub fn def_id_to_path(cx: &DocContext<'_, '_, '_>, did: DefId, name: Option<String>) -> Vec<String> {
|
||||
let crate_name = name.unwrap_or_else(|| cx.tcx.crate_name(did.krate).to_string());
|
||||
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
|
||||
// extern blocks have an empty name
|
||||
@ -4107,7 +4109,7 @@ pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<
|
||||
once(crate_name).chain(relative).collect()
|
||||
}
|
||||
|
||||
pub fn enter_impl_trait<F, R>(cx: &DocContext, f: F) -> R
|
||||
pub fn enter_impl_trait<F, R>(cx: &DocContext<'_, '_, '_>, f: F) -> R
|
||||
where
|
||||
F: FnOnce() -> R,
|
||||
{
|
||||
@ -4120,7 +4122,7 @@ where
|
||||
|
||||
// Start of code copied from rust-clippy
|
||||
|
||||
pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
|
||||
pub fn path_to_def_local(tcx: &TyCtxt<'_, '_, '_>, path: &[&str]) -> Option<DefId> {
|
||||
let krate = tcx.hir().krate();
|
||||
let mut items = krate.module.item_ids.clone();
|
||||
let mut path_it = path.iter().peekable();
|
||||
@ -4145,7 +4147,7 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
|
||||
pub fn path_to_def(tcx: &TyCtxt<'_, '_, '_>, path: &[&str]) -> Option<DefId> {
|
||||
let crates = tcx.crates();
|
||||
|
||||
let krate = crates
|
||||
@ -4182,7 +4184,7 @@ pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_path_for_type<F>(tcx: TyCtxt, def_id: DefId, def_ctor: F) -> hir::Path
|
||||
pub fn get_path_for_type<F>(tcx: TyCtxt<'_, '_, '_>, def_id: DefId, def_ctor: F) -> hir::Path
|
||||
where F: Fn(DefId) -> Def {
|
||||
#[derive(Debug)]
|
||||
struct AbsolutePathBuffer {
|
||||
|
@ -17,12 +17,12 @@ use std::collections::BTreeMap;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::ty;
|
||||
|
||||
use clean::GenericArgs as PP;
|
||||
use clean::WherePredicate as WP;
|
||||
use clean;
|
||||
use core::DocContext;
|
||||
use crate::clean::GenericArgs as PP;
|
||||
use crate::clean::WherePredicate as WP;
|
||||
use crate::clean;
|
||||
use crate::core::DocContext;
|
||||
|
||||
pub fn where_clauses(cx: &DocContext, clauses: Vec<WP>) -> Vec<WP> {
|
||||
pub fn where_clauses(cx: &DocContext<'_, '_, '_>, clauses: Vec<WP>) -> Vec<WP> {
|
||||
// First, partition the where clause into its separate components
|
||||
let mut params: BTreeMap<_, Vec<_>> = BTreeMap::new();
|
||||
let mut lifetimes = Vec::new();
|
||||
@ -141,7 +141,7 @@ fn ty_bounds(bounds: Vec<clean::GenericBound>) -> Vec<clean::GenericBound> {
|
||||
bounds
|
||||
}
|
||||
|
||||
fn trait_is_same_or_supertrait(cx: &DocContext, child: DefId,
|
||||
fn trait_is_same_or_supertrait(cx: &DocContext<'_, '_, '_>, child: DefId,
|
||||
trait_: DefId) -> bool {
|
||||
if child == trait_ {
|
||||
return true
|
||||
|
@ -15,14 +15,14 @@ use rustc_driver;
|
||||
use rustc_target::spec::TargetTriple;
|
||||
use syntax::edition::Edition;
|
||||
|
||||
use core::new_handler;
|
||||
use externalfiles::ExternalHtml;
|
||||
use html;
|
||||
use html::markdown::IdMap;
|
||||
use html::static_files;
|
||||
use opts;
|
||||
use passes::{self, DefaultPassOption};
|
||||
use theme;
|
||||
use crate::core::new_handler;
|
||||
use crate::externalfiles::ExternalHtml;
|
||||
use crate::html;
|
||||
use crate::html::{static_files};
|
||||
use crate::html::markdown::{IdMap};
|
||||
use crate::opts;
|
||||
use crate::passes::{self, DefaultPassOption};
|
||||
use crate::theme;
|
||||
|
||||
/// Configuration options for rustdoc.
|
||||
#[derive(Clone)]
|
||||
@ -95,11 +95,11 @@ pub struct Options {
|
||||
}
|
||||
|
||||
impl fmt::Debug for Options {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
struct FmtExterns<'a>(&'a Externs);
|
||||
|
||||
impl<'a> fmt::Debug for FmtExterns<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_map()
|
||||
.entries(self.0.iter())
|
||||
.finish()
|
||||
@ -204,7 +204,7 @@ impl Options {
|
||||
nightly_options::check_nightly_options(&matches, &opts());
|
||||
|
||||
if matches.opt_present("h") || matches.opt_present("help") {
|
||||
::usage("rustdoc");
|
||||
crate::usage("rustdoc");
|
||||
return Err(0);
|
||||
} else if matches.opt_present("version") {
|
||||
rustc_driver::version("rustdoc", &matches);
|
||||
|
@ -33,12 +33,13 @@ use rustc_data_structures::sync::{self, Lrc};
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use visit_ast::RustdocVisitor;
|
||||
use config::{Options as RustdocOptions, RenderOptions};
|
||||
use clean;
|
||||
use clean::{get_path_for_type, Clean, MAX_DEF_ID, AttributesExt};
|
||||
use html::render::RenderInfo;
|
||||
use passes;
|
||||
use crate::visit_ast::RustdocVisitor;
|
||||
use crate::config::{Options as RustdocOptions, RenderOptions};
|
||||
use crate::clean;
|
||||
use crate::clean::{get_path_for_type, Clean, MAX_DEF_ID, AttributesExt};
|
||||
use crate::html::render::RenderInfo;
|
||||
|
||||
use crate::passes;
|
||||
|
||||
pub use rustc::session::config::{Input, Options, CodegenOptions};
|
||||
pub use rustc::session::search_paths::SearchPath;
|
||||
|
@ -2,8 +2,9 @@ use std::fs;
|
||||
use std::path::Path;
|
||||
use std::str;
|
||||
use errors;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
use html::markdown::{IdMap, ErrorCodes, Markdown};
|
||||
use crate::syntax::feature_gate::UnstableFeatures;
|
||||
use crate::html::markdown::{IdMap, ErrorCodes, Markdown};
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use clean::*;
|
||||
use crate::clean::*;
|
||||
|
||||
pub struct StripItem(pub Item);
|
||||
|
||||
|
@ -10,7 +10,7 @@ use std::fmt;
|
||||
pub struct Escape<'a>(pub &'a str);
|
||||
|
||||
impl<'a> fmt::Display for Escape<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// Because the internet is always right, turns out there's not that many
|
||||
// characters to escape: http://stackoverflow.com/questions/7381974
|
||||
let Escape(s) = *self;
|
||||
|
@ -12,10 +12,11 @@ use rustc::hir::def_id::DefId;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc::hir;
|
||||
|
||||
use clean::{self, PrimitiveType};
|
||||
use core::DocAccessLevels;
|
||||
use html::item_type::ItemType;
|
||||
use html::render::{self, cache, CURRENT_LOCATION_KEY};
|
||||
use crate::clean::{self, PrimitiveType};
|
||||
use crate::core::DocAccessLevels;
|
||||
use crate::html::item_type::ItemType;
|
||||
use crate::html::render::{self, cache, CURRENT_LOCATION_KEY};
|
||||
|
||||
|
||||
/// Helper to render an optional visibility with a space after it (if the
|
||||
/// visibility is preset)
|
||||
@ -42,7 +43,7 @@ pub struct RawMutableSpace(pub clean::Mutability);
|
||||
/// Wrapper struct for emitting type parameter bounds.
|
||||
pub struct GenericBounds<'a>(pub &'a [clean::GenericBound]);
|
||||
/// Wrapper struct for emitting a comma-separated list of items
|
||||
pub struct CommaSep<'a, T: 'a>(pub &'a [T]);
|
||||
pub struct CommaSep<'a, T>(pub &'a [T]);
|
||||
pub struct AbiSpace(pub Abi);
|
||||
|
||||
/// Wrapper struct for properly emitting a function or method declaration.
|
||||
@ -94,7 +95,7 @@ impl ConstnessSpace {
|
||||
}
|
||||
|
||||
impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
for (i, item) in self.0.iter().enumerate() {
|
||||
if i != 0 { write!(f, ", ")?; }
|
||||
fmt::Display::fmt(item, f)?;
|
||||
@ -104,7 +105,7 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for GenericBounds<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let &GenericBounds(bounds) = self;
|
||||
for (i, bound) in bounds.iter().enumerate() {
|
||||
if i > 0 {
|
||||
@ -117,7 +118,7 @@ impl<'a> fmt::Display for GenericBounds<'a> {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::GenericParamDef {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.kind {
|
||||
clean::GenericParamDefKind::Lifetime => write!(f, "{}", self.name),
|
||||
clean::GenericParamDefKind::Type { ref bounds, ref default, .. } => {
|
||||
@ -156,7 +157,7 @@ impl fmt::Display for clean::GenericParamDef {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Generics {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let real_params = self.params
|
||||
.iter()
|
||||
.filter(|p| !p.is_synthetic_type_param())
|
||||
@ -173,7 +174,7 @@ impl fmt::Display for clean::Generics {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for WhereClause<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let &WhereClause { gens, indent, end_newline } = self;
|
||||
if gens.where_predicates.is_empty() {
|
||||
return Ok(());
|
||||
@ -252,14 +253,14 @@ impl<'a> fmt::Display for WhereClause<'a> {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Lifetime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(self.get_ref())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::PolyTrait {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if !self.generic_params.is_empty() {
|
||||
if f.alternate() {
|
||||
write!(f, "for<{:#}> ", CommaSep(&self.generic_params))?;
|
||||
@ -276,7 +277,7 @@ impl fmt::Display for clean::PolyTrait {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::GenericBound {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
clean::GenericBound::Outlives(ref lt) => {
|
||||
write!(f, "{}", *lt)
|
||||
@ -297,7 +298,7 @@ impl fmt::Display for clean::GenericBound {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::GenericArgs {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
clean::GenericArgs::AngleBracketed {
|
||||
ref lifetimes, ref types, ref bindings
|
||||
@ -374,7 +375,7 @@ impl fmt::Display for clean::GenericArgs {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::PathSegment {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(&self.name)?;
|
||||
if f.alternate() {
|
||||
write!(f, "{:#}", self.args)
|
||||
@ -385,7 +386,7 @@ impl fmt::Display for clean::PathSegment {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Path {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.global {
|
||||
f.write_str("::")?
|
||||
}
|
||||
@ -445,7 +446,7 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
|
||||
|
||||
/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
|
||||
/// rendering function with the necessary arguments for linking to a local path.
|
||||
fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||
fn resolved_path(w: &mut fmt::Formatter<'_>, did: DefId, path: &clean::Path,
|
||||
print_all: bool, use_absolute: bool) -> fmt::Result {
|
||||
let last = path.segments.last().unwrap();
|
||||
|
||||
@ -474,7 +475,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn primitive_link(f: &mut fmt::Formatter,
|
||||
fn primitive_link(f: &mut fmt::Formatter<'_>,
|
||||
prim: clean::PrimitiveType,
|
||||
name: &str) -> fmt::Result {
|
||||
let m = cache();
|
||||
@ -519,7 +520,7 @@ fn primitive_link(f: &mut fmt::Formatter,
|
||||
}
|
||||
|
||||
/// Helper to render type parameters
|
||||
fn tybounds(w: &mut fmt::Formatter,
|
||||
fn tybounds(w: &mut fmt::Formatter<'_>,
|
||||
typarams: &Option<Vec<clean::GenericBound>>) -> fmt::Result {
|
||||
match *typarams {
|
||||
Some(ref params) => {
|
||||
@ -540,7 +541,7 @@ impl<'a> HRef<'a> {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for HRef<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match href(self.did) {
|
||||
Some((url, shortty, fqp)) => if !f.alternate() {
|
||||
write!(f, "<a class=\"{}\" href=\"{}\" title=\"{} {}\">{}</a>",
|
||||
@ -553,7 +554,7 @@ impl<'a> fmt::Display for HRef<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt::Result {
|
||||
fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> fmt::Result {
|
||||
match *t {
|
||||
clean::Generic(ref name) => {
|
||||
f.write_str(name)
|
||||
@ -745,13 +746,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Type {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt_type(self, f, false)
|
||||
}
|
||||
}
|
||||
|
||||
fn fmt_impl(i: &clean::Impl,
|
||||
f: &mut fmt::Formatter,
|
||||
f: &mut fmt::Formatter<'_>,
|
||||
link_trait: bool,
|
||||
use_absolute: bool) -> fmt::Result {
|
||||
if f.alternate() {
|
||||
@ -791,20 +792,20 @@ fn fmt_impl(i: &clean::Impl,
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Impl {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt_impl(self, f, true, false)
|
||||
}
|
||||
}
|
||||
|
||||
// The difference from above is that trait is not hyperlinked.
|
||||
pub fn fmt_impl_for_trait_page(i: &clean::Impl,
|
||||
f: &mut fmt::Formatter,
|
||||
f: &mut fmt::Formatter<'_>,
|
||||
use_absolute: bool) -> fmt::Result {
|
||||
fmt_impl(i, f, false, use_absolute)
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Arguments {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
for (i, input) in self.values.iter().enumerate() {
|
||||
if !input.name.is_empty() {
|
||||
write!(f, "{}: ", input.name)?;
|
||||
@ -821,7 +822,7 @@ impl fmt::Display for clean::Arguments {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::FunctionRetTy {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
clean::Return(clean::Tuple(ref tys)) if tys.is_empty() => Ok(()),
|
||||
clean::Return(ref ty) if f.alternate() => write!(f, " -> {:#}", ty),
|
||||
@ -832,7 +833,7 @@ impl fmt::Display for clean::FunctionRetTy {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::FnDecl {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.variadic {
|
||||
if f.alternate() {
|
||||
write!(f, "({args:#}, ...){arrow:#}", args = self.inputs, arrow = self.output)
|
||||
@ -850,7 +851,7 @@ impl fmt::Display for clean::FnDecl {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for Function<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let &Function { decl, header_len, indent, asyncness } = self;
|
||||
let amp = if f.alternate() { "&" } else { "&" };
|
||||
let mut args = String::new();
|
||||
@ -947,7 +948,7 @@ impl<'a> fmt::Display for Function<'a> {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for VisSpace<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self.get() {
|
||||
Some(clean::Public) => f.write_str("pub "),
|
||||
Some(clean::Inherited) | None => Ok(()),
|
||||
@ -967,7 +968,7 @@ impl<'a> fmt::Display for VisSpace<'a> {
|
||||
}
|
||||
|
||||
impl fmt::Display for UnsafetySpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.get() {
|
||||
hir::Unsafety::Unsafe => write!(f, "unsafe "),
|
||||
hir::Unsafety::Normal => Ok(())
|
||||
@ -976,7 +977,7 @@ impl fmt::Display for UnsafetySpace {
|
||||
}
|
||||
|
||||
impl fmt::Display for ConstnessSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.get() {
|
||||
hir::Constness::Const => write!(f, "const "),
|
||||
hir::Constness::NotConst => Ok(())
|
||||
@ -985,7 +986,7 @@ impl fmt::Display for ConstnessSpace {
|
||||
}
|
||||
|
||||
impl fmt::Display for AsyncSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.0 {
|
||||
hir::IsAsync::Async => write!(f, "async "),
|
||||
hir::IsAsync::NotAsync => Ok(()),
|
||||
@ -994,7 +995,7 @@ impl fmt::Display for AsyncSpace {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Import {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
clean::Import::Simple(ref name, ref src) => {
|
||||
if *name == src.path.last_name() {
|
||||
@ -1015,7 +1016,7 @@ impl fmt::Display for clean::Import {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::ImportSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.did {
|
||||
Some(did) => resolved_path(f, did, &self.path, true, false),
|
||||
_ => {
|
||||
@ -1032,7 +1033,7 @@ impl fmt::Display for clean::ImportSource {
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::TypeBinding {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if f.alternate() {
|
||||
write!(f, "{} = {:#}", self.name, self.ty)
|
||||
} else {
|
||||
@ -1042,7 +1043,7 @@ impl fmt::Display for clean::TypeBinding {
|
||||
}
|
||||
|
||||
impl fmt::Display for MutableSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
MutableSpace(clean::Immutable) => Ok(()),
|
||||
MutableSpace(clean::Mutable) => write!(f, "mut "),
|
||||
@ -1051,7 +1052,7 @@ impl fmt::Display for MutableSpace {
|
||||
}
|
||||
|
||||
impl fmt::Display for RawMutableSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
RawMutableSpace(clean::Immutable) => write!(f, "const "),
|
||||
RawMutableSpace(clean::Mutable) => write!(f, "mut "),
|
||||
@ -1060,7 +1061,7 @@ impl fmt::Display for RawMutableSpace {
|
||||
}
|
||||
|
||||
impl fmt::Display for AbiSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let quot = if f.alternate() { "\"" } else { """ };
|
||||
match self.0 {
|
||||
Abi::Rust => Ok(()),
|
||||
|
@ -5,7 +5,7 @@
|
||||
//!
|
||||
//! Use the `render_with_highlighting` to highlight some rust code.
|
||||
|
||||
use html::escape::Escape;
|
||||
use crate::html::escape::Escape;
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::io;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::fmt;
|
||||
use syntax::ext::base::MacroKind;
|
||||
use clean;
|
||||
use crate::clean;
|
||||
|
||||
/// Item type. Corresponds to `clean::ItemEnum` variants.
|
||||
///
|
||||
@ -189,7 +189,7 @@ impl ItemType {
|
||||
}
|
||||
|
||||
impl fmt::Display for ItemType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.css_class().fmt(f)
|
||||
}
|
||||
}
|
||||
@ -211,7 +211,7 @@ impl NameSpace {
|
||||
}
|
||||
|
||||
impl fmt::Display for NameSpace {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.to_static_str().fmt(f)
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,8 @@ use std::fmt;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use externalfiles::ExternalHtml;
|
||||
|
||||
use html::render::SlashChecker;
|
||||
use crate::externalfiles::ExternalHtml;
|
||||
use crate::html::render::SlashChecker;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Layout {
|
||||
@ -29,7 +28,7 @@ pub struct Page<'a> {
|
||||
pub fn render<T: fmt::Display, S: fmt::Display>(
|
||||
dst: &mut dyn io::Write,
|
||||
layout: &Layout,
|
||||
page: &Page,
|
||||
page: &Page<'_>,
|
||||
sidebar: &S,
|
||||
t: &T,
|
||||
css_file_extension: bool,
|
||||
|
@ -29,9 +29,9 @@ use std::ops::Range;
|
||||
use std::str;
|
||||
use syntax::edition::Edition;
|
||||
|
||||
use html::toc::TocBuilder;
|
||||
use html::highlight;
|
||||
use test;
|
||||
use crate::html::toc::TocBuilder;
|
||||
use crate::html::highlight;
|
||||
use crate::test;
|
||||
|
||||
use pulldown_cmark::{html, Event, Tag, Parser};
|
||||
use pulldown_cmark::{Options, OPTION_ENABLE_FOOTNOTES, OPTION_ENABLE_TABLES};
|
||||
@ -101,7 +101,7 @@ impl<'a> Line<'a> {
|
||||
// is done in the single # case. This inconsistency seems okay, if non-ideal. In
|
||||
// order to fix it we'd have to iterate to find the first non-# character, and
|
||||
// then reallocate to remove it; which would make us return a String.
|
||||
fn map_line(s: &str) -> Line {
|
||||
fn map_line(s: &str) -> Line<'_> {
|
||||
let trimmed = s.trim();
|
||||
if trimmed.starts_with("##") {
|
||||
Line::Shown(Cow::Owned(s.replacen("##", "#", 1)))
|
||||
@ -185,7 +185,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'a, I> {
|
||||
}
|
||||
}
|
||||
let lines = origtext.lines().filter_map(|l| map_line(l).for_html());
|
||||
let text = lines.collect::<Vec<Cow<str>>>().join("\n");
|
||||
let text = lines.collect::<Vec<Cow<'_, str>>>().join("\n");
|
||||
PLAYGROUND.with(|play| {
|
||||
// insert newline to clearly separate it from the
|
||||
// previous block so we can shorten the html output
|
||||
@ -196,7 +196,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'a, I> {
|
||||
}
|
||||
let test = origtext.lines()
|
||||
.map(|l| map_line(l).for_code())
|
||||
.collect::<Vec<Cow<str>>>().join("\n");
|
||||
.collect::<Vec<Cow<'_, str>>>().join("\n");
|
||||
let krate = krate.as_ref().map(|s| &**s);
|
||||
let (test, _) = test::make_test(&test, krate, false,
|
||||
&Default::default());
|
||||
@ -386,7 +386,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> SummaryLine<'a, I> {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_if_allowed_tag(t: &Tag) -> bool {
|
||||
fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
|
||||
match *t {
|
||||
Tag::Paragraph
|
||||
| Tag::Item
|
||||
@ -523,7 +523,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for Footnotes<'a, I> {
|
||||
pub struct TestableCodeError(());
|
||||
|
||||
impl fmt::Display for TestableCodeError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "invalid start of a new code block")
|
||||
}
|
||||
}
|
||||
@ -569,7 +569,7 @@ pub fn find_testable_code<T: test::Tester>(
|
||||
}
|
||||
if let Some(offset) = offset {
|
||||
let lines = test_s.lines().map(|l| map_line(l).for_code());
|
||||
let text = lines.collect::<Vec<Cow<str>>>().join("\n");
|
||||
let text = lines.collect::<Vec<Cow<'_, str>>>().join("\n");
|
||||
nb_lines += doc[prev_offset..offset].lines().count();
|
||||
let line = tests.get_line() + (nb_lines - 1);
|
||||
tests.add_test(text, block_info, line);
|
||||
@ -681,7 +681,7 @@ impl LangString {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for Markdown<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let Markdown(md, links, ref ids, codes) = *self;
|
||||
let mut ids = ids.borrow_mut();
|
||||
|
||||
@ -714,7 +714,7 @@ impl<'a> fmt::Display for Markdown<'a> {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for MarkdownWithToc<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let MarkdownWithToc(md, ref ids, codes) = *self;
|
||||
let mut ids = ids.borrow_mut();
|
||||
|
||||
@ -742,7 +742,7 @@ impl<'a> fmt::Display for MarkdownWithToc<'a> {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for MarkdownHtml<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let MarkdownHtml(md, ref ids, codes) = *self;
|
||||
let mut ids = ids.borrow_mut();
|
||||
|
||||
@ -772,7 +772,7 @@ impl<'a> fmt::Display for MarkdownHtml<'a> {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for MarkdownSummaryLine<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let MarkdownSummaryLine(md, links) = *self;
|
||||
// This is actually common enough to special-case
|
||||
if md.is_empty() { return Ok(()) }
|
||||
|
@ -55,18 +55,18 @@ use rustc::hir;
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::flock;
|
||||
|
||||
use clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy, Mutability};
|
||||
use config::RenderOptions;
|
||||
use doctree;
|
||||
use fold::DocFolder;
|
||||
use html::escape::Escape;
|
||||
use html::format::{AsyncSpace, ConstnessSpace};
|
||||
use html::format::{GenericBounds, WhereClause, href, AbiSpace};
|
||||
use html::format::{VisSpace, Function, UnsafetySpace, MutableSpace};
|
||||
use html::format::fmt_impl_for_trait_page;
|
||||
use html::item_type::ItemType;
|
||||
use html::markdown::{self, Markdown, MarkdownHtml, MarkdownSummaryLine, ErrorCodes, IdMap};
|
||||
use html::{highlight, layout, static_files};
|
||||
use crate::clean::{self, AttributesExt, Deprecation, GetDefId, SelfTy, Mutability};
|
||||
use crate::config::RenderOptions;
|
||||
use crate::doctree;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::html::escape::Escape;
|
||||
use crate::html::format::{AsyncSpace, ConstnessSpace};
|
||||
use crate::html::format::{GenericBounds, WhereClause, href, AbiSpace};
|
||||
use crate::html::format::{VisSpace, Function, UnsafetySpace, MutableSpace};
|
||||
use crate::html::format::fmt_impl_for_trait_page;
|
||||
use crate::html::item_type::ItemType;
|
||||
use crate::html::markdown::{self, Markdown, MarkdownHtml, MarkdownSummaryLine, ErrorCodes, IdMap};
|
||||
use crate::html::{highlight, layout, static_files};
|
||||
|
||||
use minifier;
|
||||
|
||||
@ -76,7 +76,7 @@ pub type NameDoc = (String, Option<String>);
|
||||
pub struct SlashChecker<'a>(pub &'a str);
|
||||
|
||||
impl<'a> Display for SlashChecker<'a> {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
if !self.0.ends_with("/") && !self.0.is_empty() {
|
||||
write!(f, "{}/", self.0)
|
||||
} else {
|
||||
@ -223,7 +223,7 @@ impl error::Error for Error {
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "\"{}\": {}", self.file.display(), self.error)
|
||||
}
|
||||
}
|
||||
@ -367,7 +367,7 @@ pub struct Cache {
|
||||
#[derive(Default)]
|
||||
pub struct RenderInfo {
|
||||
pub inlined: FxHashSet<DefId>,
|
||||
pub external_paths: ::core::ExternalPaths,
|
||||
pub external_paths: crate::core::ExternalPaths,
|
||||
pub external_typarams: FxHashMap<DefId, String>,
|
||||
pub exact_paths: FxHashMap<DefId, Vec<String>>,
|
||||
pub access_levels: AccessLevels<DefId>,
|
||||
@ -1130,7 +1130,7 @@ themePicker.onblur = handleThemeButtonsBlur;
|
||||
md_opts.output = cx.dst.clone();
|
||||
md_opts.external_html = (*cx.shared).layout.external_html.clone();
|
||||
|
||||
::markdown::render(index_page, md_opts, diag);
|
||||
crate::markdown::render(index_page, md_opts, diag);
|
||||
} else {
|
||||
let dst = cx.dst.join("index.html");
|
||||
let mut w = BufWriter::new(try_err!(File::create(&dst), &dst));
|
||||
@ -1808,7 +1808,7 @@ impl ItemEntry {
|
||||
}
|
||||
|
||||
impl fmt::Display for ItemEntry {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "<a href='{}'>{}</a>", self.url, Escape(&self.name))
|
||||
}
|
||||
}
|
||||
@ -1893,7 +1893,7 @@ impl AllTypes {
|
||||
}
|
||||
}
|
||||
|
||||
fn print_entries(f: &mut fmt::Formatter, e: &FxHashSet<ItemEntry>, title: &str,
|
||||
fn print_entries(f: &mut fmt::Formatter<'_>, e: &FxHashSet<ItemEntry>, title: &str,
|
||||
class: &str) -> fmt::Result {
|
||||
if !e.is_empty() {
|
||||
let mut e: Vec<&ItemEntry> = e.iter().collect();
|
||||
@ -1908,7 +1908,7 @@ fn print_entries(f: &mut fmt::Formatter, e: &FxHashSet<ItemEntry>, title: &str,
|
||||
}
|
||||
|
||||
impl fmt::Display for AllTypes {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f,
|
||||
"<h1 class='fqn'>\
|
||||
<span class='out-of-band'>\
|
||||
@ -1965,7 +1965,7 @@ impl<'a> Settings<'a> {
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for Settings<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f,
|
||||
"<h1 class='fqn'>\
|
||||
<span class='in-band'>Rustdoc settings</span>\
|
||||
@ -2364,16 +2364,16 @@ impl<'a> Item<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn wrap_into_docblock<F>(w: &mut fmt::Formatter,
|
||||
fn wrap_into_docblock<F>(w: &mut fmt::Formatter<'_>,
|
||||
f: F) -> fmt::Result
|
||||
where F: Fn(&mut fmt::Formatter) -> fmt::Result {
|
||||
where F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(w, "<div class=\"docblock type-decl hidden-by-usual-hider\">")?;
|
||||
f(w)?;
|
||||
write!(w, "</div>")
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for Item<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
debug_assert!(!self.item.is_stripped());
|
||||
// Write the breadcrumb trail header for the top
|
||||
write!(fmt, "<h1 class='fqn'><span class='out-of-band'>")?;
|
||||
@ -2516,7 +2516,7 @@ fn plain_summary_line_short(s: Option<&str>) -> String {
|
||||
markdown::plain_summary_line_full(&line[..], true)
|
||||
}
|
||||
|
||||
fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
|
||||
fn document(w: &mut fmt::Formatter<'_>, cx: &Context, item: &clean::Item) -> fmt::Result {
|
||||
if let Some(ref name) = item.name {
|
||||
info!("Documenting {}", name);
|
||||
}
|
||||
@ -2526,7 +2526,7 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
|
||||
}
|
||||
|
||||
/// Render md_text as markdown.
|
||||
fn render_markdown(w: &mut fmt::Formatter,
|
||||
fn render_markdown(w: &mut fmt::Formatter<'_>,
|
||||
cx: &Context,
|
||||
md_text: &str,
|
||||
links: Vec<(String, String)>,
|
||||
@ -2541,7 +2541,7 @@ fn render_markdown(w: &mut fmt::Formatter,
|
||||
cx.codes))
|
||||
}
|
||||
|
||||
fn document_short(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, link: AssocItemLink,
|
||||
fn document_short(w: &mut fmt::Formatter<'_>, cx: &Context, item: &clean::Item, link: AssocItemLink<'_>,
|
||||
prefix: &str, is_hidden: bool) -> fmt::Result {
|
||||
if let Some(s) = item.doc_value() {
|
||||
let markdown = if s.contains('\n') {
|
||||
@ -2559,7 +2559,7 @@ fn document_short(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item, link
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn document_full(w: &mut fmt::Formatter, item: &clean::Item,
|
||||
fn document_full(w: &mut fmt::Formatter<'_>, item: &clean::Item,
|
||||
cx: &Context, prefix: &str, is_hidden: bool) -> fmt::Result {
|
||||
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
|
||||
debug!("Doc block: =====\n{}\n=====", s);
|
||||
@ -2572,7 +2572,7 @@ fn document_full(w: &mut fmt::Formatter, item: &clean::Item,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
|
||||
fn document_stability(w: &mut fmt::Formatter<'_>, cx: &Context, item: &clean::Item,
|
||||
is_hidden: bool) -> fmt::Result {
|
||||
let stabilities = short_stability(item, cx);
|
||||
if !stabilities.is_empty() {
|
||||
@ -2589,7 +2589,7 @@ fn document_non_exhaustive_header(item: &clean::Item) -> &str {
|
||||
if item.is_non_exhaustive() { " (Non-exhaustive)" } else { "" }
|
||||
}
|
||||
|
||||
fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
|
||||
fn document_non_exhaustive(w: &mut fmt::Formatter<'_>, item: &clean::Item) -> fmt::Result {
|
||||
if item.is_non_exhaustive() {
|
||||
write!(w, "<div class='docblock non-exhaustive non-exhaustive-{}'>", {
|
||||
if item.is_struct() { "struct" } else if item.is_enum() { "enum" } else { "type" }
|
||||
@ -2637,7 +2637,7 @@ fn name_key(name: &str) -> (&str, u64, usize) {
|
||||
}
|
||||
}
|
||||
|
||||
fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||
fn item_module(w: &mut fmt::Formatter<'_>, cx: &Context,
|
||||
item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
|
||||
document(w, cx, item)?;
|
||||
|
||||
@ -2741,7 +2741,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||
|
||||
match myitem.inner {
|
||||
clean::ExternCrateItem(ref name, ref src) => {
|
||||
use html::format::HRef;
|
||||
use crate::html::format::HRef;
|
||||
|
||||
match *src {
|
||||
Some(ref src) => {
|
||||
@ -2957,7 +2957,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
|
||||
stability
|
||||
}
|
||||
|
||||
fn item_constant(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_constant(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
c: &clean::Constant) -> fmt::Result {
|
||||
write!(w, "<pre class='rust const'>")?;
|
||||
render_attributes(w, it)?;
|
||||
@ -2969,7 +2969,7 @@ fn item_constant(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
document(w, cx, it)
|
||||
}
|
||||
|
||||
fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_static(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
s: &clean::Static) -> fmt::Result {
|
||||
write!(w, "<pre class='rust static'>")?;
|
||||
render_attributes(w, it)?;
|
||||
@ -2982,7 +2982,7 @@ fn item_static(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
document(w, cx, it)
|
||||
}
|
||||
|
||||
fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_function(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
f: &clean::Function) -> fmt::Result {
|
||||
let header_len = format!(
|
||||
"{}{}{}{}{:#}fn {}{:#}",
|
||||
@ -3016,7 +3016,7 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
document(w, cx, it)
|
||||
}
|
||||
|
||||
fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
||||
fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter<'_>,
|
||||
implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> fmt::Result {
|
||||
// If there's already another implementor that has the same abbridged name, use the
|
||||
// full path, for example in `std::iter::ExactSizeIterator`
|
||||
@ -3033,7 +3033,7 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_impls(cx: &Context, w: &mut fmt::Formatter,
|
||||
fn render_impls(cx: &Context, w: &mut fmt::Formatter<'_>,
|
||||
traits: &[&&Impl],
|
||||
containing_item: &clean::Item) -> fmt::Result {
|
||||
for i in traits {
|
||||
@ -3070,7 +3070,7 @@ fn compare_impl<'a, 'b>(lhs: &'a &&Impl, rhs: &'b &&Impl) -> Ordering {
|
||||
}
|
||||
|
||||
fn item_trait(
|
||||
w: &mut fmt::Formatter,
|
||||
w: &mut fmt::Formatter<'_>,
|
||||
cx: &Context,
|
||||
it: &clean::Item,
|
||||
t: &clean::Trait,
|
||||
@ -3156,7 +3156,7 @@ fn item_trait(
|
||||
document(w, cx, it)?;
|
||||
|
||||
fn write_small_section_header(
|
||||
w: &mut fmt::Formatter,
|
||||
w: &mut fmt::Formatter<'_>,
|
||||
id: &str,
|
||||
title: &str,
|
||||
extra_content: &str,
|
||||
@ -3167,11 +3167,11 @@ fn item_trait(
|
||||
</h2>{2}", id, title, extra_content)
|
||||
}
|
||||
|
||||
fn write_loading_content(w: &mut fmt::Formatter, extra_content: &str) -> fmt::Result {
|
||||
fn write_loading_content(w: &mut fmt::Formatter<'_>, extra_content: &str) -> fmt::Result {
|
||||
write!(w, "{}<span class='loading-content'>Loading content...</span>", extra_content)
|
||||
}
|
||||
|
||||
fn trait_item(w: &mut fmt::Formatter, cx: &Context, m: &clean::Item, t: &clean::Item)
|
||||
fn trait_item(w: &mut fmt::Formatter<'_>, cx: &Context, m: &clean::Item, t: &clean::Item)
|
||||
-> fmt::Result {
|
||||
let name = m.name.as_ref().unwrap();
|
||||
let item_type = m.type_();
|
||||
@ -3328,8 +3328,8 @@ fn item_trait(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn naive_assoc_href(it: &clean::Item, link: AssocItemLink) -> String {
|
||||
use html::item_type::ItemType::*;
|
||||
fn naive_assoc_href(it: &clean::Item, link: AssocItemLink<'_>) -> String {
|
||||
use crate::html::item_type::ItemType::*;
|
||||
|
||||
let name = it.name.as_ref().unwrap();
|
||||
let ty = match it.type_() {
|
||||
@ -3347,11 +3347,11 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn assoc_const(w: &mut fmt::Formatter,
|
||||
fn assoc_const(w: &mut fmt::Formatter<'_>,
|
||||
it: &clean::Item,
|
||||
ty: &clean::Type,
|
||||
_default: Option<&String>,
|
||||
link: AssocItemLink) -> fmt::Result {
|
||||
link: AssocItemLink<'_>) -> fmt::Result {
|
||||
write!(w, "{}const <a href='{}' class=\"constant\"><b>{}</b></a>: {}",
|
||||
VisSpace(&it.visibility),
|
||||
naive_assoc_href(it, link),
|
||||
@ -3363,7 +3363,7 @@ fn assoc_const(w: &mut fmt::Formatter,
|
||||
fn assoc_type<W: fmt::Write>(w: &mut W, it: &clean::Item,
|
||||
bounds: &[clean::GenericBound],
|
||||
default: Option<&clean::Type>,
|
||||
link: AssocItemLink) -> fmt::Result {
|
||||
link: AssocItemLink<'_>) -> fmt::Result {
|
||||
write!(w, "type <a href='{}' class=\"type\">{}</a>",
|
||||
naive_assoc_href(it, link),
|
||||
it.name.as_ref().unwrap())?;
|
||||
@ -3389,22 +3389,22 @@ fn render_stability_since_raw<'a, T: fmt::Write>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_stability_since(w: &mut fmt::Formatter,
|
||||
fn render_stability_since(w: &mut fmt::Formatter<'_>,
|
||||
item: &clean::Item,
|
||||
containing_item: &clean::Item) -> fmt::Result {
|
||||
render_stability_since_raw(w, item.stable_since(), containing_item.stable_since())
|
||||
}
|
||||
|
||||
fn render_assoc_item(w: &mut fmt::Formatter,
|
||||
fn render_assoc_item(w: &mut fmt::Formatter<'_>,
|
||||
item: &clean::Item,
|
||||
link: AssocItemLink,
|
||||
link: AssocItemLink<'_>,
|
||||
parent: ItemType) -> fmt::Result {
|
||||
fn method(w: &mut fmt::Formatter,
|
||||
fn method(w: &mut fmt::Formatter<'_>,
|
||||
meth: &clean::Item,
|
||||
header: hir::FnHeader,
|
||||
g: &clean::Generics,
|
||||
d: &clean::FnDecl,
|
||||
link: AssocItemLink,
|
||||
link: AssocItemLink<'_>,
|
||||
parent: ItemType)
|
||||
-> fmt::Result {
|
||||
let name = meth.name.as_ref().unwrap();
|
||||
@ -3481,7 +3481,7 @@ fn render_assoc_item(w: &mut fmt::Formatter,
|
||||
}
|
||||
}
|
||||
|
||||
fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_struct(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
s: &clean::Struct) -> fmt::Result {
|
||||
wrap_into_docblock(w, |w| {
|
||||
write!(w, "<pre class='rust struct'>")?;
|
||||
@ -3532,7 +3532,7 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
||||
}
|
||||
|
||||
fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_union(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
s: &clean::Union) -> fmt::Result {
|
||||
wrap_into_docblock(w, |w| {
|
||||
write!(w, "<pre class='rust union'>")?;
|
||||
@ -3577,7 +3577,7 @@ fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
||||
}
|
||||
|
||||
fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_enum(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
e: &clean::Enum) -> fmt::Result {
|
||||
wrap_into_docblock(w, |w| {
|
||||
write!(w, "<pre class='rust enum'>")?;
|
||||
@ -3666,7 +3666,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
write!(w, "</code></span>")?;
|
||||
document(w, cx, variant)?;
|
||||
|
||||
use clean::{Variant, VariantKind};
|
||||
use crate::clean::{Variant, VariantKind};
|
||||
if let clean::VariantItem(Variant {
|
||||
kind: VariantKind::Struct(ref s)
|
||||
}) = variant.inner {
|
||||
@ -3678,7 +3678,7 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
write!(w, "<h3>Fields of <b>{name}</b></h3><div>",
|
||||
name = variant.name.as_ref().unwrap())?;
|
||||
for field in &s.fields {
|
||||
use clean::StructFieldItem;
|
||||
use crate::clean::StructFieldItem;
|
||||
if let StructFieldItem(ref ty) = field.inner {
|
||||
let id = cx.derive_id(format!("variant.{}.field.{}",
|
||||
variant.name.as_ref().unwrap(),
|
||||
@ -3741,7 +3741,7 @@ const ATTRIBUTE_WHITELIST: &'static [&'static str] = &[
|
||||
"non_exhaustive"
|
||||
];
|
||||
|
||||
fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
|
||||
fn render_attributes(w: &mut fmt::Formatter<'_>, it: &clean::Item) -> fmt::Result {
|
||||
let mut attrs = String::new();
|
||||
|
||||
for attr in &it.attrs.other_attrs {
|
||||
@ -3759,7 +3759,7 @@ fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
||||
fn render_struct(w: &mut fmt::Formatter<'_>, it: &clean::Item,
|
||||
g: Option<&clean::Generics>,
|
||||
ty: doctree::StructType,
|
||||
fields: &[clean::Item],
|
||||
@ -3835,7 +3835,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_union(w: &mut fmt::Formatter, it: &clean::Item,
|
||||
fn render_union(w: &mut fmt::Formatter<'_>, it: &clean::Item,
|
||||
g: Option<&clean::Generics>,
|
||||
fields: &[clean::Item],
|
||||
tab: &str,
|
||||
@ -3893,11 +3893,11 @@ enum RenderMode {
|
||||
ForDeref { mut_: bool },
|
||||
}
|
||||
|
||||
fn render_assoc_items(w: &mut fmt::Formatter,
|
||||
fn render_assoc_items(w: &mut fmt::Formatter<'_>,
|
||||
cx: &Context,
|
||||
containing_item: &clean::Item,
|
||||
it: DefId,
|
||||
what: AssocItemRender) -> fmt::Result {
|
||||
what: AssocItemRender<'_>) -> fmt::Result {
|
||||
let c = cache();
|
||||
let v = match c.impls.get(&it) {
|
||||
Some(v) => v,
|
||||
@ -3955,7 +3955,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
|
||||
struct RendererStruct<'a, 'b, 'c>(&'a Context, Vec<&'b &'b Impl>, &'c clean::Item);
|
||||
|
||||
impl<'a, 'b, 'c> fmt::Display for RendererStruct<'a, 'b, 'c> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
render_impls(self.0, fmt, &self.1, self.2)
|
||||
}
|
||||
}
|
||||
@ -3996,7 +3996,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_deref_methods(w: &mut fmt::Formatter, cx: &Context, impl_: &Impl,
|
||||
fn render_deref_methods(w: &mut fmt::Formatter<'_>, cx: &Context, impl_: &Impl,
|
||||
container_item: &clean::Item, deref_mut: bool) -> fmt::Result {
|
||||
let deref_type = impl_.inner_impl().trait_.as_ref().unwrap();
|
||||
let target = impl_.inner_impl().items.iter().filter_map(|item| {
|
||||
@ -4107,7 +4107,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLink,
|
||||
fn render_impl(w: &mut fmt::Formatter<'_>, cx: &Context, i: &Impl, link: AssocItemLink<'_>,
|
||||
render_mode: RenderMode, outer_version: Option<&str>,
|
||||
show_def_docs: bool, use_absolute: Option<bool>) -> fmt::Result {
|
||||
if render_mode == RenderMode::Normal {
|
||||
@ -4149,8 +4149,8 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
}
|
||||
}
|
||||
|
||||
fn doc_impl_item(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item,
|
||||
link: AssocItemLink, render_mode: RenderMode,
|
||||
fn doc_impl_item(w: &mut fmt::Formatter<'_>, cx: &Context, item: &clean::Item,
|
||||
link: AssocItemLink<'_>, render_mode: RenderMode,
|
||||
is_default_item: bool, outer_version: Option<&str>,
|
||||
trait_: Option<&clean::Trait>, show_def_docs: bool) -> fmt::Result {
|
||||
let item_type = item.type_();
|
||||
@ -4264,7 +4264,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
false, outer_version, trait_, show_def_docs)?;
|
||||
}
|
||||
|
||||
fn render_default_items(w: &mut fmt::Formatter,
|
||||
fn render_default_items(w: &mut fmt::Formatter<'_>,
|
||||
cx: &Context,
|
||||
t: &clean::Trait,
|
||||
i: &clean::Impl,
|
||||
@ -4297,7 +4297,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
|
||||
}
|
||||
|
||||
fn item_existential(
|
||||
w: &mut fmt::Formatter,
|
||||
w: &mut fmt::Formatter<'_>,
|
||||
cx: &Context,
|
||||
it: &clean::Item,
|
||||
t: &clean::Existential,
|
||||
@ -4319,7 +4319,7 @@ fn item_existential(
|
||||
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
||||
}
|
||||
|
||||
fn item_trait_alias(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_trait_alias(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
t: &clean::TraitAlias) -> fmt::Result {
|
||||
write!(w, "<pre class='rust trait-alias'>")?;
|
||||
render_attributes(w, it)?;
|
||||
@ -4338,7 +4338,7 @@ fn item_trait_alias(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
||||
}
|
||||
|
||||
fn item_typedef(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_typedef(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
t: &clean::Typedef) -> fmt::Result {
|
||||
write!(w, "<pre class='rust typedef'>")?;
|
||||
render_attributes(w, it)?;
|
||||
@ -4357,7 +4357,7 @@ fn item_typedef(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
||||
}
|
||||
|
||||
fn item_foreign_type(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item) -> fmt::Result {
|
||||
fn item_foreign_type(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item) -> fmt::Result {
|
||||
writeln!(w, "<pre class='rust foreigntype'>extern {{")?;
|
||||
render_attributes(w, it)?;
|
||||
write!(
|
||||
@ -4373,7 +4373,7 @@ fn item_foreign_type(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item) ->
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for Sidebar<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let cx = self.cx;
|
||||
let it = self.item;
|
||||
let parentlen = cx.current.len() - if it.is_mod() {1} else {0};
|
||||
@ -4638,7 +4638,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
fn sidebar_struct(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
fn sidebar_struct(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
|
||||
s: &clean::Struct) -> fmt::Result {
|
||||
let mut sidebar = String::new();
|
||||
let fields = get_struct_fields_name(&s.fields);
|
||||
@ -4675,7 +4675,7 @@ fn is_negative_impl(i: &clean::Impl) -> bool {
|
||||
i.polarity == Some(clean::ImplPolarity::Negative)
|
||||
}
|
||||
|
||||
fn sidebar_trait(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
fn sidebar_trait(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
|
||||
t: &clean::Trait) -> fmt::Result {
|
||||
let mut sidebar = String::new();
|
||||
|
||||
@ -4787,7 +4787,7 @@ fn sidebar_trait(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
write!(fmt, "<div class=\"block items\">{}</div>", sidebar)
|
||||
}
|
||||
|
||||
fn sidebar_primitive(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
fn sidebar_primitive(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
|
||||
_p: &clean::PrimitiveType) -> fmt::Result {
|
||||
let sidebar = sidebar_assoc_items(it);
|
||||
|
||||
@ -4797,7 +4797,7 @@ fn sidebar_primitive(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sidebar_typedef(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
fn sidebar_typedef(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
|
||||
_t: &clean::Typedef) -> fmt::Result {
|
||||
let sidebar = sidebar_assoc_items(it);
|
||||
|
||||
@ -4822,7 +4822,7 @@ fn get_struct_fields_name(fields: &[clean::Item]) -> String {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn sidebar_union(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
fn sidebar_union(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
|
||||
u: &clean::Union) -> fmt::Result {
|
||||
let mut sidebar = String::new();
|
||||
let fields = get_struct_fields_name(&u.fields);
|
||||
@ -4840,7 +4840,7 @@ fn sidebar_union(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sidebar_enum(fmt: &mut fmt::Formatter, it: &clean::Item,
|
||||
fn sidebar_enum(fmt: &mut fmt::Formatter<'_>, it: &clean::Item,
|
||||
e: &clean::Enum) -> fmt::Result {
|
||||
let mut sidebar = String::new();
|
||||
|
||||
@ -4895,7 +4895,7 @@ fn item_ty_to_strs(ty: &ItemType) -> (&'static str, &'static str) {
|
||||
}
|
||||
}
|
||||
|
||||
fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item,
|
||||
fn sidebar_module(fmt: &mut fmt::Formatter<'_>, _it: &clean::Item,
|
||||
items: &[clean::Item]) -> fmt::Result {
|
||||
let mut sidebar = String::new();
|
||||
|
||||
@ -4927,7 +4927,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sidebar_foreign_type(fmt: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
|
||||
fn sidebar_foreign_type(fmt: &mut fmt::Formatter<'_>, it: &clean::Item) -> fmt::Result {
|
||||
let sidebar = sidebar_assoc_items(it);
|
||||
if !sidebar.is_empty() {
|
||||
write!(fmt, "<div class=\"block items\">{}</div>", sidebar)?;
|
||||
@ -4936,7 +4936,7 @@ fn sidebar_foreign_type(fmt: &mut fmt::Formatter, it: &clean::Item) -> fmt::Resu
|
||||
}
|
||||
|
||||
impl<'a> fmt::Display for Source<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let Source(s) = *self;
|
||||
let lines = s.lines().count();
|
||||
let mut cols = 0;
|
||||
@ -4956,7 +4956,7 @@ impl<'a> fmt::Display for Source<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn item_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
fn item_macro(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item,
|
||||
t: &clean::Macro) -> fmt::Result {
|
||||
wrap_into_docblock(w, |w| {
|
||||
w.write_str(&highlight::render_with_highlighting(&t.source,
|
||||
@ -4967,7 +4967,7 @@ fn item_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
|
||||
document(w, cx, it)
|
||||
}
|
||||
|
||||
fn item_proc_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, m: &clean::ProcMacro)
|
||||
fn item_proc_macro(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item, m: &clean::ProcMacro)
|
||||
-> fmt::Result
|
||||
{
|
||||
let name = it.name.as_ref().expect("proc-macros always have names");
|
||||
@ -5000,14 +5000,14 @@ fn item_proc_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, m: &c
|
||||
document(w, cx, it)
|
||||
}
|
||||
|
||||
fn item_primitive(w: &mut fmt::Formatter, cx: &Context,
|
||||
fn item_primitive(w: &mut fmt::Formatter<'_>, cx: &Context,
|
||||
it: &clean::Item,
|
||||
_p: &clean::PrimitiveType) -> fmt::Result {
|
||||
document(w, cx, it)?;
|
||||
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
|
||||
}
|
||||
|
||||
fn item_keyword(w: &mut fmt::Formatter, cx: &Context,
|
||||
fn item_keyword(w: &mut fmt::Formatter<'_>, cx: &Context,
|
||||
it: &clean::Item,
|
||||
_p: &str) -> fmt::Result {
|
||||
document(w, cx, it)
|
||||
|
@ -166,13 +166,13 @@ impl TocBuilder {
|
||||
}
|
||||
|
||||
impl fmt::Debug for Toc {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Toc {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(fmt, "<ul>")?;
|
||||
for entry in &self.entries {
|
||||
// recursively format this table of contents (the
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![deny(rust_2018_idioms)]
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
|
||||
html_playground_url = "https://play.rust-lang.org/")]
|
||||
|
||||
@ -17,7 +19,6 @@
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
||||
extern crate arena;
|
||||
extern crate getopts;
|
||||
extern crate env_logger;
|
||||
extern crate rustc;
|
||||
@ -35,10 +36,6 @@ extern crate syntax_pos;
|
||||
extern crate test as testing;
|
||||
#[macro_use] extern crate log;
|
||||
extern crate rustc_errors as errors;
|
||||
extern crate pulldown_cmark;
|
||||
extern crate tempfile;
|
||||
extern crate minifier;
|
||||
extern crate parking_lot;
|
||||
|
||||
extern crate serialize as rustc_serialize; // used by deriving
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use std::default::Default;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
@ -9,13 +8,12 @@ use testing;
|
||||
use syntax::source_map::DUMMY_SP;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
|
||||
use externalfiles::{LoadStringError, load_string};
|
||||
|
||||
use config::{Options, RenderOptions};
|
||||
use html::escape::Escape;
|
||||
use html::markdown;
|
||||
use html::markdown::{ErrorCodes, IdMap, Markdown, MarkdownWithToc, find_testable_code};
|
||||
use test::{TestOptions, Collector};
|
||||
use crate::externalfiles::{LoadStringError, load_string};
|
||||
use crate::config::{Options, RenderOptions};
|
||||
use crate::html::escape::Escape;
|
||||
use crate::html::markdown;
|
||||
use crate::html::markdown::{ErrorCodes, IdMap, Markdown, MarkdownWithToc, find_testable_code};
|
||||
use crate::test::{TestOptions, Collector};
|
||||
|
||||
/// Separate any lines at the start of the file that begin with `# ` or `%`.
|
||||
fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
|
||||
|
@ -4,17 +4,17 @@ use syntax::parse::{ParseSess, token};
|
||||
use syntax::source_map::FilePathMapping;
|
||||
use syntax_pos::FileName;
|
||||
|
||||
use clean;
|
||||
use core::DocContext;
|
||||
use fold::DocFolder;
|
||||
use html::markdown::{self, RustCodeBlock};
|
||||
use passes::Pass;
|
||||
use crate::clean;
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::html::markdown::{self, RustCodeBlock};
|
||||
use crate::passes::Pass;
|
||||
|
||||
pub const CHECK_CODE_BLOCK_SYNTAX: Pass =
|
||||
Pass::early("check-code-block-syntax", check_code_block_syntax,
|
||||
"validates syntax inside Rust code blocks");
|
||||
|
||||
pub fn check_code_block_syntax(krate: clean::Crate, cx: &DocContext) -> clean::Crate {
|
||||
pub fn check_code_block_syntax(krate: clean::Crate, cx: &DocContext<'_, '_, '_>) -> clean::Crate {
|
||||
SyntaxChecker { cx }.fold_crate(krate)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
use clean::{self, DocFragment, Item};
|
||||
use fold;
|
||||
use fold::DocFolder;
|
||||
use passes::Pass;
|
||||
use crate::clean::{self, DocFragment, Item};
|
||||
use crate::fold;
|
||||
use crate::fold::{DocFolder};
|
||||
use crate::passes::Pass;
|
||||
|
||||
use std::mem::replace;
|
||||
|
||||
pub const COLLAPSE_DOCS: Pass =
|
||||
|
@ -10,19 +10,19 @@ use syntax_pos::DUMMY_SP;
|
||||
|
||||
use std::ops::Range;
|
||||
|
||||
use core::DocContext;
|
||||
use fold::DocFolder;
|
||||
use html::markdown::markdown_links;
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::html::markdown::markdown_links;
|
||||
use crate::clean::*;
|
||||
use crate::passes::{look_for_tests, Pass};
|
||||
|
||||
use clean::*;
|
||||
use passes::{look_for_tests, Pass};
|
||||
use super::span_of_attrs;
|
||||
|
||||
pub const COLLECT_INTRA_DOC_LINKS: Pass =
|
||||
Pass::early("collect-intra-doc-links", collect_intra_doc_links,
|
||||
"reads a crate's documentation to resolve intra-doc-links");
|
||||
|
||||
pub fn collect_intra_doc_links(krate: Crate, cx: &DocContext) -> Crate {
|
||||
pub fn collect_intra_doc_links(krate: Crate, cx: &DocContext<'_, '_, '_>) -> Crate {
|
||||
if !UnstableFeatures::from_environment().is_nightly_build() {
|
||||
krate
|
||||
} else {
|
||||
@ -423,7 +423,7 @@ impl<'a, 'tcx, 'rcx> DocFolder for LinkCollector<'a, 'tcx, 'rcx> {
|
||||
}
|
||||
|
||||
/// Resolves a string as a macro.
|
||||
fn macro_resolve(cx: &DocContext, path_str: &str) -> Option<Def> {
|
||||
fn macro_resolve(cx: &DocContext<'_, '_, '_>, path_str: &str) -> Option<Def> {
|
||||
use syntax::ext::base::{MacroKind, SyntaxExtension};
|
||||
let segment = ast::PathSegment::from_ident(Ident::from_str(path_str));
|
||||
let path = ast::Path { segments: vec![segment], span: DUMMY_SP };
|
||||
@ -451,7 +451,7 @@ fn macro_resolve(cx: &DocContext, path_str: &str) -> Option<Def> {
|
||||
/// documentation attributes themselves. This is a little heavy-handed, so we display the markdown
|
||||
/// line containing the failure as a note as well.
|
||||
fn resolution_failure(
|
||||
cx: &DocContext,
|
||||
cx: &DocContext<'_, '_, '_>,
|
||||
attrs: &Attributes,
|
||||
path_str: &str,
|
||||
dox: &str,
|
||||
@ -493,7 +493,7 @@ fn resolution_failure(
|
||||
diag.emit();
|
||||
}
|
||||
|
||||
fn ambiguity_error(cx: &DocContext, attrs: &Attributes,
|
||||
fn ambiguity_error(cx: &DocContext<'_, '_, '_>, attrs: &Attributes,
|
||||
path_str: &str,
|
||||
article1: &str, kind1: &str, disambig1: &str,
|
||||
article2: &str, kind2: &str, disambig2: &str) {
|
||||
@ -549,7 +549,7 @@ fn type_ns_kind(def: Def, path_str: &str) -> (&'static str, &'static str, String
|
||||
}
|
||||
|
||||
/// Given an enum variant's def, return the def of its enum and the associated fragment.
|
||||
fn handle_variant(cx: &DocContext, def: Def) -> Result<(Def, Option<String>), ()> {
|
||||
fn handle_variant(cx: &DocContext<'_, '_, '_>, def: Def) -> Result<(Def, Option<String>), ()> {
|
||||
use rustc::ty::DefIdTree;
|
||||
|
||||
let parent = if let Some(parent) = cx.tcx.parent(def.def_id()) {
|
||||
|
@ -1,17 +1,16 @@
|
||||
use clean::*;
|
||||
use crate::clean::*;
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use super::Pass;
|
||||
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
use rustc::hir::def_id::DefId;
|
||||
|
||||
use super::Pass;
|
||||
use core::DocContext;
|
||||
use fold::DocFolder;
|
||||
|
||||
pub const COLLECT_TRAIT_IMPLS: Pass =
|
||||
Pass::early("collect-trait-impls", collect_trait_impls,
|
||||
"retrieves trait impls for items in the crate");
|
||||
|
||||
pub fn collect_trait_impls(krate: Crate, cx: &DocContext) -> Crate {
|
||||
pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_, '_, '_>) -> Crate {
|
||||
let mut synth = SyntheticImplCollector::new(cx);
|
||||
let mut krate = synth.fold_crate(krate);
|
||||
|
||||
|
@ -11,12 +11,10 @@ use syntax::ast::NodeId;
|
||||
use syntax_pos::{DUMMY_SP, Span};
|
||||
use std::ops::Range;
|
||||
|
||||
use clean::{self, GetDefId, Item};
|
||||
use core::{DocContext, DocAccessLevels};
|
||||
use fold;
|
||||
use fold::StripItem;
|
||||
|
||||
use html::markdown::{find_testable_code, ErrorCodes, LangString};
|
||||
use crate::clean::{self, GetDefId, Item};
|
||||
use crate::core::{DocContext, DocAccessLevels};
|
||||
use crate::fold::{DocFolder, StripItem};
|
||||
use crate::html::markdown::{find_testable_code, ErrorCodes, LangString};
|
||||
|
||||
mod collapse_docs;
|
||||
pub use self::collapse_docs::COLLAPSE_DOCS;
|
||||
@ -55,7 +53,7 @@ pub enum Pass {
|
||||
/// traits and the like.
|
||||
EarlyPass {
|
||||
name: &'static str,
|
||||
pass: fn(clean::Crate, &DocContext) -> clean::Crate,
|
||||
pass: fn(clean::Crate, &DocContext<'_, '_, '_>) -> clean::Crate,
|
||||
description: &'static str,
|
||||
},
|
||||
/// A "late pass" is run between crate cleaning and page generation.
|
||||
@ -67,7 +65,7 @@ pub enum Pass {
|
||||
}
|
||||
|
||||
impl fmt::Debug for Pass {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut dbg = match *self {
|
||||
Pass::EarlyPass { .. } => f.debug_struct("EarlyPass"),
|
||||
Pass::LatePass { .. } => f.debug_struct("LatePass"),
|
||||
@ -83,7 +81,7 @@ impl fmt::Debug for Pass {
|
||||
impl Pass {
|
||||
/// Constructs a new early pass.
|
||||
pub const fn early(name: &'static str,
|
||||
pass: fn(clean::Crate, &DocContext) -> clean::Crate,
|
||||
pass: fn(clean::Crate, &DocContext<'_, '_, '_>) -> clean::Crate,
|
||||
description: &'static str) -> Pass {
|
||||
Pass::EarlyPass { name, pass, description }
|
||||
}
|
||||
@ -112,7 +110,7 @@ impl Pass {
|
||||
}
|
||||
|
||||
/// If this pass is an early pass, returns the pointer to its function.
|
||||
pub fn early_fn(self) -> Option<fn(clean::Crate, &DocContext) -> clean::Crate> {
|
||||
pub fn early_fn(self) -> Option<fn(clean::Crate, &DocContext<'_, '_, '_>) -> clean::Crate> {
|
||||
match self {
|
||||
Pass::EarlyPass { pass, .. } => Some(pass),
|
||||
_ => None,
|
||||
@ -196,7 +194,7 @@ struct Stripper<'a> {
|
||||
update_retained: bool,
|
||||
}
|
||||
|
||||
impl<'a> fold::DocFolder for Stripper<'a> {
|
||||
impl<'a> DocFolder for Stripper<'a> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
match i.inner {
|
||||
clean::StrippedItem(..) => {
|
||||
@ -308,7 +306,7 @@ struct ImplStripper<'a> {
|
||||
retained: &'a DefIdSet,
|
||||
}
|
||||
|
||||
impl<'a> fold::DocFolder for ImplStripper<'a> {
|
||||
impl<'a> DocFolder for ImplStripper<'a> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
if let clean::ImplItem(ref imp) = i.inner {
|
||||
// emptied none trait impls can be stripped
|
||||
@ -345,7 +343,7 @@ impl<'a> fold::DocFolder for ImplStripper<'a> {
|
||||
|
||||
// This stripper discards all private import statements (`use`, `extern crate`)
|
||||
struct ImportStripper;
|
||||
impl fold::DocFolder for ImportStripper {
|
||||
impl DocFolder for ImportStripper {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
match i.inner {
|
||||
clean::ExternCrateItem(..) | clean::ImportItem(..)
|
||||
@ -373,7 +371,7 @@ pub fn look_for_tests<'a, 'tcx: 'a, 'rcx: 'a>(
|
||||
found_tests: usize,
|
||||
}
|
||||
|
||||
impl ::test::Tester for Tests {
|
||||
impl crate::test::Tester for Tests {
|
||||
fn add_test(&mut self, _: String, _: LangString, _: usize) {
|
||||
self.found_tests += 1;
|
||||
}
|
||||
@ -420,7 +418,7 @@ crate fn span_of_attrs(attrs: &clean::Attributes) -> Span {
|
||||
/// attributes are not all sugared doc comments. It's difficult to calculate the correct span in
|
||||
/// that case due to escaping and other source features.
|
||||
crate fn source_span_for_markdown_range(
|
||||
cx: &DocContext,
|
||||
cx: &DocContext<'_, '_, '_>,
|
||||
markdown: &str,
|
||||
md_range: &Range<usize>,
|
||||
attrs: &clean::Attributes,
|
||||
|
@ -1,9 +1,8 @@
|
||||
use clean::*;
|
||||
use crate::clean::*;
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::passes::{look_for_tests, Pass};
|
||||
|
||||
use core::DocContext;
|
||||
use fold::DocFolder;
|
||||
|
||||
use passes::{look_for_tests, Pass};
|
||||
|
||||
pub const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass =
|
||||
Pass::early("check-private-items-doc-tests", check_private_items_doc_tests,
|
||||
@ -21,7 +20,7 @@ impl<'a, 'tcx, 'rcx> PrivateItemDocTestLinter<'a, 'tcx, 'rcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_private_items_doc_tests(krate: Crate, cx: &DocContext) -> Crate {
|
||||
pub fn check_private_items_doc_tests(krate: Crate, cx: &DocContext<'_, '_, '_>) -> Crate {
|
||||
let mut coll = PrivateItemDocTestLinter::new(cx);
|
||||
|
||||
coll.fold_crate(krate)
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use clean::{Crate, Item};
|
||||
use clean::cfg::Cfg;
|
||||
use fold::DocFolder;
|
||||
use passes::Pass;
|
||||
use crate::clean::{Crate, Item};
|
||||
use crate::clean::cfg::Cfg;
|
||||
use crate::fold::DocFolder;
|
||||
use crate::passes::Pass;
|
||||
|
||||
pub const PROPAGATE_DOC_CFG: Pass =
|
||||
Pass::late("propagate-doc-cfg", propagate_doc_cfg,
|
||||
|
@ -1,20 +1,18 @@
|
||||
use rustc::util::nodemap::DefIdSet;
|
||||
use std::mem;
|
||||
|
||||
use clean::{self, AttributesExt, NestedAttributesExt};
|
||||
use clean::Item;
|
||||
use core::DocContext;
|
||||
use fold;
|
||||
use fold::DocFolder;
|
||||
use fold::StripItem;
|
||||
use passes::{ImplStripper, Pass};
|
||||
use crate::clean::{self, AttributesExt, NestedAttributesExt};
|
||||
use crate::clean::Item;
|
||||
use crate::core::DocContext;
|
||||
use crate::fold::{DocFolder, StripItem};
|
||||
use crate::passes::{ImplStripper, Pass};
|
||||
|
||||
pub const STRIP_HIDDEN: Pass =
|
||||
Pass::early("strip-hidden", strip_hidden,
|
||||
"strips all doc(hidden) items from the output");
|
||||
|
||||
/// Strip items marked `#[doc(hidden)]`
|
||||
pub fn strip_hidden(krate: clean::Crate, _: &DocContext) -> clean::Crate {
|
||||
pub fn strip_hidden(krate: clean::Crate, _: &DocContext<'_, '_, '_>) -> clean::Crate {
|
||||
let mut retained = DefIdSet::default();
|
||||
|
||||
// strip all #[doc(hidden)] items
|
||||
@ -35,7 +33,7 @@ struct Stripper<'a> {
|
||||
update_retained: bool,
|
||||
}
|
||||
|
||||
impl<'a> fold::DocFolder for Stripper<'a> {
|
||||
impl<'a> DocFolder for Stripper<'a> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
if i.attrs.lists("doc").has_word("hidden") {
|
||||
debug!("strip_hidden: stripping {} {:?}", i.type_(), i.name);
|
||||
|
@ -1,11 +1,11 @@
|
||||
use clean;
|
||||
use core::DocContext;
|
||||
use fold::DocFolder;
|
||||
use passes::{ImportStripper, Pass};
|
||||
use crate::clean;
|
||||
use crate::fold::{DocFolder};
|
||||
use crate::core::DocContext;
|
||||
use crate::passes::{ImportStripper, Pass};
|
||||
|
||||
pub const STRIP_PRIV_IMPORTS: Pass = Pass::early("strip-priv-imports", strip_priv_imports,
|
||||
"strips all private import statements (`use`, `extern crate`) from a crate");
|
||||
|
||||
pub fn strip_priv_imports(krate: clean::Crate, _: &DocContext) -> clean::Crate {
|
||||
pub fn strip_priv_imports(krate: clean::Crate, _: &DocContext<'_, '_, '_>) -> clean::Crate {
|
||||
ImportStripper.fold_crate(krate)
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use rustc::util::nodemap::DefIdSet;
|
||||
|
||||
use clean;
|
||||
use core::DocContext;
|
||||
use fold::DocFolder;
|
||||
use passes::{ImplStripper, ImportStripper, Stripper, Pass};
|
||||
use crate::clean;
|
||||
use crate::fold::{DocFolder};
|
||||
use crate::core::DocContext;
|
||||
use crate::passes::{ImplStripper, ImportStripper, Stripper, Pass};
|
||||
|
||||
pub const STRIP_PRIVATE: Pass =
|
||||
Pass::early("strip-private", strip_private,
|
||||
@ -12,7 +12,7 @@ pub const STRIP_PRIVATE: Pass =
|
||||
|
||||
/// Strip private items from the point of view of a crate or externally from a
|
||||
/// crate, specified by the `xcrate` flag.
|
||||
pub fn strip_private(mut krate: clean::Crate, cx: &DocContext) -> clean::Crate {
|
||||
pub fn strip_private(mut krate: clean::Crate, cx: &DocContext<'_, '_, '_>) -> clean::Crate {
|
||||
// This stripper collects all *retained* nodes.
|
||||
let mut retained = DefIdSet::default();
|
||||
let access_levels = cx.renderinfo.borrow().access_levels.clone();
|
||||
|
@ -2,9 +2,9 @@ use std::cmp;
|
||||
use std::string::String;
|
||||
use std::usize;
|
||||
|
||||
use clean::{self, DocFragment, Item};
|
||||
use fold::{self, DocFolder};
|
||||
use passes::Pass;
|
||||
use crate::clean::{self, DocFragment, Item};
|
||||
use crate::fold::{self, DocFolder};
|
||||
use crate::passes::Pass;
|
||||
|
||||
pub const UNINDENT_COMMENTS: Pass =
|
||||
Pass::late("unindent-comments", unindent_comments,
|
||||
|
@ -28,9 +28,9 @@ use std::process::Command;
|
||||
use std::str;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use clean::Attributes;
|
||||
use config::Options;
|
||||
use html::markdown::{self, ErrorCodes, LangString};
|
||||
use crate::clean::Attributes;
|
||||
use crate::config::Options;
|
||||
use crate::html::markdown::{self, ErrorCodes, LangString};
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct TestOptions {
|
||||
|
@ -14,9 +14,10 @@ use syntax_pos::{self, Span};
|
||||
|
||||
use std::mem;
|
||||
|
||||
use core;
|
||||
use clean::{self, AttributesExt, NestedAttributesExt, def_id_to_path};
|
||||
use doctree::*;
|
||||
use crate::core;
|
||||
use crate::clean::{self, AttributesExt, NestedAttributesExt, def_id_to_path};
|
||||
use crate::doctree::*;
|
||||
|
||||
|
||||
// Looks to me like the first two of these are actually
|
||||
// output parameters, maybe only mutated once; perhaps
|
||||
@ -268,7 +269,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
|
||||
om: &mut Module,
|
||||
please_inline: bool) -> bool {
|
||||
|
||||
fn inherits_doc_hidden(cx: &core::DocContext, mut node: ast::NodeId) -> bool {
|
||||
fn inherits_doc_hidden(cx: &core::DocContext<'_, '_, '_>, mut node: ast::NodeId) -> bool {
|
||||
while let Some(id) = cx.tcx.hir().get_enclosing_scope(node) {
|
||||
node = id;
|
||||
if cx.tcx.hir().attrs(node).lists("doc").has_word("hidden") {
|
||||
@ -315,7 +316,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
|
||||
.insert(did, AccessLevel::Public);
|
||||
},
|
||||
Def::Mod(did) => if !self_is_hidden {
|
||||
::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did);
|
||||
crate::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ use rustc::util::nodemap::FxHashSet;
|
||||
|
||||
use std::cell::RefMut;
|
||||
|
||||
use clean::{AttributesExt, NestedAttributesExt};
|
||||
use crate::clean::{AttributesExt, NestedAttributesExt};
|
||||
|
||||
// FIXME: this may not be exhaustive, but is sufficient for rustdocs current uses
|
||||
|
||||
/// Similar to `librustc_privacy::EmbargoVisitor`, but also takes
|
||||
/// specific rustdoc annotations into account (i.e., `doc(hidden)`)
|
||||
pub struct LibEmbargoVisitor<'a, 'tcx: 'a, 'rcx: 'a> {
|
||||
cx: &'a ::core::DocContext<'a, 'tcx, 'rcx>,
|
||||
cx: &'a crate::core::DocContext<'a, 'tcx, 'rcx>,
|
||||
// Accessibility levels for reachable nodes
|
||||
access_levels: RefMut<'a, AccessLevels<DefId>>,
|
||||
// Previous accessibility level, None means unreachable
|
||||
@ -24,7 +24,7 @@ pub struct LibEmbargoVisitor<'a, 'tcx: 'a, 'rcx: 'a> {
|
||||
|
||||
impl<'a, 'tcx, 'rcx> LibEmbargoVisitor<'a, 'tcx, 'rcx> {
|
||||
pub fn new(
|
||||
cx: &'a ::core::DocContext<'a, 'tcx, 'rcx>
|
||||
cx: &'a crate::core::DocContext<'a, 'tcx, 'rcx>
|
||||
) -> LibEmbargoVisitor<'a, 'tcx, 'rcx> {
|
||||
LibEmbargoVisitor {
|
||||
cx,
|
||||
|
Loading…
Reference in New Issue
Block a user