don't try to get a DefId for a Def that doesn't have one
This commit is contained in:
parent
1aa250635e
commit
c955f172b2
4 changed files with 18 additions and 6 deletions
|
@ -37,8 +37,11 @@ use super::Clean;
|
||||||
/// and `Some` of a vector of items if it was successfully expanded.
|
/// 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>> {
|
-> Option<Vec<clean::Item>> {
|
||||||
if def == Def::Err { return None }
|
let did = if let Some(did) = def.opt_def_id() {
|
||||||
let did = def.def_id();
|
did
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
if did.is_local() { return None }
|
if did.is_local() { return None }
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
let inner = match def {
|
let inner = match def {
|
||||||
|
|
|
@ -3818,7 +3818,7 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId {
|
||||||
|
|
||||||
fn resolve_use_source(cx: &DocContext, path: Path) -> ImportSource {
|
fn resolve_use_source(cx: &DocContext, path: Path) -> ImportSource {
|
||||||
ImportSource {
|
ImportSource {
|
||||||
did: if path.def == Def::Err {
|
did: if path.def.opt_def_id().is_none() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(register_def(cx, path.def))
|
Some(register_def(cx, path.def))
|
||||||
|
|
|
@ -284,10 +284,11 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
|
||||||
debug!("maybe_inline_local def: {:?}", def);
|
debug!("maybe_inline_local def: {:?}", def);
|
||||||
|
|
||||||
let tcx = self.cx.tcx;
|
let tcx = self.cx.tcx;
|
||||||
if def == Def::Err {
|
let def_did = if let Some(did) = def.opt_def_id() {
|
||||||
|
did
|
||||||
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
let def_did = def.def_id();
|
|
||||||
|
|
||||||
let use_attrs = tcx.hir().attrs(id);
|
let use_attrs = tcx.hir().attrs(id);
|
||||||
// Don't inline `doc(hidden)` imports so they can be stripped at a later stage.
|
// Don't inline `doc(hidden)` imports so they can be stripped at a later stage.
|
||||||
|
|
8
src/test/rustdoc/use-attr.rs
Normal file
8
src/test/rustdoc/use-attr.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// edition:2018
|
||||||
|
|
||||||
|
// ICE when rustdoc encountered a use statement of a non-macro attribute (see #58054)
|
||||||
|
|
||||||
|
// @has use_attr/index.html
|
||||||
|
// @has - '//code' 'pub use proc_macro_attribute'
|
||||||
|
pub use proc_macro_attribute;
|
||||||
|
use proc_macro_derive;
|
Loading…
Add table
Add a link
Reference in a new issue