Skip to content

[experiment] Turn off never type fallback #122955

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 11 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
81 changes: 66 additions & 15 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -774,7 +774,7 @@ dependencies = [
"tracing-subscriber",
"unified-diff",
"walkdir",
"windows",
"windows 0.52.0",
]

[[package]]
@@ -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"
@@ -891,8 +893,7 @@ dependencies = [
[[package]]
name = "ctrlc"
version = "3.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345"
source = "git+https://github.com/WaffleLapkin/rust-ctrlc.git?rev=17e3ee4b35f7988489a3d9fd7a3b10e81ca94809#17e3ee4b35f7988489a3d9fd7a3b10e81ca94809"
dependencies = [
"nix",
"windows-sys 0.52.0",
@@ -1533,6 +1534,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"
@@ -2304,6 +2318,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"
@@ -2461,13 +2488,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]]
@@ -3093,6 +3119,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"
@@ -3220,11 +3255,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",
]

@@ -3723,7 +3759,7 @@ dependencies = [
"thorin-dwp",
"tracing",
"wasm-encoder",
"windows",
"windows 0.52.0",
]

[[package]]
@@ -3780,7 +3816,7 @@ dependencies = [
"tempfile",
"thin-vec",
"tracing",
"windows",
"windows 0.52.0",
]

[[package]]
@@ -3843,7 +3879,7 @@ dependencies = [
"shlex",
"time",
"tracing",
"windows",
"windows 0.52.0",
]

[[package]]
@@ -3895,7 +3931,7 @@ dependencies = [
"termize",
"tracing",
"unicode-width",
"windows",
"windows 0.52.0",
]

[[package]]
@@ -4593,7 +4629,7 @@ dependencies = [
"smallvec",
"termize",
"tracing",
"windows",
"windows 0.52.0",
]

[[package]]
@@ -5114,6 +5150,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"
@@ -5379,7 +5421,7 @@ dependencies = [
"libc",
"ntapi",
"once_cell",
"windows",
"windows 0.52.0",
]

[[package]]
@@ -6310,6 +6352,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"
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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",
@@ -112,5 +115,10 @@ 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' }
ctrlc = { git = "https://github.com/WaffleLapkin/rust-ctrlc.git", rev = "17e3ee4b35f7988489a3d9fd7a3b10e81ca94809" }

[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
Original file line number Diff line number Diff line change
@@ -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>> {
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/const_eval/dummy_machine.rs
Original file line number Diff line number Diff line change
@@ -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(())
4 changes: 1 addition & 3 deletions compiler/rustc_const_eval/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
@@ -264,9 +264,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);

14 changes: 7 additions & 7 deletions compiler/rustc_const_eval/src/interpret/validity.rs
Original file line number Diff line number Diff line change
@@ -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 => {}
@@ -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)
}
}
}
@@ -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)
@@ -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)
}
}
}
@@ -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)
}
}
}
@@ -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() {
28 changes: 13 additions & 15 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -643,21 +643,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();
8 changes: 2 additions & 6 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
@@ -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 {
@@ -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)
}
5 changes: 5 additions & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
Original file line number Diff line number Diff line change
@@ -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 }
});

Loading