From a11756ca757e37aa19fb5101aa44f8c82cd17d81 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 23 Feb 2024 12:11:11 +0000 Subject: [PATCH 1/4] Forbid implementing `Freeze` even if the trait is stabilized --- example/mini_core.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/example/mini_core.rs b/example/mini_core.rs index a79909ce0c87..47db7ee36918 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -8,6 +8,7 @@ rustc_attrs, transparent_unions, auto_traits, + freeze_impls, thread_local )] #![no_core] From 127c232050df04a4ae06fc536a428c34e248c5d9 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Mon, 26 Feb 2024 21:25:27 -0500 Subject: [PATCH 2/4] Distinguish between library and lang UB in assert_unsafe_precondition --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 1ce920f3bdb7..2415c2c90b22 100644 --- a/src/base.rs +++ b/src/base.rs @@ -779,7 +779,7 @@ fn codegen_stmt<'tcx>( NullOp::OffsetOf(fields) => { layout.offset_of_subfield(fx, fields.iter()).bytes() } - NullOp::DebugAssertions => { + NullOp::UbCheck(_) => { let val = fx.tcx.sess.opts.debug_assertions; let val = CValue::by_val( fx.bcx.ins().iconst(types::I8, i64::try_from(val).unwrap()), From 01affeb53a32f2e29bb90ebd3eff4c4c687e6746 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 10 Mar 2024 11:49:27 +0100 Subject: [PATCH 3/4] use Instance::expect_resolve() instead of unwraping Instance::resolve() --- src/main_shim.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main_shim.rs b/src/main_shim.rs index 6535c3a367b8..1abfded8b11f 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -115,14 +115,12 @@ pub(crate) fn maybe_create_entry_wrapper( termination_trait, ) .unwrap(); - let report = Instance::resolve( + let report = Instance::expect_resolve( tcx, ParamEnv::reveal_all(), report.def_id, tcx.mk_args(&[GenericArg::from(main_ret_ty)]), ) - .unwrap() - .unwrap() .polymorphize(tcx); let report_name = tcx.symbol_name(report).name; @@ -142,14 +140,12 @@ pub(crate) fn maybe_create_entry_wrapper( } } else if is_main_fn { let start_def_id = tcx.require_lang_item(LangItem::Start, None); - let start_instance = Instance::resolve( + let start_instance = Instance::expect_resolve( tcx, ParamEnv::reveal_all(), start_def_id, tcx.mk_args(&[main_ret_ty.into()]), ) - .unwrap() - .unwrap() .polymorphize(tcx); let start_func_id = import_function(tcx, m, start_instance); From fe7be63daed8ddce4fc1cf7ba65cb5fb3b27ca75 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 10 Mar 2024 12:39:53 +0100 Subject: [PATCH 4/4] add comments explaining where post-mono const eval errors abort compilation --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index 18c5960ffc68..cec479218b71 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -71,7 +71,7 @@ pub(crate) fn eval_mir_constant<'tcx>( // This cannot fail because we checked all required_consts in advance. let val = cv .eval(fx.tcx, ty::ParamEnv::reveal_all(), Some(constant.span)) - .expect("erroneous constant not captured by required_consts"); + .expect("erroneous constant missed by mono item collection"); (val, cv.ty()) }