-
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
Pretty-print inherent projections correctly #111486
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
This comment was marked as outdated.
This comment was marked as outdated.
596e476
to
79f2c1f
Compare
I've changed the approach (over at fmease#4, you can see an explanation why the previous one wasn't correct). |
This comment has been minimized.
This comment has been minimized.
@@ -2821,7 +2838,11 @@ define_print_and_forward_display! { | |||
} | |||
|
|||
ty::AliasTy<'tcx> { | |||
p!(print_def_path(self.def_id, self.substs)); | |||
if let DefKind::Impl { of_trait: false } = cx.tcx().def_kind(cx.tcx().parent(self.def_id)) { |
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.
I'm no longer using AliasTy::kind()
here since it ICEs on AssocConst
s (see the rust-long-analyzer above). AliasTy
s can actually be AssocConst
s to represent associated const projections even though it's not really documented anywhere as I assume it to be a temporary hack to make #![feature(associated_const_equality)]
work until AliasTerm
is introduced.
Alright, now it should be ready for review! Apologies for the spam. I've added some If those cases are ever reached (which I don't believe) the proper solution would be to uplift |
r=me after writing a more readable commit message |
@rustbot ready |
@bors r+ |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#111427 ([rustdoc][JSON] Use exclusively externally tagged enums in the JSON representation) - rust-lang#111486 (Pretty-print inherent projections correctly) - rust-lang#111722 (Document stack-protector option) - rust-lang#111761 (fix(resolve): not defined `extern crate shadow_name`) - rust-lang#111845 (Update books) - rust-lang#111851 (CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)) - rust-lang#111871 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
…er-errors Add regression tests for pretty-printing inherent projections Tests for rust-lang#111486. Fixes rust-lang#111879. r? `@matthiaskrgr`
Previously, we were trying to pretty-print inherent projections with
Printer::print_def_path
which is incorrect sinceit expects the substitutions to be of a certain format (parents substs followed by own substs) which doesn't hold for
inherent projections (self type subst followed by own substs).
Now we print inherent projections manually.
Fixes #111390.
Fixes #111397.
Lacking tests! Is there a test suite / compiletest flags for the pretty-printer? In most if not all cases,
inherent projections are normalized away before they get the chance to appear in diagnostics.
If I were to create regression tests for linked issues, they would need to be
mir-opt
tests to exercise-Zdump-mir=all
(right?) which doesn't feel quite adequate to me.@rustbot label F-inherent_associated_types