Skip to content

Commit cfb5deb

Browse files
committed
Auto merge of #42605 - frewsxcv:rollup, r=frewsxcv
Rollup of 4 pull requests - Successful merges: #42579, #42586, #42592, #42594 - Failed merges:
2 parents 5aa3403 + 3023cc4 commit cfb5deb

File tree

8 files changed

+99
-62
lines changed

8 files changed

+99
-62
lines changed

src/libcollections/str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ impl str {
13201320
core_str::StrExt::rsplitn(self, n, pat)
13211321
}
13221322

1323-
/// An iterator over the matches of a pattern within the given string
1323+
/// An iterator over the disjoint matches of a pattern within the given string
13241324
/// slice.
13251325
///
13261326
/// The pattern can be a `&str`, [`char`], or a closure that
@@ -1359,7 +1359,7 @@ impl str {
13591359
core_str::StrExt::matches(self, pat)
13601360
}
13611361

1362-
/// An iterator over the matches of a pattern within this string slice,
1362+
/// An iterator over the disjoint matches of a pattern within this string slice,
13631363
/// yielded in reverse order.
13641364
///
13651365
/// The pattern can be a `&str`, [`char`], or a closure that determines if

src/librustdoc/html/format.rs

+19-23
Original file line numberDiff line numberDiff line change
@@ -459,22 +459,10 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
459459
/// rendering function with the necessary arguments for linking to a local path.
460460
fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
461461
print_all: bool, use_absolute: bool) -> fmt::Result {
462-
let empty = clean::PathSegment {
463-
name: String::new(),
464-
params: clean::PathParameters::Parenthesized {
465-
inputs: Vec::new(),
466-
output: None,
467-
}
468-
};
469-
let last = path.segments.last()
470-
.unwrap_or(&empty);
471-
let rel_root = if path.segments.is_empty() {
472-
None
473-
} else {
474-
match &*path.segments[0].name {
475-
"self" => Some("./".to_string()),
476-
_ => None,
477-
}
462+
let last = path.segments.last().unwrap();
463+
let rel_root = match &*path.segments[0].name {
464+
"self" => Some("./".to_string()),
465+
_ => None,
478466
};
479467

480468
if print_all {
@@ -508,7 +496,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
508496
Some((_, _, fqp)) => {
509497
format!("{}::{}",
510498
fqp[..fqp.len() - 1].join("::"),
511-
HRef::new(did, fqp.last().unwrap_or(&String::new())))
499+
HRef::new(did, fqp.last().unwrap()))
512500
}
513501
None => format!("{}", HRef::new(did, &last.name)),
514502
}
@@ -740,10 +728,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
740728
}
741729
clean::QPath { ref name, ref self_type, ref trait_ } => {
742730
let should_show_cast = match *trait_ {
743-
box clean::ResolvedPath { .. } => {
744-
let path = clean::Path::singleton(name.clone());
745-
!path.segments.is_empty() && &format!("{:#}", trait_) != "()" &&
746-
&format!("{:#}", self_type) != "Self"
731+
box clean::ResolvedPath { ref path, .. } => {
732+
!path.segments.is_empty() && !self_type.is_self_type()
747733
}
748734
_ => true,
749735
};
@@ -772,8 +758,18 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
772758
// everything comes in as a fully resolved QPath (hard to
773759
// look at).
774760
box clean::ResolvedPath { did, ref typarams, .. } => {
775-
let path = clean::Path::singleton(name.clone());
776-
resolved_path(f, did, &path, true, use_absolute)?;
761+
match href(did) {
762+
Some((ref url, _, ref path)) if !f.alternate() => {
763+
write!(f,
764+
"<a class=\"type\" href=\"{url}#{shortty}.{name}\" \
765+
title=\"type {path}::{name}\">{name}</a>",
766+
url = url,
767+
shortty = ItemType::AssociatedType,
768+
name = name,
769+
path = path.join("::"))?;
770+
}
771+
_ => write!(f, "{}", name)?,
772+
}
777773

778774
// FIXME: `typarams` are not rendered, and this seems bad?
779775
drop(typarams);

src/librustdoc/html/render.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ impl Context {
13341334
// these modules are recursed into, but not rendered normally
13351335
// (a flag on the context).
13361336
if !self.render_redirect_pages {
1337-
self.render_redirect_pages = maybe_ignore_item(&item);
1337+
self.render_redirect_pages = item.is_stripped();
13381338
}
13391339

13401340
if item.is_mod() {
@@ -1417,7 +1417,7 @@ impl Context {
14171417
// BTreeMap instead of HashMap to get a sorted output
14181418
let mut map = BTreeMap::new();
14191419
for item in &m.items {
1420-
if maybe_ignore_item(item) { continue }
1420+
if item.is_stripped() { continue }
14211421

14221422
let short = item.type_().css_class();
14231423
let myname = match item.name {
@@ -1718,7 +1718,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
17181718
if let clean::DefaultImplItem(..) = items[*i].inner {
17191719
return false;
17201720
}
1721-
!maybe_ignore_item(&items[*i])
1721+
!items[*i].is_stripped()
17221722
}).collect::<Vec<usize>>();
17231723

17241724
// the order of item types in the listing
@@ -1887,17 +1887,6 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
18871887
Ok(())
18881888
}
18891889

1890-
fn maybe_ignore_item(it: &clean::Item) -> bool {
1891-
match it.inner {
1892-
clean::StrippedItem(..) => true,
1893-
clean::ModuleItem(ref m) => {
1894-
it.doc_value().is_none() && m.items.is_empty()
1895-
&& it.visibility != Some(clean::Public)
1896-
},
1897-
_ => false,
1898-
}
1899-
}
1900-
19011890
fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<String> {
19021891
let mut stability = vec![];
19031892

@@ -3317,7 +3306,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item,
33173306
if let clean::DefaultImplItem(..) = it.inner {
33183307
false
33193308
} else {
3320-
!maybe_ignore_item(it) && !it.is_stripped() && it.type_() == myty
3309+
!it.is_stripped() && it.type_() == myty
33213310
}
33223311
}) {
33233312
let (short, name) = match myty {

src/librustdoc/passes/mod.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,12 @@ impl<'a> fold::DocFolder for Stripper<'a> {
145145
self.fold_item_recur(i)
146146
};
147147

148-
i.and_then(|i| {
149-
match i.inner {
150-
// emptied modules have no need to exist
151-
clean::ModuleItem(ref m)
152-
if m.items.is_empty() &&
153-
i.doc_value().is_none() => None,
154-
_ => {
155-
if self.update_retained {
156-
self.retained.insert(i.def_id);
157-
}
158-
Some(i)
159-
}
148+
if let Some(ref i) = i {
149+
if self.update_retained {
150+
self.retained.insert(i.def_id);
160151
}
161-
})
152+
}
153+
i
162154
}
163155
}
164156

src/libstd/env.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ fn _remove_var(k: &OsStr) {
367367
/// An iterator that splits an environment variable into paths according to
368368
/// platform-specific conventions.
369369
///
370-
/// This structure is created by the [`std::env::split_paths`] function See its
370+
/// This structure is created by the [`std::env::split_paths`] function. See its
371371
/// documentation for more.
372372
///
373373
/// [`std::env::split_paths`]: fn.split_paths.html
@@ -605,14 +605,15 @@ pub fn current_exe() -> io::Result<PathBuf> {
605605
os_imp::current_exe()
606606
}
607607

608-
/// An iterator over the arguments of a process, yielding a [`String`] value
609-
/// for each argument.
608+
/// An iterator over the arguments of a process, yielding a [`String`] value for
609+
/// each argument.
610610
///
611-
/// This structure is created through the [`std::env::args`] function.
611+
/// This struct is created by the [`std::env::args`] function. See its
612+
/// documentation for more.
612613
///
613614
/// The first element is traditionally the path of the executable, but it can be
614-
/// set to arbitrary text, and may not even exist. This means this property should
615-
/// not be relied upon for security purposes.
615+
/// set to arbitrary text, and may not even exist. This means this property
616+
/// should not be relied upon for security purposes.
616617
///
617618
/// [`String`]: ../string/struct.String.html
618619
/// [`std::env::args`]: ./fn.args.html
@@ -622,11 +623,12 @@ pub struct Args { inner: ArgsOs }
622623
/// An iterator over the arguments of a process, yielding an [`OsString`] value
623624
/// for each argument.
624625
///
625-
/// This structure is created through the [`std::env::args_os`] function.
626+
/// This struct is created by the [`std::env::args_os`] function. See its
627+
/// documentation for more.
626628
///
627629
/// The first element is traditionally the path of the executable, but it can be
628-
/// set to arbitrary text, and may not even exist. This means this property should
629-
/// not be relied upon for security purposes.
630+
/// set to arbitrary text, and may not even exist. This means this property
631+
/// should not be relied upon for security purposes.
630632
///
631633
/// [`OsString`]: ../ffi/struct.OsString.html
632634
/// [`std::env::args_os`]: ./fn.args_os.html

src/test/rustdoc/assoc-types.rs

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// ignore-tidy-linelength
12+
1113
#![crate_type="lib"]
1214

1315
// @has assoc_types/trait.Index.html
@@ -18,11 +20,14 @@ pub trait Index<I: ?Sized> {
1820
// @has - '//*[@id="index.v"]//code' 'fn index'
1921
// @has - '//*[@id="tymethod.index"]//code' \
2022
// "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
23+
// @has - '//*[@id="tymethod.index"]//code//a[@href="../assoc_types/trait.Index.html#associatedtype.Output"]' \
24+
// "Output"
2125
fn index<'a>(&'a self, index: I) -> &'a Self::Output;
2226
}
2327

2428
// @has assoc_types/fn.use_output.html
2529
// @has - '//*[@class="rust fn"]' '-> &T::Output'
30+
// @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Index.html#associatedtype.Output"]' 'Output'
2631
pub fn use_output<T: Index<usize>>(obj: &T, index: usize) -> &T::Output {
2732
obj.index(index)
2833
}
@@ -33,10 +38,12 @@ pub trait Feed {
3338

3439
// @has assoc_types/fn.use_input.html
3540
// @has - '//*[@class="rust fn"]' 'T::Input'
41+
// @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Feed.html#associatedtype.Input"]' 'Input'
3642
pub fn use_input<T: Feed>(_feed: &T, _element: T::Input) { }
3743

3844
// @has assoc_types/fn.cmp_input.html
3945
// @has - '//*[@class="rust fn"]' 'where T::Input: PartialEq<U::Input>'
46+
// @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Feed.html#associatedtype.Input"]' 'Input'
4047
pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool
4148
where T::Input: PartialEq<U::Input>
4249
{

src/test/rustdoc/empty-mod-private.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-tidy-linelength
12+
// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports
13+
14+
// @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo'
15+
// @has 'empty_mod_private/sidebar-items.js' 'foo'
16+
// @matches 'empty_mod_private/foo/index.html' '//h1' 'Module empty_mod_private::foo'
17+
mod foo {}
18+
19+
// @has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar'
20+
// @has 'empty_mod_private/sidebar-items.js' 'bar'
21+
// @matches 'empty_mod_private/bar/index.html' '//h1' 'Module empty_mod_private::bar'
22+
mod bar {
23+
// @has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz'
24+
// @has 'empty_mod_private/bar/sidebar-items.js' 'baz'
25+
// @matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module empty_mod_private::bar::baz'
26+
mod baz {}
27+
}

src/test/rustdoc/empty-mod-public.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// @has 'empty_mod_public/index.html' '//a[@href="foo/index.html"]' 'foo'
12+
// @has 'empty_mod_public/sidebar-items.js' 'foo'
13+
// @matches 'empty_mod_public/foo/index.html' '//h1' 'Module empty_mod_public::foo'
14+
pub mod foo {}
15+
16+
// @has 'empty_mod_public/index.html' '//a[@href="bar/index.html"]' 'bar'
17+
// @has 'empty_mod_public/sidebar-items.js' 'bar'
18+
// @matches 'empty_mod_public/bar/index.html' '//h1' 'Module empty_mod_public::bar'
19+
pub mod bar {
20+
// @has 'empty_mod_public/bar/index.html' '//a[@href="baz/index.html"]' 'baz'
21+
// @has 'empty_mod_public/bar/sidebar-items.js' 'baz'
22+
// @matches 'empty_mod_public/bar/baz/index.html' '//h1' 'Module empty_mod_public::bar::baz'
23+
pub mod baz {}
24+
}

0 commit comments

Comments
 (0)