Rollup merge of #102472 - lcnr:static-in-eval, r=jackh726
stop special-casing `'static` in evaluation fixes #102360 I have no idea whether this actually removed all places where `'static` matters. Without canonicalization it's very easy to accidentally rely on `'static` again. Blocked on changing the `order_dependent_trait_objects` future-compat lint to a hard error r? `@nikomatsakis`
This commit is contained in:
commit
4bd33fdb4a
7 changed files with 151 additions and 102 deletions
|
@ -43,18 +43,16 @@ pub struct TypeFreshener<'a, 'tcx> {
|
|||
const_freshen_count: u32,
|
||||
ty_freshen_map: FxHashMap<ty::InferTy, Ty<'tcx>>,
|
||||
const_freshen_map: FxHashMap<ty::InferConst<'tcx>, ty::Const<'tcx>>,
|
||||
keep_static: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'tcx>, keep_static: bool) -> TypeFreshener<'a, 'tcx> {
|
||||
pub fn new(infcx: &'a InferCtxt<'tcx>) -> TypeFreshener<'a, 'tcx> {
|
||||
TypeFreshener {
|
||||
infcx,
|
||||
ty_freshen_count: 0,
|
||||
const_freshen_count: 0,
|
||||
ty_freshen_map: Default::default(),
|
||||
const_freshen_map: Default::default(),
|
||||
keep_static,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,18 +119,9 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
|
|||
| ty::ReFree(_)
|
||||
| ty::ReVar(_)
|
||||
| ty::RePlaceholder(..)
|
||||
| ty::ReStatic
|
||||
| ty::ReError(_)
|
||||
| ty::ReErased => {
|
||||
// replace all free regions with 'erased
|
||||
self.interner().lifetimes.re_erased
|
||||
}
|
||||
ty::ReStatic => {
|
||||
if self.keep_static {
|
||||
r
|
||||
} else {
|
||||
self.interner().lifetimes.re_erased
|
||||
}
|
||||
}
|
||||
| ty::ReErased => self.interner().lifetimes.re_erased,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -713,12 +713,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}
|
||||
|
||||
pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'tcx> {
|
||||
freshen::TypeFreshener::new(self, false)
|
||||
}
|
||||
|
||||
/// Like `freshener`, but does not replace `'static` regions.
|
||||
pub fn freshener_keep_static<'b>(&'b self) -> TypeFreshener<'b, 'tcx> {
|
||||
freshen::TypeFreshener::new(self, true)
|
||||
freshen::TypeFreshener::new(self)
|
||||
}
|
||||
|
||||
pub fn unsolved_variables(&self) -> Vec<Ty<'tcx>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue