| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| 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>.
Sorry, something went wrong.
There was a problem hiding this comment.
Should be fixed in 4200d44
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
| "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.
Sorry, something went wrong.
There was a problem hiding this comment.
Updated the test in 7f4847a to highlight the case insensitivity
Sorry, something went wrong.
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!
Sorry, something went wrong.
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.
Sorry, something went wrong.
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.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
| ) | ||
| } | ||
|
|
||
| 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"?
Sorry, something went wrong.
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
Sorry, something went wrong.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
I'm fine with taking our time.
Sorry, something went wrong.
| "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!
Sorry, something went wrong.
|
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 CTBuilder construction method. |
Sorry, something went wrong.
|
Point taken. Yes, I think this is a good stopping point. Ready to squash? |
Sorry, something went wrong.
|
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 grmtools_section_value_for_crate("cratename", "key") that could mark the key as used. Where the current API grmtools_section_values_for_crate we can't really tell if any specific key is used or not. Now somehow we need to deal with the fact that nimbleparse and ctbuilder don't know about downstream crates. 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 Header<Span> rather than the eager conversion to HashMap<String, GrmtoolsSectionValue> because Header is what contains the mark_used ability. Edit2: An alternate thought is just having a key registration mechanism register_key_for_crate(crate, key) separate from the query mechanism. That would allow us to complain if keys were unregistered. Edit3: I think one way to expose the check is just changing the Header.check_unused_header_keys to check_unused_header_keys_for_crate(crate). |
Sorry, something went wrong.
|
So, I think I've got a good plan for how this could work, the only issue I'm having is the HeaderValue -> GrmtoolsSectionValue conversion makes us return owned GrmtoolsSectionValue types. When calling the lookup and doing the conversion lazily then, we end up cloning the value at lookup time for the conversion. We could avoid that if we added the Span/Location generic to GrmtoolsSectionValue, and switched internally from HeaderValue<Span> to the simpler type GrmtoolsSectionValue<Span>. I believe that is possible anyways, but probably we'd want to do first as a separate patch if we're interested in doing it. It will probably make some errors worse, in the sense that if you have a bad yacckind: Original(AnUnrecognizedActionKind) we'd basically be attributing this to a bad GrmtoolsSectionValue::RustLike("Original(AnUnrecognizedActionKind)") so it would call out the yacckind rather than the YaccOriginalActionKind as the problem. 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 HeaderValue to use the GrmtoolsSectionValue type. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is a work in progress, it converts the HeaderValue into a simplified value type.
As of this time the conversion of the RustLike values (and their spans) is still largely untested.
User specified values will still trigger a Unused entry error. This is all I had time for today, will work on that tomorrow.