Skip to content

Commit

Permalink
Auto merge of rust-lang#79586 - jyn514:crate-name, r=davidtwco
Browse files Browse the repository at this point in the history
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 rust-lang/rustc-perf#797.
  • Loading branch information
bors committed Dec 3, 2020
2 parents d015f0d + 878cfb5 commit 2203527
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 16 deletions.
2 changes: 0 additions & 2 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ fn run_compiler(
file_loader: None,
diagnostic_output,
stderr: None,
crate_name: None,
lint_caps: Default::default(),
register_lints: None,
override_queries: None,
Expand Down Expand Up @@ -307,7 +306,6 @@ fn run_compiler(
file_loader,
diagnostic_output,
stderr: None,
crate_name: None,
lint_caps: Default::default(),
register_lints: None,
override_queries: None,
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_interface/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
Expand Down
12 changes: 5 additions & 7 deletions compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ pub fn build_session(

let profiler = SelfProfiler::new(
directory,
sopts.crate_name.as_ref().map(|s| &s[..]),
sopts.crate_name.as_deref(),
&sopts.debugging_opts.self_profile_events,
);
match profiler {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ crate fn run_core(
error_format,
edition,
describe_lints,
crate_name,
..Options::default()
};

Expand All @@ -384,7 +385,6 @@ crate fn run_core(
file_loader: None,
diagnostic_output: DiagnosticOutput::Default,
stderr: None,
crate_name,
lint_caps,
register_lints: None,
override_queries: Some(|_sess, providers, _external_providers| {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
debugging_opts: config::DebuggingOptions { ..config::basic_debugging_options() },
edition: options.edition,
target_triple: options.target.clone(),
crate_name: options.crate_name.clone(),
..config::Options::default()
};

Expand All @@ -90,7 +91,6 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
file_loader: None,
diagnostic_output: DiagnosticOutput::Default,
stderr: None,
crate_name: options.crate_name.clone(),
lint_caps,
register_lints: None,
override_queries: None,
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/issue-19371/foo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
file_loader: None,
diagnostic_output: DiagnosticOutput::Default,
stderr: None,
crate_name: None,
lint_caps: Default::default(),
register_lints: None,
override_queries: None,
Expand Down

0 comments on commit 2203527

Please sign in to comment.