Skip to content

Commit 2c84769

Browse files
authored
Special-case alias ty in try_from_lit
1 parent c76dc95 commit 2c84769

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,16 @@ impl<'tcx> Const<'tcx> {
305305
// mir.
306306
match tcx.at(expr.span).lit_to_const(lit_input) {
307307
Ok(c) => return Some(c),
308-
Err(_) => return None,
308+
Err(_) if lit_input.ty.has_aliases() => {
309+
// allow the `ty`` to be an alias type, though we cannot handle it here
310+
return None
311+
},
312+
Err(e) => {
313+
tcx.dcx().span_delayed_bug(
314+
expr.span,
315+
format!("Const::from_anon_const: couldn't lit_to_const {e:?}"),
316+
);
317+
}
309318
}
310319
}
311320

0 commit comments

Comments
 (0)