Skip to content

Commit a9f3e03

Browse files
authored
Rollup merge of #99582 - compiler-errors:issue-99566, r=cjgillot
Delay a span bug if we see ty/const generic params during writeback Fixes #99566
2 parents 2fbc08e + 01db8b6 commit a9f3e03

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

compiler/rustc_typeck/src/check/writeback.rs

+11
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,17 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
292292
intravisit::walk_expr(self, e);
293293
}
294294

295+
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {
296+
match &p.kind {
297+
hir::GenericParamKind::Lifetime { .. } => {
298+
// Nothing to write back here
299+
}
300+
hir::GenericParamKind::Type { .. } | hir::GenericParamKind::Const { .. } => {
301+
self.tcx().sess.delay_span_bug(p.span, format!("unexpected generic param: {p:?}"));
302+
}
303+
}
304+
}
305+
295306
fn visit_block(&mut self, b: &'tcx hir::Block<'tcx>) {
296307
self.visit_node_id(b.span, b.hir_id);
297308
intravisit::walk_block(self, b);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![feature(closure_lifetime_binder)]
2+
3+
fn main() {
4+
for<const N: i32> || -> () {};
5+
//~^ ERROR only lifetime parameters can be used in this context
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: only lifetime parameters can be used in this context
2+
--> $DIR/disallow-const.rs:4:15
3+
|
4+
LL | for<const N: i32> || -> () {};
5+
| ^
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![feature(closure_lifetime_binder)]
2+
3+
fn main() {
4+
for<T> || -> () {};
5+
//~^ ERROR only lifetime parameters can be used in this context
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: only lifetime parameters can be used in this context
2+
--> $DIR/disallow-ty.rs:4:9
3+
|
4+
LL | for<T> || -> () {};
5+
| ^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)