diff options
| author | Jaic1 <506933131@qq.com> | 2024-08-13 16:21:58 +0800 |
|---|---|---|
| committer | Jaic1 <506933131@qq.com> | 2024-08-16 08:37:19 +0800 |
| commit | cd2b0309cc948a54a7bdbc3050b0d7d6b0826f93 (patch) | |
| tree | 4a11ed258bc217d48b6a8595c697456553c0abbb | |
| parent | 2c93fabd98d2c183bcb3afed1f7d51b2517ac5ed (diff) | |
| download | rust-cd2b0309cc948a54a7bdbc3050b0d7d6b0826f93.tar.gz rust-cd2b0309cc948a54a7bdbc3050b0d7d6b0826f93.zip | |
Special-case alias ty in `try_from_lit`
| -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; } |
