Open bend-n opened 1 year ago
@rustbot claim
To reproduce with only rustc without using cargo you will need to specify --edition 2021
e.g. rustc <file>.rs --edition 2021
It is hard for the compiler to tell whether you merely forgot a starting quote before a
or you actually meant to use a
as a string prefix. So it is emitting errors for both scenarios, which I feel is reasonable.
There is one shortcoming though. The consider inserting whitespace here
suggestion makes sense only in a macro invocation i.e. if the code were like this.: my_macro!("a"-a")
. It is not helpful in other cases and therefore we could suppress it. However, given that the error originates in the lexer/StringReader
, adding such smarts so early in the compiler pipeline may be too much effort.
So all things considered I feel we should leave this behaviour as is.
(For the background on unknown prefixes and the suggestion to insert whitespace see RFC 3101: https://rust-lang.github.io/rfcs/3101-reserved_prefixes.html)
@rustbot release-assignment
Hi gang, I get this error on program litteral strings. It makes No sense really because the bytes between one quote(") and the final quote(") must be literal character encoding (UTF-8) normally.
Heres is an example of the error I saw:
source
let matches = Command::new("Typester")
.version("0.1.0")
.author("Alex E")
.about("Convert Rust types to Typescript types")
.arg
(
Arg::new("input")
.short('i')
.long("input")
.required(true)
.help("The Rust file to process (including extension)"),
)
output errror
--> src/main.rs:48:23
|
48 | .author("Alex E")
| ^ unknown prefix
|
= note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here
|
48 | .author("Alex E ")
Now; I have done teh normal quote and braket matching for this kind of thing. I'm quite concerned now that text withing a quoted srtring has some "influence" on other bits of code.
Imh Litteral meas litteral -- NO, 'interpretation' is required on string data.
Anyhoo ... this error itself seems spurious -- There are no interpolations or text enpansionhs neededed hear -- Why / HOW can it 'be' a problem
Thanks, William
Follow-up post . . . Eventually I discovered a missing quote character in the .rs
file. Hard to detect once I had found it; so mea cuppa the fault here was mine. Girls and Boys -- check your quotes!!!
^ case of how unhelpful the diagnostic is.
Code
Current output
Desired output
Rationale and extra context
Confusing error when dealing with long unclosed string literals and command line options.
Other cases
No response
Anything else?
No response