Skip to content

Commit 54cd3cf

Browse files
committed
Fix AST lowering for const args
1 parent f17a547 commit 54cd3cf

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,11 +1178,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11781178
self.arena.alloc(self.lower_anon_const_as_const_arg_direct(anon))
11791179
}
11801180

1181+
#[instrument(level = "debug", skip(self))]
11811182
fn lower_anon_const_as_const_arg_direct(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
11821183
if let ExprKind::Path(qself, path) = &anon.value.kind
11831184
&& let Some(res) = self
11841185
.resolver
1185-
.get_partial_res(anon.id)
1186+
.get_partial_res(anon.value.id)
11861187
.and_then(|partial_res| partial_res.full_res())
11871188
// FIXME(min_generic_const_exprs): for now we only lower params to ConstArgKind::Path
11881189
&& let Res::Def(DefKind::ConstParam, _) = res

compiler/rustc_middle/src/ty/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl<'tcx> Const<'tcx> {
255255
let hir::QPath::Resolved(_, &hir::Path { res: Res::Def(DefKind::ConstParam, def_id), .. }) =
256256
qpath
257257
else {
258-
bug!("non-param passed to Const::from_param")
258+
span_bug!(qpath.span(), "non-param {qpath:?} passed to Const::from_param")
259259
};
260260

261261
match tcx.named_bound_var(hir_id) {

0 commit comments

Comments
 (0)