Add grmtools_section to ast - #665
Conversation
| let array_span = Span::new(start_span.start(), end_span.end()); | ||
| let mut out = Vec::with_capacity(v.capacity()); | ||
| for setting in v { | ||
| // To Call this function recursively we need to convert the `Setting<Span>` to a `HeaderValue<Span>` |
There was a problem hiding this comment.
Out of date comment, should be Value<Span>.
| test_string_span_start, | ||
| test_string_span_start + "test.string".len(), | ||
| ); | ||
| let test_string_val_span_start = src.find("Foo").unwrap(); |
There was a problem hiding this comment.
Noting that the span here seems to exclude the quotation marks.
| "cfgrammar.yacckind".to_string(), | ||
| ( | ||
| yacckind_span, | ||
| // The actual value we receive has been lower cased |
There was a problem hiding this comment.
At this point I'm perhaps regretting this case insensitivity of the rust values?
Note that we don't do it for string values so it doesn't apply to globbed filenames.
If we want to keep the case insensitivity, perhaps it is better to move it outside of the Header structure,
to the caller. It looks like key values are not case insensitive which would be harder to move out of the HashMap.
Edit: It looks like my checking for key case insensitivty was flawed, and they actually are case insensitive.
There was a problem hiding this comment.
Updated the test in 7f4847a to highlight the case insensitivity
There was a problem hiding this comment.
I have come, in my dotage, to prefer case sensitivity, so if we want to move to that, I'm all for it!
There was a problem hiding this comment.
The main issue is that I don't know how to do that without a change of behavior (at least for key names).
But it seems like it might be a good time to pull the band-aid off I don't think the case insensitivity has actually been advertised anywhere.
There was a problem hiding this comment.
I agree: we didn't commit and I think it's reasonable to assume it is case sensitive.
| s.push('('); | ||
| if let Some((arg_ns, _)) = arg_namespace { | ||
| s.push_str(&arg_ns); | ||
| s.push_str("::"); |
There was a problem hiding this comment.
Forgot to mention in the commit message this round of testing found two bugs in the RustLike values.
| ) | ||
| } | ||
|
|
||
| pub fn grmtools_section_values( |
There was a problem hiding this comment.
Do we need this given grmtools_section_values_for_crate? Maybe if we say "an empty crate name matches everything"?
There was a problem hiding this comment.
Suprisingly took me a couple of tries, to keep the return type the same.
Because the closure is a generic parameter to the filter iterator type, and closures are uniquely typed.
However should be fixed in 065ad66
There was a problem hiding this comment.
Hmm, I'd kind of like to perhaps think more about the way that crates query for these values.
The lingering question in my mind is "Can we somehow leverage the query mechanism so that downstream crates can enable the unused key checks" without a burdensome API?
This extensibility, and strict checking seem like conflicting goals, but I'm not really convinced yet that they are.
| "cfgrammar.yacckind".to_string(), | ||
| ( | ||
| yacckind_span, | ||
| // The actual value we receive has been lower cased |
There was a problem hiding this comment.
I have come, in my dotage, to prefer case sensitivity, so if we want to move to that, I'm all for it!
|
There is still one thing left to do before user values will be able to be added by downstream crates. But this seemed like a good stopping point for this patch? Edit: The above is not exactly correct, except when using the |
|
Point taken. Yes, I think this is a good stopping point. Ready to squash? |
|
I'd just like to think about, and perhaps play around with the thoughts in #665 (comment) first before we commit to this. My thought is mainly that if we had Now somehow we need to deal with the fact that Edit: Anyhow i'll think on it for a day or so, let me know whether you think it'd be worthwhile for catching errors, or too complex for the benefits it gives. One thing I think is that it seems like this would require lazily converting from Edit2: An alternate thought is just having a key registration mechanism Edit3: I think one way to expose the check is just changing the |
|
So, I think I've got a good plan for how this could work, the only issue I'm having is the We could avoid that if we added the It will probably make some errors worse, in the sense that if you have a bad If we choose not to do that it just means we have to return owned rather than borrowed values during lookup. Let me know if you want me to experiment with that? Edit: I hould probably note that I don't think there is much of an efficiency difference, we're probably just moving the clone from lookup time, to parse time. Because it is unlikely people ever do multiple lookups. Edit: I posted #666 as a experiment in switching |
This is a work in progress, it converts the
HeaderValueinto a simplified value type.As of this time the conversion of the
RustLikevalues (and their spans) is still largely untested.User specified values will still trigger a
Unused entryerror. This is all I had time for today, will work on that tomorrow.