Since bincode is unmaintained use wincode instead.#646
Conversation
| ) | ||
| // We have to call reconstitute like this because the config parameter takes a trait | ||
| // which uses const generics. Thus the two config parameters here are not actually of the same type. | ||
| match __ENCODING_CONFIG { |
|
This was tested with local versions of all the crates using the following Cargo.toml |
| + Hash | ||
| + PrimInt | ||
| + SchemaWrite<FixIntConfig, Src = LexerTypesT::StorageT> | ||
| + SchemaWrite<VarIntConfig, Src = LexerTypesT::StorageT> |
There was a problem hiding this comment.
It is a bit unfortunate, but as far as I can tell it doesn't appear that we can just do something like:
LexerTypesT::StorageT: SchemaWrite<Config, Src = LexerTypesT::StorageT> + ...;
Config: for<c: wincode::config::Config>, c,
Because higher ranked trait bounds are limited to lifetimes.
Config here is also not dyn compatible because of the associated types and consts.
So if there are other wincode configurations we do want to try encoding with afaik we have to add a bounds
here for each of those.
|
Working on the follow up commit that configures encoding between variable, and fixed... |
ratmice
left a comment
There was a problem hiding this comment.
Still needs some work to prepare it for follow up patches.
| visibility: Visibility::Private, | ||
| rust_edition: RustEdition::Rust2021, | ||
| inspect_rt: None, | ||
| encoding_config: EncodingConfiguration::VariableSizedInteger, |
There was a problem hiding this comment.
Should be None at this point like yacckind and recoverer, above.
Otherwise we can't differentiate between the default value, and user having set it.
There was a problem hiding this comment.
I went ahead and fixed this in f0da9ba
Which contains the whole configuration scheme, I did some looking at the generated sources,
and the variable in encoding files are both about half the size of the fixed int encodings,
but the fixed int encodings should should load faster.
If we don't want that, parts of the first patch can be simplified (Like the multiple Schema bounds on different configurations)
|
@ratmice Let me handle vob and sparsevec to save you the effort, |
|
Woops, think I might have already pushed to my branch, but feel free. |
|
🤞 other than version bumping, I think this one is ready for being looked at whenever you've got time. |
|
I'm working my way through. I must admit that I didn't anticipate wincode having quite such an impact! Still, this is definitely the right thing to do. |
|
I have a few minor comments and one bikeshed: do we think it's obvious what "encoding_config" will be to users? I'm somewhat neutral on this: I did wonder if "serialisation_format" (ok, ok, I could live with a "z" in there :)) might be clearer, but I'm not sure. |
|
I think all of the necessary dependencies are now on crates.io. |
|
I went with SerialisationFormat in 2822302 so at least we're consistently british spelling! |
| } | ||
|
|
||
| impl<T> Value<T> { | ||
| pub fn primary_location(&self) -> &T { |
There was a problem hiding this comment.
This is a pretty awkward API, the thing going on is that we've parameterized between
logical locations (command line arguments in nimbleparse, builder parameters in CTParserBuilder, and source locations read from %grmtools sections).
In the first two cases we have Value<Span> while in the second we have Value<Location>.
We could return a Vec<T> where T: Clone here, but in all the Value<Location> areas, this is going to be extremely unhelpful, and in the Span case, PrimaryLocation will still return at least one relevant location.
So we may drop some information regarding source locations when dealing with Span,
but we also avoid emitting redundant locations, when all those locations are like CommandLine
There was a problem hiding this comment.
So, it's kind of like we're either going to have this information loss, where we drop "secondary" locations,
or we're going to have a bunch of redundancy. So I think picking one of the locations is ok.
There was a problem hiding this comment.
Since we've got a major version bump coming up, we could consider an API change if it would help?
There was a problem hiding this comment.
I hadn't given it a whole lot of thought, In that the whole mixing of spans and logical error locations is kind of new territory for me, so I've kind of been winging it. One thing we could consider is the way that the AST Value<T> is currently an enum which has the pair of e.g. String, and Span, but also String, and Location.
We could consider making it a
enum Setting {
Num(u64, usize)
Flag(bool, usize),
Array(Vec<Setting>, usize, usize)
}
struct ValueRepr<T> {
value: Value,
locations: Vec<T>
}
With that the Location::CommandLine and Location::Other("From<...>") could just push one location on the locations stack, and we'd use the usize indexes to point to that one location.
With spans, each of these could refer to different locations on the locations stack.
I think one of the questions is whether we could get the lrpar/cttests/grmtools_section.test to emit that structure.
Because we test that the AST structure is exactly the same for the handwritten parser, and the generated parser in the testsuite. It's hard for me to imagine how this structure representation could be emitted from the generated parser's rules. I'll try and give it a think overnight.
There was a problem hiding this comment.
Hmm, perhaps the current muddle is the best we can do right now.
There was a problem hiding this comment.
Well, I did think of one more place that could be cleaned up in e8a5dab, Edit: the other thing to note is that this is all #[doc(hidden)] too.
|
Also let me know if you want me to split this one back into two separate PRs. I'm pretty sure though now that isn't the case. |
Sorry :) |
|
I'm fine with this as one PR. |
|
I think this is ready for squashing? |
Ports the bincode parser data serialistion to wincode, bumps the depdencencies, and renames the bincode feature to wincode.
|
Squashed, but unfortunately while I was almost done rebasing, I noticed a pesky line that shouldn't be there (but was actually inconsequential because of the way Plus I apparently accidentally rebased on top of current master, rather than what I originally based the patch on. Edit: Actually I may have introduced one issue in the squash accidentally. |
|
Alright, squashed correctly this time. |
|
Before we consider making a release: since we've got a major release bump coming, is there anything else breaking we want to include? |
|
I'm pretty much heads down in another project, and don't really have any API breaking changes that would be helpful paged in. With the intent of eventually having rust-analyzer I don't know how the rust-analyzer aspects will work, but we probably don't need that figured out to get grmtools in shape for it. |
I would love this! Do you think it would require breaking changes? Do you have a rough sense fo how one might go about it? |
|
My hope was to try and do it without breaking changes, by adding a new module, If only to avoid introducing more API surface to CTParserBuilder, which it seems good to keep as the primary API for cargo/ Edit: One thing we could do is consider a separate builder-like API just for configuring, which would largely mirror the configuration aspects of |
This is the final patch in the series, this should fix #616. Serialization with our complex bounds is quite a bit less straight forward with
wincodethan it was withbincode. Because theConfigurationis parameterized in the serialization bounds.Thus we end up having to put bounds on multiple serialization configurations in order to serialize data with that configuration.
At least that was the only way I could figure out how to implement it.
This doesn't provide any
CTParserBuildermechanisms for configuring the encoding used, so it currently always defaults to theVarIntencoding, but the plumbing is all there to do so.This is part of a series of patches to various crates moving from the bincode crate to the wincode crate.
I believe the reverse order of dependencies is:
I'm currently leaving how we want to deal with semver up in the air. Since these do change trait impls around,
It may be that as we release these we need to fiddle with the version numbers in
Cargo.tomltoo.