1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![crate_name = "rustc_save_analysis"]
12 #![unstable(feature = "rustc_private", issue = "27812")]
13 #![crate_type = "dylib"]
14 #![crate_type = "rlib"]
15 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
16 html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
17 html_root_url = "https://doc.rust-lang.org/nightly/")]
18 #![cfg_attr(not(stage0), deny(warnings))]
20 #![feature(custom_attribute)]
21 #![cfg_attr(stage0, feature(dotdot_in_tuple_patterns))]
22 #![allow(unused_attributes)]
23 #![feature(rustc_private)]
24 #![feature(staged_api)]
26 #[macro_use] extern crate rustc;
28 #[macro_use] extern crate log;
29 #[macro_use] extern crate syntax;
30 extern crate serialize as rustc_serialize;
31 extern crate syntax_pos;
40 pub mod external_data;
45 use rustc::hir::map::{Node, NodeItem};
46 use rustc::hir::def::Def;
47 use rustc::hir::def_id::DefId;
48 use rustc::session::config::CrateType::CrateTypeExecutable;
49 use rustc::ty::{self, TyCtxt};
52 use std::fs::{self, File};
53 use std::path::{Path, PathBuf};
55 use syntax::ast::{self, NodeId, PatKind, Attribute, CRATE_NODE_ID};
56 use syntax::parse::lexer::comments::strip_doc_comment_decoration;
57 use syntax::parse::token::{self, keywords, InternedString};
58 use syntax::visit::{self, Visitor};
59 use syntax::print::pprust::{ty_to_string, arg_to_string};
60 use syntax::codemap::MacroAttribute;
63 pub use self::csv_dumper::CsvDumper;
64 pub use self::json_api_dumper::JsonApiDumper;
65 pub use self::json_dumper::JsonDumper;
66 pub use self::data::*;
67 pub use self::external_data::make_def_id;
68 pub use self::dump::Dump;
69 pub use self::dump_visitor::DumpVisitor;
70 use self::span_utils::SpanUtils;
72 // FIXME this is legacy code and should be removed
76 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
85 pub struct SaveContext<'l, 'tcx: 'l> {
86 tcx: TyCtxt<'l, 'tcx, 'tcx>,
87 span_utils: SpanUtils<'tcx>,
90 macro_rules! option_try(
91 ($e:expr) => (match $e { Some(e) => e, None => return None })
94 impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
95 pub fn new(tcx: TyCtxt<'l, 'tcx, 'tcx>) -> SaveContext<'l, 'tcx> {
96 let span_utils = SpanUtils::new(&tcx.sess);
97 SaveContext::from_span_utils(tcx, span_utils)
100 pub fn from_span_utils(tcx: TyCtxt<'l, 'tcx, 'tcx>,
101 span_utils: SpanUtils<'tcx>)
102 -> SaveContext<'l, 'tcx> {
105 span_utils: span_utils,
109 // List external crates used by the current crate.
110 pub fn get_external_crates(&self) -> Vec<CrateData> {
111 let mut result = Vec::new();
113 for n in self.tcx.sess.cstore.crates() {
114 let span = match self.tcx.sess.cstore.extern_crate(n) {
115 Some(ref c) => c.span,
117 debug!("Skipping crate {}, no data", n);
121 result.push(CrateData {
122 name: (&self.tcx.sess.cstore.crate_name(n)[..]).to_owned(),
131 pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
133 ast::ItemKind::Fn(ref decl, .., ref generics, _) => {
134 let qualname = format!("::{}", self.tcx.node_path_str(item.id));
135 let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Fn);
136 filter!(self.span_utils, sub_span, item.span, None);
139 Some(Data::FunctionData(FunctionData {
141 name: item.ident.to_string(),
144 span: sub_span.unwrap(),
145 scope: self.enclosing_scope(item.id),
146 value: make_signature(decl, generics),
147 visibility: From::from(&item.vis),
149 docs: docs_for_attrs(&item.attrs),
152 ast::ItemKind::Static(ref typ, mt, ref expr) => {
153 let qualname = format!("::{}", self.tcx.node_path_str(item.id));
155 // If the variable is immutable, save the initialising expression.
156 let (value, keyword) = match mt {
157 ast::Mutability::Mutable => (String::from("<mutable>"), keywords::Mut),
158 ast::Mutability::Immutable => {
159 (self.span_utils.snippet(expr.span), keywords::Static)
163 let sub_span = self.span_utils.sub_span_after_keyword(item.span, keyword);
164 filter!(self.span_utils, sub_span, item.span, None);
165 Some(Data::VariableData(VariableData {
167 kind: VariableKind::Static,
168 name: item.ident.to_string(),
170 span: sub_span.unwrap(),
171 scope: self.enclosing_scope(item.id),
174 type_value: ty_to_string(&typ),
175 visibility: From::from(&item.vis),
176 docs: docs_for_attrs(&item.attrs),
179 ast::ItemKind::Const(ref typ, ref expr) => {
180 let qualname = format!("::{}", self.tcx.node_path_str(item.id));
181 let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Const);
182 filter!(self.span_utils, sub_span, item.span, None);
183 Some(Data::VariableData(VariableData {
185 kind: VariableKind::Const,
186 name: item.ident.to_string(),
188 span: sub_span.unwrap(),
189 scope: self.enclosing_scope(item.id),
191 value: self.span_utils.snippet(expr.span),
192 type_value: ty_to_string(&typ),
193 visibility: From::from(&item.vis),
194 docs: docs_for_attrs(&item.attrs),
197 ast::ItemKind::Mod(ref m) => {
198 let qualname = format!("::{}", self.tcx.node_path_str(item.id));
200 let cm = self.tcx.sess.codemap();
201 let filename = cm.span_to_filename(m.inner);
203 let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Mod);
204 filter!(self.span_utils, sub_span, item.span, None);
205 Some(Data::ModData(ModData {
207 name: item.ident.to_string(),
209 span: sub_span.unwrap(),
210 scope: self.enclosing_scope(item.id),
212 items: m.items.iter().map(|i| i.id).collect(),
213 visibility: From::from(&item.vis),
214 docs: docs_for_attrs(&item.attrs),
217 ast::ItemKind::Enum(ref def, _) => {
218 let name = item.ident.to_string();
219 let qualname = format!("::{}", self.tcx.node_path_str(item.id));
220 let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Enum);
221 filter!(self.span_utils, sub_span, item.span, None);
222 let variants_str = def.variants.iter()
223 .map(|v| v.node.name.to_string())
226 let val = format!("{}::{{{}}}", name, variants_str);
227 Some(Data::EnumData(EnumData {
231 span: sub_span.unwrap(),
233 scope: self.enclosing_scope(item.id),
234 variants: def.variants.iter().map(|v| v.node.data.id()).collect(),
235 visibility: From::from(&item.vis),
236 docs: docs_for_attrs(&item.attrs),
239 ast::ItemKind::Impl(.., ref trait_ref, ref typ, _) => {
240 let mut type_data = None;
243 let parent = self.enclosing_scope(item.id);
246 // Common case impl for a struct or something basic.
247 ast::TyKind::Path(None, ref path) => {
248 sub_span = self.span_utils.sub_span_for_type_name(path.span);
249 filter!(self.span_utils, sub_span, path.span, None);
250 type_data = self.lookup_ref_id(typ.id).map(|id| {
252 span: sub_span.unwrap(),
255 qualname: String::new() // FIXME: generate the real qualname
260 // Less useful case, impl for a compound type.
262 sub_span = self.span_utils.sub_span_for_type_name(span).or(Some(span));
266 let trait_data = trait_ref.as_ref()
267 .and_then(|tr| self.get_trait_ref_data(tr, parent));
269 filter!(self.span_utils, sub_span, typ.span, None);
270 Some(Data::ImplData(ImplData2 {
272 span: sub_span.unwrap(),
274 trait_ref: trait_data,
285 pub fn get_field_data(&self, field: &ast::StructField,
286 scope: NodeId) -> Option<VariableData> {
287 if let Some(ident) = field.ident {
288 let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident);
289 let def_id = self.tcx.map.local_def_id(field.id);
290 let typ = self.tcx.item_type(def_id).to_string();
291 let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
292 filter!(self.span_utils, sub_span, field.span, None);
295 kind: VariableKind::Field,
296 name: ident.to_string(),
298 span: sub_span.unwrap(),
300 parent: Some(make_def_id(scope, &self.tcx.map)),
301 value: "".to_owned(),
303 visibility: From::from(&field.vis),
304 docs: docs_for_attrs(&field.attrs),
311 // FIXME would be nice to take a MethodItem here, but the ast provides both
312 // trait and impl flavours, so the caller must do the disassembly.
313 pub fn get_method_data(&self, id: ast::NodeId,
314 name: ast::Name, span: Span) -> Option<FunctionData> {
315 // The qualname for a method is the trait name or name of the struct in an impl in
316 // which the method is declared in, followed by the method's name.
317 let (qualname, parent_scope, decl_id, vis, docs) =
318 match self.tcx.impl_of_method(self.tcx.map.local_def_id(id)) {
319 Some(impl_id) => match self.tcx.map.get_if_local(impl_id) {
320 Some(NodeItem(item)) => {
322 hir::ItemImpl(.., ref ty, _) => {
323 let mut result = String::from("<");
324 result.push_str(&rustc::hir::print::ty_to_string(&ty));
326 let trait_id = self.tcx.trait_id_of_impl(impl_id);
327 let mut decl_id = None;
328 if let Some(def_id) = trait_id {
329 result.push_str(" as ");
330 result.push_str(&self.tcx.item_path_str(def_id));
331 self.tcx.associated_items(def_id)
332 .find(|item| item.name == name)
333 .map(|item| decl_id = Some(item.def_id));
335 result.push_str(">");
337 (result, trait_id, decl_id,
338 From::from(&item.vis),
339 docs_for_attrs(&item.attrs))
343 "Container {:?} for method {} not an impl?",
351 "Container {:?} for method {} is not a node item {:?}",
357 None => match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) {
359 match self.tcx.map.get_if_local(def_id) {
360 Some(NodeItem(item)) => {
361 (format!("::{}", self.tcx.item_path_str(def_id)),
363 From::from(&item.vis),
364 docs_for_attrs(&item.attrs))
368 "Could not find container {:?} for \
369 method {}, got {:?}",
377 span_bug!(span, "Could not find container for method {}", id);
382 let qualname = format!("{}::{}", qualname, name);
384 let sub_span = self.span_utils.sub_span_after_keyword(span, keywords::Fn);
385 filter!(self.span_utils, sub_span, span, None);
388 name: name.to_string(),
390 declaration: decl_id,
391 span: sub_span.unwrap(),
392 scope: self.enclosing_scope(id),
393 // FIXME you get better data here by using the visitor.
394 value: String::new(),
396 parent: parent_scope,
401 pub fn get_trait_ref_data(&self,
402 trait_ref: &ast::TraitRef,
404 -> Option<TypeRefData> {
405 self.lookup_ref_id(trait_ref.ref_id).and_then(|def_id| {
406 let span = trait_ref.path.span;
407 let sub_span = self.span_utils.sub_span_for_type_name(span).or(Some(span));
408 filter!(self.span_utils, sub_span, span, None);
410 span: sub_span.unwrap(),
412 ref_id: Some(def_id),
413 qualname: String::new() // FIXME: generate the real qualname
418 pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
419 let hir_node = self.tcx.map.expect_expr(expr.id);
420 let ty = self.tcx.tables().expr_ty_adjusted_opt(&hir_node);
421 if ty.is_none() || ty.unwrap().sty == ty::TyError {
425 ast::ExprKind::Field(ref sub_ex, ident) => {
426 let hir_node = match self.tcx.map.find(sub_ex.id) {
427 Some(Node::NodeExpr(expr)) => expr,
429 debug!("Missing or weird node for sub-expression {} in {:?}",
434 match self.tcx.tables().expr_ty_adjusted(&hir_node).sty {
435 ty::TyAdt(def, _) if !def.is_enum() => {
436 let f = def.struct_variant().field_named(ident.node.name);
437 let sub_span = self.span_utils.span_for_last_ident(expr.span);
438 filter!(self.span_utils, sub_span, expr.span, None);
439 return Some(Data::VariableRefData(VariableRefData {
440 name: ident.node.to_string(),
441 span: sub_span.unwrap(),
442 scope: self.enclosing_scope(expr.id),
447 debug!("Expected struct or union type, found {:?}", ty);
452 ast::ExprKind::Struct(ref path, ..) => {
453 match self.tcx.tables().expr_ty_adjusted(&hir_node).sty {
454 ty::TyAdt(def, _) if !def.is_enum() => {
455 let sub_span = self.span_utils.span_for_last_ident(path.span);
456 filter!(self.span_utils, sub_span, path.span, None);
457 Some(Data::TypeRefData(TypeRefData {
458 span: sub_span.unwrap(),
459 scope: self.enclosing_scope(expr.id),
460 ref_id: Some(def.did),
461 qualname: String::new() // FIXME: generate the real qualname
465 // FIXME ty could legitimately be an enum, but then we will fail
466 // later if we try to look up the fields.
467 debug!("expected struct or union, found {:?}", ty);
472 ast::ExprKind::MethodCall(..) => {
473 let method_call = ty::MethodCall::expr(expr.id);
474 let method_id = self.tcx.tables().method_map[&method_call].def_id;
475 let (def_id, decl_id) = match self.tcx.associated_item(method_id).container {
476 ty::ImplContainer(_) => (Some(method_id), None),
477 ty::TraitContainer(_) => (None, Some(method_id)),
479 let sub_span = self.span_utils.sub_span_for_meth_name(expr.span);
480 filter!(self.span_utils, sub_span, expr.span, None);
481 let parent = self.enclosing_scope(expr.id);
482 Some(Data::MethodCallData(MethodCallData {
483 span: sub_span.unwrap(),
489 ast::ExprKind::Path(_, ref path) => {
490 self.get_path_data(expr.id, path)
499 pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Data> {
500 let def = option_try!(self.tcx.expect_resolution(id).maybe_full_def());
501 let sub_span = self.span_utils.span_for_last_ident(path.span);
502 filter!(self.span_utils, sub_span, path.span, None);
508 Def::AssociatedConst(..) |
509 Def::StructCtor(..) |
510 Def::VariantCtor(..) => {
511 Some(Data::VariableRefData(VariableRefData {
512 name: self.span_utils.snippet(sub_span.unwrap()),
513 span: sub_span.unwrap(),
514 scope: self.enclosing_scope(id),
515 ref_id: def.def_id(),
518 Def::Struct(def_id) |
519 Def::Variant(def_id, ..) |
522 Def::TyAlias(def_id) |
523 Def::AssociatedTy(def_id) |
525 Def::TyParam(def_id) => {
526 Some(Data::TypeRefData(TypeRefData {
527 span: sub_span.unwrap(),
528 ref_id: Some(def_id),
529 scope: self.enclosing_scope(id),
530 qualname: String::new() // FIXME: generate the real qualname
533 Def::Method(decl_id) => {
534 let sub_span = self.span_utils.sub_span_for_meth_name(path.span);
535 filter!(self.span_utils, sub_span, path.span, None);
536 let def_id = if decl_id.is_local() {
537 let ti = self.tcx.associated_item(decl_id);
538 self.tcx.associated_items(ti.container.id())
539 .find(|item| item.name == ti.name && item.defaultness.has_value())
540 .map(|item| item.def_id)
544 Some(Data::MethodCallData(MethodCallData {
545 span: sub_span.unwrap(),
546 scope: self.enclosing_scope(id),
548 decl_id: Some(decl_id),
552 Some(Data::FunctionCallData(FunctionCallData {
554 span: sub_span.unwrap(),
555 scope: self.enclosing_scope(id),
558 Def::Mod(def_id) => {
559 Some(Data::ModRefData(ModRefData {
560 ref_id: Some(def_id),
561 span: sub_span.unwrap(),
562 scope: self.enclosing_scope(id),
563 qualname: String::new() // FIXME: generate the real qualname
574 pub fn get_field_ref_data(&self,
575 field_ref: &ast::Field,
576 variant: ty::VariantDef,
578 -> Option<VariableRefData> {
579 let f = variant.field_named(field_ref.ident.node.name);
580 // We don't really need a sub-span here, but no harm done
581 let sub_span = self.span_utils.span_for_last_ident(field_ref.ident.span);
582 filter!(self.span_utils, sub_span, field_ref.ident.span, None);
583 Some(VariableRefData {
584 name: field_ref.ident.node.to_string(),
585 span: sub_span.unwrap(),
591 /// Attempt to return MacroUseData for any AST node.
593 /// For a given piece of AST defined by the supplied Span and NodeId,
594 /// returns None if the node is not macro-generated or the span is malformed,
595 /// else uses the expansion callsite and callee to return some MacroUseData.
596 pub fn get_macro_use_data(&self, span: Span, id: NodeId) -> Option<MacroUseData> {
597 if !generated_code(span) {
600 // Note we take care to use the source callsite/callee, to handle
601 // nested expansions and ensure we only generate data for source-visible
603 let callsite = self.tcx.sess.codemap().source_callsite(span);
604 let callee = self.tcx.sess.codemap().source_callee(span);
605 let callee = option_try!(callee);
606 let callee_span = option_try!(callee.span);
608 // Ignore attribute macros, their spans are usually mangled
609 if let MacroAttribute(_) = callee.format {
613 // If the callee is an imported macro from an external crate, need to get
614 // the source span and name from the session, as their spans are localized
615 // when read in, and no longer correspond to the source.
616 if let Some(mac) = self.tcx.sess.imported_macro_spans.borrow().get(&callee_span) {
617 let &(ref mac_name, mac_span) = mac;
618 return Some(MacroUseData {
620 name: mac_name.clone(),
621 callee_span: mac_span,
622 scope: self.enclosing_scope(id),
624 qualname: String::new()// FIXME: generate the real qualname
630 name: callee.name().to_string(),
631 callee_span: callee_span,
632 scope: self.enclosing_scope(id),
634 qualname: String::new() // FIXME: generate the real qualname
638 pub fn get_data_for_id(&self, _id: &NodeId) -> Data {
643 fn lookup_ref_id(&self, ref_id: NodeId) -> Option<DefId> {
644 match self.tcx.expect_def(ref_id) {
645 Def::PrimTy(_) | Def::SelfTy(..) => None,
646 def => Some(def.def_id()),
651 pub fn enclosing_scope(&self, id: NodeId) -> NodeId {
652 self.tcx.map.get_enclosing_scope(id).unwrap_or(CRATE_NODE_ID)
656 fn make_signature(decl: &ast::FnDecl, generics: &ast::Generics) -> String {
657 let mut sig = "fn ".to_owned();
658 if !generics.lifetimes.is_empty() || !generics.ty_params.is_empty() {
660 sig.push_str(&generics.lifetimes.iter()
661 .map(|l| l.lifetime.name.to_string())
664 if !generics.lifetimes.is_empty() {
667 sig.push_str(&generics.ty_params.iter()
668 .map(|l| l.ident.to_string())
674 sig.push_str(&decl.inputs.iter().map(arg_to_string).collect::<Vec<_>>().join(", "));
677 ast::FunctionRetTy::Default(_) => sig.push_str(" -> ()"),
678 ast::FunctionRetTy::Ty(ref t) => sig.push_str(&format!(" -> {}", ty_to_string(t))),
684 // An AST visitor for collecting paths from patterns.
685 struct PathCollector {
686 // The Row field identifies the kind of pattern.
687 collected_paths: Vec<(NodeId, ast::Path, ast::Mutability, recorder::Row)>,
691 fn new() -> PathCollector {
692 PathCollector { collected_paths: vec![] }
696 impl Visitor for PathCollector {
697 fn visit_pat(&mut self, p: &ast::Pat) {
699 PatKind::Struct(ref path, ..) => {
700 self.collected_paths.push((p.id, path.clone(),
701 ast::Mutability::Mutable, recorder::TypeRef));
703 PatKind::TupleStruct(ref path, ..) |
704 PatKind::Path(_, ref path) => {
705 self.collected_paths.push((p.id, path.clone(),
706 ast::Mutability::Mutable, recorder::VarRef));
708 PatKind::Ident(bm, ref path1, _) => {
709 debug!("PathCollector, visit ident in pat {}: {:?} {:?}",
713 let immut = match bm {
714 // Even if the ref is mut, you can't change the ref, only
715 // the data pointed at, so showing the initialising expression
716 // is still worthwhile.
717 ast::BindingMode::ByRef(_) => ast::Mutability::Immutable,
718 ast::BindingMode::ByValue(mt) => mt,
720 // collect path for either visit_local or visit_arm
721 let path = ast::Path::from_ident(path1.span, path1.node);
722 self.collected_paths.push((p.id, path, immut, recorder::VarRef));
726 visit::walk_pat(self, p);
730 fn docs_for_attrs(attrs: &[Attribute]) -> String {
731 let doc = InternedString::new("doc");
732 let mut result = String::new();
735 if attr.name() == doc {
736 if let Some(ref val) = attr.value_str() {
737 if attr.node.is_sugared_doc {
738 result.push_str(&strip_doc_comment_decoration(val));
740 result.push_str(val);
750 #[derive(Clone, Copy, Debug, RustcEncodable)]
758 fn extension(&self) -> &'static str {
760 Format::Csv => ".csv",
761 Format::Json | Format::JsonApi => ".json",
766 pub fn process_crate<'l, 'tcx>(tcx: TyCtxt<'l, 'tcx, 'tcx>,
768 analysis: &'l ty::CrateAnalysis<'l>,
772 let _ignore = tcx.dep_graph.in_ignore();
774 assert!(analysis.glob_map.is_some());
776 info!("Dumping crate {}", cratename);
778 // find a path to dump our data to
779 let mut root_path = match env::var_os("RUST_SAVE_ANALYSIS_FOLDER") {
780 Some(val) => PathBuf::from(val),
782 Some(val) => val.join("save-analysis"),
783 None => PathBuf::from("save-analysis-temp"),
787 if let Err(e) = fs::create_dir_all(&root_path) {
788 tcx.sess.err(&format!("Could not create directory {}: {}",
794 let disp = root_path.display();
795 info!("Writing output to {}", disp);
798 // Create output file.
799 let executable = tcx.sess.crate_types.borrow().iter().any(|ct| *ct == CrateTypeExecutable);
800 let mut out_name = if executable {
805 out_name.push_str(&cratename);
806 out_name.push_str(&tcx.sess.opts.cg.extra_filename);
807 out_name.push_str(format.extension());
808 root_path.push(&out_name);
809 let mut output_file = File::create(&root_path).unwrap_or_else(|e| {
810 let disp = root_path.display();
811 tcx.sess.fatal(&format!("Could not open {}: {}", disp, e));
814 let output = &mut output_file;
816 let save_ctxt = SaveContext::new(tcx);
819 ($new_dumper: expr) => {{
820 let mut dumper = $new_dumper;
821 let mut visitor = DumpVisitor::new(tcx, save_ctxt, analysis, &mut dumper);
823 visitor.dump_crate_info(cratename, krate);
824 visit::walk_crate(&mut visitor, krate);
829 Format::Csv => dump!(CsvDumper::new(output)),
830 Format::Json => dump!(JsonDumper::new(output)),
831 Format::JsonApi => dump!(JsonApiDumper::new(output)),
835 // Utility functions for the module.
837 // Helper function to escape quotes in a string
838 fn escape(s: String) -> String {
839 s.replace("\"", "\"\"")
842 // Helper function to determine if a span came from a
843 // macro expansion or syntax extension.
844 pub fn generated_code(span: Span) -> bool {
845 span.expn_id != NO_EXPANSION || span == DUMMY_SP