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 10 pull requests #54432

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cb594cf
Treat `dyn` as a keyword in the 2018 edition
varkor Sep 15, 2018
2a45057
rustbuild: drop color handling
Keruspe Sep 18, 2018
9332167
add -Zui-testing to rustdoc
QuietMisdreavus Sep 19, 2018
adc2c04
Make 'proc_macro::MultiSpan' public.
SergioBenitez Sep 20, 2018
b3ffd33
define copy_within on slices
oconnor663 Aug 23, 2018
d0e59f5
add tests for copy_within
oconnor663 Sep 19, 2018
000be8f
dbg!(expr) implementation.
Centril Sep 18, 2018
cbb81bd
dbg_macro: feature gate + move semantics test.
Centril Sep 18, 2018
6d08821
dbg_macro: Debug-required test.
Centril Sep 18, 2018
a9d2f38
dbg_macro: output tests.
Centril Sep 18, 2018
1d2a1bf
dbg_macro: notes about VCS and log::debug!(..)
Centril Sep 18, 2018
924a693
debug_macro: --bless tests.
Centril Sep 20, 2018
36d562f
Use no_default_libraries for all NetBSD flavors
bgermann Sep 20, 2018
d341b17
Add test for deref recursion limit printing twice
memoryruins Sep 21, 2018
70da203
Remove incidental notes
memoryruins Sep 21, 2018
7f9a259
add applicability to span suggestion call
jcpst Sep 21, 2018
48f4605
Simplify slice's first(_mut) and last(_mut) with get
ljedrz Sep 21, 2018
b9d51ed
Rollup merge of #53652 - oconnor663:copy_in_place, r=alexcrichton
kennytm Sep 21, 2018
8a61907
Rollup merge of #54261 - varkor:dyn-keyword-2018, r=petrochenkov
kennytm Sep 21, 2018
3168346
Rollup merge of #54317 - Centril:feature/dbg_macro, r=SimonSapin
kennytm Sep 21, 2018
da28ae2
Rollup merge of #54323 - Keruspe:rustc-color, r=Mark-Simulacrum
kennytm Sep 21, 2018
19b0748
Rollup merge of #54371 - QuietMisdreavus:rustdoc-ui-testing, r=Guilla…
kennytm Sep 21, 2018
a112600
Rollup merge of #54374 - SergioBenitez:pub-multispan, r=alexcrichton
kennytm Sep 21, 2018
99e79c0
Rollup merge of #54402 - bgermann:master, r=alexcrichton
kennytm Sep 21, 2018
fa6c16e
Rollup merge of #54412 - jcpst:replace_span_suggestion, r=estebank
kennytm Sep 21, 2018
eca7b5f
Rollup merge of #54413 - memoryruins:deref-error-twice, r=estebank
kennytm Sep 21, 2018
e6b2e80
Rollup merge of #54422 - ljedrz:simplify_first_last, r=Mark-Simulacrum
kennytm Sep 21, 2018
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
9 changes: 0 additions & 9 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,6 @@ fn main() {
cmd.arg("-Z").arg("verify-llvm-ir");
}

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 env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none()
{
cmd.arg("-Dwarnings");
Expand Down
34 changes: 1 addition & 33 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use build_helper::{output, mtime, up_to_date};
use filetime::FileTime;
use serde_json;

use util::{exe, libdir, is_dylib, CiEnv};
use util::{exe, libdir, is_dylib};
use {Compiler, Mode, GitRepo};
use native;

Expand Down Expand Up @@ -1034,29 +1034,6 @@ pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) {
}
}

// 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
}
}

pub fn run_cargo(builder: &Builder,
cargo: &mut Command,
tail_args: Vec<String>,
Expand Down Expand Up @@ -1218,15 +1195,6 @@ pub fn stream_cargo(
cargo.arg("--message-format").arg("json")
.stdout(Stdio::piped());

if stderr_isatty() && builder.ci_env == CiEnv::None &&
// if the terminal is reported as dumb, then we don't want to enable color for rustc
env::var_os("TERM").map(|t| t != *"dumb").unwrap_or(true) {
// 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");
}

for arg in tail_args {
cargo.arg(arg);
}
Expand Down
69 changes: 63 additions & 6 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn first(&self) -> Option<&T> {
if self.is_empty() { None } else { Some(&self[0]) }
self.get(0)
}

/// Returns a mutable pointer to the first element of the slice, or `None` if it is empty.
Expand All @@ -137,7 +137,7 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn first_mut(&mut self) -> Option<&mut T> {
if self.is_empty() { None } else { Some(&mut self[0]) }
self.get_mut(0)
}

/// Returns the first and all the rest of the elements of the slice, or `None` if it is empty.
Expand Down Expand Up @@ -239,7 +239,8 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn last(&self) -> Option<&T> {
if self.is_empty() { None } else { Some(&self[self.len() - 1]) }
let last_idx = self.len().checked_sub(1)?;
self.get(last_idx)
}

/// Returns a mutable pointer to the last item in the slice.
Expand All @@ -257,9 +258,8 @@ impl<T> [T] {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn last_mut(&mut self) -> Option<&mut T> {
let len = self.len();
if len == 0 { return None; }
Some(&mut self[len - 1])
let last_idx = self.len().checked_sub(1)?;
self.get_mut(last_idx)
}

/// Returns a reference to an element or subslice depending on the type of
Expand Down Expand Up @@ -1618,6 +1618,63 @@ impl<T> [T] {
}
}

/// Copies elements from one part of the slice to another part of itself,
/// using a memmove.
///
/// `src` is the range within `self` to copy from. `dest` is the starting
/// index of the range within `self` to copy to, which will have the same
/// length as `src`. The two ranges may overlap. The ends of the two ranges
/// must be less than or equal to `self.len()`.
///
/// # Panics
///
/// This function will panic if either range exceeds the end of the slice,
/// or if the end of `src` is before the start.
///
/// # Examples
///
/// Copying four bytes within a slice:
///
/// ```
/// # #![feature(copy_within)]
/// let mut bytes = *b"Hello, World!";
///
/// bytes.copy_within(1..5, 8);
///
/// assert_eq!(&bytes, b"Hello, Wello!");
/// ```
#[unstable(feature = "copy_within", issue = "54236")]
pub fn copy_within<R: ops::RangeBounds<usize>>(&mut self, src: R, dest: usize)
where
T: Copy,
{
let src_start = match src.start_bound() {
ops::Bound::Included(&n) => n,
ops::Bound::Excluded(&n) => n
.checked_add(1)
.unwrap_or_else(|| slice_index_overflow_fail()),
ops::Bound::Unbounded => 0,
};
let src_end = match src.end_bound() {
ops::Bound::Included(&n) => n
.checked_add(1)
.unwrap_or_else(|| slice_index_overflow_fail()),
ops::Bound::Excluded(&n) => n,
ops::Bound::Unbounded => self.len(),
};
assert!(src_start <= src_end, "src end is before src start");
assert!(src_end <= self.len(), "src is out of bounds");
let count = src_end - src_start;
assert!(dest <= self.len() - count, "dest is out of bounds");
unsafe {
ptr::copy(
self.get_unchecked(src_start),
self.get_unchecked_mut(dest),
count,
);
}
}

/// Swaps all elements in `self` with those in `other`.
///
/// The length of `other` must be the same as `self`.
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#![feature(inner_deref)]
#![feature(slice_internals)]
#![feature(option_replace)]
#![feature(copy_within)]

extern crate core;
extern crate test;
Expand Down
46 changes: 46 additions & 0 deletions src/libcore/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,3 +1000,49 @@ fn test_align_to_empty_mid() {
assert_eq!(mid.as_ptr() as usize % mem::align_of::<Chunk>(), 0);
}
}

#[test]
fn test_copy_within() {
// Start to end, with a RangeTo.
let mut bytes = *b"Hello, World!";
bytes.copy_within(..3, 10);
assert_eq!(&bytes, b"Hello, WorHel");

// End to start, with a RangeFrom.
let mut bytes = *b"Hello, World!";
bytes.copy_within(10.., 0);
assert_eq!(&bytes, b"ld!lo, World!");

// Overlapping, with a RangeInclusive.
let mut bytes = *b"Hello, World!";
bytes.copy_within(0..=11, 1);
assert_eq!(&bytes, b"HHello, World");

// Whole slice, with a RangeFull.
let mut bytes = *b"Hello, World!";
bytes.copy_within(.., 0);
assert_eq!(&bytes, b"Hello, World!");
}

#[test]
#[should_panic(expected = "src is out of bounds")]
fn test_copy_within_panics_src_too_long() {
let mut bytes = *b"Hello, World!";
// The length is only 13, so 14 is out of bounds.
bytes.copy_within(10..14, 0);
}

#[test]
#[should_panic(expected = "dest is out of bounds")]
fn test_copy_within_panics_dest_too_long() {
let mut bytes = *b"Hello, World!";
// The length is only 13, so a slice of length 4 starting at index 10 is out of bounds.
bytes.copy_within(0..4, 10);
}
#[test]
#[should_panic(expected = "src end is before src start")]
fn test_copy_within_panics_src_inverted() {
let mut bytes = *b"Hello, World!";
// 2 is greater than 1, so this range is invalid.
bytes.copy_within(2..1, 0);
}
2 changes: 1 addition & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub mod rustc;
mod diagnostic;

#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
pub use diagnostic::{Diagnostic, Level};
pub use diagnostic::{Diagnostic, Level, MultiSpan};

use std::{ascii, fmt, iter};
use std::path::PathBuf;
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,8 +1937,7 @@ impl EarlyLintPass for KeywordIdents {
let next_edition = match cx.sess.edition() {
Edition::Edition2015 => {
match &ident.as_str()[..] {
"async" |
"try" => Edition::Edition2018,
"async" | "try" | "dyn" => Edition::Edition2018,
_ => return,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::collections::VecDeque;
use std::fmt;
use syntax::symbol::keywords;
use syntax_pos::Span;
use syntax::errors::Applicability;

mod region_name;
mod var_name;
Expand Down Expand Up @@ -540,14 +541,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
RegionName::Named(name) => format!("{}", name),
RegionName::Synthesized(_) => "'_".to_string(),
};
diag.span_suggestion(
diag.span_suggestion_with_applicability(
span,
&format!(
"to allow this impl Trait to capture borrowed data with lifetime \
`{}`, add `{}` as a constraint",
fr_name, suggestable_fr_name,
),
format!("{} + {}", snippet, suggestable_fr_name),
Applicability::MachineApplicable,
);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/netbsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub fn opts() -> TargetOptions {
executables: true,
target_family: Some("unix".to_string()),
linker_is_gnu: true,
no_default_libraries: false,
has_rpath: true,
pre_link_args: args,
position_independent_executables: true,
Expand Down
1 change: 0 additions & 1 deletion src/librustc_target/spec/x86_64_rumprun_netbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub fn target() -> TargetResult {
base.has_rpath = false;
base.position_independent_executables = false;
base.disable_redzone = true;
base.no_default_libraries = false;
base.exe_allocation_crate = None;
base.stack_probes = true;

Expand Down
11 changes: 8 additions & 3 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ impl DocAccessLevels for AccessLevels<DefId> {
pub fn new_handler(error_format: ErrorOutputType,
source_map: Option<Lrc<source_map::SourceMap>>,
treat_err_as_bug: bool,
ui_testing: bool,
) -> errors::Handler {
// rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
// stick to the defaults
Expand All @@ -283,7 +284,7 @@ pub fn new_handler(error_format: ErrorOutputType,
source_map.map(|cm| cm as _),
false,
sessopts.debugging_opts.teach,
).ui_testing(sessopts.debugging_opts.ui_testing)
).ui_testing(ui_testing)
),
ErrorOutputType::Json(pretty) => {
let source_map = source_map.unwrap_or_else(
Expand All @@ -293,7 +294,7 @@ pub fn new_handler(error_format: ErrorOutputType,
None,
source_map,
pretty,
).ui_testing(sessopts.debugging_opts.ui_testing)
).ui_testing(ui_testing)
)
},
ErrorOutputType::Short(color_config) => Box::new(
Expand Down Expand Up @@ -335,6 +336,7 @@ pub fn run_core(search_paths: SearchPaths,
mut manual_passes: Vec<String>,
mut default_passes: passes::DefaultPassOption,
treat_err_as_bug: bool,
ui_testing: bool,
) -> (clean::Crate, RenderInfo, Vec<String>) {
// Parse, resolve, and typecheck the given crate.

Expand Down Expand Up @@ -389,6 +391,8 @@ pub fn run_core(search_paths: SearchPaths,
actually_rustdoc: true,
debugging_opts: config::DebuggingOptions {
force_unstable_if_unmarked,
treat_err_as_bug,
ui_testing,
..config::basic_debugging_options()
},
error_format,
Expand All @@ -400,7 +404,8 @@ pub fn run_core(search_paths: SearchPaths,
let source_map = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping()));
let diagnostic_handler = new_handler(error_format,
Some(source_map.clone()),
treat_err_as_bug);
treat_err_as_bug,
ui_testing);

let mut sess = session::build_session_(
sessopts, cpath, diagnostic_handler, source_map,
Expand Down
12 changes: 9 additions & 3 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,11 @@ fn main_args(args: &[String]) -> isize {
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
*x == "treat-err-as-bug"
});
let ui_testing = matches.opt_strs("Z").iter().any(|x| {
*x == "ui-testing"
});

let diag = core::new_handler(error_format, None, treat_err_as_bug);
let diag = core::new_handler(error_format, None, treat_err_as_bug, ui_testing);

// check for deprecated options
check_deprecated_options(&matches, &diag);
Expand Down Expand Up @@ -565,7 +568,7 @@ fn main_args(args: &[String]) -> isize {
let res = acquire_input(PathBuf::from(input), externs, edition, cg, &matches, error_format,
move |out| {
let Output { krate, passes, renderinfo } = out;
let diag = core::new_handler(error_format, None, treat_err_as_bug);
let diag = core::new_handler(error_format, None, treat_err_as_bug, ui_testing);
info!("going to format");
match output_format.as_ref().map(|s| &**s) {
Some("html") | None => {
Expand Down Expand Up @@ -702,6 +705,9 @@ where R: 'static + Send,
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
*x == "treat-err-as-bug"
});
let ui_testing = matches.opt_strs("Z").iter().any(|x| {
*x == "ui-testing"
});

let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);

Expand All @@ -715,7 +721,7 @@ where R: 'static + Send,
display_warnings, crate_name.clone(),
force_unstable_if_unmarked, edition, cg, error_format,
lint_opts, lint_cap, describe_lints, manual_passes, default_passes,
treat_err_as_bug);
treat_err_as_bug, ui_testing);

info!("finished with rustc");

Expand Down
Loading