Skip to content

Commit 53cb6fb

Browse files
refactor: few minor updates
1 parent 3567cd0 commit 53cb6fb

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

rustfmt-core/rustfmt-lib/src/items.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ impl<'a> FnSig<'a> {
281281
visit::FnKind::Method(_, method_sig, vis, _) => {
282282
let mut fn_sig = FnSig::from_method_sig(method_sig, generics);
283283
fn_sig.defaultness = defaultness;
284-
if let Some(vis) = vis {
285-
fn_sig.visibility = vis.clone();
286-
}
284+
fn_sig.visibility = vis.clone();
287285
fn_sig
288286
}
289287
_ => unreachable!(),
@@ -1753,7 +1751,7 @@ impl<'a> StaticParts<'a> {
17531751
ident: ii.ident,
17541752
ty,
17551753
mutability: ast::Mutability::Not,
1756-
expr_opt: Some(expr),
1754+
expr_opt: expr.as_ref(),
17571755
defaultness: Some(ii.defaultness),
17581756
span: ii.span,
17591757
}

rustfmt-core/rustfmt-lib/src/patterns.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ impl Rewrite for Pat {
191191
infix.to_owned()
192192
};
193193
rewrite_pair(
194-
&**lhs,
195-
&**rhs,
194+
&lhs.unwrap(),
195+
&rhs.unwrap(),
196196
PairParts::infix(&infix),
197197
context,
198198
shape,

rustfmt-core/rustfmt-lib/src/types.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::iter::ExactSizeIterator;
22
use std::ops::Deref;
33

4-
use rustc_span::{BytePos, DUMMY_SP, Span, symbol::kw};
4+
use rustc_span::{BytePos, Span, symbol::kw};
55
use syntax::ast::{self, FunctionRetTy, Mutability};
66

77
use crate::config::lists::*;
@@ -274,13 +274,9 @@ fn rewrite_segment(
274274
result.push_str(&generics_str)
275275
}
276276
ast::GenericArgs::Parenthesized(ref data) => {
277-
let output = match data.output {
278-
Some(ref ty) => FunctionRetTy::Ty(ty.clone()),
279-
None => FunctionRetTy::Default(DUMMY_SP),
280-
};
281277
result.push_str(&format_function_type(
282278
data.inputs.iter().map(|x| &**x),
283-
&output,
279+
&data.output,
284280
false,
285281
data.span,
286282
context,

0 commit comments

Comments
 (0)