Uh oh!
There was an error while loading. Please reload this page.
Propagate lifetime resolution errors into tcx.type_of - #69178
Conversation
rust-highfive
commented
Feb 15, 2020
(rust_highfive has picked a reviewer for you, use r? to override) |
bors
commented
Feb 15, 2020
☔ The latest upstream changes (presumably #67681) made this pull request unmergeable. Please resolve the merge conflicts. |
0ab312d to
bdb0794Compare
matthewjasper
left a comment
There was a problem hiding this comment.
So, I'm not convinced that this should be needed, lifetime resolution isn't handling OpaqueTy correctly because AST to HIR lowering is treating top level and nested impl Trait differeny. For example this will still incorrectly error:
#![feature(type_alias_impl_trait)]traitSomeTrait{}traitWithAssoc{typeAssocType;}impl<T: ?Sized>WithAssocforT{typeAssocType = ();}impl<T: ?Sized>SomeTraitforT{}typeReturn<'a> = implWithAssoc<AssocType = implSized + 'a>;fnmy_fun<'a>() -> Return<'a>{}fnmain(){}Uh oh!
There was an error while loading. Please reload this page.
Aaron1011
commented
Feb 16, 2020
@matthewjasper: You're right - there are still issues with lifetimes in nested opaque types (see #69137). This PR doesn't fix those errors - it just ensures that we properly bail out when errors do occur, since opaque type inference may implicitly assume that the opaque type has sane generics. |
bors
commented
Feb 17, 2020
☔ The latest upstream changes (presumably #67953) made this pull request unmergeable. Please resolve the merge conflicts. |
Fixesrust-lang#69136 Previously, lifetime resolution errors would cause an error to be emitted, but would not mark the parent type as 'tainted' in any way. We usually abort compilation before this becomes an issue - however, opaque types can cause us to type-check function bodies before such an abort occurs. Ths can result in trying to instantiate opaque types that have invalid computed generics. Currently, this only causes issues for nested opaque types, but there's no reason to expect the computed generics to be sane when we had unresolved lifetimes (which can result in extra lifetime parameters getting added to the generics). This commit tracks 'unresolved lifetime' errors that occur during lifetime resolution. When we type-check an item, we bail out and return `tcx.types.err` if a lifetime error was reported for that type. This causes us to skip type-checking of types affected by the lifetime error, while still checking unrelated types. Additionally, we now check for errors in 'parent' opaque types (if such a 'parent' exists) when collecting constraints for opaque types. This reflects the fact that opaque types inherit generics from 'parent' opaque types - if an error ocurred while type-checking the parent, we don't attempt to type-check the child.
e940496 to
50a3c38Comparebors
commented
Feb 27, 2020
☔ The latest upstream changes (presumably #69507) made this pull request unmergeable. Please resolve the merge conflicts. |
matthewjasper
commented
Mar 7, 2020
It should be OK to assume that lifetime resolution is producing sane results, if a lifetime cannot be resolved then not recording it will result in AST conv lowering it as The problem here is that lifetime resolution is recording |
Dylan-DPC-zz
commented
Apr 6, 2020
@Aaron1011 waiting for you to resolve the conflicts |
Dylan-DPC-zz
commented
Apr 14, 2020
Closing this due to inactivity |
Fixes#69136
Previously, lifetime resolution errors would cause an error to be
emitted, but would not mark the parent type as 'tainted' in any way.
We usually abort compilation before this becomes an issue - however,
opaque types can cause us to type-check function bodies before such an
abort occurs. Ths can result in trying to instantiate opaque types that
have invalid computed generics. Currently, this only causes issues for
nested opaque types, but there's no reason to expect the computed
generics to be sane when we had unresolved lifetimes (which can result
in extra lifetime parameters getting added to the generics).
This commit tracks 'unresolved lifetime' errors that occur during
lifetime resolution. When we type-check an item, we bail out and return
tcx.types.errif a lifetime error was reported for that type. Thiscauses us to skip type-checking of types affected by the lifetime error,
while still checking unrelated types.
Additionally, we now check for errors in 'parent' opaque types (if such
a 'parent' exists) when collecting constraints for opaque types. This
reflects the fact that opaque types inherit generics from 'parent'
opaque types - if an error ocurred while type-checking the parent,
we don't attempt to type-check the child.