Skip to content

Commit afaf33d

Browse files
committed
Auto merge of #83573 - JohnTitor:rollup-28jnzsr, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #79399 (Use detailed and shorter fs error explaination) - #83348 (format macro argument parsing fix) - #83462 (ExitStatus: print "exit status: {}" rather than "exit code: {}" on unix) - #83526 (lazily calls some fns) - #83558 (Use DebugStruct::finish_non_exhaustive() in std.) - #83559 (Fix Debug implementation for RwLock{Read,Write}Guard.) - #83560 (Derive Debug for io::Chain instead of manually implementing it.) - #83561 (Improve Debug implementations of Mutex and RwLock.) - #83567 (Update rustup cross-compilation docs link) - #83569 (Add regression tests for #56445) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1010038 + 1ad7c52 commit afaf33d

File tree

32 files changed

+132
-61
lines changed

32 files changed

+132
-61
lines changed

compiler/rustc_errors/src/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl DiagnosticSpanLine {
493493
h_end: usize,
494494
) -> DiagnosticSpanLine {
495495
DiagnosticSpanLine {
496-
text: sf.get_line(index).map_or(String::new(), |l| l.into_owned()),
496+
text: sf.get_line(index).map_or_else(String::new, |l| l.into_owned()),
497497
highlight_start: h_start,
498498
highlight_end: h_end,
499499
}

compiler/rustc_middle/src/ty/instance.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ impl<'tcx> InstanceDef<'tcx> {
216216
// drops of `Option::None` before LTO. We also respect the intent of
217217
// `#[inline]` on `Drop::drop` implementations.
218218
return ty.ty_adt_def().map_or(true, |adt_def| {
219-
adt_def.destructor(tcx).map_or(adt_def.is_enum(), |dtor| {
220-
tcx.codegen_fn_attrs(dtor.did).requests_inline()
221-
})
219+
adt_def.destructor(tcx).map_or_else(
220+
|| adt_def.is_enum(),
221+
|dtor| tcx.codegen_fn_attrs(dtor.did).requests_inline(),
222+
)
222223
});
223224
}
224225
tcx.codegen_fn_attrs(self.def_id()).requests_inline()

compiler/rustc_middle/src/ty/query/on_disk_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl<'sess> OnDiskCache<'sess> {
525525
) {
526526
let mut current_diagnostics = self.current_diagnostics.borrow_mut();
527527

528-
let x = current_diagnostics.entry(dep_node_index).or_insert(Vec::new());
528+
let x = current_diagnostics.entry(dep_node_index).or_default();
529529

530530
x.extend(Into::<Vec<_>>::into(diagnostics));
531531
}

compiler/rustc_mir/src/borrow_check/diagnostics/outlives_suggestion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl OutlivesSuggestionBuilder {
157157
debug!("Collected {:?}: {:?}", fr, outlived_fr);
158158

159159
// Add to set of constraints for final help note.
160-
self.constraints_to_add.entry(fr).or_insert(Vec::new()).push(outlived_fr);
160+
self.constraints_to_add.entry(fr).or_default().push(outlived_fr);
161161
}
162162

163163
/// Emit an intermediate note on the given `Diagnostic` if the involved regions are

compiler/rustc_parse_format/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,13 @@ impl<'a> Iterator for Parser<'a> {
213213
Some(String(self.string(pos + 1)))
214214
} else {
215215
let arg = self.argument();
216-
if let Some(end) = self.must_consume('}') {
217-
let start = self.to_span_index(pos);
218-
let end = self.to_span_index(end + 1);
216+
if let Some(rbrace_byte_idx) = self.must_consume('}') {
217+
let lbrace_inner_offset = self.to_span_index(pos);
218+
let rbrace_inner_offset = self.to_span_index(rbrace_byte_idx);
219219
if self.is_literal {
220-
self.arg_places.push(start.to(end));
220+
self.arg_places.push(
221+
lbrace_inner_offset.to(InnerOffset(rbrace_inner_offset.0 + 1)),
222+
);
221223
}
222224
}
223225
Some(NextArgument(arg))

compiler/rustc_resolve/src/late.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
23272327

23282328
ExprKind::Call(ref callee, ref arguments) => {
23292329
self.resolve_expr(callee, Some(expr));
2330-
let const_args = self.r.legacy_const_generic_args(callee).unwrap_or(Vec::new());
2330+
let const_args = self.r.legacy_const_generic_args(callee).unwrap_or_default();
23312331
for (idx, argument) in arguments.iter().enumerate() {
23322332
// Constant arguments need to be treated as AnonConst since
23332333
// that is how they will be later lowered to HIR.

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
184184
PathResult::Module(ModuleOrUniformRoot::Module(module)) => module.res(),
185185
_ => None,
186186
}
187-
.map_or(String::new(), |res| format!("{} ", res.descr()));
187+
.map_or_else(String::new, |res| format!("{} ", res.descr()));
188188
(mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)))
189189
};
190190
(
@@ -1042,10 +1042,10 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
10421042
if let Some(span) = self.def_span(def_id) {
10431043
err.span_label(span, &format!("`{}` defined here", path_str));
10441044
}
1045-
let fields =
1046-
self.r.field_names.get(&def_id).map_or("/* fields */".to_string(), |fields| {
1047-
vec!["_"; fields.len()].join(", ")
1048-
});
1045+
let fields = self.r.field_names.get(&def_id).map_or_else(
1046+
|| "/* fields */".to_string(),
1047+
|fields| vec!["_"; fields.len()].join(", "),
1048+
);
10491049
err.span_suggestion(
10501050
span,
10511051
"use the tuple variant pattern syntax instead",

library/std/src/collections/hash/map.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
17931793
#[unstable(feature = "hash_raw_entry", issue = "56167")]
17941794
impl<K, V, S> Debug for RawEntryBuilderMut<'_, K, V, S> {
17951795
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1796-
f.debug_struct("RawEntryBuilder").finish()
1796+
f.debug_struct("RawEntryBuilder").finish_non_exhaustive()
17971797
}
17981798
}
17991799

@@ -1813,21 +1813,21 @@ impl<K: Debug, V: Debug, S> Debug for RawOccupiedEntryMut<'_, K, V, S> {
18131813
f.debug_struct("RawOccupiedEntryMut")
18141814
.field("key", self.key())
18151815
.field("value", self.get())
1816-
.finish()
1816+
.finish_non_exhaustive()
18171817
}
18181818
}
18191819

18201820
#[unstable(feature = "hash_raw_entry", issue = "56167")]
18211821
impl<K, V, S> Debug for RawVacantEntryMut<'_, K, V, S> {
18221822
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1823-
f.debug_struct("RawVacantEntryMut").finish()
1823+
f.debug_struct("RawVacantEntryMut").finish_non_exhaustive()
18241824
}
18251825
}
18261826

18271827
#[unstable(feature = "hash_raw_entry", issue = "56167")]
18281828
impl<K, V, S> Debug for RawEntryBuilder<'_, K, V, S> {
18291829
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1830-
f.debug_struct("RawEntryBuilder").finish()
1830+
f.debug_struct("RawEntryBuilder").finish_non_exhaustive()
18311831
}
18321832
}
18331833

@@ -1867,7 +1867,10 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
18671867
#[stable(feature = "debug_hash_map", since = "1.12.0")]
18681868
impl<K: Debug, V: Debug> Debug for OccupiedEntry<'_, K, V> {
18691869
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1870-
f.debug_struct("OccupiedEntry").field("key", self.key()).field("value", self.get()).finish()
1870+
f.debug_struct("OccupiedEntry")
1871+
.field("key", self.key())
1872+
.field("value", self.get())
1873+
.finish_non_exhaustive()
18711874
}
18721875
}
18731876

@@ -1903,7 +1906,7 @@ impl<K: Debug, V: Debug> Debug for OccupiedError<'_, K, V> {
19031906
.field("key", self.entry.key())
19041907
.field("old_value", self.entry.get())
19051908
.field("new_value", &self.value)
1906-
.finish()
1909+
.finish_non_exhaustive()
19071910
}
19081911
}
19091912

library/std/src/fs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ impl fmt::Debug for Metadata {
11541154
.field("modified", &self.modified())
11551155
.field("accessed", &self.accessed())
11561156
.field("created", &self.created())
1157-
.finish()
1157+
.finish_non_exhaustive()
11581158
}
11591159
}
11601160

@@ -1677,9 +1677,9 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()>
16771677
/// This function will return an error in the following situations, but is not
16781678
/// limited to just these cases:
16791679
///
1680-
/// * The `from` path is not a file.
1681-
/// * The `from` file does not exist.
1682-
/// * The current process does not have the permission rights to access
1680+
/// * `from` is neither a regular file nor a symlink to a regular file.
1681+
/// * `from` does not exist.
1682+
/// * The current process does not have the permission rights to read
16831683
/// `from` or write `to`.
16841684
///
16851685
/// # Examples

library/std/src/io/buffered/linewriter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,6 @@ where
227227
"buffer",
228228
&format_args!("{}/{}", self.inner.buffer().len(), self.inner.capacity()),
229229
)
230-
.finish()
230+
.finish_non_exhaustive()
231231
}
232232
}

0 commit comments

Comments
 (0)