Auto merge of #79586 - jyn514:crate-name, r=davidtwco

Fix `unknown-crate` when using -Z self-profile with rustdoc

... by removing a duplicate `crate_name` field in `interface::Config`,
making it clear that rustdoc should be passing it to `config::Options` instead.

Unblocks https://github.com/rust-lang/rustc-perf/issues/797.
This commit is contained in:
bors 2020-12-03 12:14:29 +00:00
commit 220352781c
7 changed files with 8 additions and 16 deletions

View file

@ -34,7 +34,6 @@ pub struct Compiler {
pub(crate) input_path: Option<PathBuf>,
pub(crate) output_dir: Option<PathBuf>,
pub(crate) output_file: Option<PathBuf>,
pub(crate) crate_name: Option<String>,
pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>>,
pub(crate) override_queries:
Option<fn(&Session, &mut ty::query::Providers, &mut ty::query::Providers)>,
@ -140,7 +139,6 @@ pub struct Config {
/// Set to capture stderr output during compiler execution
pub stderr: Option<Arc<Mutex<Vec<u8>>>>,
pub crate_name: Option<String>,
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,
/// This is a callback from the driver that is called when we're registering lints;
@ -185,7 +183,6 @@ pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R
input_path: config.input_path,
output_dir: config.output_dir,
output_file: config.output_file,
crate_name: config.crate_name,
register_lints: config.register_lints,
override_queries: config.override_queries,
};

View file

@ -156,13 +156,11 @@ impl<'tcx> Queries<'tcx> {
pub fn crate_name(&self) -> Result<&Query<String>> {
self.crate_name.compute(|| {
Ok(match self.compiler.crate_name {
Some(ref crate_name) => crate_name.clone(),
None => {
let parse_result = self.parse()?;
let krate = parse_result.peek();
find_crate_name(self.session(), &krate.attrs, &self.compiler.input)
}
Ok({
let parse_result = self.parse()?;
let krate = parse_result.peek();
// parse `#[crate_name]` even if `--crate-name` was passed, to make sure it matches.
find_crate_name(self.session(), &krate.attrs, &self.compiler.input)
})
})
}