Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions compiler/rustc_codegen_ssa/src/mir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}

/// This is a convenience helper for `immediate_const_vector`. It has the precondition
/// that the given `constant` is an `Const::Unevaluated` and must be convertible to
/// a `ValTree`. If you want a more general version of this, talk to `wg-const-eval` on zulip.
/// that the given `constant` is a `Const::Unevaluated`, or a `Const::Ty` containing a
/// `ty::ConstKind::Value` or `ty::ConstKind::Unevaluated`, and must be convertible to a
/// `ValTree`. If you want a more general version of this, talk to `wg-const-eval` on zulip.
///
/// Note that this function is cursed, since usually MIR consts should not be evaluated to
/// valtrees!
Expand All @@ -44,6 +45,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// A constant that came from a const generic but was then used as an argument to
// old-style simd_shuffle (passing as argument instead of as a generic param).
ty::ConstKind::Value(cv) => return Ok(Ok(cv.valtree)),
ty::ConstKind::Unevaluated(uv) => uv,
other => span_bug!(constant.span, "{other:#?}"),
},
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_mir_build/src/builder/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
assert!(!constant.const_.ty().has_param());
let (uv, ty) = match constant.const_ {
mir::Const::Unevaluated(uv, ty) => (uv.shrink(), ty),
mir::Const::Ty(_, c) => match c.kind() {
mir::Const::Ty(ty, c) => match c.kind() {
// A constant that came from a const generic but was then used as an argument to
// old-style simd_shuffle (passing as argument instead of as a generic param).
ty::ConstKind::Value(cv) => return Ok((cv.valtree, cv.ty)),
ty::ConstKind::Unevaluated(uv) => (uv, ty),
other => span_bug!(constant.span, "{other:#?}"),
},
mir::Const::Val(mir::ConstValue::Scalar(mir::interpret::Scalar::Int(val)), ty) => {
Expand Down
25 changes: 25 additions & 0 deletions tests/ui/loop-match/type-const-const-continue-ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Regression test for <https://github.com/rust-lang/rust/issues/156410>

#![feature(min_generic_const_args)]
#![feature(loop_match)]

trait T {
type const N: usize;
fn a() {
let mut s;
#[loop_match]
loop {
s = 'b: {
match s {
_ => {
#[const_continue]
break 'b Self::N
//~^ ERROR could not determine the target branch for this `#[const_continue]`
}
}
}
}
}
}

fn main() {}
8 changes: 8 additions & 0 deletions tests/ui/loop-match/type-const-const-continue-ice.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: could not determine the target branch for this `#[const_continue]`
--> $DIR/type-const-const-continue-ice.rs:16:34
|
LL | break 'b Self::N
| ^^^^^^^ this value is too generic

error: aborting due to 1 previous error

Loading