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

Document that <- is a single token #1424

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Conversation

mattheww
Copy link
Contributor

@mattheww mattheww commented Nov 1, 2023

<- was the "move operator", removed in Rust 0.5, but is still lexed as a single token.

So I think it should be listed in the Punctuation table (like the tilde token is).

Originally reported as ferrocene/specification#452

Fixes #583

@ehuss
Copy link
Contributor

ehuss commented Nov 1, 2023

Thanks, yea, I noted this in #583.

Since there was an attempt to remove this that was then later backed out, I'm assuming the language team agrees that the emplacement operator has to stay permanently. However, I'm not 100% sure based on rust-lang/rust#50832 (comment).

Since I'm not completely confident that the language team doesn't want to try to remove this in the future, I'm going to nominate this for their attention for approval. I think this PR probably should be merged. I wouldn't be surprised if there were more macros using it since the last time it was attempted to be removed.

@mattheww
Copy link
Contributor Author

mattheww commented Nov 2, 2023

It looks like the main question in rust-lang/rust#50832 is whether to remove this feature from the parser.

Perhaps the question of whether it will be removed from the lexer is easier.

In particular, if the answer to that one is "perhaps, but if so it would happen in a future edition", then I think there'd be no reason to delay documenting the current behaviour any further.

@scottmcm
Copy link
Member

scottmcm commented Nov 15, 2023

@rfcbot merge

I agree that we should reflect what's actually happening in the reference.

(And I think that it's not worth trying to change the lexing rules for this at this point.)

@rfcbot
Copy link

rfcbot commented Nov 15, 2023

Team member @scottmcm has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@tmandry
Copy link
Member

tmandry commented Dec 12, 2023

Since there was an attempt to remove this that was then later backed out, I'm assuming the language team agrees that the emplacement operator has to stay permanently. However, I'm not 100% sure based on rust-lang/rust#50832 (comment).

It isn't clear to me why the token removal was backed out; the crater run above rust-lang/rust#60803 (comment) didn't find any actual regressions and the comment didn't leave a rationale.

It seems like it would have been possible to remove the token then, but now it might be harder. It seems worth running crater again to check, if only to make x<-1 parse correctly. Though if someone knows of crates that will definitely break or wants to argue for why it's a bad idea, we can skip it and I'll resolve the concern.

@rfcbot concern can we still remove the token

Otherwise, I'm not opposed to documenting the current behavior.

@rfcbot reviewed

@ehuss
Copy link
Contributor

ehuss commented Dec 12, 2023

It sounds like from rust-lang/rust#60803 that Centril and petrochenkov wanted to keep the <- token for "future-proofing" and "keeping options open". Does the lang team want to close that door?

Perhaps it could be removed, and then added again later in an edition (though I don't know how feasible that is)?

@scottmcm
Copy link
Member

Hmm, it looks like -> => <- and <= are all single-token today: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c068b8a62888b15c289e124ff39aebef

macro_rules! foo {
    ($x:tt) => {};
}

fn main() {
    foo!(->);
    foo!(=>);
    foo!(<-);
    foo!(<=);
}

So I think I'm now being pushed further to "let's just leave it as is", so tt-muncher macros can all keep using these as arrows if they want, since there's very little cost to keeping it.

@tmandry
Copy link
Member

tmandry commented Dec 13, 2023

Discussed in t-lang and we agreed to unblock documenting this for now. @compiler-errors also wants to do a crater run so we can consider removing it, but that doesn't need to block this PR.

@rfcbot resolve can we still remove the token

@compiler-errors
Copy link
Member

The crater run: rust-lang/rust#118920 (comment)

@traviscross
Copy link
Contributor

@rustbot labels -I-lang-nominated

As mentioned above, we discussed this today and the consensus was that we should separate the question of documenting the current behavior from maybe changing that behavior. This can proceed as soon as enough people review and approve.

Once the crater run is analyzed, if someone wants to make a case for changing this behavior, please discuss the pros/cons and nominate for T-lang over in rust-lang/rust#118920 or in a new issue.

@ehuss
Copy link
Contributor

ehuss commented Jan 8, 2024

The crater analysis was done in rust-lang/rust#118920, and @compiler-errors decided that there was enough breakage to not make it worth it.

I'm going to consider the comment in #1424 (comment) to imply that the team as a whole has agreed to this even though the rfcbot checkboxes weren't checked. I don't know who was in attendance, but I assume it was more than just two.

@ehuss ehuss added this pull request to the merge queue Jan 8, 2024
Merged via the queue into rust-lang:master with commit 8c77e8b Jan 8, 2024
1 check passed
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 16, 2024
Update books

## rust-lang/nomicon

1 commits in f6bd083c4ccfc4ce6699b8b4154e3c45c5a27a8c..6bc2415218d4dd0cb01433d8320f5ccf79c343a1
2024-01-03 04:01:04 UTC to 2024-01-03 04:01:04 UTC

- Update an example of `thread_local` to use `local_key_cell_methods` (rust-lang/nomicon#438)

## rust-lang/reference

1 commits in 3565c7978cfc9662f5963b135690ff9cbbfa0318..8c77e8be9da1a9c70545556218d563c8d061f1fd
2024-01-08 15:16:51 UTC to 2024-01-08 15:16:51 UTC

- Document that <- is a single token (rust-lang/reference#1424)

## rust-lang/rust-by-example

4 commits in c0be6299e52e4164c30ba6f41bd0ad0aaee64972..ddf5cb0e6ee54ba2dd84c8ca3e1314120014e20d
2024-01-13 11:06:22 UTC to 2024-01-13 11:01:00 UTC

- Update attribute.md, (rust-lang/rust-by-example#1791)
- fix: typo `unusude` (rust-lang/rust-by-example#1797)
- Update print.md (rust-lang/rust-by-example#1796)
- Update alias.md (rust-lang/rust-by-example#1790)

## rust-lang/rustc-dev-guide

4 commits in d13e85152a977cd0bcaf583cf5f49e86225697de..4af29d1a7f64f88a36539662c6a84fe1fbe6cde1
2024-01-14 10:42:53 UTC to 2024-01-06 17:47:01 UTC

- Expand upon PR guidelines (rust-lang/rustc-dev-guide#1851)
- Correct the link to rust reference (rust-lang/rustc-dev-guide#1848)
- Explain the important concepts of exhaustiveness checking (rust-lang/rustc-dev-guide#1830)
- Add guide for rustdoc search implementation (rust-lang/rustc-dev-guide#1846)
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2024
Rollup merge of rust-lang#119998 - rustbot:docs-update, r=ehuss

Update books

## rust-lang/nomicon

1 commits in f6bd083c4ccfc4ce6699b8b4154e3c45c5a27a8c..6bc2415218d4dd0cb01433d8320f5ccf79c343a1
2024-01-03 04:01:04 UTC to 2024-01-03 04:01:04 UTC

- Update an example of `thread_local` to use `local_key_cell_methods` (rust-lang/nomicon#438)

## rust-lang/reference

1 commits in 3565c7978cfc9662f5963b135690ff9cbbfa0318..8c77e8be9da1a9c70545556218d563c8d061f1fd
2024-01-08 15:16:51 UTC to 2024-01-08 15:16:51 UTC

- Document that <- is a single token (rust-lang/reference#1424)

## rust-lang/rust-by-example

4 commits in c0be6299e52e4164c30ba6f41bd0ad0aaee64972..ddf5cb0e6ee54ba2dd84c8ca3e1314120014e20d
2024-01-13 11:06:22 UTC to 2024-01-13 11:01:00 UTC

- Update attribute.md, (rust-lang/rust-by-example#1791)
- fix: typo `unusude` (rust-lang/rust-by-example#1797)
- Update print.md (rust-lang/rust-by-example#1796)
- Update alias.md (rust-lang/rust-by-example#1790)

## rust-lang/rustc-dev-guide

4 commits in d13e85152a977cd0bcaf583cf5f49e86225697de..4af29d1a7f64f88a36539662c6a84fe1fbe6cde1
2024-01-14 10:42:53 UTC to 2024-01-06 17:47:01 UTC

- Expand upon PR guidelines (rust-lang/rustc-dev-guide#1851)
- Correct the link to rust reference (rust-lang/rustc-dev-guide#1848)
- Explain the important concepts of exhaustiveness checking (rust-lang/rustc-dev-guide#1830)
- Add guide for rustdoc search implementation (rust-lang/rustc-dev-guide#1846)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Team: Lang
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maybe document emplacement syntax <-
8 participants