diff options
| author | b-naber <b_naber@gmx.de> | 2023-03-07 12:44:31 +0000 |
|---|---|---|
| committer | b-naber <b_naber@gmx.de> | 2023-03-22 16:59:41 +0000 |
| commit | da0fe80137e59708ca809f1a7e0e89e62e3ffcda (patch) | |
| tree | f8c84afd2c8afc1c2cb108429e4d5b18bb25f00a /compiler/rustc_borrowck/src | |
| parent | 439292bc7913399e406d9bb7e8da0f70c6317c6e (diff) | |
| download | rust-da0fe80137e59708ca809f1a7e0e89e62e3ffcda.tar.gz rust-da0fe80137e59708ca809f1a7e0e89e62e3ffcda.zip | |
assertion for only collection nll region variable information for debug in non-canonicalization contexts
Diffstat (limited to 'compiler/rustc_borrowck/src')
| -rw-r--r-- | compiler/rustc_borrowck/src/lib.rs | 18 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/relate_tys.rs | 18 |
2 files changed, 12 insertions, 24 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 5e77f6b190a..80c7bfaf396 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -511,16 +511,11 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> { .as_var() .unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region)); - if cfg!(debug_assertions) { + if cfg!(debug_assertions) && !self.inside_canonicalization_ctxt() { debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin); let ctxt = get_ctxt_fn(); let mut var_to_origin = self.reg_var_to_origin.borrow_mut(); - let prev = var_to_origin.insert(vid, ctxt); - - // This only makes sense if not called in a canonicalization context. If this - // ever changes we either want to get rid of `BorrowckInferContext::reg_var_to_origin` - // or modify how we track nll region vars for that map. - assert!(matches!(prev, None)); + var_to_origin.insert(vid, ctxt); } next_region @@ -540,16 +535,11 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> { .as_var() .unwrap_or_else(|| bug!("expected RegionKind::RegionVar on {:?}", next_region)); - if cfg!(debug_assertions) { + if cfg!(debug_assertions) && !self.inside_canonicalization_ctxt() { debug!("inserting vid {:?} with origin {:?} into var_to_origin", vid, origin); let ctxt = get_ctxt_fn(); let mut var_to_origin = self.reg_var_to_origin.borrow_mut(); - let prev = var_to_origin.insert(vid, ctxt); - - // This only makes sense if not called in a canonicalization context. If this - // ever changes we either want to get rid of `BorrowckInferContext::reg_var_to_origin` - // or modify how we track nll region vars for that map. - assert!(matches!(prev, None)); + var_to_origin.insert(vid, ctxt); } next_region diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs index d96372fb99b..305e2c8fe8e 100644 --- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs +++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs @@ -132,9 +132,12 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> let reg_var = reg.as_var().unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg)); - let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut(); - let prev = var_to_origin.insert(reg_var, RegionCtxt::Placeholder(reg_info)); - assert!(matches!(prev, None)); + + if cfg!(debug_assertions) && !self.type_checker.infcx.inside_canonicalization_ctxt() { + let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut(); + debug!(?reg_var); + var_to_origin.insert(reg_var, RegionCtxt::Placeholder(reg_info)); + } reg } @@ -149,14 +152,9 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> let reg_var = reg.as_var().unwrap_or_else(|| bug!("expected region {:?} to be of kind ReVar", reg)); - if cfg!(debug_assertions) { + if cfg!(debug_assertions) && !self.type_checker.infcx.inside_canonicalization_ctxt() { let mut var_to_origin = self.type_checker.infcx.reg_var_to_origin.borrow_mut(); - let prev = var_to_origin.insert(reg_var, RegionCtxt::Existential(None)); - - // It only makes sense to track region vars in non-canonicalization contexts. If this - // ever changes we either want to get rid of `BorrowckInferContext::reg_var_to_origin` - // or modify how we track nll region vars for that map. - assert!(matches!(prev, None)); + var_to_origin.insert(reg_var, RegionCtxt::Existential(None)); } reg |
