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 8 pull requests #83848

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e7f340e
BTree: move blocks around in node.rs
ssomers Feb 16, 2021
7f5964a
Add `download-rustc = "if-unchanged"`
jyn514 Mar 22, 2021
4f73d21
Fix compiletest on FreeBSD
asomers Mar 26, 2021
617e135
rustdoc: highlight macros more efficiently
notriddle Mar 15, 2021
f64038f
rustdoc: update macro highlight tests
notriddle Apr 3, 2021
8a05892
List trait impls before methods from deref in the sidebar of Rustdoc'…
slightlyoutofphase Apr 3, 2021
72502e8
Remove trailing whitespace
slightlyoutofphase Apr 3, 2021
13e482b
Remove unneeded INITIAL_IDS const
GuillaumeGomez Apr 3, 2021
3bd241f
cleanup leak after test to make miri happy
the8472 Apr 2, 2021
572873f
suggestion from review
the8472 Apr 3, 2021
a41d41c
Fix error codes check run and ensure it will not go unnoticed again
GuillaumeGomez Mar 24, 2021
92593a0
Rollup merge of #82726 - ssomers:btree_node_rearange, r=Mark-Simulacrum
GuillaumeGomez Apr 4, 2021
a604464
Rollup merge of #83368 - jyn514:download-if-unchanged, r=Mark-Simulacrum
GuillaumeGomez Apr 4, 2021
54b5f02
Rollup merge of #83451 - GuillaumeGomez:fix-error-code-tidy-check, r=…
GuillaumeGomez Apr 4, 2021
9a84a0c
Rollup merge of #83532 - asomers:gdb-fbsd, r=Mark-Simulacrum
GuillaumeGomez Apr 4, 2021
96659a9
Rollup merge of #83793 - notriddle:single-span-macro-highlight, r=Gui…
GuillaumeGomez Apr 4, 2021
4757d94
Rollup merge of #83809 - GuillaumeGomez:remove-initial-ids, r=camelid
GuillaumeGomez Apr 4, 2021
8e37df4
Rollup merge of #83826 - slightlyoutofphase:rustdoc-sidebar-order-shu…
GuillaumeGomez Apr 4, 2021
e00fb1c
Rollup merge of #83827 - the8472:fix-inplace-panic-on-drop, r=RalfJung
GuillaumeGomez Apr 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ changelog-seen = 2
# Whether to download the stage 1 and 2 compilers from CI.
# This is mostly useful for tools; if you have changes to `compiler/` they will be ignored.
#
# FIXME: currently, this also uses the downloaded compiler for stage0, but that causes unnecessary rebuilds.
# You can set this to "if-unchanged" to only download if `compiler/` has not been modified.
#
# FIXME(#82739): currently, this also uses the downloaded compiler for stage0, but that causes unnecessary rebuilds.
#download-rustc = false

# Number of codegen units to use for each compiler invocation. A value of 0
Expand Down
332 changes: 165 additions & 167 deletions library/alloc/src/collections/btree/node.rs

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion library/alloc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,12 +1078,21 @@ fn test_from_iter_specialization_panic_during_drop_leaks() {
}
}

let mut to_free: *mut Droppable = core::ptr::null_mut();
let mut cap = 0;

let _ = std::panic::catch_unwind(AssertUnwindSafe(|| {
let v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop];
let mut v = vec![Droppable::DroppedTwice(Box::new(123)), Droppable::PanicOnDrop];
to_free = v.as_mut_ptr();
cap = v.capacity();
let _ = v.into_iter().take(0).collect::<Vec<_>>();
}));

assert_eq!(unsafe { DROP_COUNTER }, 1);
// clean up the leak to keep miri happy
unsafe {
drop(Vec::from_raw_parts(to_free, 0, cap));
}
}

#[test]
Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,10 @@ def fix_bin_or_dylib(self, fname, rpath_libz=False):
# Return the stage1 compiler to download, if any.
def maybe_download_rustc(self):
# If `download-rustc` is not set, default to rebuilding.
if self.get_toml("download-rustc", section="rust") != "true":
download_rustc = self.get_toml("download-rustc", section="rust")
if download_rustc is None or download_rustc == "false":
return None
assert download_rustc == "true" or download_rustc == "if-unchanged", download_rustc

# Handle running from a directory other than the top level
rev_parse = ["git", "rev-parse", "--show-toplevel"]
Expand All @@ -656,6 +658,8 @@ def maybe_download_rustc(self):
# Warn if there were changes to the compiler since the ancestor commit.
status = subprocess.call(["git", "diff-index", "--quiet", commit, "--", compiler])
if status != 0:
if download_rustc == "if-unchanged":
return None
print("warning: `download-rustc` is enabled, but there are changes to compiler/")

return commit
Expand Down Expand Up @@ -1160,6 +1164,8 @@ def bootstrap(help_triggered):
env["RUSTC_BOOTSTRAP"] = '1'
if toml_path:
env["BOOTSTRAP_CONFIG"] = toml_path
if build.rustc_commit is not None:
env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1'
run(args, env=env, verbose=build.verbose)


Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ struct Rust {
new_symbol_mangling: Option<bool>,
profile_generate: Option<String>,
profile_use: Option<String>,
download_rustc: Option<bool>,
download_rustc: Option<String>,
}

/// TOML representation of how each build target is configured.
Expand Down Expand Up @@ -897,7 +897,7 @@ impl Config {
config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config);
config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use);
config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate);
config.download_rustc = rust.download_rustc.unwrap_or(false);
config.download_rustc = env::var("BOOTSTRAP_DOWNLOAD_RUSTC").as_deref() == Ok("1");
} else {
config.rust_profile_use = flags.rust_profile_use;
config.rust_profile_generate = flags.rust_profile_generate;
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ impl Options {
let edition = config::parse_crate_edition(&matches);

let mut id_map = html::markdown::IdMap::new();
id_map.populate(&html::render::INITIAL_IDS);
let external_html = match ExternalHtml::load(
&matches.opt_strs("html-in-header"),
&matches.opt_strs("html-before-content"),
Expand Down
8 changes: 6 additions & 2 deletions src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ impl<'a> Classifier<'a> {
// leading identifier.
TokenKind::Bang if self.in_macro => {
self.in_macro = false;
Class::Macro
sink(Highlight::Token { text, class: None });
sink(Highlight::ExitSpan);
return;
}

// Assume that '&' or '*' is the reference or dereference operator
Expand Down Expand Up @@ -298,7 +300,9 @@ impl<'a> Classifier<'a> {
},
TokenKind::Ident | TokenKind::RawIdent if lookahead == Some(TokenKind::Bang) => {
self.in_macro = true;
Class::Macro
sink(Highlight::EnterSpan { class: Class::Macro });
sink(Highlight::Token { text, class: None });
return;
}
TokenKind::Ident => match text {
"ref" | "mut" => Class::RefKeyWord,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/highlight/fixtures/dos_line.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">foo</span>() {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;foo&quot;</span>);
<span class="macro">println!</span>(<span class="string">&quot;foo&quot;</span>);
}
6 changes: 3 additions & 3 deletions src/librustdoc/html/highlight/fixtures/sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="kw-2">&amp;</span><span class="ident">foo</span>;
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="op">&amp;&amp;</span><span class="ident">foo</span>;
<span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="kw-2">*</span><span class="ident">foo</span>;
<span class="macro">mac</span><span class="macro">!</span>(<span class="ident">foo</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bar</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="self">self</span>.<span class="ident">length</span> <span class="op">&lt;</span> <span class="ident">N</span> <span class="op">&amp;&amp;</span> <span class="ident">index</span> <span class="op">&lt;</span><span class="op">=</span> <span class="self">self</span>.<span class="ident">length</span>);
<span class="macro">mac!</span>(<span class="ident">foo</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bar</span>);
<span class="macro">assert!</span>(<span class="self">self</span>.<span class="ident">length</span> <span class="op">&lt;</span> <span class="ident">N</span> <span class="op">&amp;&amp;</span> <span class="ident">index</span> <span class="op">&lt;</span><span class="op">=</span> <span class="self">self</span>.<span class="ident">length</span>);
}

<span class="macro">macro_rules</span><span class="macro">!</span> <span class="ident">bar</span> {
<span class="macro">macro_rules!</span> <span class="ident">bar</span> {
(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">foo</span>:<span class="ident">tt</span>) <span class="op">=</span><span class="op">&gt;</span> {};
}
</code></pre>
15 changes: 9 additions & 6 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,9 @@ fn init_id_map() -> FxHashMap<String, usize> {
map.insert("rustdoc-vars".to_owned(), 1);
map.insert("sidebar-vars".to_owned(), 1);
map.insert("copy-path".to_owned(), 1);
map.insert("help".to_owned(), 1);
map.insert("TOC".to_owned(), 1);
map.insert("render-detail".to_owned(), 1);
// This is the list of IDs used by rustdoc sections.
map.insert("fields".to_owned(), 1);
map.insert("variants".to_owned(), 1);
Expand All @@ -1365,6 +1368,12 @@ fn init_id_map() -> FxHashMap<String, usize> {
map.insert("trait-implementations".to_owned(), 1);
map.insert("synthetic-implementations".to_owned(), 1);
map.insert("blanket-implementations".to_owned(), 1);
map.insert("associated-types".to_owned(), 1);
map.insert("associated-const".to_owned(), 1);
map.insert("required-methods".to_owned(), 1);
map.insert("provided-methods".to_owned(), 1);
map.insert("implementors".to_owned(), 1);
map.insert("synthetic-implementors".to_owned(), 1);
map
}

Expand All @@ -1373,12 +1382,6 @@ impl IdMap {
IdMap { map: init_id_map() }
}

crate fn populate<I: IntoIterator<Item = S>, S: AsRef<str> + ToString>(&mut self, ids: I) {
for id in ids {
let _ = self.derive(id);
}
}

crate fn derive<S: AsRef<str> + ToString>(&mut self, candidate: S) -> String {
let id = match self.map.get_mut(candidate.as_ref()) {
None => candidate.to_string(),
Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::print_item::{full_path, item_path, print_item};
use super::write_shared::write_shared;
use super::{
print_sidebar, settings, AllTypes, NameDoc, SharedContext, StylePath, BASIC_KEYWORDS,
CURRENT_DEPTH, INITIAL_IDS,
CURRENT_DEPTH,
};

use crate::clean::{self, AttributesExt};
Expand Down Expand Up @@ -423,14 +423,11 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
}

fn make_child_renderer(&self) -> Self {
let mut id_map = IdMap::new();
id_map.populate(&INITIAL_IDS);

Self {
current: self.current.clone(),
dst: self.dst.clone(),
render_redirect_pages: self.render_redirect_pages,
id_map: RefCell::new(id_map),
id_map: RefCell::new(IdMap::new()),
deref_id_map: RefCell::new(FxHashMap::default()),
shared: Rc::clone(&self.shared),
cache: Rc::clone(&self.cache),
Expand Down
33 changes: 8 additions & 25 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,24 +283,6 @@ crate struct StylePath {

thread_local!(crate static CURRENT_DEPTH: Cell<usize> = Cell::new(0));

crate const INITIAL_IDS: [&'static str; 15] = [
"main",
"search",
"help",
"TOC",
"render-detail",
"associated-types",
"associated-const",
"required-methods",
"provided-methods",
"implementors",
"synthetic-implementors",
"implementors-list",
"synthetic-implementors-list",
"methods",
"implementations",
];

fn write_srclink(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
if let Some(l) = cx.src_href(item) {
write!(buf, "<a class=\"srclink\" href=\"{}\" title=\"goto source code\">[src]</a>", l)
Expand Down Expand Up @@ -1933,13 +1915,6 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
}

if v.iter().any(|i| i.inner_impl().trait_.is_some()) {
if let Some(impl_) = v
.iter()
.filter(|i| i.inner_impl().trait_.is_some())
.find(|i| i.inner_impl().trait_.def_id_full(cache) == cx.cache.deref_trait_did)
{
sidebar_deref_methods(cx, out, impl_, v);
}
let format_impls = |impls: Vec<&Impl>| {
let mut links = FxHashSet::default();

Expand Down Expand Up @@ -2007,6 +1982,14 @@ fn sidebar_assoc_items(cx: &Context<'_>, out: &mut Buffer, it: &clean::Item) {
);
write_sidebar_links(out, blanket_format);
}

if let Some(impl_) = v
.iter()
.filter(|i| i.inner_impl().trait_.is_some())
.find(|i| i.inner_impl().trait_.def_id_full(cache) == cx.cache.deref_trait_did)
{
sidebar_deref_methods(cx, out, impl_, v);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,8 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
// This particular form is documented in the GNU coding standards:
// https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion

let mut splits = full_version_line.rsplit(' ');
let unbracketed_part = full_version_line.split('[').next().unwrap();
let mut splits = unbracketed_part.trim_end().rsplit(' ');
let version_string = splits.next().unwrap();

let mut splits = version_string.split('.');
Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ fn test_extract_gdb_version() {
7012000: "GNU gdb (GDB) 7.12",
7012000: "GNU gdb (GDB) 7.12.20161027-git",
7012050: "GNU gdb (GDB) 7.12.50.20161027-git",

9002000: "GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2",
10001000: "GNU gdb (GDB) 10.1 [GDB v10.1 for FreeBSD]",
}
}

Expand Down
40 changes: 28 additions & 12 deletions src/tools/tidy/src/error_codes_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ fn check_error_code_explanation(
}

fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool {
let mut ignore_found = false;

for line in f.lines() {
let s = line.trim();
if s.starts_with("#### Note: this error code is no longer emitted by the compiler") {
Expand All @@ -56,13 +58,13 @@ fn check_if_error_code_is_test_in_explanation(f: &str, err_code: &str) -> bool {
if s.starts_with("```") {
if s.contains("compile_fail") && s.contains(err_code) {
return true;
} else if s.contains('(') {
} else if s.contains("ignore") {
// It's very likely that we can't actually make it fail compilation...
return true;
ignore_found = true;
}
}
}
false
ignore_found
}

macro_rules! some_or_continue {
Expand Down Expand Up @@ -164,18 +166,32 @@ fn extract_error_codes_from_tests(f: &str, error_codes: &mut HashMap<String, boo
}
}

pub fn check(path: &Path, bad: &mut bool) {
pub fn check(paths: &[&Path], bad: &mut bool) {
let mut errors = Vec::new();
let mut found_explanations = 0;
let mut found_tests = 0;
println!("Checking which error codes lack tests...");
let mut error_codes: HashMap<String, bool> = HashMap::new();
super::walk(path, &mut |path| super::filter_dirs(path), &mut |entry, contents| {
let file_name = entry.file_name();
if file_name == "error_codes.rs" {
extract_error_codes(contents, &mut error_codes, entry.path(), &mut errors);
} else if entry.path().extension() == Some(OsStr::new("stderr")) {
extract_error_codes_from_tests(contents, &mut error_codes);
}
});
for path in paths {
super::walk(path, &mut |path| super::filter_dirs(path), &mut |entry, contents| {
let file_name = entry.file_name();
if file_name == "error_codes.rs" {
extract_error_codes(contents, &mut error_codes, entry.path(), &mut errors);
found_explanations += 1;
} else if entry.path().extension() == Some(OsStr::new("stderr")) {
extract_error_codes_from_tests(contents, &mut error_codes);
found_tests += 1;
}
});
}
if found_explanations == 0 {
eprintln!("No error code explanation was tested!");
*bad = true;
}
if found_tests == 0 {
eprintln!("No error code was found in compilation errors!");
*bad = true;
}
if errors.is_empty() {
println!("Found {} error codes", error_codes.len());

Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() {

// Checks that only make sense for the compiler.
check!(errors, &compiler_path);
check!(error_codes_check, &src_path);
check!(error_codes_check, &[&src_path, &compiler_path]);

// Checks that only make sense for the std libs.
check!(pal, &library_path);
Expand Down