Skip to content

Commit 074f636

Browse files
committed
Auto merge of rust-lang#89549 - Manishearth:rollup-mhkyc16, r=Manishearth
Rollup of 12 pull requests Successful merges: - rust-lang#87631 (os current_exe using same approach as linux to get always the full ab…) - rust-lang#88234 (rustdoc-json: Don't ignore impls for primitive types) - rust-lang#88651 (Use the 64b inner:monotonize() implementation not the 128b one for aarch64) - rust-lang#88816 (Rustdoc migrate to table so the gui can handle >2k constants) - rust-lang#89244 (refactor: VecDeques PairSlices fields to private) - rust-lang#89364 (rustdoc-json: Encode json files with UTF-8) - rust-lang#89423 (Fix ICE caused by non_exaustive_omitted_patterns struct lint) - rust-lang#89426 (bootstrap: add config option for nix patching) - rust-lang#89462 (haiku thread affinity build fix) - rust-lang#89482 (Follow the diagnostic output style guide) - rust-lang#89504 (Don't suggest replacing region with 'static in NLL) - rust-lang#89535 (fix busted JavaScript in error index generator) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a804c4b + 068683b commit 074f636

File tree

94 files changed

+229
-339
lines changed

Some content is hidden

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

94 files changed

+229
-339
lines changed

compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ impl OutlivesSuggestionBuilder {
171171
let outlived_fr_name = self.region_vid_to_name(mbcx, errci.outlived_fr);
172172

173173
if let (Some(fr_name), Some(outlived_fr_name)) = (fr_name, outlived_fr_name) {
174-
if let RegionNameSource::Static = outlived_fr_name.source {
175-
diag.help(&format!("consider replacing `{}` with `'static`", fr_name));
176-
} else {
174+
if !matches!(outlived_fr_name.source, RegionNameSource::Static) {
177175
diag.help(&format!(
178176
"consider adding the following bound: `{}: {}`",
179177
fr_name, outlived_fr_name

compiler/rustc_const_eval/src/transform/check_consts/ops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl NonConstOp for FnCallUnstable {
102102
);
103103

104104
if ccx.is_const_stable_const_fn() {
105-
err.help("Const-stable functions can only call other const-stable functions");
105+
err.help("const-stable functions can only call other const-stable functions");
106106
} else if ccx.tcx.sess.is_nightly_build() {
107107
if let Some(feature) = feature {
108108
err.help(&format!(

compiler/rustc_typeck/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Ab
5858
tcx.sess,
5959
span,
6060
E0781,
61-
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers."
61+
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers"
6262
)
6363
.emit()
6464
}

compiler/rustc_typeck/src/check/pat.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
181181
self.check_pat_tuple_struct(pat, qpath, subpats, ddpos, expected, def_bm, ti)
182182
}
183183
PatKind::Path(_) => self.check_pat_path(pat, path_res.unwrap(), expected, ti),
184-
PatKind::Struct(ref qpath, fields, etc) => {
185-
self.check_pat_struct(pat, qpath, fields, etc, expected, def_bm, ti)
184+
PatKind::Struct(ref qpath, fields, has_rest_pat) => {
185+
self.check_pat_struct(pat, qpath, fields, has_rest_pat, expected, def_bm, ti)
186186
}
187187
PatKind::Or(pats) => {
188188
let parent_pat = Some(pat);
@@ -712,7 +712,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
712712
pat: &'tcx Pat<'tcx>,
713713
qpath: &hir::QPath<'_>,
714714
fields: &'tcx [hir::PatField<'tcx>],
715-
etc: bool,
715+
has_rest_pat: bool,
716716
expected: Ty<'tcx>,
717717
def_bm: BindingMode,
718718
ti: TopInfo<'tcx>,
@@ -734,7 +734,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
734734
self.demand_eqtype_pat(pat.span, expected, pat_ty, ti);
735735

736736
// Type-check subpatterns.
737-
if self.check_struct_pat_fields(pat_ty, pat, variant, fields, etc, def_bm, ti) {
737+
if self.check_struct_pat_fields(pat_ty, &pat, variant, fields, has_rest_pat, def_bm, ti) {
738738
pat_ty
739739
} else {
740740
self.tcx.ty_error()
@@ -1216,7 +1216,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12161216
pat: &'tcx Pat<'tcx>,
12171217
variant: &'tcx ty::VariantDef,
12181218
fields: &'tcx [hir::PatField<'tcx>],
1219-
etc: bool,
1219+
has_rest_pat: bool,
12201220
def_bm: BindingMode,
12211221
ti: TopInfo<'tcx>,
12221222
) -> bool {
@@ -1290,7 +1290,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12901290

12911291
// Require `..` if struct has non_exhaustive attribute.
12921292
let non_exhaustive = variant.is_field_list_non_exhaustive() && !adt.did.is_local();
1293-
if non_exhaustive && !etc {
1293+
if non_exhaustive && !has_rest_pat {
12941294
self.error_foreign_non_exhaustive_spat(pat, adt.variant_descr(), fields.is_empty());
12951295
}
12961296

@@ -1302,7 +1302,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13021302
.struct_span_err(pat.span, "union patterns should have exactly one field")
13031303
.emit();
13041304
}
1305-
if etc {
1305+
if has_rest_pat {
13061306
tcx.sess.struct_span_err(pat.span, "`..` cannot be used in union patterns").emit();
13071307
}
13081308
} else if !unmentioned_fields.is_empty() {
@@ -1313,9 +1313,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13131313
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
13141314
})
13151315
.collect();
1316-
if non_exhaustive {
1317-
self.non_exhaustive_reachable_pattern(pat, &accessible_unmentioned_fields, adt_ty)
1318-
} else if !etc {
1316+
1317+
if !has_rest_pat {
13191318
if accessible_unmentioned_fields.is_empty() {
13201319
unmentioned_err = Some(self.error_no_accessible_fields(pat, fields));
13211320
} else {
@@ -1326,6 +1325,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13261325
fields,
13271326
));
13281327
}
1328+
} else if non_exhaustive && !accessible_unmentioned_fields.is_empty() {
1329+
self.lint_non_exhaustive_omitted_patterns(
1330+
pat,
1331+
&accessible_unmentioned_fields,
1332+
adt_ty,
1333+
)
13291334
}
13301335
}
13311336
match (inexistent_fields_err, unmentioned_err) {
@@ -1653,7 +1658,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16531658
/// is not exhaustive enough.
16541659
///
16551660
/// Nb: the partner lint for enums lives in `compiler/rustc_mir_build/src/thir/pattern/usefulness.rs`.
1656-
fn non_exhaustive_reachable_pattern(
1661+
fn lint_non_exhaustive_omitted_patterns(
16571662
&self,
16581663
pat: &Pat<'_>,
16591664
unmentioned_fields: &[(&ty::FieldDef, Ident)],

config.toml.example

+6
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ changelog-seen = 2
313313
# this setting's very existence, are all subject to change.)
314314
#print-step-rusage = false
315315

316+
# Always patch binaries for usage with Nix toolchains. If `true` then binaries
317+
# will be patched unconditionally. If `false` or unset, binaries will be patched
318+
# only if the current distribution is NixOS. This option is useful when using
319+
# a Nix toolchain on non-NixOS distributions.
320+
#patch-binaries-for-nix = false
321+
316322
# =============================================================================
317323
# General install configuration options
318324
# =============================================================================

library/alloc/src/collections/vec_deque/pair_slices.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ use super::VecDeque;
2020
///
2121
/// and the uneven remainder of either A or B is skipped.
2222
pub struct PairSlices<'a, 'b, T> {
23-
pub(crate) a0: &'a mut [T],
24-
pub(crate) a1: &'a mut [T],
25-
pub(crate) b0: &'b [T],
26-
pub(crate) b1: &'b [T],
23+
a0: &'a mut [T],
24+
a1: &'a mut [T],
25+
b0: &'b [T],
26+
b1: &'b [T],
2727
}
2828

2929
impl<'a, 'b, T> PairSlices<'a, 'b, T> {

library/std/src/sys/unix/os.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -380,20 +380,24 @@ pub fn current_exe() -> io::Result<PathBuf> {
380380

381381
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
382382
pub fn current_exe() -> io::Result<PathBuf> {
383-
extern "C" {
384-
fn getexecname() -> *const c_char;
385-
}
386-
unsafe {
387-
let path = getexecname();
388-
if path.is_null() {
389-
Err(io::Error::last_os_error())
390-
} else {
391-
let filename = CStr::from_ptr(path).to_bytes();
392-
let path = PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename));
383+
if let Ok(path) = crate::fs::read_link("/proc/self/path/a.out") {
384+
Ok(path)
385+
} else {
386+
extern "C" {
387+
fn getexecname() -> *const c_char;
388+
}
389+
unsafe {
390+
let path = getexecname();
391+
if path.is_null() {
392+
Err(io::Error::last_os_error())
393+
} else {
394+
let filename = CStr::from_ptr(path).to_bytes();
395+
let path = PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename));
393396

394-
// Prepend a current working directory to the path if
395-
// it doesn't contain an absolute pathname.
396-
if filename[0] == b'/' { Ok(path) } else { getcwd().map(|cwd| cwd.join(path)) }
397+
// Prepend a current working directory to the path if
398+
// it doesn't contain an absolute pathname.
399+
if filename[0] == b'/' { Ok(path) } else { getcwd().map(|cwd| cwd.join(path)) }
400+
}
397401
}
398402
}
399403
}

library/std/src/sys/unix/thread.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,18 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {
339339

340340
Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
341341
} else if #[cfg(target_os = "haiku")] {
342-
let mut sinfo: libc::system_info = crate::mem::zeroed();
343-
let res = libc::get_system_info(&mut sinfo);
342+
// system_info cpu_count field gets the static data set at boot time with `smp_set_num_cpus`
343+
// `get_system_info` calls then `smp_get_num_cpus`
344+
unsafe {
345+
let mut sinfo: libc::system_info = crate::mem::zeroed();
346+
let res = libc::get_system_info(&mut sinfo);
344347

345-
if res != libc::B_OK {
346-
return Err(io::Error::last_os_error());
347-
}
348+
if res != libc::B_OK {
349+
return Err(io::Error::new_const(io::ErrorKind::NotFound, &"The number of hardware threads is not known for the target platform"));
350+
}
348351

349-
Ok(unsafe { NonZeroUsize::new_unchecked(sinfo.cpu_count as usize) })
352+
Ok(NonZeroUsize::new_unchecked(sinfo.cpu_count as usize))
353+
}
350354
} else {
351355
// FIXME: implement on vxWorks, Redox, l4re
352356
Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform"))

library/std/src/time/monotonic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub(super) fn monotonize(raw: time::Instant) -> time::Instant {
55
inner::monotonize(raw)
66
}
77

8-
#[cfg(all(target_has_atomic = "64", not(target_has_atomic = "128")))]
8+
#[cfg(any(all(target_has_atomic = "64", not(target_has_atomic = "128")), target_arch = "aarch64"))]
99
pub mod inner {
1010
use crate::sync::atomic::AtomicU64;
1111
use crate::sync::atomic::Ordering::*;
@@ -71,7 +71,7 @@ pub mod inner {
7171
}
7272
}
7373

74-
#[cfg(target_has_atomic = "128")]
74+
#[cfg(all(target_has_atomic = "128", not(target_arch = "aarch64")))]
7575
pub mod inner {
7676
use crate::sync::atomic::AtomicU128;
7777
use crate::sync::atomic::Ordering::*;

src/bootstrap/bootstrap.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -594,19 +594,23 @@ def fix_bin_or_dylib(self, fname):
594594
if ostype != "Linux":
595595
return
596596

597-
# Use `/etc/os-release` instead of `/etc/NIXOS`.
598-
# The latter one does not exist on NixOS when using tmpfs as root.
599-
try:
600-
with open("/etc/os-release", "r") as f:
601-
if not any(line.strip() == "ID=nixos" for line in f):
602-
return
603-
except FileNotFoundError:
604-
return
605-
if os.path.exists("/lib"):
606-
return
597+
# If the user has asked binaries to be patched for Nix, then
598+
# don't check for NixOS or `/lib`, just continue to the patching.
599+
if self.get_toml('patch-binaries-for-nix', 'build') != 'true':
600+
# Use `/etc/os-release` instead of `/etc/NIXOS`.
601+
# The latter one does not exist on NixOS when using tmpfs as root.
602+
try:
603+
with open("/etc/os-release", "r") as f:
604+
if not any(line.strip() == "ID=nixos" for line in f):
605+
return
606+
except FileNotFoundError:
607+
return
608+
if os.path.exists("/lib"):
609+
return
607610

608-
# At this point we're pretty sure the user is running NixOS
609-
nix_os_msg = "info: you seem to be running NixOS. Attempting to patch"
611+
# At this point we're pretty sure the user is running NixOS or
612+
# using Nix
613+
nix_os_msg = "info: you seem to be using Nix. Attempting to patch"
610614
print(nix_os_msg, fname)
611615

612616
# Only build `.nix-deps` once.

src/bootstrap/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ struct Build {
397397
install_stage: Option<u32>,
398398
dist_stage: Option<u32>,
399399
bench_stage: Option<u32>,
400+
patch_binaries_for_nix: Option<bool>,
400401
}
401402

402403
/// TOML representation of various global install decisions.

src/etc/check_missing_items.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
import json
1111

12-
crate = json.load(open(sys.argv[1]))
12+
crate = json.load(open(sys.argv[1], encoding="utf-8"))
1313

1414

1515
def get_local_item(item_id):

src/librustdoc/html/render/print_item.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ use crate::html::markdown::MarkdownSummaryLine;
3434

3535
const ITEM_TABLE_OPEN: &'static str = "<div class=\"item-table\">";
3636
const ITEM_TABLE_CLOSE: &'static str = "</div>";
37+
const ITEM_TABLE_ROW_OPEN: &'static str = "<div class=\"item-row\">";
38+
const ITEM_TABLE_ROW_CLOSE: &'static str = "</div>";
3739

3840
pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, page: &Page<'_>) {
3941
debug_assert!(!item.is_stripped());
@@ -256,9 +258,6 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
256258

257259
debug!("{:?}", indices);
258260
let mut curty = None;
259-
// See: https://github.com/rust-lang/rust/issues/88545
260-
let item_table_block_size = 900usize;
261-
let mut item_table_nth_element = 0usize;
262261

263262
for &idx in &indices {
264263
let myitem = &items[idx];
@@ -285,13 +284,13 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
285284
id = cx.derive_id(short.to_owned()),
286285
name = name
287286
);
288-
item_table_nth_element = 0;
289287
}
290288

291289
match *myitem.kind {
292290
clean::ExternCrateItem { ref src } => {
293291
use crate::html::format::anchor;
294292

293+
w.write_str(ITEM_TABLE_ROW_OPEN);
295294
match *src {
296295
Some(ref src) => write!(
297296
w,
@@ -312,6 +311,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
312311
),
313312
}
314313
w.write_str("</code></div>");
314+
w.write_str(ITEM_TABLE_ROW_CLOSE);
315315
}
316316

317317
clean::ImportItem(ref import) => {
@@ -336,6 +336,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
336336

337337
let add = if stab.is_some() { " " } else { "" };
338338

339+
w.write_str(ITEM_TABLE_ROW_OPEN);
339340
write!(
340341
w,
341342
"<div class=\"item-left {stab}{add}import-item\">\
@@ -348,6 +349,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
348349
imp = import.print(cx),
349350
stab_tags = stab_tags.unwrap_or_default(),
350351
);
352+
w.write_str(ITEM_TABLE_ROW_CLOSE);
351353
}
352354

353355
_ => {
@@ -368,6 +370,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
368370
let add = if stab.is_some() { " " } else { "" };
369371

370372
let doc_value = myitem.doc_value().unwrap_or_default();
373+
w.write_str(ITEM_TABLE_ROW_OPEN);
371374
write!(
372375
w,
373376
"<div class=\"item-left {stab}{add}module-item\">\
@@ -390,15 +393,9 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
390393
.collect::<Vec<_>>()
391394
.join(" "),
392395
);
396+
w.write_str(ITEM_TABLE_ROW_CLOSE);
393397
}
394398
}
395-
396-
item_table_nth_element += 1;
397-
if item_table_nth_element > item_table_block_size {
398-
w.write_str(ITEM_TABLE_CLOSE);
399-
w.write_str(ITEM_TABLE_OPEN);
400-
item_table_nth_element = 0;
401-
}
402399
}
403400

404401
if curty.is_some() {

0 commit comments

Comments
 (0)