about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2018-09-27 21:38:11 +0200
committerDavid Wood <david@davidtw.co>2018-10-02 01:16:08 +0200
commit4cbd397ce861ae0ee823ab56d1f797dee67e0b64 (patch)
treeaa2db63a2f697124b1fcf7ce50ff8eb2cfa8ffd1
parent9e2d6e1e62802f7a42c900438b97fd3c5316dcb3 (diff)
downloadrust-4cbd397ce861ae0ee823ab56d1f797dee67e0b64.tar.gz
rust-4cbd397ce861ae0ee823ab56d1f797dee67e0b64.zip
Move prelude crate names into `Session`.
Avoid hardcoding and special-casing the `std` crate name in the item
path logic by moving the prelude crate name logic into the `Session`
type so it can be reused in the item path logic and resolve module.
-rw-r--r--src/librustc/session/mod.rs13
-rw-r--r--src/librustc/ty/item_path.rs4
2 files changed, 9 insertions, 8 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 79d06cd7f12..3c209a43246 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -28,17 +28,16 @@ use util::common::ProfileQueriesMsg;
 use rustc_data_structures::base_n;
 use rustc_data_structures::sync::{self, Lrc, Lock, LockCell, OneThread, Once, RwLock};
 
-use syntax::ast::NodeId;
 use errors::{self, DiagnosticBuilder, DiagnosticId, Applicability};
 use errors::emitter::{Emitter, EmitterWriter};
+use syntax::ast::{self, NodeId};
 use syntax::edition::Edition;
+use syntax::feature_gate::{self, AttributeType};
 use syntax::json::JsonEmitter;
-use syntax::feature_gate;
-use syntax::parse;
-use syntax::parse::ParseSess;
-use syntax::{ast, source_map};
-use syntax::feature_gate::AttributeType;
-use syntax_pos::{MultiSpan, Span, symbol::Symbol};
+use syntax::source_map;
+use syntax::symbol::Symbol;
+use syntax::parse::{self, ParseSess};
+use syntax_pos::{MultiSpan, Span};
 use util::profiling::SelfProfiler;
 
 use rustc_target::spec::PanicStrategy;
diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs
index 41f908b4be6..4e7783a00cb 100644
--- a/src/librustc/ty/item_path.rs
+++ b/src/librustc/ty/item_path.rs
@@ -281,7 +281,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
                     // In particular, don't recurse to print the crate root if we
                     // just printed `std`. In doing this, we are able to add
                     // `crate::` to trait import suggestions.
-                    DefPathData::CrateRoot if data.as_interned_str() == "std" => {},
+                    DefPathData::CrateRoot if self.sess.extern_prelude.contains(
+                        &data.as_interned_str().as_symbol()
+                    ) => {},
                     _ => self.push_item_path(buffer, parent_def_id),
                 }