Skip to content

Commit 5bf6a46

Browse files
committed
Replace some thens with some then_somes
1 parent 8751fa1 commit 5bf6a46

File tree

24 files changed

+27
-26
lines changed

24 files changed

+27
-26
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<'a> AstValidator<'a> {
271271

272272
self.session.emit_err(InvalidVisibility {
273273
span: vis.span,
274-
implied: vis.kind.is_pub().then(|| vis.span),
274+
implied: vis.kind.is_pub().then_some(vis.span),
275275
note,
276276
});
277277
}

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11861186
return None;
11871187
};
11881188
debug!("checking call args for uses of inner_param: {:?}", args);
1189-
args.contains(&Operand::Move(inner_param)).then(|| (loc, term))
1189+
args.contains(&Operand::Move(inner_param)).then_some((loc, term))
11901190
}) else {
11911191
debug!("no uses of inner_param found as a by-move call arg");
11921192
return;

compiler/rustc_builtin_macros/src/standard_library_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn inject(
6262
// the one with the prelude.
6363
let name = names[0];
6464

65-
let root = (edition == Edition2015).then(|| kw::PathRoot);
65+
let root = (edition == Edition2015).then_some(kw::PathRoot);
6666

6767
let import_path = root
6868
.iter()

compiler/rustc_codegen_llvm/src/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn struct_llfields<'a, 'tcx>(
154154
} else {
155155
debug!("struct_llfields: offset: {:?} stride: {:?}", offset, layout.size);
156156
}
157-
let field_remapping = padding_used.then(|| field_remapping);
157+
let field_remapping = padding_used.then_some(field_remapping);
158158
(result, packed, field_remapping)
159159
}
160160

compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ fn linker_with_args<'a>(
20242024
.native_libraries
20252025
.iter()
20262026
.filter_map(|(cnum, libraries)| {
2027-
(dependency_linkage[cnum.as_usize() - 1] != Linkage::Static).then(|| libraries)
2027+
(dependency_linkage[cnum.as_usize() - 1] != Linkage::Static).then_some(libraries)
20282028
})
20292029
.flatten();
20302030
for (raw_dylib_name, raw_dylib_imports) in

compiler/rustc_expand/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl<'a> StripUnconfigured<'a> {
255255

256256
fn configure_krate_attrs(&self, mut attrs: ast::AttrVec) -> Option<ast::AttrVec> {
257257
attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr));
258-
self.in_cfg(&attrs).then(|| attrs)
258+
self.in_cfg(&attrs).then_some(attrs)
259259
}
260260

261261
/// Performs cfg-expansion on `stream`, producing a new `AttrTokenStream`.

compiler/rustc_hir_analysis/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
204204
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
205205
match tcx.hir().find(hir_id) {
206206
Some(Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })) => {
207-
generics.params.is_empty().not().then(|| generics.span)
207+
generics.params.is_empty().not().then_some(generics.span)
208208
}
209209
_ => {
210210
span_bug!(tcx.def_span(def_id), "main has a non-function type");

compiler/rustc_hir_typeck/src/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10461046
self.param_env,
10471047
)
10481048
.may_apply()
1049-
.then(|| deref_ty)
1049+
.then_some(deref_ty)
10501050
})
10511051
}
10521052

compiler/rustc_lint/src/builtin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,8 @@ impl EarlyLintPass for IncompleteFeatures {
23082308
.for_each(|(&name, &span)| {
23092309
let note = rustc_feature::find_feature_issue(name, GateIssue::Language)
23102310
.map(|n| BuiltinIncompleteFeaturesNote { n });
2311-
let help = HAS_MIN_FEATURES.contains(&name).then(|| BuiltinIncompleteFeaturesHelp);
2311+
let help =
2312+
HAS_MIN_FEATURES.contains(&name).then_some(BuiltinIncompleteFeaturesHelp);
23122313
cx.emit_spanned_lint(
23132314
INCOMPLETE_FEATURES,
23142315
span,

compiler/rustc_lint/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ impl LintStore {
487487
let mut groups: Vec<_> = self
488488
.lint_groups
489489
.iter()
490-
.filter_map(|(k, LintGroup { depr, .. })| depr.is_none().then(|| k))
490+
.filter_map(|(k, LintGroup { depr, .. })| depr.is_none().then_some(k))
491491
.collect();
492492
groups.sort();
493493
let groups = groups.iter().map(|k| Symbol::intern(k));

compiler/rustc_middle/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl<'tcx> Body<'tcx> {
414414
(self.arg_count + 1..self.local_decls.len()).filter_map(move |index| {
415415
let local = Local::new(index);
416416
let decl = &self.local_decls[local];
417-
(decl.is_user_variable() && decl.mutability.is_mut()).then(|| local)
417+
(decl.is_user_variable() && decl.mutability.is_mut()).then_some(local)
418418
})
419419
}
420420

compiler/rustc_middle/src/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ impl<'tcx> Instance<'tcx> {
584584
/// this function returns `None`, then the MIR body does not require substitution during
585585
/// codegen.
586586
fn substs_for_mir_body(&self) -> Option<SubstsRef<'tcx>> {
587-
self.def.has_polymorphic_mir_body().then(|| self.substs)
587+
self.def.has_polymorphic_mir_body().then_some(self.substs)
588588
}
589589

590590
pub fn subst_mir<T>(&self, tcx: TyCtxt<'tcx>, v: &T) -> T

compiler/rustc_mir_build/src/thir/pattern/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
203203
if !lower_overflow && !higher_overflow {
204204
self.tcx.sess.emit_err(LowerRangeBoundMustBeLessThanOrEqualToUpper {
205205
span,
206-
teach: self.tcx.sess.teach(&error_code!(E0030)).then(|| ()),
206+
teach: self.tcx.sess.teach(&error_code!(E0030)).then_some(()),
207207
});
208208
}
209209
PatKind::Wild

compiler/rustc_mir_dataflow/src/impls/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeTransitiveLiveLocals<'a> {
254254
) {
255255
// Compute the place that we are storing to, if any
256256
let destination = match &statement.kind {
257-
StatementKind::Assign(assign) => assign.1.is_safe_to_remove().then(|| assign.0),
257+
StatementKind::Assign(assign) => assign.1.is_safe_to_remove().then_some(assign.0),
258258
StatementKind::SetDiscriminant { place, .. } | StatementKind::Deinit(place) => {
259259
Some(**place)
260260
}

compiler/rustc_parse/src/parser/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ impl<'a> Parser<'a> {
870870
None
871871
};
872872

873-
let maybe = self.eat(&token::Question).then(|| self.prev_token.span);
873+
let maybe = self.eat(&token::Question).then_some(self.prev_token.span);
874874

875875
Ok(BoundModifiers { maybe, maybe_const })
876876
}

compiler/rustc_parse_format/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ impl<'a> Parser<'a> {
835835
);
836836
}
837837

838-
found.then(|| cur)
838+
found.then_some(cur)
839839
}
840840

841841
fn suggest_format(&mut self) {

compiler/rustc_passes/src/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
281281
self.recurse_with_stability_attrs(
282282
depr.map(|(d, _)| DeprecationEntry::local(d, def_id)),
283283
stab,
284-
inherit_const_stability.yes().then(|| const_stab).flatten(),
284+
inherit_const_stability.yes().then_some(const_stab).flatten(),
285285
visit_children,
286286
);
287287
}

compiler/rustc_session/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
25442544
}
25452545

25462546
// Only use this directory if it has a file we can expect to always find.
2547-
candidate.join("library/std/src/lib.rs").is_file().then(|| candidate)
2547+
candidate.join("library/std/src/lib.rs").is_file().then_some(candidate)
25482548
};
25492549

25502550
let working_dir = std::env::current_dir().unwrap_or_else(|e| {

compiler/rustc_session/src/filesearch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn get_or_default_sysroot() -> Result<PathBuf, String> {
217217
// Look for the target rustlib directory in the suspected sysroot.
218218
let mut rustlib_path = rustc_target::target_rustlib_path(&p, "dummy");
219219
rustlib_path.pop(); // pop off the dummy target.
220-
rustlib_path.exists().then(|| p)
220+
rustlib_path.exists().then_some(p)
221221
}
222222
None => None,
223223
}

compiler/rustc_session/src/options.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ mod parse {
809809
if v.is_some() {
810810
let mut bool_arg = None;
811811
if parse_opt_bool(&mut bool_arg, v) {
812-
*slot = bool_arg.unwrap().then(|| MirSpanview::Statement);
812+
*slot = bool_arg.unwrap().then_some(MirSpanview::Statement);
813813
return true;
814814
}
815815
}
@@ -850,7 +850,7 @@ mod parse {
850850
if v.is_some() {
851851
let mut bool_arg = None;
852852
if parse_opt_bool(&mut bool_arg, v) {
853-
*slot = bool_arg.unwrap().then(|| InstrumentCoverage::All);
853+
*slot = bool_arg.unwrap().then_some(InstrumentCoverage::All);
854854
return true;
855855
}
856856
}

compiler/rustc_span/src/def_id.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl DefId {
320320

321321
#[inline]
322322
pub fn as_crate_root(self) -> Option<CrateNum> {
323-
self.is_crate_root().then(|| self.krate)
323+
self.is_crate_root().then_some(self.krate)
324324
}
325325

326326
#[inline]

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
771771
.iter()
772772
.chain([&obligation])
773773
.all(|obligation| self.predicate_may_hold(obligation))
774-
.then(|| steps);
774+
.then_some(steps);
775775

776776
may_hold
777777
})

compiler/rustc_trait_selection/src/traits/object_safety.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn predicate_references_self<'tcx>(
307307
match predicate.kind().skip_binder() {
308308
ty::PredicateKind::Clause(ty::Clause::Trait(ref data)) => {
309309
// In the case of a trait predicate, we can skip the "self" type.
310-
data.trait_ref.substs[1..].iter().any(has_self_ty).then(|| sp)
310+
data.trait_ref.substs[1..].iter().any(has_self_ty).then_some(sp)
311311
}
312312
ty::PredicateKind::Clause(ty::Clause::Projection(ref data)) => {
313313
// And similarly for projections. This should be redundant with
@@ -325,7 +325,7 @@ fn predicate_references_self<'tcx>(
325325
//
326326
// This is ALT2 in issue #56288, see that for discussion of the
327327
// possible alternatives.
328-
data.projection_ty.substs[1..].iter().any(has_self_ty).then(|| sp)
328+
data.projection_ty.substs[1..].iter().any(has_self_ty).then_some(sp)
329329
}
330330
ty::PredicateKind::AliasEq(..) => bug!("`AliasEq` not allowed as assumption"),
331331

compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'tcx> ChildrenExt<'tcx> for Children {
113113
// Only report the `Self` type if it has at least
114114
// some outer concrete shell; otherwise, it's
115115
// not adding much information.
116-
self_ty: self_ty.has_concrete_skeleton().then(|| self_ty),
116+
self_ty: self_ty.has_concrete_skeleton().then_some(self_ty),
117117
intercrate_ambiguity_causes: overlap.intercrate_ambiguity_causes,
118118
involves_placeholder: overlap.involves_placeholder,
119119
}

0 commit comments

Comments
 (0)