Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to be clear I understand, because I understood something different from your text.
ownerhere is== def.did, and thus invokingthir_check_unsafetyon that will obviously cycle?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's not the problem. Let me illustrate with an example:
We're trying to compute unsafeck for
closure, which should invoke unsafeck for the parent bodyfunction. Sodef.didis the DefId of the closure, and the HIR is constructed in such a way that the corresponding HirId hasfunctionas its owner, so in the codeowneris the DefId offunctionwhich id correct.Enter consts:
Here, if I try the same "hack", i.e. get the HirId for the closure and take its owner, I get
ownerto be the DefId offunctionwhereas I want the DefId of the anonymous constant{ || {}; 4 }.To be fair I don't entirely understand which query invocations cycle and which don't when using
ensure, and I've also not dived into the internals of HIR to check thatenclosing_body_owneralways does the right thing, but this PR doesn't cycle on the examples provided in #87414 and passed the rest of the test suite.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your explanation makes sense, thanks! I do think we should get a more solid strategy around all this, but I think it kind of overlaps with various other things like generics in anonymous constants. So let's merge this PR now