Rollup merge of #98499 - JulianKnodt:erase_lifetime, r=lcnr
Erase regions in New Abstract Consts When an abstract const is constructed, we previously included lifetimes in the set of substitutes, so it was not able to unify two abstract consts if their lifetimes did not match but the values did, despite the values not depending on the lifetimes. This caused code that should have compiled to not compile. Fixes #98452 r? ```@lcnr```
This commit is contained in:
commit
7b9a7ef218
2 changed files with 35 additions and 1 deletions
|
@ -236,7 +236,7 @@ impl<'tcx> AbstractConst<'tcx> {
|
|||
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
|
||||
let inner = tcx.thir_abstract_const_opt_const_arg(uv.def)?;
|
||||
debug!("AbstractConst::new({:?}) = {:?}", uv, inner);
|
||||
Ok(inner.map(|inner| AbstractConst { inner, substs: uv.substs }))
|
||||
Ok(inner.map(|inner| AbstractConst { inner, substs: tcx.erase_regions(uv.substs) }))
|
||||
}
|
||||
|
||||
pub fn from_const(
|
||||
|
@ -416,6 +416,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
|||
// `AbstractConst`s should not contain any promoteds as they require references which
|
||||
// are not allowed.
|
||||
assert_eq!(ct.promoted, None);
|
||||
assert_eq!(ct, self.tcx.erase_regions(ct));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue