Do not freshen ReError
This commit is contained in:
parent
b63223c152
commit
ed16ae851b
4 changed files with 60 additions and 18 deletions
|
|
@ -110,17 +110,16 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
|
|||
|
||||
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
|
||||
match r.kind() {
|
||||
ty::ReBound(..) => {
|
||||
// leave bound regions alone
|
||||
r
|
||||
}
|
||||
// Leave bound regions alone, since they affect selection via the leak check.
|
||||
ty::ReBound(..) => r,
|
||||
// Leave error regions alone, since they affect selection b/c of incompleteness.
|
||||
ty::ReError(_) => r,
|
||||
|
||||
ty::ReEarlyParam(..)
|
||||
| ty::ReLateParam(_)
|
||||
| ty::ReVar(_)
|
||||
| ty::RePlaceholder(..)
|
||||
| ty::ReStatic
|
||||
| ty::ReError(_)
|
||||
| ty::ReErased => self.cx().lifetimes.re_erased,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
//@ known-bug: #132882
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
pub trait Numoid
|
||||
where
|
||||
for<N: Numoid> &'a Self: Add<Self>,
|
||||
{
|
||||
}
|
||||
|
||||
pub fn compute<N: Numoid>(a: N) -> N {
|
||||
&a + a
|
||||
}
|
||||
23
tests/ui/traits/eval-caching-error-region.rs
Normal file
23
tests/ui/traits/eval-caching-error-region.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Regression test for #132882.
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
pub trait Numoid: Sized
|
||||
where
|
||||
&'missing Self: Add<Self>,
|
||||
//~^ ERROR use of undeclared lifetime name `'missing`
|
||||
{
|
||||
}
|
||||
|
||||
// Proving `N: Numoid`'s well-formedness causes us to have to prove `&'missing N: Add<N>`.
|
||||
// Since `'missing` is a region error, that will lead to us consider the predicate to hold,
|
||||
// since it references errors. Since the freshener turns error regions into fresh regions,
|
||||
// this means that subsequent lookups of `&'?0 N: Add<N>` will also hit this cache entry
|
||||
// even if candidate assembly can't assemble anything for `&'?0 N: Add<?1>` anyways. This
|
||||
// led to an ICE.
|
||||
pub fn compute<N: Numoid>(a: N) {
|
||||
let _ = &a + a;
|
||||
//~^ ERROR cannot add `N` to `&N`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
33
tests/ui/traits/eval-caching-error-region.stderr
Normal file
33
tests/ui/traits/eval-caching-error-region.stderr
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
error[E0261]: use of undeclared lifetime name `'missing`
|
||||
--> $DIR/eval-caching-error-region.rs:7:6
|
||||
|
|
||||
LL | &'missing Self: Add<Self>,
|
||||
| ^^^^^^^^ undeclared lifetime
|
||||
|
|
||||
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
||||
help: consider making the bound lifetime-generic with a new `'missing` lifetime
|
||||
|
|
||||
LL | for<'missing> &'missing Self: Add<Self>,
|
||||
| +++++++++++++
|
||||
help: consider introducing lifetime `'missing` here
|
||||
|
|
||||
LL | pub trait Numoid<'missing>: Sized
|
||||
| ++++++++++
|
||||
|
||||
error[E0369]: cannot add `N` to `&N`
|
||||
--> $DIR/eval-caching-error-region.rs:19:16
|
||||
|
|
||||
LL | let _ = &a + a;
|
||||
| -- ^ - N
|
||||
| |
|
||||
| &N
|
||||
|
|
||||
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
||||
|
|
||||
LL | pub fn compute<N: Numoid>(a: N) where &N: Add<N> {
|
||||
| ++++++++++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0261, E0369.
|
||||
For more information about an error, try `rustc --explain E0261`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue