use rustc::hir;
use rustc::hir::def::{CtorKind, DefKind, Res};
use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
+use rustc::hir::ptr::P;
use rustc::ty::subst::{InternalSubsts, SubstsRef, UnpackedKind};
use rustc::ty::{self, DefIdTree, TyCtxt, Region, RegionVid, Ty, AdtKind};
use rustc::ty::fold::TypeFolder;
use syntax::attr;
use syntax::ext::base::MacroKind;
use syntax::source_map::{dummy_spanned, Spanned};
-use syntax::ptr::P;
use syntax::symbol::{Symbol, kw, sym};
use syntax::symbol::InternedString;
use syntax_pos::{self, Pos, FileName};
hir::ItemKind::Mod(_) => {
as_primitive(Res::Def(
DefKind::Mod,
- cx.tcx.hir().local_def_id_from_hir_id(id.id),
+ cx.tcx.hir().local_def_id(id.id),
))
}
hir::ItemKind::Use(ref path, hir::UseKind::Single)
if item.vis.node.is_pub() => {
as_primitive(path.res).map(|(_, prim, attrs)| {
// Pretend the primitive is local.
- (cx.tcx.hir().local_def_id_from_hir_id(id.id), prim, attrs)
+ (cx.tcx.hir().local_def_id(id.id), prim, attrs)
})
}
_ => None
hir::ItemKind::Mod(_) => {
as_keyword(Res::Def(
DefKind::Mod,
- cx.tcx.hir().local_def_id_from_hir_id(id.id),
+ cx.tcx.hir().local_def_id(id.id),
))
}
hir::ItemKind::Use(ref path, hir::UseKind::Single)
if item.vis.node.is_pub() => {
as_keyword(path.res).map(|(_, prim, attrs)| {
- (cx.tcx.hir().local_def_id_from_hir_id(id.id), prim, attrs)
+ (cx.tcx.hir().local_def_id(id.id), prim, attrs)
})
}
_ => None
impl Item {
/// Finds the `doc` attribute as a NameValue and returns the corresponding
/// value found.
- pub fn doc_value<'a>(&'a self) -> Option<&'a str> {
+ pub fn doc_value(&self) -> Option<&str> {
self.attrs.doc_value()
}
/// Finds all `doc` attributes as NameValues and returns their corresponding values, joined
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
- def_id: cx.tcx.hir().local_def_id(self.id),
+ def_id: cx.tcx.hir().local_def_id_from_node_id(self.id),
inner: ModuleItem(Module {
is_crate: self.is_crate,
items,
pub trait AttributesExt {
/// Finds an attribute as List and returns the list of attributes nested inside.
- fn lists<'a>(&'a self, name: Symbol) -> ListAttributesIter<'a>;
+ fn lists(&self, name: Symbol) -> ListAttributesIter<'_>;
}
impl AttributesExt for [ast::Attribute] {
- fn lists<'a>(&'a self, name: Symbol) -> ListAttributesIter<'a> {
+ fn lists(&self, name: Symbol) -> ListAttributesIter<'_> {
ListAttributesIter {
attrs: self.iter(),
current_list: Vec::new().into_iter(),
/// Finds the `doc` attribute as a NameValue and returns the corresponding
/// value found.
- pub fn doc_value<'a>(&'a self) -> Option<&'a str> {
+ pub fn doc_value(&self) -> Option<&str> {
self.doc_strings.first().map(|s| s.as_str())
}
}
impl AttributesExt for Attributes {
- fn lists<'a>(&'a self, name: Symbol) -> ListAttributesIter<'a> {
+ fn lists(&self, name: Symbol) -> ListAttributesIter<'_> {
self.other_attrs.lists(name)
}
}
}
hir::GenericParamKind::Type { ref default, synthetic } => {
(self.name.ident().name.clean(cx), GenericParamDefKind::Type {
- did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
+ did: cx.tcx.hir().local_def_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_from_hir_id(self.hir_id),
+ did: cx.tcx.hir().local_def_id(self.hir_id),
ty: ty.clean(cx),
})
}
(self.generics.clean(cx), (self.decl, self.body).clean(cx))
});
- let did = cx.tcx.hir().local_def_id_from_hir_id(self.id);
+ let did = cx.tcx.hir().local_def_id(self.id);
let constness = if cx.tcx.is_min_const_fn(did) {
hir::Constness::Const
} else {
name: Some(self.name.clean(cx)),
attrs: attrs,
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
name: Some(self.name.clean(cx)),
attrs,
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
AssocTypeItem(bounds.clean(cx), default.clean(cx))
}
};
- let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
+ let local_did = cx.tcx.hir().local_def_id(self.hir_id);
Item {
name: Some(self.ident.name.clean(cx)),
attrs: self.attrs.clean(cx),
generics: Generics::default(),
}, true),
};
- let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
+ let local_did = cx.tcx.hir().local_def_id(self.hir_id);
Item {
name: Some(self.ident.name.clean(cx)),
source: self.span.clean(cx),
}
TyKind::Slice(ref ty) => Slice(box ty.clean(cx)),
TyKind::Array(ref ty, ref length) => {
- let def_id = cx.tcx.hir().local_def_id_from_hir_id(length.hir_id);
+ let def_id = cx.tcx.hir().local_def_id(length.hir_id);
let param_env = cx.tcx.param_env(def_id);
let substs = InternalSubsts::identity_for_item(cx.tcx, def_id);
let cid = GlobalId {
if let Some(lt) = lifetime.cloned() {
if !lt.is_elided() {
let lt_def_id =
- cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
+ cx.tcx.hir().local_def_id(param.hir_id);
lt_substs.insert(lt_def_id, lt.clean(cx));
}
}
}
hir::GenericParamKind::Type { ref default, .. } => {
let ty_param_def_id =
- cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
+ cx.tcx.hir().local_def_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_id =
- cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
+ cx.tcx.hir().local_def_id(param.hir_id);
let mut j = 0;
let const_ = generic_args.args.iter().find_map(|arg| {
match arg {
ty::FnPtr(_) => {
let ty = cx.tcx.lift(self).expect("FnPtr lift failed");
let sig = ty.fn_sig(cx.tcx);
+ let local_def_id = cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID);
BareFunction(box BareFunctionDecl {
unsafety: sig.unsafety(),
generic_params: Vec::new(),
- decl: (cx.tcx.hir().local_def_id(ast::CRATE_NODE_ID), sig).clean(cx),
+ decl: (local_def_id, sig).clean(cx),
abi: sig.abi(),
})
}
impl Clean<Item> for hir::StructField {
fn clean(&self, cx: &DocContext<'_>) -> Item {
- let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
+ let local_did = cx.tcx.hir().local_def_id(self.hir_id);
Item {
name: Some(self.ident.name).clean(cx),
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
visibility: None,
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
inner: VariantItem(Variant {
kind: self.def.clean(cx),
}),
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
name: None,
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
name: None,
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id(ast::CRATE_NODE_ID),
+ def_id: cx.tcx.hir().local_def_id_from_node_id(ast::CRATE_NODE_ID),
visibility: self.vis.clean(cx),
stability: None,
deprecation: None,
name: Some(self.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.whence.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
visibility: self.vis.clean(cx),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
MacroKind::Bang => (i, TypeKind::Macro),
MacroKind::Attr => (i, TypeKind::Attr),
MacroKind::Derive => (i, TypeKind::Derive),
- MacroKind::ProcMacroStub => unreachable!(),
},
Res::Def(DefKind::TraitAlias, i) => (i, TypeKind::TraitAlias),
Res::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait),
visibility: Some(Public),
stability: self.stab.clean(cx),
deprecation: self.depr.clean(cx),
- def_id: cx.tcx.hir().local_def_id_from_hir_id(self.id),
+ def_id: cx.tcx.hir().local_def_id(self.id),
inner: ProcMacroItem(ProcMacro {
kind: self.kind,
helpers: self.helpers.clean(cx),
where
F: FnOnce() -> R,
{
- let old_bounds = mem::replace(&mut *cx.impl_trait_bounds.borrow_mut(), Default::default());
+ let old_bounds = mem::take(&mut *cx.impl_trait_bounds.borrow_mut());
let r = f();
assert!(cx.impl_trait_bounds.borrow().is_empty());
*cx.impl_trait_bounds.borrow_mut() = old_bounds;