Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2466,6 +2466,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// result in a non-infer in hir typeck but a region variable in borrowck.
if tcx.features().generic_const_parameter_types()
&& (ty.has_free_regions() || ty.has_erased_regions())
|| ty.has_infer_regions()
{
let e = self.dcx().span_err(
const_arg.span,
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/const-generics/mgca/region_vars_hashed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! Regression test for https://github.com/rust-lang/rust/issues/157147.
//!
//! It used to ICE when trying to process region vars in const arguments,
//! Since it tries to hash intentionally un-hashable `ReVar` inference var.
//@ compile-flags: --crate-type=lib
//@ incremental
#![feature(min_generic_const_args)]

fn foo<const N: usize>() {
foo::<{ Some::<&u8> { 0: const { &0_u8 } } }>()
//~^ ERROR: anonymous constants with lifetimes in their type are not yet supported
}
8 changes: 8 additions & 0 deletions tests/ui/const-generics/mgca/region_vars_hashed.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: anonymous constants with lifetimes in their type are not yet supported
--> $DIR/region_vars_hashed.rs:11:30
|
LL | foo::<{ Some::<&u8> { 0: const { &0_u8 } } }>()
| ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Loading