Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 4 pull requests #41294

Merged
merged 21 commits into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
03b0d99
rustc_typeck: consolidate adjustment composition
arielb1 Apr 13, 2017
537eb45
Update various bookshelf repositories.
steveklabnik Apr 13, 2017
15507bc
remove `metadata_*` from `SharedCrateContext`
nikomatsakis Apr 13, 2017
b078ece
rewrite to pass a ref, not slice + index
nikomatsakis Apr 13, 2017
7b42924
remove unused `link_meta`
nikomatsakis Apr 13, 2017
3387505
redirect `exported_symbols` through `shared`
nikomatsakis Apr 13, 2017
fe78b54
merge the "predeclare" and "declare" phases so we run them per-CGU
nikomatsakis Apr 13, 2017
6cb516a
move `assert_module_sources` call down below
nikomatsakis Apr 13, 2017
bc79f01
create `ModuleTranslation` all in one big loop
nikomatsakis Apr 13, 2017
863927c
rewrite post-processing routines not to require a `CrateContext`
nikomatsakis Apr 13, 2017
3f59079
kill `CrateContextList` as a thing
nikomatsakis Apr 13, 2017
c22fdf9
use `tcx.crate_name(LOCAL_CRATE)` rather than `LinkMeta::crate_name`
nikomatsakis Apr 13, 2017
f227187
remove `LinkMeta` from `SharedCrateContext`
nikomatsakis Apr 13, 2017
8e26983
pull stats out of `SharedCrateContext`
nikomatsakis Apr 13, 2017
f2487b8
refactor `metadata_symbol_name`
nikomatsakis Apr 13, 2017
07fb93e
make `write_metadata` take `tcx` intead of `SharedCrateContext`
nikomatsakis Apr 13, 2017
baeec7b
Avoid to use floating point match
est31 Apr 14, 2017
187f339
Rollup merge of #41279 - arielb1:adjustment-composition, r=nikomatsakis
frewsxcv Apr 14, 2017
017e3e9
Rollup merge of #41281 - steveklabnik:update-submodules2, r=guillaume…
frewsxcv Apr 14, 2017
adc2b10
Rollup merge of #41287 - nikomatsakis:incr-comp-refactor-trans, r=eddyb
frewsxcv Apr 14, 2017
c04ae0f
Rollup merge of #41292 - est31:master, r=BurntSushi
frewsxcv Apr 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 112 files
2 changes: 1 addition & 1 deletion src/doc/reference
12 changes: 7 additions & 5 deletions src/librand/distributions/gamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ impl Gamma {
assert!(shape > 0.0, "Gamma::new called with shape <= 0");
assert!(scale > 0.0, "Gamma::new called with scale <= 0");

let repr = match shape {
1.0 => One(Exp::new(1.0 / scale)),
0.0...1.0 => Small(GammaSmallShape::new_raw(shape, scale)),
_ => Large(GammaLargeShape::new_raw(shape, scale)),
let repr = if shape == 1.0 {
One(Exp::new(1.0 / scale))
} else if 0.0 <= shape && shape < 1.0 {
Small(GammaSmallShape::new_raw(shape, scale))
} else {
Large(GammaLargeShape::new_raw(shape, scale))
};
Gamma { repr: repr }
Gamma { repr }
}
}

Expand Down
1 change: 0 additions & 1 deletion src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ pub use self::NativeLibraryKind::*;

#[derive(Clone, Debug)]
pub struct LinkMeta {
pub crate_name: Symbol,
pub crate_hash: Svh,
}

Expand Down
12 changes: 5 additions & 7 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub use self::code_stats::{SizeKind, TypeSizeInfo, VariantInfo};

use dep_graph::DepGraph;
use hir::def_id::{CrateNum, DefIndex};
use hir::svh::Svh;
use lint;
use middle::cstore::CrateStore;
use middle::dependency_format;
Expand Down Expand Up @@ -402,15 +401,14 @@ impl Session {

/// Returns the symbol name for the registrar function,
/// given the crate Svh and the function DefIndex.
pub fn generate_plugin_registrar_symbol(&self, svh: &Svh, index: DefIndex)
pub fn generate_plugin_registrar_symbol(&self, disambiguator: Symbol, index: DefIndex)
-> String {
format!("__rustc_plugin_registrar__{}_{}", svh, index.as_usize())
format!("__rustc_plugin_registrar__{}_{}", disambiguator, index.as_usize())
}

pub fn generate_derive_registrar_symbol(&self,
svh: &Svh,
index: DefIndex) -> String {
format!("__rustc_derive_registrar__{}_{}", svh, index.as_usize())
pub fn generate_derive_registrar_symbol(&self, disambiguator: Symbol, index: DefIndex)
-> String {
format!("__rustc_derive_registrar__{}_{}", disambiguator, index.as_usize())
}

pub fn sysroot<'a>(&'a self) -> &'a Path {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/adjustment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum Adjust<'tcx> {
/// Go from a safe fn pointer to an unsafe fn pointer.
UnsafeFnPointer,

// Go from a non-capturing closure to an fn pointer.
/// Go from a non-capturing closure to an fn pointer.
ClosureFnPointer,

/// Go from a mut raw pointer to a const raw pointer.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ pub fn phase_6_link_output(sess: &Session,
outputs: &OutputFilenames) {
time(sess.time_passes(),
"linking",
|| link::link_binary(sess, trans, outputs, &trans.link.crate_name.as_str()));
|| link::link_binary(sess, trans, outputs, &trans.crate_name.as_str()));
}

fn escape_dep_filename(filename: &str) -> String {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ impl<'a> CrateLoader<'a> {
Err(err) => self.sess.span_fatal(span, &err),
};

let sym = self.sess.generate_derive_registrar_symbol(&root.hash,
let sym = self.sess.generate_derive_registrar_symbol(root.disambiguator,
root.macro_derive_registrar.unwrap());
let registrar = unsafe {
let sym = match lib.symbol(&sym) {
Expand Down Expand Up @@ -654,7 +654,7 @@ impl<'a> CrateLoader<'a> {
/// Look for a plugin registrar. Returns library path, crate
/// SVH and DefIndex of the registrar function.
pub fn find_plugin_registrar(&mut self, span: Span, name: &str)
-> Option<(PathBuf, Svh, DefIndex)> {
-> Option<(PathBuf, Symbol, DefIndex)> {
let ekrate = self.read_extension_crate(span, &ExternCrateInfo {
name: Symbol::intern(name),
ident: Symbol::intern(name),
Expand All @@ -675,7 +675,7 @@ impl<'a> CrateLoader<'a> {
let root = ekrate.metadata.get_root();
match (ekrate.dylib.as_ref(), root.plugin_registrar_fn) {
(Some(dylib), Some(reg)) => {
Some((dylib.to_path_buf(), root.hash, reg))
Some((dylib.to_path_buf(), root.disambiguator, reg))
}
(None, Some(_)) => {
span_err!(self.sess, span, E0457,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use schema::*;

use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary,
EncodedMetadata, EncodedMetadataHash};
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId};
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LOCAL_CRATE};
use rustc::hir::map::definitions::DefPathTable;
use rustc::middle::dependency_format::Linkage;
use rustc::middle::lang_items;
Expand Down Expand Up @@ -1380,7 +1380,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let link_meta = self.link_meta;
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro);
let root = self.lazy(&CrateRoot {
name: link_meta.crate_name,
name: tcx.crate_name(LOCAL_CRATE),
triple: tcx.sess.opts.target_triple.clone(),
hash: link_meta.crate_hash,
disambiguator: tcx.sess.local_crate_disambiguator(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_plugin/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ impl<'a> PluginLoader<'a> {
fn load_plugin(&mut self, span: Span, name: &str, args: Vec<ast::NestedMetaItem>) {
let registrar = self.reader.find_plugin_registrar(span, name);

if let Some((lib, svh, index)) = registrar {
let symbol = self.sess.generate_plugin_registrar_symbol(&svh, index);
if let Some((lib, disambiguator, index)) = registrar {
let symbol = self.sess.generate_plugin_registrar_symbol(disambiguator, index);
let fun = self.dylink_registrar(span, lib, symbol);
self.plugins.push(PluginRegistrar {
fun: fun,
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use std::str;
use flate;
use syntax::ast;
use syntax::attr;
use syntax::symbol::Symbol;
use syntax_pos::Span;

/// The LLVM module name containing crate-metadata. This includes a `.` on
Expand Down Expand Up @@ -136,11 +135,8 @@ pub fn find_crate_name(sess: Option<&Session>,
"rust_out".to_string()
}

pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap,
name: &str)
-> LinkMeta {
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMeta {
let r = LinkMeta {
crate_name: Symbol::intern(name),
crate_hash: Svh::new(incremental_hashes_map[&DepNode::Krate].to_smaller_hash()),
};
info!("{:?}", r);
Expand Down
13 changes: 10 additions & 3 deletions src/librustc_trans/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use back::symbol_names::symbol_name;
use util::nodemap::FxHashMap;
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
use rustc::session::config;
use rustc::ty::TyCtxt;
use syntax::attr;
use trans_item::TransItem;

Expand Down Expand Up @@ -64,15 +65,15 @@ impl ExportedSymbols {
}

if let Some(id) = scx.sess().derive_registrar_fn.get() {
let svh = &scx.link_meta().crate_hash;
let def_id = scx.tcx().hir.local_def_id(id);
let idx = def_id.index;
let registrar = scx.sess().generate_derive_registrar_symbol(svh, idx);
let disambiguator = scx.sess().local_crate_disambiguator();
let registrar = scx.sess().generate_derive_registrar_symbol(disambiguator, idx);
local_crate.push((registrar, SymbolExportLevel::C));
}

if scx.sess().crate_types.borrow().contains(&config::CrateTypeDylib) {
local_crate.push((scx.metadata_symbol_name(),
local_crate.push((metadata_symbol_name(scx.tcx()),
SymbolExportLevel::Rust));
}

Expand Down Expand Up @@ -173,6 +174,12 @@ impl ExportedSymbols {
}
}

pub fn metadata_symbol_name(tcx: TyCtxt) -> String {
format!("rust_metadata_{}_{}",
tcx.crate_name(LOCAL_CRATE),
tcx.crate_disambiguator(LOCAL_CRATE))
}

pub fn crate_export_threshold(crate_type: config::CrateType)
-> SymbolExportLevel {
match crate_type {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_trans/back/symbol_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ pub fn symbol_name<'a, 'tcx>(instance: Instance<'tcx>,

if let Some(id) = node_id {
if scx.sess().plugin_registrar_fn.get() == Some(id) {
let svh = &scx.link_meta().crate_hash;
let idx = def_id.index;
return scx.sess().generate_plugin_registrar_symbol(svh, idx);
let disambiguator = scx.sess().local_crate_disambiguator();
return scx.sess().generate_plugin_registrar_symbol(disambiguator, idx);
}
if scx.sess().derive_registrar_fn.get() == Some(id) {
let svh = &scx.link_meta().crate_hash;
let idx = def_id.index;
return scx.sess().generate_derive_registrar_symbol(svh, idx);
let disambiguator = scx.sess().local_crate_disambiguator();
return scx.sess().generate_derive_registrar_symbol(disambiguator, idx);
}
}

Expand Down
Loading