Skip to content

Commit 4fd8c04

Browse files
committedApr 3, 2025·
Auto merge of #139336 - matthiaskrgr:rollup-zsi8pgf, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #138017 (Tighten up assignment operator representations.) - #138462 (Dedup `&mut *` reborrow suggestion in loops) - #138610 (impl !PartialOrd for HirId) - #138767 (Allow boolean literals in `check-cfg`) - #139068 (io: Avoid marking some bytes as uninit) - #139255 (Remove unused variables generated in merged doctests) - #139270 (Add a mailmap entry for myself) - #139303 (Put Noratrieb on vacation) - #139312 (add Marco Ieni to mailmap) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 00095b3 + 4cf6c21 commit 4fd8c04

File tree

81 files changed

+806
-598
lines changed

Some content is hidden

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

81 files changed

+806
-598
lines changed
 

‎.mailmap

+5-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Jacob Greenfield <xales@naveria.com>
276276
Jacob Pratt <jacob@jhpratt.dev> <the.z.cuber@gmail.com>
277277
Jacob Pratt <jacob@jhpratt.dev> <jacopratt@tesla.com>
278278
Jake Goulding <jake.goulding@integer32.com>
279-
Jake Goulding <jake.goulding@integer32.com> <jake.goulding@gmail.com>
279+
Jake Goulding <jake.goulding@integer32.com> <jake.goulding@gmail.com>
280280
Jake Goulding <jake.goulding@integer32.com> <shepmaster@mac.com>
281281
Jake Vossen <jake@vossen.dev>
282282
Jakob Degen <jakob.e.degen@gmail.com> <jakob@degen.com>
@@ -412,6 +412,7 @@ Malo Jaffré <jaffre.malo@gmail.com>
412412
Manish Goregaokar <manishsmail@gmail.com>
413413
Mara Bos <m-ou.se@m-ou.se>
414414
Marcell Pardavi <marcell.pardavi@gmail.com>
415+
Marco Ieni <11428655+MarcoIeni@users.noreply.github.com>
415416
Marcus Klaas de Vries <mail@marcusklaas.nl>
416417
Margaret Meyerhofer <mmeyerho@andrew.cmu.edu> <mmeyerho@andrew>
417418
Mark Mansi <markm@cs.wisc.edu>
@@ -565,6 +566,9 @@ Robert Habermeier <rphmeier@gmail.com>
565566
Robert Millar <robert.millar@cantab.net>
566567
Roc Yu <rocyu@protonmail.com>
567568
Rohit Joshi <rohitjoshi@users.noreply.github.com> Rohit Joshi <rohit.joshi@capitalone.com>
569+
Ross Smyth <18294397+RossSmyth@users.noreply.github.com>
570+
Ross Smyth <18294397+RossSmyth@users.noreply.github.com> <crs2017@gmail.com>
571+
Ross Smyth <18294397+RossSmyth@users.noreply.github.com> <rsmyth@electrocraft.com>
568572
Roxane Fruytier <roxane.fruytier@hotmail.com>
569573
Rui <xiongmao86dev@sina.com>
570574
Russell Johnston <rpjohnst@gmail.com>

‎compiler/rustc_ast/src/ast.rs

+70-1
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,75 @@ impl BinOpKind {
981981

982982
pub type BinOp = Spanned<BinOpKind>;
983983

984+
// Sometimes `BinOpKind` and `AssignOpKind` need the same treatment. The
985+
// operations covered by `AssignOpKind` are a subset of those covered by
986+
// `BinOpKind`, so it makes sense to convert `AssignOpKind` to `BinOpKind`.
987+
impl From<AssignOpKind> for BinOpKind {
988+
fn from(op: AssignOpKind) -> BinOpKind {
989+
match op {
990+
AssignOpKind::AddAssign => BinOpKind::Add,
991+
AssignOpKind::SubAssign => BinOpKind::Sub,
992+
AssignOpKind::MulAssign => BinOpKind::Mul,
993+
AssignOpKind::DivAssign => BinOpKind::Div,
994+
AssignOpKind::RemAssign => BinOpKind::Rem,
995+
AssignOpKind::BitXorAssign => BinOpKind::BitXor,
996+
AssignOpKind::BitAndAssign => BinOpKind::BitAnd,
997+
AssignOpKind::BitOrAssign => BinOpKind::BitOr,
998+
AssignOpKind::ShlAssign => BinOpKind::Shl,
999+
AssignOpKind::ShrAssign => BinOpKind::Shr,
1000+
}
1001+
}
1002+
}
1003+
1004+
#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
1005+
pub enum AssignOpKind {
1006+
/// The `+=` operator (addition)
1007+
AddAssign,
1008+
/// The `-=` operator (subtraction)
1009+
SubAssign,
1010+
/// The `*=` operator (multiplication)
1011+
MulAssign,
1012+
/// The `/=` operator (division)
1013+
DivAssign,
1014+
/// The `%=` operator (modulus)
1015+
RemAssign,
1016+
/// The `^=` operator (bitwise xor)
1017+
BitXorAssign,
1018+
/// The `&=` operator (bitwise and)
1019+
BitAndAssign,
1020+
/// The `|=` operator (bitwise or)
1021+
BitOrAssign,
1022+
/// The `<<=` operator (shift left)
1023+
ShlAssign,
1024+
/// The `>>=` operator (shift right)
1025+
ShrAssign,
1026+
}
1027+
1028+
impl AssignOpKind {
1029+
pub fn as_str(&self) -> &'static str {
1030+
use AssignOpKind::*;
1031+
match self {
1032+
AddAssign => "+=",
1033+
SubAssign => "-=",
1034+
MulAssign => "*=",
1035+
DivAssign => "/=",
1036+
RemAssign => "%=",
1037+
BitXorAssign => "^=",
1038+
BitAndAssign => "&=",
1039+
BitOrAssign => "|=",
1040+
ShlAssign => "<<=",
1041+
ShrAssign => ">>=",
1042+
}
1043+
}
1044+
1045+
/// AssignOps are always by value.
1046+
pub fn is_by_value(self) -> bool {
1047+
true
1048+
}
1049+
}
1050+
1051+
pub type AssignOp = Spanned<AssignOpKind>;
1052+
9841053
/// Unary operator.
9851054
///
9861055
/// Note that `&data` is not an operator, it's an `AddrOf` expression.
@@ -1593,7 +1662,7 @@ pub enum ExprKind {
15931662
/// An assignment with an operator.
15941663
///
15951664
/// E.g., `a += 1`.
1596-
AssignOp(BinOp, P<Expr>, P<Expr>),
1665+
AssignOp(AssignOp, P<Expr>, P<Expr>),
15971666
/// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct field.
15981667
Field(P<Expr>, Ident),
15991668
/// An indexing operation (e.g., `foo[2]`).

0 commit comments

Comments
 (0)
Please sign in to comment.