Skip to content

Commit

Permalink
Don't reallocate the crate name when running doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Jun 21, 2021
1 parent 1c557da commit ff0e046
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/librustdoc/doctest.rs
Expand Up @@ -3,8 +3,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc;
use rustc_errors::{ColorConfig, ErrorReported};
use rustc_hir as hir;
use rustc_hir::intravisit;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::intravisit;
use rustc_hir::{HirId, CRATE_HIR_ID};
use rustc_interface::interface;
use rustc_middle::hir::map::Map;
Expand All @@ -14,6 +14,7 @@ use rustc_session::{lint, DiagnosticOutput, Session};
use rustc_span::edition::Edition;
use rustc_span::source_map::SourceMap;
use rustc_span::symbol::sym;
use rustc_span::Symbol;
use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP};
use rustc_target::spec::TargetTriple;
use tempfile::Builder as TempFileBuilder;
Expand Down Expand Up @@ -122,7 +123,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
opts.display_warnings |= options.display_warnings;
let enable_per_target_ignores = options.enable_per_target_ignores;
let mut collector = Collector::new(
tcx.crate_name(LOCAL_CRATE).to_string(),
tcx.crate_name(LOCAL_CRATE),
options,
false,
opts,
Expand Down Expand Up @@ -796,7 +797,7 @@ crate struct Collector {
options: Options,
use_headers: bool,
enable_per_target_ignores: bool,
crate_name: String,
crate_name: Symbol,
opts: TestOptions,
position: Span,
source_map: Option<Lrc<SourceMap>>,
Expand All @@ -808,7 +809,7 @@ crate struct Collector {

impl Collector {
crate fn new(
crate_name: String,
crate_name: Symbol,
options: Options,
use_headers: bool,
opts: TestOptions,
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/markdown.rs
Expand Up @@ -4,6 +4,7 @@ use std::path::Path;

use rustc_span::edition::Edition;
use rustc_span::source_map::DUMMY_SP;
use rustc_span::Symbol;

use crate::config::{Options, RenderOptions};
use crate::doctest::{Collector, TestOptions};
Expand Down Expand Up @@ -121,7 +122,7 @@ crate fn test(mut options: Options) -> Result<(), String> {
opts.no_crate_inject = true;
opts.display_warnings = options.display_warnings;
let mut collector = Collector::new(
options.input.display().to_string(),
Symbol::intern(&options.input.display().to_string()),
options.clone(),
true,
opts,
Expand Down

0 comments on commit ff0e046

Please sign in to comment.