diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 4860daa11e20c..e9e390d831f6b 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -806,9 +806,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc { /// /// This will decrement the strong reference count. If the strong reference /// count reaches zero then the only other references (if any) are - /// [`Weak`][weak], so we `drop` the inner value. - /// - /// [weak]: struct.Weak.html + /// [`Weak`], so we `drop` the inner value. /// /// # Examples /// @@ -1173,9 +1171,8 @@ impl, U: ?Sized> CoerceUnsized> for Weak {} impl Weak { /// Constructs a new `Weak`, without allocating any memory. - /// Calling [`upgrade`] on the return value always gives [`None`]. + /// Calling [`upgrade`][Weak::upgrade] on the return value always gives [`None`]. /// - /// [`upgrade`]: struct.Weak.html#method.upgrade /// [`None`]: ../../std/option/enum.Option.html /// /// # Examples @@ -1321,9 +1318,8 @@ impl fmt::Debug for Weak { #[stable(feature = "downgraded_weak", since = "1.10.0")] impl Default for Weak { /// Constructs a new `Weak`, allocating memory for `T` without initializing - /// it. Calling [`upgrade`] on the return value always gives [`None`]. + /// it. Calling [`upgrade`][Weak::upgrade] on the return value always gives [`None`]. /// - /// [`upgrade`]: struct.Weak.html#method.upgrade /// [`None`]: ../../std/option/enum.Option.html /// /// # Examples diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index aa821abb34cdf..837e17cf64017 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1927,9 +1927,7 @@ impl<'a> Add<&'a str> for String { /// Implements the `+=` operator for appending to a `String`. /// -/// This has the same behavior as the [`push_str`] method. -/// -/// [`push_str`]: struct.String.html#method.push_str +/// This has the same behavior as the [`push_str`][String::push_str] method. #[stable(feature = "stringaddassign", since = "1.12.0")] impl<'a> AddAssign<&'a str> for String { #[inline] diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index db7a4044b267f..fc6b7a29677b3 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -916,9 +916,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc { /// /// This will decrement the strong reference count. If the strong reference /// count reaches zero then the only other references (if any) are - /// [`Weak`][weak], so we `drop` the inner value. - /// - /// [weak]: struct.Weak.html + /// [`Weak`], so we `drop` the inner value. /// /// # Examples /// @@ -1159,9 +1157,9 @@ impl Clone for Weak { #[stable(feature = "downgraded_weak", since = "1.10.0")] impl Default for Weak { /// Constructs a new `Weak`, without allocating memory. - /// Calling [`upgrade`] on the return value always gives [`None`]. + /// Calling [`upgrade`][Weak::upgrade] on the return value always + /// gives [`None`]. /// - /// [`upgrade`]: struct.Weak.html#method.upgrade /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// # Examples diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 3879abb0af973..53cf626bb1ca0 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1006,9 +1006,7 @@ fn expect_failed(msg: &str) -> ! { #[stable(feature = "rust1", since = "1.0.0")] impl Default for Option { - /// Returns [`None`]. - /// - /// [`None`]: #variant.None + /// Returns [`None`][Option::None]. #[inline] fn default() -> Option { None } } @@ -1228,9 +1226,10 @@ unsafe impl TrustedLen for IntoIter {} #[stable(feature = "rust1", since = "1.0.0")] impl> FromIterator> for Option { - /// Takes each element in the [`Iterator`]: if it is [`None`], no further - /// elements are taken, and the [`None`] is returned. Should no [`None`] occur, a - /// container with the values of each `Option` is returned. + /// Takes each element in the [`Iterator`]: if it is [`None`][Option::None], + /// no further elements are taken, and the [`None`][Option::None] is + /// returned. Should no [`None`][Option::None] occur, a container with the + /// values of each [`Option`] is returned. /// /// Here is an example which increments every integer in a vector, /// checking for overflow: @@ -1247,7 +1246,6 @@ impl> FromIterator> for Option { /// ``` /// /// [`Iterator`]: ../iter/trait.Iterator.html - /// [`None`]: enum.Option.html#variant.None #[inline] fn from_iter>>(iter: I) -> Option { // FIXME(#11084): This could be replaced with Iterator::scan when this diff --git a/src/libcore/result.rs b/src/libcore/result.rs index ac908342655b6..c4b4a0fd72a68 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -507,7 +507,7 @@ impl Result { /// Returns an iterator over the possibly contained value. /// - /// The iterator yields one value if the result is [`Ok`], otherwise none. + /// The iterator yields one value if the result is [`Result::Ok`], otherwise none. /// /// # Examples /// @@ -520,8 +520,6 @@ impl Result { /// let x: Result = Err("nothing!"); /// assert_eq!(x.iter().next(), None); /// ``` - /// - /// [`Ok`]: enum.Result.html#variant.Ok #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn iter(&self) -> Iter { @@ -530,7 +528,7 @@ impl Result { /// Returns a mutable iterator over the possibly contained value. /// - /// The iterator yields one value if the result is [`Ok`], otherwise none. + /// The iterator yields one value if the result is [`Result::Ok`], otherwise none. /// /// # Examples /// @@ -547,8 +545,6 @@ impl Result { /// let mut x: Result = Err("nothing!"); /// assert_eq!(x.iter_mut().next(), None); /// ``` - /// - /// [`Ok`]: enum.Result.html#variant.Ok #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn iter_mut(&mut self) -> IterMut { @@ -994,7 +990,7 @@ impl IntoIterator for Result { /// Returns a consuming iterator over the possibly contained value. /// - /// The iterator yields one value if the result is [`Ok`], otherwise none. + /// The iterator yields one value if the result is [`Result::Ok`], otherwise none. /// /// # Examples /// @@ -1009,8 +1005,6 @@ impl IntoIterator for Result { /// let v: Vec = x.into_iter().collect(); /// assert_eq!(v, []); /// ``` - /// - /// [`Ok`]: enum.Result.html#variant.Ok #[inline] fn into_iter(self) -> IntoIter { IntoIter { inner: self.ok() } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 368c056f021c1..972c2f0e15c5e 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2678,7 +2678,6 @@ fn item_function(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter, implementor_dups: &FxHashMap<&str, (DefId, bool)>) -> fmt::Result { - write!(w, "
  • ")?; // If there's already another implementor that has the same abbridged name, use the // full path, for example in `std::iter::ExactSizeIterator` let use_absolute = match implementor.inner_impl().for_ { @@ -2689,22 +2688,8 @@ fn render_implementor(cx: &Context, implementor: &Impl, w: &mut fmt::Formatter, } => implementor_dups[path.last_name()].1, _ => false, }; - fmt_impl_for_trait_page(&implementor.inner_impl(), w, use_absolute)?; - for it in &implementor.inner_impl().items { - if let clean::TypedefItem(ref tydef, _) = it.inner { - write!(w, " ")?; - assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None))?; - write!(w, ";")?; - } - } - write!(w, "")?; - if let Some(l) = (Item { cx, item: &implementor.impl_item }).src_href() { - write!(w, "
    ")?; - write!(w, "[src]", - l, "goto source code")?; - write!(w, "
    ")?; - } - writeln!(w, "
  • ")?; + render_impl(w, cx, implementor, AssocItemLink::Anchor(None), RenderMode::Normal, + implementor.impl_item.stable_since(), false, Some(use_absolute))?; Ok(()) } @@ -2715,7 +2700,7 @@ fn render_impls(cx: &Context, w: &mut fmt::Formatter, let did = i.trait_did().unwrap(); let assoc_link = AssocItemLink::GotoSource(did, &i.inner_impl().provided_trait_methods); render_impl(w, cx, i, assoc_link, - RenderMode::Normal, containing_item.stable_since(), true)?; + RenderMode::Normal, containing_item.stable_since(), true, None)?; } Ok(()) } @@ -2907,14 +2892,14 @@ fn item_trait(

    \ Implementors\

    \ -
      \ +
      \ "; let synthetic_impl_header = "\

      \ Auto implementors\

      \ -
        \ +
        \ "; let mut synthetic_types = Vec::new(); @@ -2964,7 +2949,8 @@ fn item_trait( &implementor.inner_impl().provided_trait_methods ); render_impl(w, cx, &implementor, assoc_link, - RenderMode::Normal, implementor.impl_item.stable_since(), false)?; + RenderMode::Normal, implementor.impl_item.stable_since(), false, + None)?; } } } @@ -2973,7 +2959,7 @@ fn item_trait( for implementor in concrete { render_implementor(cx, implementor, w, &implementor_dups)?; } - write!(w, "
      ")?; + write!(w, "
      ")?; if t.auto { write!(w, "{}", synthetic_impl_header)?; @@ -2983,17 +2969,17 @@ fn item_trait( ); render_implementor(cx, implementor, w, &implementor_dups)?; } - write!(w, "
    ")?; + write!(w, "")?; } } else { // even without any implementations to write in, we still want the heading and list, so the // implementors javascript file pulled in below has somewhere to write the impls into write!(w, "{}", impl_header)?; - write!(w, "")?; + write!(w, "")?; if t.auto { write!(w, "{}", synthetic_impl_header)?; - write!(w, "")?; + write!(w, "")?; } } write!(w, r#""#, @@ -3616,7 +3602,7 @@ fn render_assoc_items(w: &mut fmt::Formatter, }; for i in &non_trait { render_impl(w, cx, i, AssocItemLink::Anchor(None), render_mode, - containing_item.stable_since(), true)?; + containing_item.stable_since(), true, None)?; } } if let AssocItemRender::DerefFor { .. } = what { @@ -3797,15 +3783,32 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result { fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLink, render_mode: RenderMode, outer_version: Option<&str>, - show_def_docs: bool) -> fmt::Result { + show_def_docs: bool, use_absolute: Option) -> fmt::Result { if render_mode == RenderMode::Normal { let id = cx.derive_id(match i.inner_impl().trait_ { Some(ref t) => format!("impl-{}", small_url_encode(&format!("{:#}", t))), None => "impl".to_string(), }); - write!(w, "

    \ -
    {}", - id, i.inner_impl())?; + if let Some(use_absolute) = use_absolute { + write!(w, "

    \ +
    ", id)?; + fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute)?; + if show_def_docs { + for it in &i.inner_impl().items { + if let clean::TypedefItem(ref tydef, _) = it.inner { + write!(w, " ")?; + assoc_type(w, it, &vec![], Some(&tydef.type_), + AssocItemLink::Anchor(None))?; + write!(w, ";")?; + } + } + } + write!(w, "")?; + } else { + write!(w, "

    \ +
    {}", + id, i.inner_impl())?; + } write!(w, "", id)?; write!(w, "")?; let since = i.impl_item.stability.as_ref().map(|s| &s.since[..]); @@ -3929,10 +3932,6 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi let traits = &cache().traits; let trait_ = i.trait_did().map(|did| &traits[&did]); - if !show_def_docs { - write!(w, "")?; - } - write!(w, "
    ")?; for trait_item in &i.inner_impl().items { doc_impl_item(w, cx, trait_item, link, render_mode, @@ -3968,10 +3967,6 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi } write!(w, "
    ")?; - if !show_def_docs { - write!(w, "
    ")?; - } - Ok(()) } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 51ed626782926..a3af621a8a416 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1791,9 +1791,12 @@ x[k].setAttribute('href', rootPath + href); } } - var li = document.createElement('li'); - li.appendChild(code); - list.appendChild(li); + var display = document.createElement('h3'); + addClass(display, "impl"); + display.innerHTML = '\ +
    ' + code.outerHTML + '
    \ +
    '; + list.appendChild(display); } } }; diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 5145e9f449b17..3a54cb6389b5b 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -114,7 +114,7 @@ h3.impl, h3.method, h3.type { h1, h2, h3, h4, .sidebar, a.source, .search-input, .content table :not(code)>a, -.collapse-toggle, ul.item-list > li > .out-of-band { +.collapse-toggle, div.item-list .out-of-band { font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; } @@ -367,10 +367,6 @@ h4.method > .out-of-band { font-size: 19px; } -ul.item-list > li > .out-of-band { - font-size: 19px; -} - h4 > code, h3 > code, .invisible > code { max-width: calc(100% - 41px); display: block; @@ -436,10 +432,6 @@ h4 > code, h3 > code, .invisible > code { padding: 0; } -.content .item-list li { - margin-bottom: 1em; -} - .content .multi-column { -moz-column-count: 5; -moz-column-gap: 2.5em; @@ -473,6 +465,11 @@ h4 > code, h3 > code, .invisible > code { .content .impl-items .docblock, .content .impl-items .stability { margin-bottom: .6em; } + +.content .impl-items > .stability { + margin-left: 40px; +} + .content .docblock > .impl-items { margin-left: 20px; margin-top: -34px; @@ -1363,6 +1360,15 @@ kbd { font-size: 19px; display: block; } +#implementors-list > .impl-items .table-display .out-of-band { + font-size: 17px; +} + +.table-display td:hover .anchor { + display: block; + top: 2px; + left: -5px; +} #main > ul { padding-left: 10px; diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 91912e5f2412e..3e54b502234ff 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2655,9 +2655,8 @@ impl DefaultHasher { #[stable(feature = "hashmap_default_hasher", since = "1.13.0")] impl Default for DefaultHasher { - /// Creates a new `DefaultHasher` using [`new`]. See its documentation for more. - /// - /// [`new`]: #method.new + /// Creates a new `DefaultHasher` using [`new`][DefaultHasher::new]. + /// See its documentation for more. fn default() -> DefaultHasher { DefaultHasher::new() } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 6bcd62dbd59c2..8ae5e20dac5aa 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -351,9 +351,6 @@ impl From for OsString { /// Converts a [`String`] into a [`OsString`]. /// /// The conversion copies the data, and includes an allocation on the heap. - /// - /// [`String`]: ../string/struct.String.html - /// [`OsString`]: struct.OsString.html fn from(s: String) -> OsString { OsString { inner: Buf::from_string(s) } } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 77bc7e946eb41..e26e6d391f84d 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -294,17 +294,15 @@ impl Seek for BufReader { /// `.into_inner()` immediately after a seek yields the underlying reader /// at the same position. /// - /// To seek without discarding the internal buffer, use [`seek_relative`]. + /// To seek without discarding the internal buffer, use [`Seek::seek_relative`]. /// - /// See `std::io::Seek` for more details. + /// See [`std::io::Seek`] for more details. /// /// Note: In the edge case where you're seeking with `SeekFrom::Current(n)` /// where `n` minus the internal buffer length overflows an `i64`, two /// seeks will be performed instead of one. If the second seek returns /// `Err`, the underlying reader will be left at the same position it would /// have if you called `seek` with `SeekFrom::Current(0)`. - /// - /// [`seek_relative`]: #method.seek_relative fn seek(&mut self, pos: SeekFrom) -> io::Result { let result: u64; if let SeekFrom::Current(n) = pos { diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index e5a410644b907..54bfd8122b4ed 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -386,8 +386,6 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex { impl From for Mutex { /// Creates a new mutex in an unlocked state ready for use. /// This is equivalent to [`Mutex::new`]. - /// - /// [`Mutex::new`]: #method.new fn from(t: T) -> Self { Mutex::new(t) } diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index ed3a3865a6cae..c0c706590db94 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -461,8 +461,6 @@ impl Default for RwLock { impl From for RwLock { /// Creates a new instance of an `RwLock` which is unlocked. /// This is equivalent to [`RwLock::new`]. - /// - /// [`RwLock::new`]: #method.new fn from(t: T) -> Self { RwLock::new(t) } diff --git a/src/test/rustdoc/doc-cfg.rs b/src/test/rustdoc/doc-cfg.rs index ea8a13b034beb..27077ed4f1ac1 100644 --- a/src/test/rustdoc/doc-cfg.rs +++ b/src/test/rustdoc/doc-cfg.rs @@ -36,7 +36,7 @@ pub mod unix_only { // @has doc_cfg/unix_only/trait.ArmOnly.html \ // '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \ // 'This is supported on Unix and ARM only.' - // @count - '//*[@class="stab portability"]' 2 + // @count - '//*[@class="stab portability"]' 3 #[doc(cfg(target_arch = "arm"))] pub trait ArmOnly { fn unix_and_arm_only_function(); diff --git a/src/test/rustdoc/issue-29503.rs b/src/test/rustdoc/issue-29503.rs index d8b484f6b501b..104e8d62f19f2 100644 --- a/src/test/rustdoc/issue-29503.rs +++ b/src/test/rustdoc/issue-29503.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + use std::fmt; // @has issue_29503/trait.MyTrait.html @@ -15,7 +17,7 @@ pub trait MyTrait { fn my_string(&self) -> String; } -// @has - "//ul[@id='implementors-list']/li" "impl MyTrait for T where T: Debug" +// @has - "//div[@id='implementors-list']/h3[@id='impl-MyTrait']//code" "impl MyTrait for T where T: Debug" impl MyTrait for T where T: fmt::Debug { fn my_string(&self) -> String { format!("{:?}", self)