Skip to content

Commit 6e19f3f

Browse files
committed
Auto merge of #64230 - Centril:rollup-vxyczjq, r=Centril
Rollup of 8 pull requests Successful merges: - #63565 (Rust 2018: NLL migrate mode => hard error) - #63969 (Add missing examples for Option type) - #64067 (Remove no-prefer-dynamic from valgrind tests) - #64166 (Better way of conditioning the sanitizer builds) - #64189 (annotate-snippet emitter: Deal with multispans from macros, too) - #64202 (Fixed grammar/style in some error messages) - #64206 (annotate-snippet emitter: Update an issue number) - #64208 (it's more pythonic to use 'is not None' in python files) Failed merges: r? @ghost
2 parents 4894123 + ee54499 commit 6e19f3f

File tree

149 files changed

+581
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+581
-538
lines changed

src/bootstrap/bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def check_submodule(self, module, slow_submodules):
668668
def update_submodule(self, module, checked_out, recorded_submodules):
669669
module_path = os.path.join(self.rust_root, module)
670670

671-
if checked_out != None:
671+
if checked_out is not None:
672672
default_encoding = sys.getdefaultencoding()
673673
checked_out = checked_out.communicate()[0].decode(default_encoding).strip()
674674
if recorded_submodules[module] == checked_out:

src/bootstrap/compile.rs

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ pub fn std_cargo(builder: &Builder<'_>,
212212
emscripten: false,
213213
});
214214
cargo.env("LLVM_CONFIG", llvm_config);
215+
cargo.env("RUSTC_BUILD_SANITIZERS", "1");
215216
}
216217

217218
cargo.arg("--features").arg(features)

src/libcore/option.rs

+31
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,18 @@ impl<T: Deref> Option<T> {
11101110
/// to the original one, additionally coercing the contents via [`Deref`].
11111111
///
11121112
/// [`Deref`]: ../../std/ops/trait.Deref.html
1113+
///
1114+
/// # Examples
1115+
///
1116+
/// ```
1117+
/// #![feature(inner_deref)]
1118+
///
1119+
/// let x: Option<String> = Some("hey".to_owned());
1120+
/// assert_eq!(x.as_deref(), Some("hey"));
1121+
///
1122+
/// let x: Option<String> = None;
1123+
/// assert_eq!(x.as_deref(), None);
1124+
/// ```
11131125
pub fn as_deref(&self) -> Option<&T::Target> {
11141126
self.as_ref().map(|t| t.deref())
11151127
}
@@ -1121,6 +1133,18 @@ impl<T: DerefMut> Option<T> {
11211133
///
11221134
/// Leaves the original `Option` in-place, creating a new one containing a mutable reference to
11231135
/// the inner type's `Deref::Target` type.
1136+
///
1137+
/// # Examples
1138+
///
1139+
/// ```
1140+
/// #![feature(inner_deref)]
1141+
///
1142+
/// let mut x: Option<String> = Some("hey".to_owned());
1143+
/// assert_eq!(x.as_deref_mut().map(|x| {
1144+
/// x.make_ascii_uppercase();
1145+
/// x
1146+
/// }), Some("HEY".to_owned().as_mut_str()));
1147+
/// ```
11241148
pub fn as_deref_mut(&mut self) -> Option<&mut T::Target> {
11251149
self.as_mut().map(|t| t.deref_mut())
11261150
}
@@ -1199,6 +1223,13 @@ impl<T: Clone> Clone for Option<T> {
11991223
#[stable(feature = "rust1", since = "1.0.0")]
12001224
impl<T> Default for Option<T> {
12011225
/// Returns [`None`][Option::None].
1226+
///
1227+
/// # Examples
1228+
///
1229+
/// ```
1230+
/// let opt: Option<u32> = Option::default();
1231+
/// assert!(opt.is_none());
1232+
/// ```
12021233
#[inline]
12031234
fn default() -> Option<T> { None }
12041235
}

src/libcore/unicode/printable.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_codepoints(f):
6060
yield Codepoint(codepoint, class_)
6161
prev_codepoint = codepoint
6262

63-
if class_first != None:
63+
if class_first is not None:
6464
raise ValueError("Missing Last after First")
6565

6666
for c in range(prev_codepoint + 1, NUM_CODEPOINTS):

src/librustc/mir/interpret/error.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
430430
match self {
431431
PointerOutOfBounds { ptr, msg, allocation_size } => {
432432
write!(f, "{} failed: pointer must be in-bounds at offset {}, \
433-
but is outside bounds of allocation {} which has size {}",
433+
but is outside bounds of allocation {} which has size {}",
434434
msg, ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes())
435435
},
436436
ValidationFailure(ref err) => {
437437
write!(f, "type validation failed: {}", err)
438438
}
439-
NoMirFor(ref func) => write!(f, "no mir for `{}`", func),
439+
NoMirFor(ref func) => write!(f, "no MIR for `{}`", func),
440440
FunctionAbiMismatch(caller_abi, callee_abi) =>
441441
write!(f, "tried to call a function with ABI {:?} using caller ABI {:?}",
442442
callee_abi, caller_abi),
@@ -451,9 +451,9 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
451451
FunctionArgCountMismatch =>
452452
write!(f, "tried to call a function with incorrect number of arguments"),
453453
ReallocatedWrongMemoryKind(ref old, ref new) =>
454-
write!(f, "tried to reallocate memory from {} to {}", old, new),
454+
write!(f, "tried to reallocate memory from `{}` to `{}`", old, new),
455455
DeallocatedWrongMemoryKind(ref old, ref new) =>
456-
write!(f, "tried to deallocate {} memory but gave {} as the kind", old, new),
456+
write!(f, "tried to deallocate `{}` memory but gave `{}` as the kind", old, new),
457457
InvalidChar(c) =>
458458
write!(f, "tried to interpret an invalid 32-bit value as a char: {}", c),
459459
AlignmentCheckFailed { required, has } =>
@@ -462,7 +462,7 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
462462
TypeNotPrimitive(ty) =>
463463
write!(f, "expected primitive type, got {}", ty),
464464
PathNotFound(ref path) =>
465-
write!(f, "Cannot find path {:?}", path),
465+
write!(f, "cannot find path {:?}", path),
466466
IncorrectAllocationInformation(size, size2, align, align2) =>
467467
write!(f, "incorrect alloc info: expected size {} and align {}, \
468468
got size {} and align {}",
@@ -525,7 +525,7 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
525525
InvalidBoolOp(_) =>
526526
write!(f, "invalid boolean operation"),
527527
UnterminatedCString(_) =>
528-
write!(f, "attempted to get length of a null terminated string, but no null \
528+
write!(f, "attempted to get length of a null-terminated string, but no null \
529529
found before end of allocation"),
530530
ReadUndefBytes(_) =>
531531
write!(f, "attempted to read undefined bytes"),

src/librustc/session/config.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ pub fn parse_error_format(
19981998
Some(arg) => early_error(
19991999
ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color)),
20002000
&format!(
2001-
"argument for --error-format must be `human`, `json` or \
2001+
"argument for `--error-format` must be `human`, `json` or \
20022002
`short` (instead was `{}`)",
20032003
arg
20042004
),
@@ -2037,7 +2037,7 @@ pub fn build_session_options_and_crate_config(
20372037
early_error(
20382038
ErrorOutputType::default(),
20392039
&format!(
2040-
"argument for --edition must be one of: \
2040+
"argument for `--edition` must be one of: \
20412041
{}. (instead was `{}`)",
20422042
EDITION_NAME_LIST,
20432043
arg
@@ -2051,7 +2051,7 @@ pub fn build_session_options_and_crate_config(
20512051
early_error(
20522052
ErrorOutputType::default(),
20532053
&format!(
2054-
"Edition {} is unstable and only \
2054+
"edition {} is unstable and only \
20552055
available for nightly builds of rustc.",
20562056
edition,
20572057
)
@@ -2075,14 +2075,14 @@ pub fn build_session_options_and_crate_config(
20752075
if let ErrorOutputType::Json { pretty: true, json_rendered } = error_format {
20762076
early_error(
20772077
ErrorOutputType::Json { pretty: false, json_rendered },
2078-
"--error-format=pretty-json is unstable",
2078+
"`--error-format=pretty-json` is unstable",
20792079
);
20802080
}
20812081
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(_)) =
20822082
error_format {
20832083
early_error(
20842084
ErrorOutputType::Json { pretty: false, json_rendered },
2085-
"--error-format=human-annotate-rs is unstable",
2085+
"`--error-format=human-annotate-rs` is unstable",
20862086
);
20872087
}
20882088
}
@@ -2132,8 +2132,8 @@ pub fn build_session_options_and_crate_config(
21322132
early_warn(
21332133
error_format,
21342134
&format!(
2135-
"--emit={} with -o incompatible with \
2136-
-C codegen-units=N for N > 1",
2135+
"`--emit={}` with `-o` incompatible with \
2136+
`-C codegen-units=N` for N > 1",
21372137
ot
21382138
),
21392139
);
@@ -2153,21 +2153,21 @@ pub fn build_session_options_and_crate_config(
21532153
if debugging_opts.threads == Some(0) {
21542154
early_error(
21552155
error_format,
2156-
"Value for threads must be a positive nonzero integer",
2156+
"value for threads must be a positive non-zero integer",
21572157
);
21582158
}
21592159

21602160
if debugging_opts.threads.unwrap_or(1) > 1 && debugging_opts.fuel.is_some() {
21612161
early_error(
21622162
error_format,
2163-
"Optimization fuel is incompatible with multiple threads",
2163+
"optimization fuel is incompatible with multiple threads",
21642164
);
21652165
}
21662166

21672167
if codegen_units == Some(0) {
21682168
early_error(
21692169
error_format,
2170-
"Value for codegen units must be a positive nonzero integer",
2170+
"value for codegen units must be a positive non-zero integer",
21712171
);
21722172
}
21732173

src/librustc/traits/object_safety.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl<'tcx> TyCtxt<'tcx> {
368368
match self.layout_of(param_env.and(ty)) {
369369
Ok(layout) => &layout.abi,
370370
Err(err) => bug!(
371-
"Error: {}\n while computing layout for type {:?}", err, ty
371+
"error: {}\n while computing layout for type {:?}", err, ty
372372
)
373373
}
374374
};
@@ -384,7 +384,7 @@ impl<'tcx> TyCtxt<'tcx> {
384384
self.sess.delay_span_bug(
385385
self.def_span(method.def_id),
386386
&format!(
387-
"Receiver when Self = () should have a Scalar ABI, found {:?}",
387+
"receiver when `Self = ()` should have a Scalar ABI; found {:?}",
388388
abi
389389
),
390390
);
@@ -406,7 +406,8 @@ impl<'tcx> TyCtxt<'tcx> {
406406
self.sess.delay_span_bug(
407407
self.def_span(method.def_id),
408408
&format!(
409-
"Receiver when Self = {} should have a ScalarPair ABI, found {:?}",
409+
"receiver when `Self = {}` should have a ScalarPair ABI; \
410+
found {:?}",
410411
trait_object_ty, abi
411412
),
412413
);

src/librustc_asan/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
44
use cmake::Config;
55

66
fn main() {
7+
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
8+
return;
9+
}
710
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
811
build_helper::restore_library_path();
912

src/librustc_errors/annotate_snippet_emitter_writer.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ pub struct AnnotateSnippetEmitterWriter {
3030
impl Emitter for AnnotateSnippetEmitterWriter {
3131
/// The entry point for the diagnostics generation
3232
fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) {
33-
let children = db.children.clone();
34-
let (primary_span, suggestions) = self.primary_span_formatted(&db);
33+
let mut children = db.children.clone();
34+
let (mut primary_span, suggestions) = self.primary_span_formatted(&db);
3535

36-
// FIXME(#59346): Add `fix_multispans_in_std_macros` function from emitter.rs
36+
self.fix_multispans_in_std_macros(&self.source_map,
37+
&mut primary_span,
38+
&mut children,
39+
&db.level,
40+
db.handler.flags.external_macro_backtrace);
3741

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

0 commit comments

Comments
 (0)