diff options
| author | est31 <MTest31@outlook.com> | 2022-02-19 00:48:49 +0100 | 
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2022-02-19 17:27:43 +0100 | 
| commit | 2ef8af66196f7cc270a0532ea989f2fc6bc6885d (patch) | |
| tree | e023e65e895d79575848f47b3d00129f9c5a9f0f /compiler/rustc_lint/src | |
| parent | b8c56fa8c30821129b0960180f528d4a1a4f9316 (diff) | |
| download | rust-2ef8af66196f7cc270a0532ea989f2fc6bc6885d.tar.gz rust-2ef8af66196f7cc270a0532ea989f2fc6bc6885d.zip | |
Adopt let else in more places
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/internal.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/levels.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/non_ascii_idents.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/types.rs | 9 | 
5 files changed, 8 insertions, 22 deletions
| diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index d2d853efda2..e9996a7ef14 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -278,9 +278,8 @@ impl LintStore { /// This lint has been renamed; warn about using the new name and apply the lint. #[track_caller] pub fn register_renamed(&mut self, old_name: &str, new_name: &str) { - let target = match self.by_name.get(new_name) { - Some(&Id(lint_id)) => lint_id, - _ => bug!("invalid lint renaming of {} to {}", old_name, new_name), + let Some(&Id(target)) = self.by_name.get(new_name) else { + bug!("invalid lint renaming of {} to {}", old_name, new_name); }; self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target)); } diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 944a0996427..5078c240ec7 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -23,10 +23,7 @@ declare_lint_pass!(DefaultHashTypes => [DEFAULT_HASH_TYPES]); impl LateLintPass<'_> for DefaultHashTypes { fn check_path(&mut self, cx: &LateContext<'_>, path: &Path<'_>, hir_id: HirId) { - let def_id = match path.res { - Res::Def(rustc_hir::def::DefKind::Struct, id) => id, - _ => return, - }; + let Res::Def(rustc_hir::def::DefKind::Struct, def_id) = path.res else { return }; if matches!(cx.tcx.hir().get(hir_id), Node::Item(Item { kind: ItemKind::Use(..), .. })) { // don't lint imports, only actual usages return; diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 8afbd462c14..35c7d885e1d 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -95,9 +95,9 @@ impl<'s> LintLevelsBuilder<'s> { let orig_level = level; let lint_flag_val = Symbol::intern(lint_name); - let ids = match store.find_lints(&lint_name) { - Ok(ids) => ids, - Err(_) => continue, // errors handled in check_lint_name_cmdline above + let Ok(ids) = store.find_lints(&lint_name) else { + // errors handled in check_lint_name_cmdline above + continue }; for id in ids { // ForceWarn and Forbid cannot be overriden diff --git a/compiler/rustc_lint/src/non_ascii_idents.rs b/compiler/rustc_lint/src/non_ascii_idents.rs index 2dd6dbd67a8..264a80339cc 100644 --- a/compiler/rustc_lint/src/non_ascii_idents.rs +++ b/compiler/rustc_lint/src/non_ascii_idents.rs @@ -301,10 +301,7 @@ impl EarlyLintPass for NonAsciiIdents { BTreeMap::new(); 'outerloop: for (augment_script_set, usage) in script_states { - let (mut ch_list, sp) = match usage { - ScriptSetUsage::Verified => continue, - ScriptSetUsage::Suspicious(ch_list, sp) => (ch_list, sp), - }; + let ScriptSetUsage::Suspicious(mut ch_list, sp) = usage else { continue }; if augment_script_set.is_all() { continue; diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index fc88e8cd912..5cd3791583f 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1331,14 +1331,7 @@ impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences { if let hir::ItemKind::Enum(ref enum_definition, _) = it.kind { let t = cx.tcx.type_of(it.def_id); let ty = cx.tcx.erase_regions(t); - let layout = match cx.layout_of(ty) { - Ok(layout) => layout, - Err( - ty::layout::LayoutError::Unknown(_) - | ty::layout::LayoutError::SizeOverflow(_) - | ty::layout::LayoutError::NormalizationFailure(_, _), - ) => return, - }; + let Ok(layout) = cx.layout_of(ty) else { return }; let Variants::Multiple { tag_encoding: TagEncoding::Direct, tag, ref variants, .. } = &layout.variants else { | 
