Skip to content

Commit

Permalink
Auto merge of #124170 - matthiaskrgr:rollup-ldopl64, r=matthiaskrgr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 19, 2024
2 parents ce3263e + f1e536d commit f9b1614
Show file tree
Hide file tree
Showing 17 changed files with 347 additions and 122 deletions.
15 changes: 9 additions & 6 deletions compiler/rustc_hir_analysis/src/collect/generics_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,19 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
}
Some(fn_def_id.to_def_id())
}
ItemKind::OpaqueTy(hir::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias { .. },
ItemKind::OpaqueTy(&hir::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias { parent, in_assoc_ty },
..
}) => {
let parent_id = tcx.hir().get_parent_item(hir_id);
assert_ne!(parent_id, hir::CRATE_OWNER_ID);
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent_id);
if in_assoc_ty {
assert!(matches!(tcx.def_kind(parent), DefKind::AssocTy));
} else {
assert!(matches!(tcx.def_kind(parent), DefKind::TyAlias));
}
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent);
// Opaque types are always nested within another item, and
// inherit the generics of the item.
Some(parent_id.to_def_id())
Some(parent.to_def_id())
}
_ => None,
},
Expand Down
33 changes: 23 additions & 10 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
Entry::Occupied(mut entry) => {
debug!(" - composing on top of {:?}", entry.get());
match (&entry.get()[..], &adj[..]) {
// Applying any adjustment on top of a NeverToAny
// is a valid NeverToAny adjustment, because it can't
// be reached.
(&[Adjustment { kind: Adjust::NeverToAny, .. }], _) => return,
match (&mut entry.get_mut()[..], &adj[..]) {
(
&[
[Adjustment { kind: Adjust::NeverToAny, target }],
&[.., Adjustment { target: new_target, .. }],
) => {
// NeverToAny coercion can target any type, so instead of adding a new
// adjustment on top we can change the target.
//
// This is required for things like `a == a` (where `a: !`) to produce
// valid MIR -- we need borrow adjustment from things like `==` to change
// the type to `&!` (or `&()` depending on the fallback). This might be
// relevant even in unreachable code.
*target = new_target;
}

(
&mut [
Adjustment { kind: Adjust::Deref(_), .. },
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(..)), .. },
],
Expand All @@ -294,11 +304,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.., // Any following adjustments are allowed.
],
) => {
// A reborrow has no effect before a dereference.
// A reborrow has no effect before a dereference, so we can safely replace adjustments.
*entry.get_mut() = adj;
}
// FIXME: currently we never try to compose autoderefs
// and ReifyFnPointer/UnsafeFnPointer, but we could.

_ => {
// FIXME: currently we never try to compose autoderefs
// and ReifyFnPointer/UnsafeFnPointer, but we could.
self.dcx().span_delayed_bug(
expr.span,
format!(
Expand All @@ -308,9 +320,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
adj
),
);

*entry.get_mut() = adj;
}
}
*entry.get_mut() = adj;
}
}

Expand Down
27 changes: 0 additions & 27 deletions src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,6 @@ dependencies = [
"crypto-common",
]

[[package]]
name = "either"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"

[[package]]
name = "errno"
version = "0.3.8"
Expand Down Expand Up @@ -448,26 +442,6 @@ dependencies = [
"proc-macro2",
]

[[package]]
name = "rayon"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
dependencies = [
"either",
"rayon-core",
]

[[package]]
name = "rayon-core"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]

[[package]]
name = "redox_syscall"
version = "0.4.1"
Expand Down Expand Up @@ -598,7 +572,6 @@ dependencies = [
"libc",
"ntapi",
"once_cell",
"rayon",
"windows",
]

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ walkdir = "2.4"
xz2 = "0.1"

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

[target.'cfg(windows)'.dependencies.junction]
version = "1.0.0"
Expand Down
21 changes: 11 additions & 10 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -1464,16 +1464,7 @@ function initSearch(rawSearchIndex) {
return 0;
});

const transformed = transformResults(result_list);
const descs = await Promise.all(transformed.map(result => {
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
"" :
searchState.loadDesc(result);
}));
for (const [i, result] of transformed.entries()) {
result.desc = descs[i];
}
return transformed;
return transformResults(result_list);
}

/**
Expand Down Expand Up @@ -2517,6 +2508,16 @@ function initSearch(rawSearchIndex) {
sorted_others,
parsedQuery);
handleAliases(ret, parsedQuery.original.replace(/"/g, ""), filterCrates, currentCrate);
await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => {
const descs = await Promise.all(list.map(result => {
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
"" :
searchState.loadDesc(result);
}));
for (const [i, result] of list.entries()) {
result.desc = descs[i];
}
}));
if (parsedQuery.error !== null && ret.others.length !== 0) {
// It means some doc aliases were found so let's "remove" the error!
ret.query.error = null;
Expand Down
73 changes: 73 additions & 0 deletions src/tools/run-make-support/src/clang.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use std::env;
use std::path::Path;
use std::process::Command;

use crate::{bin_name, handle_failed_output, tmp_dir};

/// Construct a new `clang` invocation. `clang` is not always available for all targets.
pub fn clang() -> Clang {
Clang::new()
}

/// A `clang` invocation builder.
#[derive(Debug)]
pub struct Clang {
cmd: Command,
}

crate::impl_common_helpers!(Clang);

impl Clang {
/// Construct a new `clang` invocation. `clang` is not always available for all targets.
pub fn new() -> Self {
let clang =
env::var("CLANG").expect("`CLANG` not specified, but this is required to find `clang`");
let cmd = Command::new(clang);
Self { cmd }
}

/// Provide an input file.
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());
self
}

/// Specify the name of the executable. The executable will be placed under `$TMPDIR`, and the
/// extension will be determined by [`bin_name`].
pub fn out_exe(&mut self, name: &str) -> &mut Self {
self.cmd.arg("-o");
self.cmd.arg(tmp_dir().join(bin_name(name)));
self
}

/// Specify which target triple clang should target.
pub fn target(&mut self, target_triple: &str) -> &mut Self {
self.cmd.arg("-target");
self.cmd.arg(target_triple);
self
}

/// Pass `-nostdlib` to disable linking the C standard library.
pub fn no_stdlib(&mut self) -> &mut Self {
self.cmd.arg("-nostdlib");
self
}

/// Specify architecture.
pub fn arch(&mut self, arch: &str) -> &mut Self {
self.cmd.arg(format!("-march={arch}"));
self
}

/// Specify LTO settings.
pub fn lto(&mut self, lto: &str) -> &mut Self {
self.cmd.arg(format!("-flto={lto}"));
self
}

/// Specify which ld to use.
pub fn use_ld(&mut self, ld: &str) -> &mut Self {
self.cmd.arg(format!("-fuse-ld={ld}"));
self
}
}
4 changes: 4 additions & 0 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! as `object` or `wasmparser`, they can be re-exported and be made available through this library.

pub mod cc;
pub mod clang;
pub mod llvm_readobj;
pub mod run;
pub mod rustc;
pub mod rustdoc;
Expand All @@ -17,6 +19,8 @@ pub use regex;
pub use wasmparser;

pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
pub use clang::{clang, Clang};
pub use llvm_readobj::{llvm_readobj, LlvmReadobj};
pub use run::{run, run_fail};
pub use rustc::{aux_build, rustc, Rustc};
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
Expand Down
44 changes: 44 additions & 0 deletions src/tools/run-make-support/src/llvm_readobj.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;

use crate::handle_failed_output;

/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
/// at `$LLVM_BIN_DIR/llvm-readobj`.
pub fn llvm_readobj() -> LlvmReadobj {
LlvmReadobj::new()
}

/// A `llvm-readobj` invocation builder.
#[derive(Debug)]
pub struct LlvmReadobj {
cmd: Command,
}

crate::impl_common_helpers!(LlvmReadobj);

impl LlvmReadobj {
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
/// at `$LLVM_BIN_DIR/llvm-readobj`.
pub fn new() -> Self {
let llvm_bin_dir = env::var("LLVM_BIN_DIR")
.expect("`LLVM_BIN_DIR` not specified, but this is required to find `llvm-readobj`");
let llvm_bin_dir = PathBuf::from(llvm_bin_dir);
let llvm_readobj = llvm_bin_dir.join("llvm-readobj");
let cmd = Command::new(llvm_readobj);
Self { cmd }
}

/// Provide an input file.
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());
self
}

/// Pass `--file-header` to display file headers.
pub fn file_header(&mut self) -> &mut Self {
self.cmd.arg("--file-header");
self
}
}
13 changes: 0 additions & 13 deletions tests/crashes/120600-2.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/crashes/120600.rs

This file was deleted.

53 changes: 53 additions & 0 deletions tests/mir-opt/building/eq_never_type._f.built.after.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// MIR for `_f` after built

fn _f(_1: !, _2: !) -> () {
debug a => _1;
debug b => _2;
let mut _0: ();
let mut _3: !;
let _4: bool;
let mut _5: &();
let mut _6: !;
let mut _7: &();
let _8: ();
let mut _9: !;

bb0: {
StorageLive(_4);
StorageLive(_5);
StorageLive(_6);
_6 = _1;
unreachable;
}

bb1: {
StorageDead(_6);
StorageLive(_7);
StorageLive(_8);
StorageLive(_9);
_9 = _2;
unreachable;
}

bb2: {
_7 = &_8;
StorageDead(_9);
_4 = <() as PartialEq>::eq(move _5, move _7) -> [return: bb3, unwind: bb5];
}

bb3: {
StorageDead(_7);
StorageDead(_5);
StorageDead(_8);
StorageDead(_4);
unreachable;
}

bb4: {
return;
}

bb5 (cleanup): {
resume;
}
}
Loading

0 comments on commit f9b1614

Please sign in to comment.