Skip to content

Rollup of 4 pull requests #124161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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(..)), .. },
],
@@ -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!(
@@ -308,9 +320,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
adj
),
);

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

27 changes: 0 additions & 27 deletions src/bootstrap/Cargo.lock
Original file line number Diff line number Diff line change
@@ -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"
@@ -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"
@@ -598,7 +572,6 @@ dependencies = [
"libc",
"ntapi",
"once_cell",
"rayon",
"windows",
]

2 changes: 1 addition & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
21 changes: 11 additions & 10 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
@@ -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);
}

/**
@@ -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;
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
@@ -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;
@@ -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};
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;
}
}
13 changes: 13 additions & 0 deletions tests/mir-opt/building/eq_never_type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// skip-filecheck
#![feature(never_type)]
#![allow(unreachable_code)]

// EMIT_MIR eq_never_type._f.built.after.mir
fn _f(a: !, b: !) {
// Both arguments must be references (i.e. == should auto-borrow/coerce-to-ref both arguments)
// (this previously was buggy due to `NeverToAny` coercion incorrectly throwing out other
// coercions)
a == b;
}

fn main() {}
Loading