Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 4 pull requests #42605

Merged
merged 8 commits into from
Jun 12, 2017
4 changes: 2 additions & 2 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ impl str {
core_str::StrExt::rsplitn(self, n, pat)
}

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

/// An iterator over the matches of a pattern within this string slice,
/// An iterator over the disjoint matches of a pattern within this string slice,
/// yielded in reverse order.
///
/// The pattern can be a `&str`, [`char`], or a closure that determines if
Expand Down
42 changes: 19 additions & 23 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,22 +459,10 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
/// rendering function with the necessary arguments for linking to a local path.
fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
print_all: bool, use_absolute: bool) -> fmt::Result {
let empty = clean::PathSegment {
name: String::new(),
params: clean::PathParameters::Parenthesized {
inputs: Vec::new(),
output: None,
}
};
let last = path.segments.last()
.unwrap_or(&empty);
let rel_root = if path.segments.is_empty() {
None
} else {
match &*path.segments[0].name {
"self" => Some("./".to_string()),
_ => None,
}
let last = path.segments.last().unwrap();
let rel_root = match &*path.segments[0].name {
"self" => Some("./".to_string()),
_ => None,
};

if print_all {
Expand Down Expand Up @@ -508,7 +496,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
Some((_, _, fqp)) => {
format!("{}::{}",
fqp[..fqp.len() - 1].join("::"),
HRef::new(did, fqp.last().unwrap_or(&String::new())))
HRef::new(did, fqp.last().unwrap()))
}
None => format!("{}", HRef::new(did, &last.name)),
}
Expand Down Expand Up @@ -740,10 +728,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
}
clean::QPath { ref name, ref self_type, ref trait_ } => {
let should_show_cast = match *trait_ {
box clean::ResolvedPath { .. } => {
let path = clean::Path::singleton(name.clone());
!path.segments.is_empty() && &format!("{:#}", trait_) != "()" &&
&format!("{:#}", self_type) != "Self"
box clean::ResolvedPath { ref path, .. } => {
!path.segments.is_empty() && !self_type.is_self_type()
}
_ => true,
};
Expand Down Expand Up @@ -772,8 +758,18 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
// everything comes in as a fully resolved QPath (hard to
// look at).
box clean::ResolvedPath { did, ref typarams, .. } => {
let path = clean::Path::singleton(name.clone());
resolved_path(f, did, &path, true, use_absolute)?;
match href(did) {
Some((ref url, _, ref path)) if !f.alternate() => {
write!(f,
"<a class=\"type\" href=\"{url}#{shortty}.{name}\" \
title=\"type {path}::{name}\">{name}</a>",
url = url,
shortty = ItemType::AssociatedType,
name = name,
path = path.join("::"))?;
}
_ => write!(f, "{}", name)?,
}

// FIXME: `typarams` are not rendered, and this seems bad?
drop(typarams);
Expand Down
19 changes: 4 additions & 15 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ impl Context {
// these modules are recursed into, but not rendered normally
// (a flag on the context).
if !self.render_redirect_pages {
self.render_redirect_pages = maybe_ignore_item(&item);
self.render_redirect_pages = item.is_stripped();
}

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

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

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

fn maybe_ignore_item(it: &clean::Item) -> bool {
match it.inner {
clean::StrippedItem(..) => true,
clean::ModuleItem(ref m) => {
it.doc_value().is_none() && m.items.is_empty()
&& it.visibility != Some(clean::Public)
},
_ => false,
}
}

fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<String> {
let mut stability = vec![];

Expand Down Expand Up @@ -3317,7 +3306,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item,
if let clean::DefaultImplItem(..) = it.inner {
false
} else {
!maybe_ignore_item(it) && !it.is_stripped() && it.type_() == myty
!it.is_stripped() && it.type_() == myty
}
}) {
let (short, name) = match myty {
Expand Down
18 changes: 5 additions & 13 deletions src/librustdoc/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,12 @@ impl<'a> fold::DocFolder for Stripper<'a> {
self.fold_item_recur(i)
};

i.and_then(|i| {
match i.inner {
// emptied modules have no need to exist
clean::ModuleItem(ref m)
if m.items.is_empty() &&
i.doc_value().is_none() => None,
_ => {
if self.update_retained {
self.retained.insert(i.def_id);
}
Some(i)
}
if let Some(ref i) = i {
if self.update_retained {
self.retained.insert(i.def_id);
}
})
}
i
}
}

Expand Down
20 changes: 11 additions & 9 deletions src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ fn _remove_var(k: &OsStr) {
/// An iterator that splits an environment variable into paths according to
/// platform-specific conventions.
///
/// This structure is created by the [`std::env::split_paths`] function See its
/// This structure is created by the [`std::env::split_paths`] function. See its
/// documentation for more.
///
/// [`std::env::split_paths`]: fn.split_paths.html
Expand Down Expand Up @@ -605,14 +605,15 @@ pub fn current_exe() -> io::Result<PathBuf> {
os_imp::current_exe()
}

/// An iterator over the arguments of a process, yielding a [`String`] value
/// for each argument.
/// An iterator over the arguments of a process, yielding a [`String`] value for
/// each argument.
///
/// This structure is created through the [`std::env::args`] function.
/// This struct is created by the [`std::env::args`] function. See its
/// documentation for more.
///
/// The first element is traditionally the path of the executable, but it can be
/// set to arbitrary text, and may not even exist. This means this property should
/// not be relied upon for security purposes.
/// set to arbitrary text, and may not even exist. This means this property
/// should not be relied upon for security purposes.
///
/// [`String`]: ../string/struct.String.html
/// [`std::env::args`]: ./fn.args.html
Expand All @@ -622,11 +623,12 @@ pub struct Args { inner: ArgsOs }
/// An iterator over the arguments of a process, yielding an [`OsString`] value
/// for each argument.
///
/// This structure is created through the [`std::env::args_os`] function.
/// This struct is created by the [`std::env::args_os`] function. See its
/// documentation for more.
///
/// The first element is traditionally the path of the executable, but it can be
/// set to arbitrary text, and may not even exist. This means this property should
/// not be relied upon for security purposes.
/// set to arbitrary text, and may not even exist. This means this property
/// should not be relied upon for security purposes.
///
/// [`OsString`]: ../ffi/struct.OsString.html
/// [`std::env::args_os`]: ./fn.args_os.html
Expand Down
7 changes: 7 additions & 0 deletions src/test/rustdoc/assoc-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-tidy-linelength

#![crate_type="lib"]

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

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

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

// @has assoc_types/fn.cmp_input.html
// @has - '//*[@class="rust fn"]' 'where T::Input: PartialEq<U::Input>'
// @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Feed.html#associatedtype.Input"]' 'Input'
pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool
where T::Input: PartialEq<U::Input>
{
Expand Down
27 changes: 27 additions & 0 deletions src/test/rustdoc/empty-mod-private.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-tidy-linelength
// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports

// @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo'
// @has 'empty_mod_private/sidebar-items.js' 'foo'
// @matches 'empty_mod_private/foo/index.html' '//h1' 'Module empty_mod_private::foo'
mod foo {}

// @has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar'
// @has 'empty_mod_private/sidebar-items.js' 'bar'
// @matches 'empty_mod_private/bar/index.html' '//h1' 'Module empty_mod_private::bar'
mod bar {
// @has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz'
// @has 'empty_mod_private/bar/sidebar-items.js' 'baz'
// @matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module empty_mod_private::bar::baz'
mod baz {}
}
24 changes: 24 additions & 0 deletions src/test/rustdoc/empty-mod-public.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// @has 'empty_mod_public/index.html' '//a[@href="foo/index.html"]' 'foo'
// @has 'empty_mod_public/sidebar-items.js' 'foo'
// @matches 'empty_mod_public/foo/index.html' '//h1' 'Module empty_mod_public::foo'
pub mod foo {}

// @has 'empty_mod_public/index.html' '//a[@href="bar/index.html"]' 'bar'
// @has 'empty_mod_public/sidebar-items.js' 'bar'
// @matches 'empty_mod_public/bar/index.html' '//h1' 'Module empty_mod_public::bar'
pub mod bar {
// @has 'empty_mod_public/bar/index.html' '//a[@href="baz/index.html"]' 'baz'
// @has 'empty_mod_public/bar/sidebar-items.js' 'baz'
// @matches 'empty_mod_public/bar/baz/index.html' '//h1' 'Module empty_mod_public::bar::baz'
pub mod baz {}
}