Skip to content

Emacs mode has issues with single quotes #5

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

Closed
steveklabnik opened this issue Feb 2, 2015 · 2 comments · Fixed by #45
Closed

Emacs mode has issues with single quotes #5

steveklabnik opened this issue Feb 2, 2015 · 2 comments · Fixed by #45

Comments

@steveklabnik
Copy link
Member

Issue by haxney
Thursday Oct 31, 2013 at 04:58 GMT

For earlier discussion, see rust-lang/rust#10190

This issue was labelled with: A-tools in the Rust repository


The latest version of rust-mode for Emacs (20130928.1740) has issues with
single-quoted characters, especially when that character is a " (double
quote). The following program executes correctly in Rust 0.8, but is font-locked
improperly in Emacs:

fn main() {
    println!("{}", '"');
}

It treats the double quote as the beginning of a string which runs to the end of
the file. If the double quote character is escaped like so:

fn main() {
    println!("{}", '\"');
}

Then there is not a problem with an unterminated string, but the characters
inside the single quotes are not fontified at all.

Note: Both programs compile and execute successfully under Rust 0.8.

This is related to #8793

@shepmaster
Copy link
Member

I cannot reproduce the first issue (double quote in a single-quoted string) on rust-mode 20150215.1646. The second issue (escaped double quote is not font-locked) still exists.

@MicahChalmer
Copy link
Contributor

It's interesting that rust even accepts '\"'. It isn't necessary ('"' is perfectly valid--and is now highlighted correctly in emacs too) and other unnecessary escapes get an "unknown character escape" compiler error. It looks like the same function is used to parse escapes inside either string or character literals, which means that both "\'" and '\"' are valid escapes, even though they're unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants