Adopt let else in more places
This commit is contained in:
parent
b8c56fa8c3
commit
2ef8af6619
132 changed files with 539 additions and 881 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue