From 5243a98b48da3bdac81e9685526d731e88dc48a1 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Fri, 13 Oct 2017 23:38:55 -0700 Subject: [PATCH 01/14] Add a brief description and two examples to std::process --- src/libstd/process.rs | 50 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 7d8ce4154fbfc..d3e60e3dff9d8 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -10,24 +10,57 @@ //! A module for working with processes. //! +//! This module provides a [`Command`] struct that can be used to configure and +//! spawn a process, as well as a [`Child`] struct that represents a running or +//! terminated process. +//! //! # Examples //! -//! Basic usage where we try to execute the `cat` shell command: +//! Hello world, `std::process` edition: //! -//! ```should_panic -//! use std::process::Command; +//! ``` +//! use std::process:Command; //! -//! let mut child = Command::new("/bin/cat") -//! .arg("file.txt") +//! // Note that by default, the output of the command will be sent to stdout +//! let child = Command::new("echo") +//! .arg("Hello world") //! .spawn() -//! .expect("failed to execute child"); +//! .expect("Failed to start process"); //! //! let ecode = child.wait() -//! .expect("failed to wait on child"); +//! .expect("Failed to wait on child"); //! //! assert!(ecode.success()); //! ``` //! +//! Piping output from one command into another command: +//! +//! ``` +//! use std::process::{Command, Stdio}; +//! +//! // stdout must be configured with `Stdio::piped` in order to use +//! // `echo_child.stdout` +//! let echo_child = Command::new("echo") +//! .arg("Oh no, a tpyo!") +//! .stdout(Stdio::piped()) +//! .spawn() +//! .expect("Failed to start echo process"); +//! +//! // Note that `echo_child` is moved here, but we won't be needing +//! // `echo_child` anymore +//! let echo_out = echo_child.stdout.expect("Failed to open echo stdout"); +//! +//! let mut sed_child = Command::new("sed") +//! .arg("s/tpyo/typo/") +//! .stdin(Stdio::from(echo_out)) +//! .stdout(Stdio::piped()) +//! .spawn() +//! .expect("Failed to start sed process"); +//! +//! let output = sed_child.wait_with_output().expect("Failed to wait on sed"); +//! assert_eq!(b"Oh no, a typo!\n", output.stdout.as_slice()); +//! ``` +//! //! Calling a command with input and reading its output: //! //! ```no_run @@ -52,6 +85,9 @@ //! //! assert_eq!(b"test", output.stdout.as_slice()); //! ``` +//! +//! [`Command`]: struct.Command.html +//! [`Child`]: struct.Child.html #![stable(feature = "process", since = "1.0.0")] From e788e90bad6b1ee5c028d5536c373c3f2c8a3bc4 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Sat, 14 Oct 2017 20:41:58 -0700 Subject: [PATCH 02/14] Fixed accidental deletion of colon --- src/libstd/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index d3e60e3dff9d8..5428ed59c68d9 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -19,7 +19,7 @@ //! Hello world, `std::process` edition: //! //! ``` -//! use std::process:Command; +//! use std::process::Command; //! //! // Note that by default, the output of the command will be sent to stdout //! let child = Command::new("echo") From bb74b13b742d214d20bb646d5b8d3eaebaad9b8b Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Sun, 15 Oct 2017 13:11:14 -0700 Subject: [PATCH 03/14] Fix std::process hello world example --- src/libstd/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 5428ed59c68d9..38f218ba9d54a 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -22,7 +22,7 @@ //! use std::process::Command; //! //! // Note that by default, the output of the command will be sent to stdout -//! let child = Command::new("echo") +//! let mut child = Command::new("echo") //! .arg("Hello world") //! .spawn() //! .expect("Failed to start process"); From f67f6622b37bca1b2430ab2987d94d31ad436762 Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Sun, 15 Oct 2017 19:45:07 -0700 Subject: [PATCH 04/14] Create section on how to spawn processes; change module description --- src/libstd/process.rs | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 38f218ba9d54a..72402aaae3000 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -10,29 +10,36 @@ //! A module for working with processes. //! -//! This module provides a [`Command`] struct that can be used to configure and -//! spawn a process, as well as a [`Child`] struct that represents a running or -//! terminated process. +//! This module is mostly concerned with spawning and interacting with child +//! processes, but it also provides [`abort`] and [`exit`] for terminating the +//! current process. //! -//! # Examples +//! # Spawning a process //! -//! Hello world, `std::process` edition: +//! The [`Command`] struct is used to configure and spawn processes: //! //! ``` //! use std::process::Command; //! -//! // Note that by default, the output of the command will be sent to stdout -//! let mut child = Command::new("echo") -//! .arg("Hello world") -//! .spawn() -//! .expect("Failed to start process"); -//! -//! let ecode = child.wait() -//! .expect("Failed to wait on child"); +//! let output = Command::new("echo") +//! .arg("Hello world") +//! .output() +//! .expect("Failed to execute command"); //! -//! assert!(ecode.success()); +//! assert_eq!(b"Hello world\n", output.stdout.as_slice()); //! ``` //! +//! Several methods on [`Command`], such as [`spawn`] or [`output`], can be used +//! to spawn a process. In particular, [`output`] spawns the child process and +//! waits until the process terminates, while [`spawn`] will return a [`Child`] +//! that represents the spawned child process. +//! +//! # Handling I/O +//! +//! TODO +//! +//! # Examples +//! //! Piping output from one command into another command: //! //! ``` @@ -86,8 +93,15 @@ //! assert_eq!(b"test", output.stdout.as_slice()); //! ``` //! +//! [`abort`]: fn.abort.html +//! [`exit`]: fn.exit.html +//! //! [`Command`]: struct.Command.html +//! [`spawn`]: struct.Command.html#method.spawn +//! [`output`]: struct.Command.html#method.output +//! //! [`Child`]: struct.Child.html +//! [`Stdio`]: struct.Stdio.html #![stable(feature = "process", since = "1.0.0")] From 3566832ef3a5af2ee29a76f95b55c6e1fafcf02a Mon Sep 17 00:00:00 2001 From: Bryan Tan Date: Tue, 17 Oct 2017 17:49:02 -0700 Subject: [PATCH 05/14] Add child process IO handling docs --- src/libstd/process.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 72402aaae3000..bcdbee52ca3be 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -36,11 +36,11 @@ //! //! # Handling I/O //! -//! TODO -//! -//! # Examples -//! -//! Piping output from one command into another command: +//! The [`stdout`], [`stdin`], and [`stderr`] of a child process can be +//! configured by passing an [`Stdio`] to the corresponding method on +//! [`Command`]. Once spawned, they can be accessed from the [`Child`]. For +//! example, piping output from one command into another command can be done +//! like so: //! //! ``` //! use std::process::{Command, Stdio}; @@ -68,9 +68,10 @@ //! assert_eq!(b"Oh no, a typo!\n", output.stdout.as_slice()); //! ``` //! -//! Calling a command with input and reading its output: +//! Note that [`ChildStderr`] and [`ChildStdout`] implement [`Write`] and +//! [`ChildStdin`] implements [`Read`]: //! -//! ```no_run +//! ``` //! use std::process::{Command, Stdio}; //! use std::io::Write; //! @@ -101,7 +102,17 @@ //! [`output`]: struct.Command.html#method.output //! //! [`Child`]: struct.Child.html +//! [`ChildStdin`]: struct.ChildStdin.html +//! [`ChildStdout`]: struct.ChildStdout.html +//! [`ChildStderr`]: struct.ChildStderr.html //! [`Stdio`]: struct.Stdio.html +//! +//! [`stdout`]: struct.Command.html#method.stdout +//! [`stdin`]: struct.Command.html#method.stdin +//! [`stderr`]: struct.Command.html#method.stderr +//! +//! [`Write`]: ../io/trait.Write.html +//! [`Read`]: ../io/trait.Read.html #![stable(feature = "process", since = "1.0.0")] From 4fdd6299b01b059337cdd3f173f5d2699b465f9b Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 20 Oct 2017 15:12:20 -0500 Subject: [PATCH 06/14] rustdoc: update pulldown renderer fixes #45420 --- src/Cargo.lock | 17 +---------------- src/librustdoc/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index cd0a09dd725f1..c9c35c08d6b07 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -116,11 +116,6 @@ name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "bitflags" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "0.9.1" @@ -1335,14 +1330,6 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "pulldown-cmark" -version = "0.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "pulldown-cmark" version = "0.0.15" @@ -1957,7 +1944,7 @@ dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "html-diff 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2627,7 +2614,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum backtrace 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "99f2ce94e22b8e664d95c57fff45b98a966c2252b60691d0b7aeeccd88d70983" "checksum backtrace-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "c63ea141ef8fdb10409d0f5daf30ac51f84ef43bff66f16627773d2a292cd189" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum bitflags 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1370e9fc2a6ae53aea8b7a5110edbd08836ed87c88736dfabccade1c2b44bff4" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5cde24d1b2e2216a726368b2363a273739c91f4e3eb4e0dd12d672d396ad989" "checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32" @@ -2731,7 +2717,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf1fc3616b3ef726a847f2cd2388c646ef6a1f1ba4835c2629004da48184150" "checksum procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c93cdc1fb30af9ddf3debc4afbdb0f35126cbd99daa229dd76cdd5349b41d989" "checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" -"checksum pulldown-cmark 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ab1e588ef8efd702c7ed9d2bd774db5e6f4d878bb5a1a9f371828fbdff6973" "checksum pulldown-cmark 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "378e941dbd392c101f2cb88097fa4d7167bc421d4b88de3ff7dbee503bc3233b" "checksum pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a656fdb8b6848f896df5e478a0eb9083681663e37dcb77dd16981ff65329fe8b" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index e168222058f9a..988cc08433588 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] env_logger = { version = "0.4", default-features = false } log = "0.3" -pulldown-cmark = { version = "0.0.14", default-features = false } +pulldown-cmark = { version = "0.1.0", default-features = false } html-diff = "0.0.4" [build-dependencies] From af09ba82e0cd1d5e04e203d3a2eb11cf7ee023dc Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Sat, 21 Oct 2017 15:00:26 -0500 Subject: [PATCH 07/14] change footnote anchor formats to fix spurious rendering differences --- src/librustdoc/html/markdown.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 80d1f0b01cc26..001e773098eb3 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -371,7 +371,7 @@ impl<'a, I: Iterator>> Iterator for Footnotes<'a, I> { match self.inner.next() { Some(Event::FootnoteReference(ref reference)) => { let entry = self.get_entry(&reference); - let reference = format!("{0}\ + let reference = format!("{0}\ ", (*entry).1); return Some(Event::Html(reference.into())); @@ -394,7 +394,7 @@ impl<'a, I: Iterator>> Iterator for Footnotes<'a, I> { v.sort_by(|a, b| a.1.cmp(&b.1)); let mut ret = String::from("

    "); for (mut content, id) in v { - write!(ret, "
  1. ", id).unwrap(); + write!(ret, "
  2. ", id).unwrap(); let mut is_paragraph = false; if let Some(&Event::End(Tag::Paragraph)) = content.last() { content.pop(); @@ -402,7 +402,7 @@ impl<'a, I: Iterator>> Iterator for Footnotes<'a, I> { } html::push_html(&mut ret, content.into_iter()); write!(ret, - " ", + " ", id).unwrap(); if is_paragraph { ret.push_str("

    "); From 4c6942d26249f156ede34ddbed03765ab4f398e5 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Thu, 26 Oct 2017 09:27:20 -0400 Subject: [PATCH 08/14] Remove 'just' in diagnostics This is better writing --- src/librustc/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 26f56ffacae7f..c9c03a2f7955e 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1875,7 +1875,7 @@ fn main() { "##, E0601: r##" -No `main` function was found in a binary crate. To fix this error, just add a +No `main` function was found in a binary crate. To fix this error, add a `main` function. For example: ``` From 04f27f01cb25f63d25e07ed0a48a8ac4135371c8 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 22 Oct 2017 09:27:26 -0400 Subject: [PATCH 09/14] Improve docs for UdpSocket::set_nonblocking. Closes https://github.com/rust-lang/rust/issues/44050. --- src/libstd/net/udp.rs | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 870d11298fe3b..84ceaa659510f 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -721,16 +721,45 @@ impl UdpSocket { /// Moves this UDP socket into or out of nonblocking mode. /// - /// On Unix this corresponds to calling fcntl, and on Windows this - /// corresponds to calling ioctlsocket. + /// This will result in `recv`, `recv_from`, `send`, and `send_to` + /// operations becoming nonblocking, i.e. immediately returning from their + /// calls. If the IO operation is successful, `Ok` is returned and no + /// further action is required. If the IO operation could not be completed + /// and needs to be retried, an error with kind + /// [`io::ErrorKind::WouldBlock`] is returned. + /// + /// On Unix platforms, calling this method corresponds to calling `fcntl` + /// `FIONBIO`. On Windows calling this method corresponds to calling + /// `ioctlsocket` `FIONBIO`. + /// + /// [`io::ErrorKind::WouldBlock`]: ../io/enum.ErrorKind.html#variant.WouldBlock /// /// # Examples /// + /// Create a UDP socket bound to `127.0.0.1:7878` and read bytes in + /// nonblocking mode: + /// /// ```no_run + /// use std::io; /// use std::net::UdpSocket; /// - /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); - /// socket.set_nonblocking(true).expect("set_nonblocking call failed"); + /// let socket = UdpSocket::bind("127.0.0.1:7878").unwrap(); + /// socket.set_nonblocking(true).unwrap(); + /// + /// # fn wait_for_fd() { unimplemented!() } + /// let mut buf = [0; 10]; + /// let (num_bytes_read, _) = loop { + /// match socket.recv_from(&mut buf) { + /// Ok(n) => break n, + /// Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { + /// // wait until network socket is ready, typically implemented + /// // via platform-specific APIs such as epoll or IOCP + /// wait_for_fd(); + /// } + /// Err(e) => panic!("encountered IO error: {}", e), + /// } + /// }; + /// println!("bytes: {:?}", &buf[..num_bytes_read]); /// ``` #[stable(feature = "net2_mutators", since = "1.9.0")] pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { From 11d758a7a849f2929ffb30651e4b8d74a3cef5be Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Tue, 24 Oct 2017 22:07:50 +0200 Subject: [PATCH 10/14] Use expect for current_dir on librustc/session mod --- src/librustc/session/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 42c633dc83fe5..cc27f61e369b7 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -776,7 +776,9 @@ pub fn build_session_(sopts: config::Options, let print_fuel_crate = sopts.debugging_opts.print_fuel.clone(); let print_fuel = Cell::new(0); - let working_dir = env::current_dir().unwrap().to_string_lossy().into_owned(); + let working_dir = env::current_dir() + .expect("Could not find current working directory") + .to_string_lossy().into_owned(); let working_dir = file_path_mapping.map_prefix(working_dir); let sess = Session { From 732d9b281cbcc88a627fddb660a3b4021e1d94cf Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 26 Oct 2017 06:03:07 +0900 Subject: [PATCH 11/14] Return 0 when ./x.py has no subcommand --- src/bootstrap/flags.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index df378188b4ad0..b5d51598fab88 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -136,9 +136,12 @@ To learn more about a subcommand, run `./x.py -h`"); let subcommand = match subcommand { Some(s) => s, None => { - // No subcommand -- show the general usage and subcommand help + // No or an invalid subcommand -- show the general usage and subcommand help + // An exit code will be 0 when no subcommand is given, and 1 in case of an invalid + // subcommand. println!("{}\n", subcommand_help); - process::exit(1); + let exit_code = if args.is_empty() { 0 } else { 1 }; + process::exit(exit_code); } }; From 880200ac6b3dd939e2385264441d063a8f38312a Mon Sep 17 00:00:00 2001 From: Nadav Zingerman Date: Fri, 27 Oct 2017 12:42:44 +0300 Subject: [PATCH 12/14] Fixed rustc_on_unimplemented example in Unstable Book --- .../src/language-features/on-unimplemented.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/unstable-book/src/language-features/on-unimplemented.md b/src/doc/unstable-book/src/language-features/on-unimplemented.md index 9eea3fccbbc17..70c7c110b786a 100644 --- a/src/doc/unstable-book/src/language-features/on-unimplemented.md +++ b/src/doc/unstable-book/src/language-features/on-unimplemented.md @@ -15,8 +15,8 @@ For example: ```rust,compile_fail #![feature(on_unimplemented)] -#[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an \ - iterator over elements of type `{A}`"] +#[rustc_on_unimplemented="an iterator over elements of type `{A}` \ + cannot be built from a collection of type `{Self}`"] trait MyIterator { fn next(&mut self) -> A; } @@ -37,9 +37,9 @@ error[E0277]: the trait bound `&[{integer}]: MyIterator` is not satisfied --> :14:5 | 14 | iterate_chars(&[1, 2, 3][..]); - | ^^^^^^^^^^^^^ the trait `MyIterator` is not implemented for `&[{integer}]` + | ^^^^^^^^^^^^^ an iterator over elements of type `char` cannot be built from a collection of type `&[{integer}]` | - = note: a collection of type `&[{integer}]` cannot be built from an iterator over elements of type `char` + = help: the trait `MyIterator` is not implemented for `&[{integer}]` = note: required by `iterate_chars` error: aborting due to previous error From 5773efab5c4d4d234cecef32f95f16ce8783c285 Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Fri, 27 Oct 2017 19:14:03 +0200 Subject: [PATCH 13/14] Quit immediately when current directory is invalid Thanks-to: @kennytm --- src/librustc/session/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index cc27f61e369b7..a72be733f4b6f 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -776,9 +776,10 @@ pub fn build_session_(sopts: config::Options, let print_fuel_crate = sopts.debugging_opts.print_fuel.clone(); let print_fuel = Cell::new(0); - let working_dir = env::current_dir() - .expect("Could not find current working directory") - .to_string_lossy().into_owned(); + let working_dir = match env::current_dir() { + Ok(dir) => dir.to_string_lossy().into_owned(), + Err(e) => panic!(p_s.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e))), + }; let working_dir = file_path_mapping.map_prefix(working_dir); let sess = Session { From cfc916ebf8a9039e321924ed111727c2fcfb3e70 Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Fri, 27 Oct 2017 19:31:33 +0200 Subject: [PATCH 14/14] Fix tidy error line longer than 100 chars --- src/librustc/session/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index a72be733f4b6f..c87881341daa2 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -778,7 +778,9 @@ pub fn build_session_(sopts: config::Options, let working_dir = match env::current_dir() { Ok(dir) => dir.to_string_lossy().into_owned(), - Err(e) => panic!(p_s.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e))), + Err(e) => { + panic!(p_s.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e))) + } }; let working_dir = file_path_mapping.map_prefix(working_dir);