We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
try_from_lit
1 parent c76dc95 commit 2c84769Copy full SHA for 2c84769
compiler/rustc_middle/src/ty/consts.rs
@@ -305,7 +305,16 @@ impl<'tcx> Const<'tcx> {
305
// mir.
306
match tcx.at(expr.span).lit_to_const(lit_input) {
307
Ok(c) => return Some(c),
308
- Err(_) => return None,
+ 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
+ }
318
}
319
320
0 commit comments