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

On fmt string with unescaped { note how to escape #37695

Merged
merged 1 commit into from
Nov 12, 2016

Conversation

estebank
Copy link
Contributor

On cases of malformed format strings where a { hasn't been properly escaped, like println!("{");, present a NOTE explaining how to escape the { char.

Fix #34300.

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

Awesome, thanks!

Could you be sure to add a ui test for this case as well?

@estebank
Copy link
Contributor Author

@alexcrichton added NOTE for } and a ui test for both cases.

@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Contributor

bors commented Nov 11, 2016

📌 Commit 1631a5c has been approved by alexcrichton

self.err("unmatched `}` found");
self.err_with_note("unmatched `}` found",
"if you intended to print `}`, \
can you escape it using `}}`");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"can you" -> "you can"

let msg = &format!("expected `{:?}` but string was terminated", c);
if c == '}' {
self.err_with_note(msg,
"if you intended to print `{`, can you escape it using `{{`");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. "can you" -> "you can"

@alexcrichton
Copy link
Member

@bors: r-

(waiting for changes)

On cases of malformed format strings where a `{` hasn't been properly
escaped, like `println!("{");`, present a note explaining how to escape
the `{` char.
@estebank
Copy link
Contributor Author

@brson @alexcrichton fixed.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 11, 2016

📌 Commit 3c17abc has been approved by alexcrichton

eddyb added a commit to eddyb/rust that referenced this pull request Nov 11, 2016
…chton

On fmt string with unescaped `{` note how to escape

On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a NOTE explaining how to escape the `{` char.

Fix rust-lang#34300.
eddyb added a commit to eddyb/rust that referenced this pull request Nov 12, 2016
…chton

On fmt string with unescaped `{` note how to escape

On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a NOTE explaining how to escape the `{` char.

Fix rust-lang#34300.
bors added a commit that referenced this pull request Nov 12, 2016
@bors bors merged commit 3c17abc into rust-lang:master Nov 12, 2016
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 this pull request may close these issues.

6 participants