Skip to content

Commit

Permalink
Auto merge of #80154 - GuillaumeGomez:str-to-symbol, r=jyn514
Browse files Browse the repository at this point in the history
Continue String to Symbol conversion in rustdoc (2)

Follow-up of #80119.

This is the last one (and I actually expected more conversions but seems like it was the last one remaining...).

r? `@jyn514`
  • Loading branch information
bors committed Dec 18, 2020
2 parents f745834 + 57266f1 commit 50a9097
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
.cx
.tcx
.provided_trait_methods(trait_def_id)
.map(|meth| meth.ident.to_string())
.map(|meth| meth.ident.name)
.collect();

impls.push(Item {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ crate fn build_impl(

let provided = trait_
.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();

debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,9 +2065,9 @@ fn clean_impl(impl_: &hir::Item<'_>, cx: &DocContext<'_>) -> Vec<Item> {
build_deref_target_impls(cx, &items, &mut ret);
}

let provided: FxHashSet<String> = trait_
let provided: FxHashSet<Symbol> = trait_
.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();

let for_ = for_.clean(cx);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ crate enum ImplPolarity {
crate struct Impl {
crate unsafety: hir::Unsafety,
crate generics: Generics,
crate provided_trait_methods: FxHashSet<String>,
crate provided_trait_methods: FxHashSet<Symbol>,
crate trait_: Option<Type>,
crate for_: Type,
crate items: Vec<Item>,
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2983,7 +2983,7 @@ fn render_assoc_item(
AssocItemLink::GotoSource(did, provided_methods) => {
// We're creating a link from an impl-item to the corresponding
// 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
} else {
ItemType::TyMethod
Expand Down Expand Up @@ -3452,7 +3452,7 @@ fn render_union(
#[derive(Copy, Clone)]
enum AssocItemLink<'a> {
Anchor(Option<&'a str>),
GotoSource(DefId, &'a FxHashSet<String>),
GotoSource(DefId, &'a FxHashSet<Symbol>),
}

impl<'a> AssocItemLink<'a> {
Expand Down
5 changes: 4 additions & 1 deletion src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,10 @@ impl From<clean::Impl> for Impl {
Impl {
is_unsafe: unsafety == rustc_hir::Unsafety::Unsafe,
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),
for_: for_.into(),
items: ids(items),
Expand Down

0 comments on commit 50a9097

Please sign in to comment.