use rustc::hir::{self, GenericArg, HirVec};
use rustc::hir::def::{self, Def, CtorKind};
use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind};
use rustc::ty::fold::TypeFolder;
use rustc::ty::layout::VariantIdx;
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;
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()
}
}
}
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();
}
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);
}
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));
}
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 {
///
/// 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) => {
"https://doc.rust-lang.org/nightly",
};
// This is a primitive so the url is done "by hand".
+ let tail = fragment.find('#').unwrap_or_else(|| fragment.len());
Some((s.clone(),
- format!("{}{}std/primitive.{}.html",
+ format!("{}{}std/primitive.{}.html{}",
url,
if !url.ends_with('/') { "/" } else { "" },
- fragment)))
+ &fragment[..tail],
+ &fragment[tail..])))
} else {
panic!("This isn't a primitive?!");
}
}
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)
}
}
}
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(),
}, 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() {
}
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) => {
}
}
-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: SubstsRef<'_>) -> GenericArgs {
let lifetimes = substs.regions().filter_map(|v| v.clean(cx)).collect();
let types = substs.types().skip(has_self as usize).collect::<Vec<_>>();
// 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: SubstsRef<'_>) -> Path {
Path {
global: false,
def: Def::Err,
}
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(),
}
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>> {
+impl<'tcx> Clean<Option<Vec<GenericBound>>> for InternalSubsts<'tcx> {
+ 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 {
}
impl Clean<Lifetime> for hir::Lifetime {
- fn clean(&self, cx: &DocContext) -> Lifetime {
- if self.id != ast::DUMMY_NODE_ID {
+ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Lifetime {
+ if self.hir_id != hir::DUMMY_HIR_ID {
let def = cx.tcx.named_region(self.hir_id);
match def {
Some(rl::Region::EarlyBound(_, node_id, _)) |
}
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 {
}
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),
}
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())),
}
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 {
}
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 {
}
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)]
}
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")
}
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) {
}
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 {
}
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)
}
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"),
}
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)
}
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 {
}
hir::GenericParamKind::Type { ref default, synthetic } => {
(self.name.ident().name.clean(cx), GenericParamDefKind::Type {
- did: cx.tcx.hir().local_def_id(self.id),
+ did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
bounds: self.bounds.clean(cx),
default: default.clean(cx),
synthetic: synthetic,
}
hir::GenericParamKind::Const { ref ty } => {
(self.name.ident().name.clean(cx), GenericParamDefKind::Const {
- did: cx.tcx.hir().local_def_id(self.id),
+ did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
ty: ty.clean(cx),
})
}
}
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.
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;
}
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))
});
}
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))
});
pub struct FnDecl {
pub inputs: Arguments,
pub output: FunctionRetTy,
- pub variadic: bool,
pub attrs: Attributes,
}
}
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())
}
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 {
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),
- variadic: self.0.variadic,
attrs: Attributes::default()
}
}
}
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()
FnDecl {
output: Return(sig.skip_binder().output().clean(cx)),
attrs: Attributes::default(),
- variadic: sig.skip_binder().variadic,
inputs: Arguments {
values: sig.skip_binder().inputs().iter().map(|t| {
Argument {
}
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,
}
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 {
}
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)),
}
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,
}
impl Clean<Type> for hir::TraitRef {
- fn clean(&self, cx: &DocContext) -> Type {
- resolve_type(cx, self.path.clean(cx), self.ref_id)
+ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
+ resolve_type(cx, self.path.clean(cx), self.hir_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)
}
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),
}
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),
}
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);
Slice(Box<Type>),
Array(Box<Type>, String),
Never,
+ CVarArgs,
Unique(Box<Type>),
RawPointer(Mutability, Box<Type>),
BorrowedRef {
Reference,
Fn,
Never,
+ CVarArgs,
}
#[derive(Clone, RustcEncodable, RustcDecodable, Copy, Debug)]
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(),
Reference => "reference",
Fn => "fn",
Never => "never",
+ CVarArgs => "...",
}
}
}
impl Clean<Type> for hir::Ty {
- fn clean(&self, cx: &DocContext) -> Type {
+ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
use rustc::hir::*;
match self.node {
TyKind::Never => Never,
+ TyKind::CVarArgs(_) => CVarArgs,
TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)),
TyKind::Rptr(ref l, ref m) => {
let lifetime = if l.is_elided() {
TyKind::Array(ref ty, ref length) => {
let def_id = cx.tcx.hir().local_def_id(length.id);
let param_env = cx.tcx.param_env(def_id);
- let substs = Substs::identity_for_item(cx.tcx, def_id);
+ let substs = InternalSubsts::identity_for_item(cx.tcx, def_id);
let cid = GlobalId {
instance: ty::Instance::new(def_id, substs),
promoted: None
let mut alias = None;
if let Def::TyAlias(def_id) = path.def {
// Substitute private type aliases
- if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) {
+ if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
if !cx.renderinfo.borrow().access_levels.is_exported(def_id) {
- alias = Some(&cx.tcx.hir().expect_item(node_id).node);
+ alias = Some(&cx.tcx.hir().expect_item_by_hir_id(hir_id).node);
}
}
};
if let Some(lt) = lifetime.cloned() {
if !lt.is_elided() {
let lt_def_id =
- cx.tcx.hir().local_def_id(param.id);
+ cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
lt_substs.insert(lt_def_id, lt.clean(cx));
}
}
}
hir::GenericParamKind::Type { ref default, .. } => {
let ty_param_def =
- Def::TyParam(cx.tcx.hir().local_def_id(param.id));
+ Def::TyParam(
+ cx.tcx.hir().local_def_id_from_hir_id(param.hir_id));
let mut j = 0;
let type_ = generic_args.args.iter().find_map(|arg| {
match arg {
}
hir::GenericParamKind::Const { .. } => {
let const_param_def =
- Def::ConstParam(cx.tcx.hir().local_def_id(param.id));
+ Def::ConstParam(
+ cx.tcx.hir().local_def_id_from_hir_id(param.hir_id));
let mut j = 0;
let const_ = generic_args.args.iter().find_map(|arg| {
match arg {
});
return cx.enter_alias(ty_substs, lt_substs, const_substs, || ty.clean(cx));
}
- resolve_type(cx, path.clean(cx), self.id)
+ resolve_type(cx, path.clean(cx), self.hir_id)
}
TyKind::Path(hir::QPath::Resolved(Some(ref qself), ref p)) => {
let mut segments: Vec<_> = p.segments.clone().into();
Type::QPath {
name: p.segments.last().expect("segments were empty").ident.name.clean(cx),
self_type: box qself.clean(cx),
- trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
+ trait_: box resolve_type(cx, trait_path.clean(cx), self.hir_id)
}
}
TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => {
Type::QPath {
name: segment.ident.name.clean(cx),
self_type: box qself.clean(cx),
- trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
+ trait_: box resolve_type(cx, trait_path.clean(cx), self.hir_id)
}
}
TyKind::TraitObject(ref bounds, ref lifetime) => {
}
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),
ty::Foreign(did) => {
inline::record_extern_fqn(cx, did, TypeKind::Foreign);
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
- None, false, vec![], Substs::empty());
+ None, false, vec![], InternalSubsts::empty());
ResolvedPath {
path: path,
typarams: None,
}
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),
}
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),
}
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,
}
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 })
}
}
}
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),
}
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),
}
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(),
}
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),
}
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),
}
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 => {
}
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() {
}
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();
}
}
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,
}
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 {
}
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))
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()
}
}
}
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),
}
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),
}
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))
});
}
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)),
}
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),
}
impl Clean<Mutability> for hir::Mutability {
- fn clean(&self, _: &DocContext) -> Mutability {
+ fn clean(&self, _: &DocContext<'_, '_, '_>) -> Mutability {
match self {
&hir::MutMutable => Mutable,
&hir::MutImmutable => Immutable,
}
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,
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);
}
}
-fn build_deref_target_impls(cx: &DocContext,
+fn build_deref_target_impls(cx: &DocContext<'_, '_, '_>,
items: &[Item],
ret: &mut Vec<Item>) {
use self::PrimitiveType::*;
Reference => None,
Fn => None,
Never => None,
+ CVarArgs => tcx.lang_items().va_list(),
};
if let Some(did) = did {
if !did.is_local() {
}
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() {
}
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.
}
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 {
}
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, || {
// 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,
}
}
-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) {
}
}
-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 {
+ id: hir::HirId) -> Type {
+ if id == hir::DUMMY_HIR_ID {
debug!("resolve_type({:?})", path);
} else {
debug!("resolve_type({:?},{:?})", path, id);
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 {
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
}
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()),
}
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),
}
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()),
}
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()),
}
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)
}
}
-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
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,
{
// 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();
}
}
-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
}
}
-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 {