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 upFixed-size byte string literals (RFC 339) #22838
Conversation
rust-highfive
assigned
alexcrichton
Feb 26, 2015
This comment has been minimized.
This comment has been minimized.
|
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
Notes:
|
This comment has been minimized.
This comment has been minimized.
|
I personally considered the breakage of this behavior to be a showstopper for the previous attempt: match foo {
b"foo" => { /* ... */ }
}Others may have a different opinion though! I'm also getting quite worried about how we're just spraying impls of traits for cc @nrc, @nikomatsakis on the coercions aspect, do we perhaps have any RFCs in the pipeline to help here? This relatively small change ended up having quite a large fallout! |
This comment has been minimized.
This comment has been minimized.
|
re coercions: There's nothing in the pipeline re coercions in matches - there was some RFC recently about array patterns in matches, but I think that makes things stricter. I'm not quite sure what it means to coerce in a pattern - if it means that |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton I don't think it's a showstopper for several reasons:
So, I'd like to land this PR until it's too late and to work on the fix for patterns independently of it (I currently study the implementation of pattern matching in the compiler). |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
Everything about fixed-size arrays feels not quite right until some form of rust-lang/rfcs#884 is implemented, but it doesn't mean that they should be second class citizens. In principle I can kill the new impls and spend some more time manually coercing |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton I think it's possible to remove some of the metadata bloat with the next trick (where the coherence rules allow it):
|
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov that's a pretty good idea! I like how it's turned out for fixed-size arrays. I'm not super happy that this has cc @aturon, I'm curious what you think about the ergonomic fall out here as well as the |
petrochenkov
referenced this pull request
Feb 27, 2015
Closed
Heterogeneous comparisons for Option #917
This comment has been minimized.
This comment has been minimized.
|
I think I know what to do with byte string literal patterns - they will behave exactly like array patterns - they will denote |
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov
force-pushed the
petrochenkov:bytelit
branch
from
4c7fc20
to
7625e38
Mar 9, 2015
This comment has been minimized.
This comment has been minimized.
|
Fixed byte string literal patterns and rebased |
This comment has been minimized.
This comment has been minimized.
|
Wow, nice work @petrochenkov! cc @aturon, I'm curious as to your opinion of |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton @petrochenkov Sorry for the delay giving feedback on this. I'm not too worried about In any case, I don't think we should hold up the PR just for that reason, since it's a minor impl detail that can be improved later on. |
This comment has been minimized.
This comment has been minimized.
|
@aturon while the trait itself remains stable, we are leaking stable functionality via the trait itself. Right now the stability pass does not consider the stability of an
I'm a little uncomfortable with the two and would prefer coercions to take over, but just want to confirm that you're on board with this information as well. |
This comment has been minimized.
This comment has been minimized.
What coercions exactly? I remember someone (maybe @japaric or @eddyb ?) proposing "impl lookup with coercions" - if we are not able to find an impl of trait |
This comment has been minimized.
This comment has been minimized.
|
@blaenk came up with that idea, I merely gave it a name (bound-targeting coercions). |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov yeah that's basically what I was thinking, although I'm not sure if it's actually plausible. I'm just wary of committing to providing impls for these traits for all these fixed size arrays. |
petrochenkov
referenced this pull request
Mar 14, 2015
Closed
Use generic io trait implementations for Cursor when possible #23364
petrochenkov
force-pushed the
petrochenkov:bytelit
branch
from
7625e38
to
a7e1c1d
Mar 17, 2015
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
Gah sorry about the delay on this @petrochenkov! I meant to discuss this with @aturon in more depth in the meantime, but we never got around to it :(. Due to the conservative nature of this, however, I'm fine landing this for now, thanks for being patient! As an aside, |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 17, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov
added some commits
Feb 26, 2015
petrochenkov
force-pushed the
petrochenkov:bytelit
branch
from
a7e1c1d
to
dccd17d
Mar 18, 2015
This comment has been minimized.
This comment has been minimized.
|
Fixed the failed test. @bors: r=alexcrichton dccd17d |
This comment has been minimized.
This comment has been minimized.
|
@bors: r+ dccd17d It does indeed work! It just has to come from a whitelist of reviewers :) |
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov commentedFeb 26, 2015
This patch changes the type of byte string literals from
&[u8]to&[u8; N].It also implements some necessary traits (
IntoBytes,Seek,Read,BufRead) for fixed-size arrays (also related to #21725) and adds test for #17233, which seems to be resolved.Fixes #18465
[breaking-change]