Uh oh!
There was an error while loading. Please reload this page.
Display raw pointer as *{mut,const} T instead of *-ptr in errors - #99517
Conversation
rust-highfive
commented
Jul 20, 2022
r? @wesleywiser (rust-highfive has picked a reviewer for you, use r? to override) |
wesleywiser
commented
Jul 21, 2022
This seems reasonable to me, but I'm unsure if there's an existing convention here that we are trying to move towards. @estebank@compiler-errors how do you feel about saying |
estebank
commented
Jul 21, 2022
I'm ok with calling them by name, but it'd be lovely if we did the same thing we do for references and mention what type they are a pointer for. |
raw pointer instead of *-ptr in errorsNoratrieb
commented
Jul 27, 2022
That's a great idea, especially since it's trivial to implement. So I did that. |
Noratrieb
commented
Aug 14, 2022
@estebank@compiler-errors is this good now? |
compiler-errors
left a comment
There was a problem hiding this comment.
Looks good, r=me with one nit
Uh oh!
There was an error while loading. Please reload this page.
compiler-errors
commented
Aug 14, 2022
r? @compiler-errors |
bors
commented
Aug 14, 2022
✌️ @Nilstrieb can now approve this pull request |
9e539d3 to
860ba27CompareUh oh!
There was an error while loading. Please reload this page.
860ba27 to
2806cf4CompareThere was a problem hiding this comment.
I think this works
| let tymut_string = match tymut.mutbl{ | |
| hir::Mutability::Mut => tymut.to_string(), | |
| hir::Mutability::Not => format!("const {}", tymut.ty), | |
| }; | |
| if tymut_string != "_" && tymut.ty.is_simple_text(){ | |
| format!("`*{}`", tymut_string).into() | |
| if tymut.ty.is_simple_text(){ | |
| self.to_string() |
I also wonder if we should change the code below for ty::Ref to match
There was a problem hiding this comment.
I could try it out tomorrow if you want to
There was a problem hiding this comment.
It would be pretty bad, the length check is really needed here:
- | expected `&T`, found type parameter `T`+ | expected reference, found type parameter `T`- | ---------- ^ expected `&dyn Trait`, found struct `Box`+ | ---------- ^ expected reference, found struct `Box`There was a problem hiding this comment.
I'm not sure if I understand how removing the length check causes &T to be rendered as "reference"
There was a problem hiding this comment.
oh, it's because ty is not considered simple_text... ugh
There was a problem hiding this comment.
Could we modify the logic to make a ref dyn Trait be considered "simple"?
Edit: all it would take is adding a match arm in is_simple_ty to handle Dynamic in the same way we handle Adt in is_simple_text.
There was a problem hiding this comment.
it's more complex than that, since a Dynamic is a List<Binder<ExistentialPredicate>>
I also think that having the length check is nicer than the is_simple_ty check, since this exists to avoid bloating the output, so a length check will always be more accurate than a type complexity check.
There was a problem hiding this comment.
Length check is fine then. As a final follow-up, is it possible to make the & and * printing logic as similar as possible?
There was a problem hiding this comment.
raw pointer is a little too short for the length check imo. I'll use const raw pointer, even though that is not actually used, but since the type will have a const prefix for the pointer, that seems fair
compiler-errors
commented
Aug 20, 2022
r=me with the last comment or not @bors delegate+ |
bors
commented
Aug 20, 2022
✌️ @Nilstrieb can now approve this pull request |
2806cf4 to
4e8e49eCompareThe `*-ptr` is rather confusing, and we have the full information for properly displaying the information.
4e8e49e to
5021dcdComparecompiler-errors
commented
Aug 30, 2022
Thanks nils @bors r+ |
bors
commented
Aug 30, 2022
Rollup of 5 pull requests Successful merges: - rust-lang#99517 (Display raw pointer as *{mut,const} T instead of *-ptr in errors) - rust-lang#99928 (Do not leak type variables from opaque type relation) - rust-lang#100473 (Attempt to normalize `FnDef` signature in `InferCtxt::cmp`) - rust-lang#100653 (Move the cast_float_to_int fallback code to GCC) - rust-lang#100941 (Point at the string inside literal and mention if we need string inte…) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The
*-ptris rather confusing, and we have the full information for properly displaying the information.