Skip to content

Commit 19c85a8

Browse files
Move def_id_to_path to use site in visit_ast
1 parent 65ea7b7 commit 19c85a8

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::fmt;
3939
use std::hash::{Hash, Hasher};
4040
use std::default::Default;
4141
use std::{mem, slice, vec};
42-
use std::iter::{FromIterator, once};
42+
use std::iter::FromIterator;
4343
use std::rc::Rc;
4444
use std::cell::RefCell;
4545
use std::sync::Arc;
@@ -4398,24 +4398,6 @@ impl Clean<TypeBindingKind> for hir::TypeBindingKind {
43984398
}
43994399
}
44004400

4401-
pub fn def_id_to_path(
4402-
cx: &DocContext<'_>,
4403-
did: DefId,
4404-
name: Option<String>
4405-
) -> Vec<String> {
4406-
let crate_name = name.unwrap_or_else(|| cx.tcx.crate_name(did.krate).to_string());
4407-
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
4408-
// extern blocks have an empty name
4409-
let s = elem.data.to_string();
4410-
if !s.is_empty() {
4411-
Some(s)
4412-
} else {
4413-
None
4414-
}
4415-
});
4416-
once(crate_name).chain(relative).collect()
4417-
}
4418-
44194401
pub fn enter_impl_trait<F, R>(cx: &DocContext<'_>, f: F) -> R
44204402
where
44214403
F: FnOnce() -> R,

src/librustdoc/visit_ast.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,26 @@ use syntax_pos::{self, Span};
1515
use std::mem;
1616

1717
use crate::core;
18-
use crate::clean::{self, AttributesExt, NestedAttributesExt, def_id_to_path};
18+
use crate::clean::{self, AttributesExt, NestedAttributesExt};
1919
use crate::doctree::*;
2020

21+
fn def_id_to_path(
22+
cx: &core::DocContext<'_>,
23+
did: DefId,
24+
name: Option<String>
25+
) -> Vec<String> {
26+
let crate_name = name.unwrap_or_else(|| cx.tcx.crate_name(did.krate).to_string());
27+
let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
28+
// extern blocks have an empty name
29+
let s = elem.data.to_string();
30+
if !s.is_empty() {
31+
Some(s)
32+
} else {
33+
None
34+
}
35+
});
36+
std::iter::once(crate_name).chain(relative).collect()
37+
}
2138

2239
// Also, is there some reason that this doesn't use the 'visit'
2340
// framework from syntax?.

0 commit comments

Comments
 (0)