Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

unterminated raw string error should explain the raw-string format a bit #48395

Closed
gnzlbg opened this issue Feb 21, 2018 · 2 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 21, 2018

Playground:

fn foo(s: &str) { println!("{}", s) }
fn main() {
    foo(r#"
This is a raw string  
missing a # at the end
"
    );
}

produces

error: unterminated raw string
 --> src/main.rs:4:9
  |
4 |       foo(r#"
  |  _________^
5 | | This is a raw string  
6 | | missing a # at the end
7 | | "
8 | |     );
9 | | }
  | |_^

error: aborting due to previous error

that only mentions "unterminated raw-string". It would be more helpful if it would suggest adding a # after the last " to terminate the raw string.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 21, 2018

How would one detect where the raw string ends? It might contain random " on the inside or afterwards.

let s = r#"
This is a "raw string" 
missing a # at the end
";
println!("{}", s);

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Feb 21, 2018

How would one detect where the raw string ends?

No idea, and good question. While suggesting exactly where to add # would be awesome, it would already be an improvement to add:

note: raw string must be terminated with a #:
#"  <--- raw string starts here
...
"#  <--- raw string ends here

@kennytm kennytm added A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. WG-compiler-front labels Feb 21, 2018
kennytm added a commit to kennytm/rust that referenced this issue Mar 6, 2018
…e, r=estebank

Raw string error note

Fixes rust-lang#48395.

I think this note should be helpful enough to solve the issue.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Mar 6, 2018
…e, r=estebank

Raw string error note

Fixes rust-lang#48395.

I think this note should be helpful enough to solve the issue.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Mar 6, 2018
…e, r=estebank

Raw string error note

Fixes rust-lang#48395.

I think this note should be helpful enough to solve the issue.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

No branches or pull requests

3 participants