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.
This commit is contained in:
Nicholas Nethercote 2023-11-28 09:11:03 +11:00
parent 1bcbb7c93b
commit 0efd2a9d8f
9 changed files with 20 additions and 20 deletions

View file

@ -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(),