about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-14 12:44:07 +0000
committerbors <bors@rust-lang.org>2024-07-14 12:44:07 +0000
commit88fa119c77682e6d55ce21001cf761675cfebeae (patch)
tree37cfb88f45d322ed3ed06bdb1200c0a0ca990fc9 /compiler
parenta241cf1c49c46c57ee2ea9b19df4e7e2cc41449d (diff)
parent938ed369ada248e00d5ed906e5ba589c7cac9d2e (diff)
Auto merge of #127670 - compiler-errors:no-type-length-limit, r=jackh726
Gate the type length limit check behind a nightly flag

Effectively disables the type length limit by introducing a `-Zenforce-type-length-limit` which defaults to **`false`**, since making the length limit actually be enforced ended up having a worse fallout than expected. We still keep the code around, but the type length limit attr is now a noop (except for its usage in some diagnostics code?).

r? `@lcnr` -- up to you to decide what team consensus we need here since this reverses an FCP decision.

Reopens #125460 (if we decide to reopen it or keep it closed)
Effectively reverses the decision FCP'd in #125507
Closes #127346
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/ty/instance.rs4
-rw-r--r--compiler/rustc_session/src/options.rs2
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs
index c50a98e88fd..6e64e9bc4f8 100644
--- a/compiler/rustc_middle/src/ty/instance.rs
+++ b/compiler/rustc_middle/src/ty/instance.rs
@@ -541,7 +541,9 @@ impl<'tcx> Instance<'tcx> {
         // which means that rustc basically hangs.
         //
         // Bail out in these cases to avoid that bad user experience.
-        if !tcx.type_length_limit().value_within_limit(type_length(args)) {
+        if tcx.sess.opts.unstable_opts.enforce_type_length_limit
+            && !tcx.type_length_limit().value_within_limit(type_length(args))
+        {
             return Ok(None);
         }
 
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index 68f3ff13d2e..8fd1876ff1d 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1711,6 +1711,8 @@ options! {
         "emit a section containing stack size metadata (default: no)"),
     emit_thin_lto: bool = (true, parse_bool, [TRACKED],
         "emit the bc module with thin LTO info (default: yes)"),
+    enforce_type_length_limit: bool = (false, parse_bool, [TRACKED],
+        "enforce the type length limit when monomorphizing instances in codegen"),
     export_executable_symbols: bool = (false, parse_bool, [TRACKED],
         "export symbols from executables, as if they were dynamic libraries"),
     external_clangrt: bool = (false, parse_bool, [UNTRACKED],