Skip to content

Commit 2fe91f2

Browse files
committed
Handle static const-paths correctly
1 parent 2010e0a commit 2fe91f2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
21092109
);
21102110
self.lower_const_param(def_id, hir_id)
21112111
}
2112-
Res::Def(DefKind::Const | DefKind::Ctor(_, CtorKind::Const), did) => {
2112+
Res::Def(
2113+
DefKind::Const | DefKind::Static { .. } | DefKind::Ctor(_, CtorKind::Const),
2114+
did,
2115+
) => {
21132116
assert_eq!(opt_self_ty, None);
21142117
let _ = self.prohibit_generic_args(
21152118
path.segments.split_last().unwrap().1.iter(),
@@ -2132,7 +2135,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
21322135
// an invalid Res for a const path.
21332136
Res::Def(
21342137
DefKind::Mod
2135-
| DefKind::Static { .. }
21362138
| DefKind::Enum
21372139
| DefKind::Variant
21382140
| DefKind::Ctor(CtorOf::Variant, CtorKind::Fn)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// check-pass
2+
3+
pub static STATIC: u32 = 0;
4+
pub struct Foo<const N: u32>;
5+
pub const FOO: Foo<{STATIC}> = Foo;
6+
7+
fn main() {}

0 commit comments

Comments
 (0)