Skip to content

Commit 4c6b680

Browse files
authored
Rollup merge of #109105 - compiler-errors:late-ct-in-anon-ct, r=oli-obk
Don't ICE for late-bound consts across `AnonConstBoundary` Fixes #108194
2 parents 1f159b4 + 8a53570 commit 4c6b680

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1427,25 +1427,25 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
14271427
if let ResolvedArg::LateBound(..) = def && crossed_anon_const {
14281428
let use_span = self.tcx.hir().span(hir_id);
14291429
let def_span = self.tcx.def_span(param_def_id);
1430-
match self.tcx.def_kind(param_def_id) {
1430+
let guar = match self.tcx.def_kind(param_def_id) {
14311431
DefKind::ConstParam => {
14321432
self.tcx.sess.emit_err(errors::CannotCaptureLateBoundInAnonConst::Const {
14331433
use_span,
14341434
def_span,
1435-
});
1435+
})
14361436
}
14371437
DefKind::TyParam => {
14381438
self.tcx.sess.emit_err(errors::CannotCaptureLateBoundInAnonConst::Type {
14391439
use_span,
14401440
def_span,
1441-
});
1441+
})
14421442
}
14431443
_ => unreachable!(),
1444-
}
1445-
return;
1444+
};
1445+
self.map.defs.insert(hir_id, ResolvedArg::Error(guar));
1446+
} else {
1447+
self.map.defs.insert(hir_id, def);
14461448
}
1447-
1448-
self.map.defs.insert(hir_id, def);
14491449
return;
14501450
}
14511451

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(non_lifetime_binders)]
2+
//~^ WARN the feature `non_lifetime_binders` is incomplete
3+
4+
fn b()
5+
where
6+
for<const C: usize> [(); C]: Copy,
7+
//~^ ERROR cannot capture late-bound const parameter in a constant
8+
{
9+
}
10+
11+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/capture-late-ct-in-anon.rs:1:12
3+
|
4+
LL | #![feature(non_lifetime_binders)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error: cannot capture late-bound const parameter in a constant
11+
--> $DIR/capture-late-ct-in-anon.rs:6:30
12+
|
13+
LL | for<const C: usize> [(); C]: Copy,
14+
| -------------- ^
15+
| |
16+
| parameter defined here
17+
18+
error: aborting due to previous error; 1 warning emitted
19+

0 commit comments

Comments
 (0)