Hey. Sometimes we need a String but all we have is a string literal (an &'static str). I mean, I think we've all seen eye-searing code filled with "this".to_string(), "that".to_owned(), or String::from("theother").
OMG somebody just do something about it.
Introducing S, the three-char solution to Rust's stupidest papercut.
I also created a single letter function, B, for byte string literals, but for a different reason: byte string literals have type &'static [u8; N] (where as normal string literals have type &'static str). This leads to all sorts of inconvenience when using them.
AFAIK the most important non-obvious detail covered in these threads is that adding new prefixes is technically a breaking change for reasons involving macros that I don't understand, though editions/epochs probably solve that.
IIUC, there's no deep reason why we haven't done any of these, other than no one considered "the string literal problem" to be a top 5 ergonomic headache during the ergonomics initiative, so most of that consensus-building effort went towards other language changes like editions/epochs, the module system reform, and non-lexical lifetimes (which is pretty hard to disagree with).
If we make a macro like that, then adding the S"..." syntax will break it, making it an error because it would be ambiguous which we're referring to with the S, and macros are generally very stubborn about these kinds of things so wiggle room is not readily available. Take the following example:
And therefore, if S"..." strings are introduced, then that will mean that any macros that depended on S$x:literal matching S"abc" will be broken because the S"abc" will now try to match a literal.
While this is true, it's also true that breaking changes like this have happened before post rustc 1.0, and the impact was managed by building (a subset of) all crates on crates.io and seeing what percentage of crates actually breaks.
I proposed this only for a single identifier or literal. In your example, you would have to add brackets.
EDIT: It would be possible to also allow an expression, including prefix operators like +, -, &, &mut, * and !. But writing foo!!x would be considered bad practice, and rustfmt should add parentheses like foo!(!x).
That would result in a rule that enlarges the complexity of the language in a very non-straightforward way by creating an exception of the form "X is the case, except when Y is the case".
Personally I'm not a fan of such rules. Languages like C++ and Scala are full of them, and it makes it that much harder to keep everything straight due to increased incidental complexity of the Rust language (as opposed to essential complexity i.e. the complexity necessarily involved in solving some concrete problem).
As it is I believe that Rust has already used up most if not all of its complexity budget (i.e. how complex a language can become before it is so large the programmer doesn't even know for sure which rules apply and in which order) on things like generics, ownership + borrowing, traits + trait objects, and macros.
Built-in prefixes and suffixes (r#ident, r#"String"#, b'c', 5u8) also work only with single identifiers or literals. I don't think that this rule would be hard to understand.
Also, it's similar to how brackets are used in math:
5 * x // parens not required
5 * (x + 2) // parens required
foo!x // parens not required
foo!(x + 2) // parens required
The difference is that there you can add as many matching delimiters you want and it will always work exactly the same i.e. r#"foo"# results in the same string as r###"foo"###.
With your macro proposal that doesn't seem to be the case.