Remove needless returns detected by clippy in the compiler
This commit is contained in:
parent
adf8d168af
commit
0b20ffcb63
@ -153,7 +153,7 @@ fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
StmtKind::Let(local) => local.tokens.as_ref(),
|
||||
StmtKind::Item(item) => item.tokens(),
|
||||
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens(),
|
||||
StmtKind::Empty => return None,
|
||||
StmtKind::Empty => None,
|
||||
StmtKind::MacCall(mac) => mac.tokens.as_ref(),
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
|
||||
StmtKind::Let(local) => Some(&mut local.tokens),
|
||||
StmtKind::Item(item) => item.tokens_mut(),
|
||||
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens_mut(),
|
||||
StmtKind::Empty => return None,
|
||||
StmtKind::Empty => None,
|
||||
StmtKind::MacCall(mac) => Some(&mut mac.tokens),
|
||||
}
|
||||
}
|
||||
|
@ -1240,5 +1240,5 @@ pub fn parse_confusables(attr: &Attribute) -> Option<Vec<Symbol>> {
|
||||
candidates.push(meta_lit.symbol);
|
||||
}
|
||||
|
||||
return Some(candidates);
|
||||
Some(candidates)
|
||||
}
|
||||
|
@ -3669,7 +3669,7 @@ fn predecessor_locations<'tcx, 'a>(
|
||||
reinits.push(location);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
false
|
||||
};
|
||||
|
||||
while let Some(location) = stack.pop() {
|
||||
|
@ -214,7 +214,7 @@ fn instantiate_binder_with_existentials<T>(&mut self, binder: ty::Binder<'tcx, T
|
||||
let delegate = FnMutDelegate {
|
||||
regions: &mut |br: ty::BoundRegion| {
|
||||
if let Some(ex_reg_var) = reg_map.get(&br) {
|
||||
return *ex_reg_var;
|
||||
*ex_reg_var
|
||||
} else {
|
||||
let ex_reg_var = self.next_existential_region_var(true, br.kind.get_name());
|
||||
debug!(?ex_reg_var);
|
||||
|
@ -290,7 +290,7 @@ pub(crate) fn check_tied_features(
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
/// Used to generate cfg variables and apply features
|
||||
|
@ -438,7 +438,7 @@ fn link_rlib<'a>(
|
||||
ab.add_file(&lib)
|
||||
}
|
||||
|
||||
return Ok(ab);
|
||||
Ok(ab)
|
||||
}
|
||||
|
||||
/// Extract all symbols defined in raw-dylib libraries, collated by library name.
|
||||
@ -1319,7 +1319,7 @@ fn link_sanitizer_runtime(
|
||||
fn find_sanitizer_runtime(sess: &Session, filename: &str) -> PathBuf {
|
||||
let path = sess.target_tlib_path.dir.join(filename);
|
||||
if path.exists() {
|
||||
return sess.target_tlib_path.dir.clone();
|
||||
sess.target_tlib_path.dir.clone()
|
||||
} else {
|
||||
let default_sysroot =
|
||||
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
|
||||
@ -1327,7 +1327,7 @@ fn find_sanitizer_runtime(sess: &Session, filename: &str) -> PathBuf {
|
||||
&default_sysroot,
|
||||
sess.opts.target_triple.triple(),
|
||||
);
|
||||
return default_tlib;
|
||||
default_tlib
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1484,7 +1484,6 @@ fn no_default_libraries(&mut self) {
|
||||
fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[String]) {
|
||||
// ToDo, not implemented, copy from GCC
|
||||
self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);
|
||||
return;
|
||||
}
|
||||
|
||||
fn subsystem(&mut self, subsystem: &str) {
|
||||
|
@ -171,10 +171,10 @@ pub(super) fn get_metadata_xcoff<'a>(path: &Path, data: &'a [u8]) -> Result<&'a
|
||||
"Metadata at offset {offset} with size {len} is beyond .info section"
|
||||
));
|
||||
}
|
||||
return Ok(&info_data[offset..(offset + len)]);
|
||||
Ok(&info_data[offset..(offset + len)])
|
||||
} else {
|
||||
return Err(format!("Unable to find symbol {AIX_METADATA_SYMBOL_NAME}"));
|
||||
};
|
||||
Err(format!("Unable to find symbol {AIX_METADATA_SYMBOL_NAME}"))
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
|
||||
@ -413,7 +413,7 @@ fn pack_version((major, minor, patch): (u16, u8, u8)) -> u32 {
|
||||
|
||||
/// Is Apple's CPU subtype `arm64e`s
|
||||
fn macho_is_arm64e(target: &Target) -> bool {
|
||||
return target.llvm_target.starts_with("arm64e");
|
||||
target.llvm_target.starts_with("arm64e")
|
||||
}
|
||||
|
||||
pub enum MetadataPosition {
|
||||
|
@ -235,13 +235,13 @@ fn check_argument_compat(
|
||||
if self.layout_compat(caller_abi.layout, callee_abi.layout)? {
|
||||
// Ensure that our checks imply actual ABI compatibility for this concrete call.
|
||||
assert!(caller_abi.eq_abi(callee_abi));
|
||||
return Ok(true);
|
||||
Ok(true)
|
||||
} else {
|
||||
trace!(
|
||||
"check_argument_compat: incompatible ABIs:\ncaller: {:?}\ncallee: {:?}",
|
||||
caller_abi, callee_abi
|
||||
);
|
||||
return Ok(false);
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -773,18 +773,20 @@ fn extract_symbol_from_pnr<'a>(
|
||||
match pnr {
|
||||
ParseNtResult::Ident(nt_ident, is_raw) => {
|
||||
if let IdentIsRaw::Yes = is_raw {
|
||||
return Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR));
|
||||
Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR))
|
||||
} else {
|
||||
Ok(nt_ident.name)
|
||||
}
|
||||
return Ok(nt_ident.name);
|
||||
}
|
||||
ParseNtResult::Tt(TokenTree::Token(
|
||||
Token { kind: TokenKind::Ident(symbol, is_raw), .. },
|
||||
_,
|
||||
)) => {
|
||||
if let IdentIsRaw::Yes = is_raw {
|
||||
return Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR));
|
||||
Err(dcx.struct_span_err(span_err, RAW_IDENT_ERR))
|
||||
} else {
|
||||
Ok(*symbol)
|
||||
}
|
||||
return Ok(*symbol);
|
||||
}
|
||||
ParseNtResult::Tt(TokenTree::Token(
|
||||
Token {
|
||||
@ -792,15 +794,13 @@ fn extract_symbol_from_pnr<'a>(
|
||||
..
|
||||
},
|
||||
_,
|
||||
)) => {
|
||||
return Ok(*symbol);
|
||||
}
|
||||
)) => Ok(*symbol),
|
||||
ParseNtResult::Nt(nt)
|
||||
if let Nonterminal::NtLiteral(expr) = &**nt
|
||||
&& let ExprKind::Lit(Lit { kind: LitKind::Str, symbol, suffix: None }) =
|
||||
&expr.kind =>
|
||||
{
|
||||
return Ok(*symbol);
|
||||
Ok(*symbol)
|
||||
}
|
||||
_ => Err(dcx
|
||||
.struct_err(
|
||||
|
@ -1038,7 +1038,7 @@ fn report_trait_method_mismatch<'tcx>(
|
||||
false,
|
||||
);
|
||||
|
||||
return diag.emit();
|
||||
diag.emit()
|
||||
}
|
||||
|
||||
fn check_region_bounds_on_impl_item<'tcx>(
|
||||
|
@ -274,7 +274,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
true
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
@ -605,7 +605,7 @@ fn extract_sig_from_projection_and_future_bound(
|
||||
Abi::Rust,
|
||||
));
|
||||
|
||||
return Some(ExpectedSig { cause_span, sig });
|
||||
Some(ExpectedSig { cause_span, sig })
|
||||
}
|
||||
|
||||
fn sig_of_closure(
|
||||
|
@ -1042,7 +1042,7 @@ pub(crate) fn is_destruct_assignment_desugaring(&self, expr: &hir::Expr<'_>) ->
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
false
|
||||
}
|
||||
|
||||
fn explain_self_literal(
|
||||
|
@ -307,7 +307,7 @@ fn find_issue(&self) -> Option<Issue> {
|
||||
permutation.into_iter().map(|x| x.unwrap()).collect();
|
||||
return Some(Issue::Permutation(final_permutation));
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
// Obviously, detecting exact user intention is impossible, so the goal here is to
|
||||
@ -410,6 +410,6 @@ pub(crate) fn find_errors(
|
||||
// sort errors with same type by the order they appear in the source
|
||||
// so that suggestion will be handled properly, see #112507
|
||||
errors.sort();
|
||||
return (errors, matched_inputs);
|
||||
(errors, matched_inputs)
|
||||
}
|
||||
}
|
||||
|
@ -2028,7 +2028,7 @@ pub(crate) fn suggest_missing_unwrap_expect(
|
||||
|
||||
let span = expr.span.find_oldest_ancestor_in_same_ctxt();
|
||||
err.span_suggestion_verbose(span.shrink_to_hi(), msg, sugg, Applicability::HasPlaceholders);
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) fn suggest_coercing_result_via_try_operator(
|
||||
|
@ -1481,7 +1481,7 @@ pub fn is_ty_infer_var_definitely_unchanged<'a>(
|
||||
// This hoists the borrow/release out of the loop body.
|
||||
let inner = self.inner.try_borrow();
|
||||
|
||||
return move |infer_var: TyOrConstInferVar| match (infer_var, &inner) {
|
||||
move |infer_var: TyOrConstInferVar| match (infer_var, &inner) {
|
||||
(TyOrConstInferVar::Ty(ty_var), Ok(inner)) => {
|
||||
use self::type_variable::TypeVariableValue;
|
||||
|
||||
@ -1491,7 +1491,7 @@ pub fn is_ty_infer_var_definitely_unchanged<'a>(
|
||||
)
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// `ty_or_const_infer_var_changed` is equivalent to one of these two:
|
||||
|
@ -133,7 +133,7 @@ fn extract_iterator_next_call<'tcx>(
|
||||
{
|
||||
Some(recv)
|
||||
} else {
|
||||
return None;
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ fn next(&mut self) -> Option<Self::Item> {
|
||||
debug_assert_ne!(parent_id, self.current_id);
|
||||
|
||||
self.current_id = parent_id;
|
||||
return Some(parent_id);
|
||||
Some(parent_id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ fn next(&mut self) -> Option<Self::Item> {
|
||||
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> {
|
||||
|
@ -641,7 +641,7 @@ pub fn write_scalar(
|
||||
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(())
|
||||
}
|
||||
|
||||
/// Applies a previously prepared provenance copy.
|
||||
|
@ -1166,10 +1166,9 @@ pub fn is_ref_to_thread_local(&self) -> bool {
|
||||
/// 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.,
|
||||
|
@ -2003,7 +2003,7 @@ pub fn return_type_impl_or_dyn_traits_with_type_alias(
|
||||
));
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
/// Checks if the bound region is in Impl Item.
|
||||
|
@ -431,7 +431,7 @@ pub fn get_name(&self) -> Option<Symbol> {
|
||||
|
||||
pub fn get_id(&self) -> Option<DefId> {
|
||||
match *self {
|
||||
BoundRegionKind::BrNamed(id, _) => return Some(id),
|
||||
BoundRegionKind::BrNamed(id, _) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -82,13 +82,11 @@ fn preparse(&self, expr_id: ExprId) -> ExprId {
|
||||
fn statement_as_expr(&self, stmt_id: StmtId) -> PResult<ExprId> {
|
||||
match &self.thir[stmt_id].kind {
|
||||
StmtKind::Expr { expr, .. } => Ok(*expr),
|
||||
kind @ StmtKind::Let { pattern, .. } => {
|
||||
return Err(ParseError {
|
||||
span: pattern.span,
|
||||
item_description: format!("{kind:?}"),
|
||||
expected: "expression".to_string(),
|
||||
});
|
||||
}
|
||||
kind @ StmtKind::Let { pattern, .. } => Err(ParseError {
|
||||
span: pattern.span,
|
||||
item_description: format!("{kind:?}"),
|
||||
expected: "expression".to_string(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) ->
|
||||
return Some(new.def_id);
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
/// Scans the MIR in order to find function calls, closures, and drop-glue.
|
||||
|
@ -299,7 +299,7 @@ fn unclosed_delim_err(
|
||||
}
|
||||
return diff_errs;
|
||||
}
|
||||
return errs;
|
||||
errs
|
||||
}
|
||||
|
||||
fn close_delim_err(&mut self, delim: Delimiter) -> PErr<'psess> {
|
||||
|
@ -2553,7 +2553,7 @@ pub(super) fn handle_ambiguous_unbraced_const_arg(
|
||||
err.delay_as_bug();
|
||||
}
|
||||
}
|
||||
return Ok(false); // Don't continue.
|
||||
Ok(false) // Don't continue.
|
||||
}
|
||||
|
||||
/// Attempt to parse a generic const argument that has not been enclosed in braces.
|
||||
|
@ -457,7 +457,7 @@ fn recover_missing_kw_before_item(&mut self) -> PResult<'a, ()> {
|
||||
|
||||
fn parse_item_builtin(&mut self) -> PResult<'a, Option<ItemInfo>> {
|
||||
// To be expanded
|
||||
return Ok(None);
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Parses an item macro, e.g., `item!();`.
|
||||
|
@ -1905,10 +1905,7 @@ fn check_repr(
|
||||
|| (int_reprs == 1
|
||||
&& is_c
|
||||
&& item.is_some_and(|item| {
|
||||
if let ItemLike::Item(item) = item {
|
||||
return is_c_like_enum(item);
|
||||
}
|
||||
return false;
|
||||
if let ItemLike::Item(item) = item { is_c_like_enum(item) } else { false }
|
||||
}))
|
||||
{
|
||||
self.tcx.emit_node_span_lint(
|
||||
|
@ -394,7 +394,7 @@ fn should_ignore_item(&mut self, def_id: DefId) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
false
|
||||
}
|
||||
|
||||
fn visit_node(&mut self, node: Node<'tcx>) {
|
||||
|
@ -3076,7 +3076,7 @@ fn search_for_any_use_in_items(items: &[P<ast::Item>]) -> Option<Span> {
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
fn is_span_suitable_for_use_injection(s: Span) -> bool {
|
||||
|
@ -5016,5 +5016,5 @@ fn def_id_matches_path(tcx: TyCtxt<'_>, mut def_id: DefId, expected_path: &[&str
|
||||
}
|
||||
def_id = parent;
|
||||
}
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
@ -779,7 +779,7 @@ fn try_lookup_name_relaxed(
|
||||
candidates = self.smart_resolve_partial_mod_path_errors(path, following_seg);
|
||||
}
|
||||
|
||||
return (false, candidates);
|
||||
(false, candidates)
|
||||
}
|
||||
|
||||
fn suggest_trait_and_bounds(
|
||||
|
@ -182,7 +182,7 @@ fn current_dll_path() -> Result<PathBuf, String> {
|
||||
}
|
||||
}
|
||||
|
||||
return sysroot_candidates;
|
||||
sysroot_candidates
|
||||
}
|
||||
|
||||
/// Returns the provided sysroot or calls [`get_or_default_sysroot`] if it's none.
|
||||
|
@ -353,7 +353,7 @@ fn build_options<O: Default>(
|
||||
None => early_dcx.early_fatal(format!("unknown {outputname} option: `{key}`")),
|
||||
}
|
||||
}
|
||||
return op;
|
||||
op
|
||||
}
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
|
@ -779,7 +779,7 @@ pub fn span_wrapped_by_angle_or_parentheses(&self, span: Span) -> bool {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
return Ok(true);
|
||||
Ok(true)
|
||||
})
|
||||
.is_ok_and(|is_accessible| is_accessible)
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ pub fn eq_abi(&self, other: &Self) -> bool {
|
||||
if self.arg_ext != other.arg_ext {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@ -632,7 +632,7 @@ pub fn make_direct_deprecated(&mut self) {
|
||||
PassMode::Indirect { .. } => {
|
||||
self.mode = PassMode::Direct(ArgAttributes::new());
|
||||
}
|
||||
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) => return, // already direct
|
||||
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) => {} // already direct
|
||||
_ => panic!("Tried to make {:?} direct", self.mode),
|
||||
}
|
||||
}
|
||||
@ -646,7 +646,6 @@ pub fn make_indirect(&mut self) {
|
||||
}
|
||||
PassMode::Indirect { attrs: _, meta_attrs: _, on_stack: false } => {
|
||||
// already indirect
|
||||
return;
|
||||
}
|
||||
_ => panic!("Tried to make {:?} indirect", self.mode),
|
||||
}
|
||||
@ -661,7 +660,6 @@ pub fn make_indirect_from_ignore(&mut self) {
|
||||
}
|
||||
PassMode::Indirect { attrs: _, meta_attrs: _, on_stack: false } => {
|
||||
// already indirect
|
||||
return;
|
||||
}
|
||||
_ => panic!("Tried to make {:?} indirect (expected `PassMode::Ignore`)", self.mode),
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ fn arg_scalar<C>(cx: &C, scalar: &Scalar, offset: Size, mut data: Sdata) -> Sdat
|
||||
data.last_offset = offset + Reg::f64().size;
|
||||
}
|
||||
data.prefix_index += 1;
|
||||
return data;
|
||||
data
|
||||
}
|
||||
|
||||
fn arg_scalar_pair<C>(
|
||||
@ -92,7 +92,7 @@ fn arg_scalar_pair<C>(
|
||||
offset += Size::from_bytes(4 - (offset.bytes() % 4));
|
||||
}
|
||||
data = arg_scalar(cx, scalar2, offset, data);
|
||||
return data;
|
||||
data
|
||||
}
|
||||
|
||||
fn parse_structure<'a, Ty, C>(
|
||||
@ -128,7 +128,7 @@ fn parse_structure<'a, Ty, C>(
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
data
|
||||
}
|
||||
|
||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, in_registers_max: Size)
|
||||
|
Loading…
Reference in New Issue
Block a user