Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errors

Remove needless returns detected by clippy in the compiler
This commit is contained in:
Jubilee
2024-09-11 15:53:22 -07:00
committed by GitHub
38 changed files with 66 additions and 75 deletions

View File

@@ -71,7 +71,7 @@ impl<'hir> Iterator for ParentHirIterator<'hir> {
debug_assert_ne!(parent_id, self.current_id);
self.current_id = parent_id;
return Some(parent_id);
Some(parent_id)
}
}
@@ -103,7 +103,7 @@ impl<'hir> Iterator for ParentOwnerIterator<'hir> {
self.current_id = HirId::make_owner(parent_id.def_id);
let node = self.map.tcx.hir_owner_node(self.current_id.owner);
return Some((self.current_id.owner, node));
Some((self.current_id.owner, node))
}
}
@@ -1233,14 +1233,14 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
body_owners,
..
} = collector;
return ModuleItems {
ModuleItems {
submodules: submodules.into_boxed_slice(),
free_items: items.into_boxed_slice(),
trait_items: trait_items.into_boxed_slice(),
impl_items: impl_items.into_boxed_slice(),
foreign_items: foreign_items.into_boxed_slice(),
body_owners: body_owners.into_boxed_slice(),
};
}
}
pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
@@ -1262,14 +1262,14 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
..
} = collector;
return ModuleItems {
ModuleItems {
submodules: submodules.into_boxed_slice(),
free_items: items.into_boxed_slice(),
trait_items: trait_items.into_boxed_slice(),
impl_items: impl_items.into_boxed_slice(),
foreign_items: foreign_items.into_boxed_slice(),
body_owners: body_owners.into_boxed_slice(),
};
}
}
struct ItemCollector<'tcx> {

View File

@@ -641,7 +641,7 @@ impl<Prov: Provenance, Extra, Bytes: AllocBytes> Allocation<Prov, Extra, Bytes>
pub fn write_uninit(&mut self, cx: &impl HasDataLayout, range: AllocRange) -> AllocResult {
self.mark_init(range, false);
self.provenance.clear(range, cx)?;
return Ok(());
Ok(())
}
/// Remove all provenance in the given memory range.

View File

@@ -1166,10 +1166,9 @@ impl<'tcx> LocalDecl<'tcx> {
/// Returns `true` if this is a DerefTemp
pub fn is_deref_temp(&self) -> bool {
match self.local_info() {
LocalInfo::DerefTemp => return true,
_ => (),
LocalInfo::DerefTemp => true,
_ => false,
}
return false;
}
/// Returns `true` is the local is from a compiler desugaring, e.g.,

View File

@@ -2007,7 +2007,7 @@ impl<'tcx> TyCtxt<'tcx> {
));
}
}
return None;
None
}
/// Checks if the bound region is in Impl Item.

View File

@@ -431,7 +431,7 @@ impl BoundRegionKind {
pub fn get_id(&self) -> Option<DefId> {
match *self {
BoundRegionKind::BrNamed(id, _) => return Some(id),
BoundRegionKind::BrNamed(id, _) => Some(id),
_ => None,
}
}