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

Manual doesn't document the meaning of various single quote lifetime #8007

Closed
ozten opened this issue Jul 23, 2013 · 11 comments
Closed

Manual doesn't document the meaning of various single quote lifetime #8007

ozten opened this issue Jul 23, 2013 · 11 comments
Labels
P-medium Medium priority

Comments

@ozten
Copy link
Contributor

ozten commented Jul 23, 2013

[NOTE: I misread ' as a backtick ]
I've come across types with backticks aka `.

Examples (from memory, could be wrong):

&`a
`static

From reading a presentation on memory I guess one use is to denote lifetype scope (???).

Since the compiler gives type errors that use backtick, it would be great to have a section on them.

@Kimundi
Copy link
Member

Kimundi commented Jul 23, 2013

The backtick character is not used by rust source code in any way, if it appears in official documentation then that is an error. However, the single quote character is used for denoting lifetimes on borrowed pointers/references (&'a Foo, &'static Bar), and of course for char literals like 'a' or 'λ'.

@ozten
Copy link
Contributor Author

ozten commented Jul 23, 2013

This is my poor eyesight ;)

Does the manual document the how to read these lifetime references?

(Editing Issue title to be single quote instead of backtick)

@thestinger
Copy link
Contributor

It's documented in the borrowed pointer tutorial to some extent. The documentation is far from complete.

@catamorphism
Copy link
Contributor

Manual still needs updating: the current version says "Borrowed pointers are written &content, or in some cases &f/content for some lifetime-variable f, for example &int means a borrowed pointer to an integer." I didn't look at the tutorial, assuming it still needs work too WRT this issue.

@catamorphism
Copy link
Contributor

Nominating for milestone 1, well-defined

@catamorphism
Copy link
Contributor

1.0, high

@Aatch
Copy link
Contributor

Aatch commented Mar 4, 2014

Still relevant, the manual doesn't specify the lifetime syntax, despite using it later on. The tutorial on lifetimes does have examples of the lifetime syntax.

@brson
Copy link
Contributor

brson commented Apr 8, 2014

Nominating for removal from milestone.

@pnkfelix
Copy link
Member

We can ship 1.0 without this, though it would be good to have this. Leaving as P-high, but removing from 1.0 milestone.

@pnkfelix pnkfelix removed this from the 1.0 milestone Apr 10, 2014
@brson brson removed the I-nominated label Apr 10, 2014
@steveklabnik
Copy link
Member

The manual has "A reference type is written &'f type for some lifetime-variable f, or just &type when the lifetime can be elided;", and does have a bunch of information about lifetimes. Should this be closed? Should this be changed to &'a since that's the most common lifetime name?

@steveklabnik
Copy link
Member

There's been zero discussion here, and we do have the aforementioned sentence. If we have additional specific improvements that can be made, I'm open to it, but I think this can be closed.

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 23, 2021
Add new lint `octal_escapes`

This checks for sequences in strings that would be octal character
escapes in C, but are not supported in Rust.  It suggests either
to use the `\x00` escape, or an equivalent hex escape if the octal
was intended.

Fixes rust-lang#7981

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: Add new lint [`octal_escapes`], which checks for literals like `"\033[0m"`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

8 participants