]> git.lizzy.rs Git - rust.git/commitdiff
remove redundant returns (clippy::needless_return)
authorMatthias Krüger <matthias.krueger@famsik.de>
Fri, 20 Mar 2020 14:03:11 +0000 (15:03 +0100)
committerMatthias Krüger <matthias.krueger@famsik.de>
Fri, 20 Mar 2020 19:23:03 +0000 (20:23 +0100)
84 files changed:
src/libcore/hint.rs
src/librustc/lint.rs
src/librustc/middle/region.rs
src/librustc/ty/context.rs
src/librustc/ty/relate.rs
src/librustc/ty/sty.rs
src/librustc/ty/subst.rs
src/librustc_builtin_macros/deriving/decodable.rs
src/librustc_builtin_macros/deriving/default.rs
src/librustc_builtin_macros/deriving/encodable.rs
src/librustc_builtin_macros/deriving/generic/mod.rs
src/librustc_builtin_macros/format_foreign.rs
src/librustc_codegen_llvm/back/archive.rs
src/librustc_codegen_llvm/back/bytecode.rs
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/context.rs
src/librustc_codegen_llvm/debuginfo/metadata.rs
src/librustc_codegen_llvm/debuginfo/mod.rs
src/librustc_codegen_llvm/debuginfo/utils.rs
src/librustc_codegen_llvm/llvm/archive_ro.rs
src/librustc_codegen_ssa/back/command.rs
src/librustc_codegen_ssa/base.rs
src/librustc_data_structures/graph/dominators/mod.rs
src/librustc_driver/lib.rs
src/librustc_incremental/assert_module_sources.rs
src/librustc_incremental/persist/save.rs
src/librustc_infer/infer/equate.rs
src/librustc_infer/infer/error_reporting/nice_region_error/different_lifetimes.rs
src/librustc_infer/infer/higher_ranked/mod.rs
src/librustc_infer/infer/lexical_region_resolve/mod.rs
src/librustc_infer/infer/nll_relate/mod.rs
src/librustc_infer/infer/region_constraints/mod.rs
src/librustc_lexer/src/lib.rs
src/librustc_lint/builtin.rs
src/librustc_lint/unused.rs
src/librustc_metadata/creader.rs
src/librustc_metadata/foreign_modules.rs
src/librustc_metadata/link_args.rs
src/librustc_metadata/locator.rs
src/librustc_metadata/native_libs.rs
src/librustc_metadata/rmeta/decoder/cstore_impl.rs
src/librustc_mir/borrow_check/borrow_set.rs
src/librustc_mir/borrow_check/diagnostics/region_name.rs
src/librustc_mir/const_eval/machine.rs
src/librustc_mir/dataflow/mod.rs
src/librustc_mir/interpret/operator.rs
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/terminator.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/transform/const_prop.rs
src/librustc_mir_build/build/mod.rs
src/librustc_mir_build/hair/cx/block.rs
src/librustc_parse/lib.rs
src/librustc_parse/parser/expr.rs
src/librustc_parse/parser/item.rs
src/librustc_parse/parser/pat.rs
src/librustc_parse/parser/stmt.rs
src/librustc_passes/liveness.rs
src/librustc_passes/loops.rs
src/librustc_passes/reachable.rs
src/librustc_passes/stability.rs
src/librustc_privacy/lib.rs
src/librustc_resolve/def_collector.rs
src/librustc_resolve/imports.rs
src/librustc_resolve/late/diagnostics.rs
src/librustc_resolve/macros.rs
src/librustc_save_analysis/lib.rs
src/librustc_session/config.rs
src/librustc_span/caching_source_map_view.rs
src/librustc_span/source_map.rs
src/librustc_trait_selection/traits/auto_trait.rs
src/librustc_trait_selection/traits/coherence.rs
src/librustc_trait_selection/traits/error_reporting/on_unimplemented.rs
src/librustc_trait_selection/traits/error_reporting/suggestions.rs
src/librustc_trait_selection/traits/query/normalize.rs
src/librustc_trait_selection/traits/wf.rs
src/librustc_traits/lowering/environment.rs
src/librustc_ty/needs_drop.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/coherence/inherent_impls.rs
src/librustc_typeck/collect/type_of.rs
src/libstd/backtrace.rs
src/libstd/sys_common/backtrace.rs

index f4fb9ab1757cd28bcf147bd5f281d94173e20473..6cbd26a78de726bed1d5ac403f56397f8f1ddd06 100644 (file)
@@ -114,6 +114,6 @@ pub fn black_box<T>(dummy: T) -> T {
     // more than we want, but it's so far good enough.
     unsafe {
         asm!("" : : "r"(&dummy));
-        return dummy;
+        dummy
     }
 }
index d4d01a716db97c32602f677796c4e47594b88f53..4dd276d2e032c9df90c1ad45864ee192349eb67b 100644 (file)
@@ -85,7 +85,7 @@ pub fn get_lint_level(
             level = cmp::min(*driver_level, level);
         }
 
-        return (level, src);
+        (level, src)
     }
 
     pub fn get_lint_id_level(
index 2735c4afca2c8ecd5f3dd46a86306950b11e14e0..1a63dc9dcf977f0b63efae6c968827e3de52574d 100644 (file)
@@ -467,7 +467,7 @@ pub fn temporary_scope(&self, expr_id: hir::ItemLocalId) -> Option<Scope> {
         }
 
         debug!("temporary_scope({:?}) = None", expr_id);
-        return None;
+        None
     }
 
     /// Returns the lifetime of the variable `id`.
@@ -498,7 +498,7 @@ pub fn is_subscope_of(&self, subscope: Scope, superscope: Scope) -> bool {
 
         debug!("is_subscope_of({:?}, {:?})=true", subscope, superscope);
 
-        return true;
+        true
     }
 
     /// Returns the ID of the innermost containing body.
index 742d57fb58a51bfb6d9170813f2b939117f5f1d7..0e3776f32e0e8b7a9071afc484a09adbc6f37bf8 100644 (file)
@@ -1447,11 +1447,11 @@ pub fn is_suitable_region(&self, region: Region<'tcx>) -> Option<FreeRegionInfo>
             _ => return None,
         };
 
-        return Some(FreeRegionInfo {
+        Some(FreeRegionInfo {
             def_id: suitable_region_binding_scope,
             boundregion: bound_region,
             is_impl_item,
-        });
+        })
     }
 
     pub fn return_type_impl_trait(&self, scope_def_id: DefId) -> Option<(Ty<'tcx>, Span)> {
index fb4184a9fb34762dcc658b28639ab21d7f542117..872e06e1176dc06ba88c81bded574e186c247273 100644 (file)
@@ -440,7 +440,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
                         (Some(sz_a_val), Some(sz_b_val)) => Err(TypeError::FixedArraySize(
                             expected_found(relation, &sz_a_val, &sz_b_val),
                         )),
-                        _ => return Err(err),
+                        _ => Err(err),
                     }
                 }
             }
index e265a2f8257fb77d50bb3ed29bac88ccad11bdf0..42cd2f52cb3ad1d1e52d1335b81338135446257f 100644 (file)
@@ -1612,7 +1612,7 @@ pub fn with_self_ty(
     }
 
     pub fn item_def_id(&self) -> DefId {
-        return self.skip_binder().item_def_id;
+        self.skip_binder().item_def_id
     }
 }
 
@@ -2000,8 +2000,8 @@ pub fn is_mutable_ptr(&self) -> bool {
     #[inline]
     pub fn is_unsafe_ptr(&self) -> bool {
         match self.kind {
-            RawPtr(_) => return true,
-            _ => return false,
+            RawPtr(_) => true,
+            _ => false,
         }
     }
 
index a0055812835507bac6aaf48b305e2501a174a3fc..a3acc14856e1febbb4b168dfe7e0877d9d4690dc 100644 (file)
@@ -524,7 +524,7 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
             self.root_ty = None;
         }
 
-        return t1;
+        t1
     }
 
     fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
index ac5d08ba62d0dc0bb74af42a148a0357b4351ee7..64a810bdcf687a1fe7caf09ebb6970f1c885ac01 100644 (file)
@@ -87,7 +87,7 @@ fn decodable_substructure(
     let blkarg = cx.ident_of("_d", trait_span);
     let blkdecoder = cx.expr_ident(trait_span, blkarg);
 
-    return match *substr.fields {
+    match *substr.fields {
         StaticStruct(_, ref summary) => {
             let nfields = match *summary {
                 Unnamed(ref fields, _) => fields.len(),
@@ -178,7 +178,7 @@ fn decodable_substructure(
             )
         }
         _ => cx.bug("expected StaticEnum or StaticStruct in derive(Decodable)"),
-    };
+    }
 }
 
 /// Creates a decoder for a single enum variant/struct:
index cb85a0b1a10cc7f94507d5e66fa892a83b6785dc..27d5263320041221b3ac3d18c340db64b0849eac 100644 (file)
@@ -53,7 +53,7 @@ fn default_substructure(
     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());
 
-    return match *substr.fields {
+    match *substr.fields {
         StaticStruct(_, ref summary) => match *summary {
             Unnamed(ref fields, is_tuple) => {
                 if !is_tuple {
@@ -83,5 +83,5 @@ fn default_substructure(
             DummyResult::raw_expr(trait_span, true)
         }
         _ => cx.span_bug(trait_span, "method in `derive(Default)`"),
-    };
+    }
 }
index 9073085381ac165d0d32d0485c982585f0113772..54926ec3fd502aeb44cf1ebbeb2c697e5073e4aa 100644 (file)
@@ -173,7 +173,7 @@ fn encodable_substructure(
         ],
     ));
 
-    return match *substr.fields {
+    match *substr.fields {
         Struct(_, ref fields) => {
             let emit_struct_field = cx.ident_of("emit_struct_field", trait_span);
             let mut stmts = Vec::new();
@@ -283,5 +283,5 @@ fn encodable_substructure(
         }
 
         _ => cx.bug("expected Struct or EnumMatching in derive(Encodable)"),
-    };
+    }
 }
index 84ed6e96aafc8352c5af419d525b4efa3b164b27..ee32e914acba4e3493579f08242d1d3e5e796752 100644 (file)
@@ -489,7 +489,6 @@ pub fn expand_ext(
                 // set earlier; see
                 // librustc_expand/expand.rs:MacroExpander::fully_expand_fragment()
                 // librustc_expand/base.rs:Annotatable::derive_allowed()
-                return;
             }
         }
     }
index cc3c403450e0478bf0801a6097369bfb18ea40b3..e6a87e4d82586771c2afa796e622bec3554636a9 100644 (file)
@@ -359,7 +359,7 @@ macro_rules! move_to {
         //
         // Note: `move` used to capture copies of the cursors as they are *now*.
         let fallback = move || {
-            return Some((
+            Some((
                 Substitution::Format(Format {
                     span: start.slice_between(next).unwrap(),
                     parameter: None,
@@ -371,7 +371,7 @@ macro_rules! move_to {
                     position: InnerSpan::new(start.at, next.at),
                 }),
                 next.slice_after(),
-            ));
+            ))
         };
 
         // Next parsing state.
index 239ca57ba41434d38b13858dc9157473d00c5bc6..f1fe40d919eebb36e3055657295b1512b11294f9 100644 (file)
@@ -146,7 +146,7 @@ fn add_rlib(
             }
 
             // ok, don't skip this
-            return false;
+            false
         })
     }
 
index db29556e70cccd47f5aae3b8d940f396f52fe6a8..0c8ce39132abb51283b205432a01ee711b7863e5 100644 (file)
@@ -83,7 +83,7 @@ pub fn encode(identifier: &str, bytecode: &[u8]) -> Vec<u8> {
         encoded.push(0);
     }
 
-    return encoded;
+    encoded
 }
 
 pub struct DecodedBytecode<'a> {
@@ -132,7 +132,7 @@ pub fn new(data: &'a [u8]) -> Result<DecodedBytecode<'a>, &'static str> {
     pub fn bytecode(&self) -> Vec<u8> {
         let mut data = Vec::new();
         DeflateDecoder::new(self.encoded_bytecode).read_to_end(&mut data).unwrap();
-        return data;
+        data
     }
 
     pub fn identifier(&self) -> &'a str {
index 609ddfc1d3a8075b7ef33456413cc4ba3de6187f..f72060868128c3624b4eb402162c110fbd1e1202 100644 (file)
@@ -96,15 +96,11 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
 
 impl CodegenCx<'ll, 'tcx> {
     pub fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
-        unsafe {
-            return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
-        }
+        unsafe { llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint) }
     }
 
     pub fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
-        unsafe {
-            return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
-        }
+        unsafe { llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint) }
     }
 
     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 {
     unsafe {
         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)
     }
 }
 
index 7b1526e9da154747ebf41057ca8282fb6bc67f7c..4427997c2732d4c77064d82a1f6460e9b954e7b0 100644 (file)
@@ -800,7 +800,7 @@ macro_rules! vector_types {
             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);
         }
-        return None;
+        None
     }
 }
 
index 6a7ed4e1dc384266eeefcecc13c58b047cf179dd..f35220cc6666ad059c4bb47d980f6918e5b6749f 100644 (file)
@@ -203,7 +203,7 @@ fn get_unique_type_id_of_type<'a>(
         let key = self.unique_id_interner.intern(&unique_type_id);
         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
@@ -314,7 +314,7 @@ fn finalize(&self, cx: &CodegenCx<'ll, 'tcx>) -> MetadataCreationResult<'ll> {
                     member_holding_stub,
                     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(
@@ -445,7 +445,7 @@ fn subroutine_type_metadata(
 
     return_if_metadata_created_in_meantime!(cx, unique_type_id);
 
-    return MetadataCreationResult::new(
+    MetadataCreationResult::new(
         unsafe {
             llvm::LLVMRustDIBuilderCreateSubroutineType(
                 DIB(cx),
@@ -454,7 +454,7 @@ fn subroutine_type_metadata(
             )
         },
         false,
-    );
+    )
 }
 
 // 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);
 
     match debug_context(cx).created_files.borrow_mut().entry(key) {
-        Entry::Occupied(o) => return o.get(),
+        Entry::Occupied(o) => o.get(),
         Entry::Vacant(v) => {
             let (file_name, directory) = v.key();
             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(
@@ -1273,11 +1273,11 @@ fn prepare_union_metadata(
 fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
     // On MSVC we have to use the fallback mode, because LLVM doesn't
     // 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;
         // but the required patch is in the LLVM 8.  Rust LLVM reports
         // 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
@@ -2075,7 +2075,7 @@ fn prepare_enum_metadata(
         }
     };
 
-    return create_and_register_recursive_type_forward_declaration(
+    create_and_register_recursive_type_forward_declaration(
         cx,
         enum_type,
         unique_type_id,
@@ -2088,7 +2088,7 @@ fn prepare_enum_metadata(
             containing_scope,
             span,
         }),
-    );
+    )
 }
 
 /// Creates debug information for a composite type, that is, anything that
index 85decff35b9e054267083b0f9f1629774541516e..41829d4ee42562842e4ef82eca57c7cbda23797f 100644 (file)
@@ -444,7 +444,7 @@ fn get_template_parameters<'ll, 'tcx>(
                 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> {
index bef40decdf3ab0912258c127cfe2d74d06fffdbf..b42d760a773450d38c2fdef52221da624fa2144b 100644 (file)
@@ -24,9 +24,7 @@ pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool {
 
 #[allow(non_snake_case)]
 pub fn create_DIArray(builder: &DIBuilder<'ll>, arr: &[Option<&'ll DIDescriptor>]) -> &'ll DIArray {
-    return unsafe {
-        llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32)
-    };
+    unsafe { llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) }
 }
 
 #[inline]
index ab9df4162472ccde508c9e801afbab39aae63700..64db4f7462df81d860c559c94550bcbaa012a688 100644 (file)
@@ -27,13 +27,13 @@ impl ArchiveRO {
     /// If this archive is used with a mutable method, then an error will be
     /// raised.
     pub fn open(dst: &Path) -> Result<ArchiveRO, String> {
-        return unsafe {
+        unsafe {
             let s = path_to_c_string(dst);
             let ar = super::LLVMRustOpenArchive(s.as_ptr()).ok_or_else(|| {
                 super::last_error().unwrap_or_else(|| "failed to open archive".to_owned())
             })?;
             Ok(ArchiveRO { raw: ar })
-        };
+        }
     }
 
     pub fn iter(&self) -> Iter<'_> {
index 30b055b3131499961da4db1de4f3a797ebb3e514..0208bb73abdbe1e5d3c07e0c53ec190e73b8366e 100644 (file)
@@ -119,7 +119,7 @@ pub fn command(&self) -> process::Command {
         for k in &self.env_remove {
             ret.env_remove(k);
         }
-        return ret;
+        ret
     }
 
     // extensions
index e57cae30b7795446777e956f0157dd74002b30bf..5fd16cb121fdafbea5166729b7fc9d662c0ca728 100644 (file)
@@ -852,7 +852,7 @@ pub fn new(tcx: TyCtxt<'_>) -> CrateInfo {
             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| {
index 5283bd78a302950cf5f6aafdb64cfb88e779fea8..a7f9340dead88589dee03485f49faf96fc3fb458 100644 (file)
@@ -125,9 +125,9 @@ fn next(&mut self) -> Option<Self::Item> {
             } else {
                 self.node = Some(dom);
             }
-            return Some(node);
+            Some(node)
         } else {
-            return None;
+            None
         }
     }
 }
index 34f0c182499dbc410a3f63c5be42030635122f8d..e3e076e769f5d14c91c39d98a059fa3b86ddcb9e 100644 (file)
@@ -752,7 +752,7 @@ fn print_crate_info(
                 PrintRequest::NativeStaticLibs => {}
             }
         }
-        return Compilation::Stop;
+        Compilation::Stop
     }
 }
 
index 54d7e0ece503185dfcd241023521c5d556e2c56c..c5446116f4c5093076e0938d577ec6cf74a3efec 100644 (file)
@@ -175,6 +175,6 @@ fn check_config(&self, attr: &ast::Attribute) -> bool {
             return true;
         }
         debug!("check_config: no match found");
-        return false;
+        false
     }
 }
index b465a11c99c069bdbe3c97b9088f02d05d812278..ba586d0cfba04d5d6305a19205e3a691f24da727 100644 (file)
@@ -132,7 +132,6 @@ fn save_in<F>(sess: &Session, path_buf: PathBuf, encode: F)
         }
         Err(err) => {
             sess.err(&format!("failed to write dep-graph to `{}`: {}", path_buf.display(), err));
-            return;
         }
     }
 }
index bb0c124a1892dffe39120a82e68a4a44c6b7aaf6..8f8fc4f137b7355ac22fb7206aacadfc5db601b7 100644 (file)
@@ -136,7 +136,7 @@ fn binders<T>(
         } else {
             // Fast path for the common case.
             self.relate(a.skip_binder(), b.skip_binder())?;
-            return Ok(a.clone());
+            Ok(a.clone())
         }
     }
 }
index 50b324c72278e1fa83d9a67671962e900221a6e6..689323ce4834658aa334f5a306cb66044ec557be 100644 (file)
@@ -142,6 +142,6 @@ pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorReported> {
             .span_label(span_2, String::new())
             .span_label(span, span_label)
             .emit();
-        return Some(ErrorReported);
+        Some(ErrorReported)
     }
 }
index 105b987f85e96272f36328f81b0da378cd485786..6a5a1c46d4caf38c8f5be2d2c030a678bbfaea8e 100644 (file)
@@ -30,7 +30,7 @@ pub fn higher_ranked_sub<T>(
 
         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
             // fresh placeholder region.
             let (b_prime, placeholder_map) = self.infcx.replace_bound_vars_with_placeholders(b);
@@ -53,7 +53,7 @@ pub fn higher_ranked_sub<T>(
             debug!("higher_ranked_sub: OK result={:?}", result);
 
             Ok(ty::Binder::bind(result))
-        });
+        })
     }
 }
 
index 3af10e850d534fe2c3112c58339f7075672fdfbb..821b9f72c0b20e6c04fe584c552a21aefce0703e 100644 (file)
@@ -452,12 +452,10 @@ fn expand_node(
                 debug!("Expanding value of {:?} from {:?} to {:?}", b_vid, cur_region, lub);
 
                 *b_data = VarValue::Value(lub);
-                return true;
+                true
             }
 
-            VarValue::ErrorValue => {
-                return false;
-            }
+            VarValue::ErrorValue => false,
         }
     }
 
@@ -804,7 +802,7 @@ fn construct_graph(&self) -> RegionGraph<'tcx> {
             }
         }
 
-        return graph;
+        graph
     }
 
     fn collect_error_for_expanding_node(
index 50bea300c50644ffe74ccba3c860c35f13ab561b..c194e968013eb0ecfeebeec4161f2e675ef0cee8 100644 (file)
@@ -877,7 +877,7 @@ fn tys(&mut self, a: Ty<'tcx>, _: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
                     // If sub-roots are equal, then `for_vid` and
                     // `vid` are related via subtyping.
                     debug!("TypeGeneralizer::tys: occurs check failed");
-                    return Err(TypeError::Mismatch);
+                    Err(TypeError::Mismatch)
                 } else {
                     match variables.probe(vid) {
                         TypeVariableValue::Known { value: u } => {
@@ -898,7 +898,7 @@ fn tys(&mut self, a: Ty<'tcx>, _: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
 
                             let u = self.tcx().mk_ty_var(new_var_id);
                             debug!("generalize: replacing original vid={:?} with new={:?}", vid, u);
-                            return Ok(u);
+                            Ok(u)
                         }
                     }
                 }
index 868b95043796b8b563e39727229ecb818e36bf03..38475b02e5db84073e407333bc996bc0c9c9c26c 100644 (file)
@@ -505,7 +505,7 @@ pub fn new_region_var(
             self.undo_log.push(AddVar(vid));
         }
         debug!("created new region variable {:?} in {:?} with origin {:?}", vid, universe, origin);
-        return vid;
+        vid
     }
 
     /// Returns the universe for the given variable.
index 25334461a113bb7087d68c66e032b095cd734aa3..d3ac58a49c8d5faa595f826e3e8fc27902cf9a98 100644 (file)
@@ -527,10 +527,10 @@ fn lifetime_or_char(&mut self) -> TokenKind {
         if self.first() == '\'' {
             self.bump();
             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 {
index 408031028b102dac8f11d1e594a81560161e47fd..88f2284cd6154ac4eefce533feb3f0405519adba 100644 (file)
@@ -269,7 +269,7 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) {
                 })
             }
 
-            _ => return,
+            _ => {}
         }
     }
 
index 229740615f707f60da6fa6b355568764d9f58b5d..b5826d6a5efa655035f1ab196fac88b5b0a8214f 100644 (file)
@@ -543,7 +543,7 @@ fn check_pat(&mut self, cx: &EarlyContext<'_>, p: &ast::Pat) {
             // Do not lint on `(..)` as that will result in the other arms being useless.
             Paren(_)
             // 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.
             TupleStruct(_, ps) | Tuple(ps) | Slice(ps) | Or(ps) => for p in ps {
                 self.check_unused_parens_pat(cx, p, false, false);
index f20cdfcba15ca9b1e77fdb5026f1e93f0630aed1..9b6e427abc1fd96abe04a3fa0ff91a790604c8d2 100644 (file)
@@ -264,7 +264,7 @@ fn existing_match(&self, name: Symbol, hash: Option<Svh>, kind: PathKind) -> Opt
                 ret = Some(cnum);
             }
         });
-        return ret;
+        ret
     }
 
     fn verify_no_symbol_conflicts(&self, span: Span, root: &CrateRoot<'_>) {
index fc988ec15cee99f58392b17052a14f6eb2ccd3c4..60b8239a82155d87d8126c16710709035d6f0d50 100644 (file)
@@ -6,7 +6,7 @@
 crate fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> {
     let mut collector = Collector { tcx, modules: Vec::new() };
     tcx.hir().krate().visit_all_item_likes(&mut collector);
-    return collector.modules;
+    collector.modules
 }
 
 struct Collector<'tcx> {
index 13668b2423fddf27452bdda804d8b2be7eb7d6e5..56b26efe5bf1e6c89949bcc37084fbc44f4d1781 100644 (file)
@@ -16,7 +16,7 @@
         }
     }
 
-    return collector.args;
+    collector.args
 }
 
 struct Collector {
index 1ede629e7ef7dc9af47c52d7aa5427c4df418dfe..2f9be599ba94b9ffc1a8c3035b638755120dd8c7 100644 (file)
@@ -949,7 +949,7 @@ fn get_metadata_section(
     let start = Instant::now();
     let ret = get_metadata_section_imp(target, flavor, filename, loader);
     info!("reading {:?} => {:?}", filename.file_name().unwrap(), start.elapsed());
-    return ret;
+    ret
 }
 
 /// A trivial wrapper for `Mmap` that implements `StableDeref`.
index 64bbf393ba0f1ca9e4d429703581b52ceb3bd10a..19d2d620f58a7b90ccd8da678480cf0ad45ef52b 100644 (file)
@@ -15,7 +15,7 @@
     let mut collector = Collector { tcx, libs: Vec::new() };
     tcx.hir().krate().visit_all_item_likes(&mut collector);
     collector.process_command_line();
-    return collector.libs;
+    collector.libs
 }
 
 crate fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
index cc2bd51f92f3e132889605a34621ec60c6cdf81d..ca75daf1aa9b222f72bdd3a1b4a43ca05747fe2d 100644 (file)
@@ -170,7 +170,7 @@ fn into_args(self) -> (DefId, DefId) {
             .iter()
             .filter_map(|&(exported_symbol, export_level)| {
                 if let ExportedSymbol::NonGeneric(def_id) = exported_symbol {
-                    return Some((def_id, export_level))
+                    Some((def_id, export_level))
                 } else {
                     None
                 }
index 9d5cf3ec4bec0e8c2f962d85123fc020f6654dd8..9f4f0ce5620b52d8149443c7368380cc10f884ec 100644 (file)
@@ -273,7 +273,7 @@ fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: mir::Location)
             assert_eq!(borrow_data.borrowed_place, *place);
         }
 
-        return self.super_rvalue(rvalue, location);
+        self.super_rvalue(rvalue, location)
     }
 }
 
index 7103fc596c92269c4bda1121550c1a41f8e87353..d1d0ba215e08e26eea9fee38a149f78ca055591d 100644 (file)
@@ -500,7 +500,7 @@ fn give_name_if_we_can_match_hir_ty(
             }
         }
 
-        return None;
+        None
     }
 
     /// We've found an enum/struct/union type with the substitutions
index 28889486c383b55150ced9e80d4c73fc60b31f21..d81aae6523a45addab79a39c408720556dac7a1c 100644 (file)
@@ -56,7 +56,7 @@ fn try_eval_const_fn_call(
 
         self.return_to_block(ret.map(|r| r.1))?;
         self.dump_place(*dest);
-        return Ok(true);
+        Ok(true)
     }
 
     /// "Intercept" a function call to a panic-related function
index dd0f9ff75b9fe45627ad10c2af088b1b927d3aa7..c98a5e84729ab949d8b188b77d3ff9317ad3a928 100644 (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> {
@@ -171,7 +171,7 @@ pub(crate) fn run<P>(
                     return None;
                 }
             }
-            return None;
+            None
         };
 
         let print_preflow_to = name_found(tcx.sess, attributes, sym::borrowck_graphviz_preflow);
index f2ee5e047a88e5b3366f93dcbcd2cec366c094d2..76a5aecb9db62e3bee38ed0b40533f3f2e1786ad 100644 (file)
@@ -64,7 +64,7 @@ fn binary_char_op(
             Ge => l >= r,
             _ => 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(
@@ -87,7 +87,7 @@ fn binary_bool_op(
             BitXor => l ^ r,
             _ => 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>>>(
@@ -113,7 +113,7 @@ fn binary_float_op<F: Float + Into<Scalar<M::PointerTag>>>(
             Rem => ((l % r).value.into(), ty),
             _ => bug!("invalid float op: `{:?}`", bin_op),
         };
-        return (val, false, ty);
+        (val, false, ty)
     }
 
     fn binary_int_op(
index 5313446c253c848e2864011b352cbfa180c238e4..933e74ee9ed7ee9393b255f125967100e5751907 100644 (file)
@@ -212,9 +212,7 @@ pub(super) fn len(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
         if self.layout.is_unsized() {
             // We need to consult `meta` metadata
             match self.layout.ty.kind {
-                ty::Slice(..) | ty::Str => {
-                    return self.mplace.meta.unwrap_meta().to_machine_usize(cx);
-                }
+                ty::Slice(..) | ty::Str => self.mplace.meta.unwrap_meta().to_machine_usize(cx),
                 _ => bug!("len not supported on unsized type {:?}", self.layout.ty),
             }
         } else {
index 22a081a9c8e0be9af49b682c8dbe25ad83b560c5..a9e45a032a6bee9b4b2bc2a1c4654a14cefbeefc 100644 (file)
@@ -240,7 +240,7 @@ fn eval_fn_call(
         match instance.def {
             ty::InstanceDef::Intrinsic(..) => {
                 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::ReifyShim(..)
index 4dd037d93ce9b9c727013d84a35a25690c165668..a592e8d9c05fe6863d89ca6659eaa66aa331c67d 100644 (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)
     }
 
-    return true;
+    true
 }
 
 /// For a given pair of source and target type that occur in an unsizing coercion,
index ca23c44f64668f19fb61788009b8384fc85d0b3d..43876380c840e0f1785b8e1df8607d2086c763a3 100644 (file)
@@ -483,7 +483,7 @@ fn report_assert_as_lint(
             err.span_label(source_info.span, format!("{:?}", panic));
             err.emit()
         });
-        return None;
+        None
     }
 
     fn check_unary_op(
index 821c4d68c7e8aaa93fa7acfdd5dbf5fbb5970214..f35b50d484bffe4969672bce0addcce13739e47d 100644 (file)
@@ -43,8 +43,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
             ..
         })
         | Node::TraitItem(hir::TraitItem {
-            kind:
-                hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitFn::Provided(body_id)),
+            kind: hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitFn::Provided(body_id)),
             ..
         }) => (*body_id, decl.output.span()),
         Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. })
@@ -368,7 +367,7 @@ fn currently_in_block_tail(&self) -> Option<BlockTailInfo> {
             }
         }
 
-        return None;
+        None
     }
 
     /// Looks at the topmost frame on the BlockContext and reports
index 8d7225c8c7b51ef3a883014dcf5106b91b173bfa..07a9d91cd746d344a2bd5e6dbfb7db3c1d7191b6 100644 (file)
@@ -98,7 +98,7 @@ fn mirror_stmts<'a, 'tcx>(
             }
         }
     }
-    return result;
+    result
 }
 
 crate fn to_expr_ref<'a, 'tcx>(
index c31cc1b4c9f00b4d0263a091a0c5fb21dce439cf..58db7d286e7e65b003d71817fed6f7080d7ce677 100644 (file)
@@ -320,7 +320,7 @@ pub fn nt_to_tokenstream(nt: &Nonterminal, sess: &ParseSess, span: Span) -> Toke
                 going with stringified version"
         );
     }
-    return tokens_for_real;
+    tokens_for_real
 }
 
 fn prepend_attrs(
index c65e99842c5ddf3c63353bed158521c57f6ef081..5dac461441d64ad448ca178be3376c1598c5a2b5 100644 (file)
@@ -996,7 +996,7 @@ fn parse_lit_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
                 let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(literal), attrs);
                 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 @@ fn parse_match_expr(&mut self, mut attrs: AttrVec) -> PResult<'a, P<Expr>> {
         }
         let hi = self.token.span;
         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> {
index 9d70f606f3ef4339e80e6c619cd1048282bbd8d6..2b1799f5c488584e4c258b2d1d54a5f3635f0726 100644 (file)
@@ -314,7 +314,7 @@ fn recover_missing_kw_before_item(&mut self) -> PResult<'a, ()> {
                 " struct ".into(),
                 Applicability::MaybeIncorrect, // speculative
             );
-            return Err(err);
+            Err(err)
         } else if self.look_ahead(1, |t| *t == token::OpenDelim(token::Paren)) {
             let ident = self.parse_ident().unwrap();
             self.bump(); // `(`
@@ -362,7 +362,7 @@ fn recover_missing_kw_before_item(&mut self) -> PResult<'a, ()> {
                     );
                 }
             }
-            return Err(err);
+            Err(err)
         } else if self.look_ahead(1, |t| *t == token::Lt) {
             let ident = self.parse_ident().unwrap();
             self.eat_to_tokens(&[&token::Gt]);
@@ -384,7 +384,7 @@ fn recover_missing_kw_before_item(&mut self) -> PResult<'a, ()> {
                     Applicability::MachineApplicable,
                 );
             }
-            return Err(err);
+            Err(err)
         } else {
             Ok(())
         }
@@ -910,7 +910,7 @@ fn error_bad_item_kind<T>(&self, span: Span, kind: &ItemKind, ctx: &str) -> Opti
         let span = self.sess.source_map().def_span(span);
         let msg = format!("{} is not supported in {}", kind.descr(), ctx);
         self.struct_span_err(span, &msg).emit();
-        return None;
+        None
     }
 
     fn error_on_foreign_const(&self, span: Span, ident: Ident) {
index 4585941943b74a001a64c10a85ae14c2370e55d4..6b987ff1cce683714fb6106f243552aa5a82ebcc 100644 (file)
@@ -918,7 +918,7 @@ fn parse_pat_fields(&mut self) -> PResult<'a, (Vec<FieldPat>, bool)> {
             }
             err.emit();
         }
-        return Ok((fields, etc));
+        Ok((fields, etc))
     }
 
     /// Recover on `...` as if it were `..` to avoid further errors.
index d40597d8fcb0c543127dc61e155dd87e54b84bd7..d43f5d67113a1e348055e6dabda92ef4757bf5a5 100644 (file)
@@ -278,7 +278,7 @@ fn error_block_no_opening_brace<T>(&mut self) -> PResult<'a, T> {
             _ => {}
         }
         e.span_label(sp, "expected `{`");
-        return Err(e);
+        Err(e)
     }
 
     /// Parses a block. Inner attributes are allowed.
index 70b106f5d2332eb0c11736d87cd7d463e984c9ff..bf577d26b0fed870dcdad0bab25f400ba63c98e6 100644 (file)
@@ -864,7 +864,7 @@ fn merge_from_succ(&mut self, ln: LiveNode, succ_ln: LiveNode, first_merge: bool
             first_merge,
             any_changed
         );
-        return any_changed;
+        any_changed
     }
 
     // Indicates that a local variable was *defined*; we know that no
index 1daef45a1f591776f159c17bd4d76c328af114cc..fa2afae469c045a1beb0c1f4c862bfe74891b0d9 100644 (file)
@@ -222,7 +222,7 @@ fn require_label_in_labeled_block(
                 return true;
             }
         }
-        return false;
+        false
     }
     fn emit_unlabled_cf_in_while_condition(&mut self, span: Span, cf_type: &str) {
         struct_span_err!(
index 835e7cfb628169a3c182a62b3dd3dcd7181efe81..1e9c6c91d385f3ea432860ff12d9785930bf8e43 100644 (file)
@@ -30,9 +30,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item<'_>, attrs: Codegen
     }
 
     match item.kind {
-        hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => {
-            return true;
-        }
+        hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => true,
         hir::ItemKind::Impl { .. } | hir::ItemKind::Fn(..) => {
             let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
             generics.requires_monomorphization(tcx)
index 11311a3e8aa682d4aaa94f67213178f95ff830bf..8fa5a4fbc61f46920b0ad4ee617a12da6d5bc31d 100644 (file)
@@ -465,7 +465,7 @@ fn new_index(tcx: TyCtxt<'tcx>) -> Index<'tcx> {
             |v| intravisit::walk_crate(v, krate),
         );
     }
-    return index;
+    index
 }
 
 /// Cross-references the feature names of unstable APIs with enabled
index c8c8c2299305ba55faee029f57c4291da3eda61d..a3510737b7edc7be1088514185f8efaa0f31129f 100644 (file)
@@ -1423,7 +1423,7 @@ fn path_is_private_type(&self, path: &hir::Path<'_>) -> bool {
                 Some(_) | None => false,
             }
         } else {
-            return false;
+            false
         }
     }
 
@@ -1837,7 +1837,7 @@ fn leaks_private_dep(&self, item_id: DefId) -> bool {
             && self.tcx.is_private_dep(item_id.krate);
 
         log::debug!("leaks_private_dep(item_id={:?})={}", item_id, ret);
-        return ret;
+        ret
     }
 }
 
index 505cd331a25099f5debc4e96d1a632d52dbd9d2d..0dee997f2ed962071d52a2e6a12409423adca400 100644 (file)
@@ -200,7 +200,7 @@ fn visit_assoc_item(&mut self, i: &'a AssocItem, ctxt: visit::AssocCtxt) {
 
     fn visit_pat(&mut self, pat: &'a Pat) {
         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),
         }
     }
index 663e61ad2add4c0b79d5b09882bc2c045df7af60..95597e8ebf1e9247ced9b18f9b81b2b61b66c66c 100644 (file)
@@ -1108,7 +1108,7 @@ fn finalize_import(&mut self, import: &'b Import<'b>) -> Option<UnresolvedImport
                                     match binding.kind {
                                         // Never suggest the name that has binding error
                                         // i.e., the name that cannot be previously resolved
-                                        NameBindingKind::Res(Res::Err, _) => return None,
+                                        NameBindingKind::Res(Res::Err, _) => None,
                                         _ => Some(&i.name),
                                     }
                                 }
index 41380b2a4b78a2b787e15b6a370400e4449f9aeb..e1256551e24da2fd62c1e9bc9f21c1fc9a5ebd57 100644 (file)
@@ -380,7 +380,7 @@ fn call_has_self_arg(&self, source: PathSource<'_>) -> Option<(Span, Option<Span
                 _ => (),
             }
         };
-        return has_self_arg;
+        has_self_arg
     }
 
     fn followed_by_brace(&self, span: Span) -> (bool, Option<(Span, String)>) {
@@ -430,7 +430,7 @@ fn followed_by_brace(&self, span: Span) -> (bool, Option<(Span, String)>) {
                 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`
index 6f2e0bce3acaf63e9d2cf15dfa92099b79d295bd..166fc48b44c4c87533a98d70638923557c56a937 100644 (file)
@@ -83,7 +83,7 @@ enum SubNS {
 // line-breaks and is slow.
 fn fast_print_path(path: &ast::Path) -> Symbol {
     if path.segments.len() == 1 {
-        return path.segments[0].ident.name;
+        path.segments[0].ident.name
     } else {
         let mut path_str = String::with_capacity(64);
         for (i, segment) in path.segments.iter().enumerate() {
index 98d81c6252242c3bec73c27aa30a5c2dfc5eb7f4..59084f19045454c1a3608d16a5860b483c842b23 100644 (file)
@@ -534,7 +534,7 @@ pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
                         let variant = &def.non_enum_variant();
                         filter!(self.span_utils, ident.span);
                         let span = self.span_from_span(ident.span);
-                        return Some(Data::RefData(Ref {
+                        Some(Data::RefData(Ref {
                             kind: RefKind::Variable,
                             span,
                             ref_id: self
@@ -542,7 +542,7 @@ pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
                                 .find_field_index(ident, variant)
                                 .map(|index| id_from_def_id(variant.fields[index].did))
                                 .unwrap_or_else(|| null_id()),
-                        }));
+                        }))
                     }
                     ty::Tuple(..) => None,
                     _ => {
index c273e7fdbf916432e03439a4529cf98ccc6128a5..f16e4ca93d80a5ca0d6a2e3b2569bf063feff42c 100644 (file)
@@ -1140,7 +1140,7 @@ pub fn parse_error_format(
         _ => {}
     }
 
-    return error_format;
+    error_format
 }
 
 fn parse_crate_edition(matches: &getopts::Matches) -> Edition {
index d6725160a5d022939ecf7e84d315b77258344a8a..68b0bd1a574187d3eb0982e8a7f6985737ee60e4 100644 (file)
@@ -99,10 +99,6 @@ pub fn byte_pos_to_line_and_col(
         cache_entry.line_end = line_bounds.1;
         cache_entry.time_stamp = self.time_stamp;
 
-        return Some((
-            cache_entry.file.clone(),
-            cache_entry.line_number,
-            pos - cache_entry.line_start,
-        ));
+        Some((cache_entry.file.clone(), cache_entry.line_number, pos - cache_entry.line_start))
     }
 }
index 7dd9e2f6316b41631dc899307893836499fe7f73..39eb318a785e7c69c514946ae95f6b59dd1192e7 100644 (file)
@@ -368,7 +368,7 @@ pub fn mk_substr_filename(&self, sp: Span) -> String {
 
     // If there is a doctest offset, applies it to the line.
     pub fn doctest_offset_line(&self, file: &FileName, orig: usize) -> usize {
-        return match file {
+        match file {
             FileName::DocTest(_, offset) => {
                 return if *offset >= 0 {
                     orig + *offset as usize
@@ -377,7 +377,7 @@ pub fn doctest_offset_line(&self, file: &FileName, orig: usize) -> usize {
                 };
             }
             _ => orig,
-        };
+        }
     }
 
     /// Looks up source information about a `BytePos`.
@@ -569,10 +569,10 @@ fn span_to_source<F>(&self, sp: Span, extract_source: F) -> Result<String, SpanS
         let local_end = self.lookup_byte_offset(sp.hi());
 
         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),
                 end: (local_end.sf.name.clone(), local_end.sf.start_pos),
-            }));
+            }))
         } else {
             self.ensure_source_file_source_present(local_begin.sf.clone());
 
@@ -590,13 +590,11 @@ fn span_to_source<F>(&self, sp: Span, extract_source: F) -> Result<String, SpanS
             }
 
             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() {
-                return extract_source(src, start_index, end_index);
+                extract_source(src, start_index, end_index)
             } else {
-                return Err(SpanSnippetError::SourceNotAvailable {
-                    filename: local_begin.sf.name.clone(),
-                });
+                Err(SpanSnippetError::SourceNotAvailable { filename: local_begin.sf.name.clone() })
             }
         }
     }
index d221d6886e9fbd6edf8f21d50590fef73f78091a..bd980e6eb8b8a51327ab363578ac14e42a7463f7 100644 (file)
@@ -113,7 +113,7 @@ pub fn find_auto_trait_generics<A>(
             return AutoTraitResult::ExplicitImpl;
         }
 
-        return tcx.infer_ctxt().enter(|infcx| {
+        tcx.infer_ctxt().enter(|infcx| {
             let mut fresh_preds = FxHashSet::default();
 
             // Due to the way projections are handled by SelectionContext, we need to run
@@ -219,8 +219,8 @@ pub fn find_auto_trait_generics<A>(
 
             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 @@ fn evaluate_predicates(
             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:
@@ -492,7 +492,7 @@ fn add_user_pred<'c>(
                 }
                 _ => {}
             }
-            return true;
+            true
         });
 
         if should_add_new {
@@ -591,15 +591,15 @@ fn map_vid_to_region<'cx>(
     }
 
     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 {
-        return match ty.kind {
+        match ty.kind {
             ty::Param(_) => true,
             ty::Projection(p) => self.is_of_param(p.self_ty()),
             _ => false,
-        };
+        }
     }
 
     fn is_self_referential_projection(&self, p: ty::PolyProjectionPredicate<'_>) -> bool {
@@ -804,7 +804,7 @@ fn evaluate_nested_obligations(
                 _ => panic!("Unexpected predicate {:?} {:?}", ty, predicate),
             };
         }
-        return true;
+        true
     }
 
     pub fn clean_pred(
index 5f542e7e13be5affad47c7deb52169371017ff53..dc13af99fec6c7d0b5aaac1759a1826400a110d8 100644 (file)
@@ -221,10 +221,10 @@ pub fn trait_ref_is_knowable<'tcx>(
     // we are an owner.
     if orphan_check_trait_ref(tcx, trait_ref, InCrate::Local).is_ok() {
         debug!("trait_ref_is_knowable: orphan check passed");
-        return None;
+        None
     } else {
         debug!("trait_ref_is_knowable: nonlocal, nonfundamental, unowned");
-        return Some(Conflict::Upstream);
+        Some(Conflict::Upstream)
     }
 }
 
index 3d0dd73f03c184be9bc7bbabf05fecd2449cd85a..18b2ca89837208d585c7135af5dc11fa1be6dafd 100644 (file)
@@ -111,11 +111,7 @@ fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str> {
             }),
             hir::Node::Expr(hir::Expr { .. }) => {
                 let parent_hid = hir.get_parent_node(hir_id);
-                if parent_hid != hir_id {
-                    return self.describe_enclosure(parent_hid);
-                } else {
-                    None
-                }
+                if parent_hid != hir_id { self.describe_enclosure(parent_hid) } else { None }
             }
             _ => None,
         }
index 0523a2019861cef951fc52238c3977393d87a4c2..522a8084cdc0d5555f4a84b496e4fe73103917b9 100644 (file)
@@ -351,7 +351,7 @@ fn get_closure_name(
             // Different to previous arm because one is `&hir::Local` and the other
             // is `P<hir::Local>`.
             Some(hir::Node::Local(local)) => get_name(err, &local.pat.kind),
-            _ => return None,
+            _ => None,
         }
     }
 
index adec2ddb25322c7f2987e7351ba82ff55acfa097..99412fafcfa8d854c2b265e1c68c04e17011e9b7 100644 (file)
@@ -169,12 +169,12 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
                                 debug!("QueryNormalizer: result = {:#?}", result);
                                 debug!("QueryNormalizer: obligations = {:#?}", obligations);
                                 self.obligations.extend(obligations);
-                                return result.normalized_ty;
+                                result.normalized_ty
                             }
 
                             Err(_) => {
                                 self.error = true;
-                                return ty;
+                                ty
                             }
                         }
                     }
index b69c5bdce2abc713b7a8ced083cf4e8d1643563f..5f40c1cefca45e88d60fc2ef48fd15c18ea84430 100644 (file)
@@ -595,7 +595,7 @@ fn compute(&mut self, ty0: Ty<'tcx>) -> bool {
         }
 
         // if we made it through that loop above, we made progress!
-        return true;
+        true
     }
 
     fn nominal_obligations(
index 69d0bd09296877743026aa2868f3b6051cf3410d..ed6259d4573610142f57c9b9712246d0ca7db546 100644 (file)
@@ -146,7 +146,7 @@ fn visit_clause(&mut self, clause: Clause<'tcx>) {
 
     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<'_> {
index 0f71246c73759353a7d8a45bd1f1b6f20355b066..3b72da23bafae80f8314526f801544ab6d43313a 100644 (file)
@@ -132,7 +132,7 @@ fn next(&mut self) -> Option<NeedsDropResult<Ty<'tcx>>> {
             }
         }
 
-        return None;
+        None
     }
 }
 
index 9a8d161572bcfd3e28879e70f4e429cda5536e02..3ee6d5df7356b385887ad9d24bf1fcd9e642bee0 100644 (file)
@@ -2128,7 +2128,7 @@ fn one_bound_for_assoc_type<I>(
                 return Err(ErrorReported);
             }
         }
-        return Ok(bound);
+        Ok(bound)
     }
 
     fn complain_about_assoc_type_not_found<I>(
@@ -2709,7 +2709,7 @@ pub fn res_to_ty(
             }
             Res::Err => {
                 self.set_tainted_by_errors();
-                return self.tcx().types.err;
+                self.tcx().types.err
             }
             _ => span_bug!(span, "unexpected resolution: {:?}", path.res),
         }
@@ -3047,7 +3047,7 @@ fn compute_object_lifetime_bound(
             )
             .emit();
         }
-        return Some(r);
+        Some(r)
     }
 }
 
index 368f64e4d41aab6716185803f0153936619e06e5..d19422311719590b8c26cb678222f041136ec2d6 100644 (file)
@@ -1580,7 +1580,7 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: DefId) -> bool {
     } else {
         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`
@@ -2313,7 +2313,7 @@ fn check_representable(tcx: TyCtxt<'_>, sp: Span, item_def_id: DefId) -> bool {
         }
         Representability::Representable | Representability::ContainsRecursive => (),
     }
-    return true;
+    true
 }
 
 pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: DefId) {
index 60e5df68b5842cb7c1545f15ed129255d3743266..c6ee9ab60abf3b3764e619e9233f78597700027b 100644 (file)
@@ -272,9 +272,7 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
                     item.span,
                 );
             }
-            ty::Error => {
-                return;
-            }
+            ty::Error => {}
             _ => {
                 struct_span_err!(
                     self.tcx.sess,
@@ -288,7 +286,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
                        to wrap it instead",
                 )
                 .emit();
-                return;
             }
         }
     }
index 41c205bc11b3594de9f7ea67f9cc117d6224e50e..44ef4ebd463d7448671438ccd5cd87d9d940ac0c 100644 (file)
@@ -290,7 +290,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
                             DUMMY_SP,
                             &format!("unexpected const parent path {:?}", parent_node,),
                         );
-                        return tcx.types.err;
+                        tcx.types.err
                     }
                 }
 
index 34317c7a2ee3d9ab2cb10f0d06409749604dfea5..e10d466030f0b1abc135e1418373c8d08fc0ea40 100644 (file)
@@ -250,7 +250,7 @@ fn enabled() -> bool {
             },
         };
         ENABLED.store(enabled as usize + 1, SeqCst);
-        return enabled;
+        enabled
     }
 
     /// Capture a stack backtrace of the current thread.
index 2c7ba8f8ea1fd97cbba071815a611871a36adb6a..e9b1e86d7ae49ed8e66a6f5a995be65ceb8ef4d5 100644 (file)
@@ -28,7 +28,7 @@ fn drop(&mut self) {
 
     unsafe {
         LOCK.lock();
-        return Guard;
+        Guard
     }
 }