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 8 pull requests #64230

Merged
merged 17 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def check_submodule(self, module, slow_submodules):
def update_submodule(self, module, checked_out, recorded_submodules):
module_path = os.path.join(self.rust_root, module)

if checked_out != None:
if checked_out is not None:
default_encoding = sys.getdefaultencoding()
checked_out = checked_out.communicate()[0].decode(default_encoding).strip()
if recorded_submodules[module] == checked_out:
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ pub fn std_cargo(builder: &Builder<'_>,
emscripten: false,
});
cargo.env("LLVM_CONFIG", llvm_config);
cargo.env("RUSTC_BUILD_SANITIZERS", "1");
}

cargo.arg("--features").arg(features)
Expand Down
31 changes: 31 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,18 @@ impl<T: Deref> Option<T> {
/// to the original one, additionally coercing the contents via [`Deref`].
///
/// [`Deref`]: ../../std/ops/trait.Deref.html
///
/// # Examples
///
/// ```
/// #![feature(inner_deref)]
///
/// let x: Option<String> = Some("hey".to_owned());
/// assert_eq!(x.as_deref(), Some("hey"));
///
/// let x: Option<String> = None;
/// assert_eq!(x.as_deref(), None);
/// ```
pub fn as_deref(&self) -> Option<&T::Target> {
self.as_ref().map(|t| t.deref())
}
Expand All @@ -1121,6 +1133,18 @@ impl<T: DerefMut> Option<T> {
///
/// Leaves the original `Option` in-place, creating a new one containing a mutable reference to
/// the inner type's `Deref::Target` type.
///
/// # Examples
///
/// ```
/// #![feature(inner_deref)]
///
/// let mut x: Option<String> = Some("hey".to_owned());
/// assert_eq!(x.as_deref_mut().map(|x| {
/// x.make_ascii_uppercase();
/// x
/// }), Some("HEY".to_owned().as_mut_str()));
/// ```
pub fn as_deref_mut(&mut self) -> Option<&mut T::Target> {
self.as_mut().map(|t| t.deref_mut())
}
Expand Down Expand Up @@ -1199,6 +1223,13 @@ impl<T: Clone> Clone for Option<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Default for Option<T> {
/// Returns [`None`][Option::None].
///
/// # Examples
///
/// ```
/// let opt: Option<u32> = Option::default();
/// assert!(opt.is_none());
/// ```
#[inline]
fn default() -> Option<T> { None }
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/unicode/printable.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_codepoints(f):
yield Codepoint(codepoint, class_)
prev_codepoint = codepoint

if class_first != None:
if class_first is not None:
raise ValueError("Missing Last after First")

for c in range(prev_codepoint + 1, NUM_CODEPOINTS):
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,13 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
match self {
PointerOutOfBounds { ptr, msg, allocation_size } => {
write!(f, "{} failed: pointer must be in-bounds at offset {}, \
but is outside bounds of allocation {} which has size {}",
but is outside bounds of allocation {} which has size {}",
msg, ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes())
},
ValidationFailure(ref err) => {
write!(f, "type validation failed: {}", err)
}
NoMirFor(ref func) => write!(f, "no mir for `{}`", func),
NoMirFor(ref func) => write!(f, "no MIR for `{}`", func),
FunctionAbiMismatch(caller_abi, callee_abi) =>
write!(f, "tried to call a function with ABI {:?} using caller ABI {:?}",
callee_abi, caller_abi),
Expand All @@ -451,9 +451,9 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
FunctionArgCountMismatch =>
write!(f, "tried to call a function with incorrect number of arguments"),
ReallocatedWrongMemoryKind(ref old, ref new) =>
write!(f, "tried to reallocate memory from {} to {}", old, new),
write!(f, "tried to reallocate memory from `{}` to `{}`", old, new),
DeallocatedWrongMemoryKind(ref old, ref new) =>
write!(f, "tried to deallocate {} memory but gave {} as the kind", old, new),
write!(f, "tried to deallocate `{}` memory but gave `{}` as the kind", old, new),
InvalidChar(c) =>
write!(f, "tried to interpret an invalid 32-bit value as a char: {}", c),
AlignmentCheckFailed { required, has } =>
Expand All @@ -462,7 +462,7 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
TypeNotPrimitive(ty) =>
write!(f, "expected primitive type, got {}", ty),
PathNotFound(ref path) =>
write!(f, "Cannot find path {:?}", path),
write!(f, "cannot find path {:?}", path),
IncorrectAllocationInformation(size, size2, align, align2) =>
write!(f, "incorrect alloc info: expected size {} and align {}, \
got size {} and align {}",
Expand Down Expand Up @@ -525,7 +525,7 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
InvalidBoolOp(_) =>
write!(f, "invalid boolean operation"),
UnterminatedCString(_) =>
write!(f, "attempted to get length of a null terminated string, but no null \
write!(f, "attempted to get length of a null-terminated string, but no null \
found before end of allocation"),
ReadUndefBytes(_) =>
write!(f, "attempted to read undefined bytes"),
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@ pub fn parse_error_format(
Some(arg) => early_error(
ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color)),
&format!(
"argument for --error-format must be `human`, `json` or \
"argument for `--error-format` must be `human`, `json` or \
`short` (instead was `{}`)",
arg
),
Expand Down Expand Up @@ -2037,7 +2037,7 @@ pub fn build_session_options_and_crate_config(
early_error(
ErrorOutputType::default(),
&format!(
"argument for --edition must be one of: \
"argument for `--edition` must be one of: \
{}. (instead was `{}`)",
EDITION_NAME_LIST,
arg
Expand All @@ -2051,7 +2051,7 @@ pub fn build_session_options_and_crate_config(
early_error(
ErrorOutputType::default(),
&format!(
"Edition {} is unstable and only \
"edition {} is unstable and only \
available for nightly builds of rustc.",
edition,
)
Expand All @@ -2075,14 +2075,14 @@ pub fn build_session_options_and_crate_config(
if let ErrorOutputType::Json { pretty: true, json_rendered } = error_format {
early_error(
ErrorOutputType::Json { pretty: false, json_rendered },
"--error-format=pretty-json is unstable",
"`--error-format=pretty-json` is unstable",
);
}
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(_)) =
error_format {
early_error(
ErrorOutputType::Json { pretty: false, json_rendered },
"--error-format=human-annotate-rs is unstable",
"`--error-format=human-annotate-rs` is unstable",
);
}
}
Expand Down Expand Up @@ -2132,8 +2132,8 @@ pub fn build_session_options_and_crate_config(
early_warn(
error_format,
&format!(
"--emit={} with -o incompatible with \
-C codegen-units=N for N > 1",
"`--emit={}` with `-o` incompatible with \
`-C codegen-units=N` for N > 1",
ot
),
);
Expand All @@ -2153,21 +2153,21 @@ pub fn build_session_options_and_crate_config(
if debugging_opts.threads == Some(0) {
early_error(
error_format,
"Value for threads must be a positive nonzero integer",
"value for threads must be a positive non-zero integer",
);
}

if debugging_opts.threads.unwrap_or(1) > 1 && debugging_opts.fuel.is_some() {
early_error(
error_format,
"Optimization fuel is incompatible with multiple threads",
"optimization fuel is incompatible with multiple threads",
);
}

if codegen_units == Some(0) {
early_error(
error_format,
"Value for codegen units must be a positive nonzero integer",
"value for codegen units must be a positive non-zero integer",
);
}

Expand Down
7 changes: 4 additions & 3 deletions src/librustc/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl<'tcx> TyCtxt<'tcx> {
match self.layout_of(param_env.and(ty)) {
Ok(layout) => &layout.abi,
Err(err) => bug!(
"Error: {}\n while computing layout for type {:?}", err, ty
"error: {}\n while computing layout for type {:?}", err, ty
)
}
};
Expand All @@ -384,7 +384,7 @@ impl<'tcx> TyCtxt<'tcx> {
self.sess.delay_span_bug(
self.def_span(method.def_id),
&format!(
"Receiver when Self = () should have a Scalar ABI, found {:?}",
"receiver when `Self = ()` should have a Scalar ABI; found {:?}",
abi
),
);
Expand All @@ -406,7 +406,8 @@ impl<'tcx> TyCtxt<'tcx> {
self.sess.delay_span_bug(
self.def_span(method.def_id),
&format!(
"Receiver when Self = {} should have a ScalarPair ABI, found {:?}",
"receiver when `Self = {}` should have a ScalarPair ABI; \
found {:?}",
trait_object_ty, abi
),
);
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_asan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
use cmake::Config;

fn main() {
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();

Expand Down
12 changes: 8 additions & 4 deletions src/librustc_errors/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ pub struct AnnotateSnippetEmitterWriter {
impl Emitter for AnnotateSnippetEmitterWriter {
/// The entry point for the diagnostics generation
fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) {
let children = db.children.clone();
let (primary_span, suggestions) = self.primary_span_formatted(&db);
let mut children = db.children.clone();
let (mut primary_span, suggestions) = self.primary_span_formatted(&db);

// FIXME(#59346): Add `fix_multispans_in_std_macros` function from emitter.rs
self.fix_multispans_in_std_macros(&self.source_map,
&mut primary_span,
&mut children,
&db.level,
db.handler.flags.external_macro_backtrace);

self.emit_messages_default(&db.level,
db.message(),
Expand Down Expand Up @@ -105,7 +109,7 @@ impl<'a> DiagnosticConverter<'a> {
annotated_files: Vec<FileWithAnnotatedLines>,
primary_lo: Loc
) -> Vec<Slice> {
// FIXME(#59346): Provide a test case where `annotated_files` is > 1
// FIXME(#64205): Provide a test case where `annotated_files` is > 1
annotated_files.iter().flat_map(|annotated_file| {
annotated_file.lines.iter().map(|line| {
let line_source = Self::source_string(annotated_file.file.clone(), &line);
Expand Down
Loading