diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-16 19:58:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-16 19:58:58 +0200 |
| commit | f04d25fa91103a885d124e6e8384d92358847e0c (patch) | |
| tree | 6cfdbb431386fef6e0bd70c8fade3840ef5dd8bf | |
| parent | 19d32e4e236ff6eaf71ac4e3a927e5f90ecd2a26 (diff) | |
| parent | cd2b0309cc948a54a7bdbc3050b0d7d6b0826f93 (diff) | |
| download | rust-f04d25fa91103a885d124e6e8384d92358847e0c.tar.gz rust-f04d25fa91103a885d124e6e8384d92358847e0c.zip | |
Rollup merge of #129042 - Jaic1:fix-116308, r=BoxyUwU
Special-case alias ty during the delayed bug emission in `try_from_lit` This PR tries to fix #116308. A delayed bug in `try_from_lit` will not be emitted so that the compiler will not ICE when it sees the pair `(ast::LitKind::Int, ty::TyKind::Alias)` in `lit_to_const` (called from `try_from_lit`). This PR is related to an unstable feature `adt_const_params` (#95174). r? ``@BoxyUwU``
| -rw-r--r-- | compiler/rustc_middle/src/ty/consts.rs | 4 | ||||
| -rw-r--r-- | tests/ui/const-generics/adt_const_params/116308.rs (renamed from tests/crashes/116308.rs) | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index c380019e63f..e373292741b 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -305,6 +305,10 @@ impl<'tcx> Const<'tcx> { // mir. match tcx.at(expr.span).lit_to_const(lit_input) { Ok(c) => return Some(c), + Err(_) if lit_input.ty.has_aliases() => { + // allow the `ty` to be an alias type, though we cannot handle it here + return None; + } Err(e) => { tcx.dcx().span_delayed_bug( expr.span, diff --git a/tests/crashes/116308.rs b/tests/ui/const-generics/adt_const_params/116308.rs index cb96c80d79b..9ea7022e29c 100644 --- a/tests/crashes/116308.rs +++ b/tests/ui/const-generics/adt_const_params/116308.rs @@ -1,6 +1,8 @@ -//@ known-bug: #116308 +//@ check-pass #![feature(adt_const_params)] +// Regression test for #116308 + pub trait Identity { type Identity; } |
