Skip to content

Commit 76bf345

Browse files
committed
Keep crate edition in metadata
1 parent cd4925d commit 76bf345

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

src/librustc/middle/cstore.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use session::search_paths::PathKind;
3434
use std::any::Any;
3535
use std::path::{Path, PathBuf};
3636
use syntax::ast;
37+
use syntax::edition::Edition;
3738
use syntax::ext::base::SyntaxExtension;
3839
use syntax::symbol::Symbol;
3940
use syntax_pos::Span;
@@ -235,6 +236,7 @@ pub trait CrateStore {
235236
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol;
236237
fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator;
237238
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh;
239+
fn crate_edition_untracked(&self, cnum: CrateNum) -> Edition;
238240
fn struct_field_names_untracked(&self, def: DefId) -> Vec<ast::Name>;
239241
fn item_children_untracked(&self, did: DefId, sess: &Session) -> Vec<def::Export>;
240242
fn load_macro_untracked(&self, did: DefId, sess: &Session) -> LoadedMacro;
@@ -309,6 +311,7 @@ impl CrateStore for DummyCrateStore {
309311
bug!("crate_disambiguator")
310312
}
311313
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh { bug!("crate_hash") }
314+
fn crate_edition_untracked(&self, cnum: CrateNum) -> Edition { bug!("crate_edition_untracked") }
312315

313316
// resolve
314317
fn def_key(&self, def: DefId) -> DefKey { bug!("def_key") }

src/librustc_metadata/cstore.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc::util::nodemap::{FxHashMap, NodeMap};
2424

2525
use rustc_data_structures::sync::{Lrc, RwLock, Lock};
2626
use syntax::{ast, attr};
27+
use syntax::edition::Edition;
2728
use syntax::ext::base::SyntaxExtension;
2829
use syntax::symbol::Symbol;
2930
use syntax_pos;
@@ -234,4 +235,8 @@ impl CrateMetadata {
234235
pub fn panic_strategy(&self) -> PanicStrategy {
235236
self.root.panic_strategy.clone()
236237
}
238+
239+
pub fn edition(&self) -> Edition {
240+
self.root.edition
241+
}
237242
}

src/librustc_metadata/cstore_impl.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use std::sync::Arc;
3838
use syntax::ast;
3939
use syntax::attr;
4040
use syntax::codemap;
41+
use syntax::edition::Edition;
4142
use syntax::ext::base::SyntaxExtension;
4243
use syntax::parse::filemap_to_stream;
4344
use syntax::symbol::Symbol;
@@ -464,6 +465,11 @@ impl CrateStore for cstore::CStore {
464465
self.get_crate_data(cnum).hash()
465466
}
466467

468+
fn crate_edition_untracked(&self, cnum: CrateNum) -> Edition
469+
{
470+
self.get_crate_data(cnum).edition()
471+
}
472+
467473
/// Returns the `DefKey` for a given `DefId`. This indicates the
468474
/// parent `DefId` as well as some idea of what kind of data the
469475
/// `DefId` refers to.

src/librustc_metadata/encoder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use syntax::ast::{self, CRATE_NODE_ID};
4444
use syntax::codemap::Spanned;
4545
use syntax::attr;
4646
use syntax::symbol::Symbol;
47-
use syntax_pos::{self, FileName, FileMap, Span, DUMMY_SP};
47+
use syntax_pos::{self, hygiene, FileName, FileMap, Span, DUMMY_SP};
4848

4949
use rustc::hir::{self, PatKind};
5050
use rustc::hir::itemlikevisit::ItemLikeVisitor;
@@ -496,6 +496,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
496496
hash: link_meta.crate_hash,
497497
disambiguator: tcx.sess.local_crate_disambiguator(),
498498
panic_strategy: tcx.sess.panic_strategy(),
499+
edition: hygiene::default_edition(),
499500
has_global_allocator: has_global_allocator,
500501
has_default_lib_allocator: has_default_lib_allocator,
501502
plugin_registrar_fn: tcx.sess

src/librustc_metadata/schema.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use rustc_target::spec::{PanicStrategy, TargetTriple};
2323

2424
use rustc_serialize as serialize;
2525
use syntax::{ast, attr};
26+
use syntax::edition::Edition;
2627
use syntax::symbol::Symbol;
2728
use syntax_pos::{self, Span};
2829

@@ -189,6 +190,7 @@ pub struct CrateRoot {
189190
pub hash: hir::svh::Svh,
190191
pub disambiguator: CrateDisambiguator,
191192
pub panic_strategy: PanicStrategy,
193+
pub edition: Edition,
192194
pub has_global_allocator: bool,
193195
pub has_default_lib_allocator: bool,
194196
pub plugin_registrar_fn: Option<DefIndex>,

0 commit comments

Comments
 (0)