remove redundant returns (clippy::needless_return)

This commit is contained in:
Matthias Krüger 2020-03-20 15:03:11 +01:00
parent 951a3661ad
commit ad00e91887
84 changed files with 142 additions and 170 deletions

View file

@ -114,6 +114,6 @@ pub fn black_box<T>(dummy: T) -> T {
// more than we want, but it's so far good enough. // more than we want, but it's so far good enough.
unsafe { unsafe {
asm!("" : : "r"(&dummy)); asm!("" : : "r"(&dummy));
return dummy; dummy
} }
} }

View file

@ -85,7 +85,7 @@ impl LintLevelSets {
level = cmp::min(*driver_level, level); level = cmp::min(*driver_level, level);
} }
return (level, src); (level, src)
} }
pub fn get_lint_id_level( pub fn get_lint_id_level(

View file

@ -467,7 +467,7 @@ impl<'tcx> ScopeTree {
} }
debug!("temporary_scope({:?}) = None", expr_id); debug!("temporary_scope({:?}) = None", expr_id);
return None; None
} }
/// Returns the lifetime of the variable `id`. /// Returns the lifetime of the variable `id`.
@ -498,7 +498,7 @@ impl<'tcx> ScopeTree {
debug!("is_subscope_of({:?}, {:?})=true", subscope, superscope); debug!("is_subscope_of({:?}, {:?})=true", subscope, superscope);
return true; true
} }
/// Returns the ID of the innermost containing body. /// Returns the ID of the innermost containing body.

View file

@ -1447,11 +1447,11 @@ impl<'tcx> TyCtxt<'tcx> {
_ => return None, _ => return None,
}; };
return Some(FreeRegionInfo { Some(FreeRegionInfo {
def_id: suitable_region_binding_scope, def_id: suitable_region_binding_scope,
boundregion: bound_region, boundregion: bound_region,
is_impl_item, is_impl_item,
}); })
} }
pub fn return_type_impl_trait(&self, scope_def_id: DefId) -> Option<(Ty<'tcx>, Span)> { pub fn return_type_impl_trait(&self, scope_def_id: DefId) -> Option<(Ty<'tcx>, Span)> {

View file

@ -440,7 +440,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
(Some(sz_a_val), Some(sz_b_val)) => Err(TypeError::FixedArraySize( (Some(sz_a_val), Some(sz_b_val)) => Err(TypeError::FixedArraySize(
expected_found(relation, &sz_a_val, &sz_b_val), expected_found(relation, &sz_a_val, &sz_b_val),
)), )),
_ => return Err(err), _ => Err(err),
} }
} }
} }

View file

@ -1612,7 +1612,7 @@ impl<'tcx> PolyExistentialProjection<'tcx> {
} }
pub fn item_def_id(&self) -> DefId { pub fn item_def_id(&self) -> DefId {
return self.skip_binder().item_def_id; self.skip_binder().item_def_id
} }
} }
@ -2000,8 +2000,8 @@ impl<'tcx> TyS<'tcx> {
#[inline] #[inline]
pub fn is_unsafe_ptr(&self) -> bool { pub fn is_unsafe_ptr(&self) -> bool {
match self.kind { match self.kind {
RawPtr(_) => return true, RawPtr(_) => true,
_ => return false, _ => false,
} }
} }

View file

@ -524,7 +524,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
self.root_ty = None; self.root_ty = None;
} }
return t1; t1
} }
fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {

View file

@ -87,7 +87,7 @@ fn decodable_substructure(
let blkarg = cx.ident_of("_d", trait_span); let blkarg = cx.ident_of("_d", trait_span);
let blkdecoder = cx.expr_ident(trait_span, blkarg); let blkdecoder = cx.expr_ident(trait_span, blkarg);
return match *substr.fields { match *substr.fields {
StaticStruct(_, ref summary) => { StaticStruct(_, ref summary) => {
let nfields = match *summary { let nfields = match *summary {
Unnamed(ref fields, _) => fields.len(), Unnamed(ref fields, _) => fields.len(),
@ -178,7 +178,7 @@ fn decodable_substructure(
) )
} }
_ => cx.bug("expected StaticEnum or StaticStruct in derive(Decodable)"), _ => cx.bug("expected StaticEnum or StaticStruct in derive(Decodable)"),
}; }
} }
/// Creates a decoder for a single enum variant/struct: /// Creates a decoder for a single enum variant/struct:

View file

@ -53,7 +53,7 @@ fn default_substructure(
let default_ident = cx.std_path(&[kw::Default, sym::Default, kw::Default]); let default_ident = cx.std_path(&[kw::Default, sym::Default, kw::Default]);
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new()); let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
return match *substr.fields { match *substr.fields {
StaticStruct(_, ref summary) => match *summary { StaticStruct(_, ref summary) => match *summary {
Unnamed(ref fields, is_tuple) => { Unnamed(ref fields, is_tuple) => {
if !is_tuple { if !is_tuple {
@ -83,5 +83,5 @@ fn default_substructure(
DummyResult::raw_expr(trait_span, true) DummyResult::raw_expr(trait_span, true)
} }
_ => cx.span_bug(trait_span, "method in `derive(Default)`"), _ => cx.span_bug(trait_span, "method in `derive(Default)`"),
}; }
} }

View file

@ -173,7 +173,7 @@ fn encodable_substructure(
], ],
)); ));
return match *substr.fields { match *substr.fields {
Struct(_, ref fields) => { Struct(_, ref fields) => {
let emit_struct_field = cx.ident_of("emit_struct_field", trait_span); let emit_struct_field = cx.ident_of("emit_struct_field", trait_span);
let mut stmts = Vec::new(); let mut stmts = Vec::new();
@ -283,5 +283,5 @@ fn encodable_substructure(
} }
_ => cx.bug("expected Struct or EnumMatching in derive(Encodable)"), _ => cx.bug("expected Struct or EnumMatching in derive(Encodable)"),
}; }
} }

View file

@ -489,7 +489,6 @@ impl<'a> TraitDef<'a> {
// set earlier; see // set earlier; see
// librustc_expand/expand.rs:MacroExpander::fully_expand_fragment() // librustc_expand/expand.rs:MacroExpander::fully_expand_fragment()
// librustc_expand/base.rs:Annotatable::derive_allowed() // librustc_expand/base.rs:Annotatable::derive_allowed()
return;
} }
} }
} }

View file

@ -359,7 +359,7 @@ pub mod printf {
// //
// Note: `move` used to capture copies of the cursors as they are *now*. // Note: `move` used to capture copies of the cursors as they are *now*.
let fallback = move || { let fallback = move || {
return Some(( Some((
Substitution::Format(Format { Substitution::Format(Format {
span: start.slice_between(next).unwrap(), span: start.slice_between(next).unwrap(),
parameter: None, parameter: None,
@ -371,7 +371,7 @@ pub mod printf {
position: InnerSpan::new(start.at, next.at), position: InnerSpan::new(start.at, next.at),
}), }),
next.slice_after(), next.slice_after(),
)); ))
}; };
// Next parsing state. // Next parsing state.

View file

@ -146,7 +146,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
} }
// ok, don't skip this // ok, don't skip this
return false; false
}) })
} }

View file

@ -83,7 +83,7 @@ pub fn encode(identifier: &str, bytecode: &[u8]) -> Vec<u8> {
encoded.push(0); encoded.push(0);
} }
return encoded; encoded
} }
pub struct DecodedBytecode<'a> { pub struct DecodedBytecode<'a> {
@ -132,7 +132,7 @@ impl<'a> DecodedBytecode<'a> {
pub fn bytecode(&self) -> Vec<u8> { pub fn bytecode(&self) -> Vec<u8> {
let mut data = Vec::new(); let mut data = Vec::new();
DeflateDecoder::new(self.encoded_bytecode).read_to_end(&mut data).unwrap(); DeflateDecoder::new(self.encoded_bytecode).read_to_end(&mut data).unwrap();
return data; data
} }
pub fn identifier(&self) -> &'a str { pub fn identifier(&self) -> &'a str {

View file

@ -96,15 +96,11 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
impl CodegenCx<'ll, 'tcx> { impl CodegenCx<'ll, 'tcx> {
pub fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value { pub fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
unsafe { unsafe { llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint) }
return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
}
} }
pub fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value { pub fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
unsafe { unsafe { llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint) }
return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
}
} }
pub fn const_bytes(&self, bytes: &[u8]) -> &'ll Value { pub fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
@ -330,7 +326,7 @@ pub fn val_ty(v: &Value) -> &Type {
pub fn bytes_in_context(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value { pub fn bytes_in_context(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
unsafe { unsafe {
let ptr = bytes.as_ptr() as *const c_char; let ptr = bytes.as_ptr() as *const c_char;
return llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True); llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True)
} }
} }

View file

@ -800,7 +800,7 @@ impl CodegenCx<'b, 'tcx> {
ifn!("llvm.dbg.declare", fn(self.type_metadata(), self.type_metadata()) -> void); ifn!("llvm.dbg.declare", fn(self.type_metadata(), self.type_metadata()) -> void);
ifn!("llvm.dbg.value", fn(self.type_metadata(), t_i64, self.type_metadata()) -> void); ifn!("llvm.dbg.value", fn(self.type_metadata(), t_i64, self.type_metadata()) -> void);
} }
return None; None
} }
} }

View file

@ -203,7 +203,7 @@ impl TypeMap<'ll, 'tcx> {
let key = self.unique_id_interner.intern(&unique_type_id); let key = self.unique_id_interner.intern(&unique_type_id);
self.type_to_unique_id.insert(type_, UniqueTypeId(key)); self.type_to_unique_id.insert(type_, UniqueTypeId(key));
return UniqueTypeId(key); UniqueTypeId(key)
} }
/// Gets the `UniqueTypeId` for an enum variant. Enum variants are not really /// Gets the `UniqueTypeId` for an enum variant. Enum variants are not really
@ -314,7 +314,7 @@ impl RecursiveTypeDescription<'ll, 'tcx> {
member_holding_stub, member_holding_stub,
member_descriptions, member_descriptions,
); );
return MetadataCreationResult::new(metadata_stub, true); MetadataCreationResult::new(metadata_stub, true)
} }
} }
} }
@ -364,7 +364,7 @@ fn fixed_vec_metadata(
) )
}; };
return MetadataCreationResult::new(metadata, false); MetadataCreationResult::new(metadata, false)
} }
fn vec_slice_metadata( fn vec_slice_metadata(
@ -445,7 +445,7 @@ fn subroutine_type_metadata(
return_if_metadata_created_in_meantime!(cx, unique_type_id); return_if_metadata_created_in_meantime!(cx, unique_type_id);
return MetadataCreationResult::new( MetadataCreationResult::new(
unsafe { unsafe {
llvm::LLVMRustDIBuilderCreateSubroutineType( llvm::LLVMRustDIBuilderCreateSubroutineType(
DIB(cx), DIB(cx),
@ -454,7 +454,7 @@ fn subroutine_type_metadata(
) )
}, },
false, false,
); )
} }
// FIXME(1563): This is all a bit of a hack because 'trait pointer' is an ill- // FIXME(1563): This is all a bit of a hack because 'trait pointer' is an ill-
@ -781,7 +781,7 @@ fn file_metadata_raw(
let key = (file_name, directory); let key = (file_name, directory);
match debug_context(cx).created_files.borrow_mut().entry(key) { match debug_context(cx).created_files.borrow_mut().entry(key) {
Entry::Occupied(o) => return o.get(), Entry::Occupied(o) => o.get(),
Entry::Vacant(v) => { Entry::Vacant(v) => {
let (file_name, directory) = v.key(); let (file_name, directory) = v.key();
debug!("file_metadata: file_name: {:?}, directory: {:?}", file_name, directory); debug!("file_metadata: file_name: {:?}, directory: {:?}", file_name, directory);
@ -831,7 +831,7 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
) )
}; };
return ty_metadata; ty_metadata
} }
fn foreign_type_metadata( fn foreign_type_metadata(
@ -1273,11 +1273,11 @@ fn prepare_union_metadata(
fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool { fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
// On MSVC we have to use the fallback mode, because LLVM doesn't // On MSVC we have to use the fallback mode, because LLVM doesn't
// lower variant parts to PDB. // lower variant parts to PDB.
return cx.sess().target.target.options.is_like_msvc cx.sess().target.target.options.is_like_msvc
// LLVM version 7 did not release with an important bug fix; // LLVM version 7 did not release with an important bug fix;
// but the required patch is in the LLVM 8. Rust LLVM reports // but the required patch is in the LLVM 8. Rust LLVM reports
// 8 as well. // 8 as well.
|| llvm_util::get_major_version() < 8; || llvm_util::get_major_version() < 8
} }
// FIXME(eddyb) maybe precompute this? Right now it's computed once // FIXME(eddyb) maybe precompute this? Right now it's computed once
@ -2075,7 +2075,7 @@ fn prepare_enum_metadata(
} }
}; };
return create_and_register_recursive_type_forward_declaration( create_and_register_recursive_type_forward_declaration(
cx, cx,
enum_type, enum_type,
unique_type_id, unique_type_id,
@ -2088,7 +2088,7 @@ fn prepare_enum_metadata(
containing_scope, containing_scope,
span, span,
}), }),
); )
} }
/// Creates debug information for a composite type, that is, anything that /// Creates debug information for a composite type, that is, anything that

View file

@ -444,7 +444,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
vec![] vec![]
}; };
return create_DIArray(DIB(cx), &template_params[..]); create_DIArray(DIB(cx), &template_params[..])
} }
fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> { fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {

View file

@ -24,9 +24,7 @@ pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool {
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub fn create_DIArray(builder: &DIBuilder<'ll>, arr: &[Option<&'ll DIDescriptor>]) -> &'ll DIArray { pub fn create_DIArray(builder: &DIBuilder<'ll>, arr: &[Option<&'ll DIDescriptor>]) -> &'ll DIArray {
return unsafe { unsafe { llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) }
llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32)
};
} }
#[inline] #[inline]

View file

@ -27,13 +27,13 @@ impl ArchiveRO {
/// If this archive is used with a mutable method, then an error will be /// If this archive is used with a mutable method, then an error will be
/// raised. /// raised.
pub fn open(dst: &Path) -> Result<ArchiveRO, String> { pub fn open(dst: &Path) -> Result<ArchiveRO, String> {
return unsafe { unsafe {
let s = path_to_c_string(dst); let s = path_to_c_string(dst);
let ar = super::LLVMRustOpenArchive(s.as_ptr()).ok_or_else(|| { let ar = super::LLVMRustOpenArchive(s.as_ptr()).ok_or_else(|| {
super::last_error().unwrap_or_else(|| "failed to open archive".to_owned()) super::last_error().unwrap_or_else(|| "failed to open archive".to_owned())
})?; })?;
Ok(ArchiveRO { raw: ar }) Ok(ArchiveRO { raw: ar })
}; }
} }
pub fn iter(&self) -> Iter<'_> { pub fn iter(&self) -> Iter<'_> {

View file

@ -119,7 +119,7 @@ impl Command {
for k in &self.env_remove { for k in &self.env_remove {
ret.env_remove(k); ret.env_remove(k);
} }
return ret; ret
} }
// extensions // extensions

View file

@ -852,7 +852,7 @@ impl CrateInfo {
info.missing_lang_items.insert(cnum, missing); info.missing_lang_items.insert(cnum, missing);
} }
return info; info
} }
} }
@ -887,7 +887,7 @@ pub fn provide_both(providers: &mut Providers<'_>) {
} }
} }
} }
return tcx.sess.opts.optimize; tcx.sess.opts.optimize
}; };
providers.dllimport_foreign_items = |tcx, krate| { providers.dllimport_foreign_items = |tcx, krate| {

View file

@ -125,9 +125,9 @@ impl<'dom, Node: Idx> Iterator for Iter<'dom, Node> {
} else { } else {
self.node = Some(dom); self.node = Some(dom);
} }
return Some(node); Some(node)
} else { } else {
return None; None
} }
} }
} }

View file

@ -752,7 +752,7 @@ impl RustcDefaultCalls {
PrintRequest::NativeStaticLibs => {} PrintRequest::NativeStaticLibs => {}
} }
} }
return Compilation::Stop; Compilation::Stop
} }
} }

View file

@ -175,6 +175,6 @@ impl AssertModuleSource<'tcx> {
return true; return true;
} }
debug!("check_config: no match found"); debug!("check_config: no match found");
return false; false
} }
} }

View file

@ -132,7 +132,6 @@ where
} }
Err(err) => { Err(err) => {
sess.err(&format!("failed to write dep-graph to `{}`: {}", path_buf.display(), err)); sess.err(&format!("failed to write dep-graph to `{}`: {}", path_buf.display(), err));
return;
} }
} }
} }

View file

@ -136,7 +136,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
} else { } else {
// Fast path for the common case. // Fast path for the common case.
self.relate(a.skip_binder(), b.skip_binder())?; self.relate(a.skip_binder(), b.skip_binder())?;
return Ok(a.clone()); Ok(a.clone())
} }
} }
} }

View file

@ -142,6 +142,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
.span_label(span_2, String::new()) .span_label(span_2, String::new())
.span_label(span, span_label) .span_label(span, span_label)
.emit(); .emit();
return Some(ErrorReported); Some(ErrorReported)
} }
} }

View file

@ -30,7 +30,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
let span = self.trace.cause.span; let span = self.trace.cause.span;
return self.infcx.commit_if_ok(|snapshot| { self.infcx.commit_if_ok(|snapshot| {
// First, we instantiate each bound region in the supertype with a // First, we instantiate each bound region in the supertype with a
// fresh placeholder region. // fresh placeholder region.
let (b_prime, placeholder_map) = self.infcx.replace_bound_vars_with_placeholders(b); let (b_prime, placeholder_map) = self.infcx.replace_bound_vars_with_placeholders(b);
@ -53,7 +53,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
debug!("higher_ranked_sub: OK result={:?}", result); debug!("higher_ranked_sub: OK result={:?}", result);
Ok(ty::Binder::bind(result)) Ok(ty::Binder::bind(result))
}); })
} }
} }

View file

@ -452,12 +452,10 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
debug!("Expanding value of {:?} from {:?} to {:?}", b_vid, cur_region, lub); debug!("Expanding value of {:?} from {:?} to {:?}", b_vid, cur_region, lub);
*b_data = VarValue::Value(lub); *b_data = VarValue::Value(lub);
return true; true
} }
VarValue::ErrorValue => { VarValue::ErrorValue => false,
return false;
}
} }
} }
@ -804,7 +802,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
} }
} }
return graph; graph
} }
fn collect_error_for_expanding_node( fn collect_error_for_expanding_node(

View file

@ -877,7 +877,7 @@ where
// If sub-roots are equal, then `for_vid` and // If sub-roots are equal, then `for_vid` and
// `vid` are related via subtyping. // `vid` are related via subtyping.
debug!("TypeGeneralizer::tys: occurs check failed"); debug!("TypeGeneralizer::tys: occurs check failed");
return Err(TypeError::Mismatch); Err(TypeError::Mismatch)
} else { } else {
match variables.probe(vid) { match variables.probe(vid) {
TypeVariableValue::Known { value: u } => { TypeVariableValue::Known { value: u } => {
@ -898,7 +898,7 @@ where
let u = self.tcx().mk_ty_var(new_var_id); let u = self.tcx().mk_ty_var(new_var_id);
debug!("generalize: replacing original vid={:?} with new={:?}", vid, u); debug!("generalize: replacing original vid={:?} with new={:?}", vid, u);
return Ok(u); Ok(u)
} }
} }
} }

View file

@ -505,7 +505,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
self.undo_log.push(AddVar(vid)); self.undo_log.push(AddVar(vid));
} }
debug!("created new region variable {:?} in {:?} with origin {:?}", vid, universe, origin); debug!("created new region variable {:?} in {:?} with origin {:?}", vid, universe, origin);
return vid; vid
} }
/// Returns the universe for the given variable. /// Returns the universe for the given variable.

View file

@ -527,10 +527,10 @@ impl Cursor<'_> {
if self.first() == '\'' { if self.first() == '\'' {
self.bump(); self.bump();
let kind = Char { terminated: true }; let kind = Char { terminated: true };
return Literal { kind, suffix_start: self.len_consumed() }; Literal { kind, suffix_start: self.len_consumed() }
} else {
Lifetime { starts_with_number }
} }
return Lifetime { starts_with_number };
} }
fn single_quoted_string(&mut self) -> bool { fn single_quoted_string(&mut self) -> bool {

View file

@ -269,7 +269,7 @@ impl EarlyLintPass for UnsafeCode {
}) })
} }
_ => return, _ => {}
} }
} }

View file

@ -543,7 +543,7 @@ impl EarlyLintPass for UnusedParens {
// Do not lint on `(..)` as that will result in the other arms being useless. // Do not lint on `(..)` as that will result in the other arms being useless.
Paren(_) Paren(_)
// The other cases do not contain sub-patterns. // The other cases do not contain sub-patterns.
| Wild | Rest | Lit(..) | MacCall(..) | Range(..) | Ident(.., None) | Path(..) => return, | Wild | Rest | Lit(..) | MacCall(..) | Range(..) | Ident(.., None) | Path(..) => {},
// These are list-like patterns; parens can always be removed. // These are list-like patterns; parens can always be removed.
TupleStruct(_, ps) | Tuple(ps) | Slice(ps) | Or(ps) => for p in ps { TupleStruct(_, ps) | Tuple(ps) | Slice(ps) | Or(ps) => for p in ps {
self.check_unused_parens_pat(cx, p, false, false); self.check_unused_parens_pat(cx, p, false, false);

View file

@ -264,7 +264,7 @@ impl<'a> CrateLoader<'a> {
ret = Some(cnum); ret = Some(cnum);
} }
}); });
return ret; ret
} }
fn verify_no_symbol_conflicts(&self, span: Span, root: &CrateRoot<'_>) { fn verify_no_symbol_conflicts(&self, span: Span, root: &CrateRoot<'_>) {

View file

@ -6,7 +6,7 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor;
crate fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> { crate fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> {
let mut collector = Collector { tcx, modules: Vec::new() }; let mut collector = Collector { tcx, modules: Vec::new() };
tcx.hir().krate().visit_all_item_likes(&mut collector); tcx.hir().krate().visit_all_item_likes(&mut collector);
return collector.modules; collector.modules
} }
struct Collector<'tcx> { struct Collector<'tcx> {

View file

@ -16,7 +16,7 @@ crate fn collect(tcx: TyCtxt<'_>) -> Vec<String> {
} }
} }
return collector.args; collector.args
} }
struct Collector { struct Collector {

View file

@ -949,7 +949,7 @@ fn get_metadata_section(
let start = Instant::now(); let start = Instant::now();
let ret = get_metadata_section_imp(target, flavor, filename, loader); let ret = get_metadata_section_imp(target, flavor, filename, loader);
info!("reading {:?} => {:?}", filename.file_name().unwrap(), start.elapsed()); info!("reading {:?} => {:?}", filename.file_name().unwrap(), start.elapsed());
return ret; ret
} }
/// A trivial wrapper for `Mmap` that implements `StableDeref`. /// A trivial wrapper for `Mmap` that implements `StableDeref`.

View file

@ -15,7 +15,7 @@ crate fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
let mut collector = Collector { tcx, libs: Vec::new() }; let mut collector = Collector { tcx, libs: Vec::new() };
tcx.hir().krate().visit_all_item_likes(&mut collector); tcx.hir().krate().visit_all_item_likes(&mut collector);
collector.process_command_line(); collector.process_command_line();
return collector.libs; collector.libs
} }
crate fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { crate fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {

View file

@ -170,7 +170,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
.iter() .iter()
.filter_map(|&(exported_symbol, export_level)| { .filter_map(|&(exported_symbol, export_level)| {
if let ExportedSymbol::NonGeneric(def_id) = exported_symbol { if let ExportedSymbol::NonGeneric(def_id) = exported_symbol {
return Some((def_id, export_level)) Some((def_id, export_level))
} else { } else {
None None
} }

View file

@ -273,7 +273,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
assert_eq!(borrow_data.borrowed_place, *place); assert_eq!(borrow_data.borrowed_place, *place);
} }
return self.super_rvalue(rvalue, location); self.super_rvalue(rvalue, location)
} }
} }

View file

@ -500,7 +500,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
} }
} }
return None; None
} }
/// We've found an enum/struct/union type with the substitutions /// We've found an enum/struct/union type with the substitutions

View file

@ -56,7 +56,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
self.return_to_block(ret.map(|r| r.1))?; self.return_to_block(ret.map(|r| r.1))?;
self.dump_place(*dest); self.dump_place(*dest);
return Ok(true); Ok(true)
} }
/// "Intercept" a function call to a panic-related function /// "Intercept" a function call to a panic-related function

View file

@ -122,7 +122,7 @@ pub(crate) fn has_rustc_mir_with(attrs: &[ast::Attribute], name: Symbol) -> Opti
} }
} }
} }
return None; None
} }
pub struct MoveDataParamEnv<'tcx> { pub struct MoveDataParamEnv<'tcx> {
@ -171,7 +171,7 @@ where
return None; return None;
} }
} }
return None; None
}; };
let print_preflow_to = name_found(tcx.sess, attributes, sym::borrowck_graphviz_preflow); let print_preflow_to = name_found(tcx.sess, attributes, sym::borrowck_graphviz_preflow);

View file

@ -64,7 +64,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Ge => l >= r, Ge => l >= r,
_ => bug!("Invalid operation on char: {:?}", bin_op), _ => bug!("Invalid operation on char: {:?}", bin_op),
}; };
return (Scalar::from_bool(res), false, self.tcx.types.bool); (Scalar::from_bool(res), false, self.tcx.types.bool)
} }
fn binary_bool_op( fn binary_bool_op(
@ -87,7 +87,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
BitXor => l ^ r, BitXor => l ^ r,
_ => bug!("Invalid operation on bool: {:?}", bin_op), _ => bug!("Invalid operation on bool: {:?}", bin_op),
}; };
return (Scalar::from_bool(res), false, self.tcx.types.bool); (Scalar::from_bool(res), false, self.tcx.types.bool)
} }
fn binary_float_op<F: Float + Into<Scalar<M::PointerTag>>>( fn binary_float_op<F: Float + Into<Scalar<M::PointerTag>>>(
@ -113,7 +113,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Rem => ((l % r).value.into(), ty), Rem => ((l % r).value.into(), ty),
_ => bug!("invalid float op: `{:?}`", bin_op), _ => bug!("invalid float op: `{:?}`", bin_op),
}; };
return (val, false, ty); (val, false, ty)
} }
fn binary_int_op( fn binary_int_op(

View file

@ -212,9 +212,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
if self.layout.is_unsized() { if self.layout.is_unsized() {
// We need to consult `meta` metadata // We need to consult `meta` metadata
match self.layout.ty.kind { match self.layout.ty.kind {
ty::Slice(..) | ty::Str => { ty::Slice(..) | ty::Str => self.mplace.meta.unwrap_meta().to_machine_usize(cx),
return self.mplace.meta.unwrap_meta().to_machine_usize(cx);
}
_ => bug!("len not supported on unsized type {:?}", self.layout.ty), _ => bug!("len not supported on unsized type {:?}", self.layout.ty),
} }
} else { } else {

View file

@ -240,7 +240,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
match instance.def { match instance.def {
ty::InstanceDef::Intrinsic(..) => { ty::InstanceDef::Intrinsic(..) => {
assert!(caller_abi == Abi::RustIntrinsic || caller_abi == Abi::PlatformIntrinsic); assert!(caller_abi == Abi::RustIntrinsic || caller_abi == Abi::PlatformIntrinsic);
return M::call_intrinsic(self, span, instance, args, ret, unwind); M::call_intrinsic(self, span, instance, args, ret, unwind)
} }
ty::InstanceDef::VtableShim(..) ty::InstanceDef::VtableShim(..)
| ty::InstanceDef::ReifyShim(..) | ty::InstanceDef::ReifyShim(..)

View file

@ -751,7 +751,7 @@ fn should_monomorphize_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx
bug!("cannot create local mono-item for {:?}", def_id) bug!("cannot create local mono-item for {:?}", def_id)
} }
return true; true
} }
/// For a given pair of source and target type that occur in an unsizing coercion, /// For a given pair of source and target type that occur in an unsizing coercion,

View file

@ -483,7 +483,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
err.span_label(source_info.span, format!("{:?}", panic)); err.span_label(source_info.span, format!("{:?}", panic));
err.emit() err.emit()
}); });
return None; None
} }
fn check_unary_op( fn check_unary_op(

View file

@ -43,8 +43,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
.. ..
}) })
| Node::TraitItem(hir::TraitItem { | Node::TraitItem(hir::TraitItem {
kind: kind: hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitFn::Provided(body_id)),
hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitFn::Provided(body_id)),
.. ..
}) => (*body_id, decl.output.span()), }) => (*body_id, decl.output.span()),
Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. }) Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. })
@ -368,7 +367,7 @@ impl BlockContext {
} }
} }
return None; None
} }
/// Looks at the topmost frame on the BlockContext and reports /// Looks at the topmost frame on the BlockContext and reports

View file

@ -98,7 +98,7 @@ fn mirror_stmts<'a, 'tcx>(
} }
} }
} }
return result; result
} }
crate fn to_expr_ref<'a, 'tcx>( crate fn to_expr_ref<'a, 'tcx>(

View file

@ -320,7 +320,7 @@ pub fn nt_to_tokenstream(nt: &Nonterminal, sess: &ParseSess, span: Span) -> Toke
going with stringified version" going with stringified version"
); );
} }
return tokens_for_real; tokens_for_real
} }
fn prepend_attrs( fn prepend_attrs(

View file

@ -996,7 +996,7 @@ impl<'a> Parser<'a> {
let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(literal), attrs); let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(literal), attrs);
self.maybe_recover_from_bad_qpath(expr, true) self.maybe_recover_from_bad_qpath(expr, true)
} }
None => return Err(self.expected_expression_found()), None => Err(self.expected_expression_found()),
} }
} }
@ -1713,7 +1713,7 @@ impl<'a> Parser<'a> {
} }
let hi = self.token.span; let hi = self.token.span;
self.bump(); self.bump();
return Ok(self.mk_expr(lo.to(hi), ExprKind::Match(scrutinee, arms), attrs)); Ok(self.mk_expr(lo.to(hi), ExprKind::Match(scrutinee, arms), attrs))
} }
pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> { pub(super) fn parse_arm(&mut self) -> PResult<'a, Arm> {

View file

@ -314,7 +314,7 @@ impl<'a> Parser<'a> {
" struct ".into(), " struct ".into(),
Applicability::MaybeIncorrect, // speculative Applicability::MaybeIncorrect, // speculative
); );
return Err(err); Err(err)
} else if self.look_ahead(1, |t| *t == token::OpenDelim(token::Paren)) { } else if self.look_ahead(1, |t| *t == token::OpenDelim(token::Paren)) {
let ident = self.parse_ident().unwrap(); let ident = self.parse_ident().unwrap();
self.bump(); // `(` self.bump(); // `(`
@ -362,7 +362,7 @@ impl<'a> Parser<'a> {
); );
} }
} }
return Err(err); Err(err)
} else if self.look_ahead(1, |t| *t == token::Lt) { } else if self.look_ahead(1, |t| *t == token::Lt) {
let ident = self.parse_ident().unwrap(); let ident = self.parse_ident().unwrap();
self.eat_to_tokens(&[&token::Gt]); self.eat_to_tokens(&[&token::Gt]);
@ -384,7 +384,7 @@ impl<'a> Parser<'a> {
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }
return Err(err); Err(err)
} else { } else {
Ok(()) Ok(())
} }
@ -910,7 +910,7 @@ impl<'a> Parser<'a> {
let span = self.sess.source_map().def_span(span); let span = self.sess.source_map().def_span(span);
let msg = format!("{} is not supported in {}", kind.descr(), ctx); let msg = format!("{} is not supported in {}", kind.descr(), ctx);
self.struct_span_err(span, &msg).emit(); self.struct_span_err(span, &msg).emit();
return None; None
} }
fn error_on_foreign_const(&self, span: Span, ident: Ident) { fn error_on_foreign_const(&self, span: Span, ident: Ident) {

View file

@ -918,7 +918,7 @@ impl<'a> Parser<'a> {
} }
err.emit(); err.emit();
} }
return Ok((fields, etc)); Ok((fields, etc))
} }
/// Recover on `...` as if it were `..` to avoid further errors. /// Recover on `...` as if it were `..` to avoid further errors.

View file

@ -278,7 +278,7 @@ impl<'a> Parser<'a> {
_ => {} _ => {}
} }
e.span_label(sp, "expected `{`"); e.span_label(sp, "expected `{`");
return Err(e); Err(e)
} }
/// Parses a block. Inner attributes are allowed. /// Parses a block. Inner attributes are allowed.

View file

@ -864,7 +864,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
first_merge, first_merge,
any_changed any_changed
); );
return any_changed; any_changed
} }
// Indicates that a local variable was *defined*; we know that no // Indicates that a local variable was *defined*; we know that no

View file

@ -222,7 +222,7 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> {
return true; return true;
} }
} }
return false; false
} }
fn emit_unlabled_cf_in_while_condition(&mut self, span: Span, cf_type: &str) { fn emit_unlabled_cf_in_while_condition(&mut self, span: Span, cf_type: &str) {
struct_span_err!( struct_span_err!(

View file

@ -30,9 +30,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item<'_>, attrs: Codegen
} }
match item.kind { match item.kind {
hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => { hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => true,
return true;
}
hir::ItemKind::Impl { .. } | hir::ItemKind::Fn(..) => { hir::ItemKind::Impl { .. } | hir::ItemKind::Fn(..) => {
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id)); let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
generics.requires_monomorphization(tcx) generics.requires_monomorphization(tcx)

View file

@ -465,7 +465,7 @@ fn new_index(tcx: TyCtxt<'tcx>) -> Index<'tcx> {
|v| intravisit::walk_crate(v, krate), |v| intravisit::walk_crate(v, krate),
); );
} }
return index; index
} }
/// Cross-references the feature names of unstable APIs with enabled /// Cross-references the feature names of unstable APIs with enabled

View file

@ -1423,7 +1423,7 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
Some(_) | None => false, Some(_) | None => false,
} }
} else { } else {
return false; false
} }
} }
@ -1837,7 +1837,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'tcx> {
&& self.tcx.is_private_dep(item_id.krate); && self.tcx.is_private_dep(item_id.krate);
log::debug!("leaks_private_dep(item_id={:?})={}", item_id, ret); log::debug!("leaks_private_dep(item_id={:?})={}", item_id, ret);
return ret; ret
} }
} }

View file

@ -200,7 +200,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
fn visit_pat(&mut self, pat: &'a Pat) { fn visit_pat(&mut self, pat: &'a Pat) {
match pat.kind { match pat.kind {
PatKind::MacCall(..) => return self.visit_macro_invoc(pat.id), PatKind::MacCall(..) => self.visit_macro_invoc(pat.id),
_ => visit::walk_pat(self, pat), _ => visit::walk_pat(self, pat),
} }
} }

View file

@ -1108,7 +1108,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
match binding.kind { match binding.kind {
// Never suggest the name that has binding error // Never suggest the name that has binding error
// i.e., the name that cannot be previously resolved // i.e., the name that cannot be previously resolved
NameBindingKind::Res(Res::Err, _) => return None, NameBindingKind::Res(Res::Err, _) => None,
_ => Some(&i.name), _ => Some(&i.name),
} }
} }

View file

@ -380,7 +380,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
_ => (), _ => (),
} }
}; };
return has_self_arg; has_self_arg
} }
fn followed_by_brace(&self, span: Span) -> (bool, Option<(Span, String)>) { fn followed_by_brace(&self, span: Span) -> (bool, Option<(Span, String)>) {
@ -430,7 +430,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
break; break;
} }
} }
return (followed_by_brace, closing_brace); (followed_by_brace, closing_brace)
} }
/// Provides context-dependent help for errors reported by the `smart_resolve_path_fragment` /// Provides context-dependent help for errors reported by the `smart_resolve_path_fragment`

View file

@ -83,7 +83,7 @@ fn sub_namespace_match(candidate: Option<MacroKind>, requirement: Option<MacroKi
// line-breaks and is slow. // line-breaks and is slow.
fn fast_print_path(path: &ast::Path) -> Symbol { fn fast_print_path(path: &ast::Path) -> Symbol {
if path.segments.len() == 1 { if path.segments.len() == 1 {
return path.segments[0].ident.name; path.segments[0].ident.name
} else { } else {
let mut path_str = String::with_capacity(64); let mut path_str = String::with_capacity(64);
for (i, segment) in path.segments.iter().enumerate() { for (i, segment) in path.segments.iter().enumerate() {

View file

@ -534,7 +534,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
let variant = &def.non_enum_variant(); let variant = &def.non_enum_variant();
filter!(self.span_utils, ident.span); filter!(self.span_utils, ident.span);
let span = self.span_from_span(ident.span); let span = self.span_from_span(ident.span);
return Some(Data::RefData(Ref { Some(Data::RefData(Ref {
kind: RefKind::Variable, kind: RefKind::Variable,
span, span,
ref_id: self ref_id: self
@ -542,7 +542,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
.find_field_index(ident, variant) .find_field_index(ident, variant)
.map(|index| id_from_def_id(variant.fields[index].did)) .map(|index| id_from_def_id(variant.fields[index].did))
.unwrap_or_else(|| null_id()), .unwrap_or_else(|| null_id()),
})); }))
} }
ty::Tuple(..) => None, ty::Tuple(..) => None,
_ => { _ => {

View file

@ -1140,7 +1140,7 @@ pub fn parse_error_format(
_ => {} _ => {}
} }
return error_format; error_format
} }
fn parse_crate_edition(matches: &getopts::Matches) -> Edition { fn parse_crate_edition(matches: &getopts::Matches) -> Edition {

View file

@ -99,10 +99,6 @@ impl<'sm> CachingSourceMapView<'sm> {
cache_entry.line_end = line_bounds.1; cache_entry.line_end = line_bounds.1;
cache_entry.time_stamp = self.time_stamp; cache_entry.time_stamp = self.time_stamp;
return Some(( Some((cache_entry.file.clone(), cache_entry.line_number, pos - cache_entry.line_start))
cache_entry.file.clone(),
cache_entry.line_number,
pos - cache_entry.line_start,
));
} }
} }

View file

@ -368,7 +368,7 @@ impl SourceMap {
// If there is a doctest offset, applies it to the line. // If there is a doctest offset, applies it to the line.
pub fn doctest_offset_line(&self, file: &FileName, orig: usize) -> usize { pub fn doctest_offset_line(&self, file: &FileName, orig: usize) -> usize {
return match file { match file {
FileName::DocTest(_, offset) => { FileName::DocTest(_, offset) => {
return if *offset >= 0 { return if *offset >= 0 {
orig + *offset as usize orig + *offset as usize
@ -377,7 +377,7 @@ impl SourceMap {
}; };
} }
_ => orig, _ => orig,
}; }
} }
/// Looks up source information about a `BytePos`. /// Looks up source information about a `BytePos`.
@ -569,10 +569,10 @@ impl SourceMap {
let local_end = self.lookup_byte_offset(sp.hi()); let local_end = self.lookup_byte_offset(sp.hi());
if local_begin.sf.start_pos != local_end.sf.start_pos { if local_begin.sf.start_pos != local_end.sf.start_pos {
return Err(SpanSnippetError::DistinctSources(DistinctSources { Err(SpanSnippetError::DistinctSources(DistinctSources {
begin: (local_begin.sf.name.clone(), local_begin.sf.start_pos), begin: (local_begin.sf.name.clone(), local_begin.sf.start_pos),
end: (local_end.sf.name.clone(), local_end.sf.start_pos), end: (local_end.sf.name.clone(), local_end.sf.start_pos),
})); }))
} else { } else {
self.ensure_source_file_source_present(local_begin.sf.clone()); self.ensure_source_file_source_present(local_begin.sf.clone());
@ -590,13 +590,11 @@ impl SourceMap {
} }
if let Some(ref src) = local_begin.sf.src { if let Some(ref src) = local_begin.sf.src {
return extract_source(src, start_index, end_index); extract_source(src, start_index, end_index)
} else if let Some(src) = local_begin.sf.external_src.borrow().get_source() { } else if let Some(src) = local_begin.sf.external_src.borrow().get_source() {
return extract_source(src, start_index, end_index); extract_source(src, start_index, end_index)
} else { } else {
return Err(SpanSnippetError::SourceNotAvailable { Err(SpanSnippetError::SourceNotAvailable { filename: local_begin.sf.name.clone() })
filename: local_begin.sf.name.clone(),
});
} }
} }
} }

View file

@ -113,7 +113,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
return AutoTraitResult::ExplicitImpl; return AutoTraitResult::ExplicitImpl;
} }
return tcx.infer_ctxt().enter(|infcx| { tcx.infer_ctxt().enter(|infcx| {
let mut fresh_preds = FxHashSet::default(); let mut fresh_preds = FxHashSet::default();
// Due to the way projections are handled by SelectionContext, we need to run // Due to the way projections are handled by SelectionContext, we need to run
@ -219,8 +219,8 @@ impl<'tcx> AutoTraitFinder<'tcx> {
let info = AutoTraitInfo { full_user_env, region_data, vid_to_region }; let info = AutoTraitInfo { full_user_env, region_data, vid_to_region };
return AutoTraitResult::PositiveImpl(auto_trait_callback(&infcx, info)); AutoTraitResult::PositiveImpl(auto_trait_callback(&infcx, info))
}); })
} }
} }
@ -384,7 +384,7 @@ impl AutoTraitFinder<'tcx> {
ty, trait_did, new_env, final_user_env ty, trait_did, new_env, final_user_env
); );
return Some((new_env, final_user_env)); Some((new_env, final_user_env))
} }
/// This method is designed to work around the following issue: /// This method is designed to work around the following issue:
@ -492,7 +492,7 @@ impl AutoTraitFinder<'tcx> {
} }
_ => {} _ => {}
} }
return true; true
}); });
if should_add_new { if should_add_new {
@ -591,15 +591,15 @@ impl AutoTraitFinder<'tcx> {
} }
fn is_param_no_infer(&self, substs: SubstsRef<'_>) -> bool { fn is_param_no_infer(&self, substs: SubstsRef<'_>) -> bool {
return self.is_of_param(substs.type_at(0)) && !substs.types().any(|t| t.has_infer_types()); self.is_of_param(substs.type_at(0)) && !substs.types().any(|t| t.has_infer_types())
} }
pub fn is_of_param(&self, ty: Ty<'_>) -> bool { pub fn is_of_param(&self, ty: Ty<'_>) -> bool {
return match ty.kind { match ty.kind {
ty::Param(_) => true, ty::Param(_) => true,
ty::Projection(p) => self.is_of_param(p.self_ty()), ty::Projection(p) => self.is_of_param(p.self_ty()),
_ => false, _ => false,
}; }
} }
fn is_self_referential_projection(&self, p: ty::PolyProjectionPredicate<'_>) -> bool { fn is_self_referential_projection(&self, p: ty::PolyProjectionPredicate<'_>) -> bool {
@ -804,7 +804,7 @@ impl AutoTraitFinder<'tcx> {
_ => panic!("Unexpected predicate {:?} {:?}", ty, predicate), _ => panic!("Unexpected predicate {:?} {:?}", ty, predicate),
}; };
} }
return true; true
} }
pub fn clean_pred( pub fn clean_pred(

View file

@ -221,10 +221,10 @@ pub fn trait_ref_is_knowable<'tcx>(
// we are an owner. // we are an owner.
if orphan_check_trait_ref(tcx, trait_ref, InCrate::Local).is_ok() { if orphan_check_trait_ref(tcx, trait_ref, InCrate::Local).is_ok() {
debug!("trait_ref_is_knowable: orphan check passed"); debug!("trait_ref_is_knowable: orphan check passed");
return None; None
} else { } else {
debug!("trait_ref_is_knowable: nonlocal, nonfundamental, unowned"); debug!("trait_ref_is_knowable: nonlocal, nonfundamental, unowned");
return Some(Conflict::Upstream); Some(Conflict::Upstream)
} }
} }

View file

@ -111,11 +111,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
}), }),
hir::Node::Expr(hir::Expr { .. }) => { hir::Node::Expr(hir::Expr { .. }) => {
let parent_hid = hir.get_parent_node(hir_id); let parent_hid = hir.get_parent_node(hir_id);
if parent_hid != hir_id { if parent_hid != hir_id { self.describe_enclosure(parent_hid) } else { None }
return self.describe_enclosure(parent_hid);
} else {
None
}
} }
_ => None, _ => None,
} }

View file

@ -351,7 +351,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
// Different to previous arm because one is `&hir::Local` and the other // Different to previous arm because one is `&hir::Local` and the other
// is `P<hir::Local>`. // is `P<hir::Local>`.
Some(hir::Node::Local(local)) => get_name(err, &local.pat.kind), Some(hir::Node::Local(local)) => get_name(err, &local.pat.kind),
_ => return None, _ => None,
} }
} }

View file

@ -169,12 +169,12 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
debug!("QueryNormalizer: result = {:#?}", result); debug!("QueryNormalizer: result = {:#?}", result);
debug!("QueryNormalizer: obligations = {:#?}", obligations); debug!("QueryNormalizer: obligations = {:#?}", obligations);
self.obligations.extend(obligations); self.obligations.extend(obligations);
return result.normalized_ty; result.normalized_ty
} }
Err(_) => { Err(_) => {
self.error = true; self.error = true;
return ty; ty
} }
} }
} }

View file

@ -595,7 +595,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
} }
// if we made it through that loop above, we made progress! // if we made it through that loop above, we made progress!
return true; true
} }
fn nominal_obligations( fn nominal_obligations(

View file

@ -146,7 +146,7 @@ crate fn program_clauses_for_env<'tcx>(
debug!("program_clauses_for_env: closure = {:#?}", closure); debug!("program_clauses_for_env: closure = {:#?}", closure);
return tcx.mk_clauses(closure.into_iter()); tcx.mk_clauses(closure.into_iter())
} }
crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> { crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> {

View file

@ -132,7 +132,7 @@ where
} }
} }
return None; None
} }
} }

View file

@ -2128,7 +2128,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
return Err(ErrorReported); return Err(ErrorReported);
} }
} }
return Ok(bound); Ok(bound)
} }
fn complain_about_assoc_type_not_found<I>( fn complain_about_assoc_type_not_found<I>(
@ -2709,7 +2709,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
} }
Res::Err => { Res::Err => {
self.set_tainted_by_errors(); self.set_tainted_by_errors();
return self.tcx().types.err; self.tcx().types.err
} }
_ => span_bug!(span, "unexpected resolution: {:?}", path.res), _ => span_bug!(span, "unexpected resolution: {:?}", path.res),
} }
@ -3047,7 +3047,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
) )
.emit(); .emit();
} }
return Some(r); Some(r)
} }
} }

View file

@ -1580,7 +1580,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: DefId) -> bool {
} else { } else {
span_bug!(span, "unions must be ty::Adt, but got {:?}", item_type.kind); span_bug!(span, "unions must be ty::Adt, but got {:?}", item_type.kind);
} }
return true; true
} }
/// Checks that an opaque type does not contain cycles and does not use `Self` or `T::Foo` /// Checks that an opaque type does not contain cycles and does not use `Self` or `T::Foo`
@ -2313,7 +2313,7 @@ fn check_representable(tcx: TyCtxt<'_>, sp: Span, item_def_id: DefId) -> bool {
} }
Representability::Representable | Representability::ContainsRecursive => (), Representability::Representable | Representability::ContainsRecursive => (),
} }
return true; true
} }
pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: DefId) { pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: DefId) {

View file

@ -272,9 +272,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
item.span, item.span,
); );
} }
ty::Error => { ty::Error => {}
return;
}
_ => { _ => {
struct_span_err!( struct_span_err!(
self.tcx.sess, self.tcx.sess,
@ -288,7 +286,6 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
to wrap it instead", to wrap it instead",
) )
.emit(); .emit();
return;
} }
} }
} }

View file

@ -290,7 +290,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
DUMMY_SP, DUMMY_SP,
&format!("unexpected const parent path {:?}", parent_node,), &format!("unexpected const parent path {:?}", parent_node,),
); );
return tcx.types.err; tcx.types.err
} }
} }

View file

@ -250,7 +250,7 @@ impl Backtrace {
}, },
}; };
ENABLED.store(enabled as usize + 1, SeqCst); ENABLED.store(enabled as usize + 1, SeqCst);
return enabled; enabled
} }
/// Capture a stack backtrace of the current thread. /// Capture a stack backtrace of the current thread.

View file

@ -28,7 +28,7 @@ pub fn lock() -> impl Drop {
unsafe { unsafe {
LOCK.lock(); LOCK.lock();
return Guard; Guard
} }
} }