Skip to content

Commit f9b1614

Browse files
committed
Auto merge of #124170 - matthiaskrgr:rollup-ldopl64, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #123571 (Correctly change type when adding adjustments on top of `NeverToAny`) - #123729 (run-make: refactor out command wrappers for `clang` and `llvm-readobj`) - #124106 (Don't repeatedly duplicate TAIT lifetimes for each subsequently nested TAIT) - #124149 (rustdoc-search: fix description on aliases in results) - #124155 (bootstrap: don't use rayon for sysinfo) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ce3263e + f1e536d commit f9b1614

File tree

17 files changed

+347
-122
lines changed

17 files changed

+347
-122
lines changed

compiler/rustc_hir_analysis/src/collect/generics_of.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,19 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
195195
}
196196
Some(fn_def_id.to_def_id())
197197
}
198-
ItemKind::OpaqueTy(hir::OpaqueTy {
199-
origin: hir::OpaqueTyOrigin::TyAlias { .. },
198+
ItemKind::OpaqueTy(&hir::OpaqueTy {
199+
origin: hir::OpaqueTyOrigin::TyAlias { parent, in_assoc_ty },
200200
..
201201
}) => {
202-
let parent_id = tcx.hir().get_parent_item(hir_id);
203-
assert_ne!(parent_id, hir::CRATE_OWNER_ID);
204-
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent_id);
202+
if in_assoc_ty {
203+
assert!(matches!(tcx.def_kind(parent), DefKind::AssocTy));
204+
} else {
205+
assert!(matches!(tcx.def_kind(parent), DefKind::TyAlias));
206+
}
207+
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent);
205208
// Opaque types are always nested within another item, and
206209
// inherit the generics of the item.
207-
Some(parent_id.to_def_id())
210+
Some(parent.to_def_id())
208211
}
209212
_ => None,
210213
},

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+23-10
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
279279
}
280280
Entry::Occupied(mut entry) => {
281281
debug!(" - composing on top of {:?}", entry.get());
282-
match (&entry.get()[..], &adj[..]) {
283-
// Applying any adjustment on top of a NeverToAny
284-
// is a valid NeverToAny adjustment, because it can't
285-
// be reached.
286-
(&[Adjustment { kind: Adjust::NeverToAny, .. }], _) => return,
282+
match (&mut entry.get_mut()[..], &adj[..]) {
287283
(
288-
&[
284+
[Adjustment { kind: Adjust::NeverToAny, target }],
285+
&[.., Adjustment { target: new_target, .. }],
286+
) => {
287+
// NeverToAny coercion can target any type, so instead of adding a new
288+
// adjustment on top we can change the target.
289+
//
290+
// This is required for things like `a == a` (where `a: !`) to produce
291+
// valid MIR -- we need borrow adjustment from things like `==` to change
292+
// the type to `&!` (or `&()` depending on the fallback). This might be
293+
// relevant even in unreachable code.
294+
*target = new_target;
295+
}
296+
297+
(
298+
&mut [
289299
Adjustment { kind: Adjust::Deref(_), .. },
290300
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. },
291301
],
@@ -294,11 +304,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
294304
.., // Any following adjustments are allowed.
295305
],
296306
) => {
297-
// A reborrow has no effect before a dereference.
307+
// A reborrow has no effect before a dereference, so we can safely replace adjustments.
308+
*entry.get_mut() = adj;
298309
}
299-
// FIXME: currently we never try to compose autoderefs
300-
// and ReifyFnPointer/UnsafeFnPointer, but we could.
310+
301311
_ => {
312+
// FIXME: currently we never try to compose autoderefs
313+
// and ReifyFnPointer/UnsafeFnPointer, but we could.
302314
self.dcx().span_delayed_bug(
303315
expr.span,
304316
format!(
@@ -308,9 +320,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
308320
adj
309321
),
310322
);
323+
324+
*entry.get_mut() = adj;
311325
}
312326
}
313-
*entry.get_mut() = adj;
314327
}
315328
}
316329

src/bootstrap/Cargo.lock

-27
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,6 @@ dependencies = [
236236
"crypto-common",
237237
]
238238

239-
[[package]]
240-
name = "either"
241-
version = "1.9.0"
242-
source = "registry+https://github.com/rust-lang/crates.io-index"
243-
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
244-
245239
[[package]]
246240
name = "errno"
247241
version = "0.3.8"
@@ -448,26 +442,6 @@ dependencies = [
448442
"proc-macro2",
449443
]
450444

451-
[[package]]
452-
name = "rayon"
453-
version = "1.8.0"
454-
source = "registry+https://github.com/rust-lang/crates.io-index"
455-
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
456-
dependencies = [
457-
"either",
458-
"rayon-core",
459-
]
460-
461-
[[package]]
462-
name = "rayon-core"
463-
version = "1.12.0"
464-
source = "registry+https://github.com/rust-lang/crates.io-index"
465-
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
466-
dependencies = [
467-
"crossbeam-deque",
468-
"crossbeam-utils",
469-
]
470-
471445
[[package]]
472446
name = "redox_syscall"
473447
version = "0.4.1"
@@ -598,7 +572,6 @@ dependencies = [
598572
"libc",
599573
"ntapi",
600574
"once_cell",
601-
"rayon",
602575
"windows",
603576
]
604577

src/bootstrap/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ walkdir = "2.4"
6464
xz2 = "0.1"
6565

6666
# Dependencies needed by the build-metrics feature
67-
sysinfo = { version = "0.30", optional = true }
67+
sysinfo = { version = "0.30", default-features = false, optional = true }
6868

6969
[target.'cfg(windows)'.dependencies.junction]
7070
version = "1.0.0"

src/librustdoc/html/static/js/search.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -1464,16 +1464,7 @@ function initSearch(rawSearchIndex) {
14641464
return 0;
14651465
});
14661466

1467-
const transformed = transformResults(result_list);
1468-
const descs = await Promise.all(transformed.map(result => {
1469-
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
1470-
"" :
1471-
searchState.loadDesc(result);
1472-
}));
1473-
for (const [i, result] of transformed.entries()) {
1474-
result.desc = descs[i];
1475-
}
1476-
return transformed;
1467+
return transformResults(result_list);
14771468
}
14781469

14791470
/**
@@ -2517,6 +2508,16 @@ function initSearch(rawSearchIndex) {
25172508
sorted_others,
25182509
parsedQuery);
25192510
handleAliases(ret, parsedQuery.original.replace(/"/g, ""), filterCrates, currentCrate);
2511+
await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => {
2512+
const descs = await Promise.all(list.map(result => {
2513+
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
2514+
"" :
2515+
searchState.loadDesc(result);
2516+
}));
2517+
for (const [i, result] of list.entries()) {
2518+
result.desc = descs[i];
2519+
}
2520+
}));
25202521
if (parsedQuery.error !== null && ret.others.length !== 0) {
25212522
// It means some doc aliases were found so let's "remove" the error!
25222523
ret.query.error = null;
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
use std::env;
2+
use std::path::Path;
3+
use std::process::Command;
4+
5+
use crate::{bin_name, handle_failed_output, tmp_dir};
6+
7+
/// Construct a new `clang` invocation. `clang` is not always available for all targets.
8+
pub fn clang() -> Clang {
9+
Clang::new()
10+
}
11+
12+
/// A `clang` invocation builder.
13+
#[derive(Debug)]
14+
pub struct Clang {
15+
cmd: Command,
16+
}
17+
18+
crate::impl_common_helpers!(Clang);
19+
20+
impl Clang {
21+
/// Construct a new `clang` invocation. `clang` is not always available for all targets.
22+
pub fn new() -> Self {
23+
let clang =
24+
env::var("CLANG").expect("`CLANG` not specified, but this is required to find `clang`");
25+
let cmd = Command::new(clang);
26+
Self { cmd }
27+
}
28+
29+
/// Provide an input file.
30+
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
31+
self.cmd.arg(path.as_ref());
32+
self
33+
}
34+
35+
/// Specify the name of the executable. The executable will be placed under `$TMPDIR`, and the
36+
/// extension will be determined by [`bin_name`].
37+
pub fn out_exe(&mut self, name: &str) -> &mut Self {
38+
self.cmd.arg("-o");
39+
self.cmd.arg(tmp_dir().join(bin_name(name)));
40+
self
41+
}
42+
43+
/// Specify which target triple clang should target.
44+
pub fn target(&mut self, target_triple: &str) -> &mut Self {
45+
self.cmd.arg("-target");
46+
self.cmd.arg(target_triple);
47+
self
48+
}
49+
50+
/// Pass `-nostdlib` to disable linking the C standard library.
51+
pub fn no_stdlib(&mut self) -> &mut Self {
52+
self.cmd.arg("-nostdlib");
53+
self
54+
}
55+
56+
/// Specify architecture.
57+
pub fn arch(&mut self, arch: &str) -> &mut Self {
58+
self.cmd.arg(format!("-march={arch}"));
59+
self
60+
}
61+
62+
/// Specify LTO settings.
63+
pub fn lto(&mut self, lto: &str) -> &mut Self {
64+
self.cmd.arg(format!("-flto={lto}"));
65+
self
66+
}
67+
68+
/// Specify which ld to use.
69+
pub fn use_ld(&mut self, ld: &str) -> &mut Self {
70+
self.cmd.arg(format!("-fuse-ld={ld}"));
71+
self
72+
}
73+
}

src/tools/run-make-support/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! as `object` or `wasmparser`, they can be re-exported and be made available through this library.
55
66
pub mod cc;
7+
pub mod clang;
8+
pub mod llvm_readobj;
79
pub mod run;
810
pub mod rustc;
911
pub mod rustdoc;
@@ -17,6 +19,8 @@ pub use regex;
1719
pub use wasmparser;
1820

1921
pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
22+
pub use clang::{clang, Clang};
23+
pub use llvm_readobj::{llvm_readobj, LlvmReadobj};
2024
pub use run::{run, run_fail};
2125
pub use rustc::{aux_build, rustc, Rustc};
2226
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
use std::env;
2+
use std::path::{Path, PathBuf};
3+
use std::process::Command;
4+
5+
use crate::handle_failed_output;
6+
7+
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
8+
/// at `$LLVM_BIN_DIR/llvm-readobj`.
9+
pub fn llvm_readobj() -> LlvmReadobj {
10+
LlvmReadobj::new()
11+
}
12+
13+
/// A `llvm-readobj` invocation builder.
14+
#[derive(Debug)]
15+
pub struct LlvmReadobj {
16+
cmd: Command,
17+
}
18+
19+
crate::impl_common_helpers!(LlvmReadobj);
20+
21+
impl LlvmReadobj {
22+
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
23+
/// at `$LLVM_BIN_DIR/llvm-readobj`.
24+
pub fn new() -> Self {
25+
let llvm_bin_dir = env::var("LLVM_BIN_DIR")
26+
.expect("`LLVM_BIN_DIR` not specified, but this is required to find `llvm-readobj`");
27+
let llvm_bin_dir = PathBuf::from(llvm_bin_dir);
28+
let llvm_readobj = llvm_bin_dir.join("llvm-readobj");
29+
let cmd = Command::new(llvm_readobj);
30+
Self { cmd }
31+
}
32+
33+
/// Provide an input file.
34+
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
35+
self.cmd.arg(path.as_ref());
36+
self
37+
}
38+
39+
/// Pass `--file-header` to display file headers.
40+
pub fn file_header(&mut self) -> &mut Self {
41+
self.cmd.arg("--file-header");
42+
self
43+
}
44+
}

tests/crashes/120600-2.rs

-13
This file was deleted.

tests/crashes/120600.rs

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// MIR for `_f` after built
2+
3+
fn _f(_1: !, _2: !) -> () {
4+
debug a => _1;
5+
debug b => _2;
6+
let mut _0: ();
7+
let mut _3: !;
8+
let _4: bool;
9+
let mut _5: &();
10+
let mut _6: !;
11+
let mut _7: &();
12+
let _8: ();
13+
let mut _9: !;
14+
15+
bb0: {
16+
StorageLive(_4);
17+
StorageLive(_5);
18+
StorageLive(_6);
19+
_6 = _1;
20+
unreachable;
21+
}
22+
23+
bb1: {
24+
StorageDead(_6);
25+
StorageLive(_7);
26+
StorageLive(_8);
27+
StorageLive(_9);
28+
_9 = _2;
29+
unreachable;
30+
}
31+
32+
bb2: {
33+
_7 = &_8;
34+
StorageDead(_9);
35+
_4 = <() as PartialEq>::eq(move _5, move _7) -> [return: bb3, unwind: bb5];
36+
}
37+
38+
bb3: {
39+
StorageDead(_7);
40+
StorageDead(_5);
41+
StorageDead(_8);
42+
StorageDead(_4);
43+
unreachable;
44+
}
45+
46+
bb4: {
47+
return;
48+
}
49+
50+
bb5 (cleanup): {
51+
resume;
52+
}
53+
}

0 commit comments

Comments
 (0)