Uh oh!
There was an error while loading. Please reload this page.
Print the two types in the span label for transmute errors. - #42304
Conversation
rust-highfive
commented
May 29, 2017
(rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
at minimum, this should be {} and {} -- but it definitely feels like we can do better. If nothing else, these error messages are really long, and I think it'd be better to break it up in parts. Let me see if I can draft a suggestion.
nikomatsakis
commented
May 30, 2017
Maybe something like this? |
nikomatsakis
commented
May 30, 2017
cc @estebank |
estebank
commented
May 30, 2017
For the general case, I feel something along the lines of this would be ok: but I'd like to have a specific message for this case along the lines of For example, in fntakes_u8(_:u8){}fnmain(){unsafe{takes_u8(::std::mem::transmute(0u16));}}I feel the current output is relatively ok: and would look ridiculous under the above proposal: Because of all of this, I would check for the case where there's an unknown layout in the source and target. If they are, present my second proposed output, otherwise, @nikomatsakis proposed output. If both source and target are not of unknown layout, either have a single-line note or (my preference) keep the current label. Part of the problem here is that this is two different errors conceptually, the compiler knows in the last example that the types have different sizes, while the other case they might be of different sizes, so they warrant slightly different output. |
Mark-Simulacrum
commented
May 30, 2017
Hm, okay. I can't say I entirely follow the discussion quite right now, but I'll look into implementing things in this way soon. |
nikomatsakis
commented
May 30, 2017
@Mark-Simulacrum great let me know if you need anything |
estebank
commented
May 31, 2017
@Mark-Simulacrum It'd also be great if you also moved these tests to |
fwiw, I don't think that final version looks particularly ridiculous. In fact, I maybe slightly prefer it. I think in particular I'd like to migrate towards a version where the "main error message" is fairly generic, and the details are exposed elsewhere. I think a lot of times we try to pack too much info into the header. But we really need to try and schedule some time to draw up some overall guidelines in this respect. But I'm also happy with a special case. Don't care that much. |
There was a problem hiding this comment.
The span here was entirely not helpful as far as I can tell; but I'm open to re-adding it if there's disagreement.
There was a problem hiding this comment.
I'm not sure if there's much point to this branch myself; I can't come up with an example that would follow it.
There was a problem hiding this comment.
Should we change this error to also follow the same pattern of a simple header and notes to explain it?
There was a problem hiding this comment.
I think that would be best. The error text should be something like can't transmute zero-sized type.
Mark-Simulacrum
commented
May 31, 2017
Updated; left a few comments, let me know what you think. |
There was a problem hiding this comment.
I think that would be best. The error text should be something like can't transmute zero-sized type.
Mark-Simulacrum
commented
May 31, 2017
Updated the zero-sized case as well. |
There was a problem hiding this comment.
Nit: "called with types of different sizes" sounds more grammatical to me
nikomatsakis
commented
Jun 1, 2017
This looks good to me modulo the nit about the error message phrasing. |
Mark-Simulacrum
commented
Jun 1, 2017
@bors r=nikomatsakis Fixed the nit. |
bors
commented
Jun 1, 2017
📌 Commit e7b8935 has been approved by |
Mark-Simulacrum
commented
Jun 1, 2017
@bors rollup |
Mark-Simulacrum
commented
Jun 1, 2017
@bors r- I need to fix the UI tests to not be dependent on 32/64-bit (they use usize/isize). |
arielb1
commented
Jun 13, 2017
I think we might want to have tests only run on 32-bit or 64-bit architectures, and have separate paths for that. |
nikomatsakis
commented
Jun 14, 2017
certainly the short-term hack is just to have two tests, one for 32-bit and one for 64-bit? But I thought that the idea of being able to add custom "filters" into the |
Mark-Simulacrum
commented
Jun 14, 2017
Yeah, I hope to get around to adding the two tests later this week, I just need to figure out the specific syntax and what architectures I need to ignore. |
Also moves a few transmute tests to UI tests to better test their output.
7898f41 to
d09cf46CompareMark-Simulacrum
commented
Jun 18, 2017
I just ignored the tests on 32-bit targets. I personally don't know if it's worth testing on those, the tests are just for diagnostics. If we want 32 bit tests I'll spin up a VM to generate those tests. |
alexcrichton
commented
Jun 22, 2017
ping r? @nikomatsakis Or @rust-lang/compiler I think Niko's out of town, so if someone else can take a look that'd be great! |
nikomatsakis
commented
Jun 22, 2017
@bors r+ |
bors
commented
Jun 22, 2017
📌 Commit d09cf46 has been approved by |
nikomatsakis
commented
Jun 22, 2017
@bors r- |
nikomatsakis
commented
Jun 22, 2017
Actually, I have some mild reservations. I just want to be sure: are those tests checking anything important? e.g., do we have other tests that show that the size of points on 32-bit machines is correctly handled, etc? |
nikomatsakis
commented
Jun 22, 2017
I guess my question is -- are there other tests that test similar conditions and do run on 32-bit? |
Mark-Simulacrum
commented
Jun 22, 2017
Yes, there are tests (the compile-fail tests that this edits, but doesn't move to UI, for one) that test all cases as far as I can tell. If you'd like, we can wait on this (probably closing it for now) until we get some form of ERROR-x86 or something like that so we can properly test across both platforms easily. |
nikomatsakis
commented
Jun 22, 2017
@Mark-Simulacrum ok, cool :) |
nikomatsakis
commented
Jun 22, 2017
@bors r+ |
bors
commented
Jun 22, 2017
📌 Commit d09cf46 has been approved by |
Mark-Simulacrum
commented
Jun 22, 2017
@bors rollup- Since it failed CI last time. |
bors
commented
Jun 23, 2017
Print the two types in the span label for transmute errors. Fixes#37157. I'm not entirely happy with the changes here but overall it's better in my opinion; we certainly avoid the odd language in that issue, which changes to: ``` error[E0512]: transmute called with differently sized types: <C as TypeConstructor<'a>>::T (size can vary because of <C as TypeConstructor>::T) to <C as TypeConstructor<'b>>::T (size can vary because of <C as TypeConstructor>::T) --> test.rs:8:5 | 8 | ::std::mem::transmute(x) | ^^^^^^^^^^^^^^^^^^^^^ transmuting between <C as TypeConstructor<'a>>::T and <C as TypeConstructor<'b>>::T error: aborting due to previous error(s) ```
bors
commented
Jun 23, 2017
☀️ Test successful - status-appveyor, status-travis |
… r=nikomatsakis compilertest (UI test): Support custom normalization. Closes#42434. Adds this header for UI tests: ```rust // normalize-stderr-32bit: "fn() (32 bits)" -> "fn() ($PTR bits)" ``` It will normalize the `stderr` output on 32-bit platforms, by replacing all instances of `fn() (32 bits)` by `fn() ($PTR bits)`. Extends the UI tests in #42304 and #41968 to 32-bit targets. r? @nikomatsakis
… r=nikomatsakis compilertest (UI test): Support custom normalization. Closes#42434. Adds this header for UI tests: ```rust // normalize-stderr-32bit: "fn() (32 bits)" -> "fn() ($PTR bits)" ``` It will normalize the `stderr` output on 32-bit platforms, by replacing all instances of `fn() (32 bits)` by `fn() ($PTR bits)`. Extends the UI tests in #42304 and #41968 to 32-bit targets. r? @nikomatsakis
Fixes#37157. I'm not entirely happy with the changes here but overall it's better in my opinion; we certainly avoid the odd language in that issue, which changes to: