Skip to content

Commit 0e5c96b

Browse files
authored
Auto merge of #36255 - Manishearth:rollup, r=Manishearth
Rollup of 7 pull requests - Successful merges: #36070, #36132, #36200, #36212, #36225, #36231, #36234 - Failed merges:
2 parents 1ca1de6 + a139242 commit 0e5c96b

File tree

29 files changed

+836
-126
lines changed

29 files changed

+836
-126
lines changed

src/bootstrap/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ struct Rust {
144144
rpath: Option<bool>,
145145
optimize_tests: Option<bool>,
146146
debuginfo_tests: Option<bool>,
147+
codegen_tests: Option<bool>,
147148
}
148149

149150
/// TOML representation of how each build target is configured.
@@ -232,6 +233,7 @@ impl Config {
232233
set(&mut config.rust_optimize, rust.optimize);
233234
set(&mut config.rust_optimize_tests, rust.optimize_tests);
234235
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
236+
set(&mut config.codegen_tests, rust.codegen_tests);
235237
set(&mut config.rust_rpath, rust.rpath);
236238
set(&mut config.debug_jemalloc, rust.debug_jemalloc);
237239
set(&mut config.use_jemalloc, rust.use_jemalloc);

src/bootstrap/config.toml.example

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Sample TOML configuration file for building Rust.
22
#
3+
# To configure rustbuild, copy this file to the directory from which you will be
4+
# running the build, and name it config.toml.
5+
#
36
# All options are commented out by default in this file, and they're commented
47
# out with their default values. The build system by default looks for
58
# `config.toml` in the current directory of a build for build configuration, but
@@ -130,6 +133,10 @@
130133
#optimize-tests = true
131134
#debuginfo-tests = true
132135

136+
# Flag indicating whether codegen tests will be run or not. If you get an error
137+
# saying that the FileCheck executable is missing, you may want to disable this.
138+
#codegen-tests = true
139+
133140
# =============================================================================
134141
# Options for specific targets
135142
#

src/doc/book/nightly-rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ binary downloads][install-page].
5454

5555
Oh, we should also mention the officially supported platforms:
5656

57-
* Windows (7, 8, Server 2008 R2)
57+
* Windows (7+)
5858
* Linux (2.6.18 or later, various distributions), x86 and x86-64
5959
* OSX 10.7 (Lion) or greater, x86 and x86-64
6060

src/librustc/session/config.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,13 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
849849
ls: bool = (false, parse_bool, [UNTRACKED],
850850
"list the symbols defined by a library crate"),
851851
save_analysis: bool = (false, parse_bool, [UNTRACKED],
852-
"write syntax and type analysis (in JSON format) information in addition to normal output"),
852+
"write syntax and type analysis (in JSON format) information, in \
853+
addition to normal output"),
853854
save_analysis_csv: bool = (false, parse_bool, [UNTRACKED],
854-
"write syntax and type analysis (in CSV format) information in addition to normal output"),
855+
"write syntax and type analysis (in CSV format) information, in addition to normal output"),
856+
save_analysis_api: bool = (false, parse_bool, [UNTRACKED],
857+
"write syntax and type analysis information for opaque libraries (in JSON format), \
858+
in addition to normal output"),
855859
print_move_fragments: bool = (false, parse_bool, [UNTRACKED],
856860
"print out move-fragment data for every fn"),
857861
flowgraph_print_loans: bool = (false, parse_bool, [UNTRACKED],
@@ -2365,6 +2369,8 @@ mod tests {
23652369
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
23662370
opts.debugging_opts.save_analysis_csv = true;
23672371
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2372+
opts.debugging_opts.save_analysis_api = true;
2373+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
23682374
opts.debugging_opts.print_move_fragments = true;
23692375
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
23702376
opts.debugging_opts.flowgraph_print_loans = true;

src/librustc_driver/driver.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ fn keep_hygiene_data(sess: &Session) -> bool {
250250
fn keep_ast(sess: &Session) -> bool {
251251
sess.opts.debugging_opts.keep_ast ||
252252
sess.opts.debugging_opts.save_analysis ||
253-
sess.opts.debugging_opts.save_analysis_csv
253+
sess.opts.debugging_opts.save_analysis_csv ||
254+
sess.opts.debugging_opts.save_analysis_api
254255
}
255256

256257
/// The name used for source code that doesn't originate in a file

src/librustc_driver/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -555,14 +555,17 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
555555

556556
fn save_analysis(sess: &Session) -> bool {
557557
sess.opts.debugging_opts.save_analysis ||
558-
sess.opts.debugging_opts.save_analysis_csv
558+
sess.opts.debugging_opts.save_analysis_csv ||
559+
sess.opts.debugging_opts.save_analysis_api
559560
}
560561

561562
fn save_analysis_format(sess: &Session) -> save::Format {
562563
if sess.opts.debugging_opts.save_analysis {
563564
save::Format::Json
564565
} else if sess.opts.debugging_opts.save_analysis_csv {
565566
save::Format::Csv
567+
} else if sess.opts.debugging_opts.save_analysis_api {
568+
save::Format::JsonApi
566569
} else {
567570
unreachable!();
568571
}

src/librustc_llvm/ffi.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ pub enum CallConv {
4949

5050
/// LLVMLinkage
5151
///
52+
/// This does not attempt to mirror the similar enum in LLVM, as this is fragile
53+
/// to upstream changes. Use LLVMRustSetLinkage() and LLVMRustGetLinkage() to
54+
/// translate these values to and from the LLVM side.
55+
///
5256
/// This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
5357
/// DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
5458
/// LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
@@ -60,13 +64,13 @@ pub enum Linkage {
6064
AvailableExternallyLinkage = 1,
6165
LinkOnceAnyLinkage = 2,
6266
LinkOnceODRLinkage = 3,
63-
WeakAnyLinkage = 5,
64-
WeakODRLinkage = 6,
65-
AppendingLinkage = 7,
66-
InternalLinkage = 8,
67-
PrivateLinkage = 9,
68-
ExternalWeakLinkage = 12,
69-
CommonLinkage = 14,
67+
WeakAnyLinkage = 4,
68+
WeakODRLinkage = 5,
69+
AppendingLinkage = 6,
70+
InternalLinkage = 7,
71+
PrivateLinkage = 8,
72+
ExternalWeakLinkage = 9,
73+
CommonLinkage = 10,
7074
}
7175

7276
/// LLVMDiagnosticSeverity
@@ -821,8 +825,8 @@ extern {
821825
/* Operations on global variables, functions, and aliases (globals) */
822826
pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
823827
pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
824-
pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
825-
pub fn LLVMSetLinkage(Global: ValueRef, Link: Linkage);
828+
pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
829+
pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
826830
pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
827831
pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
828832
pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;

src/librustc_metadata/creader.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,9 @@ impl<'a> LocalCrateReader<'a> {
10561056
Some("dylib") => cstore::NativeUnknown,
10571057
Some("framework") => cstore::NativeFramework,
10581058
Some(k) => {
1059-
span_err!(self.sess, m.span, E0458,
1060-
"unknown kind: `{}`", k);
1059+
struct_span_err!(self.sess, m.span, E0458,
1060+
"unknown kind: `{}`", k)
1061+
.span_label(m.span, &format!("unknown kind")).emit();
10611062
cstore::NativeUnknown
10621063
}
10631064
None => cstore::NativeUnknown
@@ -1068,8 +1069,9 @@ impl<'a> LocalCrateReader<'a> {
10681069
let n = match n {
10691070
Some(n) => n,
10701071
None => {
1071-
span_err!(self.sess, m.span, E0459,
1072-
"#[link(...)] specified without `name = \"foo\"`");
1072+
struct_span_err!(self.sess, m.span, E0459,
1073+
"#[link(...)] specified without `name = \"foo\"`")
1074+
.span_label(m.span, &format!("missing `name` argument")).emit();
10731075
InternedString::new("foo")
10741076
}
10751077
};

src/librustc_mir/transform/qualify_consts.rs

+33
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_data_structures::bitvec::BitVector;
1818
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
1919
use rustc::dep_graph::DepNode;
2020
use rustc::hir;
21+
use rustc::hir::map as hir_map;
2122
use rustc::hir::def_id::DefId;
2223
use rustc::hir::intravisit::FnKind;
2324
use rustc::hir::map::blocks::FnLikeNode;
@@ -252,14 +253,46 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
252253

253254
let mut err =
254255
struct_span_err!(self.tcx.sess, self.span, E0493, "{}", msg);
256+
255257
if self.mode != Mode::Const {
256258
help!(&mut err,
257259
"in Nightly builds, add `#![feature(drop_types_in_const)]` \
258260
to the crate attributes to enable");
261+
} else {
262+
self.find_drop_implementation_method_span()
263+
.map(|span| err.span_label(span, &format!("destructor defined here")));
264+
265+
err.span_label(self.span, &format!("constants cannot have destructors"));
259266
}
267+
260268
err.emit();
261269
}
262270

271+
fn find_drop_implementation_method_span(&self) -> Option<Span> {
272+
self.tcx.lang_items
273+
.drop_trait()
274+
.and_then(|drop_trait_id| {
275+
let mut span = None;
276+
277+
self.tcx
278+
.lookup_trait_def(drop_trait_id)
279+
.for_each_relevant_impl(self.tcx, self.mir.return_ty, |impl_did| {
280+
self.tcx.map
281+
.as_local_node_id(impl_did)
282+
.and_then(|impl_node_id| self.tcx.map.find(impl_node_id))
283+
.map(|node| {
284+
if let hir_map::NodeItem(item) = node {
285+
if let hir::ItemImpl(_, _, _, _, _, ref methods) = item.node {
286+
span = methods.first().map(|method| method.span);
287+
}
288+
}
289+
});
290+
});
291+
292+
span
293+
})
294+
}
295+
263296
/// Check if an Lvalue with the current qualifications could
264297
/// be consumed, by either an operand or a Deref projection.
265298
fn try_consume(&mut self) -> bool {

src/librustc_save_analysis/data.rs

+50-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
//! The `Dump` trait can be used together with `DumpVisitor` in order to
1414
//! retrieve the data from a crate.
1515
16+
use rustc::hir;
1617
use rustc::hir::def_id::DefId;
17-
use syntax::ast::{CrateNum, NodeId};
18+
use syntax::ast::{self, CrateNum, NodeId};
1819
use syntax_pos::Span;
1920

2021
pub struct CrateData {
@@ -76,6 +77,35 @@ pub enum Data {
7677
VariableRefData(VariableRefData),
7778
}
7879

80+
#[derive(Eq, PartialEq, Clone, Copy, Debug, RustcEncodable)]
81+
pub enum Visibility {
82+
Public,
83+
Restricted,
84+
Inherited,
85+
}
86+
87+
impl<'a> From<&'a ast::Visibility> for Visibility {
88+
fn from(v: &'a ast::Visibility) -> Visibility {
89+
match *v {
90+
ast::Visibility::Public => Visibility::Public,
91+
ast::Visibility::Crate(_) => Visibility::Restricted,
92+
ast::Visibility::Restricted { .. } => Visibility::Restricted,
93+
ast::Visibility::Inherited => Visibility::Inherited,
94+
}
95+
}
96+
}
97+
98+
impl<'a> From<&'a hir::Visibility> for Visibility {
99+
fn from(v: &'a hir::Visibility) -> Visibility {
100+
match *v {
101+
hir::Visibility::Public => Visibility::Public,
102+
hir::Visibility::Crate => Visibility::Restricted,
103+
hir::Visibility::Restricted { .. } => Visibility::Restricted,
104+
hir::Visibility::Inherited => Visibility::Inherited,
105+
}
106+
}
107+
}
108+
79109
/// Data for the prelude of a crate.
80110
#[derive(Debug, RustcEncodable)]
81111
pub struct CratePreludeData {
@@ -103,7 +133,7 @@ pub struct EnumData {
103133
pub span: Span,
104134
pub scope: NodeId,
105135
pub variants: Vec<NodeId>,
106-
136+
pub visibility: Visibility,
107137
}
108138

109139
/// Data for extern crates.
@@ -135,6 +165,8 @@ pub struct FunctionData {
135165
pub span: Span,
136166
pub scope: NodeId,
137167
pub value: String,
168+
pub visibility: Visibility,
169+
pub parent: Option<NodeId>,
138170
}
139171

140172
/// Data about a function call.
@@ -215,6 +247,7 @@ pub struct MethodData {
215247
pub scope: NodeId,
216248
pub value: String,
217249
pub decl_id: Option<DefId>,
250+
pub visibility: Visibility,
218251
}
219252

220253
/// Data for modules.
@@ -227,6 +260,7 @@ pub struct ModData {
227260
pub scope: NodeId,
228261
pub filename: String,
229262
pub items: Vec<NodeId>,
263+
pub visibility: Visibility,
230264
}
231265

232266
/// Data for a reference to a module.
@@ -248,6 +282,7 @@ pub struct StructData {
248282
pub scope: NodeId,
249283
pub value: String,
250284
pub fields: Vec<NodeId>,
285+
pub visibility: Visibility,
251286
}
252287

253288
#[derive(Debug, RustcEncodable)]
@@ -258,7 +293,8 @@ pub struct StructVariantData {
258293
pub qualname: String,
259294
pub type_value: String,
260295
pub value: String,
261-
pub scope: NodeId
296+
pub scope: NodeId,
297+
pub parent: Option<NodeId>,
262298
}
263299

264300
#[derive(Debug, RustcEncodable)]
@@ -270,6 +306,7 @@ pub struct TraitData {
270306
pub scope: NodeId,
271307
pub value: String,
272308
pub items: Vec<NodeId>,
309+
pub visibility: Visibility,
273310
}
274311

275312
#[derive(Debug, RustcEncodable)]
@@ -280,7 +317,8 @@ pub struct TupleVariantData {
280317
pub qualname: String,
281318
pub type_value: String,
282319
pub value: String,
283-
pub scope: NodeId
320+
pub scope: NodeId,
321+
pub parent: Option<NodeId>,
284322
}
285323

286324
/// Data for a typedef.
@@ -291,6 +329,8 @@ pub struct TypeDefData {
291329
pub span: Span,
292330
pub qualname: String,
293331
pub value: String,
332+
pub visibility: Visibility,
333+
pub parent: Option<NodeId>,
294334
}
295335

296336
/// Data for a reference to a type or trait.
@@ -308,15 +348,17 @@ pub struct UseData {
308348
pub span: Span,
309349
pub name: String,
310350
pub mod_id: Option<DefId>,
311-
pub scope: NodeId
351+
pub scope: NodeId,
352+
pub visibility: Visibility,
312353
}
313354

314355
#[derive(Debug, RustcEncodable)]
315356
pub struct UseGlobData {
316357
pub id: NodeId,
317358
pub span: Span,
318359
pub names: Vec<String>,
319-
pub scope: NodeId
360+
pub scope: NodeId,
361+
pub visibility: Visibility,
320362
}
321363

322364
/// Data for local and global variables (consts and statics).
@@ -328,8 +370,10 @@ pub struct VariableData {
328370
pub qualname: String,
329371
pub span: Span,
330372
pub scope: NodeId,
373+
pub parent: Option<NodeId>,
331374
pub value: String,
332375
pub type_value: String,
376+
pub visibility: Visibility,
333377
}
334378

335379
#[derive(Debug, RustcEncodable)]

0 commit comments

Comments
 (0)