merge with master to pick up pulldown switch
This commit is contained in:
commit
8dd4c44ef6
1196 changed files with 28940 additions and 37303 deletions
|
@ -60,6 +60,7 @@ use rustc::middle::privacy::AccessLevels;
|
|||
use rustc::middle::stability;
|
||||
use rustc::hir;
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use rustc::session::config::nightly_options::is_nightly_build;
|
||||
use rustc_data_structures::flock;
|
||||
|
||||
use clean::{self, AttributesExt, GetDefId, SelfTy, Mutability};
|
||||
|
@ -71,7 +72,7 @@ use html::format::{TyParamBounds, WhereClause, href, AbiSpace};
|
|||
use html::format::{VisSpace, Method, UnsafetySpace, MutableSpace};
|
||||
use html::format::fmt_impl_for_trait_page;
|
||||
use html::item_type::ItemType;
|
||||
use html::markdown::{self, Markdown, MarkdownHtml};
|
||||
use html::markdown::{self, Markdown, MarkdownHtml, MarkdownSummaryLine};
|
||||
use html::{highlight, layout};
|
||||
|
||||
/// A pair of name and its optional document.
|
||||
|
@ -1649,7 +1650,8 @@ fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLin
|
|||
} else {
|
||||
format!("{}", &plain_summary_line(Some(s)))
|
||||
};
|
||||
write!(w, "<div class='docblock'>{}</div>", Markdown(&markdown))?;
|
||||
write!(w, "<div class='docblock'>{}</div>",
|
||||
Markdown(&markdown))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1699,6 +1701,23 @@ fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item)
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn name_key(name: &str) -> (&str, u64, usize) {
|
||||
// find number at end
|
||||
let split = name.bytes().rposition(|b| b < b'0' || b'9' < b).map_or(0, |s| s + 1);
|
||||
|
||||
// count leading zeroes
|
||||
let after_zeroes =
|
||||
name[split..].bytes().position(|b| b != b'0').map_or(name.len(), |extra| split + extra);
|
||||
|
||||
// sort leading zeroes last
|
||||
let num_zeroes = after_zeroes - split;
|
||||
|
||||
match name[split..].parse() {
|
||||
Ok(n) => (&name[..split], n, num_zeroes),
|
||||
Err(_) => (name, 0, num_zeroes),
|
||||
}
|
||||
}
|
||||
|
||||
fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||
item: &clean::Item, items: &[clean::Item]) -> fmt::Result {
|
||||
document(w, cx, item)?;
|
||||
|
@ -1743,7 +1762,9 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
|||
(Some(stability::Stable), Some(stability::Unstable)) => return Ordering::Less,
|
||||
_ => {}
|
||||
}
|
||||
i1.name.cmp(&i2.name)
|
||||
let lhs = i1.name.as_ref().map_or("", |s| &**s);
|
||||
let rhs = i2.name.as_ref().map_or("", |s| &**s);
|
||||
name_key(lhs).cmp(&name_key(rhs))
|
||||
}
|
||||
|
||||
indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2));
|
||||
|
@ -1851,7 +1872,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
|||
</tr>",
|
||||
name = *myitem.name.as_ref().unwrap(),
|
||||
stab_docs = stab_docs,
|
||||
docs = shorter(Some(&Markdown(doc_value).to_string())),
|
||||
docs = MarkdownSummaryLine(doc_value),
|
||||
class = myitem.type_(),
|
||||
stab = myitem.stability_class().unwrap_or("".to_string()),
|
||||
unsafety_flag = unsafety_flag,
|
||||
|
@ -2331,9 +2352,10 @@ fn render_assoc_item(w: &mut fmt::Formatter,
|
|||
}
|
||||
};
|
||||
// FIXME(#24111): remove when `const_fn` is stabilized
|
||||
let vis_constness = match UnstableFeatures::from_environment() {
|
||||
UnstableFeatures::Allow => constness,
|
||||
_ => hir::Constness::NotConst
|
||||
let vis_constness = if is_nightly_build() {
|
||||
constness
|
||||
} else {
|
||||
hir::Constness::NotConst
|
||||
};
|
||||
let mut head_len = format!("{}{}{:#}fn {}{:#}",
|
||||
ConstnessSpace(vis_constness),
|
||||
|
@ -2605,7 +2627,7 @@ fn render_attribute(attr: &ast::MetaItem) -> Option<String> {
|
|||
if attr.is_word() {
|
||||
Some(format!("{}", name))
|
||||
} else if let Some(v) = attr.value_str() {
|
||||
Some(format!("{} = {:?}", name, &v.as_str()[..]))
|
||||
Some(format!("{} = {:?}", name, v.as_str()))
|
||||
} else if let Some(values) = attr.meta_item_list() {
|
||||
let display: Vec<_> = values.iter().filter_map(|attr| {
|
||||
attr.meta_item().and_then(|mi| render_attribute(mi))
|
||||
|
@ -2635,11 +2657,11 @@ fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
|
|||
let mut attrs = String::new();
|
||||
|
||||
for attr in &it.attrs.other_attrs {
|
||||
let name = attr.name();
|
||||
if !ATTRIBUTE_WHITELIST.contains(&&name.as_str()[..]) {
|
||||
let name = attr.name().unwrap();
|
||||
if !ATTRIBUTE_WHITELIST.contains(&&*name.as_str()) {
|
||||
continue;
|
||||
}
|
||||
if let Some(s) = render_attribute(attr.meta()) {
|
||||
if let Some(s) = render_attribute(&attr.meta().unwrap()) {
|
||||
attrs.push_str(&format!("#[{}]\n", s));
|
||||
}
|
||||
}
|
||||
|
@ -2804,7 +2826,7 @@ fn render_assoc_items(w: &mut fmt::Formatter,
|
|||
}
|
||||
AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => {
|
||||
write!(w, "<h2 id='deref-methods'>Methods from \
|
||||
{}<Target={}></h2>", trait_, type_)?;
|
||||
{}<Target = {}></h2>", trait_, type_)?;
|
||||
RenderMode::ForDeref { mut_: deref_mut_ }
|
||||
}
|
||||
};
|
||||
|
@ -3193,3 +3215,32 @@ fn test_unique_id() {
|
|||
reset_ids(true);
|
||||
test();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_name_key() {
|
||||
assert_eq!(name_key("0"), ("", 0, 1));
|
||||
assert_eq!(name_key("123"), ("", 123, 0));
|
||||
assert_eq!(name_key("Fruit"), ("Fruit", 0, 0));
|
||||
assert_eq!(name_key("Fruit0"), ("Fruit", 0, 1));
|
||||
assert_eq!(name_key("Fruit0000"), ("Fruit", 0, 4));
|
||||
assert_eq!(name_key("Fruit01"), ("Fruit", 1, 1));
|
||||
assert_eq!(name_key("Fruit10"), ("Fruit", 10, 0));
|
||||
assert_eq!(name_key("Fruit123"), ("Fruit", 123, 0));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_name_sorting() {
|
||||
let names = ["Apple",
|
||||
"Banana",
|
||||
"Fruit", "Fruit0", "Fruit00",
|
||||
"Fruit1", "Fruit01",
|
||||
"Fruit2", "Fruit02",
|
||||
"Fruit20",
|
||||
"Fruit100",
|
||||
"Pear"];
|
||||
let mut sorted = names.to_owned();
|
||||
sorted.sort_by_key(|&s| name_key(s));
|
||||
assert_eq!(names, sorted);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue