diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-07-21 12:41:29 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-07-28 12:05:04 -0400 |
| commit | ffc13b2f80dfe60895bb415175fa246d7247a33c (patch) | |
| tree | fb945c4dad4a88f85609136da280a93fcd64d9e5 /src/librustc | |
| parent | 2b38c4bdea7acf72b8322660de5a4f86d561a65c (diff) | |
| download | rust-ffc13b2f80dfe60895bb415175fa246d7247a33c.tar.gz rust-ffc13b2f80dfe60895bb415175fa246d7247a33c.zip | |
Store `crate_disambiguator` as an `InternedString`
We used to use `Name`, but the session outlives the tokenizer, which means that attempts to read this field after trans has complete otherwise panic. All reads want an `InternedString` anyhow.
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/session/mod.rs | 7 | ||||
| -rw-r--r-- | src/librustc/ty/context.rs | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 5901c42b525..cee18232ec9 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -80,7 +80,7 @@ pub struct Session { // forms a unique global identifier for the crate. It is used to allow // multiple crates with the same name to coexist. See the // trans::back::symbol_names module for more information. - pub crate_disambiguator: Cell<ast::Name>, + pub crate_disambiguator: RefCell<token::InternedString>, pub features: RefCell<feature_gate::Features>, /// The maximum recursion limit for potentially infinitely recursive @@ -106,6 +106,9 @@ pub struct Session { } impl Session { + pub fn local_crate_disambiguator(&self) -> token::InternedString { + self.crate_disambiguator.borrow().clone() + } pub fn struct_span_warn<'a, S: Into<MultiSpan>>(&'a self, sp: S, msg: &str) @@ -438,7 +441,7 @@ pub fn build_session_(sopts: config::Options, plugin_attributes: RefCell::new(Vec::new()), crate_types: RefCell::new(Vec::new()), dependency_formats: RefCell::new(FnvHashMap()), - crate_disambiguator: Cell::new(token::intern("")), + crate_disambiguator: RefCell::new(token::intern("").as_str()), features: RefCell::new(feature_gate::Features::new()), recursion_limit: Cell::new(64), next_node_id: Cell::new(1), diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 56938a7a838..5444dd94761 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -504,7 +504,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn crate_disambiguator(self, cnum: ast::CrateNum) -> token::InternedString { if cnum == LOCAL_CRATE { - self.sess.crate_disambiguator.get().as_str() + self.sess.local_crate_disambiguator() } else { self.sess.cstore.crate_disambiguator(cnum) } |
