Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details<!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
I was just looking at the parsing code for const generic exprs.. claim
actually, so this isn't related to incorrectly parsing , since we're parsing in expr position to allow if-let chains.. -- this is due to const eval lowering to MIR and the fact that const generic parameters have no enclosing scope. Adding around the generic args works, but I don't know where exactly to hack in a scope for these params. release-assignment label A-const-eval A-mir
Maybe fixing this also fixes :slightlysmilingface:
This gives an error without ICE in 1.55
It was unclear to me - I think meant that changing to gives a compile error instead of an ICE. So the proper fix here is probably to add somewhere instead of panicking.
Then this should be easy. claim

Discussion:
self.parent_map.get(&id).cloned().map(|(p, _)| p) } <del> /// Returns the lifetime of the local variable `var_id` pub fn var_scope(&self, var_id: hir::ItemLocalId) -> Scope { self.var_map .get(&var_id) .cloned() .unwrap_or_else(|| bug!("no enclosing scope for id {:?}", var_id)) </del> <ins> /// Returns the lifetime of the local variable `var_id`, if any. pub fn var_scope(&self, var_id: hir::ItemLocalId) -> Option<Scope> { self.var_map.get(&var_id).cloned() </ins> } /// Returns the scope when the temp created by `expr_id` will be cleaned up.

let local_id = self.var_local_id(var, for_guard); let source_info = self.source_info(span); self.cfg.push(block, Statement { source_info, kind: StatementKind::StorageLive(local_id) }); <del> let region_scope = self.region_scope_tree.var_scope(var.local_id); if schedule_drop { </del> <ins> // Altough there is almost always scope for given variable in corner cases // like #92893 we might get variable with no scope. if let Some(region_scope) = self.region_scope_tree.var_scope(var.local_id) && schedule_drop{ </ins> self.schedule_drop(span, region_scope, local_id, DropKind::Storage); } Place::from(local_id)

crate fn schedule_drop_for_binding(&mut self, var: HirId, span: Span, for_guard: ForGuard) { let local_id = self.var_local_id(var, for_guard); <del> let region_scope = self.region_scope_tree.var_scope(var.local_id); self.schedule_drop(span, region_scope, local_id, DropKind::Value); </del> <ins> if let Some(region_scope) = self.region_scope_tree.var_scope(var.local_id) { self.schedule_drop(span, region_scope, local_id, DropKind::Value); } </ins> } /// Visit all of the primary bindings in a patterns, that is, visit the

self.expr_count += 1; if let PatKind::Binding(..) = pat.kind { <del> let scope = self.region_scope_tree.var_scope(pat.hir_id.local_id); </del> <ins> let scope = self.region_scope_tree.var_scope(pat.hir_id.local_id).unwrap(); </ins> let ty = self.fcx.typeck_results.borrow().pat_ty(pat); self.record(ty, pat.hir_id, Some(scope), None, pat.span, false); }

<ins> struct Bug<A = [(); (let a = (), 1).1]> { //~^ `let` expressions are not supported here //~^^ `let` expressions in this position are unstable [E0658] a: A } fn main() {} </ins>

<ins> error: `let` expressions are not supported here --> $DIR/issue-92893.rs:1:22 | LL | struct Bug<A = [(); (let a = (), 1).1]> { |                      ^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions error[E0658]: `let` expressions in this position are unstable --> $DIR/issue-92893.rs:1:22 | LL | struct Bug<A = [(); (let a = (), 1).1]> { |                      ^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information = help: add `#![feature(let_chains)]` to the crate attributes to enable error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. </ins>

if let Some(indexed_extent) = indexed_extent { let parent_def_id = cx.tcx.hir().get_parent_item(expr.hir_id); let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id); <del> let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id); </del> <ins> let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id).unwrap(); </ins> if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) { return; }

match res { Res::Local(hir_id) => { let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id); <del> let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id); </del> <ins> let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id).unwrap(); </ins> if index_used_directly { self.indexed_directly.insert( seqvar.segments[0].ident.name,

fn is_shadow(cx: &LateContext<'_>, owner: LocalDefId, first: ItemLocalId, second: ItemLocalId) -> bool { let scope_tree = cx.tcx.region_scope_tree(owner.to_def_id()); <del> let first_scope = scope_tree.var_scope(first); let second_scope = scope_tree.var_scope(second); </del> <ins> let first_scope = scope_tree.var_scope(first).unwrap(); let second_scope = scope_tree.var_scope(second).unwrap(); </ins> scope_tree.is_subscope_of(second_scope, first_scope) }