Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDeref coercions do not work with blocks #26978
Comments
This comment has been minimized.
This comment has been minimized.
|
CC @nrc |
Gankro
added
the
A-typesystem
label
Jul 11, 2015
This comment has been minimized.
This comment has been minimized.
|
As some users have discovered, |
nrc
changed the title
Auto-deref does not work with blocks
Deref coercions do not work with blocks
Jul 12, 2015
This comment has been minimized.
This comment has been minimized.
|
I suspect this is something specific to deref coercions. I think it is 'just a bug', but I don't know how easy it is to fix. |
barosl
referenced this issue
Aug 3, 2015
Open
Borrow checker gets confused with a mutable pointer which should be moved #27487
This comment has been minimized.
This comment has been minimized.
|
This blocks usage of
|
This comment has been minimized.
This comment has been minimized.
|
@tbu- Yup, actually this issue was found by a Stack Overflow question that tried the same thing. |
This comment has been minimized.
This comment has been minimized.
|
There is also this rust-users thread with a very similar problem. |
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated |
rust-highfive
added
the
I-nominated
label
Sep 21, 2015
This comment has been minimized.
This comment has been minimized.
|
triaged because it is such an annoying bug. Recommend p-medium. |
nrc
added
the
T-compiler
label
Sep 21, 2015
This comment has been minimized.
This comment has been minimized.
|
cc @eddyb |
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium |
rust-highfive
added
P-medium
and removed
I-nominated
labels
Oct 1, 2015
This comment has been minimized.
This comment has been minimized.
|
It would be very helpful to point out the error, which is: <anon>:8:9: 8:10 error: mismatched types:
expected `str`,
found `collections::string::String`
(expected str,
found struct `collections::string::String`) [E0308]
<anon>:8 f(&{x}); // Error
^So the problem could be that |
gifnksm
referenced this issue
Nov 2, 2015
Closed
power_assert! does not behave like assert! with deref coercion #4
This comment has been minimized.
This comment has been minimized.
|
Update: That was dumb of me: I did not realize this only ever happens with |
barosl commentedJul 11, 2015
It seems that the compiler handles a block differently when coercing a value.
RFC 401 says that a block with type
Uis also a target for coercion, so I think this behavior is a bug.Also, the compiler seems to be able to coerce blocks using some "trivial" rules (e.g.
&mut T->&T).So I guess this is more likely a problem of auto-deref.