about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-11-28 09:11:03 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2023-11-28 09:42:07 +1100
commit0efd2a9d8ff5d2ef1b23545a9f67216b7e183a3d (patch)
tree5c8e0e44b7c76924d608f06598a6da63de2134a0 /compiler/rustc_parse/src/parser
parent1bcbb7c93b96828092e83e52d592faa046183d6c (diff)
downloadrust-0efd2a9d8ff5d2ef1b23545a9f67216b7e183a3d.tar.gz
rust-0efd2a9d8ff5d2ef1b23545a9f67216b7e183a3d.zip
Rework `ast::BinOpKind::to_string` and `ast::UnOp::to_string`.
- Rename them both `as_str`, which is the typical name for a function
  that returns a `&str`. (`to_string` is appropriate for functions
  returning `String` or maybe `Cow<'a, str>`.)
- Change `UnOp::as_str` from an associated function (weird!) to a
  method.
- Avoid needless `self` dereferences.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 5316dde6096..cf165a50b53 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -387,7 +387,7 @@ impl<'a> Parser<'a> {
             if op.node.lazy() {
                 self.sess.emit_err(errors::InvalidExpressionInLetElse {
                     span: init.span,
-                    operator: op.node.to_string(),
+                    operator: op.node.as_str(),
                     sugg: errors::WrapExpressionInParentheses {
                         left: init.span.shrink_to_lo(),
                         right: init.span.shrink_to_hi(),