mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
Delay a span bug if we see ty/const generic params during writeback
This commit is contained in:
parent
74f600b990
commit
01db8b656c
@ -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);
|
||||
|
6
src/test/ui/closures/binder/disallow-const.rs
Normal file
6
src/test/ui/closures/binder/disallow-const.rs
Normal 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
|
||||
}
|
8
src/test/ui/closures/binder/disallow-const.stderr
Normal file
8
src/test/ui/closures/binder/disallow-const.stderr
Normal 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
|
||||
|
6
src/test/ui/closures/binder/disallow-ty.rs
Normal file
6
src/test/ui/closures/binder/disallow-ty.rs
Normal file
@ -0,0 +1,6 @@
|
||||
#![feature(closure_lifetime_binder)]
|
||||
|
||||
fn main() {
|
||||
for<T> || -> () {};
|
||||
//~^ ERROR only lifetime parameters can be used in this context
|
||||
}
|
8
src/test/ui/closures/binder/disallow-ty.stderr
Normal file
8
src/test/ui/closures/binder/disallow-ty.stderr
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user