Skip to content

Commit 0c96061

Browse files
committedJun 11, 2024
Auto merge of #126274 - jieyouxu:rollup-uj93sfm, r=jieyouxu
Rollup of 5 pull requests Successful merges: - #126186 (Migrate `run-make/multiple-emits` to `rmake.rs`) - #126236 (Delegation: fix ICE on recursive delegation) - #126254 (Remove ignore-cross-compile directive from ui/macros/proc_macro) - #126258 (Do not define opaque types when selecting impls) - #126265 (interpret: ensure we check bool/char for validity when they are used in a cast) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 20ba13c + cfd48bd commit 0c96061

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+377
-120
lines changed
 

‎compiler/rustc_ast_lowering/src/delegation.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
6767
return false;
6868
};
6969
if let Some(local_sig_id) = sig_id.as_local() {
70-
self.resolver.delegation_fn_sigs[&local_sig_id].has_self
70+
// The value may be missing due to recursive delegation.
71+
// Error will be emmited later during HIR ty lowering.
72+
self.resolver.delegation_fn_sigs.get(&local_sig_id).map_or(false, |sig| sig.has_self)
7173
} else {
7274
match self.tcx.def_kind(sig_id) {
7375
DefKind::Fn => false,

‎compiler/rustc_const_eval/src/interpret/cast.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
274274
// Let's make sure v is sign-extended *if* it has a signed type.
275275
let signed = src_layout.abi.is_signed(); // Also asserts that abi is `Scalar`.
276276

277-
let v = scalar.to_bits(src_layout.size)?;
278-
let v = if signed { self.sign_extend(v, src_layout) } else { v };
279-
trace!("cast_from_scalar: {}, {} -> {}", v, src_layout.ty, cast_ty);
277+
let v = match src_layout.ty.kind() {
278+
Uint(_) | RawPtr(..) | FnPtr(..) => scalar.to_uint(src_layout.size)?,
279+
Int(_) => scalar.to_int(src_layout.size)? as u128, // we will cast back to `i128` below if the sign matters
280+
Bool => scalar.to_bool()?.into(),
281+
Char => scalar.to_char()?.into(),
282+
_ => span_bug!(self.cur_span(), "invalid int-like cast from {}", src_layout.ty),
283+
};
280284

281285
Ok(match *cast_ty.kind() {
282286
// int -> int

0 commit comments

Comments
 (0)