Skip to content

Commit

Permalink
refactor: update ast::Mutabiltiy variants
Browse files Browse the repository at this point in the history
`Mutability` variants were renamed to `Not` and `Mut`
rust-lang/rust#67355
  • Loading branch information
calebcartwright committed Jan 15, 2020
1 parent 4a71b53 commit f87fe48
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions rustfmt-core/rustfmt-lib/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2040,8 +2040,8 @@ fn rewrite_expr_addrof(
shape: Shape,
) -> Option<String> {
let operator_str = match mutability {
ast::Mutability::Immutable => "&",
ast::Mutability::Mutable => "&mut ",
ast::Mutability::Not => "&",
ast::Mutability::Mut => "&mut ",
};
rewrite_unary_prefix(context, operator_str, expr, shape)
}
Expand Down
6 changes: 3 additions & 3 deletions rustfmt-core/rustfmt-lib/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ impl<'a> StaticParts<'a> {
let (prefix, ty, mutability, expr) = match item.kind {
ast::ItemKind::Static(ref ty, mutability, ref expr) => ("static", ty, mutability, expr),
ast::ItemKind::Const(ref ty, ref expr) => {
("const", ty, ast::Mutability::Immutable, expr)
("const", ty, ast::Mutability::Not, expr)
}
_ => unreachable!(),
};
Expand All @@ -1735,7 +1735,7 @@ impl<'a> StaticParts<'a> {
vis: &DEFAULT_VISIBILITY,
ident: ti.ident,
ty,
mutability: ast::Mutability::Immutable,
mutability: ast::Mutability::Not,
expr_opt: expr_opt.as_ref(),
defaultness: None,
span: ti.span,
Expand All @@ -1752,7 +1752,7 @@ impl<'a> StaticParts<'a> {
vis: &ii.vis,
ident: ii.ident,
ty,
mutability: ast::Mutability::Immutable,
mutability: ast::Mutability::Not,
expr_opt: Some(expr),
defaultness: Some(ii.defaultness),
span: ii.span,
Expand Down
4 changes: 2 additions & 2 deletions rustfmt-core/rustfmt-lib/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ impl Rewrite for ast::Ty {
}
ast::TyKind::Ptr(ref mt) => {
let prefix = match mt.mutbl {
Mutability::Mutable => "*mut ",
Mutability::Immutable => "*const ",
Mutability::Mut => "*mut ",
Mutability::Not => "*const ",
};

rewrite_unary_prefix(context, prefix, &*mt.ty, shape)
Expand Down
4 changes: 2 additions & 2 deletions rustfmt-core/rustfmt-lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ pub(crate) fn format_auto(is_auto: ast::IsAuto) -> &'static str {
#[inline]
pub(crate) fn format_mutability(mutability: ast::Mutability) -> &'static str {
match mutability {
ast::Mutability::Mutable => "mut ",
ast::Mutability::Immutable => "",
ast::Mutability::Mut => "mut ",
ast::Mutability::Not => "",
}
}

Expand Down

0 comments on commit f87fe48

Please sign in to comment.