Delay a span bug if we see ty/const generic params during writeback

This commit is contained in:
Michael Goulet 2022-07-22 00:54:36 +00:00
parent 74f600b990
commit 01db8b656c
5 changed files with 39 additions and 0 deletions

View File

@ -293,6 +293,17 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> {
intravisit::walk_expr(self, e);
}
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {
match &p.kind {
hir::GenericParamKind::Lifetime { .. } => {
// Nothing to write back here
}
hir::GenericParamKind::Type { .. } | hir::GenericParamKind::Const { .. } => {
self.tcx().sess.delay_span_bug(p.span, format!("unexpected generic param: {p:?}"));
}
}
}
fn visit_block(&mut self, b: &'tcx hir::Block<'tcx>) {
self.visit_node_id(b.span, b.hir_id);
intravisit::walk_block(self, b);

View File

@ -0,0 +1,6 @@
#![feature(closure_lifetime_binder)]
fn main() {
for<const N: i32> || -> () {};
//~^ ERROR only lifetime parameters can be used in this context
}

View File

@ -0,0 +1,8 @@
error: only lifetime parameters can be used in this context
--> $DIR/disallow-const.rs:4:15
|
LL | for<const N: i32> || -> () {};
| ^
error: aborting due to previous error

View File

@ -0,0 +1,6 @@
#![feature(closure_lifetime_binder)]
fn main() {
for<T> || -> () {};
//~^ ERROR only lifetime parameters can be used in this context
}

View File

@ -0,0 +1,8 @@
error: only lifetime parameters can be used in this context
--> $DIR/disallow-ty.rs:4:9
|
LL | for<T> || -> () {};
| ^
error: aborting due to previous error