-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't use QueryNormalizer
to normalize in rustdoc
#102835
Don't use QueryNormalizer
to normalize in rustdoc
#102835
Conversation
r? @notriddle (rust-highfive has picked a reviewer for you, use r? to override) |
dd6039b
to
3a3bc23
Compare
3a3bc23
to
2964f15
Compare
@compiler-errors how does this interact with #82692 ? Does it still immediately give a fatal error when the type length limit is reached? Anyway, using a normalize method that panics less often is great, thanks :) rustdoc really wants to be able to recover from any kind of error when normalizing. Is the difference between these documented somewhere? |
Wait, I don't understand how these are related. Why would normalizing in one place affect the results of normalizing in another? How is skip_binders related? |
@jyn514, so I guess first I wanted to mention that One specific case where this can be frequently seen is However, we can normalize a type and its binder at the same type. By normalizing the whole signature first, we normalize the associated type within the binder its debruijn indices actually point to. So we end up doing something like The underlying issue is that this |
Can you explain a bit more? That's a tracking issue, not a specific error I can test. |
#102038 is the test; currently it gives a fatal error on overflow instead of silently continuing.
Ok. How hard would that be to change? I'd rather not try to work around it in rustdoc. |
Pretty hard. It's only coincidental that the old normalization call rustdoc was using didn't ICE with escaping bound vars, since that normalize call has its own hack -- however, rustdoc is fundamentally using the normalize call in a way that it shouldn't, so I do think it's rustdoc's responsibility to work around it. |
What does "ways it shouldn't" mean here? |
"shouldn't" means that It's like going from |
☔ The latest upstream changes (presumably #102850) made this pull request unmergeable. Please resolve the merge conflicts. |
The change in #102858 is a bit more conservative approach if we don't want to move to using |
How bad would it be to create wrappers for those functions in rustdoc that immediately normalize the result, then change all the other spots to call the wrappers? |
(I'm still not convinced that's the best approach; if you can give me a day or two to look at this I'll try and get back to you by then.) |
I actually agree with @notriddle that that would be the ideal solution, but that's quite a lot of work. Anything we get from |
I like making progress here more than what was done in #102858 |
@oli-obk, we still have legitimate issues with this
... in non-rustdoc code that this PR does not fix (#103181), though. I actually am not really a fan of this approach compared to #102858, which is both simpler and more general 🤔 |
Hmm, but that one is already erroring, so we could even just delay span bug and return NoSolution at the Tho we could go with your other PR and track the other future rustdoc cleanups proposed here in an issue. I don't have a strong opinion, so let's close this one and I'llvm approve the other one, the impl lgtm. |
yeet |
The
QueryNormalizer
, which is what rustdoc was using to normalize its types, has a note:In Rustdoc, this is currently not true -- it will gladly accept programs that aren't completely correct (see issue that this PR fixes #102827). This causes an ICE currently, because the normalizer doesn't currently handle normalization ambiguity correctly.
So let's use another normalization scheme, namely
fully_normalize
, to normalize types in rustdoc. It's slightly different in semantics, like how it doesn't allow escaping bound vars, so I added an extra normalization call in one place where we're pretty blatantly skipping binders. More normalize calls may need to be added in other places before we callskip_binder
.Alternatively, I could just revert 7808f69, which caused this ICE. It's not clear that that's a better solution than this, since @lcnr's PR actually did signal a shortcoming in the current normalize call -- we don't really have a way to signal failures due to ambiguity, since right now all we return is a
Result<T, NoSolution>
.