-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept strings as values of attributes #12467
Conversation
I'm pretty sure it does... Am I reading this correctly that it basically converts |
for attribute in attrs.iter() { | ||
match attribute.name_str_pair() { | ||
Some((ref key, ref value)) if key.equiv(&("lang")) => { | ||
// Raise error after snapshot landed | ||
//session.err(format!("`lang = {}` was replaced by `lang({})`", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be format!(" ... {0} ... {0}", *value)
to avoid the repeat.
I'm not sure how to use /// Bytewise slice equality
#[cfg(not(stage0))]
#[cfg(not(test))]
#[lang("str_eq")]
#[inline]
pub fn eq_slice(a: &str, b: &str) -> bool {
eq_slice_(a, b)
}
Yes, both forms are equivalent, both set the value of |
This will need to add support for I'm a little surprised that Regardless, though, I think that |
From the discussion in #11886 it wasn't entirely clear to me in which way quoted strings in attributes should be accepted. I'll update the code to generate name/value pairs for |
(General point: specifically for |
It seems like there is no real consensus on this issue. Is it valid for If the |
Lang items are I'm under the impression that we're changing all instances of I am personally unsure of whether we want |
We get to choose the names of the lang items, so we can choose them to always be valid identifiers. :) |
Don't want to derail this discussion, but the lang item syntax in particular was ill-chosen since lang items can easily be idents. |
Also, if #12538 gets merged then the impetus for this change is less since we'll be keeping the brackets. That doesn't mean we shouldn't do this change, but should probably step back and think about it again. |
We ended up deciding to close #11886 for now, so I'm going to close this as well. |
fix: Fix match to if let assist for wildcard pats
This patch is the first step to solve #11886. It allows quoted strings as values of attributes and uses this syntax for
lang
items, while keeping the old syntaxlang = "foo"
valid. I've created another branch, which changes alllang = "foo"
attributes tolang("foo")
, because this only works after this PR got merged and is in the current snapshot (It seems like #[cfg(stage0)] does not work any more). The relevant commit can be found in my fork: fhahn@41527f7With this patch, quoted strings are accepted as values of all attributes, not only for
lang
attributes, but I'm not sure if this is intended.Also, I want to add a few tests, because it seems like there are not tests for
lang
at the moment.