Skip to content

Commit 24ea08e

Browse files
committedMay 11, 2017
Auto merge of #41905 - frewsxcv:rollup, r=frewsxcv
Rollup of 5 pull requests - Successful merges: #41192, #41724, #41873, #41877, #41889 - Failed merges:
2 parents 1d46840 + 00f6e39 commit 24ea08e

File tree

23 files changed

+296
-128
lines changed

23 files changed

+296
-128
lines changed
 

Diff for: ‎src/doc/unstable-book/src/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
- [peek](library-features/peek.md)
179179
- [placement_in](library-features/placement-in.md)
180180
- [placement_new_protocol](library-features/placement-new-protocol.md)
181-
- [print](library-features/print.md)
181+
- [print_internals](library-features/print-internals.md)
182182
- [proc_macro_internals](library-features/proc-macro-internals.md)
183183
- [process_try_wait](library-features/process-try-wait.md)
184184
- [question_mark_carrier](library-features/question-mark-carrier.md)

Diff for: ‎src/doc/unstable-book/src/library-features/print.md renamed to ‎src/doc/unstable-book/src/library-features/print-internals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `print`
1+
# `print_internals`
22

33
This feature is internal to the Rust compiler and is not intended for general use.
44

Diff for: ‎src/librustc/dep_graph/dep_node.rs

+16
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ pub enum DepNode<D: Clone + Debug> {
159159
DefSpan(D),
160160
Stability(D),
161161
Deprecation(D),
162+
ItemBodyNestedBodies(D),
163+
ConstIsRvaluePromotableToStatic(D),
164+
ImplParent(D),
165+
TraitOfItem(D),
166+
IsExportedSymbol(D),
167+
IsMirAvailable(D),
168+
ItemAttrs(D),
169+
FnArgNames(D),
162170
FileMap(D, Arc<String>),
163171
}
164172

@@ -273,6 +281,14 @@ impl<D: Clone + Debug> DepNode<D> {
273281
DefSpan(ref d) => op(d).map(DefSpan),
274282
Stability(ref d) => op(d).map(Stability),
275283
Deprecation(ref d) => op(d).map(Deprecation),
284+
ItemAttrs(ref d) => op(d).map(ItemAttrs),
285+
FnArgNames(ref d) => op(d).map(FnArgNames),
286+
ImplParent(ref d) => op(d).map(ImplParent),
287+
TraitOfItem(ref d) => op(d).map(TraitOfItem),
288+
IsExportedSymbol(ref d) => op(d).map(IsExportedSymbol),
289+
ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies),
290+
ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic),
291+
IsMirAvailable(ref d) => op(d).map(IsMirAvailable),
276292
GlobalMetaData(ref d, kind) => op(d).map(|d| GlobalMetaData(d, kind)),
277293
FileMap(ref d, ref file_name) => op(d).map(|d| FileMap(d, file_name.clone())),
278294
}

Diff for: ‎src/librustc/middle/cstore.rs

-12
Original file line numberDiff line numberDiff line change
@@ -210,27 +210,21 @@ pub trait CrateStore {
210210
fn visibility(&self, def: DefId) -> ty::Visibility;
211211
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
212212
fn item_generics_cloned(&self, def: DefId) -> ty::Generics;
213-
fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>;
214-
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
215213

216214
// trait info
217215
fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId>;
218216

219217
// impl info
220218
fn impl_defaultness(&self, def: DefId) -> hir::Defaultness;
221-
fn impl_parent(&self, impl_def_id: DefId) -> Option<DefId>;
222219

223220
// trait/impl-item info
224-
fn trait_of_item(&self, def_id: DefId) -> Option<DefId>;
225221
fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem;
226222

227223
// flags
228224
fn is_const_fn(&self, did: DefId) -> bool;
229225
fn is_default_impl(&self, impl_did: DefId) -> bool;
230-
fn is_foreign_item(&self, did: DefId) -> bool;
231226
fn is_dllimport_foreign_item(&self, def: DefId) -> bool;
232227
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool;
233-
fn is_exported_symbol(&self, def_id: DefId) -> bool;
234228

235229
// crate metadata
236230
fn dylib_dependency_formats(&self, cnum: CrateNum)
@@ -337,28 +331,22 @@ impl CrateStore for DummyCrateStore {
337331
}
338332
fn item_generics_cloned(&self, def: DefId) -> ty::Generics
339333
{ bug!("item_generics_cloned") }
340-
fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]> { bug!("item_attrs") }
341-
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
342334

343335
// trait info
344336
fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId> { vec![] }
345337

346338
// impl info
347339
fn impl_defaultness(&self, def: DefId) -> hir::Defaultness { bug!("impl_defaultness") }
348-
fn impl_parent(&self, def: DefId) -> Option<DefId> { bug!("impl_parent") }
349340

350341
// trait/impl-item info
351-
fn trait_of_item(&self, def_id: DefId) -> Option<DefId> { bug!("trait_of_item") }
352342
fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem
353343
{ bug!("associated_item_cloned") }
354344

355345
// flags
356346
fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
357347
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
358-
fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") }
359348
fn is_dllimport_foreign_item(&self, id: DefId) -> bool { false }
360349
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool { false }
361-
fn is_exported_symbol(&self, def_id: DefId) -> bool { false }
362350

363351
// crate metadata
364352
fn dylib_dependency_formats(&self, cnum: CrateNum)

Diff for: ‎src/librustc/middle/effect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> {
205205
} else if match self.tcx.hir.get_if_local(def_id) {
206206
Some(hir::map::NodeForeignItem(..)) => true,
207207
Some(..) => false,
208-
None => self.tcx.sess.cstore.is_foreign_item(def_id),
208+
None => self.tcx.is_foreign_item(def_id),
209209
} {
210210
self.require_unsafe_ext(expr.id, expr.span, "use of extern static", true);
211211
}

Diff for: ‎src/librustc/ty/maps.rs

+39-7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use std::ops::Deref;
3434
use std::rc::Rc;
3535
use syntax_pos::{Span, DUMMY_SP};
3636
use syntax::attr;
37+
use syntax::ast;
3738
use syntax::symbol::Symbol;
3839

3940
pub trait Key: Clone + Hash + Eq + Debug {
@@ -340,6 +341,36 @@ impl<'tcx> QueryDescription for queries::deprecation<'tcx> {
340341
}
341342
}
342343

344+
impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
345+
fn describe(_: TyCtxt, _: DefId) -> String {
346+
bug!("item_attrs")
347+
}
348+
}
349+
350+
impl<'tcx> QueryDescription for queries::is_exported_symbol<'tcx> {
351+
fn describe(_: TyCtxt, _: DefId) -> String {
352+
bug!("is_exported_symbol")
353+
}
354+
}
355+
356+
impl<'tcx> QueryDescription for queries::fn_arg_names<'tcx> {
357+
fn describe(_: TyCtxt, _: DefId) -> String {
358+
bug!("fn_arg_names")
359+
}
360+
}
361+
362+
impl<'tcx> QueryDescription for queries::impl_parent<'tcx> {
363+
fn describe(_: TyCtxt, _: DefId) -> String {
364+
bug!("impl_parent")
365+
}
366+
}
367+
368+
impl<'tcx> QueryDescription for queries::trait_of_item<'tcx> {
369+
fn describe(_: TyCtxt, _: DefId) -> String {
370+
bug!("trait_of_item")
371+
}
372+
}
373+
343374
impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
344375
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
345376
format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
@@ -781,9 +812,14 @@ define_maps! { <'tcx>
781812
[] def_span: DefSpan(DefId) -> Span,
782813
[] stability: Stability(DefId) -> Option<attr::Stability>,
783814
[] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
784-
[] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
785-
[] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
786-
[] is_mir_available: metadata_dep_node(DefId) -> bool,
815+
[] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
816+
[] fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
817+
[] impl_parent: ImplParent(DefId) -> Option<DefId>,
818+
[] trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
819+
[] is_exported_symbol: IsExportedSymbol(DefId) -> bool,
820+
[] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
821+
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
822+
[] is_mir_available: IsMirAvailable(DefId) -> bool,
787823
}
788824

789825
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
@@ -798,10 +834,6 @@ fn reachability_dep_node(_: CrateNum) -> DepNode<DefId> {
798834
DepNode::Reachability
799835
}
800836

801-
fn metadata_dep_node(def_id: DefId) -> DepNode<DefId> {
802-
DepNode::MetaData(def_id)
803-
}
804-
805837
fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode<DefId> {
806838
instance.dep_node()
807839
}

Diff for: ‎src/librustc/ty/mod.rs

+17-18
Original file line numberDiff line numberDiff line change
@@ -2360,7 +2360,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23602360
if let Some(id) = self.hir.as_local_node_id(did) {
23612361
Attributes::Borrowed(self.hir.attrs(id))
23622362
} else {
2363-
Attributes::Owned(self.sess.cstore.item_attrs(did))
2363+
Attributes::Owned(self.item_attrs(did))
23642364
}
23652365
}
23662366

@@ -2396,7 +2396,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23962396
let trait_ref = self.impl_trait_ref(impl_def_id).unwrap();
23972397

23982398
// Record the trait->implementation mapping.
2399-
let parent = self.sess.cstore.impl_parent(impl_def_id).unwrap_or(trait_id);
2399+
let parent = self.impl_parent(impl_def_id).unwrap_or(trait_id);
24002400
def.record_remote_impl(self, impl_def_id, trait_ref, parent);
24012401
}
24022402

@@ -2433,22 +2433,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24332433
}
24342434
}
24352435

2436-
/// If the given def ID describes an item belonging to a trait,
2437-
/// return the ID of the trait that the trait item belongs to.
2438-
/// Otherwise, return `None`.
2439-
pub fn trait_of_item(self, def_id: DefId) -> Option<DefId> {
2440-
if def_id.krate != LOCAL_CRATE {
2441-
return self.sess.cstore.trait_of_item(def_id);
2442-
}
2443-
self.opt_associated_item(def_id)
2444-
.and_then(|associated_item| {
2445-
match associated_item.container {
2446-
TraitContainer(def_id) => Some(def_id),
2447-
ImplContainer(_) => None
2448-
}
2449-
})
2450-
}
2451-
24522436
/// Construct a parameter environment suitable for static contexts or other contexts where there
24532437
/// are no free type/lifetime parameters in scope.
24542438
pub fn empty_parameter_environment(self) -> ParameterEnvironment<'tcx> {
@@ -2688,13 +2672,28 @@ fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span {
26882672
tcx.hir.span_if_local(def_id).unwrap()
26892673
}
26902674

2675+
/// If the given def ID describes an item belonging to a trait,
2676+
/// return the ID of the trait that the trait item belongs to.
2677+
/// Otherwise, return `None`.
2678+
fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option<DefId> {
2679+
tcx.opt_associated_item(def_id)
2680+
.and_then(|associated_item| {
2681+
match associated_item.container {
2682+
TraitContainer(def_id) => Some(def_id),
2683+
ImplContainer(_) => None
2684+
}
2685+
})
2686+
}
2687+
2688+
26912689
pub fn provide(providers: &mut ty::maps::Providers) {
26922690
*providers = ty::maps::Providers {
26932691
associated_item,
26942692
associated_item_def_ids,
26952693
adt_sized_constraint,
26962694
adt_dtorck_constraint,
26972695
def_span,
2696+
trait_of_item,
26982697
..*providers
26992698
};
27002699
}

Diff for: ‎src/librustc_const_eval/eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn lookup_const_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
7474
// constants, we only try to find the expression for a
7575
// trait-associated const if the caller gives us the
7676
// substitutions for the reference to it.
77-
if tcx.sess.cstore.trait_of_item(def_id).is_some() {
77+
if tcx.trait_of_item(def_id).is_some() {
7878
resolve_trait_associated_const(tcx, def_id, substs)
7979
} else {
8080
Some((def_id, substs))

Diff for: ‎src/librustc_incremental/persist/hash.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> {
7979

8080
DepNode::FileMap(def_id, ref name) => {
8181
if def_id.is_local() {
82-
Some(self.incremental_hashes_map[dep_node])
82+
// We will have been able to retrace the DefId (which is
83+
// always the local CRATE_DEF_INDEX), but the file with the
84+
// given name might have been removed, so we use get() in
85+
// order to allow for that case.
86+
self.incremental_hashes_map.get(dep_node).map(|x| *x)
8387
} else {
8488
Some(self.metadata_hash(DepNode::FileMap(def_id, name.clone()),
8589
def_id.krate,

Diff for: ‎src/librustc_lint/builtin.rs

-1
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,6 @@ fn fl_lit_check_expr(cx: &EarlyContext, expr: &ast::Expr) {
718718
cx.span_lint(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
719719
l.span,
720720
"floating-point literals cannot be used in patterns");
721-
error!("span mc spanspam");
722721
},
723722
_ => (),
724723
}

Diff for: ‎src/librustc_metadata/cstore_impl.rs

+15-53
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ use rustc::hir::svh::Svh;
4141
use rustc_back::target::Target;
4242
use rustc::hir;
4343

44-
use std::collections::BTreeMap;
45-
4644
macro_rules! provide {
4745
(<$lt:tt> $tcx:ident, $def_id:ident, $cdata:ident $($name:ident => $compute:block)*) => {
4846
pub fn provide<$lt>(providers: &mut Providers<$lt>) {
@@ -113,21 +111,23 @@ provide! { <'tcx> tcx, def_id, cdata
113111
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
114112
stability => { cdata.get_stability(def_id.index) }
115113
deprecation => { cdata.get_deprecation(def_id.index) }
116-
item_body_nested_bodies => {
117-
let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| {
118-
ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body))
119-
}).collect();
120-
121-
Rc::new(map)
122-
}
114+
item_attrs => { cdata.get_item_attrs(def_id.index, &tcx.dep_graph) }
115+
// FIXME(#38501) We've skipped a `read` on the `HirBody` of
116+
// a `fn` when encoding, so the dep-tracking wouldn't work.
117+
// This is only used by rustdoc anyway, which shouldn't have
118+
// incremental recompilation ever enabled.
119+
fn_arg_names => { cdata.get_fn_arg_names(def_id.index) }
120+
impl_parent => { cdata.get_parent_impl(def_id.index) }
121+
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
122+
is_exported_symbol => {
123+
let dep_node = cdata.metadata_dep_node(GlobalMetaDataKind::ExportedSymbols);
124+
cdata.exported_symbols.get(&tcx.dep_graph, dep_node).contains(&def_id.index)
125+
}
126+
item_body_nested_bodies => { Rc::new(cdata.item_body_nested_bodies(def_id.index)) }
123127
const_is_rvalue_promotable_to_static => {
124-
cdata.entry(def_id.index).ast.expect("const item missing `ast`")
125-
.decode(cdata).rvalue_promotable_to_static
126-
}
127-
is_mir_available => {
128-
!cdata.is_proc_macro(def_id.index) &&
129-
cdata.maybe_entry(def_id.index).and_then(|item| item.decode(cdata).mir).is_some()
128+
cdata.const_is_rvalue_promotable_to_static(def_id.index)
130129
}
130+
is_mir_available => { cdata.is_item_mir_available(def_id.index) }
131131
}
132132

133133
impl CrateStore for cstore::CStore {
@@ -145,22 +145,6 @@ impl CrateStore for cstore::CStore {
145145
self.get_crate_data(def.krate).get_generics(def.index)
146146
}
147147

148-
fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>
149-
{
150-
self.get_crate_data(def_id.krate)
151-
.get_item_attrs(def_id.index, &self.dep_graph)
152-
}
153-
154-
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>
155-
{
156-
// FIXME(#38501) We've skipped a `read` on the `HirBody` of
157-
// a `fn` when encoding, so the dep-tracking wouldn't work.
158-
// This is only used by rustdoc anyway, which shouldn't have
159-
// incremental recompilation ever enabled.
160-
assert!(!self.dep_graph.is_fully_enabled());
161-
self.get_crate_data(did.krate).get_fn_arg_names(did.index)
162-
}
163-
164148
fn implementations_of_trait(&self, filter: Option<DefId>) -> Vec<DefId>
165149
{
166150
if let Some(def_id) = filter {
@@ -179,16 +163,6 @@ impl CrateStore for cstore::CStore {
179163
self.get_crate_data(def.krate).get_impl_defaultness(def.index)
180164
}
181165

182-
fn impl_parent(&self, impl_def: DefId) -> Option<DefId> {
183-
self.dep_graph.read(DepNode::MetaData(impl_def));
184-
self.get_crate_data(impl_def.krate).get_parent_impl(impl_def.index)
185-
}
186-
187-
fn trait_of_item(&self, def_id: DefId) -> Option<DefId> {
188-
self.dep_graph.read(DepNode::MetaData(def_id));
189-
self.get_crate_data(def_id.krate).get_trait_of_item(def_id.index)
190-
}
191-
192166
fn associated_item_cloned(&self, def: DefId) -> ty::AssociatedItem
193167
{
194168
self.dep_graph.read(DepNode::MetaData(def));
@@ -206,23 +180,11 @@ impl CrateStore for cstore::CStore {
206180
self.get_crate_data(impl_did.krate).is_default_impl(impl_did.index)
207181
}
208182

209-
fn is_foreign_item(&self, did: DefId) -> bool {
210-
self.get_crate_data(did.krate).is_foreign_item(did.index)
211-
}
212-
213183
fn is_statically_included_foreign_item(&self, def_id: DefId) -> bool
214184
{
215185
self.do_is_statically_included_foreign_item(def_id)
216186
}
217187

218-
fn is_exported_symbol(&self, def_id: DefId) -> bool {
219-
let data = self.get_crate_data(def_id.krate);
220-
let dep_node = data.metadata_dep_node(GlobalMetaDataKind::ExportedSymbols);
221-
data.exported_symbols
222-
.get(&self.dep_graph, dep_node)
223-
.contains(&def_id.index)
224-
}
225-
226188
fn is_dllimport_foreign_item(&self, def_id: DefId) -> bool {
227189
if def_id.krate == LOCAL_CRATE {
228190
self.dllimport_foreign_items.borrow().contains(&def_id.index)

0 commit comments

Comments
 (0)
Please sign in to comment.