Skip to content

Rollup of 7 pull requests #45586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5243a98
Add a brief description and two examples to std::process
Technius Oct 14, 2017
e788e90
Fixed accidental deletion of colon
Technius Oct 15, 2017
bb74b13
Fix std::process hello world example
Technius Oct 15, 2017
f67f662
Create section on how to spawn processes; change module description
Technius Oct 16, 2017
3566832
Add child process IO handling docs
Technius Oct 18, 2017
4fdd629
rustdoc: update pulldown renderer
QuietMisdreavus Oct 20, 2017
af09ba8
change footnote anchor formats to fix spurious rendering differences
QuietMisdreavus Oct 21, 2017
4c6942d
Remove 'just' in diagnostics
steveklabnik Oct 26, 2017
04f27f0
Improve docs for UdpSocket::set_nonblocking.
frewsxcv Oct 22, 2017
11d758a
Use expect for current_dir on librustc/session mod
spk Oct 24, 2017
732d9b2
Return 0 when ./x.py has no subcommand
topecongiro Oct 25, 2017
880200a
Fixed rustc_on_unimplemented example in Unstable Book
nzig Oct 27, 2017
5773efa
Quit immediately when current directory is invalid
spk Oct 27, 2017
cfc916e
Fix tidy error line longer than 100 chars
spk Oct 27, 2017
0aad849
Rollup merge of #45295 - Technius:docs/process, r=steveklabnik
frewsxcv Oct 28, 2017
e814f75
Rollup merge of #45421 - QuietMisdreavus:update-pulldown, r=steveklabnik
frewsxcv Oct 28, 2017
6a8b21c
Rollup merge of #45449 - frewsxcv:frewsxcv-udp-nonblocking, r=sfackler
frewsxcv Oct 28, 2017
efd20e7
Rollup merge of #45505 - spk:use-expect-instead-unwrap, r=kennytm
frewsxcv Oct 28, 2017
4993701
Rollup merge of #45535 - topecongiro:bootstrap-exit-code, r=kennytm
frewsxcv Oct 28, 2017
00f07f1
Rollup merge of #45549 - steveklabnik:remove-just, r=QuietMisdreavus
frewsxcv Oct 28, 2017
09134a2
Rollup merge of #45574 - nzig:on_unimplemented_example, r=steveklabnik
frewsxcv Oct 28, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -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);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<A> {
fn next(&mut self) -> A;
}
Expand All @@ -37,9 +37,9 @@ error[E0277]: the trait bound `&[{integer}]: MyIterator<char>` is not satisfied
--> <anon>:14:5
|
14 | iterate_chars(&[1, 2, 3][..]);
| ^^^^^^^^^^^^^ the trait `MyIterator<char>` 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<char>` is not implemented for `&[{integer}]`
= note: required by `iterate_chars`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
Expand Down
7 changes: 6 additions & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,12 @@ 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 = 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for Footnotes<'a, I> {
match self.inner.next() {
Some(Event::FootnoteReference(ref reference)) => {
let entry = self.get_entry(&reference);
let reference = format!("<sup id=\"supref{0}\"><a href=\"#ref{0}\">{0}\
let reference = format!("<sup id=\"fnref{0}\"><a href=\"#fn{0}\">{0}\
</a></sup>",
(*entry).1);
return Some(Event::Html(reference.into()));
Expand All @@ -394,15 +394,15 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for Footnotes<'a, I> {
v.sort_by(|a, b| a.1.cmp(&b.1));
let mut ret = String::from("<div class=\"footnotes\"><hr><ol>");
for (mut content, id) in v {
write!(ret, "<li id=\"ref{}\">", id).unwrap();
write!(ret, "<li id=\"fn{}\">", id).unwrap();
let mut is_paragraph = false;
if let Some(&Event::End(Tag::Paragraph)) = content.last() {
content.pop();
is_paragraph = true;
}
html::push_html(&mut ret, content.into_iter());
write!(ret,
"&nbsp;<a href=\"#supref{}\" rev=\"footnote\">↩</a>",
"&nbsp;<a href=\"#fnref{}\" rev=\"footnote\">↩</a>",
id).unwrap();
if is_paragraph {
ret.push_str("</p>");
Expand Down
37 changes: 33 additions & 4 deletions src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down
85 changes: 73 additions & 12 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,68 @@

//! A module for working with processes.
//!
//! # Examples
//! This module is mostly concerned with spawning and interacting with child
//! processes, but it also provides [`abort`] and [`exit`] for terminating the
//! current process.
//!
//! Basic usage where we try to execute the `cat` shell command:
//! # Spawning a process
//!
//! ```should_panic
//! The [`Command`] struct is used to configure and spawn processes:
//!
//! ```
//! use std::process::Command;
//!
//! let mut child = Command::new("/bin/cat")
//! .arg("file.txt")
//! .spawn()
//! .expect("failed to execute child");
//! let output = Command::new("echo")
//! .arg("Hello world")
//! .output()
//! .expect("Failed to execute command");
//!
//! 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.
//!
//! let ecode = child.wait()
//! .expect("failed to wait on child");
//! # Handling I/O
//!
//! 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:
//!
//! assert!(ecode.success());
//! ```
//! 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");
//!
//! Calling a command with input and reading its output:
//! // 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");
//!
//! ```no_run
//! 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());
//! ```
//!
//! Note that [`ChildStderr`] and [`ChildStdout`] implement [`Write`] and
//! [`ChildStdin`] implements [`Read`]:
//!
//! ```
//! use std::process::{Command, Stdio};
//! use std::io::Write;
//!
Expand All @@ -52,6 +93,26 @@
//!
//! 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
//! [`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")]

Expand Down