@@ -231,17 +231,34 @@ struct VarianceExtractor<'a, 'tcx> {
231231impl < ' tcx > VarianceExtractor < ' _ , ' tcx > {
232232 fn record_variance ( & mut self , region : ty:: Region < ' tcx > , variance : ty:: Variance ) {
233233 // We're only interested in the variance of vars and free regions.
234+ //
235+ // Note: even if we currently bail for two cases of unexpected region kinds here, missing
236+ // variance data is not a soundness problem: the regions with missing variance will still be
237+ // present in the constraint graph as they are live, and liveness edges construction has a
238+ // fallback for this case.
239+ //
240+ // FIXME: that being said, we need to investigate these cases better to not ignore regions
241+ // in general.
242+ if region. is_bound ( ) {
243+ // We ignore these because they cannot be turned into the vids we need.
244+ return ;
245+ }
234246
235- if region. is_bound ( ) || region. is_erased ( ) {
236- // ignore these
247+ if region. is_erased ( ) {
248+ // These cannot be turned into a vid either, and we also ignore them: the fact that they
249+ // show up here looks like either an issue upstream or a combination with unexpectedly
250+ // continuing compilation too far when we're in a tainted by errors situation.
251+ //
252+ // FIXME: investigate the `generic_const_exprs` test that triggers this issue,
253+ // `ui/const-generics/generic_const_exprs/issue-97047-ice-2.rs`
237254 return ;
238255 }
239256
240257 let direction = match variance {
241- ty:: Variance :: Covariant => ConstraintDirection :: Forward ,
242- ty:: Variance :: Contravariant => ConstraintDirection :: Backward ,
243- ty:: Variance :: Invariant => ConstraintDirection :: Bidirectional ,
244- ty:: Variance :: Bivariant => {
258+ ty:: Covariant => ConstraintDirection :: Forward ,
259+ ty:: Contravariant => ConstraintDirection :: Backward ,
260+ ty:: Invariant => ConstraintDirection :: Bidirectional ,
261+ ty:: Bivariant => {
245262 // We don't add edges for bivariant cases.
246263 return ;
247264 }
0 commit comments