From 39260d9016db6925414541ad2dce6502dded3a64 Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Wed, 21 Aug 2019 14:10:40 +0200 Subject: [PATCH 01/25] make abs, wrapping_abs, and overflowing_abs const functions --- src/libcore/num/mod.rs | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index b46e06f8d8ada..df1c00ccd184f 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1401,12 +1401,8 @@ $EndFeature, " ```"), #[stable(feature = "no_panic_abs", since = "1.13.0")] #[inline] - pub fn wrapping_abs(self) -> Self { - if self.is_negative() { - self.wrapping_neg() - } else { - self - } + pub const fn wrapping_abs(self) -> Self { + (self ^ (self >> ($BITS - 1))).wrapping_sub(self >> ($BITS - 1)) } } @@ -1764,12 +1760,8 @@ $EndFeature, " ```"), #[stable(feature = "no_panic_abs", since = "1.13.0")] #[inline] - pub fn overflowing_abs(self) -> (Self, bool) { - if self.is_negative() { - self.overflowing_neg() - } else { - (self, false) - } + pub const fn overflowing_abs(self) -> (Self, bool) { + (self ^ (self >> ($BITS - 1))).overflowing_sub(self >> ($BITS - 1)) } } @@ -1973,15 +1965,11 @@ $EndFeature, " #[stable(feature = "rust1", since = "1.0.0")] #[inline] #[rustc_inherit_overflow_checks] - pub fn abs(self) -> Self { - if self.is_negative() { - // Note that the #[inline] above means that the overflow - // semantics of this negation depend on the crate we're being - // inlined into. - -self - } else { - self - } + pub const fn abs(self) -> Self { + // Note that the #[inline] above means that the overflow + // semantics of the subtraction depend on the crate we're being + // inlined into. + (self ^ (self >> ($BITS - 1))) - (self >> ($BITS - 1)) } } From adee559659774054497fc36afea0076c334c0bb2 Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Wed, 21 Aug 2019 15:40:12 +0200 Subject: [PATCH 02/25] test const abs, wrapping_abs, and overflowing_abs --- src/test/ui/consts/const-int-overflowing-rpass.rs | 8 ++++++++ src/test/ui/consts/const-int-sign-rpass.rs | 6 ++++++ src/test/ui/consts/const-int-wrapping-rpass.rs | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/src/test/ui/consts/const-int-overflowing-rpass.rs b/src/test/ui/consts/const-int-overflowing-rpass.rs index b619c7908aa22..9be87a6447cda 100644 --- a/src/test/ui/consts/const-int-overflowing-rpass.rs +++ b/src/test/ui/consts/const-int-overflowing-rpass.rs @@ -18,6 +18,10 @@ const SHR_B: (u32, bool) = 0x10u32.overflowing_shr(132); const NEG_A: (u32, bool) = 0u32.overflowing_neg(); const NEG_B: (u32, bool) = core::u32::MAX.overflowing_neg(); +const ABS_POS: (i32, bool) = 10i32.overflowing_abs(); +const ABS_NEG: (i32, bool) = (-10i32).overflowing_abs(); +const ABS_MIN: (i32, bool) = i32::min_value().overflowing_abs(); + fn main() { assert_eq!(ADD_A, (7, false)); assert_eq!(ADD_B, (0, true)); @@ -36,4 +40,8 @@ fn main() { assert_eq!(NEG_A, (0, false)); assert_eq!(NEG_B, (1, true)); + + assert_eq!(ABS_POS, (10, false)); + assert_eq!(ABS_NEG, (10, false)); + assert_eq!(ABS_MIN, (i32::min_value(), true)); } diff --git a/src/test/ui/consts/const-int-sign-rpass.rs b/src/test/ui/consts/const-int-sign-rpass.rs index 05726cb228647..dc46fce39a93c 100644 --- a/src/test/ui/consts/const-int-sign-rpass.rs +++ b/src/test/ui/consts/const-int-sign-rpass.rs @@ -11,6 +11,9 @@ const SIGNUM_POS: i32 = 10i32.signum(); const SIGNUM_NIL: i32 = 0i32.signum(); const SIGNUM_NEG: i32 = (-42i32).signum(); +const ABS_A: i32 = 10i32.abs(); +const ABS_B: i32 = (-10i32).abs(); + fn main() { assert!(NEGATIVE_A); assert!(!NEGATIVE_B); @@ -20,4 +23,7 @@ fn main() { assert_eq!(SIGNUM_POS, 1); assert_eq!(SIGNUM_NIL, 0); assert_eq!(SIGNUM_NEG, -1); + + assert_eq!(ABS_A, 10); + assert_eq!(ABS_B, 10); } diff --git a/src/test/ui/consts/const-int-wrapping-rpass.rs b/src/test/ui/consts/const-int-wrapping-rpass.rs index 73147d7912d19..2bbad99a52a90 100644 --- a/src/test/ui/consts/const-int-wrapping-rpass.rs +++ b/src/test/ui/consts/const-int-wrapping-rpass.rs @@ -18,6 +18,10 @@ const SHR_B: u32 = 128u32.wrapping_shr(128); const NEG_A: u32 = 5u32.wrapping_neg(); const NEG_B: u32 = 1234567890u32.wrapping_neg(); +const ABS_POS: i32 = 10i32.wrapping_abs(); +const ABS_NEG: i32 = (-10i32).wrapping_abs(); +const ABS_MIN: i32 = i32::min_value().wrapping_abs(); + fn main() { assert_eq!(ADD_A, 255); assert_eq!(ADD_B, 199); @@ -36,4 +40,8 @@ fn main() { assert_eq!(NEG_A, 4294967291); assert_eq!(NEG_B, 3060399406); + + assert_eq!(ABS_POS, 10); + assert_eq!(ABS_NEG, 10); + assert_eq!(ABS_MIN, i32::min_value()); } From 925a766bc0d34f8808e9902c47bea54b09540774 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Wed, 28 Aug 2019 20:28:42 -0700 Subject: [PATCH 03/25] Add Yaah to clippy toolstain notification list --- src/tools/publish_toolstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/publish_toolstate.py b/src/tools/publish_toolstate.py index 1411f4c0b05a2..2e2505b7f0246 100755 --- a/src/tools/publish_toolstate.py +++ b/src/tools/publish_toolstate.py @@ -22,7 +22,7 @@ # List of people to ping when the status of a tool or a book changed. MAINTAINERS = { 'miri': '@oli-obk @RalfJung @eddyb', - 'clippy-driver': '@Manishearth @llogiq @mcarton @oli-obk @phansch @flip1995', + 'clippy-driver': '@Manishearth @llogiq @mcarton @oli-obk @phansch @flip1995 @yaahc', 'rls': '@Xanewok', 'rustfmt': '@topecongiro', 'book': '@carols10cents @steveklabnik', From 98bd8fd88c3750cfc33b6ae56a0ff1078940bdc6 Mon Sep 17 00:00:00 2001 From: Dario Gonzalez Date: Fri, 26 Apr 2019 13:52:56 -0700 Subject: [PATCH 04/25] Added ability to crosscompile doctests --- src/librustdoc/config.rs | 10 ++++++ src/librustdoc/html/markdown.rs | 34 +++++++++++++++++---- src/librustdoc/html/markdown/tests.rs | 44 ++++++++++++++------------- src/librustdoc/lib.rs | 12 ++++++++ src/librustdoc/test.rs | 42 +++++++++++++++++++++---- 5 files changed, 109 insertions(+), 33 deletions(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index d261408fc148a..6d1258fe3a390 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -77,6 +77,10 @@ pub struct Options { /// Optional path to persist the doctest executables to, defaults to a /// temporary directory if not set. pub persist_doctests: Option, + /// Runtool to run doctests with + pub runtool: Option, + /// Arguments to pass to the runtool + pub runtool_args: Vec, // Options that affect the documentation process @@ -140,6 +144,8 @@ impl fmt::Debug for Options { .field("show_coverage", &self.show_coverage) .field("crate_version", &self.crate_version) .field("render_options", &self.render_options) + .field("runtool", &self.runtool) + .field("runtool_args", &self.runtool_args) .finish() } } @@ -466,6 +472,8 @@ impl Options { let codegen_options_strs = matches.opt_strs("C"); let lib_strs = matches.opt_strs("L"); let extern_strs = matches.opt_strs("extern"); + let runtool = matches.opt_str("runtool"); + let runtool_args = matches.opt_strs("runtool-arg"); let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format); @@ -496,6 +504,8 @@ impl Options { show_coverage, crate_version, persist_doctests, + runtool, + runtool_args, render_options: RenderOptions { output, external_html, diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 74413a7f905d4..45f2efd411fae 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -272,7 +272,7 @@ impl<'a, I: Iterator>> Iterator for CodeBlocks<'_, 'a, I> { )) }); - let tooltip = if ignore { + let tooltip = if ignore != Ignore::None { Some(("This example is not tested".to_owned(), "ignore")) } else if compile_fail { Some(("This example deliberately fails to compile".to_owned(), "compile_fail")) @@ -286,7 +286,7 @@ impl<'a, I: Iterator>> Iterator for CodeBlocks<'_, 'a, I> { s.push_str(&highlight::render_with_highlighting( &text, Some(&format!("rust-example-rendered{}", - if ignore { " ignore" } + if ignore != Ignore::None { " ignore" } else if compile_fail { " compile_fail" } else if explicit_edition { " edition " } else { "" })), @@ -297,7 +297,7 @@ impl<'a, I: Iterator>> Iterator for CodeBlocks<'_, 'a, I> { s.push_str(&highlight::render_with_highlighting( &text, Some(&format!("rust-example-rendered{}", - if ignore { " ignore" } + if ignore != Ignore::None { " ignore" } else if compile_fail { " compile_fail" } else if explicit_edition { " edition " } else { "" })), @@ -607,7 +607,7 @@ pub struct LangString { original: String, pub should_panic: bool, pub no_run: bool, - pub ignore: bool, + pub ignore: Ignore, pub rust: bool, pub test_harness: bool, pub compile_fail: bool, @@ -616,13 +616,20 @@ pub struct LangString { pub edition: Option } +#[derive(Eq, PartialEq, Clone, Debug)] +pub enum Ignore { + All, + None, + Some(Vec), +} + impl LangString { fn all_false() -> LangString { LangString { original: String::new(), should_panic: false, no_run: false, - ignore: false, + ignore: Ignore::None, rust: true, // NB This used to be `notrust = false` test_harness: false, compile_fail: false, @@ -637,6 +644,7 @@ impl LangString { let mut seen_rust_tags = false; let mut seen_other_tags = false; let mut data = LangString::all_false(); + let mut ignores = vec![]; data.original = string.to_owned(); let tokens = string.split(|c: char| @@ -651,7 +659,11 @@ impl LangString { seen_rust_tags = seen_other_tags == false; } "no_run" => { data.no_run = true; seen_rust_tags = !seen_other_tags; } - "ignore" => { data.ignore = true; seen_rust_tags = !seen_other_tags; } + "ignore" => { data.ignore = Ignore::All; seen_rust_tags = !seen_other_tags; } + x if x.starts_with("ignore-") => { + ignores.push(x.trim_start_matches("ignore-").to_owned()); + seen_rust_tags = !seen_other_tags; + } "allow_fail" => { data.allow_fail = true; seen_rust_tags = !seen_other_tags; } "rust" => { data.rust = true; seen_rust_tags = true; } "test_harness" => { @@ -680,6 +692,16 @@ impl LangString { } } + match data.ignore { + Ignore::All => {}, + Ignore::None => { + if !ignores.is_empty() { + data.ignore = Ignore::Some(ignores); + } + }, + _ => unreachable!(), + } + data.rust &= !seen_other_tags || seen_rust_tags; data diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index a95c29038d46f..5d6811a29a3eb 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -1,4 +1,4 @@ -use super::{ErrorCodes, LangString, Markdown, MarkdownHtml, IdMap}; +use super::{ErrorCodes, LangString, Markdown, MarkdownHtml, IdMap, Ignore}; use super::plain_summary_line; use std::cell::RefCell; use syntax::edition::{Edition, DEFAULT_EDITION}; @@ -26,10 +26,10 @@ fn test_unique_id() { #[test] fn test_lang_string_parse() { fn t(s: &str, - should_panic: bool, no_run: bool, ignore: bool, rust: bool, test_harness: bool, + should_panic: bool, no_run: bool, ignore: Ignore, rust: bool, test_harness: bool, compile_fail: bool, allow_fail: bool, error_codes: Vec, - edition: Option) { - assert_eq!(LangString::parse(s, ErrorCodes::Yes), LangString { + edition: Option) { + assert_eq!(LangString::parse(s, ErrorCodes::Yes, true), LangString { should_panic, no_run, ignore, @@ -42,6 +42,7 @@ fn test_lang_string_parse() { edition, }) } + let ignore_foo = Ignore::Some(vec!("foo".to_string())); fn v() -> Vec { Vec::new() @@ -50,23 +51,24 @@ fn test_lang_string_parse() { // 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)); + t("", false, false, Ignore::None, true, false, false, false, v(), None); + t("rust", false, false, Ignore::None, true, false, false, false, v(), None); + t("sh", false, false, Ignore::None, false, false, false, false, v(), None); + t("ignore", false, false, Ignore::All, true, false, false, false, v(), None); + t("ignore-foo", false, false, ignore_foo, true, false, false, false, v(), None); + t("should_panic", true, false, Ignore::None, true, false, false, false, v(), None); + t("no_run", false, true, Ignore::None, true, false, false, false, v(), None); + t("test_harness", false, false, Ignore::None, true, true, false, false, v(), None); + t("compile_fail", false, true, Ignore::None, true, false, true, false, v(), None); + t("allow_fail", false, false, Ignore::None, true, false, false, true, v(), None); + t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None); + t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None); + t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None); + t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None); + t("text, no_run", false, true, Ignore::None, false, false, false, false, v(), None); + t("text,no_run", false, true, Ignore::None, false, false, false, false, v(), None); + t("edition2015", false, false, Ignore::None, true, false, false, false, v(), Some(Edition::Edition2015)); + t("edition2018", false, false, Ignore::None, true, false, false, false, v(), Some(Edition::Edition2018)); } #[test] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index dfa0db0d23b74..c5ac2440f6791 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -355,6 +355,18 @@ fn opts() -> Vec { "show-coverage", "calculate percentage of public items with documentation") }), + unstable("runtool", |o| { + o.optopt("", + "runtool", + "", + "The tool to run tests with when building for a different target than host") + }), + unstable("runtool-arg", |o| { + o.optmulti("", + "runtool-arg", + "", + "One (of possibly many) arguments to pass to the runtool") + }), ] } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index adcc9930b6c33..2c9e530b9e6b1 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -1,5 +1,6 @@ use rustc_data_structures::sync::Lrc; use rustc_interface::interface; +use rustc_target::spec::TargetTriple; use rustc::hir; use rustc::hir::intravisit; use rustc::session::{self, config, DiagnosticOutput}; @@ -22,7 +23,7 @@ use testing; use crate::clean::Attributes; use crate::config::Options; -use crate::html::markdown::{self, ErrorCodes, LangString}; +use crate::html::markdown::{self, ErrorCodes, LangString, Ignore}; #[derive(Clone, Default)] pub struct TestOptions { @@ -44,7 +45,7 @@ pub fn run(options: Options) -> i32 { vec![config::CrateType::Dylib] }; - let sessopts = config::Options { + let mut sessopts = config::Options { maybe_sysroot: options.maybe_sysroot.clone(), search_paths: options.libs.clone(), crate_types, @@ -59,7 +60,7 @@ pub fn run(options: Options) -> i32 { edition: options.edition, ..config::Options::default() }; - + options.target.as_ref().map(|t| { sessopts.target_triple = t.clone() }); let config = interface::Config { opts: sessopts, crate_cfg: config::parse_cfgspecs(options.cfgs.clone()), @@ -181,6 +182,9 @@ fn run_test( should_panic: bool, no_run: bool, as_test_harness: bool, + runtool: Option, + runtool_args: Vec, + target: Option, compile_fail: bool, mut error_codes: Vec, opts: &TestOptions, @@ -315,7 +319,15 @@ fn run_test( } // Run the code! - let mut cmd = Command::new(output_file); + let mut cmd; + + if let Some(tool) = runtool { + cmd = Command::new(tool); + cmd.arg(output_file); + cmd.args(runtool_args); + }else{ + cmd = Command::new(output_file); + } match cmd.output() { Err(e) => return Err(TestFailure::ExecutionError(e)), @@ -661,12 +673,27 @@ impl Tester for Collector { let opts = self.opts.clone(); let edition = config.edition.unwrap_or(self.options.edition.clone()); let options = self.options.clone(); + let maybe_sysroot = self.maybe_sysroot.clone(); + let linker = self.linker.clone(); + let edition = config.edition.unwrap_or(self.edition); + let persist_doctests = self.persist_doctests.clone(); + let runtool = self.runtool.clone(); + let runtool_args = self.runtool_args.clone(); + let target = self.target.clone(); + let target_str = target.as_ref().map(|t| t.to_string()); debug!("creating test {}: {}", name, test); self.tests.push(testing::TestDescAndFn { desc: testing::TestDesc { - name: testing::DynTestName(name), - ignore: config.ignore, + name: testing::DynTestName(name.clone()), + ignore: match config.ignore { + Ignore::All => true, + Ignore::None => false, + Ignore::Some(ref ignores) => { + target_str.map_or(false, + |s| ignores.iter().any(|t| s.contains(t))) + }, + }, // compiler failures are test failures should_panic: testing::ShouldPanic::No, allow_fail: config.allow_fail, @@ -681,6 +708,9 @@ impl Tester for Collector { config.should_panic, config.no_run, config.test_harness, + runtool, + runtool_args, + target, config.compile_fail, config.error_codes, &opts, From 3f7640884128c6d2acaa9aee3b582cc372044b6d Mon Sep 17 00:00:00 2001 From: Dario Gonzalez Date: Thu, 6 Jun 2019 16:01:53 -0700 Subject: [PATCH 05/25] added feature gate enable-per-target-ignores updated and augmented tests in html/markdown.rs --- src/librustdoc/config.rs | 7 +++++++ src/librustdoc/html/markdown.rs | 17 +++++++++++------ src/librustdoc/lib.rs | 5 +++++ src/librustdoc/markdown.rs | 2 +- src/librustdoc/passes/mod.rs | 2 +- src/librustdoc/test.rs | 7 +++++-- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 6d1258fe3a390..d8fe8d6c8a362 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -81,6 +81,10 @@ pub struct Options { pub runtool: Option, /// Arguments to pass to the runtool pub runtool_args: Vec, + /// Whether to allow ignoring doctests on a per-target basis + /// For example, using ignore-foo to ignore running the doctest on any target that + /// contains "foo" as a substring + pub enable_per_target_ignores: bool, // Options that affect the documentation process @@ -146,6 +150,7 @@ impl fmt::Debug for Options { .field("render_options", &self.render_options) .field("runtool", &self.runtool) .field("runtool_args", &self.runtool_args) + .field("enable-per-target-ignores", &self.enable_per_target_ignores) .finish() } } @@ -474,6 +479,7 @@ impl Options { let extern_strs = matches.opt_strs("extern"); let runtool = matches.opt_str("runtool"); let runtool_args = matches.opt_strs("runtool-arg"); + let enable_per_target_ignores = matches.opt_present("enable-per-target-ignores"); let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format); @@ -506,6 +512,7 @@ impl Options { persist_doctests, runtool, runtool_args, + enable_per_target_ignores, render_options: RenderOptions { output, external_html, diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 45f2efd411fae..cdc6d4eda4006 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -199,7 +199,7 @@ impl<'a, I: Iterator>> Iterator for CodeBlocks<'_, 'a, I> { let ignore; let edition; if let Some(Event::Start(Tag::CodeBlock(lang))) = event { - let parse_result = LangString::parse(&lang, self.check_error_codes); + let parse_result = LangString::parse(&lang, self.check_error_codes, false); if !parse_result.rust { return Some(Event::Start(Tag::CodeBlock(lang))); } @@ -551,7 +551,8 @@ impl<'a, I: Iterator>> Iterator for Footnotes<'a, I> { } } -pub fn find_testable_code(doc: &str, tests: &mut T, error_codes: ErrorCodes) { +pub fn find_testable_code(doc: &str, tests: &mut T, error_codes: ErrorCodes, + enable_per_target_ignores: bool) { let mut parser = Parser::new(doc); let mut prev_offset = 0; let mut nb_lines = 0; @@ -564,7 +565,7 @@ pub fn find_testable_code(doc: &str, tests: &mut T, error_codes let block_info = if s.is_empty() { LangString::all_false() } else { - LangString::parse(&*s, error_codes) + LangString::parse(&*s, error_codes, enable_per_target_ignores) }; if !block_info.rust { continue; @@ -639,7 +640,11 @@ impl LangString { } } - fn parse(string: &str, allow_error_code_check: ErrorCodes) -> LangString { + fn parse( + string: &str, + allow_error_code_check: ErrorCodes, + enable_per_target_ignores: bool + ) -> LangString { let allow_error_code_check = allow_error_code_check.as_bool(); let mut seen_rust_tags = false; let mut seen_other_tags = false; @@ -660,7 +665,7 @@ impl LangString { } "no_run" => { data.no_run = true; seen_rust_tags = !seen_other_tags; } "ignore" => { data.ignore = Ignore::All; seen_rust_tags = !seen_other_tags; } - x if x.starts_with("ignore-") => { + x if enable_per_target_ignores && x.starts_with("ignore-") => { ignores.push(x.trim_start_matches("ignore-").to_owned()); seen_rust_tags = !seen_other_tags; } @@ -941,7 +946,7 @@ crate fn rust_code_blocks(md: &str) -> Vec { let lang_string = if syntax.is_empty() { LangString::all_false() } else { - LangString::parse(&*syntax, ErrorCodes::Yes) + LangString::parse(&*syntax, ErrorCodes::Yes, false) }; if lang_string.rust { diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index c5ac2440f6791..8f6067da08335 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -355,6 +355,11 @@ fn opts() -> Vec { "show-coverage", "calculate percentage of public items with documentation") }), + unstable("enable-per-target-ignores", |o| { + o.optflag("", + "enable-per-target-ignores", + "parse ignore-foo for ignoring doctests on a per-target basis") + }), unstable("runtool", |o| { o.optopt("", "runtool", diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index a30fc05f36acd..67faec6bd3d0c 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -147,7 +147,7 @@ pub fn test(mut options: Options, diag: &errors::Handler) -> i32 { collector.set_position(DUMMY_SP); let codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build()); - find_testable_code(&input_str, &mut collector, codes); + find_testable_code(&input_str, &mut collector, codes, options.enable_per_target_ignores); options.test_args.insert(0, "rustdoctest".to_string()); testing::test_main(&options.test_args, collector.tests, diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index 641a6df221446..3bb1d0deca78d 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -336,7 +336,7 @@ pub fn look_for_tests<'tcx>( found_tests: 0, }; - find_testable_code(&dox, &mut tests, ErrorCodes::No); + find_testable_code(&dox, &mut tests, ErrorCodes::No, false); if check_missing_code == true && tests.found_tests == 0 { let sp = span_of_attrs(&item.attrs).substitute_dummy(item.source.span()); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 2c9e530b9e6b1..a30ac1a512893 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -325,7 +325,7 @@ fn run_test( cmd = Command::new(tool); cmd.arg(output_file); cmd.args(runtool_args); - }else{ + } else { cmd = Command::new(output_file); } @@ -857,7 +857,10 @@ impl<'a, 'hir> HirCollector<'a, 'hir> { // anything else, this will combine them for us. if let Some(doc) = attrs.collapsed_doc_value() { self.collector.set_position(attrs.span.unwrap_or(DUMMY_SP)); - markdown::find_testable_code(&doc, self.collector, self.codes); + markdown::find_testable_code(&doc, + self.collector, + self.codes, + self.collector.enable_per_target_ignores); } nested(self); From 657e24c56b11a45ee1cc019eb0763838f4437475 Mon Sep 17 00:00:00 2001 From: Dario Gonzalez Date: Tue, 11 Jun 2019 11:06:34 -0700 Subject: [PATCH 06/25] changed target from option to plain target, populated with host triple at argument parsing time if no --target arguments --- src/librustdoc/config.rs | 8 +++++--- src/librustdoc/core.rs | 3 +-- src/librustdoc/test.rs | 8 +++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index d8fe8d6c8a362..995a340143f78 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -9,7 +9,7 @@ use rustc::session; use rustc::session::config::{CrateType, parse_crate_types_from_list}; use rustc::session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, Externs}; use rustc::session::config::{nightly_options, build_codegen_options, build_debugging_options, - get_cmd_lint_options, ExternEntry}; + get_cmd_lint_options, host_triple, ExternEntry}; use rustc::session::search_paths::SearchPath; use rustc_driver; use rustc_target::spec::TargetTriple; @@ -54,7 +54,7 @@ pub struct Options { /// Debugging (`-Z`) options to pass to the compiler. pub debugging_options: DebuggingOptions, /// The target used to compile the crate against. - pub target: Option, + pub target: TargetTriple, /// Edition used when reading the crate. Defaults to "2015". Also used by default when /// compiling doctests from the crate. pub edition: Edition, @@ -425,7 +425,9 @@ impl Options { } } - let target = matches.opt_str("target").map(|target| { + let target = matches.opt_str("target").map_or( + TargetTriple::from_triple(host_triple()), + |target| { if target.ends_with(".json") { TargetTriple::TargetPath(PathBuf::from(target)) } else { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 9cfcad4271966..66a32c73e0f16 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -13,7 +13,6 @@ use rustc_interface::interface; use rustc_driver::abort_on_err; use rustc_resolve as resolve; use rustc_metadata::cstore::CStore; -use rustc_target::spec::TargetTriple; use syntax::source_map; use syntax::attr; @@ -313,7 +312,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt lint_cap: Some(lint_cap.unwrap_or_else(|| lint::Forbid)), cg: codegen_options, externs, - target_triple: target.unwrap_or(host_triple), + target_triple: target, // Ensure that rustdoc works even if rustc is feature-staged unstable_features: UnstableFeatures::Allow, actually_rustdoc: true, diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index a30ac1a512893..daec977810682 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -60,7 +60,6 @@ pub fn run(options: Options) -> i32 { edition: options.edition, ..config::Options::default() }; - options.target.as_ref().map(|t| { sessopts.target_triple = t.clone() }); let config = interface::Config { opts: sessopts, crate_cfg: config::parse_cfgspecs(options.cfgs.clone()), @@ -184,7 +183,7 @@ fn run_test( as_test_harness: bool, runtool: Option, runtool_args: Vec, - target: Option, + target: TargetTriple, compile_fail: bool, mut error_codes: Vec, opts: &TestOptions, @@ -680,7 +679,7 @@ impl Tester for Collector { let runtool = self.runtool.clone(); let runtool_args = self.runtool_args.clone(); let target = self.target.clone(); - let target_str = target.as_ref().map(|t| t.to_string()); + let target_str = target.to_string(); debug!("creating test {}: {}", name, test); self.tests.push(testing::TestDescAndFn { @@ -690,8 +689,7 @@ impl Tester for Collector { Ignore::All => true, Ignore::None => false, Ignore::Some(ref ignores) => { - target_str.map_or(false, - |s| ignores.iter().any(|t| s.contains(t))) + ignores.iter().any(|s| target_str.contains(s)) }, }, // compiler failures are test failures From 14110ebd936747eff905ec4e444a02a4a74f6e11 Mon Sep 17 00:00:00 2001 From: Dario Gonzalez Date: Wed, 12 Jun 2019 10:49:41 -0700 Subject: [PATCH 07/25] added rustdoc book documentation, improved behavior when unstable flag not present --- src/doc/rustdoc/src/unstable-features.md | 50 ++++++++++++++++++++++++ src/librustdoc/html/markdown.rs | 14 ++----- src/librustdoc/test.rs | 2 + 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 993fc8412836e..49d05b5038df7 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -471,3 +471,53 @@ Some methodology notes about what rustdoc counts in this metric: Public items that are not documented can be seen with the built-in `missing_docs` lint. Private items that are not documented can be seen with Clippy's `missing_docs_in_private_items` lint. + +### `--enable-per-target-ignores`: allow `ignore-foo` style filters for doctests + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --enable-per-target-ignores +``` + +This flag allows you to tag doctests with compiltest style `ignore-foo` filters that prevent +rustdoc from running that test if the target triple string contains foo. For example: + +```rust +///```ignore-foo,ignore-bar +///assert!(2 == 2); +///``` +struct Foo; +``` + +This will not be run when the build target is `super-awesome-foo` or `less-bar-awesome`. +If the flag is not enabled, then rustdoc will consume the filter, but do nothing with it, and +the above example will be run for all targets. +If you want to preserve backwards compatibility for older versions of rustdoc, you can use + +```rust +///```ignore,ignore-foo +///assert!(2 == 2); +///``` +struct Foo; +``` + +In older versions, this will be ignored on all targets, but on newer versions `ignore-gnu` will +override `ignore`. + +### `--runtool`, `--runtool-arg`: program to run tests with; args to pass to it + +Using thses options looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --runtool runner --runtool-arg --do-thing --runtool-arg --do-other-thing +``` + +These options can be used to run the doctest under a program, and also pass arguments to +that program. For example, if you want to run your doctests under valgrind you might run + +```bash +$ rustdoc src/lib.rs -Z unstable-options --runtool valgrind +``` + +Another use case would be to run a test inside an emulator, or through a Virtual Machine. diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index cdc6d4eda4006..05e6c77256e7b 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -665,7 +665,7 @@ impl LangString { } "no_run" => { data.no_run = true; seen_rust_tags = !seen_other_tags; } "ignore" => { data.ignore = Ignore::All; seen_rust_tags = !seen_other_tags; } - x if enable_per_target_ignores && x.starts_with("ignore-") => { + x if x.starts_with("ignore-") => if enable_per_target_ignores { ignores.push(x.trim_start_matches("ignore-").to_owned()); seen_rust_tags = !seen_other_tags; } @@ -696,15 +696,9 @@ impl LangString { _ => { seen_other_tags = true } } } - - match data.ignore { - Ignore::All => {}, - Ignore::None => { - if !ignores.is_empty() { - data.ignore = Ignore::Some(ignores); - } - }, - _ => unreachable!(), + // ignore-foo overrides ignore + if !ignores.is_empty() { + data.ignore = Ignore::Some(ignores); } data.rust &= !seen_other_tags || seen_rust_tags; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index daec977810682..840eeda9ad7ca 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -58,8 +58,10 @@ pub fn run(options: Options) -> i32 { ..config::basic_debugging_options() }, edition: options.edition, + target_triple: options.target.clone(), ..config::Options::default() }; + let config = interface::Config { opts: sessopts, crate_cfg: config::parse_cfgspecs(options.cfgs.clone()), From 4a2094c9f61836214d9e37fa042761948483c2d9 Mon Sep 17 00:00:00 2001 From: Dario Gonzalez Date: Tue, 27 Aug 2019 15:44:11 -0700 Subject: [PATCH 08/25] address rebase changes --- src/librustdoc/core.rs | 1 - src/librustdoc/markdown.rs | 3 ++- src/librustdoc/test.rs | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 66a32c73e0f16..57b016a08c2fe 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -293,7 +293,6 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt } }).collect(); - let host_triple = TargetTriple::from_triple(config::host_triple()); let crate_types = if proc_macro_crate { vec![config::CrateType::ProcMacro] } else { diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 67faec6bd3d0c..b06b368469fc1 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -143,7 +143,8 @@ pub fn test(mut options: Options, diag: &errors::Handler) -> i32 { opts.no_crate_inject = true; opts.display_warnings = options.display_warnings; let mut collector = Collector::new(options.input.display().to_string(), options.clone(), - true, opts, None, Some(options.input)); + true, opts, None, Some(options.input), + options.enable_per_target_ignores); collector.set_position(DUMMY_SP); let codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build()); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 840eeda9ad7ca..aefe4d3ea3f43 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -45,7 +45,7 @@ pub fn run(options: Options) -> i32 { vec![config::CrateType::Dylib] }; - let mut sessopts = config::Options { + let sessopts = config::Options { maybe_sysroot: options.maybe_sysroot.clone(), search_paths: options.libs.clone(), crate_types, @@ -84,6 +84,7 @@ pub fn run(options: Options) -> i32 { let mut opts = scrape_test_config(lower_to_hir.peek().0.borrow().krate()); opts.display_warnings |= options.display_warnings; + let enable_per_target_ignores = options.enable_per_target_ignores; let mut collector = Collector::new( compiler.crate_name()?.peek().to_string(), options, @@ -91,6 +92,7 @@ pub fn run(options: Options) -> i32 { opts, Some(compiler.source_map().clone()), None, + enable_per_target_ignores, ); let mut global_ctxt = compiler.global_ctxt()?.take(); @@ -275,6 +277,7 @@ fn run_test( if no_run { compiler.arg("--emit=metadata"); } + compiler.arg("--target").arg(target.to_string()); compiler.arg("-"); compiler.stdin(Stdio::piped()); @@ -616,6 +619,7 @@ pub struct Collector { options: Options, use_headers: bool, + enable_per_target_ignores: bool, cratename: String, opts: TestOptions, position: Span, @@ -625,12 +629,14 @@ pub struct Collector { impl Collector { pub fn new(cratename: String, options: Options, use_headers: bool, opts: TestOptions, - source_map: Option>, filename: Option,) -> Collector { + source_map: Option>, filename: Option, + enable_per_target_ignores: bool) -> Collector { Collector { tests: Vec::new(), names: Vec::new(), options, use_headers, + enable_per_target_ignores, cratename, opts, position: DUMMY_SP, @@ -674,13 +680,9 @@ impl Tester for Collector { let opts = self.opts.clone(); let edition = config.edition.unwrap_or(self.options.edition.clone()); let options = self.options.clone(); - let maybe_sysroot = self.maybe_sysroot.clone(); - let linker = self.linker.clone(); - let edition = config.edition.unwrap_or(self.edition); - let persist_doctests = self.persist_doctests.clone(); - let runtool = self.runtool.clone(); - let runtool_args = self.runtool_args.clone(); - let target = self.target.clone(); + let runtool = self.options.runtool.clone(); + let runtool_args = self.options.runtool_args.clone(); + let target = self.options.target.clone(); let target_str = target.to_string(); debug!("creating test {}: {}", name, test); From 32101ad3b38d29291a5150840e88aeef2fb911a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Thu, 22 Aug 2019 12:28:03 +0200 Subject: [PATCH 09/25] Upgrade rand to 0.7 --- Cargo.lock | 13 +++++++------ src/librustc_incremental/Cargo.toml | 2 +- src/libstd/Cargo.toml | 2 +- src/libstd/fs.rs | 2 +- src/libstd/tests/env.rs | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 313fef1c086a8..43eb28168086a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1151,12 +1151,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.8" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" +checksum = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" dependencies = [ "cfg-if", "libc", + "wasi", ] [[package]] @@ -1583,9 +1584,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" [[package]] name = "libc" -version = "0.2.61" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c665266eb592905e8503ba3403020f4b8794d26263f412ca33171600eca9a6fa" +checksum = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" dependencies = [ "rustc-std-workspace-core", ] @@ -3248,7 +3249,7 @@ version = "0.0.0" dependencies = [ "graphviz", "log", - "rand 0.6.1", + "rand 0.7.0", "rustc", "rustc_data_structures", "rustc_fs_util", @@ -3864,7 +3865,7 @@ dependencies = [ "panic_abort", "panic_unwind", "profiler_builtins", - "rand 0.6.1", + "rand 0.7.0", "rustc_asan", "rustc_lsan", "rustc_msan", diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index a931ad3b66e21..659c4c89fe33c 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] graphviz = { path = "../libgraphviz" } log = "0.4" -rand = "0.6" +rand = "0.7" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_serialize = { path = "../libserialize", package = "serialize" } diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 18a46cf0b5257..a34ab598aed94 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -38,7 +38,7 @@ features = [ optional = true [dev-dependencies] -rand = "0.6.1" +rand = "0.7" [target.x86_64-apple-darwin.dependencies] rustc_asan = { path = "../librustc_asan" } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 5f76875bd66c4..b14e02a2cb478 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -2144,7 +2144,7 @@ mod tests { use crate::sys_common::io::test::{TempDir, tmpdir}; use crate::thread; - use rand::{rngs::StdRng, FromEntropy, RngCore}; + use rand::{rngs::StdRng, RngCore, SeedableRng}; #[cfg(windows)] use crate::os::windows::fs::{symlink_dir, symlink_file}; diff --git a/src/libstd/tests/env.rs b/src/libstd/tests/env.rs index 06fb5533afdd8..f8014cb2ad9af 100644 --- a/src/libstd/tests/env.rs +++ b/src/libstd/tests/env.rs @@ -5,7 +5,7 @@ use rand::{thread_rng, Rng}; use rand::distributions::Alphanumeric; fn make_rand_name() -> OsString { - let mut rng = thread_rng(); + let rng = thread_rng(); let n = format!("TEST{}", rng.sample_iter(&Alphanumeric).take(10) .collect::()); let n = OsString::from(n); From 9a561872c419d3bc0c8ac9d13942f73535df27c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 1 Sep 2019 00:01:25 -0700 Subject: [PATCH 10/25] Always emit unresolved import errors and hide unused import lint --- src/librustc_resolve/resolve_imports.rs | 89 ++++++++++++------- src/test/ui/extenv/issue-55897.rs | 2 +- src/test/ui/extenv/issue-55897.stderr | 8 +- .../ui/imports/unresolved-imports-used.rs | 8 +- .../ui/imports/unresolved-imports-used.stderr | 26 +++++- .../ui/rust-2018/uniform-paths/deadlock.rs | 2 +- .../rust-2018/uniform-paths/deadlock.stderr | 6 +- 7 files changed, 96 insertions(+), 45 deletions(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 132690dcd7df2..eb509f1a01d67 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -71,7 +71,7 @@ pub enum ImportDirectiveSubclass<'a> { } /// One import directive. -#[derive(Debug,Clone)] +#[derive(Debug, Clone)] crate struct ImportDirective<'a> { /// The ID of the `extern crate`, `UseTree` etc that imported this `ImportDirective`. /// @@ -447,12 +447,13 @@ impl<'a> Resolver<'a> { } // Define the name or return the existing binding if there is a collision. - pub fn try_define(&mut self, - module: Module<'a>, - ident: Ident, - ns: Namespace, - binding: &'a NameBinding<'a>) - -> Result<(), &'a NameBinding<'a>> { + pub fn try_define( + &mut self, + module: Module<'a>, + ident: Ident, + ns: Namespace, + binding: &'a NameBinding<'a>, + ) -> Result<(), &'a NameBinding<'a>> { let res = binding.res(); self.check_reserved_macro_name(ident, res); self.set_binding_parent_module(binding, module); @@ -480,8 +481,11 @@ impl<'a> Resolver<'a> { }; if glob_binding.res() != nonglob_binding.res() && ns == MacroNS && nonglob_binding.expansion != ExpnId::root() { - resolution.binding = Some(this.ambiguity(AmbiguityKind::GlobVsExpanded, - nonglob_binding, glob_binding)); + resolution.binding = Some(this.ambiguity( + AmbiguityKind::GlobVsExpanded, + nonglob_binding, + glob_binding, + )); } else { resolution.binding = Some(nonglob_binding); } @@ -513,9 +517,11 @@ impl<'a> Resolver<'a> { }) } - fn ambiguity(&self, kind: AmbiguityKind, - primary_binding: &'a NameBinding<'a>, secondary_binding: &'a NameBinding<'a>) - -> &'a NameBinding<'a> { + fn ambiguity( + &self, kind: AmbiguityKind, + primary_binding: &'a NameBinding<'a>, + secondary_binding: &'a NameBinding<'a>, + ) -> &'a NameBinding<'a> { self.arenas.alloc_name_binding(NameBinding { ambiguity: Some((secondary_binding, kind)), ..primary_binding.clone() @@ -524,8 +530,12 @@ impl<'a> Resolver<'a> { // Use `f` to mutate the resolution of the name in the module. // If the resolution becomes a success, define it in the module's glob importers. - fn update_resolution(&mut self, module: Module<'a>, ident: Ident, ns: Namespace, f: F) - -> T + fn update_resolution( + &mut self, module: Module<'a>, + ident: Ident, + ns: Namespace, + f: F, + ) -> T where F: FnOnce(&mut Resolver<'a>, &mut NameResolution<'a>) -> T { // Ensure that `resolution` isn't borrowed when defining in the module's glob importers, @@ -627,14 +637,18 @@ impl<'a, 'b> ImportResolver<'a, 'b> { self.finalize_resolutions_in(module); } - let mut has_errors = false; let mut seen_spans = FxHashSet::default(); let mut errors = vec![]; let mut prev_root_id: NodeId = NodeId::from_u32(0); - for i in 0 .. self.r.determined_imports.len() { - let import = self.r.determined_imports[i]; + let determined_imports = mem::take(&mut self.r.determined_imports); + let indeterminate_imports = mem::take(&mut self.r.indeterminate_imports); + + for (is_indeterminate, import) in determined_imports + .into_iter() + .map(|i| (false, i)) + .chain(indeterminate_imports.into_iter().map(|i| (true, i))) + { if let Some(err) = self.finalize_import(import) { - has_errors = true; if let SingleImport { source, ref source_bindings, .. } = import.subclass { if source.name == kw::SelfLower { @@ -666,25 +680,27 @@ impl<'a, 'b> ImportResolver<'a, 'b> { errors.push((path, err)); prev_root_id = import.root_id; } + } else if is_indeterminate { + // Consider erroneous imports used to avoid duplicate diagnostics. + self.r.used_imports.insert((import.id, TypeNS)); + let path = import_path_to_string( + &import.module_path.iter().map(|seg| seg.ident).collect::>(), + &import.subclass, + import.span, + ); + let err = UnresolvedImportError { + span: import.span, + label: None, + note: Vec::new(), + suggestion: None, + }; + errors.push((path, err)); } } if !errors.is_empty() { self.throw_unresolved_import_error(errors.clone(), None); } - - for import in &self.r.indeterminate_imports { - // Consider erroneous imports used to avoid duplicate diagnostics. - self.r.used_imports.insert((import.id, TypeNS)); - } - // Report unresolved imports only if no hard error was already reported - // to avoid generating multiple errors on the same import. - if !has_errors { - for import in &self.r.indeterminate_imports { - self.throw_unresolved_import_error(errors, Some(MultiSpan::from(import.span))); - break; - } - } } fn throw_unresolved_import_error( @@ -839,8 +855,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> { ) -> Option { let orig_vis = directive.vis.replace(ty::Visibility::Invisible); let prev_ambiguity_errors_len = self.r.ambiguity_errors.len(); - let path_res = self.r.resolve_path(&directive.module_path, None, &directive.parent_scope, - true, directive.span, directive.crate_lint()); + let path_res = self.r.resolve_path( + &directive.module_path, + None, + &directive.parent_scope, + true, + directive.span, + directive.crate_lint(), + ); let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len; directive.vis.set(orig_vis); if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res { @@ -903,7 +925,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> { } } }; - return Some(err); } return None; diff --git a/src/test/ui/extenv/issue-55897.rs b/src/test/ui/extenv/issue-55897.rs index c3975f6b9255e..64c4107e89875 100644 --- a/src/test/ui/extenv/issue-55897.rs +++ b/src/test/ui/extenv/issue-55897.rs @@ -1,7 +1,7 @@ use prelude::*; //~ ERROR unresolved import `prelude` mod unresolved_env { - use env; + use env; //~ ERROR unresolved import `env` include!(concat!(env!("NON_EXISTENT"), "/data.rs")); //~^ ERROR cannot determine resolution for the macro `env` diff --git a/src/test/ui/extenv/issue-55897.stderr b/src/test/ui/extenv/issue-55897.stderr index 9d68131beabd7..c57a467cdba56 100644 --- a/src/test/ui/extenv/issue-55897.stderr +++ b/src/test/ui/extenv/issue-55897.stderr @@ -19,6 +19,12 @@ LL | use prelude::*; | unresolved import | help: a similar path exists: `std::prelude` +error[E0432]: unresolved import `env` + --> $DIR/issue-55897.rs:4:9 + | +LL | use env; + | ^^^ no `env` in the root + error: cannot determine resolution for the macro `env` --> $DIR/issue-55897.rs:6:22 | @@ -27,6 +33,6 @@ LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs")); | = note: import resolution is stuck, try simplifying macro imports -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/imports/unresolved-imports-used.rs b/src/test/ui/imports/unresolved-imports-used.rs index 5398dd63c8929..75cf880192c8e 100644 --- a/src/test/ui/imports/unresolved-imports-used.rs +++ b/src/test/ui/imports/unresolved-imports-used.rs @@ -8,11 +8,11 @@ mod qux { use qux::quz; //~ ERROR function `quz` is private use qux::bar; //~ ERROR unresolved import `qux::bar` -use foo::bar; -use baz::*; +use foo::bar; //~ ERROR unresolved import `foo` +use baz::*; //~ ERROR unresolved import `baz` use qux::bar2; //~ ERROR unresolved import `qux::bar2` -use foo2::bar2; -use baz2::*; +use foo2::bar2;//~ ERROR unresolved import `foo2` +use baz2::*; //~ ERROR unresolved import `baz2` use qux::quy; //~ ERROR unused import fn main() {} diff --git a/src/test/ui/imports/unresolved-imports-used.stderr b/src/test/ui/imports/unresolved-imports-used.stderr index c9342d17a49d7..b341e8e059288 100644 --- a/src/test/ui/imports/unresolved-imports-used.stderr +++ b/src/test/ui/imports/unresolved-imports-used.stderr @@ -10,6 +10,30 @@ error[E0432]: unresolved import `qux::bar2` LL | use qux::bar2; | ^^^^^^^^^ no `bar2` in `qux` +error[E0432]: unresolved import `foo` + --> $DIR/unresolved-imports-used.rs:11:5 + | +LL | use foo::bar; + | ^^^ maybe a missing crate `foo`? + +error[E0432]: unresolved import `baz` + --> $DIR/unresolved-imports-used.rs:12:5 + | +LL | use baz::*; + | ^^^ maybe a missing crate `baz`? + +error[E0432]: unresolved import `foo2` + --> $DIR/unresolved-imports-used.rs:14:5 + | +LL | use foo2::bar2; + | ^^^^ maybe a missing crate `foo2`? + +error[E0432]: unresolved import `baz2` + --> $DIR/unresolved-imports-used.rs:15:5 + | +LL | use baz2::*; + | ^^^^ maybe a missing crate `baz2`? + error[E0603]: function `quz` is private --> $DIR/unresolved-imports-used.rs:9:10 | @@ -28,7 +52,7 @@ note: lint level defined here LL | #![deny(unused_imports)] | ^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 8 previous errors Some errors have detailed explanations: E0432, E0603. For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/rust-2018/uniform-paths/deadlock.rs b/src/test/ui/rust-2018/uniform-paths/deadlock.rs index 3228d799083fb..83ed70a0459a8 100644 --- a/src/test/ui/rust-2018/uniform-paths/deadlock.rs +++ b/src/test/ui/rust-2018/uniform-paths/deadlock.rs @@ -1,7 +1,7 @@ // edition:2018 // compile-flags:--extern foo --extern bar -use foo::bar; //~ ERROR unresolved import +use foo::bar; //~ ERROR can't find crate for `foo` use bar::foo; fn main() {} diff --git a/src/test/ui/rust-2018/uniform-paths/deadlock.stderr b/src/test/ui/rust-2018/uniform-paths/deadlock.stderr index b4ac15c588ebd..9336e90afb71d 100644 --- a/src/test/ui/rust-2018/uniform-paths/deadlock.stderr +++ b/src/test/ui/rust-2018/uniform-paths/deadlock.stderr @@ -1,9 +1,9 @@ -error[E0432]: unresolved import +error[E0463]: can't find crate for `foo` --> $DIR/deadlock.rs:4:5 | LL | use foo::bar; - | ^^^^^^^^ + | ^^^ can't find crate error: aborting due to previous error -For more information about this error, try `rustc --explain E0432`. +For more information about this error, try `rustc --explain E0463`. From 851a5fd99736eee68faa2074011434f2405d4ef4 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 9 Sep 2019 12:50:29 +0000 Subject: [PATCH 11/25] Update clippy --- src/tools/clippy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy b/src/tools/clippy index 5f28fda13efeb..58e01ea4d7df6 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 5f28fda13efeb85097fe082af4b4827a58b0ecf6 +Subproject commit 58e01ea4d7df69e658c034afbfa6d0abd90808ed From 3d7040bdef50c4679b438cabd11ac0f81434a013 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 9 Sep 2019 13:01:46 +0200 Subject: [PATCH 12/25] Update miri submodule --- src/tools/miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri b/src/tools/miri index e479ab26406ed..dd94c7c5a32be 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit e479ab26406ed8a473987e5f4a1f3be3e978e5d2 +Subproject commit dd94c7c5a32be2ee0adeeaf9d46f26f14925797c From 625a9d6a4b0d0ef89e9a70e91275b7f91d871e65 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 9 Sep 2019 17:37:38 +0300 Subject: [PATCH 13/25] lldb: avoid mixing "Hit breakpoint" message with other output. --- src/etc/lldb_batchmode.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/etc/lldb_batchmode.py b/src/etc/lldb_batchmode.py index 537b419b3279f..7c2e91474c1f1 100644 --- a/src/etc/lldb_batchmode.py +++ b/src/etc/lldb_batchmode.py @@ -45,7 +45,10 @@ def normalize_whitespace(s): def breakpoint_callback(frame, bp_loc, dict): """This callback is registered with every breakpoint and makes sure that the - frame containing the breakpoint location is selected""" + frame containing the breakpoint location is selected """ + + # HACK(eddyb) print a newline to avoid continuing an unfinished line. + print("") print("Hit breakpoint " + str(bp_loc)) # Select the frame and the thread containing it From 91dae2e233d6b468731eaa8908794d0a7e4e876d Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sun, 8 Sep 2019 10:28:01 +0200 Subject: [PATCH 14/25] Bump RLS and Rustfmt submodules --- src/tools/rls | 2 +- src/tools/rustfmt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/rls b/src/tools/rls index 496c892752213..412fb00b37afb 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 496c89275221303a4b0c2779cb8203fb3ce2a136 +Subproject commit 412fb00b37afb6b7f7fa96a35f2315c7e640b916 diff --git a/src/tools/rustfmt b/src/tools/rustfmt index f800ce47d1da2..afb1ee1c14594 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit f800ce47d1da2a1c02ffd260deca8b7445f7facf +Subproject commit afb1ee1c14594aed5bb4a762b357b01f13c9de10 From c2249a4bf996435803ad3f8fbe9fe45d9289e19f Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sun, 8 Sep 2019 10:28:11 +0200 Subject: [PATCH 15/25] cargo update -p rustfmt-nightly --- Cargo.lock | 523 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 374 insertions(+), 149 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 108c2fbd8f503..beae224b500dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -223,9 +223,9 @@ checksum = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" [[package]] name = "bytecount" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0fdd54b507df8f22012890aadd099979befdba27713c767993f8380112ca7c" +checksum = "b0017894339f586ccb943b01b9555de56770c11cda818e7e3d8bd93f4ed7f46e" dependencies = [ "packed_simd", ] @@ -287,7 +287,7 @@ dependencies = [ "git2-curl", "glob", "hex", - "home 0.5.0", + "home", "ignore", "im-rc", "jobserver", @@ -309,7 +309,7 @@ dependencies = [ "same-file", "semver", "serde", - "serde_ignored 0.1.0", + "serde_ignored", "serde_json", "shell-escape", "strip-ansi-escapes", @@ -392,9 +392,9 @@ dependencies = [ [[package]] name = "clap" -version = "2.32.0" +version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" dependencies = [ "ansi_term", "atty", @@ -753,9 +753,9 @@ checksum = "d2a368589465391e127e10c9e3a08efc8df66fd49b87dc8524c764bbe7f2ef82" dependencies = [ "fnv", "ident_case", - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", ] [[package]] @@ -765,8 +765,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "244e8987bd4e174385240cde20a3657f607fb0797563c28255c353b5819a07b1" dependencies = [ "darling_core", - "quote", - "syn", + "quote 0.6.12", + "syn 0.15.35", ] [[package]] @@ -781,9 +781,9 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", ] [[package]] @@ -792,10 +792,10 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f57d78cf3bd45270dad4e70c21ec77a960b36c7a841ff9db76aaa775a8fb871" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 0.4.30", + "quote 0.6.12", "rustc_version", - "syn", + "syn 0.15.35", ] [[package]] @@ -953,9 +953,9 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", "synstructure", ] @@ -1259,16 +1259,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" -[[package]] -name = "home" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80dff82fb58cfbbc617fb9a9184b010be0529201553cda50ad04372bc2333aff" -dependencies = [ - "scopeguard 0.3.3", - "winapi 0.3.6", -] - [[package]] name = "home" version = "0.5.0" @@ -1288,9 +1278,9 @@ dependencies = [ "log", "mac", "markup5ever", - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", ] [[package]] @@ -1528,11 +1518,30 @@ version = "0.11.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be" +[[package]] +name = "jsonrpc-client-transports" +version = "13.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39577db48b004cffb4c5b8e5c9b993c177c52599ecbee88711e815acf65144db" +dependencies = [ + "failure", + "futures", + "jsonrpc-core", + "jsonrpc-pubsub", + "jsonrpc-server-utils", + "log", + "parity-tokio-ipc", + "serde", + "serde_json", + "tokio", + "url 1.7.2", +] + [[package]] name = "jsonrpc-core" -version = "12.0.0" +version = "13.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "288dca7f9713710a29e485076b9340156cb701edb46a881f5d0c31aa4f5b9143" +checksum = "dd42951eb35079520ee29b7efbac654d85821b397ef88c8151600ef7e2d00217" dependencies = [ "futures", "log", @@ -1541,6 +1550,70 @@ dependencies = [ "serde_json", ] +[[package]] +name = "jsonrpc-core-client" +version = "13.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f047c10738edee7c3c6acf5241a0ce33df32ef9230c1a7fb03e4a77ee72c992f" +dependencies = [ + "jsonrpc-client-transports", +] + +[[package]] +name = "jsonrpc-derive" +version = "13.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29f9149f785deaae92a4c834a9a1a83a4313b8cfedccf15362cd4cf039a64501" +dependencies = [ + "proc-macro-crate", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", +] + +[[package]] +name = "jsonrpc-ipc-server" +version = "13.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "256c5e4292c17b4c2ecdf542299dc8e9d6b3939c075c54825570ad9317fe5751" +dependencies = [ + "jsonrpc-core", + "jsonrpc-server-utils", + "log", + "parity-tokio-ipc", + "parking_lot 0.9.0", + "tokio-service", +] + +[[package]] +name = "jsonrpc-pubsub" +version = "13.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2c08b444cc0ed70263798834343d0ac875e664257df8079160f23ac1ea79446" +dependencies = [ + "jsonrpc-core", + "log", + "parking_lot 0.9.0", + "serde", +] + +[[package]] +name = "jsonrpc-server-utils" +version = "13.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44561bfdd31401bad790527f1e951dde144f2341ddc3e1b859d32945e1a34eff" +dependencies = [ + "bytes", + "globset", + "jsonrpc-core", + "lazy_static 1.3.0", + "log", + "num_cpus", + "tokio", + "tokio-codec", + "unicase 2.4.0", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1655,6 +1728,15 @@ dependencies = [ "scopeguard 0.3.3", ] +[[package]] +name = "lock_api" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" +dependencies = [ + "scopeguard 1.0.0", +] + [[package]] name = "log" version = "0.4.8" @@ -1686,18 +1768,15 @@ dependencies = [ [[package]] name = "lsp-types" -version = "0.57.2" +version = "0.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62b77309737b1e262b3bbf37ff8faa740562c633b14702afe9be85dbcb6f88a" +checksum = "fe3edefcd66dde1f7f1df706f46520a3c93adc5ca4bc5747da6621195e894efd" dependencies = [ "bitflags", - "num-derive", - "num-traits", "serde", - "serde_derive", "serde_json", - "url 1.7.2", - "url_serde", + "serde_repr", + "url 2.1.0", ] [[package]] @@ -1800,7 +1879,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "structopt", + "structopt 0.2.18", "url 1.7.2", ] @@ -2033,18 +2112,6 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" -[[package]] -name = "num-derive" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8af1847c907c2f04d7bfd572fb25bbb4385c637fe5be163cf2f8c5d778fe1e7d" -dependencies = [ - "num-traits", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "num-integer" version = "0.1.39" @@ -2178,14 +2245,43 @@ dependencies = [ "unwind", ] +[[package]] +name = "parity-tokio-ipc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8281bf4f1d6429573f89589bf68d89451c46750977a8264f8ea3edbabeba7947" +dependencies = [ + "bytes", + "futures", + "log", + "mio-named-pipes", + "miow 0.3.3", + "rand 0.7.0", + "tokio", + "tokio-named-pipes", + "tokio-uds", + "winapi 0.3.6", +] + [[package]] name = "parking_lot" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" dependencies = [ - "lock_api", - "parking_lot_core", + "lock_api 0.1.3", + "parking_lot_core 0.4.0", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api 0.3.1", + "parking_lot_core 0.6.2", + "rustc_version", ] [[package]] @@ -2201,6 +2297,21 @@ dependencies = [ "winapi 0.3.6", ] +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "rustc_version", + "smallvec", + "winapi 0.3.6", +] + [[package]] name = "percent-encoding" version = "1.0.1" @@ -2240,9 +2351,9 @@ checksum = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646" dependencies = [ "pest", "pest_meta", - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", ] [[package]] @@ -2355,6 +2466,26 @@ dependencies = [ "log", ] +[[package]] +name = "proc-macro-crate" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097" +dependencies = [ + "proc-macro2 1.0.3", + "quote 1.0.2", + "syn 1.0.5", +] + [[package]] name = "proc-macro2" version = "0.4.30" @@ -2364,6 +2495,15 @@ dependencies = [ "unicode-xid 0.1.0", ] +[[package]] +name = "proc-macro2" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" +dependencies = [ + "unicode-xid 0.2.0", +] + [[package]] name = "proc_macro" version = "0.0.0" @@ -2416,14 +2556,23 @@ version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" dependencies = [ - "proc-macro2", + "proc-macro2 0.4.30", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +dependencies = [ + "proc-macro2 1.0.3", ] [[package]] name = "racer" -version = "2.1.25" +version = "2.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0727b9d7baaf9e42851145545d7b980b5c1752bd16a4c77c925c5e573d0069d9" +checksum = "dde22b84ab75220015cbd91240222402bf885cbe3a5dc856475771abb82533ae" dependencies = [ "bitflags", "clap", @@ -2715,7 +2864,7 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" [[package]] name = "rls" -version = "1.38.0" +version = "1.39.0" dependencies = [ "cargo", "cargo_metadata", @@ -2726,7 +2875,7 @@ dependencies = [ "failure", "futures", "heck", - "home 0.3.3", + "home", "itertools 0.8.0", "jsonrpc-core", "lazy_static 1.3.0", @@ -2741,6 +2890,7 @@ dependencies = [ "regex", "rls-analysis", "rls-data", + "rls-ipc", "rls-rustc", "rls-span", "rls-vfs", @@ -2750,14 +2900,14 @@ dependencies = [ "rustfmt-nightly", "serde", "serde_derive", - "serde_ignored 0.0.4", + "serde_ignored", "serde_json", "tempfile", "tokio", "tokio-process", "tokio-timer", "toml", - "url 1.7.2", + "url 2.1.0", "walkdir", ] @@ -2788,9 +2938,33 @@ dependencies = [ "serde", ] +[[package]] +name = "rls-ipc" +version = "0.1.0" +dependencies = [ + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "jsonrpc-ipc-server", + "rls-data", + "serde", +] + [[package]] name = "rls-rustc" version = "0.6.0" +dependencies = [ + "clippy_lints", + "env_logger", + "failure", + "futures", + "log", + "rand 0.6.1", + "rls-data", + "rls-ipc", + "serde", + "tokio", +] [[package]] name = "rls-span" @@ -2837,7 +3011,7 @@ dependencies = [ "log", "measureme", "num_cpus", - "parking_lot", + "parking_lot 0.7.1", "polonius-engine", "rustc-rayon", "rustc-rayon-core", @@ -2856,9 +3030,9 @@ dependencies = [ [[package]] name = "rustc-ap-arena" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc2e1e68b64268c543bfa6e63e3c0d9ea58074c71396f42f76931f35a9287f9" +checksum = "f59b76d334bd533f3fdc5c651c27678c5e80fac67c6f7da22ba21a58878c55f5" dependencies = [ "rustc-ap-rustc_data_structures", "smallvec", @@ -2866,15 +3040,15 @@ dependencies = [ [[package]] name = "rustc-ap-graphviz" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c108d647ce0dd46477b048eafff5a6273b5652e02d47424b0cd684147379c811" +checksum = "3e632ef08ca17458acfd46d2ead3d541a1c249586cd5329f5fe333dacfab6142" [[package]] name = "rustc-ap-rustc_data_structures" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656771744e0783cb8e4481e3b8b1f975687610aaf18833b898018111a0e0e582" +checksum = "e89e2c7be68185418f3cd56af3df8b29007a59a1cebefa63612d055f9bcb1a36" dependencies = [ "cfg-if", "crossbeam-utils 0.6.5", @@ -2883,7 +3057,7 @@ dependencies = [ "jobserver", "lazy_static 1.3.0", "log", - "parking_lot", + "parking_lot 0.7.1", "rustc-ap-graphviz", "rustc-ap-serialize", "rustc-hash", @@ -2895,9 +3069,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_errors" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37064f6624bc799bfaa2968b61ee6880926dea2a8bba69f18aef6c8e69c9604" +checksum = "1e47cb380abeb72b01e42b2342d592f7eeea7d536c2f1f0d0e550dc509e46333" dependencies = [ "annotate-snippets", "atty", @@ -2905,34 +3079,38 @@ dependencies = [ "rustc-ap-rustc_data_structures", "rustc-ap-serialize", "rustc-ap-syntax_pos", + "term_size", "termcolor", "unicode-width", ] [[package]] name = "rustc-ap-rustc_lexer" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5bc0a971823637ea23a857f0ef1467f44b1e05d71968821f83a0abe53e0fe3" +checksum = "494cfaf67f49217d67d0774eeecbba61ac89acf478db97ef11f113ed8a959305" +dependencies = [ + "unicode-xid 0.2.0", +] [[package]] name = "rustc-ap-rustc_macros" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b90037e3336fe8835f468db44d0848ae10d9cc8533ae89b55828883f905b7e80" +checksum = "e2e5d36becc59b4497f9cbd3ae0610081de0207a1d0e95c066369167b14f486f" dependencies = [ "itertools 0.8.0", - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", "synstructure", ] [[package]] name = "rustc-ap-rustc_target" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadf9ca07315eab3a7a21f63872f9cc81e250fd6ede0419c24f8926ade73a45d" +checksum = "a7bfc5f96dfc3b9f8d5b57884f7f37467ecff6776cd4b8b491a7daece6fdd7c2" dependencies = [ "bitflags", "log", @@ -2943,9 +3121,9 @@ dependencies = [ [[package]] name = "rustc-ap-serialize" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61673783f2089e01033ffa82d1988f55175402071b31253a358292e1624d4602" +checksum = "2bb9ee231cf79eded39c56647499f83d6136ff5c8c0baaa9e21b6febee00f4f6" dependencies = [ "indexmap", "smallvec", @@ -2953,9 +3131,9 @@ dependencies = [ [[package]] name = "rustc-ap-syntax" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28f3dd1346d5b0269c07a4a78855e309a298ab569c9c1302d4d4f57f8eee4e84" +checksum = "b3827fc208814efbde82d613e31d11b4250ce9e8cf8afe4a4d47bbbd099632c9" dependencies = [ "bitflags", "lazy_static 1.3.0", @@ -2973,9 +3151,9 @@ dependencies = [ [[package]] name = "rustc-ap-syntax_pos" -version = "546.0.0" +version = "583.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e67b526dbda3a0c7dab91c8947d43685e7697f52686a4949da3c179cd7c979" +checksum = "930ed81c34f325e512cc315c04d676fa84a373879d5c43bb54054a0522b05213" dependencies = [ "cfg-if", "rustc-ap-arena", @@ -3071,13 +3249,13 @@ version = "1.0.0" dependencies = [ "byteorder", "crossbeam-utils 0.6.5", - "parking_lot", + "parking_lot 0.7.1", "rand 0.6.1", "scopeguard 0.3.3", "serde", "serde_json", "smallvec", - "syn", + "syn 0.15.35", "winapi 0.3.6", ] @@ -3131,7 +3309,7 @@ dependencies = [ "log", "memmap", "num_cpus", - "parking_lot", + "parking_lot 0.7.1", "rustc", "rustc_apfloat", "rustc_codegen_utils", @@ -3174,7 +3352,7 @@ dependencies = [ "jobserver", "lazy_static 1.3.0", "log", - "parking_lot", + "parking_lot 0.7.1", "rustc-hash", "rustc-rayon", "rustc-rayon-core", @@ -3314,9 +3492,9 @@ name = "rustc_macros" version = "0.1.0" dependencies = [ "itertools 0.8.0", - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", "synstructure", ] @@ -3555,20 +3733,19 @@ dependencies = [ [[package]] name = "rustfmt-config_proc_macro" -version = "0.1.2" +version = "0.2.0" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.3", + "quote 1.0.2", "serde", - "syn", + "syn 1.0.5", ] [[package]] name = "rustfmt-nightly" -version = "1.4.6" +version = "1.4.8" dependencies = [ "annotate-snippets", - "atty", "bytecount", "cargo_metadata", "derive-new", @@ -3589,7 +3766,7 @@ dependencies = [ "rustfmt-config_proc_macro", "serde", "serde_json", - "structopt", + "structopt 0.3.1", "term 0.6.0", "toml", "unicode-segmentation", @@ -3698,18 +3875,9 @@ version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "477b13b646f5b5b56fc95bedfc3b550d12141ce84f466f6c44b9a17589923885" dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_ignored" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190e9765dcedb56be63b6e0993a006c7e3b071a016a304736e4a315dc01fb142" -dependencies = [ - "serde", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", ] [[package]] @@ -3732,6 +3900,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd02c7587ec314570041b2754829f84d873ced14a96d1fd1823531e11db40573" +dependencies = [ + "proc-macro2 1.0.3", + "quote 1.0.2", + "syn 1.0.5", +] + [[package]] name = "serde_urlencoded" version = "0.5.5" @@ -3889,8 +4068,8 @@ checksum = "1eea1eee654ef80933142157fdad9dd8bc43cf7c74e999e369263496f04ff4da" dependencies = [ "phf_generator", "phf_shared", - "proc-macro2", - "quote", + "proc-macro2 0.4.30", + "quote 0.6.12", "string_cache_shared", ] @@ -3911,9 +4090,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" @@ -3922,7 +4101,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7" dependencies = [ "clap", - "structopt-derive", + "structopt-derive 0.2.18", +] + +[[package]] +name = "structopt" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac9d6e93dd792b217bf89cda5c14566e3043960c6f9da890c2ba5d09d07804c" +dependencies = [ + "clap", + "structopt-derive 0.3.1", ] [[package]] @@ -3932,9 +4121,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107" dependencies = [ "heck", - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", +] + +[[package]] +name = "structopt-derive" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ae9e5165d463a0dea76967d021f8d0f9316057bf5163aa2a4843790e842ff37" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2 1.0.3", + "quote 1.0.2", + "syn 1.0.5", ] [[package]] @@ -3950,9 +4152,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8baacebd7b7c9b864d83a6ba7a246232983e277b86fa5cdec77f565715a4b136" dependencies = [ "heck", - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", ] [[package]] @@ -3961,20 +4163,31 @@ version = "0.15.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 0.4.30", + "quote 0.6.12", "unicode-xid 0.1.0", ] +[[package]] +name = "syn" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +dependencies = [ + "proc-macro2 1.0.3", + "quote 1.0.2", + "unicode-xid 0.2.0", +] + [[package]] name = "synstructure" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.30", + "quote 0.6.12", + "syn 0.15.35", "unicode-xid 0.1.0", ] @@ -4154,9 +4367,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ "unicode-width", ] @@ -4279,6 +4492,19 @@ dependencies = [ "log", ] +[[package]] +name = "tokio-named-pipes" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d282d483052288b2308ba5ee795f5673b159c9bdf63c385a05609da782a5eae" +dependencies = [ + "bytes", + "futures", + "mio", + "mio-named-pipes", + "tokio", +] + [[package]] name = "tokio-process" version = "0.2.3" @@ -4307,12 +4533,21 @@ dependencies = [ "log", "mio", "num_cpus", - "parking_lot", + "parking_lot 0.7.1", "slab", "tokio-executor", "tokio-io", ] +[[package]] +name = "tokio-service" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" +dependencies = [ + "futures", +] + [[package]] name = "tokio-signal" version = "0.2.7" @@ -4436,8 +4671,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c99ca245ec273c7e75c8ee58f47b882d0146f3c2c8495158082c6671e8b5335" dependencies = [ "darling", - "quote", - "syn", + "quote 0.6.12", + "syn 0.15.35", ] [[package]] @@ -4574,16 +4809,6 @@ dependencies = [ "serde", ] -[[package]] -name = "url_serde" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea" -dependencies = [ - "serde", - "url 1.7.2", -] - [[package]] name = "utf-8" version = "0.7.2" From 69d503038edc7bd20b6262e60b1640ba88403c52 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 9 Sep 2019 20:32:03 +0200 Subject: [PATCH 16/25] Update LLVM submodule --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 48818e9f5d0f2..71fe7ec06b85f 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 48818e9f5d0f2d5978a9b43ad1a2e8d0b83f6aa0 +Subproject commit 71fe7ec06b85f612fc0e4eb4134c7a7d0f23fac5 From 4dd60f3114ce5b0dcb6cef30cfdd44dc240226f6 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 9 Sep 2019 20:48:57 +0200 Subject: [PATCH 17/25] update reference --- src/doc/reference | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/reference b/src/doc/reference index 090c015f79396..1944efed35989 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 090c015f7939665866432c334957bd536c811870 +Subproject commit 1944efed35989ba57fa397c0724c4921310311fc From 6c74bc951804940800da45ba5b9b3c3e5b613eb3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 9 Sep 2019 13:01:05 -0700 Subject: [PATCH 18/25] Update version of `rustc-std-workspace-*` crates This commit updates the version of the `rustc-std-workspace-*` crates in-tree which are used in `[patch]`. This will guarantee that Cargo will select these versions even if minor updates are published to crates.io because otherwise a newer version on crates.io would be preferred which misses the point of `[patch]`! --- Cargo.lock | 6 +++--- src/tools/rustc-std-workspace-alloc/Cargo.toml | 2 +- src/tools/rustc-std-workspace-core/Cargo.toml | 2 +- src/tools/rustc-std-workspace-std/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 328d96023bc1f..9ffa250c5720f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3046,21 +3046,21 @@ checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" [[package]] name = "rustc-std-workspace-alloc" -version = "1.0.0" +version = "1.99.0" dependencies = [ "alloc", ] [[package]] name = "rustc-std-workspace-core" -version = "1.0.0" +version = "1.99.0" dependencies = [ "core", ] [[package]] name = "rustc-std-workspace-std" -version = "1.0.0" +version = "1.99.0" dependencies = [ "std", ] diff --git a/src/tools/rustc-std-workspace-alloc/Cargo.toml b/src/tools/rustc-std-workspace-alloc/Cargo.toml index ef7dc812af9d4..9e04b14756e06 100644 --- a/src/tools/rustc-std-workspace-alloc/Cargo.toml +++ b/src/tools/rustc-std-workspace-alloc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustc-std-workspace-alloc" -version = "1.0.0" +version = "1.99.0" authors = ["Alex Crichton "] license = 'MIT OR Apache-2.0' description = """ diff --git a/src/tools/rustc-std-workspace-core/Cargo.toml b/src/tools/rustc-std-workspace-core/Cargo.toml index 38ca56a557be6..6b4e7540affc9 100644 --- a/src/tools/rustc-std-workspace-core/Cargo.toml +++ b/src/tools/rustc-std-workspace-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustc-std-workspace-core" -version = "1.0.0" +version = "1.99.0" authors = ["Alex Crichton "] license = 'MIT OR Apache-2.0' description = """ diff --git a/src/tools/rustc-std-workspace-std/Cargo.toml b/src/tools/rustc-std-workspace-std/Cargo.toml index ce1644809dbe6..e41554b74affd 100644 --- a/src/tools/rustc-std-workspace-std/Cargo.toml +++ b/src/tools/rustc-std-workspace-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustc-std-workspace-std" -version = "1.0.0" +version = "1.99.0" authors = ["Alex Crichton "] license = 'MIT OR Apache-2.0' description = """ From 7eb42c98389e30aada94885d5d3a77c4c8ff543e Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Mon, 9 Sep 2019 13:40:11 -0700 Subject: [PATCH 19/25] Always show backtrace on Fuchsia --- src/libstd/sys_common/backtrace.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs index f434b62aced67..43550ab04ca66 100644 --- a/src/libstd/sys_common/backtrace.rs +++ b/src/libstd/sys_common/backtrace.rs @@ -117,6 +117,12 @@ where // For now logging is turned off by default, and this function checks to see // whether the magical environment variable is present to see if it's turned on. pub fn log_enabled() -> Option { + // Setting environment variables for Fuchsia components isn't a standard + // or easily supported workflow. For now, always display backtraces. + if cfg!(target_os = "fuchsia") { + return Some(PrintFmt::Full); + } + static ENABLED: atomic::AtomicIsize = atomic::AtomicIsize::new(0); match ENABLED.load(Ordering::SeqCst) { 0 => {} From 007a58d4ce01f945426f240d387f69dfe3198a6b Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 9 Sep 2019 21:25:49 -0400 Subject: [PATCH 20/25] Switch rustdoc logging to RUSTDOC_LOG This better aligns with Cargo (CARGO_LOG) and rustc (RUSTC_LOG). --- src/librustdoc/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 25ee8b4273d52..2f6f63dcc8dd0 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -90,7 +90,7 @@ pub fn main() { 32_000_000 // 32MB on other platforms }; rustc_driver::set_sigpipe_handler(); - env_logger::init(); + env_logger::init_from_env("RUSTDOC_LOG"); let res = std::thread::Builder::new().stack_size(thread_stack_size).spawn(move || { get_args().map(|args| main_args(&args)).unwrap_or(1) }).unwrap().join().unwrap_or(rustc_driver::EXIT_FAILURE); From 6eb7b698344cfdee6c25d2c6406db33a2ce87aa2 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 9 Sep 2019 21:34:24 -0400 Subject: [PATCH 21/25] Clarify E0507 to note Fn/FnMut relationship to borrowing --- src/librustc_mir/error_codes.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/error_codes.rs b/src/librustc_mir/error_codes.rs index 908dd601df3d0..ba299e9463b8d 100644 --- a/src/librustc_mir/error_codes.rs +++ b/src/librustc_mir/error_codes.rs @@ -1646,7 +1646,14 @@ fn print_fancy_ref(fancy_ref: &FancyNum){ "##, E0507: r##" -You tried to move out of a value which was borrowed. Erroneous code example: +You tried to move out of a value which was borrowed. + +This can also happen when using a type implementing `Fn` or `FnMut`, as neither +allows moving out of them (they usually represent closures which can be called +more than once). Much of the text following applies equally well to non-`FnOnce` +closure bodies. + +Erroneous code example: ```compile_fail,E0507 use std::cell::RefCell; From 2f6e73cb07edc21b1243b270e3e77faf51fcb4e4 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 2 Sep 2019 22:09:15 -0500 Subject: [PATCH 22/25] test/c-variadic: Fix patterns on powerpc64 On architectures such as powerpc64 that use extend_integer_width_to in their C ABI processing, integer parameters shorter than the native register width will be annotated with the ArgAttribute::SExt or ArgAttribute::ZExt attribute, and that attribute will be included in the generated LLVM IR. In this test, all relevant parameters are `i32`, which will get the `signext` annotation on the relevant 64-bit architectures. Match both the annotated and non-annotated case, but enforce that the annotation is applied consistently. --- src/test/codegen/c-variadic.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/test/codegen/c-variadic.rs b/src/test/codegen/c-variadic.rs index bb90a9653f573..2acf95de97ee8 100644 --- a/src/test/codegen/c-variadic.rs +++ b/src/test/codegen/c-variadic.rs @@ -1,4 +1,5 @@ // compile-flags: -C no-prepopulate-passes +// ignore-tidy-linelength #![crate_type = "lib"] #![feature(c_variadic)] @@ -14,13 +15,13 @@ extern "C" { #[unwind(aborts)] // FIXME(#58794) pub unsafe extern "C" fn use_foreign_c_variadic_0() { // Ensure that we correctly call foreign C-variadic functions. - // CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0) + // CHECK: invoke void (i32, ...) @foreign_c_variadic_0([[PARAM:i32( signext)?]] 0) foreign_c_variadic_0(0); - // CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42) + // CHECK: invoke void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42) foreign_c_variadic_0(0, 42i32); - // CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42, i32 1024) + // CHECK: invoke void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024) foreign_c_variadic_0(0, 42i32, 1024i32); - // CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42, i32 1024, i32 0) + // CHECK: invoke void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024, [[PARAM]] 0) foreign_c_variadic_0(0, 42i32, 1024i32, 0i32); } @@ -34,18 +35,18 @@ pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) { #[unwind(aborts)] // FIXME(#58794) pub unsafe extern "C" fn use_foreign_c_variadic_1_1(ap: VaList) { - // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 42) + // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 42) foreign_c_variadic_1(ap, 42i32); } #[unwind(aborts)] // FIXME(#58794) pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) { - // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42) + // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42) foreign_c_variadic_1(ap, 2i32, 42i32); } #[unwind(aborts)] // FIXME(#58794) pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) { - // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42, i32 0) + // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, [[PARAM]] 2, [[PARAM]] 42, [[PARAM]] 0) foreign_c_variadic_1(ap, 2i32, 42i32, 0i32); } @@ -64,12 +65,12 @@ pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 { // Ensure that we generate the correct `call` signature when calling a Rust // defined C-variadic. pub unsafe fn test_c_variadic_call() { - // CHECK: call i32 (i32, ...) @c_variadic(i32 0) + // CHECK: call [[RET:(signext )?i32]] (i32, ...) @c_variadic([[PARAM]] 0) c_variadic(0); - // CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42) + // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42) c_variadic(0, 42i32); - // CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42, i32 1024) + // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024) c_variadic(0, 42i32, 1024i32); - // CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42, i32 1024, i32 0) + // CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42, [[PARAM]] 1024, [[PARAM]] 0) c_variadic(0, 42i32, 1024i32, 0i32); } From 79263afb3eeb3f02cc7b9b9c328206283d85e30a Mon Sep 17 00:00:00 2001 From: hman523 Date: Mon, 9 Sep 2019 21:19:01 -0500 Subject: [PATCH 23/25] Changed instant is earlier to instant is later --- src/libstd/time.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/time.rs b/src/libstd/time.rs index d59085cd44a6f..dbec4da24f96a 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -216,7 +216,7 @@ impl Instant { } /// Returns the amount of time elapsed from another instant to this one, - /// or None if that instant is earlier than this one. + /// or None if that instant is later than this one. /// /// # Examples /// From 63fad69a9967a56e33927aa31c50768bc1498588 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 8 Sep 2019 21:22:51 +0100 Subject: [PATCH 24/25] lowering: extend temporary lifetimes around await This commit changes the HIR lowering around `await` so that temporary lifetimes are extended. Previously, await was lowered as: ```rust { let mut pinned = future; loop { match ::std::future::poll_with_tls_context(unsafe { <::std::pin::Pin>::new_unchecked(&mut pinned) }) { ::std::task::Poll::Ready(result) => break result, ::std::task::Poll::Pending => {} } yield (); } } ``` With this commit, await is lowered as: ```rust match future { mut pinned => loop { match ::std::future::poll_with_tls_context(unsafe { <::std::pin::Pin>::new_unchecked(&mut pinned) }) { ::std::task::Poll::Ready(result) => break result, ::std::task::Poll::Pending => {} } yield (); } } ``` However, this change has the following side-effects: - All temporaries in future will be considered to live across a yield for the purpose of auto-traits. - Borrowed temporaries in future are likely to be considered to be live across the yield for the purpose of the generator transform. Signed-off-by: David Wood --- src/librustc/hir/lowering/expr.rs | 35 ++++++++----------- .../ui/async-await/async-fn-nonsend.stderr | 24 ++++++------- ...-63832-await-short-temporary-lifetime-1.rs | 19 ++++++++++ ...ue-63832-await-short-temporary-lifetime.rs | 12 +++++++ 4 files changed, 58 insertions(+), 32 deletions(-) create mode 100644 src/test/ui/async-await/issue-63832-await-short-temporary-lifetime-1.rs create mode 100644 src/test/ui/async-await/issue-63832-await-short-temporary-lifetime.rs diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs index 0d8986ddec3c7..a46cdabbb518f 100644 --- a/src/librustc/hir/lowering/expr.rs +++ b/src/librustc/hir/lowering/expr.rs @@ -507,14 +507,13 @@ impl LoweringContext<'_> { /// Desugar `.await` into: /// ```rust - /// { - /// let mut pinned = ; - /// loop { + /// match { + /// mut pinned => loop { /// match ::std::future::poll_with_tls_context(unsafe { - /// ::std::pin::Pin::new_unchecked(&mut pinned) + /// <::std::pin::Pin>::new_unchecked(&mut pinned) /// }) { /// ::std::task::Poll::Ready(result) => break result, - /// ::std::task::Poll::Pending => {}, + /// ::std::task::Poll::Pending => {} /// } /// yield (); /// } @@ -549,21 +548,12 @@ impl LoweringContext<'_> { self.allow_gen_future.clone(), ); - // let mut pinned = ; - let expr = P(self.lower_expr(expr)); let pinned_ident = Ident::with_dummy_span(sym::pinned); let (pinned_pat, pinned_pat_hid) = self.pat_ident_binding_mode( span, pinned_ident, hir::BindingAnnotation::Mutable, ); - let pinned_let = self.stmt_let_pat( - ThinVec::new(), - span, - Some(expr), - pinned_pat, - hir::LocalSource::AwaitDesugar, - ); // ::std::future::poll_with_tls_context(unsafe { // ::std::pin::Pin::new_unchecked(&mut pinned) @@ -621,7 +611,7 @@ impl LoweringContext<'_> { self.arm(hir_vec![pending_pat], empty_block) }; - let match_stmt = { + let inner_match_stmt = { let match_expr = self.expr_match( span, poll_expr, @@ -643,10 +633,11 @@ impl LoweringContext<'_> { let loop_block = P(self.block_all( span, - hir_vec![match_stmt, yield_stmt], + hir_vec![inner_match_stmt, yield_stmt], None, )); + // loop { .. } let loop_expr = P(hir::Expr { hir_id: loop_hir_id, node: hir::ExprKind::Loop( @@ -658,10 +649,14 @@ impl LoweringContext<'_> { attrs: ThinVec::new(), }); - hir::ExprKind::Block( - P(self.block_all(span, hir_vec![pinned_let], Some(loop_expr))), - None, - ) + // mut pinned => loop { ... } + let pinned_arm = self.arm(hir_vec![pinned_pat], loop_expr); + + // match { + // mut pinned => loop { .. } + // } + let expr = P(self.lower_expr(expr)); + hir::ExprKind::Match(expr, hir_vec![pinned_arm], hir::MatchSource::AwaitDesugar) } fn lower_expr_closure( diff --git a/src/test/ui/async-await/async-fn-nonsend.stderr b/src/test/ui/async-await/async-fn-nonsend.stderr index fad90b29c0e6e..d2f92f04f40a7 100644 --- a/src/test/ui/async-await/async-fn-nonsend.stderr +++ b/src/test/ui/async-await/async-fn-nonsend.stderr @@ -9,9 +9,9 @@ LL | assert_send(local_dropped_before_await()); | = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` = note: required because it appears within the type `impl std::fmt::Debug` - = note: required because it appears within the type `{impl std::fmt::Debug, impl std::future::Future, ()}` - = note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, impl std::future::Future, ()}]` - = note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, impl std::future::Future, ()}]>` + = note: required because it appears within the type `{impl std::fmt::Debug, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}` + = note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]` + = note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:21:39: 26:2 {impl std::fmt::Debug, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]>` = note: required because it appears within the type `impl std::future::Future` = note: required because it appears within the type `impl std::future::Future` @@ -26,9 +26,9 @@ LL | assert_send(non_send_temporary_in_match()); | = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` = note: required because it appears within the type `impl std::fmt::Debug` - = note: required because it appears within the type `{fn(impl std::fmt::Debug) -> std::option::Option {std::option::Option::::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option, impl std::future::Future, ()}` - = note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {fn(impl std::fmt::Debug) -> std::option::Option {std::option::Option::::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option, impl std::future::Future, ()}]` - = note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {fn(impl std::fmt::Debug) -> std::option::Option {std::option::Option::::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option, impl std::future::Future, ()}]>` + = note: required because it appears within the type `{fn(impl std::fmt::Debug) -> std::option::Option {std::option::Option::::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}` + = note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {fn(impl std::fmt::Debug) -> std::option::Option {std::option::Option::::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]` + = note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:28:40: 37:2 {fn(impl std::fmt::Debug) -> std::option::Option {std::option::Option::::Some}, fn() -> impl std::fmt::Debug {non_send}, impl std::fmt::Debug, std::option::Option, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]>` = note: required because it appears within the type `impl std::future::Future` = note: required because it appears within the type `impl std::future::Future` @@ -45,9 +45,9 @@ LL | assert_send(non_sync_with_method_call()); = note: required because of the requirements on the impl of `std::marker::Send` for `&mut dyn std::fmt::Write` = note: required because it appears within the type `std::fmt::Formatter<'_>` = note: required because of the requirements on the impl of `std::marker::Send` for `&mut std::fmt::Formatter<'_>` - = note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}` - = note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}]` - = note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}]>` + = note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}` + = note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]` + = note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]>` = note: required because it appears within the type `impl std::future::Future` = note: required because it appears within the type `impl std::future::Future` @@ -68,9 +68,9 @@ LL | assert_send(non_sync_with_method_call()); = note: required because of the requirements on the impl of `std::marker::Send` for `std::slice::Iter<'_, std::fmt::ArgumentV1<'_>>` = note: required because it appears within the type `std::fmt::Formatter<'_>` = note: required because of the requirements on the impl of `std::marker::Send` for `&mut std::fmt::Formatter<'_>` - = note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}` - = note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}]` - = note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, impl std::future::Future, ()}]>` + = note: required because it appears within the type `for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}` + = note: required because it appears within the type `[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]` + = note: required because it appears within the type `std::future::GenFuture<[static generator@$DIR/async-fn-nonsend.rs:39:38: 45:2 for<'r, 's> {&'r mut std::fmt::Formatter<'s>, bool, fn() -> impl std::future::Future {fut}, impl std::future::Future, ()}]>` = note: required because it appears within the type `impl std::future::Future` = note: required because it appears within the type `impl std::future::Future` diff --git a/src/test/ui/async-await/issue-63832-await-short-temporary-lifetime-1.rs b/src/test/ui/async-await/issue-63832-await-short-temporary-lifetime-1.rs new file mode 100644 index 0000000000000..54059b29f72e2 --- /dev/null +++ b/src/test/ui/async-await/issue-63832-await-short-temporary-lifetime-1.rs @@ -0,0 +1,19 @@ +// check-pass +// edition:2018 + +struct Test(String); + +impl Test { + async fn borrow_async(&self) {} + + fn with(&mut self, s: &str) -> &mut Self { + self.0 = s.into(); + self + } +} + +async fn test() { + Test("".to_string()).with("123").borrow_async().await; +} + +fn main() { } diff --git a/src/test/ui/async-await/issue-63832-await-short-temporary-lifetime.rs b/src/test/ui/async-await/issue-63832-await-short-temporary-lifetime.rs new file mode 100644 index 0000000000000..c5ea2b821ad78 --- /dev/null +++ b/src/test/ui/async-await/issue-63832-await-short-temporary-lifetime.rs @@ -0,0 +1,12 @@ +// check-pass +// edition:2018 + +async fn foo(x: &[Vec]) -> u32 { + 0 +} + +async fn bar() { + foo(&[vec![123]]).await; +} + +fn main() { } From 1e7faef2204f02d79506559d298f61dc3dcd24b3 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 10 Sep 2019 13:43:54 +0300 Subject: [PATCH 25/25] rustc_mir: buffer -Zdump-mir output instead of pestering the kernel constantly. --- src/librustc_mir/util/pretty.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index ac2701971dfd5..c35c9e4da9f48 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -227,12 +227,12 @@ pub(crate) fn create_dump_file( pass_name: &str, disambiguator: &dyn Display, source: MirSource<'tcx>, -) -> io::Result { +) -> io::Result> { let file_path = dump_path(tcx, extension, pass_num, pass_name, disambiguator, source); if let Some(parent) = file_path.parent() { fs::create_dir_all(parent)?; } - fs::File::create(&file_path) + Ok(io::BufWriter::new(fs::File::create(&file_path)?)) } /// Write out a human-readable textual representation for the given MIR.