Rollup merge of #125667 - oli-obk:taintify, r=TaKO8Ki

Silence follow-up errors directly based on error types and regions

During type_of, we used to just return an error type if there were any errors encountered. This is problematic, because it means a struct declared as `struct Foo<'static>` will end up not finding any inherent or trait impls because those impl blocks' `Self` type will be `{type error}` instead of `Foo<'re_error>`. Now it's the latter, silencing nonsensical follow-up errors about `Foo` not having any methods.

Unfortunately that now allows for new follow-up errors, because borrowck treats `'re_error` as `'static`, causing nonsensical errors about non-error lifetimes not outliving `'static`. So what I also did was to just strip all outlives bounds that borrowck found, thus never letting it check them. There are probably more nuanced ways to do this, but I worried there would be other nonsensical errors if some outlives bounds were missing. Also from the test changes, it looked like an improvement everywhere.
This commit is contained in:
Michael Goulet 2024-06-04 08:52:12 -04:00 committed by GitHub
commit 5019bb608a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 271 additions and 297 deletions

View file

@ -502,7 +502,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
bug!("unexpected sort of node in type_of(): {:?}", x);
}
};
if let Err(e) = icx.check_tainted_by_errors() {
if let Err(e) = icx.check_tainted_by_errors()
&& !output.references_error()
{
ty::EarlyBinder::bind(Ty::new_error(tcx, e))
} else {
ty::EarlyBinder::bind(output)