Skip to content

Commit f697955

Browse files
committed
tut tut tut
1 parent de1026a commit f697955

File tree

8 files changed

+16
-29
lines changed

8 files changed

+16
-29
lines changed

compiler/rustc_expand/src/base.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1272,9 +1272,7 @@ pub fn parse_macro_name_and_helper_attrs(
12721272
// Once we've located the `#[proc_macro_derive]` attribute, verify
12731273
// that it's of the form `#[proc_macro_derive(Foo)]` or
12741274
// `#[proc_macro_derive(Foo, attributes(A, ..))]`
1275-
let Some(list) = attr.meta_item_list() else {
1276-
return None;
1277-
};
1275+
let list = attr.meta_item_list()?;
12781276
if list.len() != 1 && list.len() != 2 {
12791277
diag.span_err(attr.span, "attribute must have either one or two arguments");
12801278
return None;

compiler/rustc_index/src/bit_set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
17141714
}
17151715

17161716
pub fn row(&self, row: R) -> Option<&HybridBitSet<C>> {
1717-
if let Some(Some(row)) = self.rows.get(row) { Some(row) } else { None }
1717+
self.rows.get(row)?.as_ref()
17181718
}
17191719

17201720
/// Intersects `row` with `set`. `set` can be either `BitSet` or

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,16 @@ pub(crate) fn find_anon_type<'tcx>(
2525
region: Region<'tcx>,
2626
br: &ty::BoundRegionKind,
2727
) -> Option<(&'tcx hir::Ty<'tcx>, &'tcx hir::FnSig<'tcx>)> {
28-
if let Some(anon_reg) = tcx.is_suitable_region(region) {
29-
let hir_id = tcx.hir().local_def_id_to_hir_id(anon_reg.def_id);
30-
let Some(fn_sig) = tcx.hir().get(hir_id).fn_sig() else {
31-
return None
32-
};
28+
let anon_reg = tcx.is_suitable_region(region)?;
29+
let hir_id = tcx.hir().local_def_id_to_hir_id(anon_reg.def_id);
30+
let fn_sig = tcx.hir().get(hir_id).fn_sig()?;
3331

34-
fn_sig
35-
.decl
36-
.inputs
37-
.iter()
38-
.find_map(|arg| find_component_for_bound_region(tcx, arg, br))
39-
.map(|ty| (ty, fn_sig))
40-
} else {
41-
None
42-
}
32+
fn_sig
33+
.decl
34+
.inputs
35+
.iter()
36+
.find_map(|arg| find_component_for_bound_region(tcx, arg, br))
37+
.map(|ty| (ty, fn_sig))
4338
}
4439

4540
// This method creates a FindNestedTypeVisitor which returns the type corresponding

compiler/rustc_mir_transform/src/early_otherwise_branch.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,7 @@ fn evaluate_candidate<'tcx>(
336336
Some(poss)
337337
}
338338
};
339-
let Some((_, child)) = targets.iter().next() else {
340-
return None
341-
};
339+
let (_, child) = targets.iter().next()?;
342340
let child_terminator = &bbs[child].terminator();
343341
let TerminatorKind::SwitchInt {
344342
switch_ty: child_ty,

compiler/rustc_parse/src/lexer/unicode_chars.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,7 @@ pub(super) fn check_for_substitution<'a>(
338338
ch: char,
339339
err: &mut Diagnostic,
340340
) -> Option<token::TokenKind> {
341-
let Some(&(_u_char, u_name, ascii_char)) = UNICODE_ARRAY.iter().find(|&&(c, _, _)| c == ch) else {
342-
return None;
343-
};
341+
let &(_u_char, u_name, ascii_char) = UNICODE_ARRAY.iter().find(|&&(c, _, _)| c == ch)?;
344342

345343
let span = Span::with_root_ctxt(pos, pos + Pos::from_usize(ch.len_utf8()));
346344

compiler/rustc_resolve/src/late/diagnostics.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
11831183
ident: Symbol,
11841184
kind: &AssocItemKind,
11851185
) -> Option<Symbol> {
1186-
let Some((module, _)) = &self.current_trait_ref else {
1187-
return None;
1188-
};
1186+
let (module, _) = self.current_trait_ref.as_ref()?;
11891187
if ident == kw::Underscore {
11901188
// We do nothing for `_`.
11911189
return None;

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
757757
formal_args: &[Ty<'tcx>],
758758
) -> Option<Vec<Ty<'tcx>>> {
759759
let formal_ret = self.resolve_vars_with_obligations(formal_ret);
760-
let Some(ret_ty) = expected_ret.only_has_type(self) else { return None };
760+
let ret_ty = expected_ret.only_has_type(self)?;
761761

762762
// HACK(oli-obk): This is a hack to keep RPIT and TAIT in sync wrt their behaviour.
763763
// Without it, the inference

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
13051305
fn maybe_expand_private_type_alias(cx: &mut DocContext<'_>, path: &hir::Path<'_>) -> Option<Type> {
13061306
let Res::Def(DefKind::TyAlias, def_id) = path.res else { return None };
13071307
// Substitute private type aliases
1308-
let Some(def_id) = def_id.as_local() else { return None };
1308+
let def_id = def_id.as_local()?;
13091309
let alias = if !cx.cache.access_levels.is_exported(def_id.to_def_id()) {
13101310
&cx.tcx.hir().expect_item(def_id).kind
13111311
} else {

0 commit comments

Comments
 (0)