Auto merge of #125507 - compiler-errors:type-length-limit, r= · rust-lang/rust@61a9ac6 (original) (raw)
File tree
35 files changed
lines changed
- rustc_codegen_cranelift/src
- rustc_trait_selection/src/traits
- issue-37311-type-length-limit
35 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -370,9 +370,14 @@ pub(crate) fn codegen_terminator_call<'tcx>( | ||
370 | 370 | |
371 | 371 | // Handle special calls like intrinsics and empty drop glue. |
372 | 372 | let instance = if let ty::FnDef(def_id, fn_args) = *func.layout().ty.kind() { |
373 | -let instance = | |
374 | - ty::Instance::expect_resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, fn_args) | |
375 | -.polymorphize(fx.tcx); | |
373 | +let instance = ty::Instance::expect_resolve( | |
374 | + fx.tcx, | |
375 | + ty::ParamEnv::reveal_all(), | |
376 | + def_id, | |
377 | + fn_args, | |
378 | +Some(source_info.span), | |
379 | +) | |
380 | +.polymorphize(fx.tcx); | |
376 | 381 | |
377 | 382 | if is_call_from_compiler_builtins_to_upstream_monomorphization(fx.tcx, instance) { |
378 | 383 | if target.is_some() { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -121,6 +121,7 @@ pub(crate) fn maybe_create_entry_wrapper( | ||
121 | 121 | ParamEnv::reveal_all(), |
122 | 122 | report.def_id, |
123 | 123 | tcx.mk_args(&[GenericArg::from(main_ret_ty)]), |
124 | +None, | |
124 | 125 | ) |
125 | 126 | .polymorphize(tcx); |
126 | 127 | |
@@ -146,6 +147,7 @@ pub(crate) fn maybe_create_entry_wrapper( | ||
146 | 147 | ParamEnv::reveal_all(), |
147 | 148 | start_def_id, |
148 | 149 | tcx.mk_args(&[main_ret_ty.into()]), |
150 | +None, | |
149 | 151 | ) |
150 | 152 | .polymorphize(tcx); |
151 | 153 | let start_func_id = import_function(tcx, m, start_instance); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -483,6 +483,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> { | ||
483 | 483 | ty::ParamEnv::reveal_all(), |
484 | 484 | def_id, |
485 | 485 | ty::List::empty(), |
486 | +None, | |
486 | 487 | ); |
487 | 488 | |
488 | 489 | let symbol_name = tcx.symbol_name(instance).name; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -566,6 +566,7 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { | ||
566 | 566 | ty::ParamEnv::reveal_all(), |
567 | 567 | def_id, |
568 | 568 | ty::List::empty(), |
569 | +None, | |
569 | 570 | )), |
570 | 571 | _ => { |
571 | 572 | let name = name.unwrap_or("rust_eh_personality"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -29,8 +29,8 @@ use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, Debugger | ||
29 | 29 | use rustc_middle::middle::exported_symbols; |
30 | 30 | use rustc_middle::middle::exported_symbols::SymbolExportKind; |
31 | 31 | use rustc_middle::middle::lang_items; |
32 | -use rustc_middle::mir::BinOp; | |
33 | 32 | use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem}; |
33 | +use rustc_middle::mir::BinOp; | |
34 | 34 | use rustc_middle::query::Providers; |
35 | 35 | use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout}; |
36 | 36 | use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; |
@@ -467,6 +467,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( | ||
467 | 467 | ty::ParamEnv::reveal_all(), |
468 | 468 | start_def_id, |
469 | 469 | cx.tcx().mk_args(&[main_ret_ty.into()]), |
470 | +None, | |
470 | 471 | ); |
471 | 472 | let start_fn = cx.get_fn_addr(start_instance); |
472 | 473 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -826,6 +826,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | ||
826 | 826 | ty::ParamEnv::reveal_all(), |
827 | 827 | def_id, |
828 | 828 | args, |
829 | +Some(fn_span), | |
829 | 830 | ) |
830 | 831 | .polymorphize(bx.tcx()), |
831 | 832 | ), |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -254,6 +254,7 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> { | ||
254 | 254 | ty::ParamEnv::reveal_all(), |
255 | 255 | const_def_id, |
256 | 256 | instance.args, |
257 | +Some(self.find_closest_untracked_caller_location()), | |
257 | 258 | ); |
258 | 259 | |
259 | 260 | return Ok(Some(new_instance)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -871,13 +871,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | ||
871 | 871 | ty::ExistentialTraitRef::erase_self_ty(tcx, virtual_trait_ref); |
872 | 872 | let concrete_trait_ref = existential_trait_ref.with_self_ty(tcx, dyn_ty); |
873 | 873 | |
874 | -let concrete_method = Instance::resolve_for_vtable( | |
874 | +let concrete_method = Instance::expect_resolve_for_vtable( | |
875 | 875 | tcx, |
876 | 876 | self.param_env, |
877 | 877 | def_id, |
878 | 878 | instance.args.rebase_onto(tcx, trait_def_id, concrete_trait_ref.args), |
879 | -) | |
880 | -.unwrap(); | |
879 | +); | |
881 | 880 | assert_eq!(fn_inst, concrete_method); |
882 | 881 | } |
883 | 882 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -41,6 +41,9 @@ middle_cannot_be_normalized = | ||
41 | 41 | middle_conflict_types = |
42 | 42 | this expression supplies two conflicting concrete types for the same opaque type |
43 | 43 | |
44 | +middle_consider_type_length_limit = | |
45 | + consider adding a `#![type_length_limit="{$type_length}"]` attribute to your crate | |
46 | + | |
44 | 47 | middle_const_eval_non_int = |
45 | 48 | constant evaluation of enum discriminant resulted in non-integer |
46 | 49 | |
@@ -94,8 +97,11 @@ middle_strict_coherence_needs_negative_coherence = | ||
94 | 97 | to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled |
95 | 98 | .label = due to this attribute |
96 | 99 | |
100 | +middle_type_length_limit = reached the type-length limit while instantiating `{$shrunk}` | |
101 | + | |
97 | 102 | middle_unknown_layout = |
98 | 103 | the type `{$ty}` has an unknown layout |
99 | 104 | |
100 | 105 | middle_values_too_big = |
101 | 106 | values of the type `{$ty}` are too big for the current architecture |
107 | +middle_written_to_path = the full type name has been written to '{$path}' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
1 | 1 | use std::fmt; |
2 | +use std::path::PathBuf; | |
2 | 3 | |
3 | 4 | use rustc_errors::{codes::*, DiagArgName, DiagArgValue, DiagMessage}; |
4 | 5 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
@@ -149,3 +150,16 @@ pub struct ErroneousConstant { | ||
149 | 150 | |
150 | 151 | /// Used by `rustc_const_eval` |
151 | 152 | pub use crate::fluent_generated::middle_adjust_for_foreign_abi_error; |
153 | + | |
154 | +#[derive(Diagnostic)] | |
155 | +#[diag(middle_type_length_limit)] | |
156 | +#[help(middle_consider_type_length_limit)] | |
157 | +pub struct TypeLengthLimit { | |
158 | +#[primary_span] | |
159 | +pub span: Span, | |
160 | +pub shrunk: String, | |
161 | +#[note(middle_written_to_path)] | |
162 | +pub was_written: Option<()>, | |
163 | +pub path: PathBuf, | |
164 | +pub type_length: usize, | |
165 | +} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2151,8 +2151,8 @@ rustc_queries! { | ||
2151 | 2151 | /// * `Err(ErrorGuaranteed)` when the `Instance` resolution process |
2152 | 2152 | /// couldn't complete due to errors elsewhere - this is distinct |
2153 | 2153 | /// from `Ok(None)` to avoid misleading diagnostics when an error |
2154 | - /// has already been/will be emitted, for the original cause | |
2155 | - query resolve_instance( | |
2154 | + /// has already been/will be emitted, for the original cause. | |
2155 | + query resolve_instance_raw( | |
2156 | 2156 | key: ty::ParamEnvAnd<'tcx, (DefId, GenericArgsRef<'tcx>)> |
2157 | 2157 | ) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> { |
2158 | 2158 | desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) } |