about summary refs log tree commit diff
path: root/src/librustc_codegen_utils
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:04 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:47 -0500
commita06baa56b95674fc626b3c3fd680d6a65357fe60 (patch)
treecd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/librustc_codegen_utils
parent8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff)
downloadrust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz
rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip
Format the world
Diffstat (limited to 'src/librustc_codegen_utils')
-rw-r--r--src/librustc_codegen_utils/codegen_backend.rs16
-rw-r--r--src/librustc_codegen_utils/lib.rs24
-rw-r--r--src/librustc_codegen_utils/link.rs120
-rw-r--r--src/librustc_codegen_utils/symbol_names.rs14
-rw-r--r--src/librustc_codegen_utils/symbol_names/legacy.rs95
-rw-r--r--src/librustc_codegen_utils/symbol_names_test.rs7
6 files changed, 123 insertions, 153 deletions
diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs
index 0e2c3731eae..0737fd6b5ca 100644
--- a/src/librustc_codegen_utils/codegen_backend.rs
+++ b/src/librustc_codegen_utils/codegen_backend.rs
@@ -8,21 +8,23 @@
 
 use std::any::Any;
 
-use syntax::symbol::Symbol;
-use rustc::session::Session;
-use rustc::util::common::ErrorReported;
+use rustc::dep_graph::DepGraph;
+use rustc::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
 use rustc::session::config::{OutputFilenames, PrintRequest};
-use rustc::ty::TyCtxt;
+use rustc::session::Session;
 use rustc::ty::query::Providers;
-use rustc::middle::cstore::{EncodedMetadata, MetadataLoaderDyn};
-use rustc::dep_graph::DepGraph;
+use rustc::ty::TyCtxt;
+use rustc::util::common::ErrorReported;
+use syntax::symbol::Symbol;
 
 pub use rustc_data_structures::sync::MetadataRef;
 
 pub trait CodegenBackend {
     fn init(&self, _sess: &Session) {}
     fn print(&self, _req: PrintRequest, _sess: &Session) {}
-    fn target_features(&self, _sess: &Session) -> Vec<Symbol> { vec![] }
+    fn target_features(&self, _sess: &Session) -> Vec<Symbol> {
+        vec![]
+    }
     fn print_passes(&self) {}
     fn print_version(&self) {}
 
diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs
index fb2099e71a3..578aa591b5c 100644
--- a/src/librustc_codegen_utils/lib.rs
+++ b/src/librustc_codegen_utils/lib.rs
@@ -3,7 +3,6 @@
 //! This API is completely unstable and subject to change.
 
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
-
 #![feature(arbitrary_self_types)]
 #![feature(box_patterns)]
 #![feature(box_syntax)]
@@ -11,27 +10,25 @@
 #![feature(never_type)]
 #![feature(nll)]
 #![feature(in_band_lifetimes)]
-
-#![recursion_limit="256"]
+#![recursion_limit = "256"]
 
 #[macro_use]
 extern crate rustc;
 
-use rustc::ty::TyCtxt;
+use rustc::hir::def_id::{DefId, LOCAL_CRATE};
 use rustc::ty::query::Providers;
-use rustc::hir::def_id::{LOCAL_CRATE, DefId};
+use rustc::ty::TyCtxt;
 use syntax::symbol::sym;
 
-pub mod link;
 pub mod codegen_backend;
+pub mod link;
 pub mod symbol_names;
 pub mod symbol_names_test;
 
-
 pub fn trigger_delay_span_bug(tcx: TyCtxt<'_>, key: DefId) {
     tcx.sess.delay_span_bug(
         tcx.def_span(key),
-        "delayed span bug triggered by #[rustc_error(delay_span_bug_from_inside_query)]"
+        "delayed span bug triggered by #[rustc_error(delay_span_bug_from_inside_query)]",
     );
 }
 
@@ -48,8 +45,8 @@ pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
                     // check if there is a #[rustc_error(delayed)]
                     Some(list) => {
                         if list.iter().any(|list_item| {
-                            list_item.ident().map(|i| i.name) ==
-                                Some(sym::delay_span_bug_from_inside_query)
+                            list_item.ident().map(|i| i.name)
+                                == Some(sym::delay_span_bug_from_inside_query)
                         }) {
                             tcx.ensure().trigger_delay_span_bug(def_id);
                         }
@@ -58,7 +55,7 @@ pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
                     None => {
                         tcx.sess.span_fatal(
                             tcx.def_span(def_id),
-                            "fatal error triggered by #[rustc_error]"
+                            "fatal error triggered by #[rustc_error]",
                         );
                     }
                 }
@@ -69,8 +66,5 @@ pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) {
 
 pub fn provide(providers: &mut Providers<'_>) {
     crate::symbol_names::provide(providers);
-    *providers = Providers {
-        trigger_delay_span_bug,
-        ..*providers
-    };
+    *providers = Providers { trigger_delay_span_bug, ..*providers };
 }
diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs
index 6b9258c32e7..89a68d775f2 100644
--- a/src/librustc_codegen_utils/link.rs
+++ b/src/librustc_codegen_utils/link.rs
@@ -1,20 +1,23 @@
-use rustc::session::config::{self, OutputFilenames, Input, OutputType};
+use rustc::session::config::{self, Input, OutputFilenames, OutputType};
 use rustc::session::Session;
 use std::path::{Path, PathBuf};
-use syntax::{ast, attr};
 use syntax::symbol::sym;
+use syntax::{ast, attr};
 use syntax_pos::Span;
 
-pub fn out_filename(sess: &Session,
-                crate_type: config::CrateType,
-                outputs: &OutputFilenames,
-                crate_name: &str)
-                -> PathBuf {
+pub fn out_filename(
+    sess: &Session,
+    crate_type: config::CrateType,
+    outputs: &OutputFilenames,
+    crate_name: &str,
+) -> PathBuf {
     let default_filename = filename_for_input(sess, crate_type, crate_name, outputs);
-    let out_filename = outputs.outputs.get(&OutputType::Exe)
-                              .and_then(|s| s.to_owned())
-                              .or_else(|| outputs.single_output_file.clone())
-                              .unwrap_or(default_filename);
+    let out_filename = outputs
+        .outputs
+        .get(&OutputType::Exe)
+        .and_then(|s| s.to_owned())
+        .or_else(|| outputs.single_output_file.clone())
+        .unwrap_or(default_filename);
 
     check_file_is_writeable(&out_filename, sess);
 
@@ -26,21 +29,22 @@ pub fn out_filename(sess: &Session,
 // read-only file.  We should be consistent.
 pub fn check_file_is_writeable(file: &Path, sess: &Session) {
     if !is_writeable(file) {
-        sess.fatal(&format!("output file {} is not writeable -- check its \
-                            permissions", file.display()));
+        sess.fatal(&format!(
+            "output file {} is not writeable -- check its \
+                            permissions",
+            file.display()
+        ));
     }
 }
 
 fn is_writeable(p: &Path) -> bool {
     match p.metadata() {
         Err(..) => true,
-        Ok(m) => !m.permissions().readonly()
+        Ok(m) => !m.permissions().readonly(),
     }
 }
 
-pub fn find_crate_name(sess: Option<&Session>,
-                       attrs: &[ast::Attribute],
-                       input: &Input) -> String {
+pub fn find_crate_name(sess: Option<&Session>, attrs: &[ast::Attribute], input: &Input) -> String {
     let validate = |s: String, span: Option<Span>| {
         rustc_metadata::validate_crate_name(sess, &s, span);
         s
@@ -50,16 +54,18 @@ pub fn find_crate_name(sess: Option<&Session>,
     // as used. After doing this, however, we still prioritize a crate name from
     // the command line over one found in the #[crate_name] attribute. If we
     // find both we ensure that they're the same later on as well.
-    let attr_crate_name = attr::find_by_name(attrs, sym::crate_name)
-        .and_then(|at| at.value_str().map(|s| (at, s)));
+    let attr_crate_name =
+        attr::find_by_name(attrs, sym::crate_name).and_then(|at| at.value_str().map(|s| (at, s)));
 
     if let Some(sess) = sess {
         if let Some(ref s) = sess.opts.crate_name {
             if let Some((attr, name)) = attr_crate_name {
                 if name.as_str() != *s {
-                    let msg = format!("`--crate-name` and `#[crate_name]` are \
+                    let msg = format!(
+                        "`--crate-name` and `#[crate_name]` are \
                                        required to match, but `{}` != `{}`",
-                                      s, name);
+                        s, name
+                    );
                     sess.span_err(attr.span, &msg);
                 }
             }
@@ -73,8 +79,11 @@ pub fn find_crate_name(sess: Option<&Session>,
     if let Input::File(ref path) = *input {
         if let Some(s) = path.file_stem().and_then(|s| s.to_str()) {
             if s.starts_with("-") {
-                let msg = format!("crate names cannot start with a `-`, but \
-                                   `{}` has a leading hyphen", s);
+                let msg = format!(
+                    "crate names cannot start with a `-`, but \
+                                   `{}` has a leading hyphen",
+                    s
+                );
                 if let Some(sess) = sess {
                     sess.err(&msg);
                 }
@@ -87,12 +96,16 @@ pub fn find_crate_name(sess: Option<&Session>,
     "rust_out".to_string()
 }
 
-pub fn filename_for_metadata(sess: &Session,
-                             crate_name: &str,
-                             outputs: &OutputFilenames) -> PathBuf {
+pub fn filename_for_metadata(
+    sess: &Session,
+    crate_name: &str,
+    outputs: &OutputFilenames,
+) -> PathBuf {
     let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
 
-    let out_filename = outputs.single_output_file.clone()
+    let out_filename = outputs
+        .single_output_file
+        .clone()
         .unwrap_or_else(|| outputs.out_directory.join(&format!("lib{}.rmeta", libname)));
 
     check_file_is_writeable(&out_filename, sess);
@@ -100,38 +113,32 @@ pub fn filename_for_metadata(sess: &Session,
     out_filename
 }
 
-pub fn filename_for_input(sess: &Session,
-                          crate_type: config::CrateType,
-                          crate_name: &str,
-                          outputs: &OutputFilenames) -> PathBuf {
+pub fn filename_for_input(
+    sess: &Session,
+    crate_type: config::CrateType,
+    crate_name: &str,
+    outputs: &OutputFilenames,
+) -> PathBuf {
     let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
 
     match crate_type {
-        config::CrateType::Rlib => {
-            outputs.out_directory.join(&format!("lib{}.rlib", libname))
-        }
-        config::CrateType::Cdylib |
-        config::CrateType::ProcMacro |
-        config::CrateType::Dylib => {
-            let (prefix, suffix) = (&sess.target.target.options.dll_prefix,
-                                    &sess.target.target.options.dll_suffix);
-            outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
-                                                suffix))
+        config::CrateType::Rlib => outputs.out_directory.join(&format!("lib{}.rlib", libname)),
+        config::CrateType::Cdylib | config::CrateType::ProcMacro | config::CrateType::Dylib => {
+            let (prefix, suffix) =
+                (&sess.target.target.options.dll_prefix, &sess.target.target.options.dll_suffix);
+            outputs.out_directory.join(&format!("{}{}{}", prefix, libname, suffix))
         }
         config::CrateType::Staticlib => {
-            let (prefix, suffix) = (&sess.target.target.options.staticlib_prefix,
-                                    &sess.target.target.options.staticlib_suffix);
-            outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
-                                                suffix))
+            let (prefix, suffix) = (
+                &sess.target.target.options.staticlib_prefix,
+                &sess.target.target.options.staticlib_suffix,
+            );
+            outputs.out_directory.join(&format!("{}{}{}", prefix, libname, suffix))
         }
         config::CrateType::Executable => {
             let suffix = &sess.target.target.options.exe_suffix;
             let out_filename = outputs.path(OutputType::Exe);
-            if suffix.is_empty() {
-                out_filename
-            } else {
-                out_filename.with_extension(&suffix[1..])
-            }
+            if suffix.is_empty() { out_filename } else { out_filename.with_extension(&suffix[1..]) }
         }
     }
 }
@@ -154,17 +161,14 @@ pub fn default_output_for_target(sess: &Session) -> config::CrateType {
 }
 
 /// Checks if target supports crate_type as output
-pub fn invalid_output_for_target(sess: &Session,
-                                 crate_type: config::CrateType) -> bool {
+pub fn invalid_output_for_target(sess: &Session, crate_type: config::CrateType) -> bool {
     match crate_type {
-        config::CrateType::Cdylib |
-        config::CrateType::Dylib |
-        config::CrateType::ProcMacro => {
+        config::CrateType::Cdylib | config::CrateType::Dylib | config::CrateType::ProcMacro => {
             if !sess.target.target.options.dynamic_linking {
-                return true
+                return true;
             }
             if sess.crt_static() && !sess.target.target.options.crt_static_allows_dylibs {
-                return true
+                return true;
             }
         }
         _ => {}
@@ -177,7 +181,7 @@ pub fn invalid_output_for_target(sess: &Session,
     }
     if !sess.target.target.options.executables {
         if crate_type == config::CrateType::Executable {
-            return true
+            return true;
         }
     }
 
diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs
index 922964ee45f..bd714f5c6b7 100644
--- a/src/librustc_codegen_utils/symbol_names.rs
+++ b/src/librustc_codegen_utils/symbol_names.rs
@@ -88,12 +88,12 @@
 //! DefPaths which are much more robust in the face of changes to the code base.
 
 use rustc::hir::def_id::LOCAL_CRATE;
-use rustc::hir::Node;
 use rustc::hir::CodegenFnAttrFlags;
+use rustc::hir::Node;
+use rustc::mir::mono::{InstantiationMode, MonoItem};
 use rustc::session::config::SymbolManglingVersion;
 use rustc::ty::query::Providers;
-use rustc::ty::{self, TyCtxt, Instance};
-use rustc::mir::mono::{MonoItem, InstantiationMode};
+use rustc::ty::{self, Instance, TyCtxt};
 
 use syntax_pos::symbol::Symbol;
 
@@ -104,9 +104,7 @@ mod v0;
 
 pub fn provide(providers: &mut Providers<'_>) {
     *providers = Providers {
-        symbol_name: |tcx, instance| ty::SymbolName {
-            name: symbol_name(tcx, instance),
-        },
+        symbol_name: |tcx, instance| ty::SymbolName { name: symbol_name(tcx, instance) },
 
         ..*providers
     };
@@ -160,8 +158,8 @@ fn symbol_name(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Symbol {
     //
     // [1]: https://bugs.llvm.org/show_bug.cgi?id=44316
     if is_foreign {
-        if tcx.sess.target.target.arch != "wasm32" ||
-            !tcx.wasm_import_module_map(def_id.krate).contains_key(&def_id)
+        if tcx.sess.target.target.arch != "wasm32"
+            || !tcx.wasm_import_module_map(def_id.krate).contains_key(&def_id)
         {
             if let Some(name) = attrs.link_name {
                 return name;
diff --git a/src/librustc_codegen_utils/symbol_names/legacy.rs b/src/librustc_codegen_utils/symbol_names/legacy.rs
index 1597f98771c..29869a1dae4 100644
--- a/src/librustc_codegen_utils/symbol_names/legacy.rs
+++ b/src/librustc_codegen_utils/symbol_names/legacy.rs
@@ -2,9 +2,9 @@ use rustc::hir::def_id::CrateNum;
 use rustc::hir::map::{DefPathData, DisambiguatedDefPathData};
 use rustc::ich::NodeIdHashingMode;
 use rustc::mir::interpret::{ConstValue, Scalar};
-use rustc::ty::print::{PrettyPrinter, Printer, Print};
+use rustc::ty::print::{PrettyPrinter, Print, Printer};
 use rustc::ty::subst::{GenericArg, GenericArgKind};
-use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, Instance};
+use rustc::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
 use rustc::util::common::record_time;
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 
@@ -55,11 +55,9 @@ pub(super) fn mangle(
 
     let hash = get_symbol_hash(tcx, instance, instance_ty, instantiating_crate);
 
-    let mut printer = SymbolPrinter {
-        tcx,
-        path: SymbolPath::new(),
-        keep_within_component: false,
-    }.print_def_path(def_id, &[]).unwrap();
+    let mut printer = SymbolPrinter { tcx, path: SymbolPath::new(), keep_within_component: false }
+        .print_def_path(def_id, &[])
+        .unwrap();
 
     if instance.is_vtable_shim() {
         let _ = printer.write_str("{{vtable-shim}}");
@@ -84,10 +82,7 @@ fn get_symbol_hash<'tcx>(
 ) -> u64 {
     let def_id = instance.def_id();
     let substs = instance.substs;
-    debug!(
-        "get_symbol_hash(def_id={:?}, parameters={:?})",
-        def_id, substs
-    );
+    debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs);
 
     let mut hasher = StableHasher::new();
     let mut hcx = tcx.create_stable_hashing_context();
@@ -121,10 +116,10 @@ fn get_symbol_hash<'tcx>(
         substs.hash_stable(&mut hcx, &mut hasher);
 
         if let Some(instantiating_crate) = instantiating_crate {
-            tcx.original_crate_name(instantiating_crate).as_str()
-                .hash_stable(&mut hcx, &mut hasher);
-            tcx.crate_disambiguator(instantiating_crate)
+            tcx.original_crate_name(instantiating_crate)
+                .as_str()
                 .hash_stable(&mut hcx, &mut hasher);
+            tcx.crate_disambiguator(instantiating_crate).hash_stable(&mut hcx, &mut hasher);
         }
 
         // We want to avoid accidental collision between different types of instances.
@@ -157,10 +152,8 @@ struct SymbolPath {
 
 impl SymbolPath {
     fn new() -> Self {
-        let mut result = SymbolPath {
-            result: String::with_capacity(64),
-            temp_buf: String::with_capacity(16),
-        };
+        let mut result =
+            SymbolPath { result: String::with_capacity(64), temp_buf: String::with_capacity(16) };
         result.result.push_str("_ZN"); // _Z == Begin name-sequence, N == nested
         result
     }
@@ -208,27 +201,19 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
         self.tcx
     }
 
-    fn print_region(
-        self,
-        _region: ty::Region<'_>,
-    ) -> Result<Self::Region, Self::Error> {
+    fn print_region(self, _region: ty::Region<'_>) -> Result<Self::Region, Self::Error> {
         Ok(self)
     }
 
-    fn print_type(
-        self,
-        ty: Ty<'tcx>,
-    ) -> Result<Self::Type, Self::Error> {
+    fn print_type(self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
         match ty.kind {
             // Print all nominal types as paths (unlike `pretty_print_type`).
-            ty::FnDef(def_id, substs) |
-            ty::Opaque(def_id, substs) |
-            ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs }) |
-            ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs }) |
-            ty::Closure(def_id, substs) |
-            ty::Generator(def_id, substs, _) => {
-                self.print_def_path(def_id, substs)
-            }
+            ty::FnDef(def_id, substs)
+            | ty::Opaque(def_id, substs)
+            | ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs })
+            | ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs })
+            | ty::Closure(def_id, substs)
+            | ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
             _ => self.pretty_print_type(ty),
         }
     }
@@ -248,10 +233,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
         Ok(self)
     }
 
-    fn print_const(
-        mut self,
-        ct: &'tcx ty::Const<'tcx>,
-    ) -> Result<Self::Const, Self::Error> {
+    fn print_const(mut self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
         // only print integers
         if let ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { .. })) = ct.val {
             if ct.ty.is_integral() {
@@ -262,10 +244,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
         Ok(self)
     }
 
-    fn path_crate(
-        mut self,
-        cnum: CrateNum,
-    ) -> Result<Self::Path, Self::Error> {
+    fn path_crate(mut self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
         self.write_str(&self.tcx.original_crate_name(cnum).as_str())?;
         Ok(self)
     }
@@ -277,18 +256,18 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
         // Similar to `pretty_path_qualified`, but for the other
         // types that are printed as paths (see `print_type` above).
         match self_ty.kind {
-            ty::FnDef(..) |
-            ty::Opaque(..) |
-            ty::Projection(_) |
-            ty::UnnormalizedProjection(_) |
-            ty::Closure(..) |
-            ty::Generator(..)
+            ty::FnDef(..)
+            | ty::Opaque(..)
+            | ty::Projection(_)
+            | ty::UnnormalizedProjection(_)
+            | ty::Closure(..)
+            | ty::Generator(..)
                 if trait_ref.is_none() =>
             {
                 self.print_type(self_ty)
             }
 
-            _ => self.pretty_path_qualified(self_ty, trait_ref)
+            _ => self.pretty_path_qualified(self_ty, trait_ref),
         }
     }
 
@@ -343,14 +322,12 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
         mut self,
         print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
         args: &[GenericArg<'tcx>],
-    )  -> Result<Self::Path, Self::Error> {
+    ) -> Result<Self::Path, Self::Error> {
         self = print_prefix(self)?;
 
-        let args = args.iter().cloned().filter(|arg| {
-            match arg.unpack() {
-                GenericArgKind::Lifetime(_) => false,
-                _ => true,
-            }
+        let args = args.iter().cloned().filter(|arg| match arg.unpack() {
+            GenericArgKind::Lifetime(_) => false,
+            _ => true,
         });
 
         if args.clone().next().is_some() {
@@ -362,10 +339,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
 }
 
 impl PrettyPrinter<'tcx> for SymbolPrinter<'tcx> {
-    fn region_should_not_be_omitted(
-        &self,
-        _region: ty::Region<'_>,
-    ) -> bool {
+    fn region_should_not_be_omitted(&self, _region: ty::Region<'_>) -> bool {
         false
     }
     fn comma_sep<T>(mut self, mut elems: impl Iterator<Item = T>) -> Result<Self, Self::Error>
@@ -388,8 +362,7 @@ impl PrettyPrinter<'tcx> for SymbolPrinter<'tcx> {
     ) -> Result<Self, Self::Error> {
         write!(self, "<")?;
 
-        let kept_within_component =
-            mem::replace(&mut self.keep_within_component, true);
+        let kept_within_component = mem::replace(&mut self.keep_within_component, true);
         self = f(self)?;
         self.keep_within_component = kept_within_component;
 
diff --git a/src/librustc_codegen_utils/symbol_names_test.rs b/src/librustc_codegen_utils/symbol_names_test.rs
index 893aea16fd2..7cb3050576c 100644
--- a/src/librustc_codegen_utils/symbol_names_test.rs
+++ b/src/librustc_codegen_utils/symbol_names_test.rs
@@ -5,8 +5,8 @@
 //! paths etc in all kinds of annoying scenarios.
 
 use rustc::hir;
-use rustc::ty::{TyCtxt, Instance};
-use syntax::symbol::{Symbol, sym};
+use rustc::ty::{Instance, TyCtxt};
+use syntax::symbol::{sym, Symbol};
 
 const SYMBOL_NAME: Symbol = sym::rustc_symbol_name;
 const DEF_PATH: Symbol = sym::rustc_def_path;
@@ -30,8 +30,7 @@ struct SymbolNamesTest<'tcx> {
 }
 
 impl SymbolNamesTest<'tcx> {
-    fn process_attrs(&mut self,
-                     hir_id: hir::HirId) {
+    fn process_attrs(&mut self, hir_id: hir::HirId) {
         let tcx = self.tcx;
         let def_id = tcx.hir().local_def_id(hir_id);
         for attr in tcx.get_attrs(def_id).iter() {