Skip to content

Commit 4cbd397

Browse files
committed
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.
1 parent 9e2d6e1 commit 4cbd397

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/librustc/session/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@ use util::common::ProfileQueriesMsg;
2828
use rustc_data_structures::base_n;
2929
use rustc_data_structures::sync::{self, Lrc, Lock, LockCell, OneThread, Once, RwLock};
3030

31-
use syntax::ast::NodeId;
3231
use errors::{self, DiagnosticBuilder, DiagnosticId, Applicability};
3332
use errors::emitter::{Emitter, EmitterWriter};
33+
use syntax::ast::{self, NodeId};
3434
use syntax::edition::Edition;
35+
use syntax::feature_gate::{self, AttributeType};
3536
use syntax::json::JsonEmitter;
36-
use syntax::feature_gate;
37-
use syntax::parse;
38-
use syntax::parse::ParseSess;
39-
use syntax::{ast, source_map};
40-
use syntax::feature_gate::AttributeType;
41-
use syntax_pos::{MultiSpan, Span, symbol::Symbol};
37+
use syntax::source_map;
38+
use syntax::symbol::Symbol;
39+
use syntax::parse::{self, ParseSess};
40+
use syntax_pos::{MultiSpan, Span};
4241
use util::profiling::SelfProfiler;
4342

4443
use rustc_target::spec::PanicStrategy;

src/librustc/ty/item_path.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
281281
// In particular, don't recurse to print the crate root if we
282282
// just printed `std`. In doing this, we are able to add
283283
// `crate::` to trait import suggestions.
284-
DefPathData::CrateRoot if data.as_interned_str() == "std" => {},
284+
DefPathData::CrateRoot if self.sess.extern_prelude.contains(
285+
&data.as_interned_str().as_symbol()
286+
) => {},
285287
_ => self.push_item_path(buffer, parent_def_id),
286288
}
287289

0 commit comments

Comments
 (0)