From fd064e041af61b497778583013298e5d828ffff6 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 5 Dec 2017 09:07:12 -0700 Subject: [PATCH 01/19] Stablize RefCell::{replace, swap} RefCell::replace_with is not stablized in this PR, since it wasn't part of the RFC. --- src/libcore/cell.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index d4cd3f6264efc..5da4a5de742ee 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -584,7 +584,6 @@ impl RefCell { /// # Examples /// /// ``` - /// #![feature(refcell_replace_swap)] /// use std::cell::RefCell; /// let cell = RefCell::new(5); /// let old_value = cell.replace(6); @@ -592,7 +591,7 @@ impl RefCell { /// assert_eq!(cell, RefCell::new(6)); /// ``` #[inline] - #[unstable(feature = "refcell_replace_swap", issue="43570")] + #[stable(feature = "refcell_replace_swap", since="1.24.0")] pub fn replace(&self, t: T) -> T { mem::replace(&mut *self.borrow_mut(), t) } @@ -636,7 +635,6 @@ impl RefCell { /// # Examples /// /// ``` - /// #![feature(refcell_replace_swap)] /// use std::cell::RefCell; /// let c = RefCell::new(5); /// let d = RefCell::new(6); @@ -645,7 +643,7 @@ impl RefCell { /// assert_eq!(d, RefCell::new(5)); /// ``` #[inline] - #[unstable(feature = "refcell_replace_swap", issue="43570")] + #[stable(feature = "refcell_replace_swap", since="1.24.0")] pub fn swap(&self, other: &Self) { mem::swap(&mut *self.borrow_mut(), &mut *other.borrow_mut()) } From 28a19bfa7f418d3aa4cbe6da3aba4b3b2fb87a13 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 5 Dec 2017 12:03:57 -0700 Subject: [PATCH 02/19] Move replace_with to its own feature flag I'm not allowed to have the same feature flag associated with multiple stability levels. --- src/libcore/cell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 5da4a5de742ee..dc9f4b88c206b 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -616,7 +616,7 @@ impl RefCell { /// assert_eq!(cell, RefCell::new(6)); /// ``` #[inline] - #[unstable(feature = "refcell_replace_swap", issue="43570")] + #[unstable(feature = "refcell_replace_with", issue="43570")] pub fn replace_with T>(&self, f: F) -> T { let mut_borrow = &mut *self.borrow_mut(); let replacement = f(mut_borrow); From 19775f73a39c73298c3507fe861bec8dae4e4c1f Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 5 Dec 2017 13:15:35 -0700 Subject: [PATCH 03/19] Update cell.rs --- src/libcore/cell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index dc9f4b88c206b..d2690ff64ac48 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -591,7 +591,7 @@ impl RefCell { /// assert_eq!(cell, RefCell::new(6)); /// ``` #[inline] - #[stable(feature = "refcell_replace_swap", since="1.24.0")] + #[stable(feature = "refcell_replace", since="1.24.0")] pub fn replace(&self, t: T) -> T { mem::replace(&mut *self.borrow_mut(), t) } @@ -616,7 +616,7 @@ impl RefCell { /// assert_eq!(cell, RefCell::new(6)); /// ``` #[inline] - #[unstable(feature = "refcell_replace_with", issue="43570")] + #[unstable(feature = "refcell_replace_swap", issue="43570")] pub fn replace_with T>(&self, f: F) -> T { let mut_borrow = &mut *self.borrow_mut(); let replacement = f(mut_borrow); @@ -643,7 +643,7 @@ impl RefCell { /// assert_eq!(d, RefCell::new(5)); /// ``` #[inline] - #[stable(feature = "refcell_replace_swap", since="1.24.0")] + #[stable(feature = "refcell_swap", since="1.24.0")] pub fn swap(&self, other: &Self) { mem::swap(&mut *self.borrow_mut(), &mut *other.borrow_mut()) } From bd1cf04ca7b9ffb3654aaa6c0b3106d6a381bc7f Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 11 Dec 2017 23:02:14 +0000 Subject: [PATCH 04/19] Reject superfluous `::` in IPv6 addresses Fixes #46263. --- src/libstd/net/ip.rs | 3 +++ src/libstd/net/parser.rs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index c832f8a934d3d..0d73a6f4fd7f4 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -1451,6 +1451,9 @@ mod tests { // two double colons let none: Option = "1:2::6::8".parse().ok(); assert_eq!(None, none); + // `::` indicating zero groups of zeros + let none: Option = "1:2:3:4::5:6:7:8".parse().ok(); + assert_eq!(None, none); } #[test] diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index 9f7125fb935f7..261d44eebaa27 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -246,7 +246,9 @@ impl<'a> Parser<'a> { } let mut tail = [0; 8]; - let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size); + // `::` indicates one or more groups of 16 bits of zeros + let limit = 8 - (head_size + 1); + let (tail_size, _) = read_groups(self, &mut tail, limit); Some(ipv6_addr_from_head_tail(&head[..head_size], &tail[..tail_size])) } From 7104e8f7b4da1cfdbd82fa7c4f81ed31be22f95e Mon Sep 17 00:00:00 2001 From: varkor Date: Sun, 17 Dec 2017 15:22:50 +0000 Subject: [PATCH 05/19] Add an option to allow rustdoc to list modules by appearance The `--sort-modules-by-appearance` option will list modules in the order that they appear in the source, rather than sorting them alphabetically (as is the default). This resolves #8552. --- src/librustdoc/html/render.rs | 17 +++++++++++++---- src/librustdoc/lib.rs | 7 ++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 8ed35aa8f4396..9f981e97a762b 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -129,6 +129,9 @@ pub struct SharedContext { /// The directories that have already been created in this doc run. Used to reduce the number /// of spurious `create_dir_all` calls. pub created_dirs: RefCell>, + /// This flag indicates whether listings of modules (in the side bar and documentation itself) + /// should be ordered alphabetically or in order of appearance (in the source code). + pub sort_modules_alphabetically: bool, } impl SharedContext { @@ -491,7 +494,8 @@ pub fn run(mut krate: clean::Crate, passes: FxHashSet, css_file_extension: Option, renderinfo: RenderInfo, - render_type: RenderType) -> Result<(), Error> { + render_type: RenderType, + sort_modules_alphabetically: bool) -> Result<(), Error> { let src_root = match krate.src { FileName::Real(ref p) => match p.parent() { Some(p) => p.to_path_buf(), @@ -514,6 +518,7 @@ pub fn run(mut krate: clean::Crate, css_file_extension: css_file_extension.clone(), markdown_warnings: RefCell::new(vec![]), created_dirs: RefCell::new(FxHashSet()), + sort_modules_alphabetically, }; // If user passed in `--playground-url` arg, we fill in crate name here @@ -1654,8 +1659,10 @@ impl Context { .push((myname, Some(plain_summary_line(item.doc_value())))); } - for (_, items) in &mut map { - items.sort(); + if self.shared.sort_modules_alphabetically { + for (_, items) in &mut map { + items.sort(); + } } map } @@ -2013,7 +2020,9 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, name_key(lhs).cmp(&name_key(rhs)) } - indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2)); + if cx.shared.sort_modules_alphabetically { + indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2)); + } // This call is to remove reexport duplicates in cases such as: // // ``` diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 1cf71eca84681..1b0ff3a71d70e 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -253,6 +253,9 @@ pub fn opts() -> Vec { unstable("linker", |o| { o.optopt("", "linker", "linker used for building executable test code", "PATH") }), + unstable("sort-modules-by-appearance", |o| { + o.optflag("", "sort-modules-by-appearance", "sort modules by where they appear in the program, rather than alphabetically") + }), ] } @@ -369,6 +372,7 @@ pub fn main_args(args: &[String]) -> isize { let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from); let display_warnings = matches.opt_present("display-warnings"); let linker = matches.opt_str("linker").map(PathBuf::from); + let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance"); match (should_test, markdown_input) { (true, true) => { @@ -398,7 +402,8 @@ pub fn main_args(args: &[String]) -> isize { passes.into_iter().collect(), css_file_extension, renderinfo, - render_type) + render_type, + sort_modules_alphabetically) .expect("failed to generate documentation"); 0 } From 8c7b0938c2c425cbf46f363d84d326105d2a80ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Thu, 14 Dec 2017 10:25:14 +0100 Subject: [PATCH 06/19] add aarch64-unknown-openbsd support - make liblibc to point to libc with aarch64-unknown-openbsd - make c_char (in std::os::raw) to point to right value --- src/liblibc | 2 +- src/libstd/os/raw.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/liblibc b/src/liblibc index 1a2f9639f8d29..ef9eefb6df3f3 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit 1a2f9639f8d293cefbe050053a574decbfe863f7 +Subproject commit ef9eefb6df3f3a2cb989e8050519661faa7d7118 diff --git a/src/libstd/os/raw.rs b/src/libstd/os/raw.rs index 95439640f7cc5..279caf8053a85 100644 --- a/src/libstd/os/raw.rs +++ b/src/libstd/os/raw.rs @@ -22,6 +22,7 @@ use fmt; all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), all(target_os = "l4re", target_arch = "x86_64"), + all(target_os = "openbsd", target_arch = "aarch64"), all(target_os = "fuchsia", target_arch = "aarch64")))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8; #[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64", @@ -32,6 +33,7 @@ use fmt; all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), all(target_os = "l4re", target_arch = "x86_64"), + all(target_os = "openbsd", target_arch = "aarch64"), all(target_os = "fuchsia", target_arch = "aarch64"))))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8; #[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8; From 926865ba2e4e9c137383003d76b6541fe29f6431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antal=20Szab=C3=B3?= Date: Sun, 17 Dec 2017 23:23:10 +0100 Subject: [PATCH 07/19] Distribute intrinsic.natvis with the compiler for windows-msvc. --- src/bootstrap/dist.rs | 1 + src/etc/rust-windbg.cmd | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index f04ce47c83fb5..78de9ec62d918 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -504,6 +504,7 @@ impl Step for DebuggerScripts { install(&build.src.join("src/etc/rust-windbg.cmd"), &sysroot.join("bin"), 0o755); + cp_debugger_script("natvis/intrinsic.natvis"); cp_debugger_script("natvis/liballoc.natvis"); cp_debugger_script("natvis/libcore.natvis"); } else { diff --git a/src/etc/rust-windbg.cmd b/src/etc/rust-windbg.cmd index b09b37c1db423..8da4efb58039d 100644 --- a/src/etc/rust-windbg.cmd +++ b/src/etc/rust-windbg.cmd @@ -15,4 +15,4 @@ for /f "delims=" %%i in ('rustc --print=sysroot') do set rustc_sysroot=%%i set rust_etc=%rustc_sysroot%\lib\rustlib\etc -windbg -c ".nvload %rust_etc%\liballoc.natvis; .nvload %rust_etc%\libcore.natvis;" %* +windbg -c ".nvload %rust_etc%\intrinsic.natvis; .nvload %rust_etc%\liballoc.natvis; .nvload %rust_etc%\libcore.natvis;" %* From 796264b6dfa6161e9a3f2c6fa7af830e9ed848df Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Fri, 15 Dec 2017 14:03:48 -0600 Subject: [PATCH 08/19] incr.comp.: Add -Cincremental in addition to -Zincremental --- src/librustc/session/config.rs | 26 +++++++++++++++++++++++--- src/librustc_trans/base.rs | 2 +- src/tools/compiletest/src/runtest.rs | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 009fb61984638..a1cf38ae336d2 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1013,6 +1013,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, "set the threshold for inlining a function (default: 225)"), panic: Option = (None, parse_panic_strategy, [TRACKED], "panic strategy to compile crate with"), + incremental: Option = (None, parse_opt_string, [UNTRACKED], + "enable incremental compilation"), } options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, @@ -1663,7 +1665,24 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) early_error(error_format, "Value for codegen units must be a positive nonzero integer"); } - if cg.lto && debugging_opts.incremental.is_some() { + let incremental = match (&debugging_opts.incremental, &cg.incremental) { + (&Some(ref path1), &Some(ref path2)) => { + if path1 != path2 { + early_error(error_format, + &format!("conflicting paths for `-Z incremental` and \ + `-C incremental` specified: {} versus {}", + path1, + path2)); + } else { + Some(path1) + } + } + (&Some(ref path), &None) => Some(path), + (&None, &Some(ref path)) => Some(path), + (&None, &None) => None, + }.map(|m| PathBuf::from(m)); + + if cg.lto && incremental.is_some() { early_error(error_format, "can't perform LTO when compiling incrementally"); } @@ -1837,8 +1856,6 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) let crate_name = matches.opt_str("crate-name"); - let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m)); - (Options { crate_types, optimize: opt_level, @@ -2581,6 +2598,9 @@ mod tests { opts.cg.save_temps = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); + opts.cg.incremental = Some(String::from("abc")); + assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); + // Make sure changing a [TRACKED] option changes the hash opts = reference.clone(); diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index bfc72ff06aa70..1314c98c8a30d 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -1025,7 +1025,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>( assert_symbols_are_distinct(tcx, items.iter()); - let strategy = if tcx.sess.opts.debugging_opts.incremental.is_some() { + let strategy = if tcx.sess.opts.incremental.is_some() { PartitioningStrategy::PerModule } else { PartitioningStrategy::FixedUnitCount(tcx.sess.codegen_units()) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 06e798554167b..3aee88136a1ff 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1506,7 +1506,7 @@ impl<'test> TestCx<'test> { if let Some(ref incremental_dir) = self.props.incremental_dir { rustc.args(&[ - "-Z", + "-C", &format!("incremental={}", incremental_dir.display()), ]); rustc.args(&["-Z", "incremental-verify-ich"]); From c0ff8144c49bdcad19eaa9b9847a7ea9e008cfee Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 18 Dec 2017 19:52:45 +0000 Subject: [PATCH 09/19] Fix tidy issue --- src/librustdoc/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 1b0ff3a71d70e..7ebacdec1f0b2 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -254,7 +254,8 @@ pub fn opts() -> Vec { o.optopt("", "linker", "linker used for building executable test code", "PATH") }), unstable("sort-modules-by-appearance", |o| { - o.optflag("", "sort-modules-by-appearance", "sort modules by where they appear in the program, rather than alphabetically") + o.optflag("", "sort-modules-by-appearance", "sort modules by where they appear in the \ + program, rather than alphabetically") }), ] } From 1d5ead453dd96c1040a12cbb3b0180027af165c9 Mon Sep 17 00:00:00 2001 From: Vitaly _Vi Shukela Date: Tue, 19 Dec 2017 00:35:43 +0300 Subject: [PATCH 10/19] Add Hash impl for SystemTime and Instant Closes #46670. --- src/libstd/sys/redox/time.rs | 12 ++++++++++-- src/libstd/sys/unix/time.rs | 16 ++++++++++++---- src/libstd/sys/wasm/time.rs | 4 ++-- src/libstd/sys/windows/time.rs | 9 ++++++++- src/libstd/time/mod.rs | 4 ++-- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/libstd/sys/redox/time.rs b/src/libstd/sys/redox/time.rs index 6c071afd42d05..cf798500b7fd2 100644 --- a/src/libstd/sys/redox/time.rs +++ b/src/libstd/sys/redox/time.rs @@ -13,6 +13,7 @@ use fmt; use sys::{cvt, syscall}; use time::Duration; use convert::TryInto; +use core::hash::{Hash, Hasher}; const NSEC_PER_SEC: u64 = 1_000_000_000; @@ -110,12 +111,19 @@ impl Ord for Timespec { } } -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +impl Hash for Timespec { + fn hash(&self, state: &mut H) { + self.t.tv_sec.hash(state); + self.t.tv_nsec.hash(state); + } +} + +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Instant { t: Timespec, } -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SystemTime { t: Timespec, } diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index 837cd7292e280..8312793590993 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -11,6 +11,7 @@ use cmp::Ordering; use libc; use time::Duration; +use core::hash::{Hash, Hasher}; pub use self::inner::{Instant, SystemTime, UNIX_EPOCH}; use convert::TryInto; @@ -111,6 +112,13 @@ impl Ord for Timespec { } } +impl Hash for Timespec { + fn hash(&self, state: &mut H) { + self.t.tv_sec.hash(state); + self.t.tv_nsec.hash(state); + } +} + #[cfg(any(target_os = "macos", target_os = "ios"))] mod inner { use fmt; @@ -123,12 +131,12 @@ mod inner { use super::NSEC_PER_SEC; use super::Timespec; - #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub struct Instant { t: u64 } - #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SystemTime { t: Timespec, } @@ -255,12 +263,12 @@ mod inner { use super::Timespec; - #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Instant { t: Timespec, } - #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SystemTime { t: Timespec, } diff --git a/src/libstd/sys/wasm/time.rs b/src/libstd/sys/wasm/time.rs index 7907720e4dac6..c269def98f6ff 100644 --- a/src/libstd/sys/wasm/time.rs +++ b/src/libstd/sys/wasm/time.rs @@ -11,10 +11,10 @@ use fmt; use time::Duration; -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub struct Instant; -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SystemTime; pub const UNIX_EPOCH: SystemTime = SystemTime; diff --git a/src/libstd/sys/windows/time.rs b/src/libstd/sys/windows/time.rs index 1be29b5139a55..07e64d386a1c2 100644 --- a/src/libstd/sys/windows/time.rs +++ b/src/libstd/sys/windows/time.rs @@ -17,11 +17,12 @@ use sys::cvt; use sys_common::mul_div_u64; use time::Duration; use convert::TryInto; +use core::hash::{Hash, Hasher}; const NANOS_PER_SEC: u64 = 1_000_000_000; const INTERVALS_PER_SEC: u64 = NANOS_PER_SEC / 100; -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] pub struct Instant { t: c::LARGE_INTEGER, } @@ -173,6 +174,12 @@ impl From for SystemTime { } } +impl Hash for SystemTime { + fn hash(&self, state: &mut H) { + self.intervals().hash(state) + } +} + fn dur2intervals(d: &Duration) -> i64 { d.as_secs() .checked_mul(INTERVALS_PER_SEC) diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index d4993ded843dd..6ce3b3e8a0031 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -66,7 +66,7 @@ mod duration; /// println!("{}", now.elapsed().as_secs()); /// } /// ``` -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[stable(feature = "time2", since = "1.8.0")] pub struct Instant(time::Instant); @@ -118,7 +118,7 @@ pub struct Instant(time::Instant); /// } /// } /// ``` -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[stable(feature = "time2", since = "1.8.0")] pub struct SystemTime(time::SystemTime); From 03530ee1a7e9320b518af9cefafbee5d32d8e519 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 26 Nov 2017 23:24:49 +0100 Subject: [PATCH 11/19] Add tests for hidden types --- src/test/rustdoc/hidden-trait-struct-impls.rs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/rustdoc/hidden-trait-struct-impls.rs diff --git a/src/test/rustdoc/hidden-trait-struct-impls.rs b/src/test/rustdoc/hidden-trait-struct-impls.rs new file mode 100644 index 0000000000000..d16932828d04f --- /dev/null +++ b/src/test/rustdoc/hidden-trait-struct-impls.rs @@ -0,0 +1,32 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +#[doc(hidden)] +pub trait Foo {} + +trait Dark {} + +pub trait Bam {} + +pub struct Bar; + +struct Hidden; + +// @!has foo/struct.Bar.html '//*[@id="impl-Foo"]' 'impl Foo for Bar' +impl Foo for Bar {} +// @!has foo/struct.Bar.html '//*[@id="impl-Dark"]' 'impl Dark for Bar' +impl Dark for Bar {} +// @has foo/struct.Bar.html '//*[@id="impl-Bam"]' 'impl Bam for Bar' +// @has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar' +impl Bam for Bar {} +// @!has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden' +impl Bam for Hidden {} From b3c6102be3752fa1b70cc5f9cf9903b13a4c3928 Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 19 Dec 2017 01:05:06 +0000 Subject: [PATCH 12/19] Add a test for `--sort-modules-by-appearance` --- .../rustdoc/sort-modules-by-appearance.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/rustdoc/sort-modules-by-appearance.rs diff --git a/src/test/rustdoc/sort-modules-by-appearance.rs b/src/test/rustdoc/sort-modules-by-appearance.rs new file mode 100644 index 0000000000000..abffe6fb95b99 --- /dev/null +++ b/src/test/rustdoc/sort-modules-by-appearance.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests the rustdoc --sort-modules-by-appearance option, that allows module declarations to appear +// in the order they are declared in the source code, rather than only alphabetically. + +// compile-flags: -Z unstable-options --sort-modules-by-appearance + +pub mod module_b {} + +pub mod module_c {} + +pub mod module_a {} + +// @matches 'sort_modules_by_appearance/index.html' '(?s)module_b.*module_c.*module_a' +// @matches 'sort_modules_by_appearance/sidebar-items.js' '"module_b".*"module_c".*"module_a"' From 3e98f18280a9204f9476f3a7ffc83782ea81dfdf Mon Sep 17 00:00:00 2001 From: Diggory Blake Date: Mon, 18 Dec 2017 23:16:00 +0000 Subject: [PATCH 13/19] Always print floats with a decimal point with the Debug formatter --- src/libcore/fmt/float.rs | 17 +++++++++-------- src/libcore/tests/fmt/float.rs | 4 ++++ src/test/run-pass/ifmt.rs | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 4825c2aa13264..03e7a9a49d8a7 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -32,22 +32,23 @@ fn float_to_decimal_common_exact(fmt: &mut Formatter, num: &T, // Don't inline this so callers that call both this and the above won't wind // up using the combined stack space of both functions in some cases. #[inline(never)] -fn float_to_decimal_common_shortest(fmt: &mut Formatter, - num: &T, sign: flt2dec::Sign) -> Result +fn float_to_decimal_common_shortest(fmt: &mut Formatter, num: &T, + sign: flt2dec::Sign, precision: usize) -> Result where T: flt2dec::DecodableFloat { unsafe { // enough for f32 and f64 let mut buf: [u8; flt2dec::MAX_SIG_DIGITS] = mem::uninitialized(); let mut parts: [flt2dec::Part; 4] = mem::uninitialized(); - let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, - *num, sign, 0, false, &mut buf, &mut parts); + let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num, + sign, precision, false, &mut buf, &mut parts); fmt.pad_formatted_parts(&formatted) } } // Common code of floating point Debug and Display. -fn float_to_decimal_common(fmt: &mut Formatter, num: &T, negative_zero: bool) -> Result +fn float_to_decimal_common(fmt: &mut Formatter, num: &T, + negative_zero: bool, min_precision: usize) -> Result where T: flt2dec::DecodableFloat { let force_sign = fmt.sign_plus(); @@ -61,7 +62,7 @@ fn float_to_decimal_common(fmt: &mut Formatter, num: &T, negative_zero: bool) if let Some(precision) = fmt.precision { float_to_decimal_common_exact(fmt, num, sign, precision) } else { - float_to_decimal_common_shortest(fmt, num, sign) + float_to_decimal_common_shortest(fmt, num, sign, min_precision) } } @@ -125,14 +126,14 @@ macro_rules! floating { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for $ty { fn fmt(&self, fmt: &mut Formatter) -> Result { - float_to_decimal_common(fmt, self, true) + float_to_decimal_common(fmt, self, true, 1) } } #[stable(feature = "rust1", since = "1.0.0")] impl Display for $ty { fn fmt(&self, fmt: &mut Formatter) -> Result { - float_to_decimal_common(fmt, self, false) + float_to_decimal_common(fmt, self, false, 0) } } diff --git a/src/libcore/tests/fmt/float.rs b/src/libcore/tests/fmt/float.rs index 695001312e4d5..138c3970e9087 100644 --- a/src/libcore/tests/fmt/float.rs +++ b/src/libcore/tests/fmt/float.rs @@ -20,6 +20,8 @@ fn test_format_f64() { assert_eq!("1.23456789e3", format!("{:e}", 1234.56789f64)); assert_eq!("1.23456789E6", format!("{:E}", 1234567.89f64)); assert_eq!("1.23456789E3", format!("{:E}", 1234.56789f64)); + assert_eq!("0.0", format!("{:?}", 0.0f64)); + assert_eq!("1.01", format!("{:?}", 1.01f64)); } #[test] @@ -34,4 +36,6 @@ fn test_format_f32() { assert_eq!("1.2345679e3", format!("{:e}", 1234.56789f32)); assert_eq!("1.2345679E6", format!("{:E}", 1234567.89f32)); assert_eq!("1.2345679E3", format!("{:E}", 1234.56789f32)); + assert_eq!("0.0", format!("{:?}", 0.0f32)); + assert_eq!("1.01", format!("{:?}", 1.01f32)); } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 08e9990511fbb..d09376acc84ae 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -158,8 +158,8 @@ pub fn main() { // Float edge cases t!(format!("{}", -0.0), "0"); - t!(format!("{:?}", -0.0), "-0"); - t!(format!("{:?}", 0.0), "0"); + t!(format!("{:?}", -0.0), "-0.0"); + t!(format!("{:?}", 0.0), "0.0"); // sign aware zero padding t!(format!("{:<3}", 1), "1 "); From 7374fdcf541ff92449112a539345e48a27edc45e Mon Sep 17 00:00:00 2001 From: topecongiro Date: Tue, 19 Dec 2017 17:54:39 +0900 Subject: [PATCH 14/19] Remove a token after closing delimiter from the span of macro in type position --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c3dd17e877566..74ec11b83c78a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1553,7 +1553,7 @@ impl<'a> Parser<'a> { if self.eat(&token::Not) { // Macro invocation in type position let (_, tts) = self.expect_delimited_token_tree()?; - TyKind::Mac(respan(lo.to(self.span), Mac_ { path: path, tts: tts })) + TyKind::Mac(respan(lo.to(self.prev_span), Mac_ { path: path, tts: tts })) } else { // Just a type path or bound list (trait object type) starting with a trait. // `Type` From e0e62fccd2572f80903e4e6b80891dfdb9242605 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Wed, 20 Dec 2017 01:21:40 +0900 Subject: [PATCH 15/19] Fix up an ui test --- src/test/ui/issue-32950.stderr | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/ui/issue-32950.stderr b/src/test/ui/issue-32950.stderr index 0933c81d65560..abfa03f4d581a 100644 --- a/src/test/ui/issue-32950.stderr +++ b/src/test/ui/issue-32950.stderr @@ -1,9 +1,8 @@ error: `derive` cannot be used on items with type macros --> $DIR/issue-32950.rs:15:5 | -15 | / concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros -16 | | ); - | |_^ +15 | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error From 7a95e716c731d1e358eeb8bf9741852f1278b4f3 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 19 Dec 2017 23:40:17 +0300 Subject: [PATCH 16/19] Fix whitespacing issues in pretty-printing of bounds --- src/librustc/hir/print.rs | 34 +++++++++--------- src/libsyntax/print/pprust.rs | 35 ++++++++++--------- .../parse-fail/trait-object-bad-parens.rs | 6 ++-- .../trait-object-polytrait-priority.rs | 4 +-- src/test/pretty/closure-reform-pretty.rs | 2 +- src/test/pretty/path-type-bounds.rs | 6 ++-- 6 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index c7bb121e90105..b2c2c96f6245a 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -408,15 +408,16 @@ impl<'a> State<'a> { hir::TyTraitObject(ref bounds, ref lifetime) => { let mut first = true; for bound in bounds { - self.nbsp()?; if first { first = false; } else { + self.nbsp()?; self.word_space("+")?; } self.print_poly_trait_ref(bound)?; } if !lifetime.is_elided() { + self.nbsp()?; self.word_space("+")?; self.print_lifetime(lifetime)?; } @@ -764,7 +765,8 @@ impl<'a> State<'a> { real_bounds.push(b.clone()); } } - self.print_bounds(" = ", &real_bounds[..])?; + self.nbsp()?; + self.print_bounds("=", &real_bounds[..])?; self.print_where_clause(&generics.where_clause)?; self.s.word(";")?; } @@ -788,6 +790,7 @@ impl<'a> State<'a> { comma = true; } self.s.word(">")?; + self.nbsp()?; } Ok(()) } @@ -2016,30 +2019,29 @@ impl<'a> State<'a> { self.s.word(prefix)?; let mut first = true; for bound in bounds { - self.nbsp()?; + if !(first && prefix.is_empty()) { + self.nbsp()?; + } if first { first = false; } else { self.word_space("+")?; } - match *bound { - TraitTyParamBound(ref tref, TraitBoundModifier::None) => { - self.print_poly_trait_ref(tref) - } - TraitTyParamBound(ref tref, TraitBoundModifier::Maybe) => { - self.s.word("?")?; - self.print_poly_trait_ref(tref) + match bound { + TraitTyParamBound(tref, modifier) => { + if modifier == &TraitBoundModifier::Maybe { + self.s.word("?")?; + } + self.print_poly_trait_ref(tref)?; } - RegionTyParamBound(ref lt) => { - self.print_lifetime(lt) + RegionTyParamBound(lt) => { + self.print_lifetime(lt)?; } - }? + } } - Ok(()) - } else { - Ok(()) } + Ok(()) } pub fn print_lifetime(&mut self, lifetime: &hir::Lifetime) -> io::Result<()> { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e9386e5187ff0..da4d5f5f676a6 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1066,11 +1066,11 @@ impl<'a> State<'a> { self.print_qpath(path, qself, false)? } ast::TyKind::TraitObject(ref bounds, syntax) => { - let prefix = if syntax == ast::TraitObjectSyntax::Dyn { "dyn " } else { "" }; + let prefix = if syntax == ast::TraitObjectSyntax::Dyn { "dyn" } else { "" }; self.print_bounds(prefix, &bounds[..])?; } ast::TyKind::ImplTrait(ref bounds) => { - self.print_bounds("impl ", &bounds[..])?; + self.print_bounds("impl", &bounds[..])?; } ast::TyKind::Array(ref ty, ref v) => { self.s.word("[")?; @@ -1398,7 +1398,8 @@ impl<'a> State<'a> { real_bounds.push(b.clone()); } } - self.print_bounds(" = ", &real_bounds[..])?; + self.nbsp()?; + self.print_bounds("=", &real_bounds[..])?; self.print_where_clause(&generics.where_clause)?; self.s.word(";")?; } @@ -1444,6 +1445,7 @@ impl<'a> State<'a> { comma = true; } self.s.word(">")?; + self.nbsp()?; } Ok(()) } @@ -2818,30 +2820,29 @@ impl<'a> State<'a> { self.s.word(prefix)?; let mut first = true; for bound in bounds { - self.nbsp()?; + if !(first && prefix.is_empty()) { + self.nbsp()?; + } if first { first = false; } else { self.word_space("+")?; } - (match *bound { - TraitTyParamBound(ref tref, TraitBoundModifier::None) => { - self.print_poly_trait_ref(tref) - } - TraitTyParamBound(ref tref, TraitBoundModifier::Maybe) => { - self.s.word("?")?; - self.print_poly_trait_ref(tref) + match bound { + TraitTyParamBound(tref, modifier) => { + if modifier == &TraitBoundModifier::Maybe { + self.s.word("?")?; + } + self.print_poly_trait_ref(tref)?; } - RegionTyParamBound(ref lt) => { - self.print_lifetime(lt) + RegionTyParamBound(lt) => { + self.print_lifetime(lt)?; } - })? + } } - Ok(()) - } else { - Ok(()) } + Ok(()) } pub fn print_lifetime(&mut self, diff --git a/src/test/parse-fail/trait-object-bad-parens.rs b/src/test/parse-fail/trait-object-bad-parens.rs index 3e8c140eb197d..25e9c3071d654 100644 --- a/src/test/parse-fail/trait-object-bad-parens.rs +++ b/src/test/parse-fail/trait-object-bad-parens.rs @@ -14,9 +14,9 @@ fn main() { let _: Box<((Copy)) + Copy>; //~^ ERROR expected a path on the left-hand side of `+`, not `((Copy))` let _: Box<(Copy + Copy) + Copy>; - //~^ ERROR expected a path on the left-hand side of `+`, not `( Copy + Copy)` + //~^ ERROR expected a path on the left-hand side of `+`, not `(Copy + Copy)` let _: Box<(Copy +) + Copy>; - //~^ ERROR expected a path on the left-hand side of `+`, not `( Copy)` + //~^ ERROR expected a path on the left-hand side of `+`, not `(Copy)` let _: Box<(dyn Copy) + Copy>; - //~^ ERROR expected a path on the left-hand side of `+`, not `(dyn Copy)` + //~^ ERROR expected a path on the left-hand side of `+`, not `(dyn Copy)` } diff --git a/src/test/parse-fail/trait-object-polytrait-priority.rs b/src/test/parse-fail/trait-object-polytrait-priority.rs index 9df4be4595a95..b5fc06ddaac05 100644 --- a/src/test/parse-fail/trait-object-polytrait-priority.rs +++ b/src/test/parse-fail/trait-object-polytrait-priority.rs @@ -12,7 +12,7 @@ trait Trait<'a> {} fn main() { let _: &for<'a> Trait<'a> + 'static; - //~^ ERROR expected a path on the left-hand side of `+`, not `& for<'a>Trait<'a>` + //~^ ERROR expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>` //~| HELP try adding parentheses - //~| SUGGESTION &( for<'a>Trait<'a> + 'static) + //~| SUGGESTION &(for<'a> Trait<'a> + 'static) } diff --git a/src/test/pretty/closure-reform-pretty.rs b/src/test/pretty/closure-reform-pretty.rs index 63568dbcd5b18..a1fdebf6fa1c0 100644 --- a/src/test/pretty/closure-reform-pretty.rs +++ b/src/test/pretty/closure-reform-pretty.rs @@ -17,7 +17,7 @@ fn call_it(f: Box String>) { } fn call_this(f: F) where F: Fn(&str) + Send { } -fn call_that(f: F) where F: for<'a>Fn(&'a isize, &'a isize) -> isize { } +fn call_that(f: F) where F: for<'a> Fn(&'a isize, &'a isize) -> isize { } fn call_extern(f: fn() -> isize) { } diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index 651d2b67941cb..ae6a0fc314226 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -16,10 +16,10 @@ trait Tr { } impl Tr for isize { } -fn foo<'a>(x: Box< Tr + Sync + 'a>) -> Box< Tr + Sync + 'a> { x } +fn foo<'a>(x: Box) -> Box { x } fn main() { - let x: Box< Tr + Sync>; + let x: Box; - Box::new(1isize) as Box< Tr + Sync>; + Box::new(1isize) as Box; } From fb245e05404ad5bbe689dcdc5bd5f4750f4e3730 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Tue, 19 Dec 2017 17:05:14 -0500 Subject: [PATCH 17/19] Split PlaceContext::Store into Store & AsmOutput Outputs in InlineAsm can be read-write, so splitting it out is useful for things like Store-Store folding, as it cannot be done for a Store-AsmOutput. This PR is intended to make no changes, just be the mechanical split of the enum. Future changes can use the split, like a MIR pass I'm working on and perhaps two-phase borrows. --- src/librustc/mir/visit.rs | 10 ++++++++-- src/librustc_mir/dataflow/impls/borrows.rs | 4 ++++ src/librustc_mir/transform/check_unsafety.rs | 1 + src/librustc_mir/transform/promote_consts.rs | 1 + src/librustc_mir/util/liveness.rs | 3 +++ src/librustc_trans/mir/analyze.rs | 1 + 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index d90bf1b61a7d3..a50a9c819f6ec 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -376,7 +376,7 @@ macro_rules! make_mir_visitor { ref $($mutability)* inputs, asm: _ } => { for output in & $($mutability)* outputs[..] { - self.visit_place(output, PlaceContext::Store, location); + self.visit_place(output, PlaceContext::AsmOutput, location); } for input in & $($mutability)* inputs[..] { self.visit_operand(input, location); @@ -835,6 +835,11 @@ pub enum PlaceContext<'tcx> { // Appears as LHS of an assignment Store, + // Can often be treated as a Store, but needs to be separate because + // ASM is allowed to read outputs as well, so a Store-AsmOutput sequence + // cannot be simplified the way a Store-Store can be. + AsmOutput, + // Dest of a call Call, @@ -910,7 +915,7 @@ impl<'tcx> PlaceContext<'tcx> { /// Returns true if this place context represents a use that potentially changes the value. pub fn is_mutating_use(&self) -> bool { match *self { - PlaceContext::Store | PlaceContext::Call | + PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call | PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Projection(Mutability::Mut) | PlaceContext::Drop => true, @@ -932,6 +937,7 @@ impl<'tcx> PlaceContext<'tcx> { PlaceContext::Projection(Mutability::Not) | PlaceContext::Copy | PlaceContext::Move => true, PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Store | + PlaceContext::AsmOutput | PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) | PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead | PlaceContext::Validate => false, diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index c61a57cdda0e9..2504aa5ff378a 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -540,6 +540,10 @@ impl<'a, 'b, 'tcx> FindPlaceUses<'a, 'b, 'tcx> { // "deep" does validation go? PlaceContext::Validate => false, + // FIXME: This is here to not change behaviour from before + // AsmOutput existed, but it's not necessarily a pure overwrite. + // so it's possible this should activate the place. + PlaceContext::AsmOutput | // pure overwrites of an place do not activate it. (note // PlaceContext::Call is solely about dest place) PlaceContext::Store | PlaceContext::Call => false, diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 7833f4bbac7aa..d9ef5235d1939 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -173,6 +173,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { ty::TyAdt(adt, _) => { if adt.is_union() { if context == PlaceContext::Store || + context == PlaceContext::AsmOutput || context == PlaceContext::Drop { let elem_ty = match elem { diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 1e5b0bc1392bc..1545040f2da79 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -103,6 +103,7 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> { if *temp == TempState::Undefined { match context { PlaceContext::Store | + PlaceContext::AsmOutput | PlaceContext::Call => { *temp = TempState::Defined { location, diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index 45c3fcd8a615d..0af08e1bc8ac9 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -240,6 +240,9 @@ impl<'tcx> Visitor<'tcx> for DefsUsesVisitor { PlaceContext::Store | + // This is potentially both a def and a use... + PlaceContext::AsmOutput | + // We let Call define the result in both the success and // unwind cases. This is not really correct, however it // does not seem to be observable due to the way that we diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index b5e5dd3b9ce16..cfe55aba0d3c5 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -193,6 +193,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { PlaceContext::Inspect | PlaceContext::Store | + PlaceContext::AsmOutput | PlaceContext::Borrow { .. } | PlaceContext::Projection(..) => { self.mark_as_memory(index); From 3441ffb15eb1869425a2513b945e58bb762a5267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 19 Dec 2017 14:41:03 -0800 Subject: [PATCH 18/19] Point at def span in "missing in impl" error --- src/librustc_typeck/check/mod.rs | 2 + src/test/ui/impl-trait/trait_type.stderr | 2 +- src/test/ui/missing-items/m2.stderr | 5 +-- src/test/ui/span/E0046.stderr | 2 +- .../ui/span/impl-wrong-item-for-trait.stderr | 45 ++++++------------- src/test/ui/span/issue-23729.stderr | 10 +---- src/test/ui/span/issue-23827.stderr | 9 +--- src/test/ui/span/issue-24356.stderr | 7 +-- 8 files changed, 26 insertions(+), 56 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index baa389319ca72..7ebdb876ed02f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1274,6 +1274,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_id: DefId, impl_trait_ref: ty::TraitRef<'tcx>, impl_item_refs: &[hir::ImplItemRef]) { + let impl_span = tcx.sess.codemap().def_span(impl_span); + // If the trait reference itself is erroneous (so the compilation is going // to fail), skip checking the items here -- the `impl_item` table in `tcx` // isn't populated for such impls. diff --git a/src/test/ui/impl-trait/trait_type.stderr b/src/test/ui/impl-trait/trait_type.stderr index 42e1dcdb1c42a..7a0d01a8ec215 100644 --- a/src/test/ui/impl-trait/trait_type.stderr +++ b/src/test/ui/impl-trait/trait_type.stderr @@ -27,7 +27,7 @@ error[E0046]: not all trait items implemented, missing: `fmt` --> $DIR/trait_type.rs:31:1 | 31 | impl std::fmt::Display for MyType4 {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation | = note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` diff --git a/src/test/ui/missing-items/m2.stderr b/src/test/ui/missing-items/m2.stderr index 47164a5304abb..8c57214ec771f 100644 --- a/src/test/ui/missing-items/m2.stderr +++ b/src/test/ui/missing-items/m2.stderr @@ -3,9 +3,8 @@ error[E0601]: main function not found error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method` --> $DIR/m2.rs:19:1 | -19 | / impl m1::X for X { //~ ERROR not all trait items implemented -20 | | } - | |_^ missing `CONSTANT`, `Type`, `method` in implementation +19 | impl m1::X for X { //~ ERROR not all trait items implemented + | ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method` in implementation | = note: `CONSTANT` from trait: `const CONSTANT: u32;` = note: `Type` from trait: `type Type;` diff --git a/src/test/ui/span/E0046.stderr b/src/test/ui/span/E0046.stderr index cd963de441b5f..fb13f21fe00f7 100644 --- a/src/test/ui/span/E0046.stderr +++ b/src/test/ui/span/E0046.stderr @@ -5,7 +5,7 @@ error[E0046]: not all trait items implemented, missing: `foo` | --------- `foo` from trait ... 17 | impl Foo for Bar {} - | ^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + | ^^^^^^^^^^^^^^^^ missing `foo` in implementation error: aborting due to previous error diff --git a/src/test/ui/span/impl-wrong-item-for-trait.stderr b/src/test/ui/span/impl-wrong-item-for-trait.stderr index 92993e192650e..6473b24dec5b3 100644 --- a/src/test/ui/span/impl-wrong-item-for-trait.stderr +++ b/src/test/ui/span/impl-wrong-item-for-trait.stderr @@ -16,16 +16,11 @@ error[E0323]: item `bar` is an associated const, which doesn't match its trait ` error[E0046]: not all trait items implemented, missing: `bar` --> $DIR/impl-wrong-item-for-trait.rs:21:1 | -15 | fn bar(&self); - | -------------- `bar` from trait +15 | fn bar(&self); + | -------------- `bar` from trait ... -21 | / impl Foo for FooConstForMethod { -22 | | //~^ ERROR E0046 -23 | | const bar: u64 = 1; -24 | | //~^ ERROR E0323 -25 | | const MY_CONST: u32 = 1; -26 | | } - | |_^ missing `bar` in implementation +21 | impl Foo for FooConstForMethod { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bar` in implementation error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `Foo` --> $DIR/impl-wrong-item-for-trait.rs:33:5 @@ -39,16 +34,11 @@ error[E0324]: item `MY_CONST` is an associated method, which doesn't match its t error[E0046]: not all trait items implemented, missing: `MY_CONST` --> $DIR/impl-wrong-item-for-trait.rs:30:1 | -16 | const MY_CONST: u32; - | -------------------- `MY_CONST` from trait +16 | const MY_CONST: u32; + | -------------------- `MY_CONST` from trait ... -30 | / impl Foo for FooMethodForConst { -31 | | //~^ ERROR E0046 -32 | | fn bar(&self) {} -33 | | fn MY_CONST() {} -34 | | //~^ ERROR E0324 -35 | | } - | |_^ missing `MY_CONST` in implementation +30 | impl Foo for FooMethodForConst { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `MY_CONST` in implementation error[E0325]: item `bar` is an associated type, which doesn't match its trait `Foo` --> $DIR/impl-wrong-item-for-trait.rs:41:5 @@ -62,24 +52,17 @@ error[E0325]: item `bar` is an associated type, which doesn't match its trait `F error[E0046]: not all trait items implemented, missing: `bar` --> $DIR/impl-wrong-item-for-trait.rs:39:1 | -15 | fn bar(&self); - | -------------- `bar` from trait +15 | fn bar(&self); + | -------------- `bar` from trait ... -39 | / impl Foo for FooTypeForMethod { -40 | | //~^ ERROR E0046 -41 | | type bar = u64; -42 | | //~^ ERROR E0325 -43 | | //~| ERROR E0437 -44 | | const MY_CONST: u32 = 1; -45 | | } - | |_^ missing `bar` in implementation +39 | impl Foo for FooTypeForMethod { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `bar` in implementation error[E0046]: not all trait items implemented, missing: `fmt` --> $DIR/impl-wrong-item-for-trait.rs:47:1 | -47 | / impl Debug for FooTypeForMethod { -48 | | } - | |_^ missing `fmt` in implementation +47 | impl Debug for FooTypeForMethod { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation | = note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` diff --git a/src/test/ui/span/issue-23729.stderr b/src/test/ui/span/issue-23729.stderr index 0124d33635c47..60bf804ff30c4 100644 --- a/src/test/ui/span/issue-23729.stderr +++ b/src/test/ui/span/issue-23729.stderr @@ -1,14 +1,8 @@ error[E0046]: not all trait items implemented, missing: `Item` --> $DIR/issue-23729.rs:20:9 | -20 | / impl Iterator for Recurrence { -21 | | //~^ ERROR E0046 -22 | | #[inline] -23 | | fn next(&mut self) -> Option { -... | -34 | | } -35 | | } - | |_________^ missing `Item` in implementation +20 | impl Iterator for Recurrence { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Item` in implementation | = note: `Item` from trait: `type Item;` diff --git a/src/test/ui/span/issue-23827.stderr b/src/test/ui/span/issue-23827.stderr index acf499e4c8dde..d06d6c03616e3 100644 --- a/src/test/ui/span/issue-23827.stderr +++ b/src/test/ui/span/issue-23827.stderr @@ -1,13 +1,8 @@ error[E0046]: not all trait items implemented, missing: `Output` --> $DIR/issue-23827.rs:36:1 | -36 | / impl FnOnce<(C,)> for Prototype { -37 | | //~^ ERROR E0046 -38 | | extern "rust-call" fn call_once(self, (comp,): (C,)) -> Prototype { -39 | | Fn::call(&self, (comp,)) -40 | | } -41 | | } - | |_^ missing `Output` in implementation +36 | impl FnOnce<(C,)> for Prototype { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Output` in implementation | = note: `Output` from trait: `type Output;` diff --git a/src/test/ui/span/issue-24356.stderr b/src/test/ui/span/issue-24356.stderr index c526a4bc521c4..58fb943fef827 100644 --- a/src/test/ui/span/issue-24356.stderr +++ b/src/test/ui/span/issue-24356.stderr @@ -1,11 +1,8 @@ error[E0046]: not all trait items implemented, missing: `Target` --> $DIR/issue-24356.rs:30:9 | -30 | / impl Deref for Thing { -31 | | //~^ ERROR E0046 -32 | | fn deref(&self) -> i8 { self.0 } -33 | | } - | |_________^ missing `Target` in implementation +30 | impl Deref for Thing { + | ^^^^^^^^^^^^^^^^^^^^ missing `Target` in implementation | = note: `Target` from trait: `type Target;` From f6ab79d1aaedf6fbb8f566f1d7444d0da92a264f Mon Sep 17 00:00:00 2001 From: Florian Keller Date: Wed, 20 Dec 2017 11:43:49 +0100 Subject: [PATCH 19/19] docs(slice): Clarify half-open interval --- src/libcore/slice/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 49c51f4f04fdc..ca5cf04b1d437 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -400,7 +400,7 @@ impl SliceExt for [T] { while size > 1 { let half = size / 2; let mid = base + half; - // mid is always in [0, size). + // mid is always in [0, size), that means mid is >= 0 and < size. // mid >= 0: by definition // mid < size: mid = size / 2 + size / 4 + size / 8 ... let cmp = f(unsafe { s.get_unchecked(mid) });