if $c:expr { Some($r:expr) } else { None }
=>> $c.then(|| $r)
This commit is contained in:
parent
af3c8b2726
commit
8751fa1a9a
54 changed files with 159 additions and 281 deletions
|
@ -135,19 +135,17 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
|
|||
}
|
||||
|
||||
// `let names: &'static _ = &["field1", "field2"];`
|
||||
let names_let = if is_struct {
|
||||
let names_let = is_struct.then(|| {
|
||||
let lt_static = Some(cx.lifetime_static(span));
|
||||
let ty_static_ref = cx.ty_ref(span, cx.ty_infer(span), lt_static, ast::Mutability::Not);
|
||||
Some(cx.stmt_let_ty(
|
||||
cx.stmt_let_ty(
|
||||
span,
|
||||
false,
|
||||
Ident::new(sym::names, span),
|
||||
Some(ty_static_ref),
|
||||
cx.expr_array_ref(span, name_exprs),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
)
|
||||
});
|
||||
|
||||
// `let values: &[&dyn Debug] = &[&&self.field1, &&self.field2];`
|
||||
let path_debug = cx.path_global(span, cx.std_path(&[sym::fmt, sym::Debug]));
|
||||
|
|
|
@ -942,13 +942,11 @@ impl<'a> MethodDef<'a> {
|
|||
let mut nonself_arg_tys = Vec::new();
|
||||
let span = trait_.span;
|
||||
|
||||
let explicit_self = if self.explicit_self {
|
||||
let explicit_self = self.explicit_self.then(|| {
|
||||
let (self_expr, explicit_self) = ty::get_explicit_self(cx, span);
|
||||
selflike_args.push(self_expr);
|
||||
Some(explicit_self)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
explicit_self
|
||||
});
|
||||
|
||||
for (ty, name) in self.nonself_args.iter() {
|
||||
let ast_ty = ty.to_ty(cx, span, type_ident, generics);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue