Skip to content
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

Multiline strings with carriage return - unknown string escape #11669

Closed
adam-frisby opened this issue Jan 19, 2014 · 2 comments
Closed

Multiline strings with carriage return - unknown string escape #11669

adam-frisby opened this issue Jan 19, 2014 · 2 comments
Labels
O-windows Operating system: Windows

Comments

@adam-frisby
Copy link

Using Windows style (or Mac OS 9) style line endings results in "unknown string escape: \r" when attempting to use a multiline string literal.

test.rs:2:26: 2:27 error: unknown string escape: \r
test.rs:2   let string = ~"This is \
                                    ^
fn main() {
    let string = "This is \
                  a test";
}

When cloning a rust library, git automatically converted the Linux style line endings to Windows which caused compilation to fail.

@SiegeLord
Copy link
Contributor

Discussion in #7946 seems relevant, although it only directly relates to CR-only line endings. The Rust repository specifically disables that feature of git via .gitattributes (see #9214) which is something one could do in the meantime/if this issue is determined to be a non-issue.

@huonw
Copy link
Member

huonw commented Feb 17, 2014

It would be good to at least special case this to emit a more useful error message, even if it's not legal.

@huonw huonw closed this as completed in e621e32 Nov 14, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 2, 2023
new lint: `unnecessary_fallible_conversions`

Closes rust-lang#11577

A new lint that looks for calls such as `i64::try_from(1i32)` and suggests `i64::from(1i32)`. See lint description (and linked issue) for more details for why.

There's a tiny bit of overlap with the `useless_conversion` lint, in that the other one warns `T::try_from(T)` (i.e., fallibly converting to the same type), so this lint ignores cases like `i32::try_from(1i32)` to avoid emitting two warnings for the same expression.

Also, funnily enough, with this one exception, this lint would warn on exactly every case in the `useless_conversion_try` ui test that `useless_conversion` didn't cover (but never two warnings at the same time), which is neat. I did add an `#![allow]` though since we don't want interleaved warnings from multiple lints in the same uitest.

changelog: new lint: `unnecessary_fallible_conversions`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

3 participants