question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Playgrounds rejects valid Rust (due to input processing?)

See original GitHub issue

This code is expected to work but generates a compiler error due to a comment: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=45b03c2e33ff3b6c20af40794c505c92

   Compiling playground v0.0.1 (/playground)
error: this file contains an un-closed delimiter
 --> src/main.rs:1:1854
  |
1 | pub fn main() {
    let reserved_names: [&str; 103] = [
        "as",
        "break",
        "const",
(snip)

If rust-playground tries to put all the code on a single line, that’s likely the problem. Thanks for building and maintaining such a useful tool; much appreciated!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
lqdcommented, May 9, 2019

Ha, this shows the content is not the whole problem, and unfortunately pasting it in/from github “fixes it”, as I think the issue is in the EOL delimiters. Here’s a repro for me of that last one, but constructed from the initial link.

I think the playground doesn’t see the mac \r in the code as end of lines.

0reactions
thedatakingcommented, May 9, 2019

This fails with the same error and works for me locally:

pub fn main() {
    let r: [&str; 0] = [ // works locally; errors in playgrounds
    ];   
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does code that requires user input not work in the Rust ...
The Playground does not currently accept user input via stdin. The stdin is effectively closed immediately, thus your program gets no input ...
Read more >
rust/RELEASES.md at master · rust-lang/rust - GitHub
1: the bugs that are detected by newly added incremental verification are still present in past stable versions, and are not yet fixed...
Read more >
Different ways to terminate and pause program in Rust
1. Using exit() function. std::process::exit(). This function returns nothing and terminates the program ...
Read more >
Common Newbie Mistakes and Bad Practices in Rust
When you are coming to Rust from another language you bring all your previous experiences with you. Often this is awesome because it...
Read more >
Watch out for NaNs - #98 by tczajka - The Rust Programming ...
As a minor related point, serde_json translates floating point values Infinity, -Infinity, and NaN to "None" on output. On input, though, "None" does...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found