Skip to content

Commit b7795e1

Browse files
committed
fix clippy::{needless_bool, manual_unwrap_or}
1 parent db6c509 commit b7795e1

File tree

5 files changed

+17
-29
lines changed

5 files changed

+17
-29
lines changed

compiler/rustc_mir/src/transform/early_otherwise_branch.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ impl<'a, 'tcx> Helper<'a, 'tcx> {
216216
let discr = self.find_switch_discriminant_info(bb, switch)?;
217217

218218
// go through each target, finding a discriminant read, and a switch
219-
let results = discr.targets_with_values.iter().map(|(value, target)| {
220-
self.find_discriminant_switch_pairing(&discr, *target, *value)
221-
});
219+
let results = discr
220+
.targets_with_values
221+
.iter()
222+
.map(|(value, target)| self.find_discriminant_switch_pairing(&discr, *target, *value));
222223

223224
// if the optimization did not apply for one of the targets, then abort
224225
if results.clone().any(|x| x.is_none()) || results.len() == 0 {

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,10 +1109,7 @@ impl Session {
11091109
}
11101110

11111111
pub fn link_dead_code(&self) -> bool {
1112-
match self.opts.cg.link_dead_code {
1113-
Some(explicitly_set) => explicitly_set,
1114-
None => false,
1115-
}
1112+
self.opts.cg.link_dead_code.unwrap_or(false)
11161113
}
11171114

11181115
pub fn mark_attr_known(&self, attr: &Attribute) {

compiler/rustc_typeck/src/check/upvar.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
297297

298298
closure_captures.insert(*var_hir_id, upvar_id);
299299

300-
let new_capture_kind = if let Some(capture_kind) =
301-
upvar_capture_map.get(&upvar_id)
302-
{
303-
// upvar_capture_map only stores the UpvarCapture (CaptureKind),
304-
// so we create a fake capture info with no expression.
305-
let fake_capture_info =
306-
ty::CaptureInfo { expr_id: None, capture_kind: *capture_kind };
307-
determine_capture_info(fake_capture_info, capture_info).capture_kind
308-
} else {
309-
capture_info.capture_kind
310-
};
300+
let new_capture_kind =
301+
if let Some(capture_kind) = upvar_capture_map.get(&upvar_id) {
302+
// upvar_capture_map only stores the UpvarCapture (CaptureKind),
303+
// so we create a fake capture info with no expression.
304+
let fake_capture_info =
305+
ty::CaptureInfo { expr_id: None, capture_kind: *capture_kind };
306+
determine_capture_info(fake_capture_info, capture_info).capture_kind
307+
} else {
308+
capture_info.capture_kind
309+
};
311310
upvar_capture_map.insert(upvar_id, new_capture_kind);
312311
}
313312
}

compiler/rustc_typeck/src/collect.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,13 +2141,8 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
21412141
// * It must be an associated type for this trait (*not* a
21422142
// supertrait).
21432143
if let ty::Projection(projection) = ty.kind() {
2144-
if projection.substs == trait_identity_substs
2144+
projection.substs == trait_identity_substs
21452145
&& tcx.associated_item(projection.item_def_id).container.id() == def_id
2146-
{
2147-
true
2148-
} else {
2149-
false
2150-
}
21512146
} else {
21522147
false
21532148
}

src/bootstrap/sanity.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,7 @@ pub fn check(build: &mut Build) {
159159
panic!("the iOS target is only supported on macOS");
160160
}
161161

162-
build
163-
.config
164-
.target_config
165-
.entry(*target)
166-
.or_insert(Target::from_triple(&target.triple));
162+
build.config.target_config.entry(*target).or_insert(Target::from_triple(&target.triple));
167163

168164
if target.contains("-none-") || target.contains("nvptx") {
169165
if build.no_std(*target) == Some(false) {

0 commit comments

Comments
 (0)