Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
formatting
  • Loading branch information
GuillaumeGomez committed Aug 5, 2021
1 parent f233a70 commit ef0d909
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
28 changes: 12 additions & 16 deletions src/librustdoc/html/highlight.rs
Expand Up @@ -573,24 +573,20 @@ fn string<T: Display>(
});
}
if let Some(context_info) = context_info {
if let Some(href) = context_info
.context
.shared
.span_correspondance_map
.get(&def_span)
.and_then(|href| {
let context = context_info.context;
match href {
LinkFromSrc::Local(span) => {
context
if let Some(href) =
context_info.context.shared.span_correspondance_map.get(&def_span).and_then(
|href| {
let context = context_info.context;
match href {
LinkFromSrc::Local(span) => context
.href_from_span(*span)
.map(|s| format!("{}{}", context_info.root_path, s))
.map(|s| format!("{}{}", context_info.root_path, s)),
LinkFromSrc::External(def_id) => {
format::href(*def_id, context).map(|(url, _, _)| url)
}
}
LinkFromSrc::External(def_id) => {
format::href(*def_id, context).map(|(url, _, _)| url)
}
}
})
},
)
{
write!(out, "<a class=\"{}\" href=\"{}\">{}</a>", klass.as_html(), href, text);
return;
Expand Down
21 changes: 7 additions & 14 deletions src/librustdoc/html/render/span_map.rs
Expand Up @@ -183,20 +183,13 @@ impl Visitor<'tcx> for SpanMapVisitor<'tcx> {
hir.maybe_body_owned_by(body_id).expect("a body which isn't a body"),
);
if let Some(def_id) = typeck_results.type_dependent_def_id(expr.hir_id) {
match hir.span_if_local(def_id) {
Some(span) => {
self.matches.insert(
LightSpan::new_from_span(method_span),
LinkFromSrc::Local(clean::Span::new(span)),
);
}
None => {
self.matches.insert(
LightSpan::new_from_span(method_span),
LinkFromSrc::External(def_id),
);
}
}
self.matches.insert(
LightSpan::new_from_span(method_span),
match hir.span_if_local(def_id) {
Some(span) => LinkFromSrc::Local(clean::Span::new(span)),
None => LinkFromSrc::External(def_id),
},
);
}
}
}
Expand Down

0 comments on commit ef0d909

Please sign in to comment.