Skip to content

Commit

Permalink
Auto merge of rust-lang#122955 - WaffleLapkin:no-more-fallback, r=<try>
Browse files Browse the repository at this point in the history
[experiment] Turn offf never type fallback

Crater experiment
  • Loading branch information
bors committed Mar 24, 2024
2 parents 2f090c3 + 358aca1 commit f1b8e2b
Show file tree
Hide file tree
Showing 160 changed files with 39,609 additions and 108 deletions.
78 changes: 65 additions & 13 deletions Cargo.lock
Expand Up @@ -774,7 +774,7 @@ dependencies = [
"tracing-subscriber",
"unified-diff",
"walkdir",
"windows",
"windows 0.52.0",
]

[[package]]
Expand Down Expand Up @@ -875,8 +875,10 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
dependencies = [
"loom",
"rand",
]

[[package]]
name = "crypto-common"
Expand Down Expand Up @@ -1533,6 +1535,19 @@ dependencies = [
"windows-bindgen",
]

[[package]]
name = "generator"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e"
dependencies = [
"cc",
"libc",
"log",
"rustversion",
"windows 0.48.0",
]

[[package]]
name = "generic-array"
version = "0.14.7"
Expand Down Expand Up @@ -2304,6 +2319,19 @@ version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"

[[package]]
name = "loom"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e045d70ddfbc984eacfa964ded019534e8f6cbf36f6410aee0ed5cefa5a9175"
dependencies = [
"cfg-if",
"generator",
"scoped-tls",
"tracing",
"tracing-subscriber",
]

[[package]]
name = "lzma-sys"
version = "0.1.20"
Expand Down Expand Up @@ -2461,13 +2489,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
dependencies = [
"adler",
"compiler_builtins",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
"simd-adler32",
]

[[package]]
Expand Down Expand Up @@ -3084,6 +3111,15 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9e1dcb320d6839f6edb64f7a4a59d39b30480d4d1765b56873f7c858538a5fe"

[[package]]
name = "quickcheck"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
dependencies = [
"rand",
]

[[package]]
name = "quine-mc_cluskey"
version = "0.2.4"
Expand Down Expand Up @@ -3211,11 +3247,12 @@ dependencies = [
[[package]]
name = "regex"
version = "1.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
dependencies = [
"aho-corasick",
"lazy_static",
"memchr",
"quickcheck",
"rand",
"regex-syntax 0.7.5",
]

Expand Down Expand Up @@ -3713,7 +3750,7 @@ dependencies = [
"thorin-dwp",
"tracing",
"wasm-encoder",
"windows",
"windows 0.52.0",
]

[[package]]
Expand Down Expand Up @@ -3770,7 +3807,7 @@ dependencies = [
"tempfile",
"thin-vec",
"tracing",
"windows",
"windows 0.52.0",
]

[[package]]
Expand Down Expand Up @@ -3832,7 +3869,7 @@ dependencies = [
"shlex",
"time",
"tracing",
"windows",
"windows 0.52.0",
]

[[package]]
Expand Down Expand Up @@ -3884,7 +3921,7 @@ dependencies = [
"termize",
"tracing",
"unicode-width",
"windows",
"windows 0.52.0",
]

[[package]]
Expand Down Expand Up @@ -4582,7 +4619,7 @@ dependencies = [
"smallvec",
"termize",
"tracing",
"windows",
"windows 0.52.0",
]

[[package]]
Expand Down Expand Up @@ -5100,6 +5137,12 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"

[[package]]
name = "simd-adler32"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"

[[package]]
name = "siphasher"
version = "0.3.11"
Expand Down Expand Up @@ -5365,7 +5408,7 @@ dependencies = [
"libc",
"ntapi",
"once_cell",
"windows",
"windows 0.52.0",
]

[[package]]
Expand Down Expand Up @@ -6307,6 +6350,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

[[package]]
name = "windows"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
dependencies = [
"windows-targets 0.48.5",
]

[[package]]
name = "windows"
version = "0.52.0"
Expand Down
7 changes: 7 additions & 0 deletions Cargo.toml
@@ -1,6 +1,9 @@
[workspace]
resolver = "1"
members = [
"miniz_oxide-0.7.2",
"regex-1.8.4",
"crossbeam-utils-0.8.19",
"compiler/rustc",
"library/std",
"library/sysroot",
Expand Down Expand Up @@ -112,5 +115,9 @@ rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' }
rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' }

miniz_oxide = { path = 'miniz_oxide-0.7.2' }
regex = { path = 'regex-1.8.4' }
crossbeam-utils = { path = 'crossbeam-utils-0.8.19' }

[patch."https://github.com/rust-lang/rust-clippy"]
clippy_lints = { path = "src/tools/clippy/clippy_lints" }
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/metadata.rs
Expand Up @@ -174,7 +174,7 @@ pub(super) fn get_metadata_xcoff<'a>(path: &Path, data: &'a [u8]) -> Result<&'a
return Ok(&info_data[offset..(offset + len)]);
} else {
return Err(format!("Unable to find symbol {AIX_METADATA_SYMBOL_NAME}"));
};
}
}

pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/const_eval/dummy_machine.rs
Expand Up @@ -64,13 +64,13 @@ impl<'mir, 'tcx: 'mir> interpret::Machine<'mir, 'tcx> for DummyMachine {
is_write: bool,
) -> InterpResult<'tcx> {
if is_write {
throw_machine_stop_str!("can't write to global");
throw_machine_stop_str!("can't write to global")
}

// If the static allocation is mutable, then we can't const prop it as its content
// might be different at runtime.
if alloc.inner().mutability.is_mut() {
throw_machine_stop_str!("can't access mutable globals in ConstProp");
throw_machine_stop_str!("can't access mutable globals in ConstProp")
}

Ok(())
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_const_eval/src/const_eval/eval_queries.rs
Expand Up @@ -257,9 +257,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
// Catch such calls and evaluate them instead of trying to load a constant's MIR.
if let ty::InstanceDef::Intrinsic(def_id) = key.value.instance.def {
let ty = key.value.instance.ty(tcx, key.param_env);
let ty::FnDef(_, args) = ty.kind() else {
bug!("intrinsic with type {:?}", ty);
};
let ty::FnDef(_, args) = ty.kind() else { bug!("intrinsic with type {:?}", ty) };
return eval_nullary_intrinsic(tcx, key.param_env, def_id, args).map_err(|error| {
let span = tcx.def_span(def_id);

Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_const_eval/src/interpret/validity.rs
Expand Up @@ -476,7 +476,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
Some(CtfeValidationMode::Const { .. }) => {
// We can't recursively validate `extern static`, so we better reject them.
if self.ecx.tcx.is_foreign_item(did) {
throw_validation_failure!(self.path, ConstRefToExtern);
throw_validation_failure!(self.path, ConstRefToExtern)
}
}
None => {}
Expand Down Expand Up @@ -518,14 +518,14 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
if ptr_expected_mutbl == Mutability::Mut
&& alloc_actual_mutbl == Mutability::Not
{
throw_validation_failure!(self.path, MutableRefToImmutable);
throw_validation_failure!(self.path, MutableRefToImmutable)
}
// In a const, everything must be completely immutable.
if matches!(self.ctfe_mode, Some(CtfeValidationMode::Const { .. })) {
if ptr_expected_mutbl == Mutability::Mut
|| alloc_actual_mutbl == Mutability::Mut
{
throw_validation_failure!(self.path, ConstRefToMutable);
throw_validation_failure!(self.path, ConstRefToMutable)
}
}
}
Expand Down Expand Up @@ -621,7 +621,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
} else {
// Otherwise (for standalone Miri), we have to still check it to be non-null.
if self.ecx.scalar_may_be_null(value)? {
throw_validation_failure!(self.path, NullFnPtr);
throw_validation_failure!(self.path, NullFnPtr)
}
}
Ok(true)
Expand Down Expand Up @@ -786,7 +786,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
if self.ctfe_mode.is_some_and(|c| !c.allow_immutable_unsafe_cell()) {
if !op.layout.is_zst() && !op.layout.ty.is_freeze(*self.ecx.tcx, self.ecx.param_env) {
if !self.in_mutable_memory(op) {
throw_validation_failure!(self.path, UnsafeCellInImmutable);
throw_validation_failure!(self.path, UnsafeCellInImmutable)
}
}
}
Expand Down Expand Up @@ -819,7 +819,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
&& def.is_unsafe_cell()
{
if !self.in_mutable_memory(op) {
throw_validation_failure!(self.path, UnsafeCellInImmutable);
throw_validation_failure!(self.path, UnsafeCellInImmutable)
}
}
}
Expand Down Expand Up @@ -934,7 +934,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
match op.layout.abi {
Abi::Uninhabited => {
let ty = op.layout.ty;
throw_validation_failure!(self.path, UninhabitedVal { ty });
throw_validation_failure!(self.path, UninhabitedVal { ty })
}
Abi::Scalar(scalar_layout) => {
if !scalar_layout.is_uninit_valid() {
Expand Down
28 changes: 13 additions & 15 deletions compiler/rustc_driver_impl/src/lib.rs
Expand Up @@ -642,21 +642,19 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
});
let (codegen_results, outputs) = match CodegenResults::deserialize_rlink(sess, rlink_data) {
Ok((codegen, outputs)) => (codegen, outputs),
Err(err) => {
match err {
CodegenErrors::WrongFileType => dcx.emit_fatal(RLinkWrongFileType),
CodegenErrors::EmptyVersionNumber => dcx.emit_fatal(RLinkEmptyVersionNumber),
CodegenErrors::EncodingVersionMismatch { version_array, rlink_version } => sess
.dcx()
.emit_fatal(RLinkEncodingVersionMismatch { version_array, rlink_version }),
CodegenErrors::RustcVersionMismatch { rustc_version } => {
dcx.emit_fatal(RLinkRustcVersionMismatch {
rustc_version,
current_version: sess.cfg_version,
})
}
};
}
Err(err) => match err {
CodegenErrors::WrongFileType => dcx.emit_fatal(RLinkWrongFileType),
CodegenErrors::EmptyVersionNumber => dcx.emit_fatal(RLinkEmptyVersionNumber),
CodegenErrors::EncodingVersionMismatch { version_array, rlink_version } => sess
.dcx()
.emit_fatal(RLinkEncodingVersionMismatch { version_array, rlink_version }),
CodegenErrors::RustcVersionMismatch { rustc_version } => {
dcx.emit_fatal(RLinkRustcVersionMismatch {
rustc_version,
current_version: sess.cfg_version,
})
}
},
};
if compiler.codegen_backend.link(sess, codegen_results, &outputs).is_err() {
FatalError.raise();
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Expand Up @@ -125,9 +125,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
.filter(|arg| arg.is_ty_or_const())
.position(|arg| arg.hir_id() == hir_id)
})
.unwrap_or_else(|| {
bug!("no arg matching AnonConst in segment");
});
.unwrap_or_else(|| bug!("no arg matching AnonConst in segment"));

(generics, arg_index)
} else {
Expand Down Expand Up @@ -164,9 +162,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
.filter(|arg| arg.is_ty_or_const())
.position(|arg| arg.hir_id() == hir_id)
})
.unwrap_or_else(|| {
bug!("no arg matching AnonConst in segment");
});
.unwrap_or_else(|| bug!("no arg matching AnonConst in segment"));

(tcx.generics_of(type_dependent_def), idx)
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
Expand Up @@ -438,6 +438,11 @@ fn parse_never_type_options_attr(
}

let fallback = fallback.unwrap_or_else(|| {
if true {
// For a crater experiment, turn off all fallback
return NoFallback;
}

if tcx.features().never_type_fallback { FallbackToNiko } else { FallbackToUnit }
});

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_hir_typeck/src/lib.rs
Expand Up @@ -344,9 +344,8 @@ pub struct EnclosingBreakables<'tcx> {

impl<'tcx> EnclosingBreakables<'tcx> {
fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'tcx> {
self.opt_find_breakable(target_id).unwrap_or_else(|| {
bug!("could not find enclosing breakable with id {}", target_id);
})
self.opt_find_breakable(target_id)
.unwrap_or_else(|| bug!("could not find enclosing breakable with id {}", target_id))
}

fn opt_find_breakable(&mut self, target_id: hir::HirId) -> Option<&mut BreakableCtxt<'tcx>> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/types.rs
Expand Up @@ -1118,7 +1118,7 @@ pub(crate) fn repr_nullable_ptr<'tcx>(
WrappingRange { start, end } => {
unreachable!("Unhandled start and end range: ({}, {})", start, end)
}
};
}
}
}
None
Expand Down

0 comments on commit f1b8e2b

Please sign in to comment.