Skip to content

Commit 4f32e0d

Browse files
committed
Auto merge of #41294 - frewsxcv:rollup, r=frewsxcv
Rollup of 4 pull requests - Successful merges: #41279, #41281, #41287, #41292 - Failed merges:
2 parents 28a7429 + c04ae0f commit 4f32e0d

File tree

25 files changed

+334
-401
lines changed

25 files changed

+334
-401
lines changed

src/doc/book

Submodule book updated 112 files

src/doc/reference

src/librand/distributions/gamma.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ impl Gamma {
103103
assert!(shape > 0.0, "Gamma::new called with shape <= 0");
104104
assert!(scale > 0.0, "Gamma::new called with scale <= 0");
105105

106-
let repr = match shape {
107-
1.0 => One(Exp::new(1.0 / scale)),
108-
0.0...1.0 => Small(GammaSmallShape::new_raw(shape, scale)),
109-
_ => Large(GammaLargeShape::new_raw(shape, scale)),
106+
let repr = if shape == 1.0 {
107+
One(Exp::new(1.0 / scale))
108+
} else if 0.0 <= shape && shape < 1.0 {
109+
Small(GammaSmallShape::new_raw(shape, scale))
110+
} else {
111+
Large(GammaLargeShape::new_raw(shape, scale))
110112
};
111-
Gamma { repr: repr }
113+
Gamma { repr }
112114
}
113115
}
114116

src/librustc/middle/cstore.rs

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub use self::NativeLibraryKind::*;
5353

5454
#[derive(Clone, Debug)]
5555
pub struct LinkMeta {
56-
pub crate_name: Symbol,
5756
pub crate_hash: Svh,
5857
}
5958

src/librustc/session/mod.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub use self::code_stats::{SizeKind, TypeSizeInfo, VariantInfo};
1313

1414
use dep_graph::DepGraph;
1515
use hir::def_id::{CrateNum, DefIndex};
16-
use hir::svh::Svh;
1716
use lint;
1817
use middle::cstore::CrateStore;
1918
use middle::dependency_format;
@@ -402,15 +401,14 @@ impl Session {
402401

403402
/// Returns the symbol name for the registrar function,
404403
/// given the crate Svh and the function DefIndex.
405-
pub fn generate_plugin_registrar_symbol(&self, svh: &Svh, index: DefIndex)
404+
pub fn generate_plugin_registrar_symbol(&self, disambiguator: Symbol, index: DefIndex)
406405
-> String {
407-
format!("__rustc_plugin_registrar__{}_{}", svh, index.as_usize())
406+
format!("__rustc_plugin_registrar__{}_{}", disambiguator, index.as_usize())
408407
}
409408

410-
pub fn generate_derive_registrar_symbol(&self,
411-
svh: &Svh,
412-
index: DefIndex) -> String {
413-
format!("__rustc_derive_registrar__{}_{}", svh, index.as_usize())
409+
pub fn generate_derive_registrar_symbol(&self, disambiguator: Symbol, index: DefIndex)
410+
-> String {
411+
format!("__rustc_derive_registrar__{}_{}", disambiguator, index.as_usize())
414412
}
415413

416414
pub fn sysroot<'a>(&'a self) -> &'a Path {

src/librustc/ty/adjustment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub enum Adjust<'tcx> {
3333
/// Go from a safe fn pointer to an unsafe fn pointer.
3434
UnsafeFnPointer,
3535

36-
// Go from a non-capturing closure to an fn pointer.
36+
/// Go from a non-capturing closure to an fn pointer.
3737
ClosureFnPointer,
3838

3939
/// Go from a mut raw pointer to a const raw pointer.

src/librustc_driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ pub fn phase_6_link_output(sess: &Session,
11401140
outputs: &OutputFilenames) {
11411141
time(sess.time_passes(),
11421142
"linking",
1143-
|| link::link_binary(sess, trans, outputs, &trans.link.crate_name.as_str()));
1143+
|| link::link_binary(sess, trans, outputs, &trans.crate_name.as_str()));
11441144
}
11451145

11461146
fn escape_dep_filename(filename: &str) -> String {

src/librustc_metadata/creader.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ impl<'a> CrateLoader<'a> {
600600
Err(err) => self.sess.span_fatal(span, &err),
601601
};
602602

603-
let sym = self.sess.generate_derive_registrar_symbol(&root.hash,
603+
let sym = self.sess.generate_derive_registrar_symbol(root.disambiguator,
604604
root.macro_derive_registrar.unwrap());
605605
let registrar = unsafe {
606606
let sym = match lib.symbol(&sym) {
@@ -654,7 +654,7 @@ impl<'a> CrateLoader<'a> {
654654
/// Look for a plugin registrar. Returns library path, crate
655655
/// SVH and DefIndex of the registrar function.
656656
pub fn find_plugin_registrar(&mut self, span: Span, name: &str)
657-
-> Option<(PathBuf, Svh, DefIndex)> {
657+
-> Option<(PathBuf, Symbol, DefIndex)> {
658658
let ekrate = self.read_extension_crate(span, &ExternCrateInfo {
659659
name: Symbol::intern(name),
660660
ident: Symbol::intern(name),
@@ -675,7 +675,7 @@ impl<'a> CrateLoader<'a> {
675675
let root = ekrate.metadata.get_root();
676676
match (ekrate.dylib.as_ref(), root.plugin_registrar_fn) {
677677
(Some(dylib), Some(reg)) => {
678-
Some((dylib.to_path_buf(), root.hash, reg))
678+
Some((dylib.to_path_buf(), root.disambiguator, reg))
679679
}
680680
(None, Some(_)) => {
681681
span_err!(self.sess, span, E0457,

src/librustc_metadata/encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use schema::*;
1414

1515
use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary,
1616
EncodedMetadata, EncodedMetadataHash};
17-
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId};
17+
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LOCAL_CRATE};
1818
use rustc::hir::map::definitions::DefPathTable;
1919
use rustc::middle::dependency_format::Linkage;
2020
use rustc::middle::lang_items;
@@ -1380,7 +1380,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13801380
let link_meta = self.link_meta;
13811381
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro);
13821382
let root = self.lazy(&CrateRoot {
1383-
name: link_meta.crate_name,
1383+
name: tcx.crate_name(LOCAL_CRATE),
13841384
triple: tcx.sess.opts.target_triple.clone(),
13851385
hash: link_meta.crate_hash,
13861386
disambiguator: tcx.sess.local_crate_disambiguator(),

src/librustc_plugin/load.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ impl<'a> PluginLoader<'a> {
100100
fn load_plugin(&mut self, span: Span, name: &str, args: Vec<ast::NestedMetaItem>) {
101101
let registrar = self.reader.find_plugin_registrar(span, name);
102102

103-
if let Some((lib, svh, index)) = registrar {
104-
let symbol = self.sess.generate_plugin_registrar_symbol(&svh, index);
103+
if let Some((lib, disambiguator, index)) = registrar {
104+
let symbol = self.sess.generate_plugin_registrar_symbol(disambiguator, index);
105105
let fun = self.dylink_registrar(span, lib, symbol);
106106
self.plugins.push(PluginRegistrar {
107107
fun: fun,

src/librustc_trans/back/link.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use std::str;
4747
use flate;
4848
use syntax::ast;
4949
use syntax::attr;
50-
use syntax::symbol::Symbol;
5150
use syntax_pos::Span;
5251

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

139-
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap,
140-
name: &str)
141-
-> LinkMeta {
138+
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMeta {
142139
let r = LinkMeta {
143-
crate_name: Symbol::intern(name),
144140
crate_hash: Svh::new(incremental_hashes_map[&DepNode::Krate].to_smaller_hash()),
145141
};
146142
info!("{:?}", r);

src/librustc_trans/back/symbol_export.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use back::symbol_names::symbol_name;
1515
use util::nodemap::FxHashMap;
1616
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
1717
use rustc::session::config;
18+
use rustc::ty::TyCtxt;
1819
use syntax::attr;
1920
use trans_item::TransItem;
2021

@@ -64,15 +65,15 @@ impl ExportedSymbols {
6465
}
6566

6667
if let Some(id) = scx.sess().derive_registrar_fn.get() {
67-
let svh = &scx.link_meta().crate_hash;
6868
let def_id = scx.tcx().hir.local_def_id(id);
6969
let idx = def_id.index;
70-
let registrar = scx.sess().generate_derive_registrar_symbol(svh, idx);
70+
let disambiguator = scx.sess().local_crate_disambiguator();
71+
let registrar = scx.sess().generate_derive_registrar_symbol(disambiguator, idx);
7172
local_crate.push((registrar, SymbolExportLevel::C));
7273
}
7374

7475
if scx.sess().crate_types.borrow().contains(&config::CrateTypeDylib) {
75-
local_crate.push((scx.metadata_symbol_name(),
76+
local_crate.push((metadata_symbol_name(scx.tcx()),
7677
SymbolExportLevel::Rust));
7778
}
7879

@@ -173,6 +174,12 @@ impl ExportedSymbols {
173174
}
174175
}
175176

177+
pub fn metadata_symbol_name(tcx: TyCtxt) -> String {
178+
format!("rust_metadata_{}_{}",
179+
tcx.crate_name(LOCAL_CRATE),
180+
tcx.crate_disambiguator(LOCAL_CRATE))
181+
}
182+
176183
pub fn crate_export_threshold(crate_type: config::CrateType)
177184
-> SymbolExportLevel {
178185
match crate_type {

src/librustc_trans/back/symbol_names.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ pub fn symbol_name<'a, 'tcx>(instance: Instance<'tcx>,
179179

180180
if let Some(id) = node_id {
181181
if scx.sess().plugin_registrar_fn.get() == Some(id) {
182-
let svh = &scx.link_meta().crate_hash;
183182
let idx = def_id.index;
184-
return scx.sess().generate_plugin_registrar_symbol(svh, idx);
183+
let disambiguator = scx.sess().local_crate_disambiguator();
184+
return scx.sess().generate_plugin_registrar_symbol(disambiguator, idx);
185185
}
186186
if scx.sess().derive_registrar_fn.get() == Some(id) {
187-
let svh = &scx.link_meta().crate_hash;
188187
let idx = def_id.index;
189-
return scx.sess().generate_derive_registrar_symbol(svh, idx);
188+
let disambiguator = scx.sess().local_crate_disambiguator();
189+
return scx.sess().generate_derive_registrar_symbol(disambiguator, idx);
190190
}
191191
}
192192

0 commit comments

Comments
 (0)