Auto merge of #54457 - pietroalbini:rollup, r=pietroalbini

Rollup of 16 pull requests

Successful merges:

 - #53652 (define copy_within on slices)
 - #54261 (Make `dyn` a keyword in the 2018 edition)
 - #54280 (remove (more) CAS API from Atomic* types where not natively supported)
 - #54323 (rustbuild: drop color handling)
 - #54350 (Support specifying edition in doc test)
 - #54370 (Improve handling of type bounds in `bit_set.rs`.)
 - #54371 (add -Zui-testing to rustdoc)
 - #54374 (Make 'proc_macro::MultiSpan' public.)
 - #54402 (Use no_default_libraries for all NetBSD flavors)
 - #54409 (Detect `for _ in in bar {}` typo)
 - #54412 (add applicability to span_suggestion call)
 - #54413 (Add UI test for deref recursion limit printing twice)
 - #54415 (parser: Tweak function parameter parsing to avoid rollback on succesfull path)
 - #54420 (Compress `Liveness` data some more.)
 - #54422 (Simplify slice's first(_mut) and last(_mut) with get)
 - #54446 (Unify christianpoveda's emails)

Failed merges:

 - #54058 (Introduce the partition_dedup/by/by_key methods for slices)

r? @ghost
This commit is contained in:
bors 2018-09-22 14:26:15 +00:00
commit af50e3822c
44 changed files with 911 additions and 446 deletions

View file

@ -272,6 +272,7 @@ impl DocAccessLevels for AccessLevels<DefId> {
pub fn new_handler(error_format: ErrorOutputType,
source_map: Option<Lrc<source_map::SourceMap>>,
treat_err_as_bug: bool,
ui_testing: bool,
) -> errors::Handler {
// rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
// stick to the defaults
@ -283,7 +284,7 @@ pub fn new_handler(error_format: ErrorOutputType,
source_map.map(|cm| cm as _),
false,
sessopts.debugging_opts.teach,
).ui_testing(sessopts.debugging_opts.ui_testing)
).ui_testing(ui_testing)
),
ErrorOutputType::Json(pretty) => {
let source_map = source_map.unwrap_or_else(
@ -293,7 +294,7 @@ pub fn new_handler(error_format: ErrorOutputType,
None,
source_map,
pretty,
).ui_testing(sessopts.debugging_opts.ui_testing)
).ui_testing(ui_testing)
)
},
ErrorOutputType::Short(color_config) => Box::new(
@ -335,6 +336,7 @@ pub fn run_core(search_paths: SearchPaths,
mut manual_passes: Vec<String>,
mut default_passes: passes::DefaultPassOption,
treat_err_as_bug: bool,
ui_testing: bool,
) -> (clean::Crate, RenderInfo, Vec<String>) {
// Parse, resolve, and typecheck the given crate.
@ -389,6 +391,8 @@ pub fn run_core(search_paths: SearchPaths,
actually_rustdoc: true,
debugging_opts: config::DebuggingOptions {
force_unstable_if_unmarked,
treat_err_as_bug,
ui_testing,
..config::basic_debugging_options()
},
error_format,
@ -400,7 +404,8 @@ pub fn run_core(search_paths: SearchPaths,
let source_map = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping()));
let diagnostic_handler = new_handler(error_format,
Some(source_map.clone()),
treat_err_as_bug);
treat_err_as_bug,
ui_testing);
let mut sess = session::build_session_(
sessopts, cpath, diagnostic_handler, source_map,

View file

@ -37,6 +37,7 @@ use std::fmt::{self, Write};
use std::borrow::Cow;
use std::ops::Range;
use std::str;
use syntax::edition::Edition;
use html::toc::TocBuilder;
use html::highlight;
@ -170,6 +171,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'a, I> {
let event = self.inner.next();
let compile_fail;
let ignore;
let edition;
if let Some(Event::Start(Tag::CodeBlock(lang))) = event {
let parse_result = LangString::parse(&lang, self.check_error_codes);
if !parse_result.rust {
@ -177,6 +179,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'a, I> {
}
compile_fail = parse_result.compile_fail;
ignore = parse_result.ignore;
edition = parse_result.edition;
} else {
return event;
}
@ -212,6 +215,17 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'a, I> {
} else {
""
};
let edition_string = if let Some(e @ Edition::Edition2018) = edition {
format!("&amp;edition={}{}", e,
if channel == "&amp;version=nightly" { "" }
else { "&amp;version=nightly" })
} else if let Some(e) = edition {
format!("&amp;edition={}", e)
} else {
"".to_owned()
};
// These characters don't need to be escaped in a URI.
// FIXME: use a library function for percent encoding.
fn dont_escape(c: u8) -> bool {
@ -231,26 +245,44 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'a, I> {
}
}
Some(format!(
r#"<a class="test-arrow" target="_blank" href="{}?code={}{}">Run</a>"#,
url, test_escaped, channel
r#"<a class="test-arrow" target="_blank" href="{}?code={}{}{}">Run</a>"#,
url, test_escaped, channel, edition_string
))
});
let tooltip = if ignore {
Some(("This example is not tested", "ignore"))
Some(("This example is not tested".to_owned(), "ignore"))
} else if compile_fail {
Some(("This example deliberately fails to compile", "compile_fail"))
Some(("This example deliberately fails to compile".to_owned(), "compile_fail"))
} else if let Some(e) = edition {
Some((format!("This code runs with edition {}", e), "edition"))
} else {
None
};
s.push_str(&highlight::render_with_highlighting(
&text,
Some(&format!("rust-example-rendered{}",
if ignore { " ignore" }
else if compile_fail { " compile_fail" }
else { "" })),
playground_button.as_ref().map(String::as_str),
tooltip));
Some(Event::Html(s.into()))
if let Some((s1, s2)) = tooltip {
s.push_str(&highlight::render_with_highlighting(
&text,
Some(&format!("rust-example-rendered{}",
if ignore { " ignore" }
else if compile_fail { " compile_fail" }
else if edition.is_some() { " edition " }
else { "" })),
playground_button.as_ref().map(String::as_str),
Some((s1.as_str(), s2))));
Some(Event::Html(s.into()))
} else {
s.push_str(&highlight::render_with_highlighting(
&text,
Some(&format!("rust-example-rendered{}",
if ignore { " ignore" }
else if compile_fail { " compile_fail" }
else if edition.is_some() { " edition " }
else { "" })),
playground_button.as_ref().map(String::as_str),
None));
Some(Event::Html(s.into()))
}
})
}
}
@ -577,6 +609,7 @@ pub struct LangString {
pub compile_fail: bool,
pub error_codes: Vec<String>,
pub allow_fail: bool,
pub edition: Option<Edition>
}
impl LangString {
@ -591,6 +624,7 @@ impl LangString {
compile_fail: false,
error_codes: Vec::new(),
allow_fail: false,
edition: None,
}
}
@ -625,6 +659,11 @@ impl LangString {
seen_rust_tags = !seen_other_tags || seen_rust_tags;
data.no_run = true;
}
x if allow_error_code_check && x.starts_with("edition") => {
// allow_error_code_check is true if we're on nightly, which
// is needed for edition support
data.edition = x[7..].parse::<Edition>().ok();
}
x if allow_error_code_check && x.starts_with("E") && x.len() == 5 => {
if x[1..].parse::<u32>().is_ok() {
data.error_codes.push(x.to_owned());
@ -925,12 +964,14 @@ mod tests {
use super::{ErrorCodes, LangString, Markdown, MarkdownHtml, IdMap};
use super::plain_summary_line;
use std::cell::RefCell;
use syntax::edition::Edition;
#[test]
fn test_lang_string_parse() {
fn t(s: &str,
should_panic: bool, no_run: bool, ignore: bool, rust: bool, test_harness: bool,
compile_fail: bool, allow_fail: bool, error_codes: Vec<String>) {
compile_fail: bool, allow_fail: bool, error_codes: Vec<String>,
edition: Option<Edition>) {
assert_eq!(LangString::parse(s, ErrorCodes::Yes), LangString {
should_panic,
no_run,
@ -941,6 +982,7 @@ mod tests {
error_codes,
original: s.to_owned(),
allow_fail,
edition,
})
}
@ -948,23 +990,26 @@ mod tests {
Vec::new()
}
// marker | should_panic| no_run| ignore| rust | test_harness| compile_fail
// | allow_fail | error_codes
t("", false, false, false, true, false, false, false, v());
t("rust", false, false, false, true, false, false, false, v());
t("sh", false, false, false, false, false, false, false, v());
t("ignore", false, false, true, true, false, false, false, v());
t("should_panic", true, false, false, true, false, false, false, v());
t("no_run", false, true, false, true, false, false, false, v());
t("test_harness", false, false, false, true, true, false, false, v());
t("compile_fail", false, true, false, true, false, true, false, v());
t("allow_fail", false, false, false, true, false, false, true, v());
t("{.no_run .example}", false, true, false, true, false, false, false, v());
t("{.sh .should_panic}", true, false, false, false, false, false, false, v());
t("{.example .rust}", false, false, false, true, false, false, false, v());
t("{.test_harness .rust}", false, false, false, true, true, false, false, v());
t("text, no_run", false, true, false, false, false, false, false, v());
t("text,no_run", false, true, false, false, false, false, false, v());
// ignore-tidy-linelength
// marker | should_panic | no_run | ignore | rust | test_harness
// | compile_fail | allow_fail | error_codes | edition
t("", false, false, false, true, false, false, false, v(), None);
t("rust", false, false, false, true, false, false, false, v(), None);
t("sh", false, false, false, false, false, false, false, v(), None);
t("ignore", false, false, true, true, false, false, false, v(), None);
t("should_panic", true, false, false, true, false, false, false, v(), None);
t("no_run", false, true, false, true, false, false, false, v(), None);
t("test_harness", false, false, false, true, true, false, false, v(), None);
t("compile_fail", false, true, false, true, false, true, false, v(), None);
t("allow_fail", false, false, false, true, false, false, true, v(), None);
t("{.no_run .example}", false, true, false, true, false, false, false, v(), None);
t("{.sh .should_panic}", true, false, false, false, false, false, false, v(), None);
t("{.example .rust}", false, false, false, true, false, false, false, v(), None);
t("{.test_harness .rust}", false, false, false, true, true, false, false, v(), None);
t("text, no_run", false, true, false, false, false, false, false, v(), None);
t("text,no_run", false, true, false, false, false, false, false, v(), None);
t("edition2015", false, false, false, true, false, false, false, v(), Some(Edition::Edition2015));
t("edition2018", false, false, false, true, false, false, false, v(), Some(Edition::Edition2018));
}
#[test]

View file

@ -409,8 +409,11 @@ fn main_args(args: &[String]) -> isize {
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
*x == "treat-err-as-bug"
});
let ui_testing = matches.opt_strs("Z").iter().any(|x| {
*x == "ui-testing"
});
let diag = core::new_handler(error_format, None, treat_err_as_bug);
let diag = core::new_handler(error_format, None, treat_err_as_bug, ui_testing);
// check for deprecated options
check_deprecated_options(&matches, &diag);
@ -565,7 +568,7 @@ fn main_args(args: &[String]) -> isize {
let res = acquire_input(PathBuf::from(input), externs, edition, cg, &matches, error_format,
move |out| {
let Output { krate, passes, renderinfo } = out;
let diag = core::new_handler(error_format, None, treat_err_as_bug);
let diag = core::new_handler(error_format, None, treat_err_as_bug, ui_testing);
info!("going to format");
match output_format.as_ref().map(|s| &**s) {
Some("html") | None => {
@ -702,6 +705,9 @@ where R: 'static + Send,
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
*x == "treat-err-as-bug"
});
let ui_testing = matches.opt_strs("Z").iter().any(|x| {
*x == "ui-testing"
});
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
@ -715,7 +721,7 @@ where R: 'static + Send,
display_warnings, crate_name.clone(),
force_unstable_if_unmarked, edition, cg, error_format,
lint_opts, lint_cap, describe_lints, manual_passes, default_passes,
treat_err_as_bug);
treat_err_as_bug, ui_testing);
info!("finished with rustc");

View file

@ -545,7 +545,7 @@ impl Collector {
let opts = self.opts.clone();
let maybe_sysroot = self.maybe_sysroot.clone();
let linker = self.linker.clone();
let edition = self.edition;
let edition = config.edition.unwrap_or(self.edition);
debug!("Creating test {}: {}", name, test);
self.tests.push(testing::TestDescAndFn {
desc: testing::TestDesc {