From 8951eea9b7c9a352d0d0d6485526875ebf97fb95 Mon Sep 17 00:00:00 2001 From: Nathan Kleyn Date: Tue, 16 Apr 2019 22:37:07 +0100 Subject: [PATCH 1/6] Document `Item` type in `std::env::SplitPaths` iterator. Previously there wasn't any documentation to show what the type of `Item` was inside `std::env::SplitPaths`. Now, in the same format as other examples of docs in `srd` for `Iterator#Item`, we mention the type. This fixes #59543. --- src/libstd/env.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 01b301cb43d..c0d0c23e469 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -359,9 +359,12 @@ fn _remove_var(k: &OsStr) { /// An iterator that splits an environment variable into paths according to /// platform-specific conventions. /// +/// The iterator element type is [`PathBuf`]. +/// /// This structure is created by the [`std::env::split_paths`] function. See its /// documentation for more. /// +/// [`PathBuf`]: ../../std/path/struct.PathBuf.html /// [`std::env::split_paths`]: fn.split_paths.html #[stable(feature = "env", since = "1.0.0")] pub struct SplitPaths<'a> { inner: os_imp::SplitPaths<'a> } @@ -369,7 +372,8 @@ pub struct SplitPaths<'a> { inner: os_imp::SplitPaths<'a> } /// Parses input according to platform conventions for the `PATH` /// environment variable. /// -/// Returns an iterator over the paths contained in `unparsed`. +/// Returns an iterator over the paths contained in `unparsed`. The iterator +/// element type is [`PathBuf`]. /// /// # Examples /// @@ -386,6 +390,8 @@ pub struct SplitPaths<'a> { inner: os_imp::SplitPaths<'a> } /// None => println!("{} is not defined in the environment.", key) /// } /// ``` +/// +/// [`PathBuf`]: ../../std/path/struct.PathBuf.html #[stable(feature = "env", since = "1.0.0")] pub fn split_paths + ?Sized>(unparsed: &T) -> SplitPaths<'_> { SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) } From 955f283e11dec628a988e23100f21ab92329b3bd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Apr 2019 09:06:38 -0700 Subject: [PATCH 2/6] rustc: Flag metadata compatible with multiple CGUs It looks like the `OutputType::Metadata` kind in the compiler was misclassified in #38571 long ago by accident as incompatible with codegen units and a single output file. This means that if you emit both a linkable artifact and metadata it silently turns off multiple codegen units unintentionally! This commit corrects the situation to ensure that if `--emit metadata` is used it doesn't implicitly disable multiple codegen units. This will ensure we don't accidentally regress compiler performance when striving to implement pipelined compilation! --- src/librustc/session/config.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index cb307800fcd..92a34695262 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -153,13 +153,12 @@ pub enum OutputType { impl OutputType { fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool { match *self { - OutputType::Exe | OutputType::DepInfo => true, + OutputType::Exe | OutputType::DepInfo | OutputType::Metadata => true, OutputType::Bitcode | OutputType::Assembly | OutputType::LlvmAssembly | OutputType::Mir - | OutputType::Object - | OutputType::Metadata => false, + | OutputType::Object => false, } } From dfe802b929699d8f0a30a669e55da6c7c9dad01d Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 27 Apr 2019 12:06:02 +0200 Subject: [PATCH 3/6] Document ast::ExprKind::Type. --- src/libsyntax/ast.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 334fcfd74f3..a20bf91a6ad 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1137,6 +1137,7 @@ pub enum ExprKind { Lit(Lit), /// A cast (e.g., `foo as f64`). Cast(P, P), + /// A type ascription (e.g., `42: usize`). Type(P, P), /// An `if` block, with an optional `else` block. /// From 4eda15174e287daf6d3fa223eed1b1227a02b671 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sun, 28 Apr 2019 12:22:47 +0900 Subject: [PATCH 4/6] Remove two-phase-borrows --- src/librustc/session/config.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 60d5340613c..836f42ff4ba 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1216,8 +1216,6 @@ fn parse_merge_functions(slot: &mut Option, v: Option<&str>) -> "make unnamed regions display as '# (where # is some non-ident unique id)"), borrowck: Option = (None, parse_opt_string, [UNTRACKED], "select which borrowck is used (`ast`, `mir`, `migrate`, or `compare`)"), - two_phase_borrows: bool = (false, parse_bool, [UNTRACKED], - "use two-phase reserved/active distinction for `&mut` borrows in MIR borrowck"), two_phase_beyond_autoref: bool = (false, parse_bool, [UNTRACKED], "when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"), time_passes: bool = (false, parse_bool, [UNTRACKED], From 542357f52a38efc79630854c4df2e6bbbc3437e4 Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sun, 28 Apr 2019 12:51:04 +0900 Subject: [PATCH 5/6] Remove two-phase-beyond-autoref --- src/librustc/session/config.rs | 2 -- src/librustc_mir/borrow_check/borrow_set.rs | 1 - src/librustc_mir/borrow_check/path_utils.rs | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 836f42ff4ba..75814ba6aab 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1216,8 +1216,6 @@ fn parse_merge_functions(slot: &mut Option, v: Option<&str>) -> "make unnamed regions display as '# (where # is some non-ident unique id)"), borrowck: Option = (None, parse_opt_string, [UNTRACKED], "select which borrowck is used (`ast`, `mir`, `migrate`, or `compare`)"), - two_phase_beyond_autoref: bool = (false, parse_bool, [UNTRACKED], - "when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"), time_passes: bool = (false, parse_bool, [UNTRACKED], "measure time of each rustc pass"), time: bool = (false, parse_bool, [UNTRACKED], diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index 918192395c3..c67e2b529c9 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -304,7 +304,6 @@ impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> { /// Activation phases. fn allow_two_phase_borrow(&self, kind: mir::BorrowKind) -> bool { kind.allows_two_phase_borrow() - || self.tcx.sess.opts.debugging_opts.two_phase_beyond_autoref } /// If this is a two-phase borrow, then we will record it diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index c68dee29c5b..f6a22cf0407 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -12,11 +12,10 @@ /// allowed to be split into separate Reservation and /// Activation phases. pub(super) fn allow_two_phase_borrow<'a, 'tcx, 'gcx: 'tcx>( - tcx: &TyCtxt<'a, 'gcx, 'tcx>, + _tcx: &TyCtxt<'a, 'gcx, 'tcx>, kind: BorrowKind ) -> bool { kind.allows_two_phase_borrow() - || tcx.sess.opts.debugging_opts.two_phase_beyond_autoref } /// Control for the path borrow checking code From 3a487ea977773e11c3a9d6b3a0c965db46bfb5ec Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sun, 28 Apr 2019 19:31:54 +0900 Subject: [PATCH 6/6] Remove unnecessary function --- src/librustc_mir/borrow_check/borrow_set.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index c67e2b529c9..c8d6ee9db6f 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -1,5 +1,6 @@ use crate::borrow_check::place_ext::PlaceExt; use crate::borrow_check::nll::ToRegionVid; +use crate::borrow_check::path_utils::allow_two_phase_borrow; use crate::dataflow::indexes::BorrowIndex; use crate::dataflow::move_paths::MoveData; use rustc::mir::traversal; @@ -299,12 +300,6 @@ fn visit_statement( } impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> { - /// Returns `true` if the borrow represented by `kind` is - /// allowed to be split into separate Reservation and - /// Activation phases. - fn allow_two_phase_borrow(&self, kind: mir::BorrowKind) -> bool { - kind.allows_two_phase_borrow() - } /// If this is a two-phase borrow, then we will record it /// as "pending" until we find the activating use. @@ -320,7 +315,7 @@ fn insert_as_pending_if_two_phase( start_location, assigned_place, borrow_index, ); - if !self.allow_two_phase_borrow(kind) { + if !allow_two_phase_borrow(&self.tcx, kind) { debug!(" -> {:?}", start_location); return; }