X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_incremental%2Fassert_module_sources.rs;h=70abb38278add67993682d6cc83e02aafe863a7a;hb=bbd210e6c57b23853889dddbdb1564c61a0249f7;hp=1a675ea002cda1cabc93a833bcf8046319ea5c61;hpb=9d1baaf11d0469b23763b9bd878296e5728f1c26;p=rust.git diff --git a/src/librustc_incremental/assert_module_sources.rs b/src/librustc_incremental/assert_module_sources.rs index 1a675ea002c..70abb38278a 100644 --- a/src/librustc_incremental/assert_module_sources.rs +++ b/src/librustc_incremental/assert_module_sources.rs @@ -21,13 +21,13 @@ //! allows for doing a more fine-grained check to see if pre- or post-lto data //! was re-used. -use rustc::hir::def_id::LOCAL_CRATE; -use rustc_session::cgu_reuse_tracker::*; use rustc::mir::mono::CodegenUnitNameBuilder; use rustc::ty::TyCtxt; +use rustc_hir::def_id::LOCAL_CRATE; +use rustc_session::cgu_reuse_tracker::*; +use rustc_span::symbol::{sym, Symbol}; use std::collections::BTreeSet; use syntax::ast; -use syntax::symbol::{Symbol, sym}; pub fn assert_module_sources(tcx: TyCtxt<'_>) { tcx.dep_graph.with_ignore(|| { @@ -42,12 +42,9 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) { .map(|cgu| cgu.name()) .collect::>(); - let ams = AssertModuleSource { - tcx, - available_cgus - }; + let ams = AssertModuleSource { tcx, available_cgus }; - for attr in &tcx.hir().krate().attrs { + for attr in tcx.hir().krate().attrs { ams.check_attr(attr); } }) @@ -73,7 +70,8 @@ fn check_attr(&self, attr: &ast::Attribute) { other => { self.tcx.sess.span_fatal( attr.span, - &format!("unknown cgu-reuse-kind `{}` specified", other)); + &format!("unknown cgu-reuse-kind `{}` specified", other), + ); } } } else { @@ -83,8 +81,11 @@ fn check_attr(&self, attr: &ast::Attribute) { if !self.tcx.sess.opts.debugging_opts.query_dep_graph { self.tcx.sess.span_fatal( attr.span, - &format!("found CGU-reuse attribute but `-Zquery-dep-graph` \ - was not specified")); + &format!( + "found CGU-reuse attribute but `-Zquery-dep-graph` \ + was not specified" + ), + ); } if !self.check_config(attr) { @@ -96,15 +97,18 @@ fn check_attr(&self, attr: &ast::Attribute) { let crate_name = self.tcx.crate_name(LOCAL_CRATE).to_string(); if !user_path.starts_with(&crate_name) { - let msg = format!("Found malformed codegen unit name `{}`. \ + let msg = format!( + "Found malformed codegen unit name `{}`. \ Codegen units names must always start with the name of the \ - crate (`{}` in this case).", user_path, crate_name); + crate (`{}` in this case).", + user_path, crate_name + ); self.tcx.sess.span_fatal(attr.span, &msg); } // Split of the "special suffix" if there is one. let (user_path, cgu_special_suffix) = if let Some(index) = user_path.rfind(".") { - (&user_path[..index], Some(&user_path[index + 1 ..])) + (&user_path[..index], Some(&user_path[index + 1..])) } else { (&user_path[..], None) }; @@ -115,15 +119,16 @@ fn check_attr(&self, attr: &ast::Attribute) { assert_eq!(cgu_path_components.remove(0), crate_name); let cgu_name_builder = &mut CodegenUnitNameBuilder::new(self.tcx); - let cgu_name = cgu_name_builder.build_cgu_name(LOCAL_CRATE, - cgu_path_components, - cgu_special_suffix); + let cgu_name = + cgu_name_builder.build_cgu_name(LOCAL_CRATE, cgu_path_components, cgu_special_suffix); debug!("mapping '{}' to cgu name '{}'", self.field(attr, sym::module), cgu_name); if !self.available_cgus.contains(&cgu_name) { - self.tcx.sess.span_err(attr.span, - &format!("no module named `{}` (mangled: {}). \ + self.tcx.sess.span_err( + attr.span, + &format!( + "no module named `{}` (mangled: {}). \ Available modules: {}", user_path, cgu_name, @@ -131,14 +136,18 @@ fn check_attr(&self, attr: &ast::Attribute) { .iter() .map(|cgu| cgu.to_string()) .collect::>() - .join(", "))); + .join(", ") + ), + ); } - self.tcx.sess.cgu_reuse_tracker.set_expectation(&cgu_name.as_str(), - &user_path, - attr.span, - expected_reuse, - comp_kind); + self.tcx.sess.cgu_reuse_tracker.set_expectation( + &cgu_name.as_str(), + &user_path, + attr.span, + expected_reuse, + comp_kind, + ); } fn field(&self, attr: &ast::Attribute, name: Symbol) -> ast::Name { @@ -149,14 +158,13 @@ fn field(&self, attr: &ast::Attribute, name: Symbol) -> ast::Name { } else { self.tcx.sess.span_fatal( item.span(), - &format!("associated value expected for `{}`", name)); + &format!("associated value expected for `{}`", name), + ); } } } - self.tcx.sess.span_fatal( - attr.span, - &format!("no field `{}`", name)); + self.tcx.sess.span_fatal(attr.span, &format!("no field `{}`", name)); } /// Scan for a `cfg="foo"` attribute and check whether we have a