Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9d6039c

Browse files
committedSep 23, 2024
Auto merge of rust-lang#130755 - workingjubilee:rollup-zpja9b3, r=workingjubilee
Rollup of 7 pull requests Successful merges: - rust-lang#129201 (std: implement the `random` feature (alternative version)) - rust-lang#130536 (bootstrap: Set the dylib path when building books with rustdoc) - rust-lang#130551 (Fix `break_last_token`.) - rust-lang#130657 (Remove x86_64-fuchsia and aarch64-fuchsia target aliases) - rust-lang#130721 (Add more test cases for block-no-opening-brace) - rust-lang#130736 (Add rustfmt 2024 reformatting to git blame ignore) - rust-lang#130746 (readd `@tgross35` and `@joboet` to the review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 648d024 + c7abc85 commit 9d6039c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+948
-565
lines changed
 

‎.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ ec2cc761bc7067712ecc7734502f703fe3b024c8
2727
84ac80f1921afc243d71fd0caaa4f2838c294102
2828
# bless mir-opt tests to add `copy`
2929
99cb0c6bc399fb94a0ddde7e9b38e9c00d523bad
30+
# reformat with rustfmt edition 2024
31+
c682aa162b0d41e21cc6748f4fecfe01efb69d1f

‎compiler/rustc_ast/src/token.rs

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -385,35 +385,41 @@ impl TokenKind {
385385
Literal(Lit::new(kind, symbol, suffix))
386386
}
387387

388-
/// An approximation to proc-macro-style single-character operators used by rustc parser.
389-
/// If the operator token can be broken into two tokens, the first of which is single-character,
390-
/// then this function performs that operation, otherwise it returns `None`.
391-
pub fn break_two_token_op(&self) -> Option<(TokenKind, TokenKind)> {
392-
Some(match *self {
393-
Le => (Lt, Eq),
394-
EqEq => (Eq, Eq),
395-
Ne => (Not, Eq),
396-
Ge => (Gt, Eq),
397-
AndAnd => (BinOp(And), BinOp(And)),
398-
OrOr => (BinOp(Or), BinOp(Or)),
399-
BinOp(Shl) => (Lt, Lt),
400-
BinOp(Shr) => (Gt, Gt),
401-
BinOpEq(Plus) => (BinOp(Plus), Eq),
402-
BinOpEq(Minus) => (BinOp(Minus), Eq),
403-
BinOpEq(Star) => (BinOp(Star), Eq),
404-
BinOpEq(Slash) => (BinOp(Slash), Eq),
405-
BinOpEq(Percent) => (BinOp(Percent), Eq),
406-
BinOpEq(Caret) => (BinOp(Caret), Eq),
407-
BinOpEq(And) => (BinOp(And), Eq),
408-
BinOpEq(Or) => (BinOp(Or), Eq),
409-
BinOpEq(Shl) => (Lt, Le),
410-
BinOpEq(Shr) => (Gt, Ge),
411-
DotDot => (Dot, Dot),
412-
DotDotDot => (Dot, DotDot),
413-
PathSep => (Colon, Colon),
414-
RArrow => (BinOp(Minus), Gt),
415-
LArrow => (Lt, BinOp(Minus)),
416-
FatArrow => (Eq, Gt),
388+
/// An approximation to proc-macro-style single-character operators used by
389+
/// rustc parser. If the operator token can be broken into two tokens, the
390+
/// first of which has `n` (1 or 2) chars, then this function performs that
391+
/// operation, otherwise it returns `None`.
392+
pub fn break_two_token_op(&self, n: u32) -> Option<(TokenKind, TokenKind)> {
393+
assert!(n == 1 || n == 2);
394+
Some(match (self, n) {
395+
(Le, 1) => (Lt, Eq),
396+
(EqEq, 1) => (Eq, Eq),
397+
(Ne, 1) => (Not, Eq),
398+
(Ge, 1) => (Gt, Eq),
399+
(AndAnd, 1) => (BinOp(And), BinOp(And)),
400+
(OrOr, 1) => (BinOp(Or), BinOp(Or)),
401+
(BinOp(Shl), 1) => (Lt, Lt),
402+
(BinOp(Shr), 1) => (Gt, Gt),
403+
(BinOpEq(Plus), 1) => (BinOp(Plus), Eq),
404+
(BinOpEq(Minus), 1) => (BinOp(Minus), Eq),
405+
(BinOpEq(Star), 1) => (BinOp(Star), Eq),
406+
(BinOpEq(Slash), 1) => (BinOp(Slash), Eq),
407+
(BinOpEq(Percent), 1) => (BinOp(Percent), Eq),
408+
(BinOpEq(Caret), 1) => (BinOp(Caret), Eq),
409+
(BinOpEq(And), 1) => (BinOp(And), Eq),
410+
(BinOpEq(Or), 1) => (BinOp(Or), Eq),
411+
(BinOpEq(Shl), 1) => (Lt, Le), // `<` + `<=`
412+
(BinOpEq(Shl), 2) => (BinOp(Shl), Eq), // `<<` + `=`
413+
(BinOpEq(Shr), 1) => (Gt, Ge), // `>` + `>=`
414+
(BinOpEq(Shr), 2) => (BinOp(Shr), Eq), // `>>` + `=`
415+
(DotDot, 1) => (Dot, Dot),
416+
(DotDotDot, 1) => (Dot, DotDot), // `.` + `..`
417+
(DotDotDot, 2) => (DotDot, Dot), // `..` + `.`
418+
(DotDotEq, 2) => (DotDot, Eq),
419+
(PathSep, 1) => (Colon, Colon),
420+
(RArrow, 1) => (BinOp(Minus), Gt),
421+
(LArrow, 1) => (Lt, BinOp(Minus)),
422+
(FatArrow, 1) => (Eq, Gt),
417423
_ => return None,
418424
})
419425
}

0 commit comments

Comments
 (0)
Please sign in to comment.