Rollup merge of #40419 - GuillaumeGomez:fix-const-rendering, r=frewsxcv
Fix associated consts display Fixes #40370. r? @frewsxcv
This commit is contained in:
commit
7b0caa58d9
|
@ -442,7 +442,7 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
|
||||||
/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
|
/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
|
||||||
/// rendering function with the necessary arguments for linking to a local path.
|
/// rendering function with the necessary arguments for linking to a local path.
|
||||||
fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||||
print_all: bool, use_absolute: bool) -> fmt::Result {
|
print_all: bool, use_absolute: bool, is_not_debug: bool) -> fmt::Result {
|
||||||
let last = path.segments.last().unwrap();
|
let last = path.segments.last().unwrap();
|
||||||
let rel_root = match &*path.segments[0].name {
|
let rel_root = match &*path.segments[0].name {
|
||||||
"self" => Some("./".to_string()),
|
"self" => Some("./".to_string()),
|
||||||
|
@ -459,10 +459,14 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||||
} else {
|
} else {
|
||||||
root.push_str(&seg.name);
|
root.push_str(&seg.name);
|
||||||
root.push_str("/");
|
root.push_str("/");
|
||||||
write!(w, "<a class=\"mod\"
|
if is_not_debug {
|
||||||
href=\"{}index.html\">{}</a>::",
|
write!(w, "<a class=\"mod\"
|
||||||
root,
|
href=\"{}index.html\">{}</a>::",
|
||||||
seg.name)?;
|
root,
|
||||||
|
seg.name)?;
|
||||||
|
} else {
|
||||||
|
write!(w, "{}::", seg.name)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,19 +478,37 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if w.alternate() {
|
if w.alternate() {
|
||||||
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
|
if is_not_debug {
|
||||||
} else {
|
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
|
||||||
let path = if use_absolute {
|
|
||||||
match href(did) {
|
|
||||||
Some((_, _, fqp)) => format!("{}::{}",
|
|
||||||
fqp[..fqp.len()-1].join("::"),
|
|
||||||
HRef::new(did, fqp.last().unwrap())),
|
|
||||||
None => format!("{}", HRef::new(did, &last.name)),
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
format!("{}", HRef::new(did, &last.name))
|
write!(w, "{:?}{:?}", HRef::new(did, &last.name), last.params)?;
|
||||||
};
|
}
|
||||||
write!(w, "{}{}", path, last.params)?;
|
} else {
|
||||||
|
if is_not_debug {
|
||||||
|
let path = if use_absolute {
|
||||||
|
match href(did) {
|
||||||
|
Some((_, _, fqp)) => format!("{}::{}",
|
||||||
|
fqp[..fqp.len()-1].join("::"),
|
||||||
|
HRef::new(did, fqp.last().unwrap())),
|
||||||
|
None => format!("{}", HRef::new(did, &last.name)),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
format!("{}", HRef::new(did, &last.name))
|
||||||
|
};
|
||||||
|
write!(w, "{}{}", path, last.params)?;
|
||||||
|
} else {
|
||||||
|
let path = if use_absolute {
|
||||||
|
match href(did) {
|
||||||
|
Some((_, _, fqp)) => format!("{:?}::{:?}",
|
||||||
|
fqp[..fqp.len()-1].join("::"),
|
||||||
|
HRef::new(did, fqp.last().unwrap())),
|
||||||
|
None => format!("{:?}", HRef::new(did, &last.name)),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
format!("{:?}", HRef::new(did, &last.name))
|
||||||
|
};
|
||||||
|
write!(w, "{}{:?}", path, last.params)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -570,6 +592,12 @@ impl<'a> fmt::Display for HRef<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> fmt::Debug for HRef<'a> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "{}", self.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
||||||
is_not_debug: bool) -> fmt::Result {
|
is_not_debug: bool) -> fmt::Result {
|
||||||
match *t {
|
match *t {
|
||||||
|
@ -578,7 +606,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
||||||
}
|
}
|
||||||
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
|
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
|
||||||
// Paths like T::Output and Self::Output should be rendered with all segments
|
// Paths like T::Output and Self::Output should be rendered with all segments
|
||||||
resolved_path(f, did, path, is_generic, use_absolute)?;
|
resolved_path(f, did, path, is_generic, use_absolute, is_not_debug)?;
|
||||||
tybounds(f, typarams)
|
tybounds(f, typarams)
|
||||||
}
|
}
|
||||||
clean::Infer => write!(f, "_"),
|
clean::Infer => write!(f, "_"),
|
||||||
|
@ -767,7 +795,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
||||||
write!(f, "{}::", self_type)?;
|
write!(f, "{}::", self_type)?;
|
||||||
}
|
}
|
||||||
let path = clean::Path::singleton(name.clone());
|
let path = clean::Path::singleton(name.clone());
|
||||||
resolved_path(f, did, &path, true, use_absolute)?;
|
resolved_path(f, did, &path, true, use_absolute, is_not_debug)?;
|
||||||
|
|
||||||
// FIXME: `typarams` are not rendered, and this seems bad?
|
// FIXME: `typarams` are not rendered, and this seems bad?
|
||||||
drop(typarams);
|
drop(typarams);
|
||||||
|
@ -1051,7 +1079,7 @@ impl fmt::Display for clean::Import {
|
||||||
impl fmt::Display for clean::ImportSource {
|
impl fmt::Display for clean::ImportSource {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self.did {
|
match self.did {
|
||||||
Some(did) => resolved_path(f, did, &self.path, true, false),
|
Some(did) => resolved_path(f, did, &self.path, true, false, true),
|
||||||
_ => {
|
_ => {
|
||||||
for (i, seg) in self.path.segments.iter().enumerate() {
|
for (i, seg) in self.path.segments.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
|
Loading…
Reference in New Issue