1
Fork 0

Continue String to Symbol conversion in rustdoc

This commit is contained in:
Guillaume Gomez 2020-12-18 12:05:51 +01:00
parent fee693d08e
commit 57266f1df6
6 changed files with 11 additions and 8 deletions

View file

@ -103,7 +103,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
.cx .cx
.tcx .tcx
.provided_trait_methods(trait_def_id) .provided_trait_methods(trait_def_id)
.map(|meth| meth.ident.to_string()) .map(|meth| meth.ident.name)
.collect(); .collect();
impls.push(Item { impls.push(Item {

View file

@ -427,7 +427,7 @@ crate fn build_impl(
let provided = trait_ let provided = trait_
.def_id() .def_id()
.map(|did| tcx.provided_trait_methods(did).map(|meth| meth.ident.to_string()).collect()) .map(|did| tcx.provided_trait_methods(did).map(|meth| meth.ident.name).collect())
.unwrap_or_default(); .unwrap_or_default();
debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id()); debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());

View file

@ -2065,9 +2065,9 @@ fn clean_impl(impl_: &hir::Item<'_>, cx: &DocContext<'_>) -> Vec<Item> {
build_deref_target_impls(cx, &items, &mut ret); build_deref_target_impls(cx, &items, &mut ret);
} }
let provided: FxHashSet<String> = trait_ let provided: FxHashSet<Symbol> = trait_
.def_id() .def_id()
.map(|did| cx.tcx.provided_trait_methods(did).map(|meth| meth.ident.to_string()).collect()) .map(|did| cx.tcx.provided_trait_methods(did).map(|meth| meth.ident.name).collect())
.unwrap_or_default(); .unwrap_or_default();
let for_ = for_.clean(cx); let for_ = for_.clean(cx);

View file

@ -1762,7 +1762,7 @@ crate enum ImplPolarity {
crate struct Impl { crate struct Impl {
crate unsafety: hir::Unsafety, crate unsafety: hir::Unsafety,
crate generics: Generics, crate generics: Generics,
crate provided_trait_methods: FxHashSet<String>, crate provided_trait_methods: FxHashSet<Symbol>,
crate trait_: Option<Type>, crate trait_: Option<Type>,
crate for_: Type, crate for_: Type,
crate items: Vec<Item>, crate items: Vec<Item>,

View file

@ -2966,7 +2966,7 @@ fn render_assoc_item(
AssocItemLink::GotoSource(did, provided_methods) => { AssocItemLink::GotoSource(did, provided_methods) => {
// We're creating a link from an impl-item to the corresponding // We're creating a link from an impl-item to the corresponding
// trait-item and need to map the anchored type accordingly. // trait-item and need to map the anchored type accordingly.
let ty = if provided_methods.contains(&*name.as_str()) { let ty = if provided_methods.contains(&name) {
ItemType::Method ItemType::Method
} else { } else {
ItemType::TyMethod ItemType::TyMethod
@ -3429,7 +3429,7 @@ fn render_union(
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
enum AssocItemLink<'a> { enum AssocItemLink<'a> {
Anchor(Option<&'a str>), Anchor(Option<&'a str>),
GotoSource(DefId, &'a FxHashSet<String>), GotoSource(DefId, &'a FxHashSet<Symbol>),
} }
impl<'a> AssocItemLink<'a> { impl<'a> AssocItemLink<'a> {

View file

@ -440,7 +440,10 @@ impl From<clean::Impl> for Impl {
Impl { Impl {
is_unsafe: unsafety == rustc_hir::Unsafety::Unsafe, is_unsafe: unsafety == rustc_hir::Unsafety::Unsafe,
generics: generics.into(), generics: generics.into(),
provided_trait_methods: provided_trait_methods.into_iter().collect(), provided_trait_methods: provided_trait_methods
.into_iter()
.map(|x| x.to_string())
.collect(),
trait_: trait_.map(Into::into), trait_: trait_.map(Into::into),
for_: for_.into(), for_: for_.into(),
items: ids(items), items: ids(items),