summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_save_analysis
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_save_analysis')
-rw-r--r--compiler/rustc_save_analysis/src/dump_visitor.rs24
-rw-r--r--compiler/rustc_save_analysis/src/lib.rs18
-rw-r--r--compiler/rustc_save_analysis/src/sig.rs10
3 files changed, 27 insertions, 25 deletions
diff --git a/compiler/rustc_save_analysis/src/dump_visitor.rs b/compiler/rustc_save_analysis/src/dump_visitor.rs
index df5d992f6..9ae07cb00 100644
--- a/compiler/rustc_save_analysis/src/dump_visitor.rs
+++ b/compiler/rustc_save_analysis/src/dump_visitor.rs
@@ -111,7 +111,7 @@ impl<'tcx> DumpVisitor<'tcx> {
self.save_ctxt.lookup_def_id(ref_id)
}
- pub fn dump_crate_info(&mut self, name: &str) {
+ pub fn dump_crate_info(&mut self, name: Symbol) {
let source_file = self.tcx.sess.local_crate_source_file.as_ref();
let crate_root = source_file.map(|source_file| {
let source_file = Path::new(source_file);
@@ -124,7 +124,7 @@ impl<'tcx> DumpVisitor<'tcx> {
let data = CratePreludeData {
crate_id: GlobalCrateId {
- name: name.into(),
+ name: name.to_string(),
disambiguator: (self.tcx.sess.local_stable_crate_id().to_u64(), 0),
},
crate_root: crate_root.unwrap_or_else(|| "<no source>".to_owned()),
@@ -135,7 +135,7 @@ impl<'tcx> DumpVisitor<'tcx> {
self.dumper.crate_prelude(data);
}
- pub fn dump_compilation_options(&mut self, input: &Input, crate_name: &str) {
+ pub fn dump_compilation_options(&mut self, input: &Input, crate_name: Symbol) {
// Apply possible `remap-path-prefix` remapping to the input source file
// (and don't include remapping args anymore)
let (program, arguments) = {
@@ -185,13 +185,13 @@ impl<'tcx> DumpVisitor<'tcx> {
}
}
- fn write_sub_paths(&mut self, path: &'tcx hir::Path<'tcx>) {
+ fn write_sub_paths<R>(&mut self, path: &'tcx hir::Path<'tcx, R>) {
self.write_segments(path.segments)
}
// As write_sub_paths, but does not process the last ident in the path (assuming it
// will be processed elsewhere). See note on write_sub_paths about global.
- fn write_sub_paths_truncated(&mut self, path: &'tcx hir::Path<'tcx>) {
+ fn write_sub_paths_truncated<R>(&mut self, path: &'tcx hir::Path<'tcx, R>) {
if let [segments @ .., _] = path.segments {
self.write_segments(segments)
}
@@ -527,9 +527,9 @@ impl<'tcx> DumpVisitor<'tcx> {
let value = format!("{}::{} {{ {} }}", enum_data.name, name, fields_str);
if !self.span.filter_generated(name_span) {
let span = self.span_from_span(name_span);
- let id = id_from_hir_id(variant.id, &self.save_ctxt);
+ let id = id_from_hir_id(variant.hir_id, &self.save_ctxt);
let parent = Some(id_from_def_id(item.owner_id.to_def_id()));
- let attrs = self.tcx.hir().attrs(variant.id);
+ let attrs = self.tcx.hir().attrs(variant.hir_id);
self.dumper.dump_def(
&access,
@@ -552,7 +552,7 @@ impl<'tcx> DumpVisitor<'tcx> {
}
ref v => {
let mut value = format!("{}::{}", enum_data.name, name);
- if let hir::VariantData::Tuple(fields, _) = v {
+ if let hir::VariantData::Tuple(fields, _, _) = v {
value.push('(');
value.push_str(
&fields
@@ -565,9 +565,9 @@ impl<'tcx> DumpVisitor<'tcx> {
}
if !self.span.filter_generated(name_span) {
let span = self.span_from_span(name_span);
- let id = id_from_hir_id(variant.id, &self.save_ctxt);
+ let id = id_from_hir_id(variant.hir_id, &self.save_ctxt);
let parent = Some(id_from_def_id(item.owner_id.to_def_id()));
- let attrs = self.tcx.hir().attrs(variant.id);
+ let attrs = self.tcx.hir().attrs(variant.hir_id);
self.dumper.dump_def(
&access,
@@ -591,7 +591,7 @@ impl<'tcx> DumpVisitor<'tcx> {
}
for field in variant.data.fields() {
- self.process_struct_field_def(field, variant.id);
+ self.process_struct_field_def(field, variant.hir_id);
self.visit_ty(field.ty);
}
}
@@ -1029,7 +1029,7 @@ impl<'tcx> DumpVisitor<'tcx> {
trait_item.hir_id(),
trait_item.ident,
Some(bounds),
- default_ty.as_ref().map(|ty| &**ty),
+ default_ty.as_deref(),
&self.save_ctxt,
),
attributes: lower_attributes(attrs.to_vec(), &self.save_ctxt),
diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs
index d0155c908..7735c5713 100644
--- a/compiler/rustc_save_analysis/src/lib.rs
+++ b/compiler/rustc_save_analysis/src/lib.rs
@@ -94,8 +94,8 @@ impl<'tcx> SaveContext<'tcx> {
}
}
- // Returns path to the compilation output (e.g., libfoo-12345678.rmeta)
- pub fn compilation_output(&self, crate_name: &str) -> PathBuf {
+ /// Returns path to the compilation output (e.g., libfoo-12345678.rmeta)
+ pub fn compilation_output(&self, crate_name: Symbol) -> PathBuf {
let sess = &self.tcx.sess;
// Save-analysis is emitted per whole session, not per each crate type
let crate_type = sess.crate_types()[0];
@@ -112,7 +112,7 @@ impl<'tcx> SaveContext<'tcx> {
}
}
- // List external crates used by the current crate.
+ /// List external crates used by the current crate.
pub fn get_external_crates(&self) -> Vec<ExternalCrateData> {
let mut result = Vec::with_capacity(self.tcx.crates(()).len());
@@ -319,7 +319,7 @@ impl<'tcx> SaveContext<'tcx> {
qualname,
value,
parent: None,
- children: def.variants.iter().map(|v| id_from_hir_id(v.id, self)).collect(),
+ children: def.variants.iter().map(|v| id_from_hir_id(v.hir_id, self)).collect(),
decl_id: None,
docs: self.docs_for_attrs(attrs),
sig: sig::item_signature(item, self),
@@ -594,7 +594,9 @@ impl<'tcx> SaveContext<'tcx> {
match self.tcx.hir().get(hir_id) {
Node::TraitRef(tr) => tr.path.res,
- Node::Item(&hir::Item { kind: hir::ItemKind::Use(path, _), .. }) => path.res,
+ Node::Item(&hir::Item { kind: hir::ItemKind::Use(path, _), .. }) => {
+ path.res.get(0).copied().unwrap_or(Res::Err)
+ }
Node::PathSegment(seg) => {
if seg.res != Res::Err {
seg.res
@@ -892,8 +894,8 @@ pub struct DumpHandler<'a> {
}
impl<'a> DumpHandler<'a> {
- pub fn new(odir: Option<&'a Path>, cratename: &str) -> DumpHandler<'a> {
- DumpHandler { odir, cratename: cratename.to_owned() }
+ pub fn new(odir: Option<&'a Path>, cratename: Symbol) -> DumpHandler<'a> {
+ DumpHandler { odir, cratename: cratename.to_string() }
}
fn output_file(&self, ctx: &SaveContext<'_>) -> (BufWriter<File>, PathBuf) {
@@ -958,7 +960,7 @@ impl SaveHandler for CallbackHandler<'_> {
pub fn process_crate<'l, 'tcx, H: SaveHandler>(
tcx: TyCtxt<'tcx>,
- cratename: &str,
+ cratename: Symbol,
input: &'l Input,
config: Option<Config>,
mut handler: H,
diff --git a/compiler/rustc_save_analysis/src/sig.rs b/compiler/rustc_save_analysis/src/sig.rs
index 83c51d213..9197a28c1 100644
--- a/compiler/rustc_save_analysis/src/sig.rs
+++ b/compiler/rustc_save_analysis/src/sig.rs
@@ -167,9 +167,9 @@ impl<'hir> Sig for hir::Ty<'hir> {
}
hir::TyKind::Rptr(ref lifetime, ref mt) => {
let mut prefix = "&".to_owned();
- prefix.push_str(&lifetime.name.ident().to_string());
+ prefix.push_str(&lifetime.ident.to_string());
prefix.push(' ');
- if let hir::Mutability::Mut = mt.mutbl {
+ if mt.mutbl.is_mut() {
prefix.push_str("mut ");
};
@@ -332,7 +332,7 @@ impl<'hir> Sig for hir::Item<'hir> {
match self.kind {
hir::ItemKind::Static(ref ty, m, ref body) => {
let mut text = "static ".to_owned();
- if m == hir::Mutability::Mut {
+ if m.is_mut() {
text.push_str("mut ");
}
let name = self.ident.to_string();
@@ -693,7 +693,7 @@ impl<'hir> Sig for hir::Variant<'hir> {
text.push('}');
Ok(Signature { text, defs, refs })
}
- hir::VariantData::Tuple(fields, id) => {
+ hir::VariantData::Tuple(fields, id, _) => {
let name_def = SigElement {
id: id_from_hir_id(id, scx),
start: offset,
@@ -712,7 +712,7 @@ impl<'hir> Sig for hir::Variant<'hir> {
text.push(')');
Ok(Signature { text, defs, refs })
}
- hir::VariantData::Unit(id) => {
+ hir::VariantData::Unit(id, _) => {
let name_def = SigElement {
id: id_from_hir_id(id, scx),
start: offset,