Skip to content

Concatenating adjacent string literals #10591

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
wants to merge 1 commit into from

Conversation

ILyoan
Copy link
Contributor

@ILyoan ILyoan commented Nov 21, 2013

This makes string literals placed next to each other be concatenated.
Thus "Foo" "Bar" would be "FooBar".

@thestinger
Copy link
Contributor

I think this needs an RFC. Could this just be a syntax extension? I find that I often do this by mistake in Python by missing a comma:

let xs = ["foo",
          "bar"
          "baz"];

@alexcrichton
Copy link
Member

I was hoping to avoid having to do this in the parser by implementing the concat! syntax extension. Was that found to be insufficient?

@ILyoan
Copy link
Contributor Author

ILyoan commented Nov 22, 2013

@thestinger, @alexcrichton I didn't know that there was already concat! extension. Thanks.
Closing this PR.

@ILyoan ILyoan closed this Nov 22, 2013
@stepancheg
Copy link
Contributor

concat! does not concatenate binary string literals. How it should be fixed? I see three options:

  • bconcat! macro, similar to concat!, but for binary literals
  • concat! macro may produce binary literal if all arguments are binary literals (weird thing is that no-argument concat!() still produces string literal)
  • Reopen this issue and implement C-style concatenation

@stepancheg
Copy link
Contributor

I forgot that strings can be wrapped with slash. So lack of concat! for binary literals is not a big deal.

flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 6, 2023
…p1995

Show multiple clippy.toml warnings with `sess.warn` instead of `eprintln!`

Use `sess.warn` to display the multiple clippy.toml warning instead of `eprintln!`.

changelog: none
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.

4 participants