Skip to content
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

Rollup of 7 pull requests #42817

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 1 addition & 7 deletions src/bootstrap/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ use bootstrap::{Flags, Config, Build};
fn main() {
let args = env::args().skip(1).collect::<Vec<_>>();
let flags = Flags::parse(&args);
let mut config = Config::parse(&flags.build, flags.config.clone());

// compat with `./configure` while we're still using that
if std::fs::metadata("config.mk").is_ok() {
config.update_with_config_mk();
}

let config = Config::parse(&flags.build, flags.config.clone());
Build::new(flags, config).build();
}
9 changes: 9 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ fn main() {
}
}

let color = match env::var("RUSTC_COLOR") {
Ok(s) => usize::from_str(&s).expect("RUSTC_COLOR should be an integer"),
Err(_) => 0,
};

if color != 0 {
cmd.arg("--color=always");
}

if verbose > 1 {
writeln!(&mut io::stderr(), "rustc command: {:?}", cmd).unwrap();
}
Expand Down
10 changes: 5 additions & 5 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ fn main() {
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());

// Pass the `rustbuild` feature flag to crates which rustbuild is
// building. See the comment in bootstrap/lib.rs where this env var is
// set for more details.
if env::var_os("RUSTBUILD_UNSTABLE").is_some() {
cmd.arg("--cfg").arg("rustbuild");
// Force all crates compiled by this compiler to (a) be unstable and (b)
// allow the `rustc_private` feature to link to other unstable crates
// also in the sysroot.
if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() {
cmd.arg("-Z").arg("force-unstable-if-unmarked");
}

std::process::exit(match cmd.status() {
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ def bootstrap():
env["BUILD"] = rb.build
env["SRC"] = rb.rust_root
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
env["BOOTSTRAP_PYTHON"] = sys.executable
run(args, env=env, verbose=rb.verbose)


Expand Down
32 changes: 32 additions & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,43 @@ pub fn tool(build: &Build, stage: u32, target: &str, tool: &str) {
build.run(&mut cargo);
}


// Avoiding a dependency on winapi to keep compile times down
#[cfg(unix)]
fn stderr_isatty() -> bool {
use libc;
unsafe { libc::isatty(libc::STDERR_FILENO) != 0 }
}
#[cfg(windows)]
fn stderr_isatty() -> bool {
type DWORD = u32;
type BOOL = i32;
type HANDLE = *mut u8;
const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD;
extern "system" {
fn GetStdHandle(which: DWORD) -> HANDLE;
fn GetConsoleMode(hConsoleHandle: HANDLE, lpMode: *mut DWORD) -> BOOL;
}
unsafe {
let handle = GetStdHandle(STD_ERROR_HANDLE);
let mut out = 0;
GetConsoleMode(handle, &mut out) != 0
}
}

fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) {
// Instruct Cargo to give us json messages on stdout, critically leaving
// stderr as piped so we can get those pretty colors.
cargo.arg("--message-format").arg("json")
.stdout(Stdio::piped());

if stderr_isatty() {
// since we pass message-format=json to cargo, we need to tell the rustc
// wrapper to give us colored output if necessary. This is because we
// only want Cargo's JSON output, not rustcs.
cargo.env("RUSTC_COLOR", "1");
}

build.verbose(&format!("running: {:?}", cargo));
let mut child = match cargo.spawn() {
Ok(child) => child,
Expand Down
10 changes: 8 additions & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::PathBuf;
use std::process;
Expand Down Expand Up @@ -410,6 +410,12 @@ impl Config {
set(&mut config.rust_dist_src, t.src_tarball);
}


// compat with `./configure` while we're still using that
if fs::metadata("config.mk").is_ok() {
config.update_with_config_mk();
}

return config
}

Expand All @@ -418,7 +424,7 @@ impl Config {
/// While we still have `./configure` this implements the ability to decode
/// that configuration into this. This isn't exactly a full-blown makefile
/// parser, but hey it gets the job done!
pub fn update_with_config_mk(&mut self) {
fn update_with_config_mk(&mut self) {
let mut config = String::new();
File::open("config.mk").unwrap().read_to_string(&mut config).unwrap();
for line in config.lines() {
Expand Down
7 changes: 7 additions & 0 deletions src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::env;
use std::ffi::{OsStr, OsString};
use std::fs;
use std::process::Command;
use std::path::PathBuf;

use build_helper::output;

Expand Down Expand Up @@ -86,6 +87,12 @@ pub fn check(build: &mut Build) {
}
}

if build.config.python.is_none() {
// set by bootstrap.py
if let Some(v) = env::var_os("BOOTSTRAP_PYTHON") {
build.config.python = Some(PathBuf::from(v));
}
}
if build.config.python.is_none() {
build.config.python = have_cmd("python2.7".as_ref());
}
Expand Down
4 changes: 3 additions & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
//! Recursive structures must be boxed, because if the definition of `Cons`
//! looked like this:
//!
//! ```rust,ignore
//! ```compile_fail,E0072
//! # enum List<T> {
//! Cons(T, List<T>),
//! # }
//! ```
//!
//! It wouldn't work. This is because the size of a `List` depends on how many
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
//! There are a number of related macros in the `format!` family. The ones that
//! are currently implemented are:
//!
//! ```ignore
//! ```ignore (only-for-syntax-highlight)
//! format! // described above
//! write! // first argument is a &mut io::Write, the destination
//! writeln! // same as write but appends a newline
Expand Down
22 changes: 19 additions & 3 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,11 @@ impl<T, A: Alloc> RawVec<T, A> {
///
/// # Examples
///
/// ```ignore
/// ```
/// # #![feature(alloc)]
/// # extern crate alloc;
/// # use std::ptr;
/// # use alloc::raw_vec::RawVec;
/// struct MyVec<T> {
/// buf: RawVec<T>,
/// len: usize,
Expand All @@ -261,6 +265,10 @@ impl<T, A: Alloc> RawVec<T, A> {
/// self.len += 1;
/// }
/// }
/// # fn main() {
/// # let mut vec = MyVec { buf: RawVec::new(), len: 0 };
/// # vec.push(1);
/// # }
/// ```
#[inline(never)]
#[cold]
Expand Down Expand Up @@ -440,13 +448,17 @@ impl<T, A: Alloc> RawVec<T, A> {
///
/// # Examples
///
/// ```ignore
/// ```
/// # #![feature(alloc)]
/// # extern crate alloc;
/// # use std::ptr;
/// # use alloc::raw_vec::RawVec;
/// struct MyVec<T> {
/// buf: RawVec<T>,
/// len: usize,
/// }
///
/// impl<T> MyVec<T> {
/// impl<T: Clone> MyVec<T> {
/// pub fn push_all(&mut self, elems: &[T]) {
/// self.buf.reserve(self.len, elems.len());
/// // reserve would have aborted or panicked if the len exceeded
Expand All @@ -459,6 +471,10 @@ impl<T, A: Alloc> RawVec<T, A> {
/// }
/// }
/// }
/// # fn main() {
/// # let mut vector = MyVec { buf: RawVec::new(), len: 0 };
/// # vector.push_all(&[1, 3, 5, 7, 9]);
/// # }
/// ```
pub fn reserve(&mut self, used_cap: usize, needed_extra_cap: usize) {
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ use boxed::Box;
/// similar, but without the UTF-8 constraint. The second implication is that
/// you cannot index into a `String`:
///
/// ```ignore
/// ```compile_fail,E0277
/// let s = "hello";
///
/// println!("The first letter of s is {}", s[0]); // ERROR!!!
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ use Bound::{Excluded, Included, Unbounded};
/// However be careful: if you try to access an index which isn't in the `Vec`,
/// your software will panic! You cannot do this:
///
/// ```ignore
/// ```should_panic
/// let v = vec![0, 2, 4, 6];
/// println!("{}", v[6]); // it will panic!
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
//! There's one more subtle bit here: the standard library contains an
//! interesting implementation of [`IntoIterator`]:
//!
//! ```ignore
//! ```ignore (only-for-syntax-highlight)
//! impl<I: Iterator> IntoIterator for I
//! ```
//!
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ macro_rules! impls{
/// example, here is a struct `Slice` that has two pointers of type `*const T`,
/// presumably pointing into an array somewhere:
///
/// ```ignore
/// ```compile_fail,E0392
/// struct Slice<'a, T> {
/// start: *const T,
/// end: *const T,
Expand Down
15 changes: 11 additions & 4 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,18 @@ pub fn align_of_val<T: ?Sized>(val: &T) -> usize {
///
/// Here's an example of how a collection might make use of needs_drop:
///
/// ```ignore
/// ```
/// #![feature(needs_drop)]
/// use std::{mem, ptr};
///
/// pub struct MyCollection<T> { /* ... */ }
/// pub struct MyCollection<T> {
/// # data: [T; 1],
/// /* ... */
/// }
/// # impl<T> MyCollection<T> {
/// # fn iter_mut(&mut self) -> &mut [T] { &mut self.data }
/// # fn free_buffer(&mut self) {}
/// # }
///
/// impl<T> Drop for MyCollection<T> {
/// fn drop(&mut self) {
Expand Down Expand Up @@ -575,7 +582,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
/// `replace` allows consumption of a struct field by replacing it with another value.
/// Without `replace` you can run into issues like these:
///
/// ```ignore
/// ```compile_fail,E0507
/// struct Buffer<T> { buf: Vec<T> }
///
/// impl<T> Buffer<T> {
Expand Down Expand Up @@ -645,7 +652,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
///
/// Borrows are based on lexical scope, so this produces an error:
///
/// ```ignore
/// ```compile_fail,E0502
/// let mut v = vec![1, 2, 3];
/// let x = &v[0];
///
Expand Down
18 changes: 16 additions & 2 deletions src/libcore/ops/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ pub trait Place<Data: ?Sized> {
///
/// `PLACE <- EXPR` effectively desugars into:
///
/// ```rust,ignore
/// ```
/// # #![feature(placement_new_protocol, box_heap)]
/// # use std::ops::{Placer, Place, InPlace};
/// # #[allow(non_snake_case)]
/// # fn main() {
/// # let PLACE = std::boxed::HEAP;
/// # let EXPR = 1;
/// let p = PLACE;
/// let mut place = Placer::make_place(p);
/// let raw_place = Place::pointer(&mut place);
Expand All @@ -47,6 +53,7 @@ pub trait Place<Data: ?Sized> {
/// std::ptr::write(raw_place, value);
/// InPlace::finalize(place)
/// }
/// # ; }
/// ```
///
/// The type of `PLACE <- EXPR` is derived from the type of `PLACE`;
Expand Down Expand Up @@ -89,14 +96,21 @@ pub trait InPlace<Data: ?Sized>: Place<Data> {
///
/// `box EXPR` effectively desugars into:
///
/// ```rust,ignore
/// ```
/// # #![feature(placement_new_protocol)]
/// # use std::ops::{BoxPlace, Place, Boxed};
/// # #[allow(non_snake_case)]
/// # fn main() {
/// # let EXPR = 1;
/// let mut place = BoxPlace::make_place();
/// let raw_place = Place::pointer(&mut place);
/// let value = EXPR;
/// # let _: Box<_> =
/// unsafe {
/// ::std::ptr::write(raw_place, value);
/// Boxed::finalize(place)
/// }
/// # ; }
/// ```
///
/// The type of `box EXPR` is supplied from its surrounding
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/ops/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use fmt;
/// It does not have an `IntoIterator` implementation, so you can't use it in a
/// `for` loop directly. This won't compile:
///
/// ```ignore
/// ```compile_fail,E0277
/// for i in .. {
/// // ...
/// }
Expand Down Expand Up @@ -184,7 +184,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
/// It does not have an `IntoIterator` implementation, so you can't use it in a
/// `for` loop directly. This won't compile:
///
/// ```ignore
/// ```compile_fail,E0277
/// for i in ..5 {
/// // ...
/// }
Expand Down Expand Up @@ -313,7 +313,8 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// It does not have an `IntoIterator` implementation, so you can't use it in a
/// `for` loop directly. This won't compile:
///
/// ```ignore
/// ```compile_fail,E0277
/// #![feature(inclusive_range_syntax)]
/// for i in ...5 {
/// // ...
/// }
Expand Down
6 changes: 4 additions & 2 deletions src/libcore/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
//! useful an upstream crate must define panicking for libcore to use. The current
//! interface for panicking is:
//!
//! ```ignore
//! fn panic_impl(fmt: fmt::Arguments, &(&'static str, u32)) -> !;
//! ```
//! # use std::fmt;
//! fn panic_impl(fmt: fmt::Arguments, file_line: &(&'static str, u32)) -> !
//! # { loop {} }
//! ```
//!
//! This definition allows for panicking with any general message, but it does not
Expand Down
Loading