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

"foo" is &str, so &"foo" should be & &str #10105

Closed
thestinger opened this issue Oct 27, 2013 · 8 comments
Closed

"foo" is &str, so &"foo" should be & &str #10105

thestinger opened this issue Oct 27, 2013 · 8 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR)

Comments

@thestinger
Copy link
Contributor

No description provided.

@Kimundi
Copy link
Member

Kimundi commented Oct 27, 2013

Not saying this is a bad idea, but changing it might raise a different consistency problem:
People might now confuse ~"foo" to be ~&'static str - "foo" being sugar for &"foo" is consistent in that regard.

@thestinger
Copy link
Contributor Author

I don't think it would introduce any confusion. A "foo" literal is already &'static str so there is no change in consistency in regards to ~"foo", just the removal of a useless alternative way of doing the same thing. A no-op & operator on the is definitely confusing... at the moment you need to know that "foo" is a &'static str and also that & is a no-op on it and you're going to need &("foo") to get & &str.

@nikomatsakis
Copy link
Contributor

We made a deliberate decision at some point to make & literals behave inconsistently (e.g., [...] vs &[...] as well). I'm not sure this was a correct decision though.

@thestinger
Copy link
Contributor Author

I think the distinction for arrays is fine, because both forms are useful. Strings don't really act like arrays either way.

@thestinger
Copy link
Contributor Author

I'll open a formal RFC about this soon.

@pnkfelix
Copy link
Member

(removing I-nominated tag. We do not know what exactly this was nominated for; we believe that the solution to this will fall out of DST work.)

@brson
Copy link
Contributor

brson commented Apr 17, 2014

This is part of DST: #12938

@ftxqxd
Copy link
Contributor

ftxqxd commented Dec 2, 2014

let x:  &str =  "foo";
let y: &&str = &"foo";

I believe this is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR)
Projects
None yet
Development

No branches or pull requests

6 participants