diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-08-12 20:23:07 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-08-19 18:57:09 +0300 |
| commit | f4aa00b71dbb7433c408ff111c58c81788dc879f (patch) | |
| tree | a937b68eadaffbd49ddd931b7f6b52d3d3a66375 | |
| parent | 7d9af83ffcc1543deebb7b91725981314c7af8c2 (diff) | |
| download | rust-f4aa00b71dbb7433c408ff111c58c81788dc879f.tar.gz rust-f4aa00b71dbb7433c408ff111c58c81788dc879f.zip | |
rustc_typeck: fix the generics for (const-generic) `N` expression in e.g. `[T; N]`.
| -rw-r--r-- | src/librustc_typeck/collect.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index e979bc7bf25..312a598af02 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -900,6 +900,20 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics { let parent_id = tcx.hir().get_parent_item(hir_id); Some(tcx.hir().local_def_id(parent_id)) } + // FIXME(#43408) enable this in all cases when we get lazy normalization. + Node::AnonConst(&anon_const) => { + // HACK(eddyb) this provides the correct generics when the workaround + // for a const parameter `AnonConst` is being used elsewhere, as then + // there won't be the kind of cyclic dependency blocking #43408. + let expr = &tcx.hir().body(anon_const.body).value; + let icx = ItemCtxt::new(tcx, def_id); + if AstConv::const_param_def_id(&icx, expr).is_some() { + let parent_id = tcx.hir().get_parent_item(hir_id); + Some(tcx.hir().local_def_id(parent_id)) + } else { + None + } + } Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(..), .. |
